From 85f7977d1a988bede3b6526f0fc1bccbb99d2ebd Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 13 Jul 2021 18:13:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9C=88=E7=BB=93=E6=AF=8F?= =?UTF-8?q?=E5=91=A8=E4=B8=80=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MarketPerformanceSetController.class.php | 32 +++++++++++++++++++ .../Controller/TimingController.class.php | 3 +- .../Admin/Model/CmdTasksModel.class.php | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/MarketPerformanceSetController.class.php b/Application/Admin/Controller/MarketPerformanceSetController.class.php index ed32f7bde..c34fabf9f 100644 --- a/Application/Admin/Controller/MarketPerformanceSetController.class.php +++ b/Application/Admin/Controller/MarketPerformanceSetController.class.php @@ -529,5 +529,37 @@ class MarketPerformanceSetController extends Controller { } } + /** + * 设置每周一自动重算 + */ + public function setThisMonthFirstMondayScript() + { + $year = date('Y',time()); + $m = date('m',time()); + $d = date('d',time()); + if($d != 1){ + return ; + } + // 先取得这个月的 1 号 + $iThisMonthFirst = strtotime("{$year}-{$m}-01 4:00:00"); + $dThisDay = date("w", $iThisMonthFirst); + if ($dThisDay == '1') { + $dFirstMonday = $iThisMonthFirst; + } else { + //不是星期一先回到星期日 + $iDays = 86400 * ($dThisDay * 1); + //找出星期日的日期 + $iSunday = $iThisMonthFirst - $iDays; + //星期日 + 8 天就是星期一 + $iThisMonthFirstMonday = $iSunday + (86400 * 8); + $dFirstMonday = $iThisMonthFirstMonday; + } + $tmdRes = M("cmd_tasks","tab_")->where(['type'=>'MarketPerformanceSet','schedule_time'=>$dFirstMonday])->find(); + if(!$tmdRes){ + $pay_time = date( 'Y-m', strtotime( 'last day of -1 months' ) ); + $params = "php ".SUBSITE_INDEX." Timing/caculateMarketStream/time/{$pay_time}"; + D("CmdTasks")->addScheduleTask("MarketPerformanceSet",$params,$dFirstMonday); + } + } } diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 4fc376409..216b75332 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -838,6 +838,7 @@ class TimingController extends AdminController { //计算市场专员业绩公式 参数 time 2020-10 public function caculateMarketStream () { + if ($_REQUEST['time']) { $count_date = $_REQUEST['time']; }else{ @@ -845,10 +846,10 @@ class TimingController extends AdminController { } A("MarketPerformanceSet")->setFreeMonth($count_date); $this->createMarketBonus($_REQUEST['time']); + A("MarketPerformanceSet")->setThisMonthFirstMondayScript(); die(); } - public function insertAllUserBonus($time) { // $time = $_REQUEST['time']; diff --git a/Application/Admin/Model/CmdTasksModel.class.php b/Application/Admin/Model/CmdTasksModel.class.php index 304e78812..082d74ab8 100644 --- a/Application/Admin/Model/CmdTasksModel.class.php +++ b/Application/Admin/Model/CmdTasksModel.class.php @@ -68,7 +68,7 @@ class CmdTasksModel extends Model{ } $params = rtrim($params,";").' 2>&1'; $save = [ - "uid"=>$_SESSION['onethink_admin']['user_auth']['uid'], + "uid"=>$_SESSION['onethink_admin']['user_auth']['uid']??0, "created_time"=>time(), "params"=>$params, "type"=>$type,