This commit is contained in:
shengchanzhe 2023-12-23 18:20:23 +08:00
parent eedcccff1c
commit 8846b6b4a8

View File

@ -30,7 +30,7 @@ class CloudWarehouse extends BaseController
* @param SpuRepository $repository * @param SpuRepository $repository
* @param MerchantDao $merchantDao * @param MerchantDao $merchantDao
*/ */
public function __construct(App $app, MerchantDao $merchantDao, SpuRepository $spuRepository,SpuDao $SpuDao) public function __construct(App $app, MerchantDao $merchantDao, SpuRepository $spuRepository, SpuDao $SpuDao)
{ {
parent::__construct($app); parent::__construct($app);
$this->merchantDao = $merchantDao; $this->merchantDao = $merchantDao;
@ -43,28 +43,43 @@ class CloudWarehouse extends BaseController
* type_id 13云仓商品列表 * type_id 13云仓商品列表
* @return mixed * @return mixed
*/ */
public function index($street_code, $page = 1, $category_id = 0,$location='') public function index($street_code, $page = 1, $category_id = 0, $location = '')
{ {
$cloud_product = Db::name('cloud_product') $cloud_product_arr = Db::name('cloud_product')
->where('cate_id',$category_id) ->where('cate_id', $category_id)
->where('street_code', $street_code)->where('status', 1)->page($page)->column('product_id'); ->whereOR('street_code', $street_code)->whereOR('mer_labels', ',6,')->where('status', 1)->page($page)->field('product_id,mer_labels')->select();
$cloud_product = [];
foreach ($cloud_product_arr as $key => $value) {
$cloud_product[] = $value['product_id'];
}
$where = [ $where = [
'is_show' => 1, 'is_show' => 1,
'is_used' => 1, 'is_used' => 1,
'status' => 1, 'status' => 1,
'is_del' => 0, 'is_del' => 0,
'mer_status' => 1, 'mer_status' => 1,
'product_type'=>98, 'product_type' => 98,
'product_id'=>$cloud_product 'product_id' => $cloud_product
]; ];
if (!$cloud_product && $category_id==0) { if (!$cloud_product && $category_id == 0) {
return app('json')->success(['count' => 0, 'list' => []]); return app('json')->success(['count' => 0, 'list' => []]);
} }
$count = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->count(); $count = Db::name('cloud_product')->whereOR('street_code', $street_code)->whereOR('mer_labels', ',6,')->where('status', 1)->count();
$products = $this->spuRepository->getApiSearch($where,$page,10, false,true); $products = $this->spuRepository->getApiSearch($where, $page, 10, false, true);
if($products['list']){ if ($products['list']) {
$list=$products['list']; $list = $products['list'];
foreach ($cloud_product_arr as $key => $value) {
foreach ($list as $k => $v) {
if ($value['product_id'] == $v['product_id']) {
if ($value['mer_labels'] == ',6,') {
$list[$k]['mer_labels_name'] = '五日达';
} else {
$list[$k]['mer_labels_name'] = '次日达';
}
}
}
}
} }
return app('json')->success(['count' => $count, 'list' => $list]); return app('json')->success(['count' => $count, 'list' => $list]);
} }
@ -75,10 +90,10 @@ class CloudWarehouse extends BaseController
*/ */
public function town() public function town()
{ {
$params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page','cate_pid']); $params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page', 'cate_pid']);
$search = [ $search = [
'street_id' => $params['street_code'], 'street_id' => $params['street_code'],
'type_id' =>[Merchant::TypeStore,Merchant::TypeTownSupplyChain], 'type_id' => [Merchant::TypeStore, Merchant::TypeTownSupplyChain],
'status' => 1, 'status' => 1,
'is_del' => 0, 'is_del' => 0,
'mer_state' => 1, 'mer_state' => 1,
@ -101,10 +116,10 @@ class CloudWarehouse extends BaseController
if (!empty($params['category_id'])) { if (!empty($params['category_id'])) {
$where['cate_id'] = $params['category_id']; $where['cate_id'] = $params['category_id'];
} }
if($params['cate_pid']!=''){ if ($params['cate_pid'] != '') {
$where['cate_pid'] = $params['cate_pid']; $where['cate_pid'] = $params['cate_pid'];
} }
$products = $this->spuRepository->getApiSearch($where, $page, $limit, false,true); $products = $this->spuRepository->getApiSearch($where, $page, $limit, false, true);
return app('json')->success($products); return app('json')->success($products);
} }
} }