ItemController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * User: admin
  4. * Date Time: 2021/3/2 14:33
  5. */
  6. namespace hd\controllers;
  7. use biz\item\classes\PtItemClass;
  8. use bizGhs\item\classes\ItemClass;
  9. use bizGhs\item\services\ItemService;
  10. use common\components\util;
  11. use common\services\xhItemService;
  12. use Yii;
  13. class ItemController extends BaseController
  14. {
  15. public function actionList()
  16. {
  17. $classId = Yii::$app->request->get('classId', 0);
  18. $where['sjId'] = $this->sjId;
  19. if (!empty($classId)) {
  20. $where['classId'] = $classId;
  21. }
  22. $list = ItemClass::getGhsItemList($where);
  23. util::success($list);
  24. }
  25. public function actionAdd()
  26. {
  27. $post = Yii::$app->request->post();
  28. $post['adminId'] = $this->adminId;
  29. // $post['shopId'] = $this->shopId;
  30. $post['sjId'] = $this->sjId;
  31. ItemService::addGhsItem($post);
  32. util::complete('添加成功');
  33. }
  34. public function actionBatchAdd()
  35. {
  36. $post = Yii::$app->request->post();
  37. $data = $post['data']; //[{itemId:1000,classId:2,cost:1,addPrice:1,stockWarning:1}]
  38. if(empty($data)){
  39. util::fail("参数错误");
  40. }
  41. $data = json_decode($data,true);
  42. if(!is_array($data) || empty($data)){
  43. util::fail("参数格式错误");
  44. }
  45. foreach ($data as $v){
  46. $v['adminId'] = $this->adminId;
  47. $v['sjId'] = $this->sjId;
  48. ItemService::addGhsItem($v);
  49. }
  50. util::complete('添加成功');
  51. }
  52. public function actionUpdate()
  53. {
  54. $data = Yii::$app->request->post();
  55. $data['adminId'] = $this->adminId;
  56. $data['sjId'] = $this->sjId;
  57. ItemService::updateGshItem($data);
  58. util::complete('修改成功');
  59. }
  60. public function actionDelete()
  61. {
  62. // $get = Yii::$app->request->get();
  63. // $id = isset($get['id']) ? $get['id'] : 0;
  64. // ItemService::deleteGhsItem($id, $this->shopId, $this->sjId, $this->adminId);
  65. util::fail('不能删除哦!');
  66. }
  67. //获取平台里的花材信息
  68. public function actionPlatformItem()
  69. {
  70. $py = Yii::$app->request->get('py', '');
  71. $where = [];
  72. if ($py) {
  73. $where = ['py' => $py];
  74. }
  75. $list = PtItemClass::getItemList($where);
  76. util::success($list);
  77. }
  78. }