ソースを参照

重置订单优惠券

whitefang 1 年間 前
コミット
03717aeb8d

+ 17 - 1
app/api/logic/ServiceOrderLogic.php

@@ -273,7 +273,23 @@ class ServiceOrderLogic extends BaseLogic
     {
         Db::startTrans();
         try {
-            $order = \app\common\model\recharge\RechargeOrder::where('id',$params['order_id'])->findOrEmpty();
+            $order = \app\common\model\recharge\RechargeOrder::where('sn',$params['sn'])->findOrEmpty();
+            if ($order->isEmpty()) {
+                throw new Exception('订单不存在');
+            }
+            //判断订单类型.服务订单尾款处理
+            if($order['order_type'] == 0 and $order['pay_status'] == PayEnum::ISPAID)//服务工单
+            {
+                $order = RechargeOrder::where(['work_id'=>$order['work_id'],'pay_status'=>0])->findOrEmpty();
+                if($order->isEmpty()){
+                    throw new Exception('订单已支付');
+                }
+            }
+
+            if ($order['pay_status'] == PayEnum::ISPAID) {
+                throw new Exception('订单已支付');
+            }
+
             if(!empty($order['coupon_id'])){
                 $user_coupon_ed = UserCoupon::findOrEmpty($order['coupon_id']);
                 $user_coupon_ed->voucher_count = $user_coupon_ed->voucher_count+1;

+ 1 - 1
app/api/validate/ServiceOrderValidate.php

@@ -92,6 +92,6 @@ class ServiceOrderValidate extends BaseValidate
 
     public function sceneCancelOrderCoupon()
     {
-        return $this->only(['order_id']);
+        return $this->only(['sn']);
     }
 }