shish hace 6 años
padre
commit
be7df18ce2

+ 66 - 4
biz/message/classes/InformAdminClass.php

@@ -10,11 +10,11 @@ class InformAdminClass extends BaseClass
 	
 	public static $baseFile = '\biz\message\models\InformAdmin';
 	
-	
 	//宝贝售出通知 shish 2019.12.24
 	public static function goodsSoldInformAdmin($params, $informWay = 0, $TMList = [])
 	{
-		if ($informWay == 0) {
+		$params = [];
+		if ($informWay == 'wx') {
 			//收入提醒
 			$shortTempId = 'OPENTM207422813';
 			$tempId = isset($TMList[$shortTempId]) ? $TMList[$shortTempId] : '';
@@ -27,7 +27,8 @@ class InformAdminClass extends BaseClass
 				"keyword5" => ["value" => $userName, "color" => "#173177"],
 				"remark" => ["value" => '点此查看详细、编辑收花人信息。', "color" => "#173177"]]];
 			return $tmData;
-		} else {
+		}
+		if ($informWay == 'sms') {
 			return "客户" . $userName . "付款" . $totalFee . '元';
 		}
 	}
@@ -43,5 +44,66 @@ class InformAdminClass extends BaseClass
 		}
 		return $respond;
 	}
-
+	
+	//门店收入提醒 shish 2019.12.24
+	public static function shopIncomeInformAdmin2($data, $merchantId = 0)
+	{
+		$TMList = xhTMessageService::getList($merchantId);
+		$adminList = AdminClass::getAllNoticeAdmin($merchantId);
+		$merchant = MerchantService::getById($merchantId);
+		$shortTempId = 'OPENTM207422813';//收入提醒
+		if (isset($TMList[$shortTempId]) == false) {
+			util::fail('没有找到公众号的消息模样:' . $shortTempId);
+		}
+		$tempId = $TMList[$shortTempId];
+		foreach ($adminList as $adminKey => $admin) {
+			$openId = $admin['openId'];
+			if (!empty($openId) && $admin['subscribe'] == 1) {
+				$data = ["touser" => $openId, "template_id" => $tempId,
+					"url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderId, "data" => [
+						"first" => ["value" => $userName . $payWay . '付款', "color" => "#173177"],
+						"keyword1" => ["value" => $totalFee . '元', "color" => "#173177"],
+						"keyword2" => ["value" => '客户付款', "color" => "#173177"],
+						"keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
+						"remark" => ["value" => "点击查看明细", "color" => "#173177"]]];
+				$respond = weixinUtil::sendTaskInform($data, $merchant);
+				Yii::info('tm:' . json_encode($respond));
+			} else {
+				$mobile = $admin['mobile'];
+				$msg = "客户" . $userName . "付款" . $totalFee . '元';
+				sms::merchantSend($mobile, $msg, $merchant);
+			}
+		}
+	}
+	
+	//宝贝售出通知 shish 2019.12.24
+	public static function goodsSoldInformAdmin2($merchantId)
+	{
+		
+		$TMList = xhTMessageService::getList($merchantId);
+		$merchant = MerchantService::getById($merchantId);
+		$shortTempId = 'OPENTM207422813';//收入提醒
+		$tempId = isset($TMList[$shortTempId]) ? $TMList[$shortTempId] : '';
+		foreach ($adminList as $adminKey => $admin) {
+			$openId = $admin['openId'];
+			if (!empty($openId) && $admin['subscribe'] == 1) {
+				$sendData = ["touser" => $openId, "template_id" => $tempId, "url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderId, "data" => [
+					"first" => ["value" => '您有宝贝售出哦!', "color" => "#173177"],
+					"keyword1" => ["value" => (string)$orderId, "color" => "#173177"],
+					"keyword2" => ["value" => $orderName, "color" => "#173177"],
+					"keyword3" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
+					"keyword4" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
+					"keyword5" => ["value" => $userName, "color" => "#173177"],
+					"remark" => ["value" => '点此查看详细、编辑收花人信息。', "color" => "#173177"]]];
+				$respond = weixinUtil::sendTaskInform($sendData, $merchant);
+				Yii::info('tm:' . json_encode($respond));
+			} else {
+				$mobile = $admin['mobile'];
+				$msg = "客户" . $userName . "付款" . $totalFee . '元';
+				sms::merchantSend($mobile, $msg, $merchant);
+			}
+		}
+	}
+	
+	
 }

+ 5 - 70
biz/message/services/InformAdminService.php

@@ -3,23 +3,20 @@
 namespace biz\message\services;
 
 use biz\admin\classes\AdminClass;
-use biz\admin\services\AdminService;
 use biz\base\services\BaseService;
 use biz\merchant\services\MerchantService;
 use biz\message\classes\InformAdminClass;
 use common\components\sms;
