Merge pull request '更新' (#59) from dev into preview

Reviewed-on: #59
This commit is contained in:
mkm 2023-11-05 16:04:20 +08:00
commit 6841ff5a11
2 changed files with 64 additions and 25 deletions

View File

@ -80,7 +80,7 @@ class CloudWarehouse extends BaseController
// // $entryWhere['category_id'] = $params['category_id'];
// // }
// // $where['entry_mer_id'] = $this->merchantDao->search($entryWhere)->value('mer_id');
// $where['entry_mer_id'] = 0;
// $where['keyword'] = $params['keyword'];
// $where['mer_ids'] = $merchantIds;
@ -95,32 +95,70 @@ class CloudWarehouse extends BaseController
* 云仓商品列表
* @return mixed
*/
public function index($street_code,$page_num=1,$category_id=0){
if($category_id==0){
public function index($street_code, $page_num = 1, $category_id = 0)
{
if ($category_id == 0) {
return app('json')->fail('分类id不能为0');
}
$cloud_product=Db::name('cloud_product')->where('street_code',$street_code)->where('category_id',$category_id)->where('status',1)->page($page_num)->column('product_id');
if(!$cloud_product){
return app('json')->success(['count'=>0,'list'=>[]]);
$cloud_product = Db::name('cloud_product')->where('street_code', $street_code)->where('category_id', $category_id)->where('status', 1)->page($page_num)->column('product_id');
if (!$cloud_product) {
return app('json')->success(['count' => 0, 'list' => []]);
}
$where=[
'is_show'=>1,
'is_used'=>1,
'status'=>1,
'is_del'=>0,
'mer_status'=>1,
$where = [
'is_show' => 1,
'is_used' => 1,
'status' => 1,
'is_del' => 0,
'mer_status' => 1,
];
$count=Db::name('cloud_product')->where('street_code',$street_code)->where('status',1)->count();
$select=Db::name('store_product')->whereIn('product_id',$cloud_product)->where($where)
->withAttr('merchant',function($value,$data){
return Db::name('merchant')->where('mer_id',$data['mer_id'])->field('mer_id,mer_name')->find();
})
->withAttr('sku',function($value,$data){
$find= Db::name('store_product_attr_value')->where('mer_id',$data['mer_id'])->where('product_id',$data['product_id'])->find();
return[''=>$find];
})
// ->field('product_id,mer_id,store_name,bar_code,price,stock,product_type,image')
->select();
return app('json')->success(['count'=>$count,'list'=>$select]);
$count = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->count();
$select = Db::name('store_product')->whereIn('product_id', $cloud_product)->where($where)
->withAttr('merchant', function ($value, $data) {
return Db::name('merchant')->where('mer_id', $data['mer_id'])->field('mer_id,mer_name')->find();
})
->withAttr('sku', function ($value, $data) {
$find = Db::name('store_product_attr_value')->where('mer_id', $data['mer_id'])->where('product_id', $data['product_id'])->find();
return ['' => $find];
})
// ->field('product_id,mer_id,store_name,bar_code,price,stock,product_type,image')
->select();
return app('json')->success(['count' => $count, 'list' => $select]);
}
}
/**
* 指定类型的云仓商品列表
* @return mixed
*/
public function town()
{
// 除了市级供应链都可以查询
$params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page_num']);
$search = [
'street_id' => $params['street_code'],
'type_id' => Merchant::TypeTownSupplyChain,
'status' => 1,
'is_del' => 0,
'mer_state' => 1,
];
if (!empty($params['category_id'])) {
$search['category_id'] = $params['category_id'];
}
$merchantIds = $this->merchantDao->search($search)->column('mer_id');
[$page, $limit] = $this->getPage();
if (isset($params['page_num']) && $params['page_num'] != '') {
$page = $params['page_num'];
}
if (empty($merchantIds)) {
return app('json')->success(['count' => 0, 'list' => []]);
}
$where['entry_mer_id'] = 0;
$where['keyword'] = $params['keyword'];
$where['mer_ids'] = $merchantIds;
$where['product_type'] = $params['product_type'];
$where['is_gift_bag'] = 0;
$where['order'] = $params['order'] ?: 'sort';
$products = $this->spuRepository->getApiCloudSearch($where, $page, $limit, false);
return app('json')->success($products);
}
}

View File

@ -594,6 +594,7 @@ Route::group('api/', function () {
Route::any('store/test', 'api.Test/test');
Route::get('subscribe', 'api.Common/subscribe');
Route::resource('store/product/cloudWarehouse', 'api.store.product.CloudWarehouse');
Route::get('store/product/town_cloud', 'api.store.product.CloudWarehouse/town');
})->middleware(UserTokenMiddleware::class, false);
//微信支付回调