Browse Source

复用brandlist、businesslist这两个接口

wufeng 2 years ago
parent
commit
d56c8813ae
2 changed files with 128 additions and 10 deletions
  1. 126 10
      app/abutment/controller/Index.php
  2. 2 0
      app/abutment/route/app.php

+ 126 - 10
app/abutment/controller/Index.php

@@ -38,7 +38,7 @@ class Index extends BaseController
         return IndexLogic::getCatList($param['keyword'], $param['pid']);
     }
 
-    //获取品牌列表
+    //获取品牌列表-api
     public function getBrandList()
     {
         $param = $this->request->filter('trim')->only(['keyword' => '', 'page' => 1, 'size' => 15], 'post');
@@ -50,6 +50,67 @@ class Index extends BaseController
         return IndexLogic::getBrandList($param['keyword'], $param['page'], $param['size']);
     }
 
+    //获取品牌列表-前端
+    public function brandList()
+    {
+        $this->post = $this->request->filter('trim')->post();
+
+        $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
+        $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
+        $where = [["b.is_del", "=", 0]];
+        $brand_name = isset($this->post['brand_name']) && $this->post['brand_name'] !== "" ? trim($this->post['brand_name']) : "";
+        if ($brand_name !== "") {
+            $where[] = ['b.brand_name', "like", "%$brand_name%"];
+        }
+        $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
+        if ($status !== "") {
+            $where[] = ['b.status', "=", $status];
+        }
+        $creater = isset($this->post['creater']) && $this->post['creater'] !== "" ? trim($this->post['creater']) : "";
+        if ($creater !== "") {
+            $where[] = ['b.creater', "like", "%$creater%"];
+        }
+        $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
+        if ($start !== "") {
+            $where[] = ['b.addtime', ">=", date('Y-m-d H:i:s', strtotime($start))];
+        }
+        $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
+        if ($end !== "") {
+            $where[] = ['b.addtime', "<", date('Y-m-d H:i:s', strtotime($end) + 24 * 3600)];
+        }
+        $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] != "" ? trim($this->post['supplierNo']) : "";
+        if ($supplierNo != "") {
+            $gyscode = Db::name("supplier")->where(["code" => $supplierNo])->find();
+            if (empty($gyscode)) {
+                return json_show(1004, "未找到供应商信息");
+            }
+            $wsmcode = Db::name("brand_book")->where(["gyscode" => $supplierNo, "is_del" => 0])->column("brand_id");
+            $where[] = ['b.id', "in", $wsmcode];
+        }
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["b.createrid", 'in', get_company_item_user_by_name($company_name)];
+
+        $count = Db::name('brand')
+            ->alias('b')
+            ->where($where)
+            ->count();
+        $total = ceil($count / $size);
+        $page = $page >= $total ? $total : $page;
+        $list = Db::name('brand')
+            ->alias('b')
+            ->field('b.*,u.itemid')
+            ->leftJoin("depart_user u", "u.uid=b.createrid AND u.is_del=0")
+            ->where($where)
+            ->append(['company_name'])
+            ->withAttr('company_name', function ($val, $data) {
+                return implode('/', array_column(GetPart($data['itemid']), 'name'));
+            })
+            ->page($page, $size)
+            ->order("addtime desc,id desc")
+            ->select();
+        return json_show(0, "获取成功", ['list' => $list, 'count' => $count]);
+    }
+
     //获取单位列表
     public function getUnitList()
     {
@@ -101,7 +162,7 @@ class Index extends BaseController
         return IndexLogic::getAreaList($param['level'], $param['pid_code']);
     }
 
-    //获取业务公司编码
+    //获取业务公司编码-api
     public function getCompanyNoList()
     {
         $param = $this->request->filter('trim')->only(['keyword' => ''], 'post');
@@ -113,24 +174,79 @@ class Index extends BaseController
         return IndexLogic::getCompanyNoList($param['keyword']);
     }
 
