12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\admin\controller;
- use app\admin\logic\InventoryExchangeLogic;
- use app\BaseController;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Validate;
- //【兑换商品库存】
- class InventoryExchange extends BaseController
- {
- //获取兑换商品库存列表
- public function list()
- {
- $param = $this->request->only(['page' => 1, 'size' => 10, 'status' => '', 'inventory_start' => '', 'inventory_end' => '', 'username' => '', 'name' => '', 'mobile' => '', 'good_name' => '', 'good_code' => ''], 'post');
- return InventoryExchangeLogic::list($param);
- }
- //添加兑换商品库存
- public function add()
- {
- $param = $this->request->only(['group_id', 'list'], 'post');
- $val = Validate::rule(Config::get('validate_rules.InventoryExchangeAdd'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return InventoryExchangeLogic::add($param);
- }
- //获取兑换商品库存详情
- public function read()
- {
- $id = $this->request->post('id/d', 0);
- return InventoryExchangeLogic::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 InventoryExchangeLogic::edit($param);
- }
- //兑换商品库存变动记录
- public function log()
- {
- $param = $this->request->only(['page' => 1, 'size' => 10, 'id' => 0], 'post');
- return InventoryExchangeLogic::log($param);
- }
- }
|