$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保存昨天访客数 if ($hour == '0010') { $shopList = ShopClass::getAllByCondition(['ptStyle' => 2], null, '*', null, true); if (!empty($shopList)) { foreach ($shopList as $shop) { //昨天 $date = date("Ymd", strtotime("-1 day")); //今天 //$date = date("Ymd"); $visitNum = StatVisitClass::getVisitNum($shop, $date); $currentNum = bcadd($shop->totalVisit, $visitNum, 2); $shop->totalVisit = $currentNum; $shop->save(); StatVisitClass::saveVisit($shop, $visitNum, $date); } } } } }