MqController.php 3.9 KB

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