From 5d05edbca67fcd8977f7994a6cd1c1a08c7ba9b8 Mon Sep 17 00:00:00 2001 From: liuweiwen <“529520975@qq.com> Date: Thu, 27 Feb 2020 12:14:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=87=AA=E5=8A=A8=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E6=89=A3=E9=99=A4=E5=B7=B2=E5=AE=A1=E6=A0=B8=E9=A2=9D?= =?UTF-8?q?=E5=BA=A6=EF=BC=8C=E7=94=B3=E8=AF=B7=E5=90=8E=E7=BB=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=87=AA=E5=8A=A8=E5=AE=A1=E6=A0=B8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestResourceController.class.php | 34 +++++++++++++++---- Data/update.sql | 2 ++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Application/Home/Controller/TestResourceController.class.php b/Application/Home/Controller/TestResourceController.class.php index 31e844304..2febe1a97 100644 --- a/Application/Home/Controller/TestResourceController.class.php +++ b/Application/Home/Controller/TestResourceController.class.php @@ -353,7 +353,9 @@ class TestResourceController extends BaseController session('apply_status', 0); (empty(I('server_id')) || I('server_id')<1) && $this->ajaxReturn(['msg'=>$i_account.'请选择区服' ,'status'=>0]); M('test_resource', 'tab_')->startTrans(); //事物 + $resource = 0; for ($i=0; $i < $count ; $i++) { + $data = array(); $i_account=I('user_account')[$i]; if (!empty($i_account)) { $user=M('user', 'tab_')->field('promote_id,password,phone')->where(['account'=>$i_account])->find(); @@ -426,8 +428,9 @@ class TestResourceController extends BaseController $data['create_time']=time(); $data['apply_type']=0; - $data = $this->checkAutoVerify($data); + $data = $this->checkAutoVerify($data, $resource); $model = M('test_resource', 'tab_')->add($data); + $resource += $data['apply_resource']; if ($model) { session('apply_status', 1); } @@ -453,7 +456,7 @@ class TestResourceController extends BaseController /** *判断申请资源是否自动审核 */ - private function checkAutoVerify($data) + private function checkAutoVerify($data, $resource = 0) { $config = M('resource_verify_config', 'tab_') ->where(['game_id' => $data['game_id'], 'status' => 1]) @@ -466,19 +469,36 @@ class TestResourceController extends BaseController //申请资源数量在最低额度和最高额度之间,自动审核 if ($data['apply_resource'] >= $config['new_low_value'] && $data['apply_resource'] <= $config['new_high_value']) { $data['verify_remark'] = '自动审核'; + $data['verify_resource']= $data['apply_resource']; $data['verify_time'] = time(); $data['apply_status'] = 2; + $data['is_new'] = 1; } } else {//非新用户 $promoteAllRecharge = sum_promote_total_money($data['promote_id']);//总充值量 - $autoVerifyValue = $promoteAllRecharge * $config['old_value_ratio']; - if ($data['apply_resource'] <= $autoVerifyValue) { + $allVerifyValue = $promoteAllRecharge * $config['old_value_ratio'];//可充值总量 + //已用资源(申请通过的) + $used_resource = M('test_resource', 'tab_') + ->where([ + 'promote_id' => $data['promote_id'], + 'game_id' => $data['game_id'], + 'apply_status' => 2, + 'is_new' => 2, + ]) + ->getField('SUM(verify_resource) as used_resource'); + $used_resource = $used_resource ?: 0; + $usable_resource = $allVerifyValue - $used_resource;//小于等于这个值自动审核 + $usable_resource -= $resource; + if ($data['apply_resource'] <= $usable_resource) { $data['verify_remark'] = '自动审核'; + $data['verify_resource']= $data['apply_resource']; $data['verify_time'] = time(); $data['apply_status'] = 2; + $data['is_new'] = 2; } } } + return $data; } @@ -519,8 +539,9 @@ class TestResourceController extends BaseController $ids = explode(',', I('apply_id')); M('test_resource','tab_')->startTrans(); //事物 + $resource = 0; foreach ($ids as $key => $value) { - + $data = array(); $map['id']=$value; $support=M('test_resource','tab_')->where($map)->find(); if(I('apply_resource') <0 || !preg_match('/^[1-9]\d*$/', I('apply_resource', 0))){ @@ -574,8 +595,9 @@ class TestResourceController extends BaseController $data['create_time']=time(); $data['apply_type']=1; - // + $data = $this->checkAutoVerify($data, $resource); $model = M('test_resource','tab_')->add($data); + $resource += $data['apply_resource']; if($model===false){ M('test_resource','tab_')->rollback();//回滚 $this->ajaxReturn(['status'=>0,'msg'=>'申请失败']); diff --git a/Data/update.sql b/Data/update.sql index 468a889e0..62d9a4093 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -1374,3 +1374,5 @@ CREATE TABLE `tab_resource_verify_config` ( `update_time` int(11) DEFAULT '0' COMMENT '更新时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='资源审核配置'; + +ALTER TABLE tab_test_resource ADD COLUMN `is_new` tinyint(1) DEFAULT '0' COMMENT '0-未知;1-新用户;2-非新用户';