ItemController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. //检测是否要刷新
  11. public function actionCheckRefresh()
  12. {
  13. $mainId = $this->mainId;
  14. $staffId = $this->shopAdminId;
  15. $respond = Yii::$app->redis->executeCommand('GET', ['cashier_' . $mainId . '_' . $staffId . '_may_refresh']);
  16. if ($respond == 'yes') {
  17. util::success(['remind' => 1]);
  18. }
  19. util::complete();
  20. }
  21. //列出所有花材,包括特价花材列表 ssh 20220315
  22. public function actionShowList()
  23. {
  24. $get = Yii::$app->request->get();
  25. $isCashier = $get['isCashier'] ?? 0;
  26. $mainId = $this->mainId;
  27. if ($isCashier == 1) {
  28. //去掉收银台提示价格更新
  29. $staffId = $this->shopAdminId;
  30. Yii::$app->redis->executeCommand('DEL', ['cashier_' . $mainId . '_' . $staffId . '_may_refresh']);
  31. }
  32. $where['mainId'] = $mainId;
  33. $where['delStatus'] = 0;
  34. $list = \bizHd\item\classes\ItemClass::getShowList($where);
  35. util::success(['list' => $list]);
  36. }
  37. public function actionAdd()
  38. {
  39. $post = Yii::$app->request->post();
  40. $post['adminId'] = $this->adminId;
  41. $post['sjId'] = $this->sjId;
  42. $post['shopId'] = $this->shopId;
  43. $post['mainId'] = $this->mainId;
  44. ItemService::addGhsItem($post);
  45. util::complete('添加成功');
  46. }
  47. public function actionBatchAdd()
  48. {
  49. $post = Yii::$app->request->post();
  50. //[{itemId:1000,classId:2,cost:1,addPrice:1,stockWarning:1}]
  51. $data = $post['data'];
  52. if (empty($data)) {
  53. util::fail("参数错误");
  54. }
  55. $data = json_decode($data, true);
  56. if (!is_array($data) || empty($data)) {
  57. util::fail("参数格式错误");
  58. }
  59. foreach ($data as $v) {
  60. $v['adminId'] = $this->adminId;
  61. $v['sjId'] = $this->sjId;
  62. ItemService::addGhsItem($v);
  63. }
  64. util::complete('添加成功');
  65. }
  66. public function actionDelete()
  67. {
  68. util::fail('不能删除哦!');
  69. }
  70. //获取平台里的花材信息
  71. public function actionPlatformItem()
  72. {
  73. $py = Yii::$app->request->get('py', '');
  74. $where = [];
  75. if ($py) {
  76. $where = ['py' => $py];
  77. }
  78. $list = PtItemClass::getItemList($where);
  79. util::success($list);
  80. }
  81. }