wupengfei 3 năm trước cách đây
mục cha
commit
22960fc7a2

+ 24 - 1
application/store/controller/OrderReturn.php

@@ -1,5 +1,6 @@
 <?php
 namespace app\store\controller;
+use EasyWeChat\Factory;
 use library\Controller;
 use think\Db;
 /**
@@ -115,7 +116,29 @@ class OrderReturn extends Controller
     {
         $id = input('post.id');
         $refund_info = Db::table('order_refund')->find($id);
-
+        $order_info = Db::table('store_order')->find($refund_info['order_id']);
+        if ($order_info['price_total'] < $refund_info['apply_money']) $this->error('退款金额错误');
+        $rufund_success = 0;
+        Db::startTrans();
+        try {
+            $app = Factory::payment(config('app.wx_pay'));
+            $result = $app->refund->byOutTradeNumber($order_info['pay_no'], $order_info['refund_no'], $order_info['price_total']*100, $refund_info['amount']*100, [
+                'refund_desc' => '订单退款',
+            ]);
+
+            if($result['return_result']=='SUCCESS' && $result['result_code']=='SUCCESS') $rufund_success = 1;
+            $return_json=json_encode($result);
+            if ($rufund_success == 1) {
+                Db::commit();
+                $this->success('退款成功!');
+            } else {
+                Db::rollback();// 回滚事务
+                $this->error('退款失败1');
+            }
+        }catch (\UnexpectedValueException $e) {
+            Db::rollback();// 回滚事务
+            $this->error('退款失败');
+        }
     }
 
 

BIN
public/wx_cert/apiclient_cert.p12


+ 20 - 20
public/wx_cert/apiclient_cert.pem

@@ -1,24 +1,24 @@
 -----BEGIN CERTIFICATE-----
-MIID8DCCAtigAwIBAgIUaMscqB3FzlY2TkA8DnzEIhaLDaYwDQYJKoZIhvcNAQEL
+MIID9jCCAt6gAwIBAgIUaRFcPdiqcbUsNU5IdQ7ZnDlX5/kwDQYJKoZIhvcNAQEL
 BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsT
 FFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3Qg
-Q0EwHhcNMjEwODMxMDU1NjAyWhcNMjYwODMwMDU1NjAyWjCBgTETMBEGA1UEAwwK
-MTYx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