ItemController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace hd\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 Yii;
  8. class ItemController extends BaseController
  9. {
  10. //列出所有花材,包括特价花材列表 ssh 20220315
  11. public function actionShowList()
  12. {
  13. $where['mainId'] = $this->mainId;
  14. $where['delStatus'] = 0;
  15. $list = \bizHd\item\classes\ItemClass::getShowList($where);
  16. util::success(['list' => $list]);
  17. }
  18. public function actionAdd()
  19. {
  20. $post = Yii::$app->request->post();
  21. $post['adminId'] = $this->adminId;
  22. $post['sjId'] = $this->sjId;
  23. $post['shopId'] = $this->shopId;
  24. $post['mainId'] = $this->mainId;
  25. ItemService::addGhsItem($post);
  26. util::complete('添加成功');
  27. }
  28. public function actionBatchAdd()
  29. {
  30. $post = Yii::$app->request->post();
  31. //[{itemId:1000,classId:2,cost:1,addPrice:1,stockWarning:1}]
  32. $data = $post['data'];
  33. if (empty($data)) {
  34. util::fail("参数错误");
  35. }
  36. $data = json_decode($data, true);
  37. if (!is_array($data) || empty($data)) {
  38. util::fail("参数格式错误");
  39. }
  40. foreach ($data as $v) {
  41. $v['adminId'] = $this->adminId;
  42. $v['sjId'] = $this->sjId;
  43. ItemService::addGhsItem($v);
  44. }
  45. util::complete('添加成功');
  46. }
  47. public function actionDelete()
  48. {
  49. util::fail('不能删除哦!');
  50. }
  51. //获取平台里的花材信息
  52. public function actionPlatformItem()
  53. {
  54. $py = Yii::$app->request->get('py', '');
  55. $where = [];
  56. if ($py) {
  57. $where = ['py' => $py];
  58. }
  59. $list = PtItemClass::getItemList($where);
  60. util::success($list);
  61. }
  62. }