| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace console\controllers;
- use biz\shop\classes\ShopClass;
- use bizGhs\live\classes\LiveOrderClass;
- use common\components\noticeUtil;
- use yii\console\Controller;
- use Yii;
- class LiveOrderController extends Controller
- {
- //每二分钟执行一次 ssh 20241006
- public function actionSeat()
- {
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- $shopList = ShopClass::getAllByCondition(['ptStyle'=>2],null,'id,ptStyle,shopName',null,true);
- if(empty($shopList)){
- return false;
- }
- foreach($shopList as $shop){
- $mainId = $shop->mainId;
- $shopName = $shop->shopName??'';
- $sjName = $shop->merchantName??'';
- $name = $sjName.' '.$shopName;
- $cacheKey = 'live_order_' . $mainId;
- $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- if(empty($has)){
- continue;
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $list = LiveOrderClass::getAllByCondition(['mainId' => $mainId,'switchOrder'=>0], null, '*', null, true);
- if(empty($list)){
- continue;
- }
- $arr = [];
- foreach ($list as $live) {
- $addTime = $live->addTime;
- $date = date("Y-m-d", strtotime($addTime));
- $arr[$date] = 1;
- }
- if (count($arr) > 1) {
- noticeUtil::push($name." mainId:{$mainId} live order 有记录不是同一天的", '15280215347');
- continue;
- }
- //转换完了之后要清货位号!!!!!!!!!
- $transaction->commit();
- Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
- } catch (\Exception $e) {
- $transaction->rollBack();
- $msg = $e->getMessage();
- noticeUtil::push($name." mainId:{$mainId} live order 报错了:".$msg, '15280215347');
- }
- }
- }
- }
|