InventoryExchange.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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' => ''], 'post');
  15. return InventoryExchangeLogic::list($param);
  16. }
  17. //添加兑换商品库存
  18. public function add()
  19. {
  20. $param = $this->request->only(['account_id', 'good_id', 'inventory'], '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', 'inventory'], 'post');
  35. $val = Validate::rule([
  36. 'id|兑换商品库存id' => 'require|number|gt:0',
  37. 'inventory|库存数' => 'require|number|gt:0',
  38. ]);
  39. if (!$val->check($param)) throw new ValidateException($val->getError());
  40. return InventoryExchangeLogic::edit($param);
  41. }
  42. //兑换商品库存变动记录
  43. public function log()
  44. {
  45. $param = $this->request->only(['page' => 1, 'size' => 10, 'id' => 0], 'post');
  46. return InventoryExchangeLogic::log($param);
  47. }
  48. }