|
|
@@ -7,6 +7,7 @@ use biz\shop\classes\ShopClass;
|
|
|
use biz\shop\classes\ShopExtClass;
|
|
|
use biz\shop\models\Shop;
|
|
|
use biz\sj\classes\SjClass;
|
|
|
+use biz\stat\classes\StatItemClass;
|
|
|
use biz\stat\classes\StatOrderCountClass;
|
|
|
use bizGhs\custom\models\Custom;
|
|
|
use bizGhs\express\services\DadaExpressServices;
|
|
|
@@ -1001,4 +1002,59 @@ class OrderClass extends BaseClass
|
|
|
return $order;
|
|
|
}
|
|
|
|
|
|
+ //新订单入队列 shish 20211012
|
|
|
+ public static function newOrderAddQueue($order)
|
|
|
+ {
|
|
|
+ $shopId = $order->shopId ?? 0;
|
|
|
+ if (empty($shopId)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $id = $order->id ?? 0;
|
|
|
+ if (empty($id)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $newOrderKey = 'ghsNewOrder_' . $shopId;
|
|
|
+ Yii::$app->redis->executeCommand('LPUSH', [$newOrderKey, $id]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理队列里的新订单 shish 20211012
|
|
|
+ public static function newOrderFromQueueDone()
|
|
|
+ {
|
|
|
+ $ghs = dict::getDict('ptStyle', 'ghs');
|
|
|
+ $shopList = ShopClass::getAllByCondition(['ptStyle' => $ghs], null, '*', null, true);
|
|
|
+ if (!empty($shopList)) {
|
|
|
+ foreach ($shopList as $key => $shop) {
|
|
|
+ $ids = [];
|
|
|
+ $shopId = $shop->id ?? 0;
|
|
|
+ $newOrderKey = 'ghsNewOrder_' . $shopId;
|
|
|
+ while ($count = Yii::$app->redis->executeCommand('LLEN', [$newOrderKey])) {
|
|
|
+ $id = Yii::$app->redis->executeCommand('RPOP', [$newOrderKey]);
|
|
|
+ if (is_numeric($id)) {
|
|
|
+ $ids[] = $id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (empty($ids)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $list = OrderClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
|
|
|
+ if (empty($list)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ foreach ($list as $key => $order) {
|
|
|
+ $orderSn = $order->orderSn ?? '';
|
|
|
+ if (empty($orderSn)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $itemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
|
|
|
+ if (empty($itemList)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ foreach ($itemList as $itemKey => $itemVal) {
|
|
|
+ StatItemClass::replace($itemVal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|