+    //获取业务公司编码-前端
+    public function businessList()
+    {
+        $this->post = $this->request->filter('trim')->post();
+        $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
+        $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
+        $where = [["b.is_del", "=", 0]];
+        $company = isset($this->post['company']) && $this->post['company'] !== "" ? trim($this->post['company']) : "";
+        if ($company !== "") {
+            $where[] = ['b.company', "like", "%$company%"];
+        }
+        $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
+        if ($status !== "") {
+            $where[] = ['b.status', "=", $status];
+        }
+        $creater = isset($this->post['creater']) && $this->post['creater'] !== "" ? trim($this->post['creater']) : "";
+        if ($creater !== "") {
+            $where[] = ['b.creater', "like", "%$creater%"];
+        }
+        $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
+        if ($start !== "") {
+            $where[] = ['b.addtime', ">=", date('Y-m-d H:i:s', strtotime($start))];
+        }
+        $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
+        if ($end !== "") {
+            $where[] = ['b.addtime', "<", date('Y-m-d H:i:s', strtotime($end) + 24 * 3600)];
+        }
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["b.createrid", 'in', get_company_item_user_by_name($company_name)];
+
+
+        $count = Db::name('business')
+            ->alias('b')
+            ->where($where)
+            ->count();
+        $total = ceil($count / $size);
+        $page = $page >= $total ? $total : $page;
+        $list = Db::name('business')
+            ->alias('b')
+            ->where($where)
+            ->page($page, $size)
+            ->field("b.id,b.company,b.companyNo,b.status,b.creater,b.addtime,b.type,u.itemid")
+            ->leftJoin("depart_user u", "u.uid=b.createrid AND u.is_del=0")
+            ->order("addtime desc")
+            ->append(['company_name'])
+            ->withAttr('company_name', function ($val, $data) {
+                return implode('/', array_column(GetPart($data['itemid']), 'name'));
+            })
+            ->select()
+            ->toArray();
+
+        return json_show(0, "获取成功", ['list' => $list, 'count' => $count]);
+    }
+
     //专属类型列表
-    public function getExclusiveList(){
+    public function getExclusiveList()
+    {
 
-        $pid =  $this->request->filter('trim')->post('pid/d',0);
-        $where=[["is_del","=",0],["pid","=",$pid]];
+        $pid = $this->request->filter('trim')->post('pid/d', 0);
+        $where = [["is_del", "=", 0], ["pid", "=", $pid]];
 
-        $cat_name=$this->request->filter('trim')->post('cat_name','');
-        if($cat_name!=="") $where[]=['cat_name',"like","%$cat_name%"];
+        $cat_name = $this->request->filter('trim')->post('cat_name', '');
+        if ($cat_name !== "") $where[] = ['cat_name', "like", "%$cat_name%"];
 
         $data = Db::name("exclusive")
             ->where($where)
             ->select()
             ->toArray();
         $vmp = [];
-        foreach ($data as $sts){
-            $vmp[]=coco($sts);
+        foreach ($data as $sts) {
+            $vmp[] = coco($sts);
         }
-        return json_show(0,"获取成功",$vmp);
+        return json_show(0, "获取成功", $vmp);
     }
 
 

+ 2 - 0
app/abutment/route/app.php

@@ -11,11 +11,13 @@ route::rule('getUserInfo', 'abutment/Account/getUserInfo');//供应商登录
 route::rule('getPlatformList', 'abutment/Index/getPlatformList');//推广平台列表
 route::rule('getCatList', 'abutment/Index/getCatList');//获取分类列表
 route::rule('getBrandList', 'abutment/Index/getBrandList');//获取品牌列表
+route::rule('brandList', 'abutment/Index/brandList');//获取品牌列表-前端
 route::rule('getUnitList', 'abutment/Index/getUnitList');//获取单位列表
 route::rule('getSpecsTitleList', 'abutment/Index/getSpecsTitleList');//获取规格类型列表
 route::rule('getSpecsValueByTitleList', 'abutment/Index/getSpecsValueByTitleList');//获取规格值列表
 route::rule('getAreaList', 'abutment/Index/getAreaList');//获取省市区列表
 route::rule('getCompanyNoList', 'abutment/Index/getCompanyNoList');//获取业务公司编码
+route::rule('businessList', 'abutment/Index/businessList');//获取业务公司编码-前端
 route::rule('getExclusiveList', 'abutment/Index/getExclusiveList');//专属类型列表