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 .= "<br>";
             }
 
-            $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("<br>", '', $data[$key]['market_check_detail']);
                 $data[$key]['finance_check_detail'] = str_replace("<br>", '', $data[$key]['finance_check_detail']);
+                $data[$key]['personnel_check_detail'] = str_replace("<br>", '', $data[$key]['personnel_check_detail']);
                 $data[$key]['coefficient_check_detail'] = str_replace("<br>", '', $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})<br>" . 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 @@
                     <thead>
                     <tr>
                         <th><input class="check-all" type="checkbox"></th>
-                        <th>月份</th>
-                        <th>游戏名称</th>
-                        <th>产品流水</th>
-                        <th>抽成比例</th>
-                        <th>奖金归属人</th>
-                        <th>本月奖金池总额</th>
-                        <th>本季度累计激励</th>
-                        <th>个人发放激励</th>
-                        <th>流水个人奖金</th>
-                        <th>个人奖金总额</th>
+                        <th>时间</th>
+                        <th>对应商务</th>
+                        <th>产品</th>
+                        <th>流水</th>
+                        <th>该产品奖金池</th>
+                        <th>商务个人本月应得</th>
+                        <th>助理</th>
+                        <th>助理本月应得</th>
+                        <th>部门累计</th>
+                        <th>个人激励</th>
                         <th>审批状态</th>
                     </tr>
                     </thead>
@@ -202,14 +202,14 @@
                             <tr>
                                 <td><input class="ids" type="checkbox" value="{$data['id']} "data-verify_status="{$data['verify_status']}" name="ids[]"></td>
                                 <td>{$data.time|default='无'}</td>
+                                <td>{$data.game_belong_name|default='无'}</td>
                                 <td>{$data.relation_game_name|default='无'}</td>
                                 <td>{$data.pay_amount|default='0'}</td>
-                                <td>{$data.ratio|default='--'}</td>
-                                <td>{$data.game_belong_name|default='无'}</td>
-                                <td>{$data.month_bonus_pool|default='0'}</td>
-                                <td>{$data.total_quarter_bonus_pool|default='0'}</td>
-                                <td>{$data.quarter_award|default='0'}</td>
+                                <td>{$data.game_bonus_pool|default='0'}</td>
                                 <td>{$data.month_award|default='0'}</td>
+                                <td>{$data.game_assistant_name|default='无'}</td>
+                                <td>{$data.assistant_month_award|default='0'}</td>
+                                <td>{$data.department_award|default='0'}</td>
                                 <td>{$data.person_award|default='0'}</td>
                                 <td>{$data.verify_detail|default='无'}</td>
 
diff --git a/Application/Admin/View/Game/add.html b/Application/Admin/View/Game/add.html
index bb4fc360f..25d8b48a5 100644
--- a/Application/Admin/View/Game/add.html
+++ b/Application/Admin/View/Game/add.html
@@ -80,6 +80,18 @@
                                 <input type="hidden" id="game_belong_name" name="game_belong_name" value="">
                             </td>
                         </tr>
+                        <tr>
+                            <td class="l">商务助理:</td>
+                            <td class="r">
+                                <select id="game_assistant_id" name="game_assistant_id">
+                                    <option value="0">无</option>
+                                    <volist name=":getAffairMember()" id="vo">
+                                        <option value="{$vo.admin_id}">{$vo.real_name}</option>
+                                    </volist>
+                                </select>
+                                <input type="hidden" id="game_assistant_name" name="game_assistant_name" value="">
+                            </td>
+                        </tr>
                         <tr>
                             <td class="l noticeinfo">运营平台</td>
                             <td class="r table_radio">
diff --git a/Application/Admin/View/Game/edit.html b/Application/Admin/View/Game/edit.html
index a2c185650..749676677 100644
--- a/Application/Admin/View/Game/edit.html
+++ b/Application/Admin/View/Game/edit.html
@@ -104,6 +104,22 @@
                                 <input type="hidden" id="game_belong_name" name="game_belong_name" value="{$data['game_belong_name']}">
                             </td>
                         </tr>
