diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index f79511da6..1ee9ab7e5 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2645,4 +2645,85 @@ function withMarketAdminCondition($map, $searchMarketAdminId = 0) $map['promote_id'] = ['in', $promoteIds]; } 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; + } \ No newline at end of file diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php index a4eaf5d6b..54425a723 100644 --- a/Application/Admin/Controller/MarketPercentageController.class.php +++ b/Application/Admin/Controller/MarketPercentageController.class.php @@ -336,6 +336,7 @@ class MarketPercentageController extends ThinkController public function personMarketStaffSettle($row = 10, $p = 1) { +// getDateMarket();die(); $map = []; $map['group_id'] = ['in','11,12,21']; @@ -605,7 +606,7 @@ class MarketPercentageController extends ThinkController ->where($map) ->group("admin_id,pay_time") ->select(); - +// dump($data);die(); $all_data = M("settleup_marketorder","tab_") ->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, @@ -732,7 +733,7 @@ class MarketPercentageController extends ThinkController } } 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['extend_commission'] = $data[$key]['extend_commission']; $insert['wait_commission'] = $data[$key]['wait_commission']; +// dump($insert['extend_commission']); $insert['remark'] = "{$data[$key]['nickname']}发起提成发放"; if ($_REQUEST['all']) { $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'=>'发放成功']); } diff --git a/Application/Admin/View/MarketPercentage/personmarketstaffsettle.html b/Application/Admin/View/MarketPercentage/personmarketstaffsettle.html index f4d9b2ee2..7bd0cc930 100644 --- a/Application/Admin/View/MarketPercentage/personmarketstaffsettle.html +++ b/Application/Admin/View/MarketPercentage/personmarketstaffsettle.html @@ -119,10 +119,8 @@