市场专员业绩计算修正

master
zhengyongxing 4 years ago
parent 97161900ac
commit 9a23b5588b

@ -2645,4 +2645,85 @@ function withMarketAdminCondition($map, $searchMarketAdminId = 0)
$map['promote_id'] = ['in', $promoteIds]; $map['promote_id'] = ['in', $promoteIds];
} }
return $map; return $map;
}
function getMarketMonth() {
$start = date("Y-m", strtotime("+1 month"));
//开始月份
$range = [];
$i = 1;
do {
$month = date('Y-m', strtotime($start . ' - ' . $i . ' month'));
$range[] = $month;
$i++;
} while ($i<13);
return $range;
}
function getDateMarket() {
$admin_id = $_SESSION['onethink_admin']['user_auth']['uid'];
$map['access.uid'] = $admin_id;
if(is_administrator()) {
unset($map['access.uid']);
}
$data = M("member")
->field("access.uid admin_id,real_name,nickname,market_percentage")
->join("left join sys_auth_group_access access on sys_member.uid = access.uid")
->join("left join sys_auth_group auth on access.group_id=auth.id")
->where(['group_id'=>['in','11,12,21']])
->where($map)
->select();
$return = [];
$num = 0;
foreach ($data as $key => $value) {
$group_config = json_decode($value['market_percentage'],true);
$arr_month = getMarketMonth();
foreach ($arr_month as $k => $v) {
// var_dump($v);
$month = date("m",strtotime($v));
if ($group_config['time'] == 1) {
// echo $v.' '."\n";
if ($month == '07'||$month == '10'||$month == '04'||$month == '01') {
$return[$num]['admin_id'] = $value['admin_id'];
$return[$num]['real_name'] = $value['real_name'];
$return[$num]['pay_time'] = $v;
$num++;
}
} elseif($group_config['time'] == 2) {
if ($month == '07'||$month == '01') {
$return[$num]['admin_id'] = $value['admin_id'];
$return[$num]['real_name'] = $value['real_name'];
$return[$num]['pay_time'] = $v;
$num++;
}
} elseif($group_config['time'] == 3) {
if ($month == '01') {
$return[$num]['admin_id'] = $value['admin_id'];
$return[$num]['real_name'] = $value['real_name'];
$return[$num]['pay_time'] = $v;
$num++;
}
} else {
$return[$num]['admin_id'] = $value['admin_id'];
$return[$num]['real_name'] = $value['real_name'];
$return[$num]['pay_time'] = $v;
$num++;
}
}
}
// dump($return);
return $return;
} }

@ -336,6 +336,7 @@ class MarketPercentageController extends ThinkController
public function personMarketStaffSettle($row = 10, $p = 1) { public function personMarketStaffSettle($row = 10, $p = 1) {
// getDateMarket();die();
$map = []; $map = [];
$map['group_id'] = ['in','11,12,21']; $map['group_id'] = ['in','11,12,21'];
@ -605,7 +606,7 @@ class MarketPercentageController extends ThinkController
->where($map) ->where($map)
->group("admin_id,pay_time") ->group("admin_id,pay_time")
->select(); ->select();
// dump($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,
@ -732,7 +733,7 @@ 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($value['pay_time'])))];
} }
@ -744,6 +745,7 @@ class MarketPercentageController extends ThinkController
$insert['pay_amount'] = $data[$key]['pay_amount']; $insert['pay_amount'] = $data[$key]['pay_amount'];
$insert['extend_commission'] = $data[$key]['extend_commission']; $insert['extend_commission'] = $data[$key]['extend_commission'];
$insert['wait_commission'] = $data[$key]['wait_commission']; $insert['wait_commission'] = $data[$key]['wait_commission'];
// dump($insert['extend_commission']);
$insert['remark'] = "{$data[$key]['nickname']}发起提成发放"; $insert['remark'] = "{$data[$key]['nickname']}发起提成发放";
if ($_REQUEST['all']) { if ($_REQUEST['all']) {
$insert['remark'] = '离职发放'; $insert['remark'] = '离职发放';
@ -774,6 +776,59 @@ class MarketPercentageController extends ThinkController
} }
//遍历统计数据
$data = M("market_altogether","tab_")
->join("left join sys_auth_group_access access on admin_id=access.uid")
->join("left join sys_auth_group auth on access.group_id=auth.id")
->join("left join sys_member member on access.uid=member.uid")
->where(['pay_time'=>$_REQUEST['pay_time'],'admin_id'=>$_REQUEST['admin_id']])
->select();
// dump($map['pay_time']);die();
foreach($data as $key => $value) {
$market_percentage = json_decode($value['market_percentage'],true);
if ($market_percentage['time'] == 1) {
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'];
} 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'];
} 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'];
} 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'];
}
} elseif($market_percentage['time'] == 2) {
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'] +
$wait_amount[$value['admin_id'].$yes.'-'.'04'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'];
} 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'] +
$wait_amount[$value['admin_id'].($yes-1).'-'.'10'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'];
}
} elseif($market_percentage['time'] == 3) {
if ($month == '01') {
$data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '01'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '02'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '03'] +
$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) . '-' . '10'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '11'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '12'];
}
} else {
$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'];
M("market_altogether","tab_")
->where(['pay_time'=>$data[$key]['pay_time'],'admin_id'=>$data[$key]['admin_id']])
->save($update);
}
$this->ajaxReturn(['status'=>1,'msg'=>'发放成功']); $this->ajaxReturn(['status'=>1,'msg'=>'发放成功']);
} }

@ -119,10 +119,8 @@
<td> <td>
<select id="time" class="select_gallery" style="width:120px;"> <select id="time" class="select_gallery" style="width:120px;">
<option value="">请选择时间</option> <option value="">请选择时间</option>
<volist name="list_data" id="s_data"> <volist name=":getDateMarket()" id="s_data">
<if condition="$s_data['is_send_use'] eq 1">
<option value="{$s_data['pay_time']}" data-admin_id="{$s_data.admin_id}">{$s_data['pay_time']}({$s_data['real_name']})</option> <option value="{$s_data['pay_time']}" data-admin_id="{$s_data.admin_id}">{$s_data['pay_time']}({$s_data['real_name']})</option>
</if>
</volist> </volist>
</select> </select>
<a style="background: #3C95C8;font-size: 14px;font-weight: normal;color: #fff;cursor: pointer;border-radius: 3px;display: inline-block;text-align: center;border-bottom: none;width: 55px;height: 28px;line-height: 28px;text-indent:0" <a style="background: #3C95C8;font-size: 14px;font-weight: normal;color: #fff;cursor: pointer;border-radius: 3px;display: inline-block;text-align: center;border-bottom: none;width: 55px;height: 28px;line-height: 28px;text-indent:0"

Loading…
Cancel
Save