+                        <tr>
+                            <td class="l">商务助理:</td>
+                            <td class="r">
+                                <select id="game_assistant_id" name="game_assistant_id">
+                                    <option value="0">无</option>
+                                    <volist name=":getAffairMember()" id="vo">
+                                        <if condition="$vo[admin_id] eq $data[game_assistant_id]">
+                                            <option value="{$vo.admin_id}" selected>{$vo.real_name}</option>
+                                            <else />
+                                            <option value="{$vo.admin_id}">{$vo.real_name}</option>
+                                        </if>
+                                    </volist>
+                                </select>
+                                <input type="hidden" id="game_assistant_name" name="game_assistant_name" value="{$data['game_assistant_name']}">
+                            </td>
+                        </tr>
                         <tr>
                             <td class="l noticeinfo">运营平台</td>
                             <td class="r table_radio">
diff --git a/Application/Admin/View/Game/lists.html b/Application/Admin/View/Game/lists.html
index e689f0f99..a2dafa85e 100644
--- a/Application/Admin/View/Game/lists.html
+++ b/Application/Admin/View/Game/lists.html
@@ -161,6 +161,7 @@ text-indent:0;
                         <th>排序设置</th>
                         <th>添加关联</th>
                         <th>游戏归属</th>
+                        <th>商务助理</th>
                         <th style="width:10%;min-width:150px;">操作</th>
                     </tr>
                 </thead>
@@ -248,6 +249,7 @@ text-indent:0;
                                 </if>
                             </td>
                             <td>{$data.game_belong_name|default='无'}</td>
+                            <td>{$data.game_assistant_name|default='无'}</td>
                             <td>
                                 <a href="{:U('Game/edit?id='.$data['id'].'&type=1&p='.I('p',1))}">编辑</a>
                                 <a href="{:U('Game/del?ids='.$data['id'])}" class="confirm ajax-get">删除</a>
diff --git a/Application/Admin/View/MarketPercentage/marketstaffsettle.html b/Application/Admin/View/MarketPercentage/marketstaffsettle.html
index 2c575d913..f5fd381e9 100644
--- a/Application/Admin/View/MarketPercentage/marketstaffsettle.html
+++ b/Application/Admin/View/MarketPercentage/marketstaffsettle.html
@@ -177,6 +177,9 @@
             <if condition="$finance_check eq true">
                 <a class='butn' id='finance_check' style='background-color: #3C95C8;'>财务部审批</a>
             </if>
+            <if condition="$personnel_check eq true">
+                <a class='butn' id='personnel_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>
@@ -213,6 +216,7 @@
                         <th>绩效确认</th>
                         <th>市场部确认</th>
                         <th>财务部审批</th>
+                        <th>人事部审批</th>
                     </tr>
                     </thead>
 
@@ -226,7 +230,7 @@
                     <notemtpy name = "list_data">
                         <volist name="list_data" id="data">
                             <tr>
-                                <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><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']}"  data-personnel_check="{$data['personnel_check']}" name="ids[]"></td>
                                 <td>{$data.pay_time|default='无'}</td>
                                 <td>{$data.real_name|default='无'}</td>
                                 <td>{$data.leave_time|default='--'}</td>
@@ -251,6 +255,7 @@
                                 <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>
+                                <td><if condition="$data.personnel_check eq 0"><span ></if>{$data['personnel_check_detail']|default=''}<if condition="$data.market_check eq 1"></span></if></td>
                             </tr>
                         </volist>
                         <td colspan="5">合计</td>
@@ -429,6 +434,52 @@
 
             });
 
