Răsfoiți Sursa

直接通知

shish 6 ani în urmă
părinte
comite
28a401c067

+ 62 - 3
biz/message/classes/InformAdminClass.php

@@ -3,11 +3,13 @@
 namespace biz\message\classes;
 
 use biz\admin\classes\AdminClass;
+use biz\admin\classes\ShopAdminClass;
 use biz\admin\services\ShopAdminService;
 use biz\merchant\classes\MerchantClass;
 use biz\user\classes\UserClass;
 use biz\wx\classes\WxOpenClass;
 use common\components\httpUtil;
+use common\components\sms;
 use common\components\wxUtil;
 use common\services\xhTMessageService;
 use Yii;
@@ -63,9 +65,12 @@ class InformAdminClass extends BaseClass
             'isOpen' => $isOpen,
         ];
         $data = array_merge($data, $respond);
-        $producer = Yii::$app->rabbitmq->getProducer('informProducer');
-        $msg = serialize($data);
-        $producer->publish($msg, 'informExchange', 'informRoute');
+
+        self::consumeInformQueue($data);
+
+//        $producer = Yii::$app->rabbitmq->getProducer('informProducer');
+//        $msg = serialize($data);
+//        $producer->publish($msg, 'informExchange', 'informRoute');
 
     }
 
@@ -233,4 +238,58 @@ class InformAdminClass extends BaseClass
         }
     }
 
+
+    //消费通知内容 shish 2020.1.1
+    //['messageType'=>'inform','informWay'=>'miniProgram','userType'=>'admin','shopAdminId'=>913,'mobile'=>'15280215347','tMessage'=>'','content'=>'','briefContent'=>'','isOpen'=>1]
+    public static function consumeInformQueue($data)
+    {
+        $informWay = $data['informWay'];
+        $shopAdminId = isset($data['shopAdminId']) ? $data['shopAdminId'] : 0;
+        if (empty($shopAdminId)) {
+            echo "\n 没有找到门店管理员 \n";
+            util::end();
+        }
+        $shopAdmin = ShopAdminClass::getById($shopAdminId);
+        $merchantId = $shopAdmin['merchantId'];
+        $adminId = $shopAdmin['adminId'];
+        $mobile = $data['mobile'];
+        $isOpen = isset($data['isOpen']) ? $data['isOpen'] : 0;
+        $merchant = WxOpenClass::getWxInfo();
+        $hasSend = 0;
+        $noticeWay = 0;
+        if ($informWay == 'wx') {
+            $tMessage = json_decode($data['tMessage'], true);
+            wxUtil::sendTaskInform($tMessage, $merchant, $isOpen);
+            $hasSend = 1;
+            $noticeWay = 0;
+        } elseif ($informWay == 'sms') {
+            $msg = $data['content'];
+            sms::merchantSend($mobile, $msg, $merchant);
+            $hasSend = 1;
+            $noticeWay = 1;
+        } elseif ($informWay == 'miniProgram') {
+            $tMessage = json_decode($data['tMessage'], true);
+            wxUtil::sendTaskInform($tMessage, $merchant);
+            $hasSend = 1;
+            $noticeWay = 0;
+        } else {
+
+        }
+        //存入数据库
+        $informData = [
+            'adminId' => $adminId,
+            'merchantId' => $merchantId,
+            'noticeType' => 0,
+            'content' => $data['briefContent'],
+            'noticeWay' => $noticeWay,
+            'status' => $hasSend,
+            'sourceType' => 0,
+            'sourceId' => 0,
+            'addTime' => time(),
+            'createTime' => date("Y-m-d H:i:s"),
+        ];
+        InformAdminClass::addData($informData);
+        return true;
+    }
+
 }

+ 25 - 72
biz/message/services/InformAdminService.php

@@ -9,6 +9,7 @@ use biz\admin\services\ShopAdminService;
 use biz\base\services\BaseService;
 use biz\merchant\services\MerchantService;
 use biz\message\classes\InformAdminClass;
+use biz\wx\classes\WxOpenClass;
 use biz\wx\services\WxOpenService;
 use common\components\sms;
 use common\components\util;
