|
|
@@ -290,4 +290,26 @@ class ProductController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //预售到期自动取消
|
|
|
+ public function actionCancelPresell()
|
|
|
+ {
|
|
|
+ $now = time(); //注意脚本执行时间不能是凌晨0点,否则会出问题,这个比较时间要修改为当前时间+1小时
|
|
|
+ $list = ProductClass::getAllByCondition(['presell' => 1], 'addTime DESC', 'id, presell, presellDate', null, true);
|
|
|
+ if (!empty($list)) {
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $presellDate = $item->presellDate;
|
|
|
+ $dateArr = explode(',', $presellDate);
|
|
|
+ if (empty($dateArr)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $firstDate = $dateArr[0];
|
|
|
+ $firstDate = strtotime($firstDate);
|
|
|
+ if ($firstDate < $now) {
|
|
|
+ $item->presell = 0;
|
|
|
+ $item->presellDate = '';
|
|
|
+ $item->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|