|
|
@@ -89,18 +89,18 @@ class WeChatPayService extends BasePayService
|
|
|
* @author 段誉
|
|
|
* @date 2021/8/4 15:05
|
|
|
*/
|
|
|
- public function pay($from, $order)
|
|
|
+ public function pay($from, $order, $openid = '')
|
|
|
{
|
|
|
|
|
|
try {
|
|
|
switch ($this->terminal) {
|
|
|
case UserTerminalEnum::WECHAT_MMP:
|
|
|
$config = WeChatConfigService::getMnpConfig();
|
|
|
- $result = $this->jsapiPay($from, $order, $config['app_id']);
|
|
|
+ $result = $this->jsapiPay($from, $order, $config['app_id'], $openid??'');
|
|
|
break;
|
|
|
case UserTerminalEnum::WECHAT_OA:
|
|
|
$config = WeChatConfigService::getOaConfig();
|
|
|
- $result = $this->jsapiPay($from, $order, $config['app_id']);
|
|
|
+ $result = $this->jsapiPay($from, $order, $config['app_id'], $openid??'');
|
|
|
break;
|
|
|
case UserTerminalEnum::IOS:
|
|
|
case UserTerminalEnum::ANDROID:
|
|
|
@@ -141,7 +141,7 @@ class WeChatPayService extends BasePayService
|
|
|
* @author 段誉
|
|
|
* @date 2023/2/28 12:12
|
|
|
*/
|
|
|
- public function jsapiPay($from, $order, $appId)
|
|
|
+ public function jsapiPay($from, $order, $appId, $openid = '')
|
|
|
{
|
|
|
$response = $this->app->getClient()->postJson("v3/pay/transactions/jsapi", [
|
|
|
"appid" => $appId,
|
|
|
@@ -153,7 +153,7 @@ class WeChatPayService extends BasePayService
|
|
|
"total" => intval($order['order_amount'] * 100),
|
|
|
],
|
|
|
"payer" => [
|
|
|
- "openid" => $this->auth['openid']
|
|
|
+ "openid" => $openid?:($this->auth['openid']??'')
|
|
|
],
|
|
|
'attach' => $from
|
|
|
]);
|
|
|
@@ -380,7 +380,9 @@ class WeChatPayService extends BasePayService
|
|
|
$extra['transaction_id'] = $message['transaction_id'];
|
|
|
$attach = $message['attach'];
|
|
|
$message['out_trade_no'] = mb_substr($message['out_trade_no'], 0, 18);
|
|
|
-
|
|
|
+ $openid = '';
|
|
|
+ isset($message['payer']) && $message['payer'] && $openid = $message['payer']['openid']??'';
|
|
|
+ $extra['openid'] = $openid;
|
|
|
switch ($attach) {
|
|
|
case 'recharge':
|
|
|
$order = RechargeOrder::where(['sn' => $message['out_trade_no']])->findOrEmpty();
|