微信支付 发货信息
parent
3197244f6e
commit
f98aed8153
|
|
@ -95,29 +95,36 @@ class PayService
|
||||||
}
|
}
|
||||||
|
|
||||||
// 订单支付成功, 调用发货信息API
|
// 订单支付成功, 调用发货信息API
|
||||||
if ($userId) {
|
try {
|
||||||
$socialite = SocialiteUser::where('user_id', $userId)->where('socialite_type', SocialiteType::WechatMiniProgram)->first();
|
if (!$userId) {
|
||||||
if ($socialite) {
|
throw new BizException("未找到userId");
|
||||||
$openid = $socialite->socialite_id;
|
|
||||||
if ($openid) {
|
|
||||||
$data = [
|
|
||||||
"order_key" => [
|
|
||||||
"order_number_type" => 1,
|
|
||||||
"out_trade_no" => $payLog->pay_sn,
|
|
||||||
],
|
|
||||||
"logistics_type" => 4,
|
|
||||||
"delivery_mode" => 1,
|
|
||||||
"shipping_list" => [
|
|
||||||
"item_desc" => "定制服务"
|
|
||||||
],
|
|
||||||
"upload_time" => $payLog->pay_at,
|
|
||||||
"payer" => [
|
|
||||||
"openid" => $openid
|
|
||||||
]
|
|
||||||
];
|
|
||||||
WxMpService::make()->uploadShippingInfo($data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$socialite = SocialiteUser::where('user_id', $userId)->where('socialite_type', SocialiteType::WechatMiniProgram)->first();
|
||||||
|
if (!$socialite) {
|
||||||
|
throw new BizException("未找到 SocialiteUser 记录, userId: " . $userId);
|
||||||
|
}
|
||||||
|
$openid = $socialite->socialite_id;
|
||||||
|
if (!$openid) {
|
||||||
|
throw new BizException("未找到 openid, userId: " . $userId);
|
||||||
|
}
|
||||||
|
$data = [
|
||||||
|
"order_key" => [
|
||||||
|
"order_number_type" => 1,
|
||||||
|
"out_trade_no" => $payLog->pay_sn,
|
||||||
|
],
|
||||||
|
"logistics_type" => 4,
|
||||||
|
"delivery_mode" => 1,
|
||||||
|
"shipping_list" => [
|
||||||
|
"item_desc" => "定制服务"
|
||||||
|
],
|
||||||
|
"upload_time" => $payLog->pay_at->format('Y-m-d H:i:s'),
|
||||||
|
"payer" => [
|
||||||
|
"openid" => $openid
|
||||||
|
]
|
||||||
|
];
|
||||||
|
WxMpService::make()->uploadShippingInfo($data);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
logger()->error("微信小程序-发货信息录入, " . $e->getMessage(), ['pay_log_id' => $payLog->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $payLog;
|
return $payLog;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class WxMpService
|
||||||
$result = $response->json();
|
$result = $response->json();
|
||||||
$code = data_get($result, "errcode");
|
$code = data_get($result, "errcode");
|
||||||
if ($code != 0) {
|
if ($code != 0) {
|
||||||
throw new BizException("微信小程序-发货信息录入, 失败: (".$code.")" . data_get($result, "errmsg"));
|
throw new BizException("失败: (".$code.")" . data_get($result, "errmsg"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue