12.18功能提交

master
zhengyongxing 4 years ago
parent c30e396b2c
commit 8430fa1813

@ -14,6 +14,7 @@ class FinancialSummaryController extends AdminController
"outer_count"=>"外团",
"outer_branch_count"=>"外团-分发",
"other_group_count"=>"无归属团",
"unsettlement_count"=>"不结算流水",
);
public function _initialize()
{

@ -133,7 +133,6 @@ class FinancialSummarySetController extends \Think\Controller
$map = array(
"payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"pay_status"=>1,
'is_check'=>['neq',2],
);
$res = $this->SpendModel
->field("IFNULL(SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END),0) as cash_count,IFNULL(SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END),0) as balance_coin_count")
@ -267,7 +266,6 @@ class FinancialSummarySetController extends \Think\Controller
$map = array(
"payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"pay_status"=>1,
'is_check'=>['neq',2],
);
$res = $this->SpendModel
->alias('s')
@ -307,6 +305,7 @@ class FinancialSummarySetController extends \Think\Controller
$inside_nobind_count += ($v['cash_count']*100+$v['balance_coin_count']*100);
}
}
//处理数据
$this->adddata[] = array(
"key_name"=>'inside_count',
@ -349,6 +348,41 @@ class FinancialSummarySetController extends \Think\Controller
"type"=>3,"sort"=>4,
"sum_money"=>number_format($other_group_nobind_count/100, 2, '.', '')
);
$unsettlement_count = 0;
$unsettlement_nobind_count = 0;
$unmap = $map;
$unmap['is_check'] = 2;
$unSettlementRes = $this->SpendModel
->alias('s')
->field("IFNULL(SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END),0) as cash_count,
IFNULL(SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END),0) as balance_coin_count,
IFNULL(SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END),0) as bind_coin_count,
promote.company_belong")
->where($unmap)
->join("tab_promote promote ON s.promote_id = promote.id", "left")
->select();
foreach ($unSettlementRes as $key => $value) {
$unsettlement_count += $value['cash_count']*100 + $value['balance_coin_count']*100 + $value['bind_coin_count']*100;
$unsettlement_nobind_count += $value['cash_count']*100 + $value['balance_coin_count']*100;
}
//不结算金额
$this->adddata[] = array(
"key_name"=>'unsettlement_count',
"type"=>2,"sort"=>5,
"sum_money"=>number_format($unsettlement_count/100, 2, '.', '')
);
//不结算金额不含绑币
$this->adddata[] = array(
"key_name"=>'unsettlement_count',
"type"=>3,"sort"=>5,
"sum_money"=>number_format($unsettlement_nobind_count/100, 2, '.', '')
);
}
public function setChannelMoney(){
@ -454,7 +488,6 @@ class FinancialSummarySetController extends \Think\Controller
"s.payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"s.pay_status"=>1,
"s.merchant_id"=>["GT","0"],
'is_check'=>['neq',2],
);
$spres=$this->SpendModel
->alias("s")
@ -547,7 +580,7 @@ class FinancialSummarySetController extends \Think\Controller
payed_time,game_id,main_name,merchant_way,merchant.account")
->join("left join tab_test_white_list on tab_spend.user_id=tab_test_white_list.user_id")
->join("left join tab_payment_merchant merchant on merchant.id=tab_spend.merchant_id")
->where(['pay_status'=>1,'tab_spend.pay_way'=>['egt',1],'merchant.status'=>1,'merchant.type'=>1,'is_check'=>['neq',2]])
->where(['pay_status'=>1,'tab_spend.pay_way'=>['egt',1],'merchant.status'=>1,'merchant.type'=>1])
->where($map)
->group("merchant_id")
->select(false);

