InventoryShopping.php 1.8 KB

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