ProductCopy.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\merchant\store\product;
  12. use app\common\repositories\store\product\ProductRepository;
  13. use app\common\repositories\system\merchant\MerchantRepository;
  14. use app\validate\merchant\StoreProductValidate as validate;
  15. use think\App;
  16. use crmeb\basic\BaseController;
  17. use app\common\repositories\store\product\ProductCopyRepository as repository;
  18. class ProductCopy extends BaseController
  19. {
  20. /**
  21. * @var repository
  22. */
  23. protected $repository;
  24. /**
  25. * ProductCopy constructor.
  26. * @param App $app
  27. * @param repository $repository
  28. */
  29. public function __construct(App $app ,repository $repository)
  30. {
  31. $this->repository = $repository;
  32. parent::__construct($app);
  33. }
  34. /**
  35. * 列表
  36. * @return mixed
  37. * @author Qinii
  38. * @day 2020-08-14
  39. */
  40. public function lst()
  41. {
  42. [$page, $limit] = $this->getPage();
  43. $where['mer_id'] = $this->request->param('mer_id');
  44. $mer_id = $this->request->merId();
  45. if ($mer_id){
  46. $where['mer_id'] = $this->request->merId();
  47. }
  48. $where['type'] = $this->request->param('type','copy');
  49. return app('json')->success($this->repository->getList($where,$page, $limit));
  50. }
  51. /**
  52. * 统计商家复制产品数量
  53. *
  54. * @return \Illuminate\Http\JsonResponse
  55. */
  56. public function count()
  57. {
  58. // 获取商家复制产品数量
  59. $count = $this->request->merchant()->copy_product_num;
  60. // 返回统计结果
  61. return app('json')->success(['count' => $count]);
  62. }
  63. /**
  64. * 复制商品
  65. * @return mixed
  66. * @author Qinii
  67. * @day 2020-08-06
  68. */
  69. public function get()
  70. {
  71. $status = systemConfig('copy_product_status');
  72. if($status == 0) return app('json')->fail('请前往平台后台-设置-第三方接口-开启采集');
  73. $url = $this->request->param('url');
  74. if (!$url) return app('json')->fail('请输入采集链接');
  75. $res = $this->repository->getProduct($url,$this->request->merId());
  76. return app('json')->success($res);
  77. }
  78. }