|
|
@ -353,7 +353,9 @@ class TestResourceController extends BaseController
|
|
|
|
session('apply_status', 0);
|
|
|
|
session('apply_status', 0);
|
|
|
|
(empty(I('server_id')) || I('server_id')<1) && $this->ajaxReturn(['msg'=>$i_account.'请选择区服' ,'status'=>0]);
|
|
|
|
(empty(I('server_id')) || I('server_id')<1) && $this->ajaxReturn(['msg'=>$i_account.'请选择区服' ,'status'=>0]);
|
|
|
|
M('test_resource', 'tab_')->startTrans(); //事物
|
|
|
|
M('test_resource', 'tab_')->startTrans(); //事物
|
|
|
|
|
|
|
|
$resource = 0;
|
|
|
|
for ($i=0; $i < $count ; $i++) {
|
|
|
|
for ($i=0; $i < $count ; $i++) {
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$i_account=I('user_account')[$i];
|
|
|
|
$i_account=I('user_account')[$i];
|
|
|
|
if (!empty($i_account)) {
|
|
|
|
if (!empty($i_account)) {
|
|
|
|
$user=M('user', 'tab_')->field('promote_id,password,phone')->where(['account'=>$i_account])->find();
|
|
|
|
$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['create_time']=time();
|
|
|
|
$data['apply_type']=0;
|
|
|
|
$data['apply_type']=0;
|
|
|
|
$data = $this->checkAutoVerify($data);
|
|
|
|
$data = $this->checkAutoVerify($data, $resource);
|
|
|
|
$model = M('test_resource', 'tab_')->add($data);
|
|
|
|
$model = M('test_resource', 'tab_')->add($data);
|
|
|
|
|
|
|
|
$resource += $data['apply_resource'];
|
|
|
|
if ($model) {
|
|
|
|
if ($model) {
|
|
|
|
session('apply_status', 1);
|
|
|
|
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_')
|
|
|
|
$config = M('resource_verify_config', 'tab_')
|
|
|
|
->where(['game_id' => $data['game_id'], 'status' => 1])
|
|
|
|
->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']) {
|
|
|
|
if ($data['apply_resource'] >= $config['new_low_value'] && $data['apply_resource'] <= $config['new_high_value']) {
|
|
|
|
$data['verify_remark'] = '自动审核';
|
|
|
|
$data['verify_remark'] = '自动审核';
|
|
|
|
|
|
|
|
$data['verify_resource']= $data['apply_resource'];
|
|
|
|
$data['verify_time'] = time();
|
|
|
|
$data['verify_time'] = time();
|
|
|
|
$data['apply_status'] = 2;
|
|
|
|
$data['apply_status'] = 2;
|
|
|
|
|
|
|
|
$data['is_new'] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {//非新用户
|
|
|
|
} else {//非新用户
|
|
|
|
$promoteAllRecharge = sum_promote_total_money($data['promote_id']);//总充值量
|
|
|
|
$promoteAllRecharge = sum_promote_total_money($data['promote_id']);//总充值量
|
|
|
|
$autoVerifyValue = $promoteAllRecharge * $config['old_value_ratio'];
|
|
|
|
$allVerifyValue = $promoteAllRecharge * $config['old_value_ratio'];//可充值总量
|
|
|
|
if ($data['apply_resource'] <= $autoVerifyValue) {
|
|
|
|
//已用资源(申请通过的)
|
|
|
|
|
|
|
|
$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_remark'] = '自动审核';
|
|
|
|
|
|
|
|
$data['verify_resource']= $data['apply_resource'];
|
|
|
|
$data['verify_time'] = time();
|
|
|
|
$data['verify_time'] = time();
|
|
|
|
$data['apply_status'] = 2;
|
|
|
|
$data['apply_status'] = 2;
|
|
|
|
|
|
|
|
$data['is_new'] = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -519,8 +539,9 @@ class TestResourceController extends BaseController
|
|
|
|
$ids = explode(',', I('apply_id'));
|
|
|
|
$ids = explode(',', I('apply_id'));
|
|
|
|
|
|
|
|
|
|
|
|
M('test_resource','tab_')->startTrans(); //事物
|
|
|
|
M('test_resource','tab_')->startTrans(); //事物
|
|
|
|
|
|
|
|
$resource = 0;
|
|
|
|
foreach ($ids as $key => $value) {
|
|
|
|
foreach ($ids as $key => $value) {
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$map['id']=$value;
|
|
|
|
$map['id']=$value;
|
|
|
|
$support=M('test_resource','tab_')->where($map)->find();
|
|
|
|
$support=M('test_resource','tab_')->where($map)->find();
|
|
|
|
if(I('apply_resource') <0 || !preg_match('/^[1-9]\d*$/', I('apply_resource', 0))){
|
|
|
|
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['create_time']=time();
|
|
|
|
$data['apply_type']=1;
|
|
|
|
$data['apply_type']=1;
|
|
|
|
//
|
|
|
|
$data = $this->checkAutoVerify($data, $resource);
|
|
|
|
$model = M('test_resource','tab_')->add($data);
|
|
|
|
$model = M('test_resource','tab_')->add($data);
|
|
|
|
|
|
|
|
$resource += $data['apply_resource'];
|
|
|
|
if($model===false){
|
|
|
|
if($model===false){
|
|
|
|
M('test_resource','tab_')->rollback();//回滚
|
|
|
|
M('test_resource','tab_')->rollback();//回滚
|
|
|
|
$this->ajaxReturn(['status'=>0,'msg'=>'申请失败']);
|
|
|
|
$this->ajaxReturn(['status'=>0,'msg'=>'申请失败']);
|
|
|
|