新增月结每周一脚本

master
chenzhi 3 years ago
parent 7d64738080
commit 85f7977d1a

@ -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);
}
}
}

@ -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'];

@ -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,

Loading…
Cancel
Save