@ -11,6 +11,21 @@ use User\Api\UserApi as UserApi;
class MarketPercentageController extends ThinkController
{
protected $coefficient = [];
protected function _initialize()
{
$coefficient_data = M("coefficient","tab_")->where("1=1")->select();
foreach ($coefficient_data as $key => $value) {
$this->coefficient[$value['pay_time']][$value['admin_id']] = $value['coefficient']/100;
}
parent::_initialize();
}
public function index($row = 10, $p = 1){
$map = [];
@ -367,6 +382,173 @@ class MarketPercentageController extends ThinkController
}
public function addcoefficient() {
$batch = date('Ymd').date('His').sp_random_num(3);
$this->assign("batch",$batch);
$this->meta_title = 'EXCEL导入';
$this->display();
}
public function loopAdd()
{
$p = $_REQUEST;
// $batch = $p['batch'];
$checkarr = $p['checkarr'];
//循环获取添加
if(count($checkarr) < 1){
$this->ajaxReturn(["status"=>1,"msg"=>"ok"]);
}
$data = M("auth_group")
->where(['title'=>['like','%市场专员%']])
->select(false);
$member = M("auth_group_access")
->field("sys_member.nickname,sys_member.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();
$handle_member = [];
foreach($member as $key => $value) {
$handle_member[$value['real_name']] = $value;
}
$save = [];
$coefficient = M('coefficient',"tab_");
foreach ($checkarr as $k => $v) {
if(!strtotime($v['pay_time'])) {
$this->ajaxReturn(["status"=>0,"msg"=>"导入失败,序号{$v['sort']}行日期格式错误"]);
}
if ($handle_member[$v['nickname']]) {
if ($save[$v['nickname'].$v['pay_time']]) {
$this->ajaxReturn(["status"=>0,"msg"=>"导入失败,序号{$v['sort']}行存在重复记录"]);
}
$hav_coefficient = $coefficient
->where(['admin_id'=>$handle_member[$v['nickname']]['uid'],'pay_time'=>$v['pay_time']])
->find();
if ($hav_coefficient) {
$this->ajaxReturn(["status"=>0,"msg"=>"导入失败,日期{$v['pay_time']}市场员{$handle_member[$v['nickname']]['real_name']}已经存在,请勿重复导入"]);
}
$save[$v['nickname'].$v['pay_time']]['pay_time'] = $v['pay_time'];
$save[$v['nickname'].$v['pay_time']]['real_name'] = $handle_member[$v['nickname']]['real_name'];
$save[$v['nickname'].$v['pay_time']]['admin_id'] = $handle_member[$v['nickname']]['uid'];
$save[$v['nickname'].$v['pay_time']]['nickname'] = $handle_member[$v['nickname']]['nickname'];
$save[$v['nickname'].$v['pay_time']]['coefficient'] = $v['coefficient']*100;
if ($v['coefficient'] > 1) {
$this->ajaxReturn(["status"=>0,"msg"=>"导入失败,序号{$v['sort']}行系数错误,系数超过最大值1"]);
}
} else {
$this->ajaxReturn(["status"=>0,"msg"=>"导入失败,导入的市场员{$v['nickname']}不存在"]);
}
}
$save = array_values($save);
if ($coefficient->addAll($save)) {
$this->ajaxReturn(["status"=>1,"msg"=>"导入成功"]);
}
}
public function coefficientSave() {
$pay_time =date('Y-m',strtotime(date('Y',time()).'-'.(date('m',time())-1).'-01'));
if ($_REQUEST['is_get']) {
unset($_GET['is_get']);
$data = $_GET;
$admin = $_SESSION['onethink_admin']['user_auth']['username'];
$coefficient_check_detail = "已审批({$admin}<br>".date("Y-m-d H:i:s",time());
$marketSave['coefficient_check'] = 1;
$marketSave['coefficient_check_detail'] = $coefficient_check_detail;
foreach ($data as $key => $value) {
//解析键值信息
$info = explode('-',$key);
$save['nickname'] = $info[0];
$save['admin_id'] = $info[1];
$save['real_name'] = $info[2];
$save['coefficient'] = $value*100;
$save['pay_time'] = $pay_time;
$is_hav = M("coefficient","tab_")
->where([
'pay_time'=>$save['pay_time'],
'admin_id'=>$save['admin_id']
])
->find();
if ($is_hav) {
if ($is_hav['coefficient'] != $save['coefficient']) {
$save['update_time'] = time();
M("coefficient","tab_")
->where([
'pay_time'=>$save['pay_time'],
'admin_id'=>$save['admin_id']
])->save(['coefficient'=>$save['coefficient']]);
M("market_altogether","tab_")->where([
'pay_time'=>$save['pay_time'],
'admin_id'=>$save['admin_id']
])->save($marketSave);
}
} else {
$save['create_time'] = time();
M("coefficient","tab_")->add($save);
M("market_altogether","tab_")->where([
'pay_time'=>$save['pay_time'],
'admin_id'=>$save['admin_id']
])->save($marketSave);
}
}
$this->ajaxReturn(['status'=>1,'msg'=>"绩效编辑成功"]);
} else {
$data = M("auth_group")
->where(['title'=>['like','%市场专员%']])
->select(false);
$data = M("auth_group_access")
->field("sys_member.nickname,sys_member.real_name,sys_member.uid,sys_auth_group_access.group_id,IF(coefficient is not NULL, coefficient, 100) coefficient")
->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")
->join("left join tab_coefficient on tab_coefficient.admin_id = sys_member.uid and pay_time='{$pay_time}'")
->where("auth.title is not null")
->select();
$this->assign('list_data',$data);
$this->display("coefficient");
}
}
public function marketStaffSettle($row = 10, $p = 1) {
$map = [];
@ -493,13 +675,19 @@ class MarketPercentageController extends ThinkController
$this->checkListOrCountAuthRestMap($map,[]);
if(IS_ROOT){
$this->assign('coefficient_check',true);
$this->assign('market_check',true);
$this->assign('finance_check',true);
$this->assign('coefficient_in_check',true);
}else {
$exportRule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME . "_coefficient_check");
$this->assign('coefficient_check',$this->checkRule($exportRule,array('in','1,2')));
$exportRule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME . "_market_check");
$this->assign('market_check',$this->checkRule($exportRule,array('in','1,2')));
$exportRule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME . "_finance_check");
$this->assign('finance_check',$this->checkRule($exportRule,array('in','1,2')));
$exportRule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME . "_coefficient_in_check");
$this->assign('coefficient_in_check',$this->checkRule($exportRule,array('in','1,2')));
}
$all_data = M("market_altogether","tab_")
@ -546,17 +734,20 @@ class MarketPercentageController extends ThinkController
if(!$value['market_check']) {
$data[$key]['market_check_detail'] = "-----";
//{$admin}<br>".date("Y-m-d H:m:s",time());
}
if (!$value['finance_check']) {
$data[$key]['finance_check_detail'] = "-----";
//{$admin}<br>".date("Y-m-d H:m:s",time());
}
if (!$value['coefficient_check']) {
$data[$key]['coefficient_check_detail'] = "-----";
}
if ($_REQUEST['export']) {
$data[$key]['market_check_detail'] = str_replace("<br>",'',$data[$key]['market_check_detail']);
$data[$key]['finance_check_detail'] = str_replace("<br>",'',$data[$key]['finance_check_detail']);
$data[$key]['coefficient_check_detail'] = str_replace("<br>",'',$data[$key]['coefficient_check_detail']);
}
$market_percentage = json_decode($value['market_percentage'],true);
@ -569,11 +760,18 @@ class MarketPercentageController extends ThinkController
//维护奖金考核比例
$data[$key]['maintain_appraisal_bonuses_ratio'] = $market_percentage['maintain_appraisal_bonuses_ratio'];
$data[$key]['coefficient'] = $this->coefficient[$value['pay_time']][$value['admin_id']];
$month = date("m",strtotime($value['pay_time']));
$yes = date("Y",strtotime($value['pay_time']));
$achievement_bonus = number_format($data[$key]['achievement_bonus'], 2, '.', '');
//绩效系数计算
$data[$key]['achievement_bonus'] = number_format($data[$key]['achievement_bonus'] * ($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1), 2, '.', '');
$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]['wait_commission'] = substr(number_format($value['wait_performance_commission'] + $value['wait_achievement_commission']*($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1), 4, '.', ''),0,-2);
$data[$key]['extend_commission'] = $data[$key]['commission'] - $data[$key]['wait_commission'];
//两个起提流水都没达到时,不展示税后毛利
@ -583,7 +781,6 @@ class MarketPercentageController extends ThinkController
$value['company_profit'] = "0.00";
}
if ($market_percentage['time'] == 1) {
if ($month == '07') {
@ -688,6 +885,8 @@ class MarketPercentageController extends ThinkController
$data[$key]['extend_commission'] = number_format($data[$key]['extend_commission'],2,'.','');
$data[$key]['wait_commission'] = number_format($data[$key]['wait_commission'],2,'.','');
$data[$key]['achievement_bonus'] = $achievement_bonus;
$sum['performance_revenue'] += $data[$key]['performance_revenue'];
$sum['appraisal_bonuses'] += $data[$key]['appraisal_bonuses'];
$sum['performance_commission'] += $data[$key]['performance_commission'];
@ -696,6 +895,8 @@ class MarketPercentageController extends ThinkController
$sum['extend_commission'] += $data[$key]['extend_commission'];
$sum['company_profit'] += $data[$key]['company_profit'];
}
$sum['wait_commission'] = '-------';
$sum['pay_time'] = '总计';
@ -715,9 +916,11 @@ class MarketPercentageController extends ThinkController
'performance_profit'=>'维护税后毛利',
'performance_commission' => '业绩提成',
'achievement_bonus' => '绩效考核奖金',
'coefficient'=>'绩效系数',
'commission' => '当月合计',
'extend_commission' => '应发金额',
'wait_commission' => '待发金额',
'coefficient_check_detail'=>'绩效确认',
'market_check_detail' => '市场部确认',
'finance_check_detail' => '财务部审批'];
@ -786,7 +989,7 @@ class MarketPercentageController extends ThinkController
// $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(L{$line}+M{$line},2)";
$data[$key]['commission'] = "=ROUND(L{$line}+M{$line}*N{$line},2)";
}
$data = array_merge($data,[$sum]);
@ -952,21 +1155,30 @@ class MarketPercentageController extends ThinkController
$value['company_profit'] = "0.00";
}
$data[$key]['coefficient'] = $this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1;
$data[$key]['wait_commission'] =
number_format($value['wait_performance_commission'] + $value['wait_achievement_commission'], 2, '.', '');
number_format($value['wait_performance_commission'] + $value['wait_achievement_commission']*($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1), 2, '.', '');
$achievement_bonus = number_format($data[$key]['achievement_bonus'], 2, '.', '');
$data[$key]['commission'] = $data[$key]['performance_commission'] + $data[$key]['achievement_bonus'];
//绩效系数计算
$data[$key]['achievement_bonus'] = number_format($data[$key]['achievement_bonus'] * ($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1), 2, '.', '');
$data[$key]['commission'] = number_format($data[$key]['performance_commission'] + $data[$key]['achievement_bonus'], 2, '.', '');;
$data[$key]['extend_commission'] = $data[$key]['commission'] - $data[$key]['wait_commission'];
$sum['performance_revenue'] += $value['performance_revenue'];
$sum['appraisal_bonuses'] += $value['appraisal_bonuses'];
$data[$key]['achievement_bonus'] = $achievement_bonus;
$sum['company_profit'] += $value['company_profit'];
$sum['performance_commission'] += $value['performance_commission'];
$sum['achievement_bonus'] += $value['achievement_bonus'];
$sum['achievement_bonus'] += $data[$key]['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['wait_commission'] += $data[$key]['wait_commission'];
}
@ -993,6 +1205,7 @@ class MarketPercentageController extends ThinkController
'company_profit'=>'税后毛利',
'performance_commission' => '业绩提成',
'achievement_bonus' => '绩效考核奖金',
'coefficient'=>'绩效系数',
'commission' => '当月总提成',
'extend_commission' => '本月发放',
'wait_commission' => '本月未发',
@ -1053,51 +1266,6 @@ class MarketPercentageController extends ThinkController
}
}
// $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']) {
@ -1150,12 +1318,12 @@ class MarketPercentageController extends ThinkController
->where(['group_id'=>['in','11,12,21']])
->select();
if ($admin_data) {
$map['admin_id'] = ['in',array_column($admin_data,'admin_id')];
$map['tab_market_altogether.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['pay_time']?$map['tab_market_altogether.pay_time'] = $_REQUEST['pay_time']:'';
$_REQUEST['real_name']?$map['tab_market_altogether.real_name'] = $_REQUEST['real_name']:'';
$_REQUEST['nickname']?$map['tab_market_altogether..nickname'] = $_REQUEST['nickname']:'';
$_REQUEST['level']?$map['level'] = $_REQUEST['level']:'';
@ -1172,7 +1340,7 @@ class MarketPercentageController extends ThinkController
}while ($date < date('Y-m', strtotime("{$end}")));
if ($search_date) {
$map['pay_time'] = ['in', $search_date];
$map['tab_market_altogether.pay_time'] = ['in', $search_date];
}
} elseif (isset($_REQUEST['time_start'])) {
@ -1187,7 +1355,7 @@ class MarketPercentageController extends ThinkController
}while ($date < date('Y-m', strtotime("{$end}")));
if ($search_date) {
$map['pay_time'] = ['in', $search_date];
$map['tab_market_altogether.pay_time'] = ['in', $search_date];
}
} elseif (isset($_REQUEST['time_end'])) {
@ -1202,51 +1370,62 @@ class MarketPercentageController extends ThinkController
}while ($date < date('Y-m', strtotime("{$end}")));
if ($search_date) {
$map['pay_time'] = ['in', $search_date];
$map['tab_market_altogether.pay_time'] = ['in', $search_date];
}
}
if($_REQUEST['pay_time']) {
if (in_array($_REQUEST['pay_time'],$search_date)) {
$map['pay_time'] = $_REQUEST['pay_time'];
$map['tab_market_altogether.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'];
$map['tab_market_altogether.pay_time'] = $_REQUEST['pay_time'];
}
}
$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,
->field("max(tab_market_altogether.pay_time) pay_time,tab_market_altogether.real_name,tab_market_altogether.admin_id,tab_market_altogether.nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission,
sum(performance_commission) performance_commission,sum(achievement_bonus* IF(coefficient is not NULL, coefficient, 100)/100) 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")
sum(if(status > 0, wait_performance_commission, '0.00')) + sum(if(status > 0, wait_achievement_commission,'0.00') * IF(coefficient is not NULL, coefficient, 100)/100 ) wait_extend_commission,
sum(if(status = 0, wait_performance_commission, '0.00')) + round(sum(if(status = 0, wait_achievement_commission,'0.00') * IF(coefficient is not NULL, coefficient, 100)/100),2) wait_commission, remark,status")
->where($map);
if ($_REQUEST['export']) {
$data = $data
->order("pay_time DESC,company_profit DESC")
->group("admin_id")
->select();
->join("left join tab_coefficient on tab_market_altogether.admin_id=tab_coefficient.admin_id and tab_coefficient.pay_time=tab_market_altogether.pay_time")
->order("tab_market_altogether.pay_time DESC,company_profit DESC")
->group("tab_market_altogether.admin_id,tab_market_altogether.pay_time")
->select(false);
} else {
$data = $data
// ->page($p, $row)
->order("pay_time DESC,company_profit DESC")
->group("admin_id")
->select();
->join("left join tab_coefficient on tab_market_altogether.admin_id=tab_coefficient.admin_id and tab_coefficient.pay_time=tab_market_altogether.pay_time")
->order("tab_market_altogether.pay_time DESC,company_profit DESC")
->group("tab_market_altogether.admin_id,tab_market_altogether.pay_time")
->select(false);
}
$data = M()->table("({$data})a")
->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_amount) wait_amount,
sum(wait_extend_commission) wait_extend_commission,sum(wait_commission) wait_commission,remark,status")
->group("admin_id")
->select();
// var_dump($data);die();
$sum = [];
$sum['pay_amount'] = 0;
$sum['extend_commission'] = 0;
$sum['wait_commission'] = 0;
foreach($data as $key => $value) {
// dump($value);
if ($value['level'] == 21) {
$data[$key]['level'] = '初级';
} else if ($value['level'] == 11) {
@ -1255,7 +1434,13 @@ class MarketPercentageController extends ThinkController
$data[$key]['level'] = '高级';
}
$data[$key]['commission'] = $data[$key]['performance_commission'] + $data[$key]['achievement_bonus'];
//绩效系数计算
// $data[$key]['achievement_bonus'] = $data[$key]['achievement_bonus'] * ($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1);
$data[$key]['commission'] = number_format($data[$key]['performance_commission'] + $data[$key]['achievement_bonus'], 2, '.', '');
// $data[$key]['wait_commission'] =
// number_format($value['wait_performance_commission'] + $value['wait_achievement_commission']*($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1), 2, '.', '');
$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, '.', '');
@ -1374,7 +1559,7 @@ class MarketPercentageController extends ThinkController
$this->ajaxReturn(['status'=>0,'info'=>'操作失败,id不能为空']);
}
$admin = $_SESSION['onethink_admin']['user_auth']['username'];
$market_check_detail = "市场部已确认({$admin}<br>".date("Y-m-d H:m:s",time());
$market_check_detail = "市场部已确认({$admin}<br>".date("Y-m-d H:i:s",time());
$is_save = M("market_altogether","tab_")
->where(['id'=>['in',$ids],'market_check'=>0])
@ -1397,7 +1582,7 @@ class MarketPercentageController extends ThinkController
}
$admin = $_SESSION['onethink_admin']['user_auth']['username'];
$finance_check_detail = "财务部已审批({$admin}<br>".date("Y-m-d H:m:s",time());
$finance_check_detail = "财务部已审批({$admin}<br>".date("Y-m-d H:i:s",time());
$is_save = M("market_altogether","tab_")
->where(['id'=>['in',$ids],'finance_check'=>0])

