diff --git a/app/common/repositories/community/CommunityRepository.php b/app/common/repositories/community/CommunityRepository.php index 449a9f71..ee931ed2 100644 --- a/app/common/repositories/community/CommunityRepository.php +++ b/app/common/repositories/community/CommunityRepository.php @@ -99,6 +99,7 @@ class CommunityRepository extends BaseRepository $config = systemConfig("community_app_switch"); if (!isset($where['is_type']) && $config) $where['is_type'] = is_array($config) ? implode(',', $config) : $config; $where['is_del'] = 0; + // print_r($where); $query = $this->dao->search($where)->when(in_array(self::COMMUNITY_TYPE_RESALE, explode(',', $where['is_type'])), function ($query) { $query->where('is_sale', 0); })->order('start DESC,Community.create_time DESC,community_id DESC'); diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 670535f7..4db61fc0 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -2434,4 +2434,31 @@ class ProductRepository extends BaseRepository return false; } + /** + * 可转售商品列表 + * @param + * @param + * @param + * @return array + */ + public function communityProduct($where, $keyword, $page, $limit) + { + $merId = Db::name('store_service')->where('uid', $where['uid'])->where('status', 1)->value('mer_id', 0); + unset($where['uid']); + $query = $this->dao->search($merId, $where)->with(['merCateId.category', 'storeCategory', 'brand', 'attrValue']); + $count = $query->count(); + $data = $query->page($page, $limit)->setOption('field', [])->field($this->filed)->select(); + $data->append(['us_status']); + $list = hasMany( + $data , + 'mer_labels', + ProductLabel::class, + 'product_label_id', + 'mer_labels', + ['status' => 1], + 'product_label_id,product_label_id id,label_name name' + ); + return compact('count', 'list'); + } + } diff --git a/app/controller/api/community/Community.php b/app/controller/api/community/Community.php index 323c4fc0..08b14293 100644 --- a/app/controller/api/community/Community.php +++ b/app/controller/api/community/Community.php @@ -16,6 +16,7 @@ use app\common\model\system\merchant\Merchant; use app\common\repositories\community\CommunityRepository; use app\common\repositories\store\order\StoreOrderProductRepository; use app\common\repositories\store\order\StoreOrderRepository; +use app\common\repositories\store\product\ProductRepository; use app\common\repositories\system\RelevanceRepository; use app\common\repositories\user\UserHistoryRepository; use app\common\repositories\user\UserRelationRepository; @@ -438,6 +439,14 @@ class Community extends BaseController return app('json')->success($list); } + public function product() + { + [$page, $limit] = $this->getPage(); + $keyword = $this->request->param('keyword'); + $list = app()->make(ProductRepository::class)->communityProduct(['uid' => $this->request->uid()], $keyword, $page, $limit); + return app('json')->success($list); + } + /** * 转售加购 * @return mixed diff --git a/route/api.php b/route/api.php index 75f907ad..a2f16e45 100644 --- a/route/api.php +++ b/route/api.php @@ -404,6 +404,7 @@ Route::group('api/', function () { Route::get('/focuslst', 'Community/focuslst'); Route::get('/getOrderList', 'Community/getOrderList'); + Route::get('/product/lst', 'Community/product'); Route::post('/addCart', 'Community/addCart'); })->prefix('api.community.'); //上传图片