|
|
@@ -6,7 +6,12 @@
|
|
|
|
|
|
namespace common\components\rabbitmq;
|
|
|
|
|
|
+use biz\wx\classes\WxMessageClass;
|
|
|
+use bizGhs\order\classes\OrderClass;
|
|
|
+use bizHd\purchase\classes\PurchaseClass;
|
|
|
+use bizHd\shop\classes\ShopClass;
|
|
|
use common\components\noticeUtil;
|
|
|
+use common\components\push;
|
|
|
use mikemadisonweb\rabbitmq\components\ConsumerInterface;
|
|
|
use PhpAmqpLib\Message\AMQPMessage;
|
|
|
use Yii;
|
|
|
@@ -35,17 +40,17 @@ class notifyConsumer implements ConsumerInterface
|
|
|
// 根据通知类型分发处理
|
|
|
$type = $data['type'] ?? null;
|
|
|
switch ($type) {
|
|
|
- case 'ghs_new_order':
|
|
|
+ case 'ghs_new_order_notify':
|
|
|
//供货商的新订单通知
|
|
|
- $result = $this->ghsNewOrder($data);
|
|
|
+ $result = $this->ghsNewOrderNotify($data);
|
|
|
break;
|
|
|
- case 'hd_new_order':
|
|
|
+ case 'hd_new_order_notify':
|
|
|
//花店的新订单通知
|
|
|
- $result = $this->hdNewOrder($data);
|
|
|
+ $result = $this->hdNewOrderNotify($data);
|
|
|
break;
|
|
|
- case 'hd_new_cg_order':
|
|
|
+ case 'hd_new_cg_notify':
|
|
|
//花店的新采购单通知
|
|
|
- $result = $this->hdNewCgOrder($data);
|
|
|
+ $result = $this->hdNewCgNotify($data);
|
|
|
break;
|
|
|
default:
|
|
|
noticeUtil::push("通知的消费者提示:Unknown notify type: {$type}", '15280215347');
|
|
|
@@ -63,24 +68,54 @@ class notifyConsumer implements ConsumerInterface
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function ghsNewOrder($data)
|
|
|
+ private function ghsNewOrderNotify($data)
|
|
|
{
|
|
|
- $msg = $data['msg'] ?? '';
|
|
|
- noticeUtil::push($msg, '15280215347');
|
|
|
+ $orderId = $data['orderId'] ?? 0;
|
|
|
+ if (!empty($orderId)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $order = OrderClass::getById($orderId, true);
|
|
|
+ if (empty($order)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $shopId = $order->shopId ?? 0;
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ if (empty($shop)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ 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);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private function hdNewOrder($data)
|
|
|
+ private function hdNewOrderNotify($data)
|
|
|
{
|
|
|
- $msg = $data['msg'] ?? '';
|
|
|
- noticeUtil::push($msg, '15280215347');
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private function hdNewCgOrder($data)
|
|
|
+ private function hdNewCgNotify($data)
|
|
|
{
|
|
|
- $msg = $data['msg'] ?? '';
|
|
|
- noticeUtil::push($msg, '15280215347');
|
|
|
+ $cgId = $data['cgId'] ?? 0;
|
|
|
+ $cg = PurchaseClass::getById($cgId, true);
|
|
|
+ $shopId = $cg->shopId ?? 0;
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ $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" => $cgId]
|
|
|
+ ];
|
|
|
+ $push = new push('hd', push::MSG_TYPE_ORDER);
|
|
|
+ $push->pushByCloud($cids, $title, $content, $payload);
|
|
|
return true;
|
|
|
}
|
|
|
|