发货及后台文件上传优化
This commit is contained in:
@@ -658,8 +658,12 @@ class OrderService
|
||||
*/
|
||||
public static function orderShip($id)
|
||||
{
|
||||
Db::transaction(function () use ($id) {
|
||||
$order = OrderService::getOne(['id' => $id], ['orderGoods']);
|
||||
$order = Db::transaction(function () use ($id) {
|
||||
//加锁读取,防止并发重复发货、重复分配激活码
|
||||
$order = OrderService::where(['id' => $id])->lock(true)->find();
|
||||
if (!$order) {
|
||||
exception('订单不存在');
|
||||
}
|
||||
if ($order->order_status != OrderService::ORDER_STATUS_WAIT_SHIP) {
|
||||
exception('订单状态异常,不能发货');
|
||||
}
|
||||
@@ -673,8 +677,15 @@ class OrderService
|
||||
if (!$saveRes) {
|
||||
exception('更新发货状态失败');
|
||||
}
|
||||
//发送订单发货通知
|
||||
|
||||
return $order;
|
||||
});
|
||||
|
||||
//发送订单发货通知(事务提交后发送,失败只记日志,不影响发货结果)
|
||||
try {
|
||||
$msgData = [
|
||||
'page' => SubscribeMessageService::PAGE_ORDER_DETAIL,
|
||||
'param' => ['orderNo' => $order->order_no],
|
||||
'values' => [
|
||||
$order->order_no,
|
||||
mb_substr($order->orderGoods[0]->goods_name, 0, 20),
|
||||
@@ -683,7 +694,12 @@ class OrderService
|
||||
]
|
||||
];
|
||||
(new EasyWeChatService())->sendMsg($order->user_id, SubscribeMessageService::MSG_TEMP_ORDER_SHIPPED, $msgData);
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
Log::error(__CLASS__ . ' 订单发货通知发送失败:' . json_encode([
|
||||
'order_id' => $id,
|
||||
'error' => $e->getMessage(),
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user