diff --git a/app/common/dao/store/product/ProductDao.php b/app/common/dao/store/product/ProductDao.php index a90a7233..34f53869 100644 --- a/app/common/dao/store/product/ProductDao.php +++ b/app/common/dao/store/product/ProductDao.php @@ -413,6 +413,24 @@ class ProductDao extends BaseDao ]; } + /** + * TODO api展示的商品条件 + * @return array + * @author Qinii + * @day 2020-08-18 + */ + public function productTypeShow($type=98) + { + return [ + 'is_show' => 1, + 'status' => 1, + 'is_used' => 1, + 'product_type' => $type, + 'mer_status' => 1, + 'is_gift_bag' => 0, + ]; + } + /** * TODO api展示的礼包商品条件 * @return array diff --git a/app/common/model/system/merchant/Merchant.php b/app/common/model/system/merchant/Merchant.php index 2aada263..7cbd2eda 100644 --- a/app/common/model/system/merchant/Merchant.php +++ b/app/common/model/system/merchant/Merchant.php @@ -82,7 +82,7 @@ class Merchant extends BaseModel { $list = Product::where('mer_id', $this['mer_id']) ->where((new ProductDao())->productShow()) - ->field('mer_id,product_id,store_name,image,price,is_show,status,is_gift_bag,is_good,cate_id') + ->field('mer_id,product_id,product_type,store_name,image,price,is_show,status,is_gift_bag,is_good,cate_id') ->order('sort DESC, create_time DESC') ->limit(10) ->select()->append(['show_svip_info']); @@ -90,7 +90,30 @@ class Merchant extends BaseModel $data = []; $make = app()->make(StoreActivityRepository::class); foreach ($list as $item) { - $spu_id = Spu::where('product_id',$item->product_id)->where('product_type' ,0)->value('spu_id'); + halt(1); + $spu_id = Spu::where('product_id',$item->product_id)->where('product_type' ,$item->product_type)->value('spu_id'); + $act = $make->getActivityBySpu(StoreActivityRepository::ACTIVITY_TYPE_BORDER,$spu_id,$item['cate_id'],$item['mer_id']); + $item['border_pic'] = $act['pic'] ?? ''; + $data[] = $item; + } + return $data; + } + return []; + } + + public function getAllRecommendTypeAttr() + { + $list = Product::where('mer_id', $this['mer_id']) + ->where((new ProductDao())->productTypeShow(98)) + ->field('mer_id,product_id,product_type,store_name,image,price,is_show,status,is_gift_bag,is_good,cate_id') + ->order('sort DESC, create_time DESC') + ->limit(10) + ->select()->append(['show_svip_info']); + if ($list) { + $data = []; + $make = app()->make(StoreActivityRepository::class); + foreach ($list as $item) { + $spu_id = Spu::where('product_id',$item->product_id)->where('product_type' ,$item->product_type)->value('spu_id'); $act = $make->getActivityBySpu(StoreActivityRepository::ACTIVITY_TYPE_BORDER,$spu_id,$item['cate_id'],$item['mer_id']); $item['border_pic'] = $act['pic'] ?? ''; $data[] = $item; diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index 5decc4f4..a087a4af 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -311,7 +311,9 @@ class MerchantRepository extends BaseRepository } $item['distance'] = $distance; } - $item['recommend'] = isset($where['delivery_way']) ? $item['CityRecommend'] : $item['AllRecommend']; + if(isset($where['type_id'])){ + $item['recommend'] = $item['AllRecommendType']; + } return $item; });