ItemController.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. $where['status'] = 1;
  35. $list = \bizHd\item\classes\ItemClass::getShowList($where);
  36. util::success(['list' => $list]);
  37. }
  38. public function actionAdd()
  39. {
  40. $post = Yii::$app->request->post();
  41. $post['adminId'] = $this->adminId;
  42. $post['sjId'] = $this->sjId;
  43. $post['shopId'] = $this->shopId;
  44. $post['mainId'] = $this->mainId;
  45. ItemService::addGhsItem($post);
  46. util::complete('添加成功');
  47. }
  48. public function actionBatchAdd()
  49. {
  50. $post = Yii::$app->request->post();
  51. //[{itemId:1000,classId:2,cost:1,addPrice:1,stockWarning:1}]
  52. $data = $post['data'];
  53. if (empty($data)) {
  54. util::fail("参数错误");
  55. }
  56. $data = json_decode($data, true);
  57. if (!is_array($data) || empty($data)) {
  58. util::fail("参数格式错误");
  59. }
  60. foreach ($data as $v) {
  61. $v['adminId'] = $this->adminId;
  62. $v['sjId'] = $this->sjId;
  63. ItemService::addGhsItem($v);
  64. }
  65. util::complete('添加成功');
  66. }
  67. public function actionDelete()
  68. {
  69. util::fail('不能删除哦!');
  70. }
  71. //获取平台里的花材信息
  72. public function actionPlatformItem()
  73. {
  74. $py = Yii::$app->request->get('py', '');
  75. $where = [];
  76. if ($py) {
  77. $where = ['py' => $py];
  78. }
  79. $list = PtItemClass::getItemList($where);
  80. util::success($list);
  81. }
  82. }