|
@@ -441,7 +441,7 @@ class Plantask extends Controller
|
|
|
/**
|
|
|
* 复制本周的课程表
|
|
|
*/
|
|
|
- public function auto_slot_copyweek(){
|
|
|
+ public function auto_slot_copyweek_old(){
|
|
|
|
|
|
$week = date('w');
|
|
|
|
|
@@ -489,6 +489,78 @@ class Plantask extends Controller
|
|
|
//$this->success('已复制到下周');
|
|
|
}
|
|
|
|
|
|
+ //每两周一次
|
|
|
+ //周一早上,复制本周+下周的课,到下下周+下下下周
|
|
|
+ public function auto_slot_copyweek(){
|
|
|
+
|
|
|
+ $week = date('w');
|
|
|
+ if($week != 1){
|
|
|
+ echo '不是周一';
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ $check = Db::name('plantask')->where('key','auto_slot_copyweek')->whereTime('lasttime','week')->find();
|
|
|
+ if($check){
|
|
|
+ echo '本周执行过了';
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ $check = Db::name('plantask')->where('key','auto_slot_copyweek')->whereTime('lasttime','last week')->find();
|
|
|
+ if($check){
|
|
|
+ echo '上周执行过了';
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ //先查找 下周有没有数据
|
|
|
+ /*$starttime = strtotime('this week Monday') + 86400*14;
|
|
|
+ $endtime = $starttime + 86400*14;
|
|
|
+ $check = Db::name('lesson_slot')->where('starttime','BETWEEN',[$starttime,$endtime])->find();
|
|
|
+ if($check){
|
|
|
+ echo '下下周和下下下周有数据了';
|
|
|
+ exit;
|
|
|
+ }*/
|
|
|
+
|
|
|
+ echo '准备复制';
|
|
|
+
|
|
|
+ //复制本周+下周的课
|
|
|
+ $starttime = strtotime('this week Monday'); // 获取本周一的时间戳
|
|
|
+ $endtime = $starttime + 86400*14;
|
|
|
+
|
|
|
+ $list = Db::name('lesson_slot')->where('starttime','BETWEEN',[$starttime,$endtime])->order('starttime asc')->select();
|
|
|
+ if(empty($list)){
|
|
|
+ echo 'empty';
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ //到下下周+下下下周
|
|
|
+ foreach($list as $key => &$val){
|
|
|
+ unset($val['id']);
|
|
|
+ $val['starttime'] = $val['starttime'] + 86400*14;
|
|
|
+ $val['endtime'] = $val['endtime'] + 86400*14;
|
|
|
+ $val['bookednum'] = 0;
|
|
|
+ $val['status'] = 0;
|
|
|
+ $val['notice_status'] = 0;
|
|
|
+ $val['finishtime'] = 0;
|
|
|
+ $val['cancel_reason'] = '';
|
|
|
+ $val['cancel_time'] = 0;
|
|
|
+ $val['is_show'] = 0;
|
|
|
+ $val['cancel_notice_status'] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ $rs1 = Db::name('plantask')->where('key','auto_slot_copyweek')->update(['lasttime'=>time()]);
|
|
|
+ if($rs1 === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('同步失败');
|
|
|
+ }
|
|
|
+ $rs2 = Db::name('lesson_slot')->insertAll($list);
|
|
|
+ if(!$rs2){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('复制失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ echo '复制完成';
|
|
|
+ }
|
|
|
+
|
|
|
/////////////////////////////////////////下面都是工具方法////////////////////////////////////////////////
|
|
|
|
|
|
//发送whatapp消息的方法
|