From 1279cbfe3baa600186d62607f2020c95feedbfa3 Mon Sep 17 00:00:00 2001
From: ELF <360197197@qq.com>
Date: Mon, 28 Jun 2021 16:04:22 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../BusinessAffairsAwardController.class.php | 34 +++---
.../Admin/Controller/GameController.class.php | 43 +++++---
.../MarketPercentageController.class.php | 38 ++++++-
.../Controller/TimingController.class.php | 103 ++++++++----------
.../businessAffairsList.html | 30 ++---
Application/Admin/View/Game/add.html | 12 ++
Application/Admin/View/Game/edit.html | 16 +++
Application/Admin/View/Game/lists.html | 2 +
.../MarketPercentage/marketstaffsettle.html | 53 ++++++++-
Data/update.sql | 32 +++++-
10 files changed, 248 insertions(+), 115 deletions(-)
diff --git a/Application/Admin/Controller/BusinessAffairsAwardController.class.php b/Application/Admin/Controller/BusinessAffairsAwardController.class.php
index b398a9e50..0a27ca80a 100644
--- a/Application/Admin/Controller/BusinessAffairsAwardController.class.php
+++ b/Application/Admin/Controller/BusinessAffairsAwardController.class.php
@@ -214,15 +214,6 @@ class BusinessAffairsAwardController extends ThinkController
$detail .= "
";
}
- $data[$key]['total_quarter_bonus_pool'] = round($value['quarter_bonus_pool'] * 0.25,2);
-
- $time = date("m",strtotime($value['time']));
- if (!in_array($time,$check_quarter)) {
- $data[$key]["quarter_award"] = "0.00";
- }
-
- $data[$key]['person_award'] = $data[$key]['quarter_award'] + $value['month_award'];
-
if ($value['verify_status']) {
$data[$key]['verify_detail'] = $detail.date('Y-m-d H:i:s',$value['verify_time']);
} else {
@@ -234,17 +225,20 @@ class BusinessAffairsAwardController extends ThinkController
if ($_REQUEST['export']) {
- $title = ['time' => '月份',
- 'relation_game_name' => '游戏名称',
- 'pay_amount' => '产品流水',
- 'ratio' => '抽成比例',
- 'game_belong_name' => '奖励归属',
- 'month_bonus_pool' => '本月奖金池总额',
- 'total_quarter_bonus_pool'=>'本季度累计激励',
- 'quarter_bonus_pool' => '个人发放激励',
- 'month_award' => '流水个人奖金',
- 'person_award' => '个人奖金总额',
- 'verify_detail' => '审批状态'];
+ $title = [
+ 'time' => '时间',
+ 'game_belong_name' => '对应商务',
+ 'relation_game_name' => '产品',
+ 'pay_amount' => '流水',
+
+ 'game_bonus_pool' => '该产品奖金池',
+ 'month_award'=>'商务个人本月应得',
+ // '' => '助理',
+ 'assistant_month_award' => '助理本月应得',
+ 'department_award' => '部门累计',
+ 'person_award' => '个人激励',
+ 'verify_detail' => '审批状态'
+ ];
data2csv($data, '商务奖金汇总', $title);
}
diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php
index 24751d655..08a85b7d8 100644
--- a/Application/Admin/Controller/GameController.class.php
+++ b/Application/Admin/Controller/GameController.class.php
@@ -224,16 +224,21 @@ class GameController extends ThinkController
$_POST['download_ways'] = $gameService->getDownLoadWaysValue($downloadWays);
- $realname = M("member")
- ->field("real_name")
- ->where(['uid' => I('post.game_belong_id')])
- ->find()['real_name'];
+ $gameBelongId = I('post.game_belong_id', 0);
+ $gameAssistantId = I('post.game_assistant_id', 0);
- if(!$realname) {
- $realname = '';
+ if ($gameAssistantId > 0 && $gameBelongId == 0) {
+ return $this->error("请选择游戏所属商务");
}
- $_POST['game_belong_name'] =$realname;
+ $members = M("member")
+ ->field(['uid', 'real_name'])
+ ->where(['uid' => ['in', [$gameBelongId, $gameAssistantId]]])
+ ->select();
+ $members = index_by_column('real_name', $members);
+
+ $_POST['game_belong_name'] = $members[$gameBelongId] ?? '';
+ $_POST['game_assistant_name'] = $members[$gameAssistantId] ?? '';
$game = D(self::model_name);//M('$this->$model_name','tab_');
$res = $game->update();
@@ -432,17 +437,21 @@ ADD COLUMN `kefu_qq` varchar(255) NULL DEFAULT '' COMMENT 'kefu_qq_type为2 时
$_POST['download_ways'] = $gameService->getDownLoadWaysValue($downloadWays);
+ $gameBelongId = I('post.game_belong_id', 0);
+ $gameAssistantId = I('post.game_assistant_id', 0);
- $realname = M("member")
- ->field("real_name")
- ->where(['uid' => I('post.game_belong_id')])
- ->find()['real_name'];
-
- if(!$realname) {
- $realname = '';
+ if ($gameAssistantId > 0 && $gameBelongId == 0) {
+ return $this->error("请选择游戏所属商务");
}
+
+ $members = M("member")
+ ->field(['uid', 'real_name'])
+ ->where(['uid' => ['in', [$gameBelongId, $gameAssistantId]]])
+ ->select();
+ $members = index_by_column('real_name', $members);
- $_POST['game_belong_name'] =$realname;
+ $_POST['game_belong_name'] = $members[$gameBelongId] ?? '';
+ $_POST['game_assistant_name'] = $members[$gameAssistantId] ?? '';
unset($_POST['apply_auth']);
@@ -498,7 +507,9 @@ ADD COLUMN `kefu_qq` varchar(255) NULL DEFAULT '' COMMENT 'kefu_qq_type为2 时
$otherData['kefu_qq_type'] = I('post.kefu_qq_type');
$otherData['data_share'] = I('post.data.share');
$otherData['game_belong_id'] = I('post.game_belong_id');
- $otherData['game_belong_name'] = $realname;
+ $otherData['game_belong_name'] = $_POST['game_belong_name'];
+ $otherData['game_assistant_id'] = I('post.game_assistant_id');
+ $otherData['game_assistant_name'] = $_POST['game_assistant_name'];
$otherData['data_share'] = I('post.data_share');
M('Game', 'tab_')->data($otherData)->where(array('id' => $another['id']))->save();
diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php
index 3d5f54ea1..c6494cc60 100644
--- a/Application/Admin/Controller/MarketPercentageController.class.php
+++ b/Application/Admin/Controller/MarketPercentageController.class.php
@@ -708,6 +708,7 @@ class MarketPercentageController extends ThinkController
$this->assign('coefficient_check', true);
$this->assign('market_check', true);
$this->assign('finance_check', true);
+ $this->assign('personnel_check', true);
$this->assign('coefficient_in_check', true);
} else {
$exportRule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME . "_coefficient_check");
@@ -716,6 +717,8 @@ class MarketPercentageController extends ThinkController
$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 . "_personnel_check");
+ $this->assign('personnel_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')));
}
@@ -752,7 +755,7 @@ class MarketPercentageController extends ThinkController
if ($_REQUEST['export'] && $this->checkRule($Rule, array('in', '1,2'))) {
- if (!$value['market_check'] || !$value['finance_check']) {
+ if (!$value['market_check'] || !$value['finance_check'] || !$value['personnel_check']) {
unset($data[$key]);
continue;
}
@@ -792,6 +795,10 @@ class MarketPercentageController extends ThinkController
$data[$key]['finance_check_detail'] = "-----";
}
+ if (!$value['personnel_check']) {
+ $data[$key]['personnel_check_detail'] = "-----";
+ }
+
if (!$value['coefficient_check']) {
$data[$key]['coefficient_check_detail'] = "-----";
}
@@ -799,6 +806,7 @@ class MarketPercentageController extends ThinkController
if ($_REQUEST['export']) {
$data[$key]['market_check_detail'] = str_replace("
", '', $data[$key]['market_check_detail']);
$data[$key]['finance_check_detail'] = str_replace("
", '', $data[$key]['finance_check_detail']);
+ $data[$key]['personnel_check_detail'] = str_replace("
", '', $data[$key]['personnel_check_detail']);
$data[$key]['coefficient_check_detail'] = str_replace("
", '', $data[$key]['coefficient_check_detail']);
}
@@ -910,7 +918,8 @@ class MarketPercentageController extends ThinkController
'wait_commission' => '本月待发金额合计',
'coefficient_check_detail' => '绩效确认',
'market_check_detail' => '市场部确认',
- 'finance_check_detail' => '财务部审批'];
+ 'finance_check_detail' => '财务部审批',
+ 'personnel_check_detail' => '人事部审批'];
foreach ($data as $key => $value) {
$line = $key + 2;
@@ -1586,6 +1595,31 @@ class MarketPercentageController extends ThinkController
}
+ //财务部审批操作
+ public function doPersonnelCheck()
+ {
+
+ $ids = $_REQUEST['ids'];
+
+ if (!$ids) {
+ $this->ajaxReturn(['status' => 0, 'info' => '操作失败,id不能为空']);
+ }
+
+ $admin = $_SESSION['onethink_admin']['user_auth']['username'];
+ $personnel_check_detail = "人事部已审批({$admin})
" . date("Y-m-d H:i:s", time());
+
+ $is_save = SM("market_altogether", "tab_")
+ ->where(['id' => ['in', $ids], 'personnel_check' => 0])
+ ->save(['personnel_check' => 1, 'personnel_check_detail' => $personnel_check_detail]);
+
+ if (!$is_save) {
+ $this->ajaxReturn(['status' => 0, 'info' => '操作失败']);
+ }
+
+ $this->ajaxReturn(['status' => 1, 'info' => '人事部审批成功']);
+
+ }
+
public function companybelonggame($row = 10, $p = 1)
{
diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php
index d167bf035..8e3771422 100644
--- a/Application/Admin/Controller/TimingController.class.php
+++ b/Application/Admin/Controller/TimingController.class.php
@@ -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";
diff --git a/Application/Admin/View/BusinessAffairsAward/businessAffairsList.html b/Application/Admin/View/BusinessAffairsAward/businessAffairsList.html
index afdcb886a..d587272f9 100644
--- a/Application/Admin/View/BusinessAffairsAward/businessAffairsList.html
+++ b/Application/Admin/View/BusinessAffairsAward/businessAffairsList.html
@@ -176,16 +176,16 @@
@@ -202,14 +202,14 @@
- 月份
- 游戏名称
- 产品流水
- 抽成比例
- 奖金归属人
- 本月奖金池总额
- 本季度累计激励
- 个人发放激励
- 流水个人奖金
- 个人奖金总额
+ 时间
+ 对应商务
+ 产品
+ 流水
+ 该产品奖金池
+ 商务个人本月应得
+ 助理
+ 助理本月应得
+ 部门累计
+ 个人激励
审批状态