Browse Source

支付

master
jianglong 3 years ago
parent
commit
ffae4b56f0
  1. 6
      app/api/controller/Pay.php
  2. 1
      app/api/logic/OrderLogic.php
  3. 2
      app/common/server/WeChatPayServer.php

6
app/api/controller/Pay.php

@ -60,12 +60,18 @@ class Pay extends Api
//会员订单 //会员订单
if($trader_order['type'] == 1){ if($trader_order['type'] == 1){
$order = OrderUser::where('trade_id', $post['order_id'])->findOrEmpty(); $order = OrderUser::where('trade_id', $post['order_id'])->findOrEmpty();
if($order){
$order['order_amount'] = $order['pay_money'];
}
// 更新支付方式 // 更新支付方式
OrderUser::where('trade_id', $post['order_id'])->update(['pay_way' => $post['pay_way']]); OrderUser::where('trade_id', $post['order_id'])->update(['pay_way' => $post['pay_way']]);
} }
//资料订单 //资料订单
if($trader_order['type'] == 2){ if($trader_order['type'] == 2){
$order = OrderResource::where('trade_id', $post['order_id'])->findOrEmpty(); $order = OrderResource::where('trade_id', $post['order_id'])->findOrEmpty();
if($order){
$order['order_amount'] = $order['pay_money'];
}
// 更新支付方式 // 更新支付方式
OrderResource::where('trade_id', $post['order_id'])->update(['pay_way' => $post['pay_way']]); OrderResource::where('trade_id', $post['order_id'])->update(['pay_way' => $post['pay_way']]);
} }

1
app/api/logic/OrderLogic.php

@ -1885,6 +1885,7 @@ class OrderLogic extends Logic
->field(['ot.id', 'ot.t_sn as order_sn', 'o.pay_time', 'o.pay_way', 'ot.total_amount']) ->field(['ot.id', 'ot.t_sn as order_sn', 'o.pay_time', 'o.pay_way', 'ot.total_amount'])
->findOrEmpty() ->findOrEmpty()
->toArray(); ->toArray();
$result['total_amount'] = '¥' . $result['total_amount']; $result['total_amount'] = '¥' . $result['total_amount'];
break; break;

2
app/common/server/WeChatPayServer.php

@ -106,6 +106,7 @@ class WeChatPayServer
$app = Factory::payment($config); $app = Factory::payment($config);
$attributes = self::getAttributes($from, $order, $order_source, $auth, $notify_url); $attributes = self::getAttributes($from, $order, $order_source, $auth, $notify_url);
var_dump($attributes);die;
$result = $app->order->unify($attributes); $result = $app->order->unify($attributes);
if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') { if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') {
@ -335,7 +336,6 @@ class WeChatPayServer
$app = new Application($config); $app = new Application($config);
$response = $app->handlePaidNotify(function ($message, $fail) { $response = $app->handlePaidNotify(function ($message, $fail) {
if ($message['return_code'] !== 'SUCCESS') { if ($message['return_code'] !== 'SUCCESS') {
return $fail('通信失败'); return $fail('通信失败');
} }

Loading…
Cancel
Save