MqController.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. $cgId = $order->purchaseId ?? 0;
  50. $cg = PurchaseClass::getById($cgId, true);
  51. $cgShop = ShopClass::getById($cg->shopId, true, 'shopName, merchantName');
  52. $push = new push('ghs', push::MSG_TYPE_ORDER);
  53. $push->ghsOrderMessage($shop, $cgShop, $order);
  54. }
  55. }
  56. }
  57. }
  58. }
  59. //预订增加减少通知 ssh 20240820
  60. public function actionBookChangeNotice()
  61. {
  62. $noticeKey = "bookChangeNoticeStaff";
  63. while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
  64. $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
  65. if (!empty($json)) {
  66. $arr = json_decode($json, true);
  67. $shopId = $arr['shopId'] ?? 0;
  68. if (!empty($shopId)) {
  69. $shop = ShopClass::getById($shopId, true);
  70. if (!empty($shop)) {
  71. WxMessageClass::bookChangeInform($shop, $arr);
  72. }
  73. }
  74. }
  75. }
  76. }
  77. //供货商开单通知花店 ssh 20231129
  78. public function actionGhsKdNoticeHd()
  79. {
  80. $noticeKey = "ghsKdNoticeHd";
  81. while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
  82. $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
  83. if (!empty($json)) {
  84. $arr = json_decode($json, true);
  85. $id = $arr['id'] ?? 0;
  86. if (!empty($id)) {
  87. $cg = PurchaseClass::getById($id, true);
  88. $shopId = $cg->shopId ?? 0;
  89. $shop = ShopClass::getById($shopId, true);
  90. if (!empty($shop)) {
  91. WxMessageClass::hdNewCgOrderInform($shop, $cg);
  92. }
  93. }
  94. }
  95. }
  96. }
  97. }