MerchantMp.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @package merchant
  4. * @Author: Qinii
  5. * @Date: 2020/5/28
  6. */
  7. namespace app\controller\api\store\merchant;
  8. use think\App;
  9. use crmeb\basic\BaseController;
  10. use app\common\repositories\system\merchant\MerchantRepository as repository;
  11. use app\common\repositories\store\product\ProductAttrValueRepository;
  12. class MerchantMp extends BaseController
  13. {
  14. protected $repository;
  15. protected $userInfo;
  16. /**
  17. * ProductCategory constructor.
  18. * @param App $app
  19. * @param repository $repository
  20. */
  21. public function __construct(App $app, repository $repository)
  22. {
  23. parent::__construct($app);
  24. $this->repository = $repository;
  25. }
  26. public function getProduct($id){
  27. if(!$this->repository->merExists($id))
  28. return app('json')->fail('店铺不存在');
  29. $cateList = $this->repository->categoryList($id);
  30. [$page, $limit] = $this->getPage();
  31. // $where = $this->request->params(['keyword','order','mer_cate_id','price_on', 'price_off','brand_id']);
  32. $where['is_gift_bag'] = 0;
  33. $where['is_used'] = 1;
  34. $where['product_type'] = 0;
  35. $productAttrValueRepository = app()->make(ProductAttrValueRepository::class);
  36. foreach($cateList as $key => $value){
  37. $where['mer_cate_id'] = $value['store_category_id'];
  38. $cateList[$key]['product'] = $this->repository->productList($id,$where, $page, $limit,null);
  39. foreach($cateList[$key]['product']['list'] as $key1 => $value1){
  40. $cateList[$key]['product']['list'][$key1]['sku'] = $productAttrValueRepository -> getOptionByProductId($value1['product_id']);
  41. }
  42. }
  43. return app('json')->success($cateList);
  44. }
  45. public function getProductGood($id){
  46. if(!$this->repository->merExists($id))
  47. return app('json')->fail('店铺不存在');
  48. $res = $this->repository->getProductGoodList($id);
  49. return app('json')->success($res);
  50. }
  51. }