|  | @@ -13,6 +13,7 @@ use app\common\model\AttributeValue;
 | 
											
												
													
														|  |  // use app\common\model\UserCoupon;
 |  |  // use app\common\model\UserCoupon;
 | 
											
												
													
														|  |  use fast\Http;
 |  |  use fast\Http;
 | 
											
												
													
														|  |  use think\Log;
 |  |  use think\Log;
 | 
											
												
													
														|  | 
 |  | +use think\Db;
 | 
											
												
													
														|  |  use app\common\Service\SkuSpec as SkuSpecService;
 |  |  use app\common\Service\SkuSpec as SkuSpecService;
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * 商品接口
 |  |   * 商品接口
 | 
											
										
											
												
													
														|  | @@ -146,16 +147,16 @@ class Goods extends Base
 | 
											
												
													
														|  |      public function lists()
 |  |      public function lists()
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          $param = $this->request->param();
 |  |          $param = $this->request->param();
 | 
											
												
													
														|  | -        $pageNum = (int)$this->request->param('pageNum', 10);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        $pageSize = (int)$this->request->param('pageSize', 10);
 | 
											
												
													
														|  |          $orderby = $this->request->param('orderby', 'weigh');
 |  |          $orderby = $this->request->param('orderby', 'weigh');
 | 
											
												
													
														|  |          $orderway = $this->request->param('orderway', 'desc');
 |  |          $orderway = $this->request->param('orderway', 'desc');
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          $list = GoodsModel::where(function ($query) use ($param) {
 |  |          $list = GoodsModel::where(function ($query) use ($param) {
 | 
											
												
													
														|  |              $query->where('status',GoodsEnum::STATUS_ON_SALE);
 |  |              $query->where('status',GoodsEnum::STATUS_ON_SALE);
 | 
											
												
													
														|  |              //关键词
 |  |              //关键词
 | 
											
												
													
														|  | -            if (isset($param['keyword']) && !empty($param['keyword'])) {
 |  | 
 | 
											
												
													
														|  | -                $query->where('title|keywords', 'like', '%' . $param['keyword'] . '%');
 |  | 
 | 
											
												
													
														|  | -                $log = \app\common\model\SearchLog::getByKeywords($param['keyword']);
 |  | 
 | 
											
												
													
														|  | 
 |  | +            if (isset($param['keywords']) && !empty($param['keywords'])) {
 | 
											
												
													
														|  | 
 |  | +                $query->where('title|keywords', 'like', '%' . $param['keywords'] . '%');
 | 
											
												
													
														|  | 
 |  | +                $log = \app\common\model\SearchLog::getByKeywords($param['keywords']);
 | 
											
												
													
														|  |                  if ($log) {
 |  |                  if ($log) {
 | 
											
												
													
														|  |                      $log->setInc("nums");
 |  |                      $log->setInc("nums");
 | 
											
												
													
														|  |                  } else {
 |  |                  } else {
 | 
											
										
											
												
													
														|  | @@ -165,11 +166,13 @@ class Goods extends Base
 | 
											
												
													
														|  |              //分类
 |  |              //分类
 | 
											
												
													
														|  |              if (isset($param['category_id']) && !empty($param['category_id'])) {
 |  |              if (isset($param['category_id']) && !empty($param['category_id'])) {
 | 
											
												
													
														|  |                  $categoryIds = \app\common\model\Category::getCategoryChildrenIds($param['category_id']);
 |  |                  $categoryIds = \app\common\model\Category::getCategoryChildrenIds($param['category_id']);
 | 
											
												
													
														|  | -                $query->where(function($q) use ($categoryIds) {
 |  | 
 | 
											
												
													
														|  | -                    foreach ($categoryIds as $categoryId) {
 |  | 
 | 
											
												
													
														|  | -                        $q->whereOr('category_ids', 'exp', "FIND_IN_SET('{$categoryId}', category_ids)");
 |  | 
 | 
											
												
													
														|  | -                    }
 |  | 
 | 
											
												
													
														|  | -                });
 |  | 
 | 
											
												
													
														|  | 
 |  | +                $conditions = [];
 | 
											
												
													
														|  | 
 |  | +                foreach ($categoryIds as $categoryId) {
 | 
											
												
													
														|  | 
 |  | +                    $conditions[] = "FIND_IN_SET('{$categoryId}', `category_ids`)";
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +                if (!empty($conditions)) {
 | 
											
												
													
														|  | 
 |  | +                    $query->whereRaw('(' . implode(' OR ', $conditions) . ')');
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              //属性
 |  |              //属性
 | 
											
												
													
														|  |              if (isset($param['attributes']) && !empty($param['attributes'])) {
 |  |              if (isset($param['attributes']) && !empty($param['attributes'])) {
 | 
											
										
											
												
													
														|  | @@ -192,7 +195,7 @@ class Goods extends Base
 | 
											
												
													
														|  |                      $query->where('price', 'BETWEEN', $priceArr);
 |  |                      $query->where('price', 'BETWEEN', $priceArr);
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  | -        })->order("{$orderby} {$orderway}")->paginate($pageNum);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        })->order("{$orderby} {$orderway}")->paginate($pageSize);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          foreach ($list as $item) {
 |  |          foreach ($list as $item) {
 | 
											
												
													
														|  |              $item->visible(explode(',', 'id,title,image,price,sales,views,description,marketprice,createtime'));
 |  |              $item->visible(explode(',', 'id,title,image,price,sales,views,description,marketprice,createtime'));
 |