ItemController.php 1.8 KB

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