Merge branch 'feature/market_percentage' of wmtx/platform into release

市场专员业绩bug修改
master
廖金灵 4 years ago committed by Gogs
commit e6d791ae3c

@ -543,6 +543,17 @@ class MarketPercentageController extends ThinkController
$this->ajaxReturn(['status'=>0,'msg'=>'数据错误']); $this->ajaxReturn(['status'=>0,'msg'=>'数据错误']);
} }
$check_data = M("market_altogether","tab_")
->where(['pay_time'=>$_REQUEST['pay_time'],'admin_id'=>$_REQUEST['admin_id']])
->find();
// dump($check_data);die();
if (!$_REQUEST['all']&&$check_data) {
if ($check_data['type'] > 0 || $check_data['extend_commission']!='0.00'||($check_data['type'] == 0&&$check_data['extend_commission']=='0.00')) {
$this->ajaxReturn(['status'=>0,'msg'=>'已经发放过']);
}
}
$this->insertAllUserBonus($_REQUEST['pay_time'],$_REQUEST['admin_id']); $this->insertAllUserBonus($_REQUEST['pay_time'],$_REQUEST['admin_id']);
$group_config = M("auth_group_access access") $group_config = M("auth_group_access access")
@ -605,7 +616,11 @@ class MarketPercentageController extends ThinkController
->where($map) ->where($map)
->group("admin_id,pay_time") ->group("admin_id,pay_time")
->select(); ->select();
// dump($data);die(); // dump(end($data));die();
$all_data = M("settleup_marketorder","tab_") $all_data = M("settleup_marketorder","tab_")
->field("tab_settleup_marketorder.id,pay_time,promote_account,company_belong,member.real_name,develop_type,game_name, ->field("tab_settleup_marketorder.id,pay_time,promote_account,company_belong,member.real_name,develop_type,game_name,
sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage,nickname,admin_id, sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage,nickname,admin_id,
@ -648,6 +663,8 @@ class MarketPercentageController extends ThinkController
} }
$wait_commission = 0;
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if ($value['group_id'] == 21) { if ($value['group_id'] == 21) {
@ -719,9 +736,15 @@ class MarketPercentageController extends ThinkController
if ($month == '07') { if ($month == '07') {
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'] + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'] +
$wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06']; $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
if ($_REQUEST['all']&&$check_month==$month) {
$data[$key]['extend_commission'] += $data[$key]['wait_commission'];
}
} elseif($month == '01') { } elseif($month == '01') {
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'] + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'] +
$wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12']; $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
if ($_REQUEST['all']&&$check_month==$month) {
$data[$key]['extend_commission'] += $data[$key]['wait_commission'];
}
} }
} elseif($market_percentage['time'] == 3) { } elseif($market_percentage['time'] == 3) {
if ($month == '01') { if ($month == '01') {
@ -729,10 +752,16 @@ class MarketPercentageController extends ThinkController
$wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '04'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '05'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '06'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '04'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '05'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '06'] +
$wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '07'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '08'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '09'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '07'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '08'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '09'] +
$wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '10'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '11'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '12']; $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '10'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '11'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '12'];
if ($_REQUEST['all']&&$check_month==$month) {
$data[$key]['extend_commission'] += $data[$key]['wait_commission'];
}
} }
} }
else { else {
$data[$key]['extend_commission'] +=$wait_amount[$value['admin_id'] . date("Y-m",strtotime("last month",strtotime($value['pay_time'])))]; $data[$key]['extend_commission'] +=$wait_amount[$value['admin_id'] . date("Y-m",strtotime("last month",strtotime($value['pay_time'])))];
if ($_REQUEST['all']&&$check_month==$month) {
$data[$key]['extend_commission'] += $data[$key]['wait_commission'];
}
} }
$insert['pay_time'] = $data[$key]['pay_time']; $insert['pay_time'] = $data[$key]['pay_time'];
@ -746,6 +775,9 @@ class MarketPercentageController extends ThinkController
// dump($insert['extend_commission']); // dump($insert['extend_commission']);
$insert['remark'] = "{$data[$key]['nickname']}发起提成发放"; $insert['remark'] = "{$data[$key]['nickname']}发起提成发放";
if ($_REQUEST['all']) { if ($_REQUEST['all']) {
if ($check_month==$month) {
$wait_commission = $data[$key]['wait_commission'];
}
$insert['remark'] = '离职发放'; $insert['remark'] = '离职发放';
$insert['type'] = 1; $insert['type'] = 1;
} elseif($month != $check_month) { } elseif($month != $check_month) {
@ -794,16 +826,37 @@ class MarketPercentageController extends ThinkController
} }
$market_percentage = json_decode($value['market_percentage'],true); $market_percentage = json_decode($value['market_percentage'],true);
// $month = date("m",strtotime($value['pay_time'])); // $month = date("m",strtotime($value['pay_time']));
$month = date("m",strtotime($value['pay_time']));
$yes = date("Y",strtotime($value['pay_time']));
$check_month = date("m",strtotime($_REQUEST['pay_time']));
if ($market_percentage['time'] == 1) { if ($market_percentage['time'] == 1) {
if ($month == '07') { if ($month == '07') {
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03']; $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'];
if ($_REQUEST['all']&&$check_month==$month) {
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] +
$wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
}
} elseif($month == '10') { } elseif($month == '10') {
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06']; $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
if ($_REQUEST['all']&&$check_month==$month) {
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] +
$wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
}
} elseif($month == '04') { } elseif($month == '04') {
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12']; $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
if ($_REQUEST['all']&&$check_month==$month) {
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] +
$wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
}
} elseif($month == '01') { } elseif($month == '01') {
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09']; $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'];
if ($_REQUEST['all']&&$check_month==$month) {
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'] +
$wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
}
} }
} elseif($market_percentage['time'] == 2) { } elseif($market_percentage['time'] == 2) {
@ -824,10 +877,11 @@ class MarketPercentageController extends ThinkController
} }
} else { } else {
$data[$key]['extend_commission'] +=$wait_amount[$value['admin_id'] . date("Y-m",strtotime("last month",strtotime($_REQUEST['pay_time'])))]; $data[$key]['extend_commission'] +=$wait_amount[$value['admin_id'] . date("Y-m",strtotime("last month",strtotime($_REQUEST['pay_time'])))];
} }
$update['extend_commission'] = $data[$key]['extend_commission']; $update['extend_commission'] = $data[$key]['extend_commission'];
// var_dump($sign);
if ($sign) { if ($sign) {
M("market_altogether","tab_") M("market_altogether","tab_")
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']]) ->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
@ -836,6 +890,14 @@ class MarketPercentageController extends ThinkController
} }
if ($_REQUEST['all']) {
M("market_altogether","tab_")
->where(['admin_id'=>$_REQUEST['admin_id']])
->save(['type'=>1]);
}
$this->ajaxReturn(['status'=>1,'msg'=>'发放成功']); $this->ajaxReturn(['status'=>1,'msg'=>'发放成功']);
} }
@ -867,7 +929,7 @@ class MarketPercentageController extends ThinkController
$_REQUEST['level']?$map['group_id'] = $_REQUEST['level']:''; $_REQUEST['level']?$map['group_id'] = $_REQUEST['level']:'';
$data = M("market_altogether","tab_") $data = M("market_altogether","tab_")
->field("max(pay_time) pay_time,real_name,admin_id,nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission, sum(wait_commission) wait_commission,remark,group_id,max(type) type") ->field("max(pay_time) pay_time,real_name,admin_id,nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission, sum(wait_commission) wait_commission,remark,group_id,type")
->join("left join sys_auth_group_access access on admin_id=access.uid") ->join("left join sys_auth_group_access access on admin_id=access.uid")
->where($map); ->where($map);
if ($_REQUEST['export']) { if ($_REQUEST['export']) {

@ -265,6 +265,7 @@
layer.confirm('是否确认发放提成!', { layer.confirm('是否确认发放提成!', {
title:'发放提成?', title:'发放提成?',
icon:0, icon:0,
closeBtn:0,
btn: ['发放','离职发放','取消'] //按钮 btn: ['发放','离职发放','取消'] //按钮
}, function(){ }, function(){
$.ajax({ $.ajax({

Loading…
Cancel
Save