ItemController.php 2.3 KB

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