xieruidong 2 years ago
parent
commit
6322ae5ebd

+ 1 - 1
application/admin/controller/Orders.php

@@ -59,7 +59,7 @@ class Orders extends Backend
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
 
             $list = $this->model
-                ->with(['user','logistics'])
+                ->with(['user','logistics','voucher'])
                     ->where($where)
                 ->where(function (Query $query){
                     if($this->admin('is_seller')){

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

@@ -16,4 +16,8 @@ class Orders extends \app\common\model\Orders
         $one->joinType('left');
         return $one;
     }
+    public function voucher()
+    {
+        return $this->belongsTo(OrderVoucher::class,'order_voucher_id','id',[],'left');
+    }
 }

+ 2 - 1
application/common/model/GoodsSku.php

@@ -31,7 +31,8 @@ class GoodsSku Extends Model
         return $this->hasMany(GoodsBind::class);
     }
     public static function show(){
-        return self::where('is_del',0);
+        //return self::where('is_del',0);
+        return new self;
     }
     public function goods(){
         return $this->belongsTo(Goods::class);

+ 1 - 1
application/common/model/Orders.php

@@ -99,7 +99,7 @@ class Orders extends Model
         return $this->hasOne(OrderLogistics::class,'order_id');
     }
     public function voucher(){
-        return $this->hasOne(OrderVoucher::class,'order_id');
+        return $this->hasMany(OrderVoucher::class,'order_id');
     }
     /*public function getGoodsAttr(){
         $info=$this->info()->with(['goodsBak'])->find();

+ 6 - 1
public/assets/js/backend/orders.js

@@ -29,7 +29,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
                         {field: 'order_no', title: __('Order_no')},
-                        {field: 'status', title: __('Status'),formatter: Table.api.formatter.label,searchList:status},
+                        {field: 'status', title: __('Status'),formatter(status,order,index){
+                            if(status===0 && order.voucher && voucher.status===0){
+
+                            }
+                            return Table.api.formatter.label.call(this,status,order,index)
+                        },searchList:status},
                         {field: 'user.nickname', title: __('下单用户')},
                         {field: 'amount_total', title: __('Amount_total'), operate:'BETWEEN'},
                         {field: 'amount_pay', title: __('Amount_pay'), operate:'BETWEEN'},