xieruidong 2 years ago
parent
commit
ea49dc5ce3
3 changed files with 27 additions and 1 deletions
  1. 12 0
      application/api/controller/mall/Orders.php
  2. 4 0
      application/common/model/Orders.php
  3. 11 1
      public/api.html

+ 12 - 0
application/api/controller/mall/Orders.php

@@ -8,6 +8,7 @@ use app\common\model\OrderVoucher;
 use app\common\model\Refund;
 use app\common\service\OrderService;
 use app\common\validate\TaxValidate;
+use think\Cache;
 use think\Db;
 use app\common\model\Orders as Order;
 
@@ -149,6 +150,7 @@ class Orders extends Api
             'id'=>['require'],
         ]);
         $user=$this->auth->getUser();
+        Cache::remember("user_order_show_{$user['id']}",time(),86400);
         $this->success('',$this->orderDetail($data['id']));
     }
     protected function orderDetail($orderId){
@@ -237,6 +239,7 @@ class Orders extends Api
      * @ApiParams (name=reason1,description=配置里的reason里的key)
      * @ApiParams (name=reason2,description=原因2)
      * @ApiParams (name=amount,description=金额)
+     * @ApiParams (name=fix_order_no,description=维修订单号,在拍维修费时需要)
      */
     public function refund(){
         $data=$this->_validate([
@@ -273,6 +276,15 @@ class Orders extends Api
                 'amount|金额'=>['require','float','gt:0',"elt:{$orderInfo['amount_pay']}"],
             ]);
         }
+        if($config['req_order']){
+            $this->_validate([
+                'fix_order_no|维修订单号'=>['require',],
+            ]);
+            $fixOrder=Order::statusPay()->where('order_no',$data['fix_order_no'])->where('pay_time',Cache::get("user_order_show_{$user['id']}",null))->find();
+            if(!$fixOrder){
+                $this->error('请完成维修订单支付');
+            }
+        }
         if($data['refund_type']==Refund::REFUND_TYPE_ALL){
             $refundCount=$orderInfo->refunds()->where('refund_type',Refund::REFUND_TYPE_ALL)->count();
             if($refundCount>=3){

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

@@ -24,6 +24,7 @@ use Yansongda\Supports\Arr;
  * @property float amount_cmn
  * @property float amount_pay
  * @method static static payed()
+ * @method static static statusPay()
  * @method Query hasGoods($goods_id)
  */
 class Orders extends Model
@@ -304,6 +305,9 @@ class Orders extends Model
     public function scopePayed(Query $query){
         $query->whereNotIn('status',[self::S_CANCEL,self::S_WAIT_PAY]);
     }
+    public function scopeStatusPay(Query $query){
+        $query->whereNotIn('status',self::S_WAIT_SEND);
+    }
     public function scopeHasGoods(Query $query,$goods_id){
         $query->whereExists(
             OrderInfo::whereRaw("orders.id=order_info.order_id and order_info.goods_id={$goods_id}")->buildSql()

+ 11 - 1
public/api.html

@@ -10061,6 +10061,12 @@
                                                         <td>是</td>
                                                         <td>金额</td>
                                                     </tr>
+                                                                                                        <tr>
+                                                        <td>fix_order_no</td>
+                                                        <td>string</td>
+                                                        <td>是</td>
+                                                        <td>维修订单号,在拍维修费时需要</td>
+                                                    </tr>
                                                                                                     </tbody>
                                             </table>
                                                                                     </div>
@@ -10111,6 +10117,10 @@
                                                             <label class="control-label" for="amount">amount</label>
                                                             <input type="string" class="form-control input-sm" id="amount" required placeholder="金额" name="amount">
                                                         </div>
+                                                                                                                <div class="form-group">
+                                                            <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 form-group-submit">
                                                             <button type="submit" class="btn btn-success send" rel="46">提交</button>
                                                             <button type="reset" class="btn btn-info" rel="46">重置</button>
@@ -16449,7 +16459,7 @@
 
                 </div>
                 <div class="col-md-6" align="right">
-                    Generated on 2022-11-04 13:11:39 <a href="./" target="_blank">苏州屏酷有限公司</a>
+                    Generated on 2022-11-04 13:44:00 <a href="./" target="_blank">苏州屏酷有限公司</a>
                 </div>
             </div>