| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- /**
- * rabbitMq 消费者
- */
- namespace console\controllers;
- use common\enums\ExpressEnum;
- use common\enums\StatusEnum;
- use common\helpers\FormatHelper;
- use common\models\common\MallSetting;
- use common\models\order\OrderExpressLog;
- use Yii;
- use yii\console\Controller;
- use yii\console\ExitCode;
- class LogisticsController extends Controller
- {
- public function actionUpdateExpress()
- {
- // 弃用定时任务查询,数量过大会导致curl并发导致定时任务堵塞
- echo '操作成功';
- return ExitCode::OK;
- try {
- $mall_list = \common\models\mall\Mall::getEnableMallList();
- foreach ($mall_list as $mall) {
- $mall_id = $mall['id'];
- $express_account = Yii::$app->services->setting->mall->get($mall_id,'logistics');
- $part = 1;
- $limit = 200;
- //测试 -start
- // $express_account['kdn_business_iD'] = '1757494';
- // $express_account['kdn_app_key'] = '49533209-91e9-4cb7-a55d-232169a6a91d';
- // $params = [];
- // $part_where = [['=', 'mall_id', $mall_id], ['=', 'table_express_status', ExpressEnum::TABLE_EXPRESS_WAIT]];
- // $part_data = self::batchGetExpressLog($params, $part, $limit);
- // self::updateLog($part_data, $express_account);
- //测试 -end
- $select = "id,mall_id,order_id,express_no,customer_name,express_code,express_id";
- $part_where = [['=', 'mall_id', $mall_id], ['=', 'status', StatusEnum::ENABLED], ['=', 'table_express_status', ExpressEnum::TABLE_EXPRESS_WAIT]];
- $params = ['where' => $part_where, 'select' => $select];
- while ($part_data = OrderExpressLog::batchGetExpressLog($params, $part, $limit)) {
- if ($part_data) {
- OrderExpressLog::updateLog($part_data, $express_account);
- }
- $part++;
- }
- }
- echo '操作成功';
- return ExitCode::OK;
- } catch (\Exception $e) {
- echo '物流更新任务处理出错:' . $e->getMessage() . PHP_EOL;
- return ExitCode::UNSPECIFIED_ERROR;
- }
- }
- }
|