base
parent
8d89ba1a5f
commit
79434da3f1
|
|
@ -6,6 +6,7 @@ use App\Enums\OfflineOrderStatus;
|
||||||
use App\Enums\SocialiteType;
|
use App\Enums\SocialiteType;
|
||||||
use App\Exceptions\BizException;
|
use App\Exceptions\BizException;
|
||||||
use App\Exceptions\InvalidPaySerialNumberException;
|
use App\Exceptions\InvalidPaySerialNumberException;
|
||||||
|
use App\Jobs\UploadShippingInfoJob;
|
||||||
use App\Models\PayLog;
|
use App\Models\PayLog;
|
||||||
use App\Models\{OfflineOrder, Order, OrderPre, SocialiteUser};
|
use App\Models\{OfflineOrder, Order, OrderPre, SocialiteUser};
|
||||||
|
|
||||||
|
|
@ -94,43 +95,41 @@ class PayService
|
||||||
(new \App\Services\VipService())->success($payable, ['pay_at' => $payLog->pay_at]);
|
(new \App\Services\VipService())->success($payable, ['pay_at' => $payLog->pay_at]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 延迟1分钟执行, 不然会出现错误信息: (10060001)支付单不存在
|
// TODO 延迟1分钟执行, 不然会出现错误信息: (10060001)支付单不存在
|
||||||
sleep(60);
|
// TODO 订单支付成功, 调用发货信息API
|
||||||
// 订单支付成功, 调用发货信息API
|
// try {
|
||||||
try {
|
// if (!$userId) {
|
||||||
if (!$userId) {
|
// throw new BizException("未找到userId");
|
||||||
throw new BizException("未找到userId");
|
// }
|
||||||
}
|
// $socialite = SocialiteUser::where('user_id', $userId)->where('socialite_type', SocialiteType::WechatMiniProgram)->first();
|
||||||
$socialite = SocialiteUser::where('user_id', $userId)->where('socialite_type', SocialiteType::WechatMiniProgram)->first();
|
// if (!$socialite) {
|
||||||
if (!$socialite) {
|
// throw new BizException("未找到 SocialiteUser 记录, userId: " . $userId);
|
||||||
throw new BizException("未找到 SocialiteUser 记录, userId: " . $userId);
|
// }
|
||||||
}
|
// $openid = $socialite->socialite_id;
|
||||||
$openid = $socialite->socialite_id;
|
// if (!$openid) {
|
||||||
if (!$openid) {
|
// throw new BizException("未找到 openid, userId: " . $userId);
|
||||||
throw new BizException("未找到 openid, userId: " . $userId);
|
// }
|
||||||
}
|
// $data = [
|
||||||
$data = [
|
// "order_key" => [
|
||||||
"order_key" => [
|
// // "mchid" => config("wechat.payment.sub.mch_id"),
|
||||||
// "mchid" => config("wechat.payment.sub.mch_id"),
|
// // "out_trade_no" => $payLog->pay_sn,
|
||||||
// "out_trade_no" => $payLog->pay_sn,
|
// "order_number_type" => 2,
|
||||||
"order_number_type" => 2,
|
// "transaction_id" => $payLog->out_trade_no,
|
||||||
"transaction_id" => $payLog->out_trade_no,
|
// ],
|
||||||
],
|
// "logistics_type" => 4,
|
||||||
"logistics_type" => 4,
|
// "delivery_mode" => 1,
|
||||||
"delivery_mode" => 1,
|
// "shipping_list" => [
|
||||||
"shipping_list" => [
|
// ["item_desc" => "定制服务"]
|
||||||
["item_desc" => "定制服务"]
|
// ],
|
||||||
],
|
// "upload_time" => $payLog->pay_at->format('Y-m-d\TH:i:s.vP'),
|
||||||
"upload_time" => $payLog->pay_at->format('Y-m-d\TH:i:s.vP'),
|
// "payer" => [
|
||||||
"payer" => [
|
// "openid" => $openid
|
||||||
"openid" => $openid
|
// ]
|
||||||
]
|
// ];
|
||||||
];
|
// WxMpService::make()->uploadShippingInfo($data);
|
||||||
logger("微信小程序-发货信息录入", $data);
|
// } catch (\Exception $e) {
|
||||||
WxMpService::make()->uploadShippingInfo($data);
|
// logger()->error("微信小程序-发货信息录入, " . $e->getMessage(), ['pay_log_id' => $payLog->id]);
|
||||||
} catch (\Exception $e) {
|
// }
|
||||||
logger()->error("微信小程序-发货信息录入, " . $e->getMessage(), ['pay_log_id' => $payLog->id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $payLog;
|
return $payLog;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ class WxMpService
|
||||||
*/
|
*/
|
||||||
public function uploadShippingInfo(array $data)
|
public function uploadShippingInfo(array $data)
|
||||||
{
|
{
|
||||||
|
logger("微信小程序-发货信息录入, 参数", $data);
|
||||||
$app = Factory::miniProgram(config('wechat.mini_program.default'));
|
$app = Factory::miniProgram(config('wechat.mini_program.default'));
|
||||||
$accessToken = $app->access_token->getToken()['access_token'];
|
$accessToken = $app->access_token->getToken()['access_token'];
|
||||||
$url = "https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=" . $accessToken;
|
$url = "https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=" . $accessToken;
|
||||||
|
|
@ -26,7 +27,7 @@ class WxMpService
|
||||||
$response->throw();
|
$response->throw();
|
||||||
|
|
||||||
$result = $response->json();
|
$result = $response->json();
|
||||||
logger("微信小程序-发货信息录入", $result);
|
logger("微信小程序-发货信息录入, 结果", $result);
|
||||||
$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