xieruidong 2 年之前
父节点
当前提交
c536c7cf15
共有 4 个文件被更改,包括 37 次插入21 次删除
  1. 21 17
      application/api/controller/mall/Orders.php
  2. 0 3
      application/common/model/Orders.php
  3. 5 0
      application/common/model/Refund.php
  4. 11 1
      public/api.html

+ 21 - 17
application/api/controller/mall/Orders.php

@@ -261,8 +261,10 @@ class Orders extends Api
      * @ApiParams (name=reason2,description=原因2)
      * @ApiParams (name=amount,description=金额)
      * @ApiParams (name=fix_order_no,description=维修订单号,在拍维修费时需要)
+     * @ApiParams (name=is_edit,description="是1否0修改售后信息")
      */
     public function refund(){
+        $save=[];
         $data=$this->_validate([
             'order_info_id|订单'=>['require','integer','gt:0'],
         ]);
@@ -276,35 +278,37 @@ class Orders extends Api
         }
         $order->allowRefund();
         $refund=$orderInfo->refund;
-        if($refund && $refund['refund_status']==$refund::REFUND_ING){
-            Db::rollback();
-            $this->error('您已提交,不能再次提交');
+        if(!empty($data['is_edit'])) {
+            if(!$refund){
+                Db::rollback();
+                $this->error('未找到售后信息无法修改');
+            }
+            if ($refund && !$refund->allowEdit()) {
+                Db::rollback();
+                $this->error('该售后无法修改');
+            }
         }
-        $config=Refund::makeRefundConfig($orderInfo,false,false);
+        $config=Refund::makeRefundConfig($orderInfo,false);
         if(empty($config)){
             Db::rollback();
             $this->error('该订单无法满足售后条件');
         }
         $this->_validate([
-            'refund_type|售后方式'=>['require','in:'.implode(',',array_filter(array_keys($config['refund_type'])))],
-            //'num|数量'=>['require','integer','gt:0',"elt:{$orderInfo['num']}"],
-            'refund_by|退货方式'=>['require','integer','egt:0','in:'.implode(',',array_keys($config['type']))],
+            'refund_type|售后方式'=>['require','in:'.implode(',',array_keys($config['refund_type']))],
             'reason1|退款退货原因'=>['require','integer','egt:0','in:'.implode(',',array_keys($config['reason']))],
             'reason2|原因'=>['require','max:100'],
+            'num|数量'=>['require','integer','gt:0',"elt:{$orderInfo['num']}"],
+            'num_install|安装数量'=>['require','integer','egt:0',"elt:{$orderInfo['num']}"],
         ]);
-        if($config['req_amount']){
-            /*$this->_validate([
-                'amount|金额'=>['require','float','gt:0',"elt:{$orderInfo['amount_pay']}"],
-            ]);*/
-            $data['amount']=RefundService::setOrderInfo($orderInfo,$orderInfo['num'],$orderInfo['num_install'])->amount(true);
-            $data['num']=$config['num'];
-            $data['num_install']=$config['num_install'];
-        }else{
-            $data['amount']=0;
+        if(!empty($config['type'])) {
             $this->_validate([
-                'num_install|安装数量'=>['require','integer','gt:0',"elt:{$orderInfo['num_install']}"],
+                'refund_by|退货方式' => ['require', 'integer', 'in:' . implode(',', array_keys($config['type'][$data['refund_type']]))],
             ]);
         }
+        if($config['refund_type']==Refund::REFUND_TYPE_HHBX){
+            $save['amount']=0;
+            $save['amount_install']=0;
+        }
         $fix_order_id=0;
         if($config['req_order']){
             $this->_validate([

+ 0 - 3
application/common/model/Orders.php

@@ -305,9 +305,6 @@ class Orders extends Model
         ])){
             throw_user('订单状态不允许售后');
         }
-        /*if($this['status']==self::S_OVER && time()>$this['rec_time']+self::EXP_REC){
-            throw_user('已过售后期');
-        }*/
     }
     /**
      * 是否允许取消

+ 5 - 0
application/common/model/Refund.php

@@ -98,6 +98,11 @@ class Refund Extends Model
             self::REFUND_CANCEL,
         ]);
     }
+    public function allowEdit(){
+        return in_array($this->refund_status,[
+            self::REFUND_ING,
+        ]);
+    }
     public function makeCancel(){
         $this['refund_status']=self::REFUND_CANCEL;
         $this->save();

+ 11 - 1
public/api.html

@@ -11772,6 +11772,12 @@
                                                         <td>是</td>
                                                         <td>维修订单号,在拍维修费时需要</td>
                                                     </tr>
+                                                                                                        <tr>
+                                                        <td>is_edit</td>
+                                                        <td>string</td>
+                                                        <td>是</td>
+                                                        <td>是1否0修改售后信息</td>
+                                                    </tr>
                                                                                                     </tbody>
                                             </table>
                                                                                     </div>
@@ -11830,6 +11836,10 @@
                                                             <label class="control-label" for="fix_order_no">fix_order_no</label>
                                                             <input type="string" class="form-control input-sm" id="fix_order_no" required placeholder="维修订单号,在拍维修费时需要" name="fix_order_no">
                                                         </div>
+                                                                                                                <div class="form-group">
+                                                            <label class="control-label" for="is_edit">is_edit</label>
+                                                            <input type="string" class="form-control input-sm" id="is_edit" required placeholder="是1否0修改售后信息" name="is_edit">
+                                                        </div>
                                                                                                                 <div class="form-group form-group-submit">
                                                             <button type="submit" class="btn btn-success send" rel="50">提交</button>
                                                             <button type="reset" class="btn btn-info" rel="50">重置</button>
@@ -19015,7 +19025,7 @@
 
                 </div>
                 <div class="col-md-6" align="right">
-                    Generated on 2022-12-08 19:11:37 <a href="./" target="_blank">苏州屏酷有限公司</a>
+                    Generated on 2022-12-10 11:46:04 <a href="./" target="_blank">苏州屏酷有限公司</a>
                 </div>
             </div>