diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index df0eb1020..082f79306 100644 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -47,7 +47,7 @@ class PayController extends BaseApiController } else { if ($result && $result->event_type == 'REFUND.SUCCESS') { $ciphertext = $result->resource['ciphertext']; - Cache::set('7logC'.time(),json_encode($ciphertext)); + Cache::set('7logC' . time(), json_encode($ciphertext)); if ($ciphertext['refund_status'] === 'SUCCESS') { //处理订单 -1判断是退的一单还是拆分的订单 $out_trade_no = $ciphertext['out_trade_no'] . '-1'; @@ -68,7 +68,6 @@ class PayController extends BaseApiController public function wechatQuery() { $order_no = $this->request->get('order_no'); - $recharge = $this->request->get('recharge', 0); $order = [ 'out_trade_no' => $order_no, ]; @@ -80,10 +79,17 @@ class PayController extends BaseApiController return $this->fail($e->extra['message']); } if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') { - if ($recharge == 0) { - PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res); - } else { - PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res); + $attach = $res['attach']; + switch ($attach) { + case 'recharge': + PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res); + $app->wechat->success(); + break; + case 'wechat_common': + default: + PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res); + $app->wechat->success(); + break; } return $this->success('支付成功'); } else { diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index 4a1cb24fa..de54e5ff9 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -127,6 +127,7 @@ class StoreController extends BaseApiController $order = UserRecharge::create($data); $order['pay_price']=$order['price']; + $order['attach']=$order['recharge']; $result = PaymentLogic::codepay($auth_code, $order,'条码支付'); if (PaymentLogic::hasError()) { return $this->fail(PaymentLogic::getError()); @@ -155,6 +156,7 @@ class StoreController extends BaseApiController UserRecharge::where('id', $id)->update(['order_id'=>$order_id]); $order['order_id']=$order_id; $order['pay_price']=$order['price']; + $order['attach']=$order['recharge']; $result = PaymentLogic::codepay($auth_code, $order,'条码支付'); if (PaymentLogic::hasError()) { return $this->fail(PaymentLogic::getError()); diff --git a/app/common/logic/PaymentLogic.php b/app/common/logic/PaymentLogic.php index a49df6407..322cc442d 100644 --- a/app/common/logic/PaymentLogic.php +++ b/app/common/logic/PaymentLogic.php @@ -83,7 +83,7 @@ class PaymentLogic extends BaseLogic self::$error = '请使用正确的微信收付款条码'; return false; } - $order = [ + $data = [ 'description' => $description, 'out_trade_no' => (string)$order['order_id'], 'payer' => [ @@ -97,10 +97,14 @@ class PaymentLogic extends BaseLogic 'id' => (string)$order['store_id']??1 ] ], + 'attach'=>'wechat_common' ]; + if(isset($order['attach']) && $order['attach']!=''){ + $data['attach'] = $order['attach']; + } $wechat = new PayService(1); try { - $result = $wechat->wechat->pos($order)->toArray(); + $result = $wechat->wechat->pos($data)->toArray(); } catch (Exception $e) { Log::error('条码支付报错',['message' => $e->extra['message']?? $e->getMessage(),'code'=>$e->getCode()]);