LiveOrderController.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace console\controllers;
  3. use biz\shop\classes\ShopClass;
  4. use bizGhs\live\classes\LiveOrderClass;
  5. use common\components\noticeUtil;
  6. use yii\console\Controller;
  7. use Yii;
  8. class LiveOrderController extends Controller
  9. {
  10. //每二分钟执行一次 ssh 20241006
  11. public function actionSeat()
  12. {
  13. ini_set('memory_limit', '2045M');
  14. set_time_limit(0);
  15. $shopList = ShopClass::getAllByCondition(['ptStyle'=>2],null,'id,ptStyle,shopName',null,true);
  16. if(empty($shopList)){
  17. return false;
  18. }
  19. foreach($shopList as $shop){
  20. $mainId = $shop->mainId;
  21. $shopName = $shop->shopName??'';
  22. $sjName = $shop->merchantName??'';
  23. $name = $sjName.' '.$shopName;
  24. $cacheKey = 'live_order_' . $mainId;
  25. $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  26. if(empty($has)){
  27. continue;
  28. }
  29. $connection = Yii::$app->db;
  30. $transaction = $connection->beginTransaction();
  31. try {
  32. $list = LiveOrderClass::getAllByCondition(['mainId' => $mainId,'switchOrder'=>0], null, '*', null, true);
  33. if(empty($list)){
  34. continue;
  35. }
  36. $arr = [];
  37. foreach ($list as $live) {
  38. $addTime = $live->addTime;
  39. $date = date("Y-m-d", strtotime($addTime));
  40. $arr[$date] = 1;
  41. }
  42. if (count($arr) > 1) {
  43. noticeUtil::push($name." mainId:{$mainId} live order 有记录不是同一天的", '15280215347');
  44. continue;
  45. }
  46. //转换完了之后要清货位号!!!!!!!!!
  47. $transaction->commit();
  48. Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
  49. } catch (\Exception $e) {
  50. $transaction->rollBack();
  51. $msg = $e->getMessage();
  52. noticeUtil::push($name." mainId:{$mainId} live order 报错了:".$msg, '15280215347');
  53. }
  54. }
  55. }
  56. }