1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace app\admin\controller;
- use app\admin\logic\InventoryShoppingLogic;
- use app\BaseController;
- use app\model\CommonModel;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Validate;
- //【商城商品库存】
- class InventoryShopping extends BaseController
- {
- //获取商城商品库存列表
- public function list()
- {
- $param = $this->request->only(['page' => 1, 'size' => 10, 'good_name' => '', 'inventory_start' => '', 'inventory_end' => ''], 'post');
- return InventoryShoppingLogic::list($param);
- }
- //添加商城商品库存
- public function add()
- {
- $param = $this->request->only(['list'], 'post');
- $val = Validate::rule(Config::get('validate_rules.InventoryShoppingAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return InventoryShoppingLogic::add($param);
- }
- //获取商城商品库存详情
- public function read()
- {
- $id = $this->request->post('id/d', 0);
- return InventoryShoppingLogic::read($id);
- }
- //编辑商城商品库存
- public function edit()
- {
- $param = $this->request->only(['id', 'flag', 'number'], 'post');
- $val = Validate::rule([
- 'id|商城商品库存id' => 'require|number|gt:0|lt:999999999',
- 'flag|变化方式' => 'require|number|in:1,-1',
- 'number|库存变化数' => 'require|number|gt:0|lt:999999999',
- ]);
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return InventoryShoppingLogic::edit($param);
- }
- //商城商品库存变动记录
- public function log()
- {
- $param = $this->request->only(['page' => 1, 'size' => 10, 'id' => 0], 'post');
- return InventoryShoppingLogic::log($param);
- }
- }
|