123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace app\controller\out;
- use app\Request;
- use app\services\product\category\StoreProductCategoryServices;
- use app\services\out\StoreProductServices;
- class Product
- {
-
- protected $services;
- public function __construct(StoreProductServices $services)
- {
- $this->services = $services;
- }
-
- public function detail(Request $request)
- {
- $spu = $request->getMore([
- ['spu', 0]
- ], true);
- $data = $this->services->productDetail($request, $spu);
- return app('json')->successful($data);
- }
-
- public function set_show(Request $request)
- {
- [$spu, $is_show] = $request->getMore([
- ['spu', 0],
- ['is_show', 0]
- ], true);
- $this->services->setShow($request, $spu, $is_show);
- return app('json')->success($is_show == 1 ? '上架成功' : '下架成功');
- }
-
- public function category(StoreProductCategoryServices $services)
- {
- $data = $services->getOutList();
- return app('json')->success($data);
- }
-
- public function set_stock(Request $request, $spu = '')
- {
- [$data] = $request->postMore([
- ['data', []],
- ], true);
- if (!$spu || !$data) return $this->fail('参数错误');
- $res = $this->services->setStock((array)$data, (string)$spu);
- return app('json')->success('修改成功');
- }
- }
|