wupengfei 1 year ago
parent
commit
7fd1483fad

+ 6 - 4
.idea/workspace.xml

@@ -3,8 +3,10 @@
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/common/service/Activity.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common/service/Activity.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/common/service/OrderCallback.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common/service/OrderCallback.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/mall/controller/StoreGoods.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/mall/controller/StoreGoods.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/application/order/controller/RefundOrder.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/order/controller/RefundOrder.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/application/order/view/refund_order/audit.html" beforeDir="false" afterPath="$PROJECT_DIR$/application/order/view/refund_order/audit.html" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -421,7 +423,7 @@
       <workItem from="1694392543142" duration="23428000" />
       <workItem from="1694480523673" duration="21063000" />
       <workItem from="1694565971470" duration="21552000" />
-      <workItem from="1694652561038" duration="11450000" />
+      <workItem from="1694652561038" duration="13307000" />
     </task>
     <servers />
   </component>
@@ -547,10 +549,10 @@
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
     <state x="1056" y="474" key="#Deployment/0.0.2560.1400@0.0.2560.1400" timestamp="1693191680884" />
-    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1694662644269">
+    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1694673363941">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
-    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.2560.1400@0.0.2560.1400" timestamp="1694662644269" />
+    <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.2560.1400@0.0.2560.1400" timestamp="1694673363941" />
     <state x="360" y="413" width="1942" height="1088" key="DiffContextDialog" timestamp="1694419923508">
       <screen x="0" y="0" width="2560" height="1400" />
     </state>

+ 2 - 2
application/common/service/Activity.php

