|
|
@@ -2,10 +2,17 @@
|
|
|
|
|
|
namespace console\controllers;
|
|
|
|
|
|
+use biz\ghs\classes\GhsClass;
|
|
|
+use biz\market\classes\TjFlClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
+use biz\sj\classes\SjClass;
|
|
|
+use biz\stat\classes\StatItemClass;
|
|
|
+use bizGhs\custom\classes\CustomClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
+use bizGhs\order\classes\OrderItemClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use bizHd\stat\classes\StatVisitClass;
|
|
|
+use common\components\dict;
|
|
|
use Yii;
|
|
|
use yii\console\Controller;
|
|
|
|
|
|
@@ -25,9 +32,77 @@ class GlobalController extends Controller
|
|
|
ProductClass::allShopStockWarningFromQueue();
|
|
|
}
|
|
|
|
|
|
- //每三分钟进行一次完成订单的流程处理,现在有:花材统计
|
|
|
+ //每2分钟进行已完成支付订单处理,花材销量统计、推荐新客发红包
|
|
|
if ((int)date('i') % 2 == 0) {
|
|
|
- OrderClass::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)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ //推荐新客发红包
|
|
|
+ $tjFl = $shop->tjFl ?? 0;
|
|
|
+ if ($tjFl == 1) {
|
|
|
+ $customId = $order->customId ?? 0;
|
|
|
+ $hostShopId = $order->shopId ?? 0;
|
|
|
+ $custom = CustomClass::getById($customId, true);
|
|
|
+ if (!empty($custom)) {
|
|
|
+ $ghsId = $custom->ghsId ?? 0;
|
|
|
+ $ghs = GhsClass::getById($ghsId, true);
|
|
|
+ $hasOrder = $custom->hasOrder ?? 0;
|
|
|
+ $hasCg = $ghs->hasCg ?? 0;
|
|
|
+ if ($hasOrder == 0 && $hasCg == 0) {
|
|
|
+ $custom->hasOrder = 1;
|
|
|
+ $custom->save();
|
|
|
+
|
|
|
+ $ghs->hasCg = 1;
|
|
|
+ $ghs->save();
|
|
|
+
|
|
|
+ $customSjId = $custom->sjId ?? 0;
|
|
|
+ $sj = SjClass::getById($customSjId, true);
|
|
|
+ //下单客户的介绍人如果是自己客户则发福利
|
|
|
+ $parentShopId = $sj->parentShopId ?? 0;
|
|
|
+ $tjCustom = CustomClass::getByCondition(['shopId' => $parentShopId, 'ownShopId' => $hostShopId], true);
|
|
|
+ $tjGhsId = $tjCustom->ghsId ?? 0;
|
|
|
+ $tjGhs = GhsClass::getById($tjGhsId, true);
|
|
|
+ TjFlClass::giveGift($tjGhs, $tjCustom, $custom);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//每天凌晨00:10保存昨天访客数
|