InventoryExchange.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\logic\InventoryExchangeLogic;
  4. use app\BaseController;
  5. use think\exception\ValidateException;
  6. use think\facade\Config;
  7. use think\facade\Validate;
  8. //【兑换商品库存】
  9. class InventoryExchange extends BaseController
  10. {
  11. //获取兑换商品库存列表
  12. public function list()
  13. {
  14. $param = $this->request->only(['page' => 1, 'size' => 10, 'status' => '', 'inventory_start' => '', 'inventory_end' => '', 'username' => '', 'name' => '', 'mobile' => '', 'good_name' => '', 'good_code' => ''], 'post');
  15. return InventoryExchangeLogic::list($param);
  16. }
  17. //添加兑换商品库存
  18. public function add()
  19. {
  20. $param = $this->request->only(['group_id', 'list'], 'post');
  21. $val = Validate::rule(Config::get('validate_rules.InventoryExchangeAdd'));
  22. if (!$val->check($param)) throw new ValidateException($val->getError());
  23. return InventoryExchangeLogic::add($param);
  24. }
  25. //获取兑换商品库存详情
  26. public function read()
  27. {
  28. $id = $this->request->post('id/d', 0);
  29. return InventoryExchangeLogic::read($id);
  30. }
  31. //编辑兑换商品库存
  32. public function edit()
  33. {
  34. $param = $this->request->only(['id', 'flag', 'number'], 'post');
  35. $val = Validate::rule([
  36. 'id|兑换商品库存id' => 'require|number|gt:0|lt:999999999',
  37. 'flag|变化方式' => 'require|number|in:1,-1',
  38. 'number|库存变化数' => 'require|number|gt:0|lt:999999999',
  39. ]);
  40. if (!$val->check($param)) throw new ValidateException($val->getError());
  41. return InventoryExchangeLogic::edit($param);
  42. }
  43. //兑换商品库存变动记录
  44. public function log()
  45. {
  46. $param = $this->request->only(['page' => 1, 'size' => 10, 'id' => 0], 'post');
  47. return InventoryExchangeLogic::log($param);
  48. }
  49. }