@ -1328,6 +1328,7 @@ class PlatformController extends ThinkController
'admin_username' => '当前市场专员',
'relation_game_name' => '游戏',
"count"=>"累计充值",
"unpay_count"=>"累计充值",
"rand"=>"排行榜",
"today"=>"今日充值",
"week"=>"本周充值",
@ -1351,6 +1352,7 @@ class PlatformController extends ThinkController
public function data_total($data)
{
$total['sum_count'] = array_sum(array_column($data, 'count'));
$total['unpay_count'] = array_sum(array_column($data, 'unpay_count'));
$total['sum_today'] = array_sum(array_column($data, 'today'));
$total['sum_week'] = array_sum(array_column($data, 'week'));
$total['sum_mounth'] = array_sum(array_column($data, 'mounth'));

@ -328,7 +328,7 @@ class StatementMangementController extends ThinkController
->join('tab_reward_detail as rd on rd.record_id = r.id', 'LEFT')
->where($map)
->group('r.id')
// ->order('create_time DESC')
->order('create_time DESC')
->select();
if ($result) {
@ -520,8 +520,15 @@ class StatementMangementController extends ThinkController
}
$settlmentSet = array_merge($settlment_info[RewardModel::REWARD_TYPE_REWARD] ?? [], $settlment_info[RewardModel::REWARD_TYPE_PUNISH] ?? []);
// dump($settlmentSet);die();
if ($id) {
$checkReward = $this->checkRewardDetail($settlmentSet);
if ($checkReward) {
return $this->error("奖惩确认时间需在结算时间以后,请重新选择");
}
$upt = M('reward_record', 'tab_')->where(['id'=>$id])->save($data);
if ($upt === false) {
$this->error('保存失败');
@ -536,6 +543,11 @@ class StatementMangementController extends ThinkController
}
} else {
$checkReward = $this->checkRewardDetail($settlmentSet);
if ($checkReward) {
return $this->error("奖惩确认时间需在结算时间以后,请重新选择");
}
$data['create_time'] = time();
$data['creater_id'] = is_login();
$ins = M('reward_record', 'tab_')->add($data);
@ -609,6 +621,38 @@ class StatementMangementController extends ThinkController
}
}
public function checkRewardDetail($settlmentSet = []) {
foreach ($settlmentSet as $key => $value) {
if ($value['company_id']) {
$sql = "(select statement_begin_time,statement_end_time,company_id,company_name from tab_company_statement
union all select statement_begin_time,statement_end_time,company_id,company_name from tab_company_statement_info
union all select statement_begin_time,statement_end_time,company_id,company_name from tab_company_lack_statement_info where is_pool=0)statement_info";
$data = M()->table("$sql")
->where(
[
'statement_begin_time'=>['elt',$value['confirm_time']],
'statement_end_time'=>['egt',$value['confirm_time']],
'company_id'=>$value['company_id']
]
)
->select();
if ($data) {
return true;
}
}
}
return false;
}
public function rewardManageDetail($id=0)
{
$games = M('game', 'tab_')->field('relation_game_id, relation_game_name')->group('relation_game_id')->select();

@ -58,6 +58,47 @@
right: 20px;
left: auto;
}
.tooltip {
position: relative;
display: inline-block;
color: #056dae;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 250%;
background-color: #fff;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 80%;
left: 0;
margin-left: -70%;
border: #000 solid 1px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: black transparent transparent transparent;
}
.tooltip:hover .tooltiptext {
color: #000;
visibility: visible;
line-height: 20px;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
@ -127,12 +168,18 @@
<div class="butnbox" >
<div class="butnlist jscheckbutn" style="margin-left: 2px">
<if condition="$coefficient_check eq true">
<a class='butn' id='coefficient_check' style='background-color: #3C95C8;'>绩效确认</a>
</if>
<if condition="$market_check eq true">
<a class='butn' id='market_check' style='background-color: #3C95C8;'>市场部确认</a>
</if>
<if condition="$finance_check eq true">
<a class='butn' id='finance_check' style='background-color: #3C95C8;'>财务部审批</a>
</if>
<if condition="$coefficient_in_check eq true">
<a class='butn' id='coefficient_in_check' href="{:U('addcoefficient')}" style='background-color: #3C95C8;'>绩效导入</a>
</if>
</div>
</div>
@ -148,13 +195,15 @@
<th>时间</th>
<th>市场专员</th>
<th>级别</th>
<th>开发总流水</th>
<th>维护总流水</th>
<th><div class="tooltip">开发总流水<span class="tooltiptext"><span style="margin-left: -10px">当月自主开发下渠道游戏内充值总和</span></span></div></th>
<th><div class="tooltip">维护总流水<span class="tooltiptext"><span style="margin-left: -10px">当月只维护下渠道游戏内充值总和</span></span></div></th>
<th >业绩提成</th>
<th >绩效考核奖金</th>
<th ><div class="tooltip">绩效考核奖金<span class="tooltiptext"><span style="margin-left: -10px">当月开发税后毛利奖金与维护税后毛利奖金之和</span></span></div></th>
<th >绩效系数</th>
<th>当月合计</th>
<th>应发金额</th>
<th>本月应发金额</th>
<th>待发金额</th>
<th>绩效确认</th>
<th>市场部确认</th>
<th>财务部审批</th>
</tr>
@ -170,7 +219,7 @@
<notemtpy name = "list_data">
<volist name="list_data" id="data">
<tr>
<td><input class="ids" type="checkbox" value="{$data['id']}" data-market_check="{$data['market_check']}" data-finance_check="{$data['finance_check']}" name="ids[]"></td>
<td><input class="ids" type="checkbox" value="{$data['id']} "data-coefficient_check="{$data['coefficient_check']}" data-market_check="{$data['market_check']}" data-finance_check="{$data['finance_check']}" name="ids[]"></td>
<td>{$data.pay_time|default='无'}</td>
<td>{$data.real_name|default='无'}</td>
<td>{$data.level|default='无'}</td>
@ -179,9 +228,11 @@
<td><a href="{:U('FinancePromote/index',array('time_start'=>$data['start_time'],'time_end'=>$data['end_time'],'admin_id'=>$data['admin_id'],'develop_type'=>3))}" >{$data['appraisal_bonuses']|default='0.00'}</a></td>
<td>{$data['performance_commission']|default='0.00'}</td>
<td>{$data['achievement_bonus']|default='0.00'}</td>
<td>{$data['coefficient']|default='1'}</td>
<td>{$data['commission']|default='0.00'}</td>
<td><a href="{:U('MarketPercentage/personMarketStaffSettle',array('time_start'=>$data['start_time'],'time_end'=>$data['end_time'],'admin_id'=>$data['admin_id']))}" >{$data['extend_commission']|default='0.00'}</a></td>
<td><a href="{:U('MarketPercentage/showBonusList',array('time_start'=>$data['start_time'],'time_end'=>$data['end_time'],'real_name'=>$data['real_name'],'level'=>$data['group_id']))}" >{$data['wait_commission']|default='0.00'}</a></td>
<td><if condition="$data.coefficient_check eq 0"><span ></if>{$data['coefficient_check_detail']|default=''}<if condition="$data.market_check eq 1"></span></if></td>
<td><if condition="$data.market_check eq 0"><span ></if>{$data['market_check_detail']|default=''}<if condition="$data.market_check eq 1"></span></if></td>
<td><if condition="$data.finance_check eq 0"><span ></if>{$data['finance_check_detail']|default=''}<if condition="$data.market_check eq 1"></span></if></td>
</tr>
@ -199,11 +250,13 @@
</td>
<td>{$sum['performance_commission']|default='0.00'}</td>
<td>{$sum['achievement_bonus']|default='0.00'}</td>
<td></td>
<td>{$sum['commission']|default='0.00'}</td>
<td><a href="{:U('MarketPercentage/personMarketStaffSettle',array('time_start'=>$start_time,'time_end'=>$end_time))}" >{$sum['extend_commission']|default='0.00'}</a></td>
<td></td>
<td></td>
<td></td>
<td></td>
</notemtpy>
</tbody>
</table>
@ -236,17 +289,44 @@
<script type="text/javascript">
//导航高亮
highlight_subnav('{:U('MarketPercentage/marketStaffSettle')}');
function reload(){
location.reload();
}
$(function(){
$("#coefficient_check").on("click",function() {
layer.open({
type: 2,
title: "绩效确认",
shadeClose: true
,area: ['100%','100%']
,top:50
,content: '{:U("MarketPercentage/coefficientSave")}'
,cancel: function(){
//右上角关闭回调
//return false 开启该代码可禁止点击该按钮关闭
}
});
});
$("#market_check").on("click",function(){
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
if($(elem).data("market_check") == 0){
if($(elem).data("market_check") == 0&&$(elem).data("coefficient_check")==1){
return $(elem).val();
}
}).get();
if(text.length < 1){
layer.msg("<font style='color:white'>" + '无需要进行[市场部确认]的申请,仅[市场部未确认]状态可以进行[市场部确认]操作</font>');
layer.msg("<font style='color:white'>" + '无需要进行[市场部确认]的申请,仅[绩效已确认,市场部未确认]状态可以进行[市场部确认]操作</font>');
return;
}
text = text.join(",");

@ -105,8 +105,9 @@
<th>税后毛利</th>
<th >业绩提成</th>
<th >绩效考核奖金</th>
<th >绩效系数</th>
<th>当月总提成</th>
<th>本月发放</th>
<th>本月应发金额</th>
<th>本月未发</th>
<th>剩余金额发放状态</th>
<th>操作</th>
@ -133,6 +134,7 @@
<td>{$data.company_profit|default="0.00"}</td>
<td>{$data['performance_commission']|default='0.00'}</td>
<td>{$data['achievement_bonus']|default='0.00'}</td>
<td>{$data['coefficient']|default='1'}</td>
<td>{$data['commission']|default='0.00'}</td>
<td>{$data['extend_commission']|default='0.00'}</td>
<td>{$data['wait_commission']|default='0.00'}</td>
@ -160,6 +162,7 @@
<td>{$sum.company_profit|default="0.00"}</td>
<td>{$sum['performance_commission']|default='0.00'}</td>
<td>{$sum['achievement_bonus']|default='0.00'}</td>
<td></td>
<td>{$sum['commission']|default='0.00'}</td>
<td>{$sum['extend_commission']|default='0.00'}</td>
<td>{$sum['wait_commission']|default='0.00'}</td>

@ -210,7 +210,7 @@
<tr class="data_summary">
<td colspan="4"><span>汇总</span></td>
<td ><span>{$total.sum_count}</span></td>
<td>---</td>
<td>{$total.unpay_count}</td>
<td>---</td>
<td>{$total.sum_today}</td>
<td>{$total.sum_week}</td>

@ -2752,4 +2752,8 @@ ADD COLUMN `is_site_custom` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否定制
ALTER TABLE `tab_promote_company`
ADD COLUMN `site_domain_prefix` varchar(20) NOT NULL DEFAULT '' COMMENT '推广后台域名前缀' AFTER `is_site_custom`;
ALTER TABLE `tab_promote_company`
ADD COLUMN `site_config` varchar(255) NOT NULL DEFAULT '' COMMENT '推广后台网站配置' AFTER `is_site_custom`;
ADD COLUMN `site_config` varchar(255) NOT NULL DEFAULT '' COMMENT '推广后台网站配置' AFTER `is_site_custom`;
ALTER TABLE `tab_market_altogether`
ADD COLUMN `coefficient_check` tinyint(2) NULL DEFAULT 0 COMMENT '绩效确认 0 未确认 1 确认' AFTER `finance_check_detail`,
ADD COLUMN `coefficient_check_detail` varchar(100) NULL DEFAULT '' COMMENT '绩效确认详情' AFTER `coefficient_check`;
Loading…
Cancel
Save