where(['from_store_id' => $from_store_id, 'is_delete' => 0]) ->select('to_store_id, imports')->asArray()->all(); if ($storeSyncLock && in_array($type, StoreSyncExtLog::TYPE_ARR)) { //重构格式 将同一个商城的合并 //[ //'to_store_id' => imports//数组 //] $importsArr = []; foreach ($storeSyncLock as $lock_item) { $importsArr[$lock_item['to_store_id']] = []; foreach ($storeSyncLock as $lock_import_item) { $imports = json_decode($lock_import_item['imports'], true); if ($lock_item['to_store_id'] === $lock_import_item['to_store_id']) { $importsArr[$lock_item['to_store_id']] = array_merge($importsArr[$lock_item['to_store_id']], $imports); } } } debug_log(['importsArr' => $importsArr, 'type' => $type], 'DeliveryRulesJob.log'); $to_store_id = []; //获取到可以执行当前事件的store_id foreach ($importsArr as $import_store => $import_item) { if (in_array($type, $import_item)) { array_push($to_store_id, $import_store); } } //制作缓存key sort($to_store_id); sort($params); $cache = md5($type . implode(',', $to_store_id) . implode(',', $params) . $from_store_id); $id = \Yii::$app->cache->get($cache); if ($id && !\Yii::$app->queue->isDone($id)) {//\Yii::$app->queue->status($id) \Yii::$app->queue->remove($id); } $id = 0; switch ($type) { case StoreSyncExtLog::TYPE_ACTIVITY_CUT_PRICE: $id = \queue_push(new \app\jobs\storeSync\CutPriceActivityJob(['activity_id' => $params, 'to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; case StoreSyncExtLog::TYPE_DIY: $id = \queue_push(new \app\jobs\storeSync\DiyJob(['diy_id' => $params, 'to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; case StoreSyncExtLog::TYPE_PT: $id = \queue_push(new \app\jobs\storeSync\PtActivityJob(['pt_activity_id' => $params, 'to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; case StoreSyncExtLog::TYPE_SECKILL: $id = \queue_push(new \app\jobs\storeSync\SeckillActivityJob(['activity_id' => $params, 'to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; case StoreSyncExtLog::TYPE_SHARE_CONFIG: $id = \queue_push(new \app\jobs\storeSync\ShareConfigJob(['to_store_id' => $to_store_id, 'from_store_id' => $from_store_id, 'name' => $params])); break; case StoreSyncExtLog::TYPE_SHARE_HOLDER_CONFIG: //$id = \queue_push(new \app\jobs\storeSync\ShareHolderConfigJob(['to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; case StoreSyncExtLog::TYPE_VIDEO_GOODS: $id = \queue_push(new \app\jobs\storeSync\VideoGoodsJob(['to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; case StoreSyncExtLog::TYPE_INTEGRAL_STORE: $id = \queue_push(new \app\jobs\storeSync\IntegralStoreJob(['to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; case StoreSyncExtLog::TYPE_WORKER_CONFIG_GOODS: $id = \queue_push(new \app\jobs\storeSync\WorkerConfigJob(['to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; case StoreSyncExtLog::TYPE_BOOKING_GOODS: $id = \queue_push(new \app\jobs\storeSync\BookingHomeJob(['to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; case StoreSyncExtLog::TYPE_ARTICLE: $id = \queue_push(new \app\jobs\storeSync\ArticleSettingJob(['to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; case StoreSyncExtLog::TYPE_TOPIC: $id = \queue_push(new \app\jobs\storeSync\TopicSettingJob(['to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; case StoreSyncExtLog::TYPE_POSTAGE_RULES: $id = \queue_push(new \app\jobs\storeSync\DeliveryRulesJob(['to_store_id' => $to_store_id, 'from_store_id' => $from_store_id, 'delivery_rules_id' => $params])); break; case StoreSyncExtLog::TYPE_PRODUCT_CAT: $id = \queue_push(new \app\jobs\storeSync\GoodsCatJob(['to_store_id' => $to_store_id, 'from_store_id' => $from_store_id, 'cat_id' => $params])); break; default: $id = \queue_push(new \app\jobs\storeSync\GoodsJob(['goods_id' => $params, 'to_store_id' => $to_store_id, 'from_store_id' => $from_store_id])); break; } debug_log($id, 'queuePush.log'); if ($id) { \Yii::$app->cache->set($cache, $id); } } } }