@@ -18,79 +19,31 @@ use Yii;
 
 class InformAdminService extends BaseService
 {
-	
-	public static $baseFile = '\biz\message\classes\InformAdminClass';
-	
-	//通知管理员 shish 2020.1.1
-	public static function addInform($shopId, $type, $params)
-	{
-		$shopAdminList = ShopAdminService::getNoticeAdminList($shopId);
-		if (empty($shopAdminList)) {
-			return false;
-		}
-		//本地环境取消通知
-		if (getenv('YII_ENV') == 'local') {
-			return false;
-		}
-		$TMList = TMessageService::getOpenList();
-		foreach ($shopAdminList as $adminKey => $shopAdmin) {
-			InformAdminClass::addInform($params, $shopAdmin, $type, $TMList);
-		}
-	}
 
-	//消费通知内容 shish 2020.1.1
-	//['messageType'=>'inform','informWay'=>'miniProgram','userType'=>'admin','shopAdminId'=>913,'mobile'=>'15280215347','tMessage'=>'','content'=>'','briefContent'=>'','isOpen'=>1]
-	public static function consumeInformQueue($data)
-	{
-		$informWay = $data['informWay'];
-		$shopAdminId = isset($data['shopAdminId']) ? $data['shopAdminId'] : 0;
-		if (empty($shopAdminId)) {
-			echo "\n 没有找到门店管理员 \n";
-			util::end();
-		}
-		$shopAdmin = ShopAdminClass::getById($shopAdminId);
-		$merchantId = $shopAdmin['merchantId'];
-		$adminId = $shopAdmin['adminId'];
-		$mobile = $data['mobile'];
-		$isOpen = isset($data['isOpen']) ? $data['isOpen'] : 0;
-		$merchant = WxOpenService::getWxInfo();
-		$hasSend = 0;
-		$noticeWay = 0;
-		if ($informWay == 'wx') {
-			$tMessage = json_decode($data['tMessage'], true);
-			$r = wxUtil::sendTaskInform($tMessage, $merchant, $isOpen);
-			print_r($r);
-			$hasSend = 1;
-			$noticeWay = 0;
-		} elseif ($informWay == 'sms') {
-			$msg = $data['content'];
-			sms::merchantSend($mobile, $msg, $merchant);
-			$hasSend = 1;
-			$noticeWay = 1;
-		} elseif ($informWay == 'miniProgram') {
-			$tMessage = json_decode($data['tMessage'], true);
-			$r = wxUtil::sendTaskInform($tMessage, $merchant);
-			print_r($r);
-			$hasSend = 1;
-			$noticeWay = 0;
-		} else {
+    public static $baseFile = '\biz\message\classes\InformAdminClass';
 
-		}
-		//存入数据库
-		$informData = [
-			'adminId' => $adminId,
-			'merchantId' => $merchantId,
-			'noticeType' => 0,
-			'content' => $data['briefContent'],
-			'noticeWay' => $noticeWay,
-			'status' => $hasSend,
-			'sourceType' => 0,
-			'sourceId' => 0,
-			'addTime' => time(),
-			'createTime' => date("Y-m-d H:i:s"),
-		];
-		InformAdminClass::addData($informData);
-		return true;
-	}
+    //通知管理员 shish 2020.1.1
+    public static function addInform($shopId, $type, $params)
+    {
+        $shopAdminList = ShopAdminService::getNoticeAdminList($shopId);
+        if (empty($shopAdminList)) {
+            return false;
+        }
+        //本地环境取消通知
+        if (getenv('YII_ENV') == 'local') {
+            return false;
+        }
+        $TMList = TMessageService::getOpenList();
+        foreach ($shopAdminList as $adminKey => $shopAdmin) {
+            InformAdminClass::addInform($params, $shopAdmin, $type, $TMList);
+        }
+    }
+
+    //消费通知内容 shish 2020.1.1
+    //['messageType'=>'inform','informWay'=>'miniProgram','userType'=>'admin','shopAdminId'=>913,'mobile'=>'15280215347','tMessage'=>'','content'=>'','briefContent'=>'','isOpen'=>1]
+    public static function consumeInformQueue($data)
+    {
+        return InformAdminClass::consumeInformQueue($data);
+    }
 
 }