-use common\components\util;
 use common\components\weixinUtil;
 use common\services\xhTMessageService;
 use Yii;
-use linslin\yii2\curl;
 
 class InformAdminService extends BaseService
 {
 
 	public static $baseFile = '\biz\message\classes\InformAdminClass';
 
-	//通知
+	//通知到员工 shish 2020.1.1
 	public static function inform($merchantId, $type, $params)
 	{
 		$adminList = AdminClass::getAllNoticeAdmin($merchantId);
@@ -30,78 +27,16 @@ class InformAdminService extends BaseService
 		$merchant = MerchantService::getById($merchantId);
 		foreach ($adminList as $adminKey => $admin) {
 			$openId = $admin['openId'];
+			$informWay = !empty($openId) && $admin['subscribe'] == 1 ? 'wx' : 'sms';
+			$sendData = InformAdminClass::inform($params, $type, $informWay, $TMList);
 			if (!empty($openId) && $admin['subscribe'] == 1) {
-				$tmData = InformAdminClass::inform($params, $type, 0, $TMList);
-				$respond = weixinUtil::sendTaskInform($tmData, $merchant);
+				$respond = weixinUtil::sendTaskInform($sendData, $merchant);
 				Yii::info('tm:' . json_encode($respond));
 			} else {
 				$mobile = $admin['mobile'];
-				$msg = InformAdminClass::inform($params, $type, 1);
-				sms::merchantSend($mobile, $msg, $merchant);
+				sms::merchantSend($mobile, $sendData, $merchant);
 			}
 		}
 	}
-
-	//门店收入提醒 shish 2019.12.24
-	public static function shopIncomeInformAdmin($data, $merchantId = 0)
-	{
-		$TMList = xhTMessageService::getList($merchantId);
-		$adminList = AdminClass::getAllNoticeAdmin($merchantId);
-		$merchant = MerchantService::getById($merchantId);
-		$shortTempId = 'OPENTM207422813';//收入提醒
-		if (isset($TMList[$shortTempId]) == false) {
-			util::fail('没有找到公众号的消息模样:' . $shortTempId);
-		}
-		$tempId = $TMList[$shortTempId];
-		foreach ($adminList as $adminKey => $admin) {
-			$openId = $admin['openId'];
-			if (!empty($openId) && $admin['subscribe'] == 1) {
-				$data = ["touser" => $openId, "template_id" => $tempId,
-					"url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderId, "data" => [
-						"first" => ["value" => $userName . $payWay . '付款', "color" => "#173177"],
-						"keyword1" => ["value" => $totalFee . '元', "color" => "#173177"],
-						"keyword2" => ["value" => '客户付款', "color" => "#173177"],
-						"keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
-						"remark" => ["value" => "点击查看明细", "color" => "#173177"]]];
-				$respond = weixinUtil::sendTaskInform($data, $merchant);
-				Yii::info('tm:' . json_encode($respond));
-			} else {
-				$mobile = $admin['mobile'];
-				$msg = "客户" . $userName . "付款" . $totalFee . '元';
-				sms::merchantSend($mobile, $msg, $merchant);
-			}
-		}
-	}
-	
-	//宝贝售出通知 shish 2019.12.24
-	public static function goodsSoldInformAdmin($merchantId)
-	{
-		
-		$TMList = xhTMessageService::getList($merchantId);
-		$merchant = MerchantService::getById($merchantId);
-		$shortTempId = 'OPENTM207422813';//收入提醒
-		$tempId = isset($TMList[$shortTempId]) ? $TMList[$shortTempId] : '';
-		foreach ($adminList as $adminKey => $admin) {
-			$openId = $admin['openId'];
-			if (!empty($openId) && $admin['subscribe'] == 1) {
-				$tmData = ["touser" => $openId, "template_id" => $tempId, "url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderId, "data" => [
-					"first" => ["value" => '您有宝贝售出哦!', "color" => "#173177"],
-					"keyword1" => ["value" => (string)$orderId, "color" => "#173177"],
-					"keyword2" => ["value" => $orderName, "color" => "#173177"],
-					"keyword3" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
-					"keyword4" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
-					"keyword5" => ["value" => $userName, "color" => "#173177"],
-					"remark" => ["value" => '点此查看详细、编辑收花人信息。', "color" => "#173177"]]];
-				$respond = weixinUtil::sendTaskInform($tmData, $merchant);
-				Yii::info('tm:' . json_encode($respond));
-			} else {
-				$mobile = $admin['mobile'];
-				$msg = "客户" . $userName . "付款" . $totalFee . '元';
-				sms::merchantSend($mobile, $msg, $merchant);
-			}
-		}
-	}
-	
-
 	
 }