@@ -166,7 +166,7 @@ class Activity extends SerBase
         try {
             $refund_no = $refund_info['refund_no'] ? $refund_info['refund_no'] : get_order_sn();
             //微信退款
-            if(in_array($order_info['pay_type'],[1,3,5])){ // h5
+            if(in_array($order_info['pay_type'],[1,3,5,6])){ // h5
                 $app = $order_info['pay_type'] == 3 ? Factory::payment(config('app.app_wx')) :  Factory::payment(config('app.wx_pay'));
                 $result = $app->refund->byOutTradeNumber($order_info['pay_no'], $refund_no, $order_info['money'] * 100, $refund_info['refund_money']*100, ['refund_desc' => '订单退款']);
                // var_dump($result);
@@ -176,7 +176,7 @@ class Activity extends SerBase
                 GoodsOrderRefund::where(['id'=>$refund_info['id']])->update(['refund_no'=>$refund_no,'status'=>3]);
             }
             //  支付宝退款
-            if(in_array($order_info['pay_type'],[2,4]))
+            if(in_array($order_info['pay_type'],[2,4,7]))
             {
                 $result =  Alipay::aliRefund($order_info['pay_no'], $refund_info['refund_money'],$order_info['pay_type'] == 2 ?'H5':'APP');
                 if(!$result)   throw new Exception('支付宝退款异常');

+ 15 - 42
application/common/service/OrderCallback.php

@@ -1,5 +1,6 @@
 <?php
 namespace app\common\service;
+use app\api\controller\Alipay;
 use app\common\model\ActivityApply;
 use app\common\model\ActivityApplyItem;
 use app\common\model\BillApply;
@@ -65,7 +66,7 @@ class OrderCallback
     }
 
 
-    // 订单金额退款
+    // 商城订单执行退款
     public static function refundMoney($refund_info =[],$order_info=[],$order_id = 0)
     {
         $ret = ['code'=>200,'msg'=>'退款成功'];
@@ -76,48 +77,20 @@ class OrderCallback
         $refund_no = $refund_info['refund_no'] ? $refund_info['refund_no'] : get_order_sn();
         Db::startTrans();
         try {
-            switch ($order_info['pay_type']){
-                case 1:
-                    $app = Factory::payment(config('app.wx_pay'));
-                    $result = $app->refund->byOutTradeNumber($order_info['pay_no'], $refund_no, $order_info['price_total']*100, $refund_info['refund_money']*100, ['refund_desc' => '订单退款']);
-                    if($result['return_code'] != 'SUCCESS')  throw new Exception('退款异常');
-                    if($result['result_code'] != 'SUCCESS')  throw new Exception($result['err_code_des']);
-                    // 修改退款记录状态
-                    GoodsOrderRefund::where(['id'=>$refund_info['id']])->update(['refund_no'=>$refund_no,'status'=>3]);
-                    // 修改订单状态
-                    GoodsOrder::where('id',$refund_info['order_id'])->update(['status'=>8]);
-                    // 积分退回
-                    if($order_info['integral']) UserWallet::userIntegralChange($order_info['user_id'],$order_info['integral'],'订单退款退回',9,1,$order_info['id']);
-                    // 余额退回
-                    if($order_info['balance']) UserWallet::userMoneyChange($order_info['user_id'],$order_info['balance'],'订单退款退回',2, 1,$order_info['id']);
-                    // 券暂不出来
-                    break;
-                case 2:
-                    break;
-                case 3:
-                    break;
-                case 4: //4移动支付(微信)
-                    $app = Factory::payment(config('app.app_wx'));
-                    $result = $app->refund->byOutTradeNumber($order_info['pay_no'], $refund_no, $order_info['price_total']*100, $refund_info['refund_money']*100, ['refund_desc' => '订单退款']);
-                    if($result['return_code'] != 'SUCCESS')  throw new Exception('退款异常');
-                    if($result['result_code'] != 'SUCCESS')  throw new Exception($result['err_code_des']);
-                    // 修改退款记录状态
-                    GoodsOrderRefund::where(['id'=>$refund_info['id']])->update(['refund_no'=>$refund_no,'status'=>3]);
-                    // 修改订单状态
-                    GoodsOrder::where('id',$refund_info['order_id'])->update(['status'=>8]);
-                    // 积分退回
-                    if($order_info['integral']) UserWallet::userIntegralChange($order_info['user_id'],$order_info['integral'],'订单退款退回',9,1,$order_info['id']);
-                    // 余额退回
-                    if($order_info['balance']) UserWallet::userMoneyChange($order_info['user_id'],$order_info['balance'],'订单退款退回',2, 1,$order_info['id']);
-                    // 券暂不出来
-                    break;
-                case 5:
-                    break;
-                case 6:
-                    break;
+            //微信退款
+            if(in_array($order_info['pay_type'],[1,3,5,6])){
+                $app = $order_info['pay_type'] == 3 ? Factory::payment(config('app.app_wx')) :  Factory::payment(config('app.wx_pay'));
+                $result = $app->refund->byOutTradeNumber($order_info['pay_no'], $refund_no, $order_info['price_total'] * 100, $refund_info['refund_money']*100, ['refund_desc' => '订单退款']);
+                if($result['return_code'] != 'SUCCESS')  throw new Exception('微信退款异常');
+                if($result['result_code'] != 'SUCCESS')  throw new Exception($result['err_code_des']);
+                GoodsOrderRefund::where(['id'=>$refund_info['id']])->update(['refund_no'=>$refund_no,'status'=>3]);
+            }
+            //  支付宝退款
+            if(in_array($order_info['pay_type'],[2,4,7])) {
+                $result =  Alipay::aliRefund($order_info['pay_no'], $refund_info['refund_money'],$order_info['pay_type'] == 4 ?'APP':'H5');
+                if(!$result)   throw new Exception('支付宝退款异常');
+                GoodsOrderRefund::where(['id'=>$refund_info['id']])->update(['refund_no'=>$refund_no,'status'=>3]);
             }
-            // 订单相关返利追回
-            self::goodsOrderRefundBack($order_info , $order_id);
             Db::commit();
         }catch (\Exception $e){
             $ret['code'] = 201;

+ 2 - 3
application/mall/controller/StoreGoods.php

@@ -119,7 +119,8 @@ class StoreGoods extends Controller
         // 添加或编辑商品
         if($this->request->isPost() && in_array($this->request->action(),['add','edit'])){
             list($data) = [$this->request->post()];
-
+            if(!$data['release_time']) $data['release_time'] = date("Y-m-d H:i:s");
+            if($data['hot_num'] != $data['hot_num_old']) $data['hot_time'] = date("Y-m-d H:i:s");
             $check_price = true;
             $lists = json_decode($data['lists'], true);
             foreach ($lists as $ke=>&$vo){
@@ -221,8 +222,6 @@ class StoreGoods extends Controller
             $this->fetch('', ['vo' => $goods_info]);
         } else {
             list($post, $data) = [$this->request->post(), []];
-            if(!$data['release_time']) $data['release_time'] = date("Y-m-d H:i:s");
-            if($data['hot_num'] != $data['hot_num_old']) $data['hot_time'] = date("Y-m-d H:i:s");
             if (isset($post['id']) && isset($post['goods_id']) && is_array($post['goods_id'])) {
                 foreach (array_keys($post['goods_id']) as $key) {
                     if ($post['goods_number'][$key] > 0) array_push($data, [

+ 2 - 2
application/order/controller/RefundOrder.php

@@ -121,7 +121,7 @@ class RefundOrder extends Controller
             if($sh_status > 1) GoodsOrder::where('id',$refund_info['order_id'])->update(['refund_state'=>$sh_status]);
             if($status == 3) {
                 $res = OrderCallback::refundMoney($refund_info,[],$refund_info['order_id']);
-                if($res['code'] != 200) StoreOrderRefund::where('id',$id)->update(['status'=>2]);
+                if($res['code'] != 200) StoreOrderRefund::where('id',$id)->update(['status'=>4]);
                 $this->error($res['msg']);
             }
         }
@@ -137,7 +137,7 @@ class RefundOrder extends Controller
             if($refund_info['status'] == 5) $this->error('申请已取消');
             if ($order_info['price_total'] < $refund_info['refund_money'])return $this->error('退款金额错误');
             $res = OrderCallback::refundMoney($refund_info,$order_info,$refund_info['order_id']);
-            return $res['code'] == 200 ? $this->success($res['msg']):$this->error($res['msg']);
+            $res['code'] == 200 ? $this->success($res['msg']):$this->error($res['msg']);
         }
     }