+            $("#personnel_check").on("click",function(){
+                var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
+                    if($(elem).data("personnel_check") == 0 && $(elem).data("finance_check") == 1 && $(elem).data("market_check") == 1){
+                        return $(elem).val();
+                    }
+                }).get();
+
+                if(text.length < 1){
+                    layer.msg("<font style='color:white'>" + '无需要进行[人事部审批]的申请,仅[人事部未审批且市场部已确认]状态可以进行[人事部审批]操作</font>');
+                    return;
+                }
+
+                text = text.join(",");
+                layer.confirm('【警告】[人事部审批]将不可回退,如需继续请点击确认', {
+                    btn: ['确认','取消'],
+                    title:false
+                }, function(index){
+                    layer.close(index);
+                    _doAgreeApply();
+                });
+                function _doAgreeApply(){
+                    //执行
+                    layer.load(2);
+                    $.ajax({
+                        type: "POST",
+                        url: "{:U('doPersonnelCheck')}",
+                        dataType: 'json',
+                        async: true,
+                        data: {ids:text},
+                        success:function(data){
+                            layer.closeAll('loading');
+                            if(data.status==1){
+                                layer.msg("<font style='color:white'>" + data.info + "</font>");
+                                setTimeout(function(){
+                                    window.location.reload();
+                                },1500);
+                            }else{
+                                layer.msg("<font style='color:white'>" + data.info + "</font>");
+                                return false;
+                            }
+                        }
+                    });
+                }
+
+            });
+
             //搜索功能
             $("#search").click(function(){
                 var url = $(this).attr('url');
diff --git a/Data/update.sql b/Data/update.sql
index bf0b9f9bd..fdf441e35 100644
--- a/Data/update.sql
+++ b/Data/update.sql
@@ -2835,4 +2835,34 @@ ADD COLUMN `check_time` int(11) NULL DEFAULT 0 COMMENT '确认时间' AFTER `sta
 ALTER TABLE `tab_spend_refund`
 ADD COLUMN `admin` varchar(50) NULL DEFAULT '' COMMENT '操作人' AFTER `check_time`;
 
-alter table  sys_auth_group add column `allow_over_week` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否允许跨周补链' after show_promote;
\ No newline at end of file
+alter table  sys_auth_group add column `allow_over_week` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否允许跨周补链' after show_promote;
+
+CREATE TABLE `tab_business_affairs_award_pool` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `time` varchar(20) NOT NULL DEFAULT '' COMMENT '月份',
+  `pay_amount` decimal(13,2) NOT NULL COMMENT '流水',
+  `relation_game_id` int(11) NOT NULL COMMENT '游戏id',
+  `relation_game_name` varchar(50) NOT NULL DEFAULT '' COMMENT '游戏名',
+  `game_belong_id` int(11) NOT NULL DEFAULT '0' COMMENT '归属id',
+  `game_belong_name` varchar(50) NOT NULL DEFAULT '' COMMENT '归属名',
+  `game_assistant_id` int(11) NOT NULL DEFAULT '0' COMMENT '助理id',
+  `game_assistant_name` varchar(50) NOT NULL DEFAULT '' COMMENT '助理姓名',
+  `month_bonus_pool` decimal(13,2) NOT NULL DEFAULT '0.00' COMMENT '月奖金池',
+  `month_award` decimal(13,2) NOT NULL DEFAULT '0.00' COMMENT '月奖金',
+  `person_award` decimal(13,2) NOT NULL DEFAULT '0.00' COMMENT '个人激励',
+  `total_pay_amount` decimal(13,2) NOT NULL DEFAULT '0.00' COMMENT '月总流水',
+  `game_bonus_pool` decimal(13,2) NOT NULL DEFAULT '0.00' COMMENT '该产品奖金池',
+  `assistant_month_award` decimal(13,2) NOT NULL DEFAULT '0.00' COMMENT '助理本月应得',
+  `department_award` decimal(13,2) NOT NULL DEFAULT '0.00' COMMENT '部门累计',
+  `verify_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '审核状态 0 未审核 1 审核通过 2 审核拒绝',
+  `verify_time` int(11) NOT NULL DEFAULT '0' COMMENT '审核时间',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
+
+ALTER TABLE `tab_game`
+ADD COLUMN `game_assistant_id` int(11) NOT NULL DEFAULT 0 COMMENT '商务助理id' AFTER `game_belong_name`,
+ADD COLUMN `game_assistant_name` varchar(50) NOT NULL DEFAULT '' COMMENT '商务助理姓名' AFTER `game_assistant_id`;
+
+ALTER TABLE `tab_market_altogether`
+ADD COLUMN `personnel_check` tinyint(2) NULL DEFAULT 0 COMMENT '人事确认 0 未确认 1 确认' AFTER `finance_check_detail`,
+ADD COLUMN `personnel_check_detail` varchar(100) NULL DEFAULT '' COMMENT '人事确认详情' AFTER `personnel_check`;
\ No newline at end of file