浏览代码

优化接口

huangsanjia 1 年之前
父节点
当前提交
8ebff8d5d3
共有 1 个文件被更改,包括 8 次插入5 次删除
  1. 8 5
      application/api/controller/Product.php

+ 8 - 5
application/api/controller/Product.php

@@ -2,10 +2,10 @@
 
 namespace app\api\controller;
 
-use app\admin\model\EntrustLog;
 use app\common\controller\Api;
 use \think\Request;
 use \think\Db;
+use think\Cache;
 /**
  * 产品管理接口
  */
@@ -668,7 +668,8 @@ class Product extends Api
                 LEFT JOIN `物料_存货结构` b ON LEFT(a.物料代码,$num-2) = b.编号
                 LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,$num) = c.编号
                 LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,$num+2) = d.编号
-                WHERE a.物料名称 LIKE '%{$search}%' or a.物料代码 LIKE '%{$search}%'";
+                WHERE (a.物料名称 LIKE '%{$search}%' or a.物料代码 LIKE '%{$search}%') and (a.物料代码 LIKE 'Y00%' or a.物料代码 LIKE 'Y01%' or a.物料代码 LIKE 'Y04%' or a.物料代码 LIKE 'J03%')";
+            $data = Db::query($sql);
         }else{
             $sql = "SELECT rtrim(a.`物料代码`) as 物料代码,rtrim(a.`物料名称`) as 物料名称,rtrim(a.`规格`) as 规格,rtrim(b.编号) as oneCode,rtrim(b.名称) as oneName,
                 rtrim(c.`编号`) as twoCode,rtrim(c.`名称`) as twoName,rtrim(d.`编号`) as thrCode,rtrim(d.`名称`) as thrName
@@ -676,10 +677,9 @@ class Product extends Api
                 LEFT JOIN `物料_存货结构` b ON LEFT(a.物料代码,$num-2) = b.编号
                 LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,$num) = c.编号
                 LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,$num+2) = d.编号
-               ";
+                WHERE a.物料代码 LIKE 'Y00%' or a.物料代码 LIKE 'Y01%' or a.物料代码 LIKE 'Y04%' or a.物料代码 LIKE 'J03%'";
+            $data = Db::query($sql);
         }
-
-        $data = Db::query($sql);
         $mergedArray = [];
         foreach ($data as $item) {
             $oneCode = $item['oneCode'];
@@ -790,6 +790,9 @@ class Product extends Api
             ->join('产品_工艺资料 b','a.YB_cpdh = b.Gy0_cpdh and a.YB_Yjno = b.Gy0_yjno and a.YB_gxh = b.Gy0_gxh','left')
             ->join('物料_存货编码 c','a.存货编码 = c.物料代码','left')
             ->where('a.UniqID',$params['UniqID'])->field($field)->order('存货编码')->find();
+        if (empty($data)){
+            $this->error('未查询到产品印版资料');
+        }
         $where['Gy0_site'] = [
             ['like','胶印%'],
             ['like','烫模%'],