InventoryShopping.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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(['good_id', 'inventory'], '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', 'inventory'], 'post');
  36. $val = Validate::rule([
  37. 'id|商城商品库存id' => 'require|number|gt:0',
  38. 'inventory|库存数' => 'require|number|gt:0',
  39. ]);
  40. if (!$val->check($param)) throw new ValidateException($val->getError());
  41. return InventoryShoppingLogic::edit($param);
  42. }
  43. //商城商品库存变动记录
  44. public function log()
  45. {
  46. $param = $this->request->only(['page' => 1, 'size' => 10, 'id' => 0], 'post');
  47. return InventoryShoppingLogic::log($param);
  48. }
  49. }