diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 8d73aa48c..d2a649338 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -1424,7 +1424,7 @@ function get_promote_levels($id = 0) case '4': return "组员"; break; - + default: return ''; } @@ -1932,7 +1932,7 @@ function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_ } $pay_amount_str .= "J{$line}+"; $objPHPExcel->getActiveSheet()->setCellValue('D'.$line, $product_name); - + $line++; } @@ -1993,7 +1993,7 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al if ($data['withdraw_type'] == '2') { $objPHPExcel->getActiveSheet()->setCellValue('D2','补点比例'); } - + $line = 3; $pay_amount_str = "="; @@ -2292,6 +2292,32 @@ function a_array_unique($array){ return $data; } } +/** + * 获取团体归属类型其他 + * @author chenzhi 20200219 + * $id 不传返回所有类型列表 + * 传入ID 返回对应的团体类型 + */ +function getCompanyBlongOther($id = -1) +{ + $data = array( + ["id"=>0,'name'=>"内团"], + ["id"=>1,'name'=>"外团"], + ["id"=>2,'name'=>"外团-分发"], + ["id"=>3,'name'=>"无"], + ["id"=>'1,2','name'=>"外团&外团-分发"] + ); + if($id > -1){ + foreach($data as $k=>$v){ + if($v['id'] == $id){ + return $v['name']; + break; + } + } + }else{ + return $data; + } +} /** * 获取公会归属关系 * @author chenzhi 20200219 @@ -2544,7 +2570,7 @@ function isMarketLeader() } $userAuth = session('user_auth'); $adminIds = M('auth_group_access', 'sys_')->where(['group_id' => $authGroup['id']])->getField('uid', true); - return in_array($userAuth['uid'], $adminIds); + return in_array($userAuth['uid'], $adminIds); } function isMarketAdmin() @@ -2557,6 +2583,46 @@ function isMarketAdmin() $adminIds = M('auth_group_access', 'sys_')->where(['group_id' => ['in', $ids]])->getField('uid', true); return in_array($userAuth['uid'], $adminIds); } +/** + * + * 获取市场专员 + * + */ +function getMarketAdmin() { + + $map['group_id'] = ['in','11,12,21']; + $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; + $map['menber.uid'] = $admin_id; + if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14) { + unset($map['menber.uid']); + } + + $data = M("auth_group_access") + ->field("real_name,menber.uid,nickname") + ->join("left join sys_member menber on sys_auth_group_access.uid = menber.uid") + ->where($map) + ->select(); + + foreach ($data as $key => $value) { + !$value['real_name'] ? ($data[$key]['real_name'] = "未命名"):""; + } + + return $data; +} + +function is_sendBonus($pay_time = '',$admin_id = '') { + + $market_altogether = M("market_altogether","tab_") + ->where(['pay_time'=>$pay_time,'admin_id'=>$admin_id]) + ->find(); + + if ($market_altogether['status'] > 0) { + return 1; + } else { + return 0; + } + +} function getPromoteIdsByTopIds($ids) { @@ -2578,7 +2644,17 @@ function getCompanyDevelopTypes() return [ 1 => '自主开发', 2 => '自主开发及维护', - 3 => '只维护' + 3 => '只维护', + ]; +} + +function getCompanyDevelopTypesOther() +{ + return [ + 1 => '自主开发', + 2 => '自主开发及维护', + 3 => '只维护', + '1,2'=>'自主开发&自主开发及维护' ]; } @@ -2609,4 +2685,125 @@ function withMarketAdminCondition($map, $searchMarketAdminId = 0) $map['promote_id'] = ['in', $promoteIds]; } return $map; +} + +function getMarketMonth() { + $start = date("Y-m", strtotime("+4 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; + +} + +/** + * 渠道列表 + * @param $type + * @return mixed + */ +function promote_listsMarket($type){ + if($type){ + $map['level'] = $type; + } else{ + $map = ''; + } + +// $promoteRoot = getPowerPromoteIds(); +// if ($promoteRoot) { +// $map['id'] =array('in',$promoteRoot); +// } + + setPowerPromoteIds($map,'id'); + + $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; + $map['admin_id'] = $admin_id; + if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14) { + unset($map['admin_id']); + } + + $data = M('promote','tab_')->where($map)->select(); + + $items = M('PromoteBalanceCoin', 'tab_')->where(['game_id' => 0])->select(); + $records = []; + foreach ($items as $item) { + $records[$item['promote_id']] = $item['num']; + } + foreach ($data as $key => $item) { + $item['common_coin'] = isset($records[$item['id']]) ? $records[$item['id']] : $item['balance_coin']; + $data[$key] = $item; + } + + return $data; } \ No newline at end of file diff --git a/Application/Admin/Controller/AdminController.class.php b/Application/Admin/Controller/AdminController.class.php index 55629e82a..133778918 100644 --- a/Application/Admin/Controller/AdminController.class.php +++ b/Application/Admin/Controller/AdminController.class.php @@ -640,15 +640,22 @@ class AdminController extends Controller { public function checkListOrCountAuthRestMap(&$map,$checkarr = false,$countfield = "rule_count_check"){ //验证count if(IS_ROOT){ + $this->assign('caculate_check',true); + $this->assign('send_bonus_check',true); $this->assign('role_export_check',true); $this->assign($countfield,true); }else{ $exportRule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME."_export_check"); -// var_dump($this->checkRule($exportRule,array('in','1,2')));die(); - $this->assign('role_export_check',$this->checkRule($exportRule,array('in','1,2'))); + $sendBonus = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME."_send_bonus_check"); + $this->assign('send_bonus_check',$this->checkRule($sendBonus,array('in','1,2'))); + + $caculateRule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME."_caculate_check"); + + $this->assign('caculate_check',$this->checkRule($caculateRule,array('in','1,2'))); + $countRule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME."_count_check"); $this->assign($countfield,$this->checkRule($countRule,array('in','1,2'))); diff --git a/Application/Admin/Controller/AuthManagerController.class.php b/Application/Admin/Controller/AuthManagerController.class.php index dd1d5627c..c72fca0cf 100644 --- a/Application/Admin/Controller/AuthManagerController.class.php +++ b/Application/Admin/Controller/AuthManagerController.class.php @@ -595,4 +595,40 @@ class AuthManagerController extends AdminController{ $this->ajaxReturn(json_encode($returnData)); } + function AuthMarketMember() { + + $gid = I('group_id'); + + $data = $_POST; + + $AuthGroup = D('AuthGroup'); + if( !$AuthGroup->find($gid)){ + $this->error('用户组不存在'); + } + + if (IS_POST) { + + $data = json_encode($data); + + $AuthGroup->where(['id'=>$gid])->save(['market_percentage'=>$data]); + + $this->success("编辑成功",U("index")); + + } else { + + $auth_group = M('AuthGroup')->where( array('status'=>array('egt','0'),'module'=>'admin','type'=>AuthGroupModel::TYPE_ADMIN) ) + ->getfield('id,id,title,rules'); + $data = $AuthGroup->where(['id'=>$gid])->find(); + + $data['market_percentage'] = json_decode($data['market_percentage'],true); + $this->assign('data',$data['market_percentage']); + $this->assign('auth_group', $auth_group); + + $this->display("authmarketmember"); + } + + + + } + } diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index f9e332b9f..929355e79 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -3873,16 +3873,21 @@ class ExportController extends Controller $this->meta_title = '留存统计'; $start = I('start', date('Y-m-d',strtotime('-7 day'))); $end = empty(I('end')) ? time_format(time(),'Y-m-d') : I('end'); - $gameId = I('game_id', 0); $promoteId = I('promote_id', 0); + $baseGameId = I('game_id', 0); + $deviceType = I('device_type', ''); $status = true; $data = false; $error = ''; - if ($gameId == 0) { + if ($baseGameId == 0) { $error = '请选择游戏!'; $status = false; } + if ($deviceType == '') { + $error = '请选择设备类型!'; + $status = false; + } $startTime = strtotime($start . ' 00:00:00'); $endTime = strtotime($end . ' 23:59:59') + 1; if ((($endTime - $startTime)/(24*3600)) > 31) { @@ -3890,6 +3895,10 @@ class ExportController extends Controller $status = false; } if ($status) { + + $baseGame = M('base_game', 'tab_')->where(['id' => $baseGameId])->find(); + $gameId = $deviceType == 'android' ? $baseGame['android_game_id'] : $baseGame['ios_game_id']; + $client = new Client([ 'base_uri' => C('TASK_URL'), 'timeout' => 10.0, diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index 742036f1f..ffb8dcf53 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -241,7 +241,7 @@ class FinancePromoteController extends AdminController } if (isset($_REQUEST['company_belong'])) { $map['promote.company_belong'] = $_REQUEST['company_belong']; - + } $isMarketLeader = isMarketLeader(); if ($isMarketLeader) { @@ -249,7 +249,7 @@ class FinancePromoteController extends AdminController } if (!empty(I('develop_type'))) { - $map['company.develop_type'] = I('develop_type'); + $map['company.develop_type'] = ['in',I('develop_type')]; } $adminId = 0; @@ -275,6 +275,9 @@ class FinancePromoteController extends AdminController if($istimeselect){ $map['s.payed_time']=$istimeselect; } + if ($adminId > 0) { + $map['s.market_admin_id'] = $adminId; + } $map['s.pay_status']=1; $field= "SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count, SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count, @@ -357,7 +360,8 @@ class FinancePromoteController extends AdminController $title = ''; if (!empty(I('develop_type'))) { - $map['company.develop_type'] = I('develop_type'); +// $map['company.develop_type'] = I('develop_type'); + $map['company.develop_type'] = ['in',I('develop_type')]; } self::setPromoteMap($map,"s.promote_id",$title); @@ -588,7 +592,8 @@ class FinancePromoteController extends AdminController $map['s.pay_time'] = ['LT', strtotime($_REQUEST['time_end']) + 86399]; } if (!empty(I('develop_type'))) { - $map['develop_type'] = I('develop_type'); +// $map['develop_type'] = I('develop_type'); + $map['develop_type'] = ['in',I('develop_type')]; } $isMarketLeader = isMarketLeader(); if ($isMarketLeader) { diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php new file mode 100644 index 000000000..13d73fb09 --- /dev/null +++ b/Application/Admin/Controller/MarketPercentageController.class.php @@ -0,0 +1,1059 @@ + + */ +class MarketPercentageController extends ThinkController +{ + + public function index($row = 10, $p = 1){ + + $map = []; + +// $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):''; + $_REQUEST['promote_id']?($map['promote_id'] = $_REQUEST['promote_id']):''; + $_REQUEST['relation_game_id']?($map['relation_game_id'] = $_REQUEST['relation_game_id']):''; + $_REQUEST['sdk_version']?($map['sdk_version'] = $_REQUEST['sdk_version']):''; + + $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; + $map['admin_id'] = $admin_id; + if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14) { + unset($map['admin_id']); + $admin_data = M("member") + ->field("access.uid admin_id") + ->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']]) + ->select(); + if ($admin_data) { + $map['admin_id'] = ['in',array_column($admin_data,'admin_id')]; + } + $_REQUEST['admin_id']?($map['admin_id'] = $_REQUEST['admin_id']):''; + } + + $search_date = []; + if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { + + $end = $_REQUEST['time_end']; + $start = $_REQUEST['time_start']; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + + } elseif (isset($_REQUEST['time_start'])) { + + $end = date("Y-m",time()); + $start = $_REQUEST['time_start']; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + + } elseif (isset($_REQUEST['time_end'])) { + + $end = $_REQUEST['time_end']; + $start = '2019-08'; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + } +// dump($map);die(); +// var_dump($map);die(); + + $data = M("settleup_marketorder","tab_") + ->field("pay_time,promote_account,company_belong,member.real_name,develop_type,game_name, + sum(pay_amount) pay_amount,sum(cp_amount) cp_amount,sum(promote_amount) promote_amount, + sum(channel_amount) channel_amount, sum(company_tax) company_tax,sum(company_profit) company_profit") + ->join("left join sys_member member on member.uid=admin_id"); + + if ($_REQUEST['export']) { + $data = $data->where($map) + ->group("promote_id,game_name,pay_time") + ->order("pay_time DESC") + ->select(); + } else { + $data = $data->page($p, $row) + ->where($map) + ->group("promote_id,game_name,pay_time") + ->order("pay_time DESC") + ->select(); + } + + $sum = M("settleup_marketorder","tab_") + ->field("pay_time,promote_account,company_belong,real_name,develop_type,game_name, + sum(pay_amount) pay_amount,sum(cp_amount) cp_amount,sum(promote_amount) promote_amount, + sum(channel_amount) channel_amount, sum(company_tax) company_tax,sum(company_profit) company_profit") + ->where($map) + ->find(); + + $this->assign("sum",$sum); + + foreach ($data as $key => $value) { + + if ($value['company_belong'] == 0) { + $data[$key]['company_belong'] = '内团'; + } else if ($value['company_belong'] == 1) { + $data[$key]['company_belong'] = '外团'; + } else if ($value['company_belong'] == 2) { + $data[$key]['company_belong'] = '外团-分发联盟'; + } else { + $data[$key]['company_belong'] = '无'; + } + + if ($value['develop_type'] == 1) { + $data[$key]['develop_type'] = '自主开发'; + } else if ($value['develop_type'] == 2) { + $data[$key]['develop_type'] = '自主开发及维护'; + } else if ($value['develop_type'] == 3) { + $data[$key]['develop_type'] = '只维护'; + } else { + $data[$key]['develop_type'] = '无'; + } + } + + if ($_REQUEST['export']) { + + $title = ['pay_time' => '时间', + 'promote_account' => '会长账号', + 'company_belong' => '内外团', + 'real_name' => '所属市场专员', + 'develop_type' => '类型', + 'game_name' => '游戏名称', + 'pay_amount' => '总流水', + 'cp_amount' => '上游结算流水', + 'promote_amount' => '下游结算流水', + 'channel_amount' => '支付渠道费用', + 'company_tax' => '公司税费', + 'company_profit' => '税后毛利额']; + + foreach ($data as $key => $value) { + $data[$key]['pay_time'] = '`'.$data[$key]['pay_time']; + } + + $sum['pay_time'] = ''; + $sum['promote_account'] = ''; + $sum['company_belong'] = '合计'; + $sum['real_name'] = ''; + $sum['develop_type'] = ''; + $sum['game_name'] = ''; + + $data = array_merge($data,[$sum]); + + data2csv($data,'市场毛利统计',$title); + } + + $count = M("settleup_marketorder","tab_") + ->where($map) + ->group("promote_id,game_name,pay_time") + ->select(false); + + $count = M()->table("({$count}) count")->count(); + + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + $this->checkListOrCountAuthRestMap($map,[]); + + $this->assign("list_data",$data); + $this->display(); + + } + + public function marketStaffSettle($row = 10, $p = 1) { + + $map = []; + + $map['group_id'] = ['in','11,12,21']; + +// $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):''; + $_REQUEST['admin_id']?($map['admin_id'] = $_REQUEST['admin_id']):''; + $_REQUEST['group_id']?($map['level'] = $_REQUEST['group_id']):''; + + + $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; + $map['admin_id'] = $admin_id; + if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14) { + unset($map['admin_id']); + + $admin_data = M("member") + ->field("access.uid admin_id") + ->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']]) + ->select(); + if ($admin_data) { + $map['admin_id'] = ['in',array_column($admin_data,'admin_id')]; + } + + $_REQUEST['admin_id']?($map['admin_id'] = $_REQUEST['admin_id']):''; + } + + + + $search_date = []; + if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { + + $end = $_REQUEST['time_end']; + $start = $_REQUEST['time_start']; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + + } elseif (isset($_REQUEST['time_start'])) { + + $end = date("Y-m",time()); + $start = $_REQUEST['time_start']; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + + } elseif (isset($_REQUEST['time_end'])) { + + $end = $_REQUEST['time_end']; + $start = '2019-08'; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + } + + $_REQUEST['time_start']?($start_time = date("Y-m-1",strtotime($_REQUEST['time_start']))):''; + $_REQUEST['time_end']?($end_time = date("Y-m-t",strtotime($_REQUEST['time_end']))):''; + + $this->assign('start_time',$start_time); + $this->assign('end_time',$end_time); + + $data = M("market_altogether","tab_") + ->where($map); + + + if ($_REQUEST['export']) { + $data = $data + ->field("tab_market_altogether.*,market_percentage") + ->join("left join sys_auth_group_access access on tab_market_altogether.admin_id = access.uid") + ->join("left join sys_auth_group auth on access.group_id=auth.id") + ->order("pay_time DESC") + ->select(); + } else { + $data = $data + ->field("tab_market_altogether.*,market_percentage") + ->join("left join sys_auth_group_access access on tab_market_altogether.admin_id = access.uid") + ->join("left join sys_auth_group auth on access.group_id=auth.id") +// ->page($p, $row) + ->order("pay_time DESC") + ->select(); + } + + $count = M("market_altogether","tab_") + ->where($map) + ->count(); + + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + $this->checkListOrCountAuthRestMap($map,[]); + + + $all_data = M("market_altogether","tab_") +// ->where($map) + ->select(); + $wait_amount = []; + foreach ($all_data as $key => $value) { + + $wait_amount[$value['admin_id'].$value['pay_time'].'performance_commission'] = $value['wait_performance_commission']; + $wait_amount[$value['admin_id'].$value['pay_time'].'achievement_bonus'] = $value['wait_achievement_commission']; + + } + + $sum = []; + $sum['performance_revenue'] = 0; + $sum['performance_commission'] = 0; + $sum['achievement_bonus'] = 0; + $sum['commission'] = 0; + $sum['extend_commission'] = 0; + $sum['wait_commission'] = 0; + + foreach ($data as $key => $value) { + + $data[$key]['start_time'] = date("Y-m-1",strtotime($value['pay_time'])); + $data[$key]['end_time'] = date("Y-m-t",strtotime($value['pay_time'])); + + if ($value['level'] == 21) { + $data[$key]['level'] = '初级'; + } else if ($value['level'] == 11) { + $data[$key]['level'] = '中级'; + } else if ($value['level'] == 12) { + $data[$key]['level'] = '高级'; + } + + $market_percentage = json_decode($value['market_percentage'],true); + //开发业绩提成比例 + $data[$key]['develop_commission_ratio'] = $market_percentage['develop_commission_ratio']; + //维护业绩提成比例 + $data[$key]['maintain_commission_ratio'] = $market_percentage['maintain_commission_ratio']; + //开发考核奖金比例 + $data[$key]['appraisal_bonuses_ratio'] = $market_percentage['appraisal_bonuses_ratio']; + //维护奖金考核比例 + $data[$key]['maintain_appraisal_bonuses_ratio'] = $market_percentage['maintain_appraisal_bonuses_ratio']; + + $month = date("m",strtotime($value['pay_time'])); + $yes = date("Y",strtotime($value['pay_time'])); + + $data[$key]['commission'] = number_format($data[$key]['performance_commission'] + $data[$key]['achievement_bonus'], 2, '.', ''); + $data[$key]['wait_commission'] = substr(number_format($value['wait_performance_commission'] + $value['wait_achievement_commission'], 4, '.', ''),0,-2); + $data[$key]['extend_commission'] = $data[$key]['commission'] - $data[$key]['wait_commission']; + + if ($market_percentage['time'] == 1) { + + if ($month == '07') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'performance_commission']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'performance_commission']; + } elseif($month == '10') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'performance_commission']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'08'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'.'performance_commission']; + } elseif($month == '04') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'performance_commission']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'performance_commission']; + } elseif($month == '01') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'.'performance_commission']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'performance_commission']; + } + } elseif($market_percentage['time'] == 2) { + if ($month == '07') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'performance_commission'] + + $wait_amount[$value['admin_id'].$yes.'-'.'04'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'performance_commission']; + } elseif($month == '01') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'.'performance_commission'] + + $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'performance_commission']; + } + } elseif($market_percentage['time'] == 3) { + if ($month == '01') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '01'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '02'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '03'.'performance_commission'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '04'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '05'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '06'.'performance_commission'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '07'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '08'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '09'.'performance_commission'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '10'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '11'.'performance_commission'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '12'.'performance_commission']; + } + } else { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] .date("Y-m",strtotime("last month",strtotime($value['pay_time']))).'performance_commission']; + } + + if ($market_percentage['remain_time'] == 1) { + if ($month == '07') { + + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'achievement_bonus']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'achievement_bonus']; + // dump($data[$key]['extend_commission']);die(); + } elseif($month == '10') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'achievement_bonus']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'08'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'.'achievement_bonus']; + } elseif($month == '04') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'achievement_bonus']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'achievement_bonus']; + } + elseif($month == '01') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'.'achievement_bonus']; +// $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'achievement_bonus']; + } + } elseif($market_percentage['remain_time'] == 2) { + if ($month == '07') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'achievement_bonus'] + + $wait_amount[$value['admin_id'].$yes.'-'.'04'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'achievement_bonus']; + } elseif($month == '01') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'07'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'08'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'09'.'achievement_bonus'] + + $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'achievement_bonus']; + } + } elseif($market_percentage['remain_time'] == 3) { + if ($month == '01') { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '01'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '02'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '03'.'achievement_bonus'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '04'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '05'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '06'.'achievement_bonus'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '07'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '08'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '09'.'achievement_bonus'] + + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '10'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '11'.'achievement_bonus'] + $wait_amount[$value['admin_id'] . ($yes - 1) . '-' . '12'.'achievement_bonus']; + } + } else { + $data[$key]['extend_commission'] += $wait_amount[$value['admin_id'] .date("Y-m",strtotime("last month",strtotime($value['pay_time']))).'achievement_bonus']; + } +// $data[$key]['extend_commission'] = number_format($data[$key]['extend_commission'], 2, '.', ''); +// + + + if ($market_percentage['time'] == 1) { + + if ($month == '07') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'performance_commission']; + } elseif($month == '10') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'08'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'.'performance_commission']; + } elseif($month == '04') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'performance_commission'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'performance_commission']; + } elseif($month == '01') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'performance_commission'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'performance_commission']; + } + } + + if ($market_percentage['remain_time'] == 1) { + if ($month == '07') { + + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'04'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'05'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'06'.'achievement_bonus']; + // dump($data[$key]['extend_commission']);die(); + } elseif($month == '10') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'07'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'08'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'09'.'achievement_bonus']; + } elseif($month == '04') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].$yes.'-'.'01'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'02'.'achievement_bonus'] + $wait_amount[$value['admin_id'].$yes.'-'.'03'.'achievement_bonus']; + } + elseif($month == '01') { + $data[$key]['wait_commission'] += $wait_amount[$value['admin_id'].($yes-1).'-'.'10'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'11'.'achievement_bonus'] + $wait_amount[$value['admin_id'].($yes-1).'-'.'12'.'achievement_bonus']; + } + } + + $data[$key]['extend_commission'] = number_format($data[$key]['extend_commission'],2,'.',''); + $data[$key]['wait_commission'] = number_format($data[$key]['wait_commission'],2,'.',''); + + $sum['performance_revenue'] += $data[$key]['performance_revenue']; + $sum['appraisal_bonuses'] += $data[$key]['appraisal_bonuses']; + $sum['performance_commission'] += $data[$key]['performance_commission']; + $sum['achievement_bonus'] += $data[$key]['achievement_bonus']; + $sum['commission'] += $data[$key]['commission']; + $sum['extend_commission'] += $data[$key]['extend_commission']; + + } + $sum['wait_commission'] = '-------'; + + if ($_REQUEST['export']) { + + $title = ['pay_time' => '时间', + 'real_name' => '市场人员', + 'level' => '级别', + 'performance_revenue' => '开发总流水', + 'appraisal_bonuses' => '维护总流水', + 'develop_commission_ratio'=>'开发业绩提成比例(%)', + 'maintain_commission_ratio'=>'维护业绩提成比例(%)', + 'appraisal_bonuses_ratio'=>'开发考核奖金比例(%)', + 'maintain_appraisal_bonuses_ratio'=>'维护奖金考核比例(%)', + 'company_profit'=>'税后毛利', + 'performance_commission' => '业绩提成', + 'achievement_bonus' => '绩效考核奖金', + 'commission' => '当月合计', + 'extend_commission' => '应发金额', + 'wait_commission' => '待发金额']; + + foreach ($data as $key => $value) { + $line = $key+2; +// $develop_commission_ratio = $value['develop_commission_ratio']/100; + $data[$key]['pay_time'] = '`'.$data[$key]['pay_time']; + $data[$key]['performance_commission'] = "=ROUND(J{$line}*(F{$line}/100)+J{$line}*(G{$line}/100),2)"; + $data[$key]['achievement_bonus'] = "=ROUND(J{$line}*(H{$line}/100)+J{$line}*(I{$line}/100),2)"; + $data[$key]['commission'] = "=ROUND(K{$line}+L{$line},2)"; + } + + $data = array_merge($data,[$sum]); + + data2csv($data,'市场业绩提成',$title); + } + + $arraypage = $p; + $size = $row;//每页显示的记录数 + $data = array_slice($data, ($arraypage - 1) * $size, $size); + + $this->assign("sum",$sum); + $this->assign("list_data",$data); + $this->display("marketstaffsettle"); + + } + + public function personMarketStaffSettle($row = 10, $p = 1) { +// var_dump(getMarketAdmin()); + $map = []; + + $map['group_id'] = ['in','11,12,21']; + +// $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):''; +// $_REQUEST['admin_id']?($map['admin_id'] = $_REQUEST['admin_id']):''; + $_REQUEST['group_id']?($map['group_id'] = $_REQUEST['group_id']):''; + ($_REQUEST['status']||$_REQUEST['status']=='0')?($map['status'] = $_REQUEST['status']):''; + + if($_REQUEST['status']||$_REQUEST['status']=='0') { + if( $_REQUEST['status'] == '1') { + $map['status'] = ['egt',1]; + } else { + $map['status'] = $_REQUEST['status']; + } + } + + $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; + $map['admin_id'] = $admin_id; + if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14) { + unset($map['admin_id']); + + $admin_data = M("member") + ->field("access.uid admin_id") + ->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']]) + ->select(); + if ($admin_data) { + $map['admin_id'] = ['in',array_column($admin_data,'admin_id')]; + } + + $_REQUEST['admin_id']?($map['admin_id'] = $_REQUEST['admin_id']):''; + } + + $search_date = []; + if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { + + $end = $_REQUEST['time_end']; + $start = $_REQUEST['time_start']; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + + } elseif (isset($_REQUEST['time_start'])) { + + $end = date("Y-m",time()); + $start = $_REQUEST['time_start']; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + + } elseif (isset($_REQUEST['time_end'])) { + + $end = $_REQUEST['time_end']; + $start = '2019-08'; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + } + + $data = M("market_altogether","tab_") + ->where($map); + + if ($_REQUEST['export']) { + $data = $data + ->order("pay_time DESC") + ->select(); + } else { + $data = $data +// ->page($p, $row) + ->order("pay_time DESC") + ->select(); + } + + $count = M("market_altogether","tab_") + ->where($map) + ->count(); + + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + $this->checkListOrCountAuthRestMap($map,[]); + + $sum['performance_revenue'] = 0; + $sum['appraisal_bonuses'] = 0; + $sum['company_profit'] = 0; + $sum['performance_commission'] = 0; + $sum['achievement_bonus'] = 0; + $sum['commission'] = 0; + $sum['extend_commission'] = 0; + $sum['wait_commission'] = 0; + + foreach ($data as $key => $value) { + + $data[$key]['start_time'] = date("Y-m-1",strtotime($value['pay_time'])); + $data[$key]['end_time'] = date("Y-m-t",strtotime($value['pay_time'])); + + if ($value['level'] == 21) { + $data[$key]['level'] = '初级'; + } else if ($value['level'] == 11) { + $data[$key]['level'] = '中级'; + } else if ($value['level'] == 12) { + $data[$key]['level'] = '高级'; + } + + if ($value['status'] > 0) { + $data[$key]['is_send'] = '已发放'; + } else { + $data[$key]['is_send'] = '未发放'; + } + + $data[$key]['wait_commission'] = + number_format($value['wait_performance_commission'] + $value['wait_achievement_commission'], 2, '.', ''); + + $data[$key]['commission'] = $data[$key]['performance_commission'] + $data[$key]['achievement_bonus']; + $data[$key]['extend_commission'] = $data[$key]['commission'] - $data[$key]['wait_commission']; + + $sum['performance_revenue'] += $value['performance_revenue']; + $sum['appraisal_bonuses'] += $value['appraisal_bonuses']; + + $sum['company_profit'] += $value['company_profit']; + $sum['performance_commission'] += $value['performance_commission']; + $sum['achievement_bonus'] += $value['achievement_bonus']; + $sum['commission'] += $data[$key]['commission']; + $sum['extend_commission'] += $data[$key]['extend_commission'] ; + $sum['wait_commission'] += $value['wait_performance_commission'] + $value['wait_achievement_commission']; + + } + + $sum['performance_revenue'] = number_format($sum['performance_revenue'], 2, '.', ''); + $sum['appraisal_bonuses'] = number_format($sum['appraisal_bonuses'], 2, '.', ''); + + $sum['company_profit'] = number_format($sum['company_profit'], 2, '.', ''); + $sum['performance_commission'] = number_format($sum['performance_commission'], 2, '.', ''); + $sum['achievement_bonus'] = number_format($sum['achievement_bonus'], 2, '.', ''); + $sum['commission'] = number_format($sum['commission'], 2, '.', ''); + $sum['extend_commission'] = number_format($sum['extend_commission'], 2, '.', ''); + $sum['wait_commission'] = number_format($sum['wait_commission'], 2, '.', ''); + + $this->assign("sum",$sum); + + if ($_REQUEST['export']) { + + $title = ['pay_time' => '时间', + 'real_name' => '市场人员', + 'nickname' => '账号', + 'level' => '级别', + 'performance_revenue' => '开发总流水', + 'appraisal_bonuses' => '维护总流水', + 'company_profit'=>'税后毛利', + 'performance_commission' => '业绩提成', + 'achievement_bonus' => '绩效考核奖金', + 'commission' => '当月总提成', + 'extend_commission' => '本月发放', + 'wait_commission' => '本月未发', + 'is_send'=>'剩余金额发放状态']; + + $data = array_merge($data,[$sum]); + + foreach ($data as $key => $value) { + $data[$key]['pay_time'] = '`'.$data[$key]['pay_time']; + } + + data2csv($data,'个人总提成列表',$title); + } + $arraypage = $p; + $size = $row;//每页显示的记录数 + $data = array_slice($data, ($arraypage - 1) * $size, $size); + + $this->assign("list_data",$data); + $this->display("personmarketstaffsettle"); + + } + + public function sendBonus() { + + $map['pay_time'] = $_REQUEST['pay_time']; + + $admin_data = M("member") + ->field("access.uid admin_id") + ->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']]) + ->select(); + if ($admin_data) { + $map['admin_id'] = ['in',array_column($admin_data,'admin_id')]; + } + + $map['admin_id'] = $_REQUEST['admin_id']; + + if (!$_REQUEST['pay_time']||!$_REQUEST['admin_id']) { + $this->ajaxReturn(['status'=>0,'msg'=>'数据错误']); + } + + $check_data = M("market_altogether","tab_") + ->where(['pay_time'=>$_REQUEST['pay_time'],'admin_id'=>$_REQUEST['admin_id']]) + ->find(); + + //正常发放添加判断,不让他重新发放 + if (!$_REQUEST['all']&&$check_data) { + + if ($check_data['status'] >0) { + $this->ajaxReturn(['status'=>0,'msg'=>'已经发放过,请勿重复操作']); + } + } + //判断是否已经离职发放过 + if($_REQUEST['all']) { + if ($check_data['status']==2) { + $this->ajaxReturn(['status'=>0,'msg'=>'离职发放已经发放过']); + } + } + +// $group_config = M("auth_group_access access") +// ->field("market_percentage") +// ->join("left join sys_auth_group auth on access.group_id=auth.id") +// ->where(['uid'=>$_REQUEST['admin_id']]) +// ->find(); +// $group_config = json_decode($group_config['market_percentage'],true); +// $month = date("m",strtotime($_REQUEST['pay_time'])); +// $yes = date("Y",strtotime($_REQUEST['pay_time'])); +// if ($group_config['time'] == 1) { +// if ($month == '07') { +// $where = [$yes.'-'.'01',$yes.'-'.'02',$yes.'-'.'03']; +// if ($_REQUEST['all']) { +// $where = array_merge($where,[$yes.'-'.'04',$yes.'-'.'05',$yes.'-'.'06']); +// } +// } elseif($month == '10') { +// $where = [$yes.'-'.'04',$yes.'-'.'05',$yes.'-'.'06']; +// if ($_REQUEST['all']) { +// $where = array_merge($where,[$yes.'-'.'07',$yes.'-'.'08',$yes.'-'.'09']); +// } +// } elseif($month == '04') { +// $where = [($yes-1).'-'.'10',($yes-1).'-'.'11',($yes-1).'-'.'12']; +// if ($_REQUEST['all']) { +// $where = array_merge($where,[$yes.'-'.'01',$yes.'-'.'02',$yes.'-'.'03']); +// } +// } elseif($month == '01') { +// $where = [($yes-1).'-'.'07',($yes-1).'-'.'08',($yes-1).'-'.'09']; +// if ($_REQUEST['all']) { +// $where = array_merge($where,[$yes.'-'.'10',$yes.'-'.'11',$yes.'-'.'12']); +// } +// } +// +// } elseif($group_config['time'] == 2) { +// if ($month == '07') { +// $where = [$yes.'-'.'01',$yes.'-'.'02',$yes.'-'.'03',$yes.'-'.'04',$yes.'-'.'05',$yes.'-'.'06']; +// } elseif($month == '01') { +// $where = [($yes-1).'-'.'07',($yes-1).'-'.'08',($yes-1).'-'.'09',($yes-1).'-'.'10',($yes-1).'-'.'11',($yes-1).'-'.'12']; +// } +// } elseif($group_config['time'] == 3) { +// if ($month == '01') { +// $where = [($yes-1).'-'.'01',($yes-1).'-'.'02',($yes-1).'-'.'03',($yes-1).'-'.'04',($yes-1).'-'.'05',($yes-1).'-'.'06', +// ($yes-1).'-'.'07',($yes-1).'-'.'08',($yes-1).'-'.'09',($yes-1).'-'.'10',($yes-1).'-'.'11',($yes-1).'-'.'12']; +// } +// } else { +// $where = [date("Y-m",strtotime("last month",strtotime($_REQUEST['pay_time'])))]; +// } + $save['status'] = 1; + $save['remark'] = '手动发放'; + if ($_REQUEST['all']) { + unset($map['pay_time']); + $save['status'] = 2; + $save['remark'] = '离职发放'; + } + + $is_save = M("market_altogether","tab_") + ->where($map) + ->save($save); + + if ($is_save) { + $this->ajaxReturn(['status'=>1,'msg'=>'发放成功']); + } else { + $this->ajaxReturn(['status'=>0,'msg'=>'发放失败']); + } + + } + + public function reCaculateBonus() { + + $pay_time = $_REQUEST['pay_time']; + + if (!$pay_time) { + $pay_time = "all"; +// $pay_time = date("Y-m",strtotime('-1 month')); + } + +// var_dump("cd ".ROOTTT.";php admin.php timing/caculateMarketStream/time/{$pay_time} > /dev/null &");die(); + + exec("source /etc/profile;cd ".ROOTTT.";php admin.php timing/caculateMarketStream/time/{$pay_time} > /dev/null &"); + + $this->ajaxReturn(['status'=>1]); + } + + public function showBonusList($row = 10, $p = 1) { + + //排序 + if(!array_key_exists("time_start",$_REQUEST)){ + $this->redirect(ACTION_NAME, array('time_start' => date('Y-m',strtotime('-1 month')),"time_end"=>date('Y-m',strtotime('-1 month')))); + } + + $map = []; + + $admin_data = M("member") + ->field("access.uid admin_id") + ->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']]) + ->select(); + if ($admin_data) { + $map['admin_id'] = ['in',array_column($admin_data,'admin_id')]; + } + + $_REQUEST['pay_time']?$map['pay_time'] = $_REQUEST['pay_time']:''; + $_REQUEST['real_name']?$map['real_name'] = $_REQUEST['real_name']:''; + $_REQUEST['nickname']?$map['nickname'] = $_REQUEST['nickname']:''; + $_REQUEST['level']?$map['level'] = $_REQUEST['level']:''; + + + $search_date = []; + if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { + + $end = $_REQUEST['time_end']; + $start = $_REQUEST['time_start']; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + + } elseif (isset($_REQUEST['time_start'])) { + + $end = date("Y-m",time()); + $start = $_REQUEST['time_start']; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + + } elseif (isset($_REQUEST['time_end'])) { + + $end = $_REQUEST['time_end']; + $start = '2019-08'; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + } + + if($_REQUEST['pay_time']) { + if (in_array($_REQUEST['pay_time'],$search_date)) { + $map['pay_time'] = $_REQUEST['pay_time']; + } elseif(isset($_REQUEST['time_start']) || isset($_REQUEST['time_end'])) { + $this->checkListOrCountAuthRestMap($map,[]); + $this->assign("list_data",[]); + $this->display("showbonuslist"); + die(); + } else { + $map['pay_time'] = $_REQUEST['pay_time']; + } + } +// var_dump($map);die(); + $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(performance_commission) performance_commission,sum(achievement_bonus) achievement_bonus, + sum(wait_performance_commission)+sum(wait_achievement_commission) wait_amount, + sum(if(status > 0, wait_performance_commission, '0.00')) + sum(if(status > 0, wait_achievement_commission,'0.00')) wait_extend_commission, + sum(if(status = 0, wait_performance_commission, '0.00')) + sum(if(status = 0, wait_achievement_commission, '0.00')) wait_commission, remark,level,status") + ->where($map); + + if ($_REQUEST['export']) { + $data = $data + ->order("pay_time DESC") + ->group("admin_id") + ->select(); + } else { + $data = $data +// ->page($p, $row) + ->order("pay_time DESC") + ->group("admin_id") + ->select(); + } + + $sum = []; + $sum['pay_amount'] = 0; + $sum['extend_commission'] = 0; + $sum['wait_commission'] = 0; + + foreach($data as $key => $value) { + + if ($value['level'] == 21) { + $data[$key]['level'] = '初级'; + } else if ($value['level'] == 11) { + $data[$key]['level'] = '中级'; + } else if ($value['level'] == 12) { + $data[$key]['level'] = '高级'; + } + + $data[$key]['commission'] = $data[$key]['performance_commission'] + $data[$key]['achievement_bonus']; + + $data[$key]['extend_commission'] = number_format($data[$key]['commission'] - $data[$key]['wait_commission'], 2, '.', ''); + $data[$key]['pay_amount'] = number_format($data[$key]['pay_amount'] , 2, '.', ''); + $data[$key]['wait_commission'] = number_format($data[$key]['wait_commission'] , 2, '.', ''); +// $data[$key]['all_commission'] = $data[$key]['wait_amount'] + ; + + $sum['pay_amount'] += $data[$key]['pay_amount']; + $sum['extend_commission'] += $data[$key]['extend_commission']; + $sum['wait_commission'] += $data[$key]['wait_commission']; + $sum['commission'] += $data[$key]['commission']; + + } + + $sum['pay_amount'] = number_format($sum['pay_amount'], 2, '.', '');; + $sum['extend_commission'] = number_format($sum['extend_commission'], 2, '.', '');; + $sum['wait_commission'] = number_format($sum['wait_commission'], 2, '.', '');; + + $_REQUEST['time_start']?($start_time = date("Y-m-1",strtotime($_REQUEST['time_start']))):$start_time = date("Y-m-1",strtotime('')); + $_REQUEST['time_end']?($end_time = date("Y-m-t",strtotime($_REQUEST['time_end']))):''; + $this->assign('start_time',$start_time); + $this->assign('end_time',$end_time); + + if ($_REQUEST['export']) { + + $title = ['real_name' => '姓名', + 'nickname' => '账号', + 'level' => '级别', + 'pay_amount' => '总流水', + 'commission'=>'总提成', + 'extend_commission' => '已发放总提成', + 'wait_commission'=>'剩余未发放总提成']; + + $data = array_merge($data,[$sum]); + + data2csv($data,'提成汇总结算单',$title); + } + + $count = M("market_altogether","tab_") + ->where($map) + ->group("admin_id") + ->select(false); + $count = M()->table("({$count}) count")->count(); + + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + + $arraypage = $p; + $size = $row;//每页显示的记录数 + $data = array_slice($data, ($arraypage - 1) * $size, $size); + + $this->checkListOrCountAuthRestMap($map,[]); + + $this->assign("sum",$sum); + $this->assign("list_data",$data); + $this->display("showbonuslist"); + + } + + public function editTaxRatio() { + + if (IS_POST) { + + if (!$_POST['tax_radio']) { + $this->error("税率不能填空"); + } + + if (!$_POST['timestart']) { + $this->error("生效时间不能填空"); + } + + $data = $_POST; + $data['time'] = strtotime($data['timestart']); + $data['create_time'] = time(); + + $is_hav = M("tax_radio","tab_") + ->where(['time'=>strtotime($data['timestart'])]) + ->find(); + + M("tax_radio","tab_") + ->where(['time'=>['gt',strtotime($data['timestart'])]]) + ->delete(); + + if ($is_hav) { + $is_save = M("tax_radio","tab_") + ->where(['time'=>strtotime($data['timestart'])]) + ->save($data); + } else { + $is_save = M("tax_radio","tab_")->add($data); + } + + $this->success("保存成功",U("index")); + + } else { + + $data = M("tax_radio","tab_") + ->field("tax_radio,time timestart") + ->order("create_time DESC") + ->find(); + + $data['timestart'] = Date("Y-m",$data['timestart']); + + $this->assign('data',$data); + $this->display("edittaxratio"); + + } + + } + +} diff --git a/Application/Admin/Controller/PayChannelController.class.php b/Application/Admin/Controller/PayChannelController.class.php index 7928ddc9d..4b7477f9b 100644 --- a/Application/Admin/Controller/PayChannelController.class.php +++ b/Application/Admin/Controller/PayChannelController.class.php @@ -461,6 +461,8 @@ class PayChannelController extends ThinkController ->group('pay_way') ->select(false); +// var_dump($map);die(); + //推广后台充值数据 $spreadMap['order_status'] = array('egt',1); $spreadMap['pay_way'] = array('egt',1); diff --git a/Application/Admin/Controller/StatController.class.php b/Application/Admin/Controller/StatController.class.php index eb690a23d..bb95ec29d 100644 --- a/Application/Admin/Controller/StatController.class.php +++ b/Application/Admin/Controller/StatController.class.php @@ -838,6 +838,7 @@ AND UNIX_TIMESTAMP( array_multisort($orderColumn, $sort, SORT_REGULAR, $rows); } + $this->checkListOrCountAuthRestMap($map,[]); $this->meta_title = 'ARPU统计'; $this->assign('baseGames', $baseGames); $this->assign('records', $rows); diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index aa475884e..a4c97c60a 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -736,4 +736,418 @@ class TimingController extends AdminController { } + function getPayway($name) { + switch ($name){ + case 'alipay': //支付宝 1 + return 1; + case 'wei_xin': //微信支付 2 3 + return 2; + case 'heepay': //汇付宝 6 + return 6; + case 'sqpay': //双乾支付9,10,15 + return 9; + case 'yeepay': //易宝支付17 + return 17; + default: + return ''; + } + + } + //计算市场专员业绩公式 参数 time 2020-10 + public function caculateMarketStream () { + echo date("Y-m-d H:i:s")."----------------------市场结算管理计算----------------------\n"; + + $map['pay_time'] = date("Y-m",strtotime('-1 month')); + + if ($_REQUEST['time']) { + $map['pay_time'] = $_REQUEST['time']; + } + $spend_map = []; + if($_REQUEST['time'] == 'all') { + $map = []; + $spend_map['pay_time'] = ['elt',strtotime(date('Y-m-t 23:59:59', strtotime('-1 month')))]; + } + + $data = M("auth_group") + ->where(['title'=>['like','%市场%']]) + ->select(false); + + $data = M("auth_group_access") + ->field("auth.market_percentage,real_name,sys_member.uid,sys_auth_group_access.group_id") + ->join("left join ({$data}) auth on auth.id = sys_auth_group_access.group_id") + ->join("left join sys_member on sys_member.uid = sys_auth_group_access.uid") + ->where("auth.title is not null") + ->select(false); + + $spend = M("spend","tab_") + ->field("sum(pay_amount) as pay_amount,FROM_UNIXTIME(pay_time,'%Y-%m') pay_time, + substring_index(substring_index(tab_spend.game_name,'(',1),'(',-1) game_name,game_id,relation_game_id,tab_spend.sdk_version, + CASE WHEN substring_index(substring_index(`chain`,'/',2),'/',-1) !='' THEN substring_index(substring_index(`chain`,'/',2),'/',-1) ELSE promote_id END promote_id,pay_way,market_admin_id") + ->join("left join tab_promote on tab_spend.promote_id = tab_promote.id") + ->join("left join tab_game game on game.id=tab_spend.game_id") + ->where(['tab_spend.pay_status'=>1,'pay_way'=>['egt',1]]) + ->where($spend_map) + ->group("tab_spend.id") + ->select(false); +// var_dump($spend);die(); + $payway_spend = M()->table("({$spend}) spend") + ->field("sum(pay_amount) as pay_amount,pay_time,promote_id,game_name,game_id,relation_game_id,pay_way,sdk_version") + ->where($map) + ->group("pay_time,promote_id,game_name,pay_way,market_admin_id") + ->select(); + + $channel_fee = []; + + $paywayData = M("tool","tab_") + ->field("name,config") + ->where(['name'=>['in',"alipay,weixin,wei_xin,wei_xin_app,jubaobar,weixin_gf,jft,jft_wap,goldpig,ptb_pay,bind_pay,sqpay,heepay,yeepay"]]) + ->select(); + + //公司税费计算 + $tax_radio = []; + $tax_data = M("tax_radio","tab_") + ->field("tax_radio,time") + ->order("time ASC") + ->select(); + + foreach ($tax_data as $key => $value) { + + $tax_radio[$key]['start'] = $value['time']; + $tax_radio[$key]['end'] = $tax_data[$key+1]['time']; + $tax_radio[$key]['tax_radio'] = $value['tax_radio']; + + if (!$tax_data[$key+1]['time']) { + $tax_radio[$key]['end'] = 99999999999; + } + } + + $pay_rate = []; + foreach ($paywayData as $key => $value) { + $pay_config = json_decode($value['config'],true); + if ($this->getPayway($value['name'])) { + $pay_rate[$this->getPayway($value['name'])] = $pay_config['channel_rate']?$pay_config['channel_rate']:0; + } + } + foreach ($payway_spend as $key => $value) { + + switch ($value['pay_way']){ + case 3: //微信同步 + $value['pay_way'] = '2'; + break; + case 10: //双乾同步 + $value['pay_way'] = '9'; + break; + case 15: //双乾同步 + $value['pay_way'] = '9'; + break; + } + //将时间、推广员id、游戏名、设备类型作为键值标记渠道费用 + if (!$channel_fee[$value['pay_time'].$value['promote_id'].$value['game_name']]) { + if (!$value['pay_way']) { + $channel_fee[$value['pay_time'].$value['promote_id'].$value['game_name']] = 0; + } + $channel_fee[$value['pay_time'].$value['promote_id'].$value['game_name']] + = $value['pay_amount'] * ($pay_rate[$value['pay_way']]/100); + } else { + $channel_fee[$value['pay_time'].$value['promote_id'].$value['game_name']] + = $channel_fee[$value['pay_time'].$value['promote_id'].$value['game_name']]+($value['pay_amount'] * ($pay_rate[$value['pay_way']]/100)); + } + + } + + $spend = M()->table("({$spend}) spend") + ->field("sum(pay_amount) as pay_amount,pay_time,promote_id,game_name,game_id,relation_game_id,sdk_version,market_admin_id") + ->where($map) + ->group("pay_time,promote_id,game_name,market_admin_id") + ->select(false); + + $promote_data = M()->table("({$spend}) spend") + ->field("pay_time,company_id,account as promote_account,company.company_belong,develop_type,spend.promote_id,spend.game_name,game_id,relation_game_id,spend.pay_amount,auth.real_name,market_admin_id as admin_id,market_percentage,sdk_version") + ->join("left join tab_promote promote on spend.promote_id = promote.id") + ->join("left join tab_promote_company company on promote.company_id = company.id") + ->join("left join ({$data}) auth on auth.uid=market_admin_id") + ->where(['develop_type'=>['egt',1],'group_id'=>['in',['11','12','21']]]) + ->select(); +// dump($spend);die(); + // + +// dump($tax_radio);die(); + + foreach ($promote_data as $key => $value) { + + $cp_radio = getGameCpRadio($value['game_id'],$value['pay_amount'],true); + if (!$cp_radio) { + $cp_radio = getGameCpRadio($value['game_id'],$value['pay_amount'],false); + } + //上游流水 + $promote_data[$key]['cp_amount'] = $value['pay_amount'] * ($cp_radio * 0.01); + //下游 + $promote_radio = getGamePromoteCompanyRadio($value['company_id'],$value['relation_game_id'],time(),$value['pay_amount'],true,$value['company_belong']); + if (!$promote_radio) { + $promote_radio = getGamePromoteCompanyRadio($value['company_id'],$value['relation_game_id'],time(),$value['pay_amount'],false,$value['company_belong']); + } + //下游流水 + $promote_data[$key]['promote_amount'] = $value['pay_amount'] * ($promote_radio * 0.01); + //渠道费用 + $promote_data[$key]['channel_amount'] = $channel_fee[$value['pay_time'].$value['promote_id'].$value['game_name']]; + $tax = 0; + //公司税费 + foreach($tax_radio as $k => $v) { + if (strtotime($value['pay_time'])>=$v['start'] && strtotime($value['pay_time'])<$v['end']) { + $tax = $v['tax_radio']; + } + } + + $promote_data[$key]['company_tax'] = ($value['pay_amount']-$promote_data[$key]['cp_amount']- $promote_data[$key]['promote_amount'])*($tax/100); + + //毛利 + $promote_data[$key]['company_profit'] = $value['pay_amount']-$promote_data[$key]['cp_amount']-$promote_data[$key]['promote_amount']-$promote_data[$key]['channel_amount']-$promote_data[$key]['company_tax']; + + if ($value['promote_id'] == 0) { +// $promote_data[$key]['promote_account']='官方渠道'; +// $promote_data[$key]['company_id']='0'; +// $promote_data[$key]['company_belong']='3'; +// $promote_data[$key]['develop_type']='0'; + continue; + } + + unset($promote_data[$key]['market_percentage']); + + $marker_data = M("settleup_marketorder","tab_") + ->where(['pay_time'=>$value['pay_time'],'promote_id'=>$value['promote_id'],'game_name'=>$value['game_name']]) + ->find(); + echo "日期:{$value['pay_time']},游戏:{$value['game_name']},推广员:{$value['promote_account']}\n"; +// dump($promote_data[$key]);die(); + if (!$marker_data) { + M("settleup_marketorder","tab_") + ->add($promote_data[$key]); + } else { + M("settleup_marketorder","tab_") + ->where(['pay_time'=>$value['pay_time'],'promote_id'=>$value['promote_id'],'game_name'=>$value['game_name']]) + ->save($promote_data[$key]); + } + + } +// var_dump($_REQUEST['time']); + $this->createMarketBonus($_REQUEST['time']); + echo date("Y-m-d H:i:s")."----------------------市场结算管理计算----------------------\n"; + + } + + + public function insertAllUserBonus($time) { + +// $time = $_REQUEST['time']; + $data = M("member") + ->field("access.uid admin_id,real_name,nickname,group_id level") + ->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']]) + ->select(); + + foreach ($data as $key => $value) { + $value['pay_time'] = $time; + $value['remark'] = ""; + $value['create_time'] = time(); + + $sign = M("market_altogether","tab_") + ->where(['admin_id'=>$value['admin_id'],'pay_time'=>$time]) + ->find(); + if (!$sign) { + M("market_altogether","tab_")->add($value); + } elseif(!$sign['real_name']) { + M("market_altogether","tab_")->where(['admin_id'=>$value['admin_id'],'pay_time'=>$time])->save(['real_name'=>$value['real_name']]); + } + + } + + } + + + public function createMarketBonus($pay_time) { + + if ($pay_time&&$pay_time!='all') { + $map['pay_time'] = $pay_time; + } + + if (!$pay_time) { + $pay_time = date("Y-m",strtotime('-1 month')); + $map['pay_time'] = date("Y-m",strtotime('-1 month')); + } + + if ($pay_time == 'all') { + + $end = date("Y-m",time()); + $start = '2019-08'; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $i++; + $this->insertAllUserBonus($date); + } while ($date < date('Y-m', strtotime("{$end} -1 month"))); + +// $map['pay_time'] = []; + unset($map['pay_time']); + } else{ + $this->insertAllUserBonus($pay_time); + } + + $all_data = M("settleup_marketorder","tab_") + ->field("tab_settleup_marketorder.id,pay_time,promote_account,company_belong,tab_settleup_marketorder.real_name,develop_type,game_name, + sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage,nickname,admin_id, + sum(if((develop_type = 1 or develop_type = 2), pay_amount, 0)) performance_revenue,sum(if(develop_type = 3, pay_amount, 0)) appraisal_bonuses, + sum(company_tax) company_tax, sum(cp_amount) cp_amount,sum(promote_amount) promote_amount") + ->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(['group_id'=>['in','11,12,21']]) + ->where($map) + ->group("admin_id,pay_time") + ->select(); + + foreach ($all_data as $key => $value) { + + $sum_amount = $value['performance_revenue'] + $value['appraisal_bonuses']; + + $market_percentage = json_decode($value['market_percentage'],true);//业绩提成 + $all_data[$key]['performance_commission'] = + number_format($value['company_profit']*($market_percentage['develop_commission_ratio']/100) + + $value['company_profit']*($market_percentage['maintain_commission_ratio']/100), 2, '.', ''); + + $sum_amount <$market_percentage['performance_revenue'] ? ($all_data[$key]['performance_commission'] = 0):""; + //绩效考核奖金 + $all_data[$key]['achievement_bonus'] = + number_format($value['company_profit']*($market_percentage['appraisal_bonuses_ratio']/100) + + $value['company_profit']*($market_percentage['maintain_appraisal_bonuses_ratio']/100), 2, '.', ''); + $sum_amount <$market_percentage['appraisal_bonuses'] ? ($all_data[$key]['achievement_bonus'] = 0):""; + //总提成 + $all_data[$key]['commission'] = number_format($all_data[$key]['performance_commission']+$all_data[$key]['achievement_bonus'], 2, '.', ''); + //应发金额 + $all_data[$key]['extend_commission'] = + substr(number_format($all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+ + $all_data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100), 4, '.', ''),0,-2); + + //待发金额 + $all_data[$key]['wait_commission'] = substr(number_format($all_data[$key]['commission'] - ( $all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100)+ + $all_data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100) ), 4, '.', ''),0,-2); + + $insert['pay_time'] = $value['pay_time']; + $insert['real_name'] = $value['real_name']; + $insert['admin_id'] = $value['admin_id']; + $insert['nickname'] = $value['nickname']; + + $insert['level'] = $value['group_id']; + $insert['pay_amount'] = $value['pay_amount']; + $insert['extend_commission'] = substr( + number_format(($all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100) + + $all_data[$key]['achievement_bonus'] * ($market_percentage['month_bonus_ratio']/100)), 4, '.', ''),0,-2); + $insert['wait_commission'] = $all_data[$key]['wait_commission']; + $insert['remark'] = ''; + $insert['create_time'] = time(); + $insert['company_profit'] = $value['company_profit']; + $insert['company_tax'] = $value['company_tax']; + + $insert['cp_amount'] = $value['cp_amount']; + $insert['promote_amount'] = $value['promote_amount']; + $insert['performance_revenue'] = $value['performance_revenue']; + $insert['appraisal_bonuses'] = $value['appraisal_bonuses']; + + $insert['performance_commission'] = $all_data[$key]['performance_commission']; + $insert['achievement_bonus'] = $all_data[$key]['achievement_bonus']; + //待发业绩奖金 + $insert['wait_performance_commission'] = number_format($all_data[$key]['performance_commission'] * (1-($market_percentage['performance_monthly_ratio']/100)), 2, '.', ''); + //待发绩效奖金 + $insert['wait_achievement_commission'] = number_format($all_data[$key]['achievement_bonus'] * (1-($market_percentage['month_bonus_ratio']/100)), 2, '.', ''); +// $insert['wait_commission'] = ($insert['wait_performance_commission']+$insert['wait_achievement_commission']); + $is_hav = M("market_altogether","tab_") + ->where(['admin_id'=>$value['admin_id'],'pay_time'=>$value['pay_time']]) + ->find(); + + if (!$is_hav) { + M("market_altogether","tab_")->add($insert); + } else { + M("market_altogether","tab_") + ->where(['admin_id'=>$value['admin_id'],'pay_time'=>$value['pay_time']]) + ->save($insert); + } + + } + + } + + public function sendMarketBonus(){ + echo date("Y-m-d H:i:s")."----------------------月初发放市场专员应发份额----------------------\n"; + + $map['pay_time'] = date("Y-m",strtotime('-1 month')); + + if ($_REQUEST['time']) { + $map['pay_time'] = $_REQUEST['time']; + } + + if ($_REQUEST['time'] == 'all') { + unset($map['pay_time']); + } + + $data = M("market_altogether","tab_") + ->where($map) + ->select(); +// dump($map);die(); + foreach ($data as $key => $value) { + + $group_config = M("auth_group_access access") + ->field("market_percentage") + ->join("left join sys_auth_group auth on access.group_id=auth.id") + ->where(['uid'=>$value['admin_id']]) + ->find(); + $group_config = json_decode($group_config['market_percentage'],true); + $month = date("m",strtotime($value['pay_time'])); + $yes = date("Y",strtotime($value['pay_time'])); + + $where =[]; + + if ($group_config['time'] == 1) { +// var_dump($month);die(); + if ($month == '07') { + $where = [$yes.'-'.'01',$yes.'-'.'02',$yes.'-'.'03']; + } elseif($month == '10') { + $where = [$yes.'-'.'04',$yes.'-'.'05',$yes.'-'.'06']; + } elseif($month == '04') { + $where = [($yes-1).'-'.'10',($yes-1).'-'.'11',($yes-1).'-'.'12']; + } elseif($month == '01') { + $where = [($yes-1).'-'.'07',($yes-1).'-'.'08',($yes-1).'-'.'09']; + } + + } elseif($group_config['time'] == 2) { + if ($month == '07') { + $where = [$yes.'-'.'01',$yes.'-'.'02',$yes.'-'.'03',$yes.'-'.'04',$yes.'-'.'05',$yes.'-'.'06']; + } elseif($month == '01') { + $where = [($yes-1).'-'.'07',($yes-1).'-'.'08',($yes-1).'-'.'09',($yes-1).'-'.'10',($yes-1).'-'.'11',($yes-1).'-'.'12']; + } + } elseif($group_config['time'] == 3) { + if ($month == '01') { + $where = [($yes-1).'-'.'01',($yes-1).'-'.'02',($yes-1).'-'.'03',($yes-1).'-'.'04',($yes-1).'-'.'05',($yes-1).'-'.'06', + ($yes-1).'-'.'07',($yes-1).'-'.'08',($yes-1).'-'.'09',($yes-1).'-'.'10',($yes-1).'-'.'11',($yes-1).'-'.'12']; + } + } else { + $where = [date("Y-m",strtotime("last month",strtotime($value['pay_time'])))]; + } + echo "{$value['pay_time']}:{$value['real_name']}发放\n"; + $save['status'] = 1; + $save['remark'] = '自动发放'; + if ($where) { + $map['pay_time'] = ['in',$where]; + $map['admin_id'] = $value['admin_id']; + + M("market_altogether","tab_") + ->where($map) + ->save($save); + } + + } + + + echo date("Y-m-d H:i:s")."----------------------市场结算管理计算----------------------\n"; + + } + } diff --git a/Application/Admin/Controller/UserController.class.php b/Application/Admin/Controller/UserController.class.php index c6725bc92..93bc74b1a 100644 --- a/Application/Admin/Controller/UserController.class.php +++ b/Application/Admin/Controller/UserController.class.php @@ -261,7 +261,7 @@ class UserController extends AdminController } } - public function add($username = '', $password = '', $repassword = '', $email = '', $second_pwd = '') + public function add($username = '', $real_name='', $password = '', $repassword = '', $email = '', $second_pwd = '') { if (IS_POST) { @@ -269,6 +269,9 @@ class UserController extends AdminController if (empty($username)) { $this->error('管理员账号不能为空!'); } + if (empty($real_name)) { + $this->error('真实姓名不能为空!'); + } /* 检测密码 */ if ($password != $repassword) { $this->error('管理员密码和确认密码不一致!'); @@ -285,7 +288,7 @@ class UserController extends AdminController $User = new UserApi; $uid = $User->register($username, $password, $email, $second_pwd); if (0 < $uid) { //注册成功 - $user = array('uid' => $uid, 'nickname' => $username, 'status' => 1,"birthday"=>date('Y-m-d',time())); + $user = array('uid' => $uid,'realname'=>$real_name, 'nickname' => $username, 'status' => 1,"birthday"=>date('Y-m-d',time())); $data['uid'] = $uid; $data['group_id'] = I('auth'); M('auth_group_access')->data($data)->add(); @@ -343,6 +346,9 @@ class UserController extends AdminController } } } + if (empty($_POST['real_name'])) { + $this->error('真实姓名不能为空!'); + } if ($_POST['auth'] == '' && $id != 1) { $this->error('请选择用户权限!'); } @@ -389,6 +395,7 @@ class UserController extends AdminController $maps['uid'] = $id; $info['username'] = $_POST['username']; $in['nickname'] = $_POST['username']; + $in['real_name'] = $_POST['real_name']; $pwd = $this->think_ucenter_md5($_POST['password'], UC_AUTH_KEY); $spwd = $this->think_ucenter_md5($_POST['second_pwd'], UC_AUTH_KEY); $rpwd = $Member->where(array('id' => $id))->find(); @@ -428,6 +435,9 @@ class UserController extends AdminController } else { $map['id'] = $_GET['id']; $Member = D('UcenterMember')->where($map)->find(); + + $data = D('Member')->where(array('uid' => $_GET['id']))->find(); + $au = D('AuthGroupAccess')->where(array('uid' => $_GET['id']))->find(); $this->assign("authid", $au["group_id"]); $this->assign("houtai", $au["houtai"]); @@ -435,6 +445,7 @@ class UserController extends AdminController $username = $_POST['username']; $password = $_POST['password']; $this->assign('lists', $list); + $this->assign('data',$data); $this->assign('list', $Member); $this->assign('sd', $group); $this->meta_title = '编辑管理员'; diff --git a/Application/Admin/View/AuthManager/authmarketmember.html b/Application/Admin/View/AuthManager/authmarketmember.html new file mode 100644 index 000000000..8378cdbdc --- /dev/null +++ b/Application/Admin/View/AuthManager/authmarketmember.html @@ -0,0 +1,164 @@ + + + + + 位置 + + 用户 + 管理组 + {$meta_title} + + + + + + 访问授权 + 分类授权 + 数据授权 + 成员授权 + 市场专员分成 + + + + selected >{$vo.title} + + + + + + + + + + + 市场专员分成 + + + + + + + + 业绩提成起提流水: + + + + + + 开发业绩提成比例: + + + + + + 维护业绩提成比例: + + + + + + 业绩月发放比例: + + + + + + + 余下业绩发放时间选择: + + + selected>月 + selected>跨季 + selected>半年 + selected>一年 + + + + + + 考核奖金起提流水: + + + + + + + 开发考核奖金比例: + + + + + + + 维护考核奖金比例: + + + + + + + 奖金月发放比例: + + + + + + + 余下奖金发放时间选择: + + + selected>月 + selected>跨季 + selected>半年 + selected>一年 + + + + + + + + + + + + + 确认 + + + 返回 + + + + + + + + {$_page} + + + + + + + + + + + + + + 已添加添加至常用设置 + + + + + + + diff --git a/Application/Admin/View/AuthManager/category.html b/Application/Admin/View/AuthManager/category.html index 9e976cb56..1343dcfc8 100644 --- a/Application/Admin/View/AuthManager/category.html +++ b/Application/Admin/View/AuthManager/category.html @@ -16,6 +16,9 @@ 分类授权 数据授权 成员授权 + + 市场专员分成 + diff --git a/Application/Admin/View/AuthManager/dataempower.html b/Application/Admin/View/AuthManager/dataempower.html index 0635b726a..2237a2e47 100644 --- a/Application/Admin/View/AuthManager/dataempower.html +++ b/Application/Admin/View/AuthManager/dataempower.html @@ -17,6 +17,9 @@ 数据授权 成员授权 + + 市场专员分成 + diff --git a/Application/Admin/View/AuthManager/index.html b/Application/Admin/View/AuthManager/index.html index 5e19eb690..1a543c92c 100644 --- a/Application/Admin/View/AuthManager/index.html +++ b/Application/Admin/View/AuthManager/index.html @@ -47,6 +47,9 @@ 分类授权 成员授权 数据授权 + + 市场专员分成 + {:get_status_title($vo['status'])} diff --git a/Application/Admin/View/AuthManager/managergroup.html b/Application/Admin/View/AuthManager/managergroup.html index 7cbac77ff..a817267c6 100644 --- a/Application/Admin/View/AuthManager/managergroup.html +++ b/Application/Admin/View/AuthManager/managergroup.html @@ -16,6 +16,9 @@ 分类授权 数据授权 成员授权 + + 市场专员分成 + diff --git a/Application/Admin/View/AuthManager/user.html b/Application/Admin/View/AuthManager/user.html index c28bae755..b9618a0c7 100644 --- a/Application/Admin/View/AuthManager/user.html +++ b/Application/Admin/View/AuthManager/user.html @@ -16,6 +16,9 @@ 分类授权 数据授权 成员授权 + + 市场专员分成 + diff --git a/Application/Admin/View/FinancePromote/gameStatistics.html b/Application/Admin/View/FinancePromote/gameStatistics.html index bca97e492..f46117538 100644 --- a/Application/Admin/View/FinancePromote/gameStatistics.html +++ b/Application/Admin/View/FinancePromote/gameStatistics.html @@ -140,7 +140,7 @@ 请选择开发类型 - $value):?> + $value):?> selected>=$value?> diff --git a/Application/Admin/View/FinancePromote/index.html b/Application/Admin/View/FinancePromote/index.html index 5c6704951..b7bdae4c9 100644 --- a/Application/Admin/View/FinancePromote/index.html +++ b/Application/Admin/View/FinancePromote/index.html @@ -131,7 +131,7 @@ 请选择开发类型 - $value):?> + $value):?> selected>=$value?> diff --git a/Application/Admin/View/FinancePromote/promoteUser.html b/Application/Admin/View/FinancePromote/promoteUser.html index 027028cf2..21dc5d37a 100644 --- a/Application/Admin/View/FinancePromote/promoteUser.html +++ b/Application/Admin/View/FinancePromote/promoteUser.html @@ -117,11 +117,11 @@ - - + + 请选择开发类型 - $value):?> + $value):?> selected>=$value?> diff --git a/Application/Admin/View/MarketPercentage/edittaxratio.html b/Application/Admin/View/MarketPercentage/edittaxratio.html new file mode 100644 index 000000000..586b5f254 --- /dev/null +++ b/Application/Admin/View/MarketPercentage/edittaxratio.html @@ -0,0 +1,130 @@ + + + + + + + + + + + + + 公司税率修改 + 提示:修改税率后请点击“重算” + + + + + + + + + + + + + + 原税率: + + {$data['tax_radio']}% + + + 修改后税率: + + + + + + 生效时间点: + + + + + + + + + + 应用 + + + 返回 + + + + + + + + + + + + + 已添加添加至常用设置 + + + + + + + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + diff --git a/Application/Admin/View/MarketPercentage/index.html b/Application/Admin/View/MarketPercentage/index.html new file mode 100644 index 000000000..37be4c5df --- /dev/null +++ b/Application/Admin/View/MarketPercentage/index.html @@ -0,0 +1,487 @@ + + + + + + + + + + + + + 市场毛利统计 + 说明:市场毛利统计 + + + + + + + + + + 重算 + + + + + + + + 搜索: + + + + + + + + + + + + - + + + + + + + + 请选择会长账号 + + selected=selected>{$vo.account} + + + + + + 请选择游戏 + + >{$vo.relation_game_name} + + + + + + + 搜索 + + + + + + + + + + + + 时间 + 会长账号 + 内外团 + 所属市场专员 + 类型 + 游戏名称 + 总流水 + 上游结算流水 + 下游结算流水 + 支付渠道费用 + 公司税费 + 税后毛利额 + + + + + + + + aOh! 暂时还没有内容! + + + + + + {$data.pay_time} + {$data.promote_account} + {$data.company_belong} + {$data.real_name} + {$data['develop_type']} + {$data['game_name']} + {$data['pay_amount']} + {$data['cp_amount']} + {$data['promote_amount']} + {$data['channel_amount']} + {$data['company_tax']} + {$data['company_profit']} + + + + + + 合计 + + + + {$sum['pay_amount']} + {$sum['cp_amount']} + {$sum['promote_amount']} + {$sum['channel_amount']} + {$sum['company_tax']} + {$sum['company_profit']} + + + + + + + + + + + + 导出 + + {$_page|default=''} + + + + + + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + diff --git a/Application/Admin/View/MarketPercentage/marketstaffsettle.html b/Application/Admin/View/MarketPercentage/marketstaffsettle.html new file mode 100644 index 000000000..c5b39f591 --- /dev/null +++ b/Application/Admin/View/MarketPercentage/marketstaffsettle.html @@ -0,0 +1,480 @@ + + + + + + + + + + + + + 市场业绩提成 + 说明:公会统计仅表示符合筛选条件下的数据统计,当搜索所属市场专员时,因为存在换绑等原因,所以不作为市场业绩统计依据 + + + + + + + + + + 重算 + + + + + + + + 搜索: + + + + + + + + + + + + - + + + + + + + + 请选择人员 + + selected=selected>{$vo.real_name} + + + + + + 请选择级别 + selected>初级 + selected>中级 + selected>高级 + + + + + + 搜索 + + + + + + + + + + + + 时间 + 市场专员 + 级别 + 开发总流水 + 维护总流水 + 业绩提成 + 绩效考核奖金 + 当月合计 + 应发金额 + 待发金额 + + + + + + + + aOh! 暂时还没有内容! + + + + + + {$data.pay_time|default='无'} + {$data.real_name|default='无'} + {$data.level|default='无'} + {$data.performance_revenue|default='0.00'} + + {$data['appraisal_bonuses']|default='0.00'} + {$data['performance_commission']|default='0.00'} + {$data['achievement_bonus']|default='0.00'} + {$data['commission']|default='0.00'} + {$data['extend_commission']|default='0.00'} + {$data['wait_commission']|default='0.00'} + + + 合计 + {$sum['performance_revenue']|default="0.00"} + {$sum['appraisal_bonuses']|default='0.00'} + {$sum['performance_commission']|default='0.00'} + {$sum['achievement_bonus']|default='0.00'} + {$sum['commission']|default='0.00'} + {$sum['extend_commission']|default='0.00'} + + + + + + + + + + + + 导出 + + {$_page|default=''} + + + + + + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + diff --git a/Application/Admin/View/MarketPercentage/personmarketstaffsettle.html b/Application/Admin/View/MarketPercentage/personmarketstaffsettle.html new file mode 100644 index 000000000..64b1572ec --- /dev/null +++ b/Application/Admin/View/MarketPercentage/personmarketstaffsettle.html @@ -0,0 +1,538 @@ + + + + + + + + + + + + + 个人总提成列表 + + + + + + + + + 重算 + + + + + + + 搜索: + + + + + + + + + + + + - + + + + + + + + 请选择人员 + + selected=selected>{$vo.real_name} + + + + + + 请选择剩余金额发放状态 + 已发放 + 未发放 + + + + + + 搜索 + + + + + + + + + + + + 时间 + 市场专员 + 账号 + 级别 + 开发总流水 + 维护总流水 + 税后毛利 + 业绩提成 + 绩效考核奖金 + 当月总提成 + 本月发放 + 本月未发 + 剩余金额发放状态 + 操作 + + + + + + + + aOh! 暂时还没有内容! + + + + + + {$data.pay_time|default='无'} + {$data.real_name|default='无'} + {$data.nickname|default='无'} + {$data.level|default='无'} + {$data.performance_revenue|default='0.00'} + + {$data['appraisal_bonuses']|default='0.00'} + {$data.company_profit|default="0.00"} + {$data['performance_commission']|default='0.00'} + {$data['achievement_bonus']|default='0.00'} + {$data['commission']|default='0.00'} + {$data['extend_commission']|default='0.00'} + {$data['wait_commission']|default='0.00'} + {$data['is_send']|default='未发放'} + + + + + 发放 + 离职发放 + + + + + + + + + + + + 合计 + {$sum.performance_revenue|default="0.00"} + {$sum.appraisal_bonuses|default="0.00"} + {$sum.company_profit|default="0.00"} + {$sum['performance_commission']|default='0.00'} + {$sum['achievement_bonus']|default='0.00'} + {$sum['commission']|default='0.00'} + {$sum['extend_commission']|default='0.00'} + {$sum['wait_commission']|default='0.00'} + + + + + + + + + + + + + + 导出 + + {$_page|default=''} + + + + + + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + diff --git a/Application/Admin/View/MarketPercentage/showbonuslist.html b/Application/Admin/View/MarketPercentage/showbonuslist.html new file mode 100644 index 000000000..c467fc756 --- /dev/null +++ b/Application/Admin/View/MarketPercentage/showbonuslist.html @@ -0,0 +1,479 @@ + + + + + + + + + + + + + 提成数据汇总表 + + + + + + + + + + 重算 + + + + + + + 搜索: + + + + + + + + + + + + + - + + + + + + + + + 请选择人员 + + selected=selected>{$vo.real_name} + + + + + + 请选择账号 + + selected=selected>{$vo.nickname} + + + + + + 请选择级别 + selected>初级 + selected>中级 + selected>高级 + + + + + + 搜索 + + + + + + + + + + + + 姓名 + 账号 + 级别 + 总流水 + 总提成 + 已发放总提成 + 剩余未发放总提成 + 操作备注 + + + + + + + + aOh! 暂时还没有内容! + + + + + + {$data.real_name} + {$data.nickname} + {$data.level} + {$data.pay_amount} + {$data.commission} + {$data['extend_commission']} + {$data['wait_commission']} + {$data['remark']} + + + 合计 + {$sum['pay_amount']|default="0.00"} + {$sum['commission']|default="0.00"} + {$sum['extend_commission']|default='0.00'} + {$sum['wait_commission']|default='0.00'} + + + + + + + + + + + + 导出 + + {$_page|default=''} + + + + + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + + diff --git a/Application/Admin/View/PromoteCompany/edit.html b/Application/Admin/View/PromoteCompany/edit.html index 30be1cfa6..e9768e68a 100644 --- a/Application/Admin/View/PromoteCompany/edit.html +++ b/Application/Admin/View/PromoteCompany/edit.html @@ -198,7 +198,7 @@ 开发类型: - 请选择开发类型 + 请选择开发类型 selected>自主开发 selected>自主开发及维护 selected>只维护 diff --git a/Application/Admin/View/Stat/userretention.html b/Application/Admin/View/Stat/userretention.html index b12f2c343..714745428 100644 --- a/Application/Admin/View/Stat/userretention.html +++ b/Application/Admin/View/Stat/userretention.html @@ -155,6 +155,7 @@ 'end' =>I('end',date('Y-m-d',time())), 'game_id'=>I('game_id'), 'promote_id'=>I('promote_id'), + 'device_type'=>I('device_type'), 'xlsname'=>'数据分析_留存率分析',) ,false)}">导出 diff --git a/Application/Admin/View/User/add.html b/Application/Admin/View/User/add.html index 28b04cbee..755d599e1 100644 --- a/Application/Admin/View/User/add.html +++ b/Application/Admin/View/User/add.html @@ -12,7 +12,7 @@ - *管理员账号 + *账号 @@ -20,7 +20,15 @@ - *管理员密码 + *真实姓名 + + + + 管理员真实姓名 + + + + *密码 管理员密码不能少于6位 diff --git a/Application/Admin/View/User/edit.html b/Application/Admin/View/User/edit.html index 3bff5e5b5..815296928 100644 --- a/Application/Admin/View/User/edit.html +++ b/Application/Admin/View/User/edit.html @@ -18,6 +18,14 @@ 管理员账号用于管理后台登录 + + 真实姓名 + + + + 管理员真实姓名 + + 管理员密码 diff --git a/Data/update.sql b/Data/update.sql index 38ab12252..b635d2f92 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -2103,4 +2103,47 @@ CREATE TABLE `tab_excel_statement_info` ( KEY `statement_begin_time` (`statement_begin_time`) USING BTREE, KEY `statement_end_time` (`statement_end_time`) USING BTREE, KEY `pay_status` (`pay_status`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='exce汇总单'; \ No newline at end of file +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='exce汇总单'; +--市场专员提成结算 zyx 20200629 +ALTER TABLE `sys_member` +ADD COLUMN `real_name` varchar(255) NULL DEFAULT '' COMMENT '真实姓名' AFTER `status`; + +CREATE TABLE `tab_settleup_marketorder` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `pay_time` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT '' COMMENT '月份时间', + `company_id` int(11) NULL DEFAULT 0 COMMENT '公司id', + `promote_id` int(11) NULL DEFAULT 0 COMMENT '推广员id', + `promote_account` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT '' COMMENT '推广员账号', + `company_belong` tinyint(2) NULL DEFAULT 0 COMMENT '工会归属:0-内团;1-外团 2-分发联盟 3 无', + `develop_type` tinyint(2) NULL DEFAULT 0 COMMENT '开发类型 1 自主开发 2 自主开发及维护 3 只维护', + `game_id` int(11) NULL DEFAULT 0 COMMENT '游戏id', + `game_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '游戏名称', + `relation_game_id` int(11) NULL DEFAULT 0 COMMENT '关联游戏id', + `pay_amount` decimal(13, 2) NOT NULL DEFAULT 0.00 COMMENT '总流水', + `real_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT '' COMMENT '市场专员姓名', + `admin_id` int(11) NULL DEFAULT 0 COMMENT '市场专员id', + `cp_amount` decimal(13, 2) NULL DEFAULT 0.00 COMMENT '上游结算流水', + `promote_amount` decimal(13, 2) NULL DEFAULT 0.00 COMMENT '下游结算流水', + `channel_amount` decimal(13, 2) NULL DEFAULT 0.00 COMMENT '支付渠道费用', + `company_tax` decimal(13, 2) NULL DEFAULT 0.00 COMMENT '公司税费', + `company_profit` decimal(13, 2) NULL DEFAULT 0.00 COMMENT '毛利', + `sdk_version` tinyint(2) NULL DEFAULT 1 COMMENT '设备类型 1 安卓 2 ios', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic; + +CREATE TABLE `tab_market_altogether` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `pay_time` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT '' COMMENT '时间月份记录', + `real_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT '' COMMENT '管理员姓名', + `admin_id` int(11) NULL DEFAULT NULL COMMENT '管理员id', + `nickname` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT '' COMMENT '管理员账号', + `level` tinyint(2) NULL DEFAULT 0 COMMENT '级别:21:初级 11:中级 12:高级', + `pay_amount` decimal(13, 2) NULL DEFAULT 0.00 COMMENT '总流水', + `extend_commission` decimal(13, 2) NULL DEFAULT 0.00 COMMENT '已发放金额', + `wait_commission` decimal(13, 2) NULL DEFAULT 0.00 COMMENT '待发放金额', + `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT '' COMMENT '备注', + `create_time` int(11) NULL DEFAULT 0 COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic; + +INSERT INTO `tab_tool`(`id`, `name`, `title`, `config`, `type`, `status`) VALUES (59, 'tax_radio', '公司税费', '{"tax_radio":1.5,"time":1589361782}', 1, 1)
提示:修改税率后请点击“重算”
说明:市场毛利统计
说明:公会统计仅表示符合筛选条件下的数据统计,当搜索所属市场专员时,因为存在换绑等原因,所以不作为市场业绩统计依据