afa 5 months ago
parent
commit
b2cac359ea

+ 2 - 1
app/admin/controller/shop/ShopDelivery.php

@@ -6,6 +6,7 @@ namespace app\admin\controller\shop;
 use app\common\controller\Backend;
 use think\annotation\route\Group;
 use app\admin\traits\Actions;
+use think\annotation\route\Route;
 use app\common\model\ShopDelivery as ShopDeliveryModel;
 
 #[Group("shop/shop_delivery")]
@@ -17,7 +18,7 @@ class ShopDelivery extends Backend
     {
         parent::_initialize();
         $this->model = new ShopDeliveryModel();
+            $this->relationField=['customer','user'];
     }
 
-
 }

+ 2 - 2
app/admin/controller/shop/ShopList.php

@@ -11,7 +11,7 @@ use app\common\model\Customer;
 use app\common\model\User;
 use app\common\model\StockConfig;
 use app\common\model\CustomerSpec;
-use app\common\service\SpecService;
+use app\api\service\SpecService;
 use app\common\model\ShopList as ShopListModel;
 
 #[Group("shop/shop_list")]
@@ -20,7 +20,7 @@ class ShopList extends Backend
     use Actions{
         add as protected _add;
         edit as protected _edit;
-     }
+    }
 
     protected function _initialize()
     {

+ 2 - 2
app/admin/view/shop/shop_delivery/index.html

@@ -26,8 +26,8 @@
             columns:[
                 {checkbox: true},
                 {field: 'id',title: __('ID'),width:80,sortable: true},
-                {field: 'user_id', title: __('录入人'),operate: 'LIKE'},
-                {field: 'customer_id',title: __('客户'),operate:'LIKE'},
+                {field: 'user.nickname', title: __('录入人'),operate: 'LIKE'},
+                {field: 'customer.name',title: __('客户'),operate:'LIKE'},
                 {field: 'shop_id',title: __('店铺'),operate:'LIKE'},
                 {field: 'plat_id',title: __('平台'),operate: false, searchList: Yunqi.data.platformList},
                 {field: 'variety_id', title: __('品种'),operate: false},

+ 6 - 7
app/api/controller/Shops.php

@@ -29,15 +29,14 @@ class Shops extends Base
         $spec_id = $this->request->post('spec_id/d', 0); //规格
         $customer = $this->request->post('customer_name/s', ''); //客户
         $num  = $this->request->post('num/d', 0); //数量
-
         $limit = $this->request->post('limit/d', 15); //条数
         $where['a.user_id'] = $this->userinfo['id'];
-        if($plat_id  > 0) $where['a.plat_id']   = $plat_id;
-        if($shop_id  > 0) $where['a.shop_id']   = $shop_id;
-        if($variety_id  > 0) $where['a.variety_id']= $variety_id;
-        if($spec_id  > 0) $where['a.spec_id']   = $spec_id;
-        if(!empty($customer)) $where['customer_name']   = ['like', '%'.$customer.'%'];
-        if($num  > 0)      $where['a.num']= $num;
+        if($plat_id  > 0) $where[]      = ['a.plat_id','=', $plat_id]; //'a.plat_id'
+        if($shop_id  > 0) $where[]      = ['a.shop_id','=', $shop_id]; //'a.shop_id'
+        if($variety_id  > 0) $where[]   = ['a.variety_id','=', $variety_id]; //'a.variety_id'
+        if($spec_id  > 0) $where[]      = ['a.spec_id','=', $spec_id]; //'a.spec_id'
+        if(!empty($customer)) $where[]   = ['u.name','like', "%{$customer}%"];
+        if($num  > 0)      $where[]      = ['a.num','=', $num]; //'a.num'
 
         $result = $shopDelivery::alias('a')
                 ->leftjoin('shop_list b', 'a.shop_id = b.id') //店铺

+ 37 - 0
app/common/model/ShopDelivery.php

@@ -23,4 +23,41 @@ class ShopDelivery Extends Model
         $data->weigh=1000-$data->id;
         $data->save();
     }
+
+
+    public function user()
+    {
+        return $this->hasOne(User::class,'id','user_id')->field('id,nickname');
+    }
+
+
+    public function customer()
+    {
+        return $this->hasOne(Customer::class,'id','customer_id')->field('id,name');
+    }
+
+
+    
+    public function shops()
+    {
+        return $this->hasOne(ShopList::class,'id','shop_id')->field('id,name');
+    }
+
+
+    
+    public function variety()
+    {
+        return $this->hasOne(Customer::class,'id','variety_id')->field('id,name');
+    }
+
+
+
+    
+    public function specs()
+    {
+        return $this->hasOne(Customer::class,'id','spec_id')->field('id,name');
+    }
+
+    
+    
 }