|
|
|
@ -1559,38 +1559,35 @@ class TimingController extends AdminController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setbusinessAffairsAward() {
|
|
|
|
|
public function setbusinessAffairsAward($month = null) {
|
|
|
|
|
|
|
|
|
|
echo date("Y-m-d H:i:s")."----------------------商务奖金计算----------------------\n";
|
|
|
|
|
|
|
|
|
|
// dump($this->businessAffairRatio(3471300));die();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$_REQUEST['time']) {
|
|
|
|
|
$time = time();
|
|
|
|
|
} else {
|
|
|
|
|
$time = strtotime($_REQUEST['time']);
|
|
|
|
|
|
|
|
|
|
$time = strtotime(date('Y-m',strtotime(date('Y',$time).'-'.(date('m',$time)+1).'-01')));
|
|
|
|
|
|
|
|
|
|
if (is_null($month)) {
|
|
|
|
|
$month = date('Y-m', strtotime(date('Y-m-01') . ' -1 month'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list($becomeTimeList,$becomeTimeCount) = $this->getAffairList(date('Y-m',strtotime(date('Y',$time).'-'.(date('m',$time)-1).'-01')));
|
|
|
|
|
// dump([$becomeTimeList,$becomeTimeCount]);die();
|
|
|
|
|
$quarterMonthIndex = date('n', strtotime($month . '-01')) % 3;
|
|
|
|
|
$quarterBeforeMonth = $quarterMonthIndex == 1 ? null : date('Y-m', strtotime($month . '-01' . ' -1 month'));
|
|
|
|
|
|
|
|
|
|
list($becomeTimeList, $becomeTimeCount) = $this->getAffairList($month);
|
|
|
|
|
|
|
|
|
|
$time1 = date('Y-m',strtotime(date('Y',$time).'-'.(date('m',$time)-1).'-01'));
|
|
|
|
|
/* $time1 = date('Y-m',strtotime(date('Y',$time).'-'.(date('m',$time)-1).'-01'));
|
|
|
|
|
$time2 = date('Y-m',strtotime(date('Y',$time).'-'.(date('m',$time)-2).'-01'));
|
|
|
|
|
$time3 = date('Y-m',strtotime(date('Y',$time).'-'.(date('m',$time)-3).'-01'));
|
|
|
|
|
|
|
|
|
|
$lasttime = [$time2,$time3];
|
|
|
|
|
$lasttime = [$time2,$time3]; */
|
|
|
|
|
|
|
|
|
|
$firstday = $month . '-01';
|
|
|
|
|
$lastday = date('Y-m-d', strtotime($firstday . ' +1 month -1 day'));
|
|
|
|
|
$timeRange = [strtotime($firstday . ' 00:00:00'), strtotime($lastday . ' 23:59:59')];
|
|
|
|
|
$tempoparyData = M("spend","tab_")
|
|
|
|
|
->field("tab_spend.*,from_unixtime(payed_time,'%Y-%m') time,from_unixtime(payed_time,'%Y') year,from_unixtime(payed_time,'%m') month,relation_game_id,relation_game_name,game_belong_id,game_belong_name")
|
|
|
|
|
->field("tab_spend.*,from_unixtime(payed_time,'%Y-%m') time,from_unixtime(payed_time,'%Y') year,from_unixtime(payed_time,'%m') month,relation_game_id,relation_game_name,game_belong_id,game_belong_name,game_assistant_id,game_assistant_name")
|
|
|
|
|
->join("left join tab_game on tab_game.id=tab_spend.game_id")
|
|
|
|
|
->where(['tab_spend.pay_status'=>1,'game_belong_id'=>['neq',0],'pay_way' => ['egt', 0]])
|
|
|
|
|
->where(['tab_spend.pay_status' => 1, 'game_belong_id' => ['neq',0], 'pay_way' => ['egt', 0], 'tab_spend.payed_time' => ['between', $timeRange]])
|
|
|
|
|
->select(false);
|
|
|
|
|
|
|
|
|
|
$lastdata = M()->table("({$tempoparyData}) a")
|
|
|
|
|
/* $lastdata = M()->table("({$tempoparyData}) a")
|
|
|
|
|
->field("*,sum(pay_amount) pay_amount")
|
|
|
|
|
->where(['time'=>['in',$lasttime]])
|
|
|
|
|
->group("time,relation_game_id,game_belong_id")
|
|
|
|
@ -1600,73 +1597,60 @@ class TimingController extends AdminController {
|
|
|
|
|
|
|
|
|
|
foreach ($lastdata as $key => $value) {
|
|
|
|
|
$handleData[$value['time'].$value['game_belong_id'].$value['relation_game_id']] = $value;
|
|
|
|
|
}
|
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
$data = M()->table("({$tempoparyData}) a")
|
|
|
|
|
->field("sum(pay_amount) pay_amount,time,year,month,relation_game_id,relation_game_name,game_belong_id,game_belong_name")
|
|
|
|
|
->where(['time'=>$time1])
|
|
|
|
|
->field("sum(pay_amount) pay_amount,time,year,month,relation_game_id,relation_game_name,game_belong_id,game_belong_name,game_assistant_id,game_assistant_name")
|
|
|
|
|
->where(['time' => $month])
|
|
|
|
|
->group("time,relation_game_id,game_belong_id")
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$sum_amount = M()->table("({$tempoparyData}) a")
|
|
|
|
|
/* $sum_amount = M()->table("({$tempoparyData}) a")
|
|
|
|
|
->field("sum(pay_amount) pay_amount")
|
|
|
|
|
->where(['time'=>$time1])
|
|
|
|
|
->find()['pay_amount'];
|
|
|
|
|
->where(['time' => $month])
|
|
|
|
|
->find()['pay_amount']; */
|
|
|
|
|
//判断是不是初次
|
|
|
|
|
$is_hav = M("business_affairs_award_pool","tab_")->where(['time'=>$time2])->find();
|
|
|
|
|
// $is_hav = M("business_affairs_award_pool","tab_")->where(['time' => $time2])->find();
|
|
|
|
|
|
|
|
|
|
$month_bonus_pool = 0;
|
|
|
|
|
$sum_amount = array_sum(array_column($data, 'pay_amount'));
|
|
|
|
|
$quarter_bonus_pool = 0;
|
|
|
|
|
|
|
|
|
|
foreach($data as $key => $value) {
|
|
|
|
|
|
|
|
|
|
$month_bonus_pool += $value['pay_amount'];
|
|
|
|
|
|
|
|
|
|
// if ($is_hav) {
|
|
|
|
|
// for($i = (($value['month']%3)?(($value['month']%3)-1):2); $i > 0; $i--) {
|
|
|
|
|
//
|
|
|
|
|
// $date = date("Y-m",strtotime($value['year'].'-'.(($value['month']-$i)>0?($value['month']-$i):($value['month']-$i+12))));
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$last_amount = M("business_affairs_award_pool","tab_")->where(['time'=>['in',$lasttime]])->group("month_bonus_pool")->select(false);
|
|
|
|
|
|
|
|
|
|
$last_amount = M()->table("({$last_amount}) a")->sum("month_bonus_pool");
|
|
|
|
|
/* foreach($data as $key => $value) {
|
|
|
|
|
$sum_amount += $value['pay_amount'];
|
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
$month_bonus_pool = $this->businessAffairRatio($month_bonus_pool);
|
|
|
|
|
$quarter_bonus_pool = $month_bonus_pool + $last_amount;
|
|
|
|
|
/* $last_amount = 0;
|
|
|
|
|
if (!is_null($quarterBeforeMonth)) {
|
|
|
|
|
$last_amount = M("business_affairs_award_pool", "tab_")->where(['time' => $quarterBeforeMonth])->getField('month_bonus_pool');
|
|
|
|
|
$last_amount = $last_amount ?? 0;
|
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
foreach ($data as $key => $value){
|
|
|
|
|
$month_bonus_pool = $this->businessAffairRatio($sum_amount);
|
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
|
|
|
|
|
|
echo "{$value['time']},{$value['game_belong_name']},{$value['pay_amount']}\n";
|
|
|
|
|
|
|
|
|
|
$value['month_bonus_pool'] = $month_bonus_pool;
|
|
|
|
|
|
|
|
|
|
$value['quarter_bonus_pool'] = $quarter_bonus_pool;
|
|
|
|
|
|
|
|
|
|
unset($value['year']);
|
|
|
|
|
unset($value['month']);
|
|
|
|
|
|
|
|
|
|
$value['quarter_award'] = $value['quarter_bonus_pool']*0.25*(($becomeTimeList[$value['game_belong_id']]?$becomeTimeList[$value['game_belong_id']]:0)/$becomeTimeCount);
|
|
|
|
|
$becomeTimeMonth = $becomeTimeList[$value['game_belong_id']] ? $becomeTimeList[$value['game_belong_id']] : 0;
|
|
|
|
|
$becomeTimeRate = $becomeTimeMonth == 0 || $becomeTimeCount == 0 ? 0 : $becomeTimeMonth/$becomeTimeCount;
|
|
|
|
|
|
|
|
|
|
$is_assistant = M("ucenter_member")
|
|
|
|
|
/* $is_assistant = M("ucenter_member")
|
|
|
|
|
->field("sys_ucenter_member.id admin_id,become_time")
|
|
|
|
|
->join("left join sys_auth_group_access access on sys_ucenter_member.id = access.uid")
|
|
|
|
|
->join("left join sys_auth_group auth on access.group_id=auth.id")
|
|
|
|
|
->where(['title' => ['like', '%助理%'],'sys_ucenter_member.id'=>$value['game_belong_id']])
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
if (!$is_assistant) {
|
|
|
|
|
$value['month_award'] = ($value['pay_amount']/$sum_amount)*$value['month_bonus_pool']*0.7;
|
|
|
|
|
} else {
|
|
|
|
|
$value['month_award'] = ($value['pay_amount']/$sum_amount)*$value['month_bonus_pool']*0.05;
|
|
|
|
|
}
|
|
|
|
|
->select(); */
|
|
|
|
|
|
|
|
|
|
$value['month_award'] = round($value['month_award'],2);
|
|
|
|
|
$value['quarter_award'] = round($value['quarter_award'],2);
|
|
|
|
|
$value['total_pay_amount'] = $sum_amount;
|
|
|
|
|
$value['game_bonus_pool'] = round(($value['pay_amount']/$sum_amount)*$value['month_bonus_pool'], 2);
|
|
|
|
|
$value['month_award'] = round($value['game_bonus_pool']*0.7, 2);
|
|
|
|
|
$value['assistant_month_award'] = round($value['game_bonus_pool']*0.05, 2);
|
|
|
|
|
$value['department_award'] = round($value['game_bonus_pool']*0.25, 2);
|
|
|
|
|
$value['person_award'] = round($value['game_bonus_pool']*0.25*$becomeTimeRate, 2);
|
|
|
|
|
|
|
|
|
|
if (!$becomeTimeCount) {
|
|
|
|
|
$value['month_award'] = 0;
|
|
|
|
@ -1691,7 +1675,6 @@ class TimingController extends AdminController {
|
|
|
|
|
} else {
|
|
|
|
|
M("business_affairs_award_pool","tab_")->add($value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo date("Y-m-d H:i:s")."----------------------商务奖金计算----------------------\n";
|
|
|
|
|