orderId,'订单发货通知用户订阅消息发送队列start'); $t = \Yii::$app->db->beginTransaction(); try { $this->setRequest(); $ProductOrder = ProductOrder::find()->where([ 'id' => $this->orderId, 'is_pay' => 1, 'status' => ProductOrderEnum::WAIT_ACCEPT ])->with(['user','expressNos'])->one(); if (!$ProductOrder||!$ProductOrder->user||!$ProductOrder->expressNos) { throw new Exception('订单不存在'); } $result = WechatService::getInstance()->app->subscribe_message->send([ 'touser' => $ProductOrder->user->openid, 'template_id' => \Yii::$app->params['template']['user']['order_send'], 'page' => 'subPackages/my/my-drug/drug-info?id='.$ProductOrder->id."&store_id=".$ProductOrder->store_id, 'data' => [ 'character_string2' =>[ 'value' => $ProductOrder->order_no, ], 'thing3' => [ 'value' => $ProductOrder->expressNos->express_company_name, ], 'character_string4' => [ 'value' => $ProductOrder->expressNos->express_no, ], 'thing5' => [ 'value' => '您的订单已发货,请注意接收!', ] ] ]); if(isset($result['errcode']) && $result['errcode']){ throw new Exception('发送失败,失败原因:'.$result['errmsg']); } ProductOrderLog::saveLog($this->orderId,'订单发货通知用户订阅消息发送队列end'); } catch (\Exception $exception) { $t->rollBack(); ProductOrderLog::saveLog($this->orderId,'订单发货通知用户订阅消息发送队列异常:'.$exception->getMessage()); return; } } }