瀏覽代碼

商品订单退款

lizhen_gitee 11 月之前
父節點
當前提交
972735459b

+ 12 - 8
application/admin/controller/unishop/Order.php

@@ -10,6 +10,7 @@ use think\Exception;
 use think\exception\PDOException;
 use think\exception\ValidateException;
 use think\Hook;
+use addons\epay\library\Service;
 
 /**
  * 订单管理
@@ -429,22 +430,25 @@ class Order extends Backend
                 // 退款
                 $params = [
                     'refund_status' => $refund_status,
+                    'updatetime' => time(),
                 ];
                 if($refund_status == 3) {
                     $params['had_refund'] = time();
                 }
                 // 乐观锁
                 $result = Db::name('unishop_order')->where(['id' => $ids, 'updatetime' => $updatetime])->update($params);
+                if (!$result) {
+                    throw new Exception(__('Data had been update before saved, close windows and do it again'));
+                }
 
                 //修改退款金额
                 $rs2 = Db::name('unishop_order_refund')->where('order_id',$ids)->update(['amount'=>$refund_amount]);
-
-                if (!$result || !$rs2) {
-                    throw new Exception(__('Data had been update before saved, close windows and do it again'));
+                if ($rs2 === false) {
+                    throw new Exception('操作失败');
                 }
 
-                //执行退款
-                if($refund_amount > 0){
+                //同意并执行退款
+                if($refund_status == 3 && $refund_amount > 0){
                     $order = Db::name('unishop_order')->where('id',$ids)->find();
 
                     if($order['pay_type'] == 2){
@@ -515,16 +519,16 @@ class Order extends Backend
         $remark = '订单退款';
 
         if($order['pay_type'] == 3){
-            $order['pay_type'] == 'wechat';
+            $order['pay_type'] = 'wechat';
         }
         if($order['pay_type'] == 4){
-            $order['pay_type'] == 'alipay';
+            $order['pay_type'] = 'alipay';
         }
 
         // 生成退款单
         $refund_data = [
             'order_id' => $order['id'],
-            'out_refund_no'=> createUniqueNo('R',$order['id']),
+            'out_refund_no'=> createUniqueNo('R'),
             'pay_fee'  => $order['total_price'],
             'refund_price' => $refund_price,
             'pay_type' => $order['pay_type'],

+ 2 - 2
application/admin/view/unishop/order/edit.html

@@ -75,7 +75,7 @@
         </div>
     </div>-->
 
-    <div class="form-group">
+    <!--<div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Refund status')}:</label>
         <div class="col-xs-12 col-sm-8">
 
@@ -86,7 +86,7 @@
             </div>
 
         </div>
-    </div>
+    </div>-->
 
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Pay time')}:</label>

+ 1 - 2
application/admin/view/unishop/order/refund.html

@@ -57,7 +57,7 @@
             <div class="total-price">总共:{$item.price * $item.number} 元</div>
         </div>
         <div class="media-body">
-            <h4 class="media-heading">{$item.choose == 1?'参与售后':'不参与售后'}</h4>
+            <h4 class="media-heading"><!--{$item.choose == 1?'参与售后':'不参与售后'}--></h4>
         </div>
     </div>
     {/foreach}
@@ -134,7 +134,6 @@
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">
             <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
-            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
         </div>
     </div>
     <?php } ?>