MqController.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace console\controllers;
  3. use bizGhs\book\classes\BookItemCustomClass;
  4. use bizHd\purchase\classes\PurchaseClass;
  5. use bizHd\shop\classes\ShopClass;
  6. use biz\wx\classes\WxMessageClass;
  7. use yii\console\Controller;
  8. use bizGhs\order\classes\OrderClass;
  9. use \common\components\push;
  10. use Yii;
  11. class MqController extends Controller
  12. {
  13. //预订变化下架花材 ssh 20240729
  14. public function actionBookChangeOutStock()
  15. {
  16. $noticeKey = "bookChangeOffItem";
  17. while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
  18. $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
  19. //$json = '{"id":163,"num":"1","shopId":36523}';
  20. if (!empty($json)) {
  21. $arr = json_decode($json, true);
  22. $id = $arr['id'] ?? 0;
  23. $num = $arr['num'] ?? 0;
  24. $shopId = $arr['shopId'] ?? 0;
  25. $res = BookItemCustomClass::getById($id, true);
  26. if (!empty($res)) {
  27. $shop = \biz\shop\classes\ShopClass::getById($shopId, true);
  28. WxMessageClass::bookChangeOutStockInform($shop, $res, $num);
  29. }
  30. }
  31. }
  32. }
  33. //花店采购通知供货商 ssh 20230805
  34. public function actionHdCgNoticeGhs()
  35. {
  36. $noticeKey = "hdCgNoticeGhs";
  37. while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
  38. $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
  39. if (!empty($json)) {
  40. $arr = json_decode($json, true);
  41. $orderId = $arr['orderId'] ?? 0;
  42. if (!empty($orderId)) {
  43. $order = OrderClass::getById($orderId, true);
  44. $shopId = $order->shopId ?? 0;
  45. $shop = ShopClass::getById($shopId, true);
  46. if (!empty($shop)) {
  47. WxMessageClass::ghsHasNewOrderInform($shop, $order);
  48. // 向供货商App发通知
  49. $cgShop = ShopClass::getById($cg->shopId, true, 'shopName, merchantName');
  50. $push = new push('ghs', push::MSG_TYPE_ORDER);
  51. $push->ghsOrderMessage($shop, $cgShop, $order);
  52. }
  53. }
  54. }
  55. }
  56. }
  57. //预订增加减少通知 ssh 20240820
  58. public function actionBookChangeNotice()
  59. {
  60. $noticeKey = "bookChangeNoticeStaff";
  61. while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
  62. $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
  63. if (!empty($json)) {
  64. $arr = json_decode($json, true);
  65. $shopId = $arr['shopId'] ?? 0;
  66. if (!empty($shopId)) {
  67. $shop = ShopClass::getById($shopId, true);
  68. if (!empty($shop)) {
  69. WxMessageClass::bookChangeInform($shop, $arr);
  70. }
  71. }
  72. }
  73. }
  74. }
  75. //供货商开单通知花店 ssh 20231129
  76. public function actionGhsKdNoticeHd()
  77. {
  78. $noticeKey = "ghsKdNoticeHd";
  79. while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
  80. $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
  81. if (!empty($json)) {
  82. $arr = json_decode($json, true);
  83. $id = $arr['id'] ?? 0;
  84. if (!empty($id)) {
  85. $cg = PurchaseClass::getById($id, true);
  86. $shopId = $cg->shopId ?? 0;
  87. $shop = ShopClass::getById($shopId, true);
  88. if (!empty($shop)) {
  89. WxMessageClass::hdNewCgOrderInform($shop, $cg);
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }