| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- namespace console\controllers;
- use bizGhs\book\classes\BookItemCustomClass;
- use bizHd\purchase\classes\PurchaseClass;
- use bizHd\shop\classes\ShopClass;
- use biz\wx\classes\WxMessageClass;
- use yii\console\Controller;
- use bizGhs\order\classes\OrderClass;
- use \common\components\push;
- use Yii;
- class MqController extends Controller
- {
- //预订变化下架花材 ssh 20240729
- public function actionBookChangeOutStock()
- {
- $noticeKey = "bookChangeOffItem";
- while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
- $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
- //$json = '{"id":163,"num":"1","shopId":36523}';
- if (!empty($json)) {
- $arr = json_decode($json, true);
- $id = $arr['id'] ?? 0;
- $num = $arr['num'] ?? 0;
- $shopId = $arr['shopId'] ?? 0;
- $res = BookItemCustomClass::getById($id, true);
- if (!empty($res)) {
- $shop = \biz\shop\classes\ShopClass::getById($shopId, true);
- WxMessageClass::bookChangeOutStockInform($shop, $res, $num);
- }
- }
- }
- }
- //花店采购通知供货商 ssh 20230805
- public function actionHdCgNoticeGhs()
- {
- $noticeKey = "hdCgNoticeGhs";
- while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
- $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
- if (!empty($json)) {
- $arr = json_decode($json, true);
- $orderId = $arr['orderId'] ?? 0;
- if (!empty($orderId)) {
- $order = OrderClass::getById($orderId, true);
- $shopId = $order->shopId ?? 0;
- $shop = ShopClass::getById($shopId, true);
- if (!empty($shop)) {
- WxMessageClass::ghsHasNewOrderInform($shop, $order);
- // 向供货商App发通知
- $cgId = $order->purchaseId ?? 0;
- $cg = PurchaseClass::getById($cgId, true);
- $cgShop = ShopClass::getById($cg->shopId, true, 'shopName, merchantName');
- $push = new push('ghs', push::MSG_TYPE_ORDER);
- $push->ghsOrderMessage($shop, $cgShop, $order);
- }
- }
- }
- }
- }
- //预订增加减少通知 ssh 20240820
- public function actionBookChangeNotice()
- {
- $noticeKey = "bookChangeNoticeStaff";
- while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
- $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
- if (!empty($json)) {
- $arr = json_decode($json, true);
- $shopId = $arr['shopId'] ?? 0;
- if (!empty($shopId)) {
- $shop = ShopClass::getById($shopId, true);
- if (!empty($shop)) {
- WxMessageClass::bookChangeInform($shop, $arr);
- }
- }
- }
- }
- }
- //供货商开单通知花店员工 ssh 20231129
- public function actionGhsKdNoticeHd()
- {
- $noticeKey = "ghsKdNoticeHd";
- while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
- $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
- if (!empty($json)) {
- $arr = json_decode($json, true);
- $id = $arr['id'] ?? 0;
- if (!empty($id)) {
- $cg = PurchaseClass::getById($id, true);
- $shopId = $cg->shopId ?? 0;
- $shop = ShopClass::getById($shopId, true);
- if (!empty($shop)) {
- $allDevices = \bizHd\device\classes\HdDeviceClass::getAllByCondition(['shopId'=>$shopId]);
- $cids = array_column($allDevices, 'clientId');
- $title = '买花成功';
- $shopName = $shop->merchantName . ($shop->shopName != '首店' ? '(' . $shop->shopName . ')' : '');
- $content = $shopName . ' ¥' . $cg->actPrice;
- $payload = [
- "page" => "pagesPurchase/purDetails",
- "params" => ["id" => $id]
- ];
- $push = new push('hd', push::MSG_TYPE_ORDER);
- $push->pushByCloud($cids, $title, $content, $payload);
- }
- }
- }
- }
- }
- }
|