Ver Fonte

送达通知

shish há 6 anos atrás
pai
commit
5c04e098e4

+ 3 - 3
biz/admin/classes/AdminClass.php

@@ -44,7 +44,7 @@ class AdminClass extends BaseClass
 			if ($sensitive) {
 				$list[$key]['openId'] = '';
 				$list[$key]['password'] = '';
-				$list[$key]['confirmPassword']='';
+				$list[$key]['confirmPassword'] = '';
 			}
 		}
 		return $list;
@@ -107,7 +107,7 @@ class AdminClass extends BaseClass
 	//获取商家的所有员工 shish 2019.12.9
 	public static function getAdminList($merchantId)
 	{
-		return self::getAllByCondition(['merchantId' => $merchantId], null, '*');
+		return self::getAllByCondition(['merchantId' => $merchantId, 'delStatus' => 0, 'status' => 1], null, '*');
 	}
 	
 	//获取商家所有员工的名字 shish 2019.12.9
@@ -178,7 +178,7 @@ class AdminClass extends BaseClass
 		} else {
 			$data['password'] = password_hash($data['password'], PASSWORD_BCRYPT);
 		}
-
+		
 		$adminName = $data['adminName'];
 		if ($adminName != $admin['adminName']) {
 			$adminNameList = self::getAdminNameList($merchantId);

+ 50 - 0
biz/message/classes/InformAdminClass.php

@@ -2,6 +2,11 @@
 
 namespace biz\message\classes;
 
+use biz\admin\classes\AdminClass;
+use biz\user\classes\UserClass;
+use common\components\httpUtil;
+use common\components\wxUtil;
+use common\services\xhTMessageService;
 use Yii;
 use biz\base\classes\BaseClass;
 
@@ -89,5 +94,50 @@ class InformAdminClass extends BaseClass
 	{
 		self::add($data);
 	}
+
+	//订单完成通知店长 shish 2020.3.19
+	public static function sendComplete($order, $merchant)
+	{
+		$merchantId = $merchant['id'];
+		$adminList = AdminClass::getAdminList($merchantId);
+		if (empty($adminList)) {
+			return false;
+		}
+		$remindUserIds = [];
+		foreach ($adminList as $admin) {
+			$remind = $admin['remind'];
+			if ($remind == 1) {
+				$remindUserIds = $admin['userId'];
+			}
+		}
+		$remindUserIds = array_filter(array_unique($remindUserIds));
+		if (empty($remindUserIds)) {
+			return false;
+		}
+		$userList = UserClass::getByIds($remindUserIds);
+
+		$allTM = xhTMessageService::getList($merchantId);
+		$shortTempId = 'OPENTM201205968';//订单送达通知
+		$tempId = $allTM[$shortTempId];
+
+		foreach ($userList as $user) {
+			if (isset($user['subscribe']) && $user['subscribe'] == 1) {
+				$openId = $user['openId'];
+				$url = Yii::$app->params['bDomain'] . "/#/admin/order/detail?id=" . $order['id'];
+				$url = httpUtil::becomeHttps($url);
+				$data = [
+					"touser" => $openId,
+					"template_id" => $tempId,
+					"url" => $url,
+					"data" => [
+						"first" => ["value" => '客户订单已送达', "color" => "#173177"],
+						"keyword1" => ["value" => (string)$order['orderSn'], "color" => "#173177"],
+						"keyword2" => ["value" => $order['bookName'], "color" => "#173177"],
+						"keyword3" => ["value" => '已送达', "color" => "#173177"],
+						"remark" => ["value" => '', "color" => "#173177"]]];
+				wxUtil::sendTaskInform($data, $merchant);
+			}
+		}
+	}
 	
 }

+ 16 - 12
biz/message/classes/InformUserClass.php

@@ -3,6 +3,7 @@
 namespace biz\message\classes;
 
 use biz\merchant\classes\MerchantClass;
+use common\components\httpUtil;
 use common\components\sms;
 use common\components\stringUtil;
 use common\components\wxUtil;
@@ -16,18 +17,21 @@ class InformUserClass extends BaseClass
 	public static $baseFile = '\biz\message\models\InformUser';
 	
 	//花送到了通知客户 shish
-	public static function sendComplete($user, $order)
+	public static function sendComplete($user, $order, $merchant)
 	{
 		//通知客户
 		$openId = $user['openId'];
-		$merchantId = $user['merchantId'];
-		$merchant = MerchantClass::getById($merchantId);
+		$merchantId = $merchant['id'];
 		if (isset($user['subscribe']) && $user['subscribe'] == 1) {
 			$allTM = xhTMessageService::getList($merchantId);
 			$shortTempId = 'OPENTM201205968';//订单送达通知
 			$tempId = $allTM[$shortTempId];
-			$data = ["touser" => $openId, "template_id" => $tempId,
-				"url" => Yii::$app->params['mDomain'] . "/#/pages/order/detail?id={$order['id']}&account=" . $merchantId,
+			$url = Yii::$app->params['mDomain'] . "/#/pages/order/detail?id={$order['id']}&account=" . $merchantId;
+			$url = httpUtil::becomeHttps($url);
+			$data = [
+				"touser" => $openId,
+				"template_id" => $tempId,
+				"url" => $url,
 				"data" => [
 					"first" => ["value" => '您的订单已送达', "color" => "#173177"],
 					"keyword1" => ["value" => (string)$order['orderSn'], "color" => "#173177"],
@@ -35,15 +39,15 @@ class InformUserClass extends BaseClass
 					"keyword3" => ["value" => '已送达', "color" => "#173177"],
 					"remark" => ["value" => '感谢您惠顾,祝你生活愉快!', "color" => "#173177"]]];
 			wxUtil::sendTaskInform($data, $merchant);
-			return true;
+		} else {
+			if (isset($order['bookMobile']) && !empty($order['bookMobile']) && stringUtil::isMobile($order['bookMobile'])) {
+				$mobile = $order['bookMobile'];
+				$msg = '您的鲜花已送达,感谢惠顾,祝您生活愉快。';
+				sms::send($mobile, $msg, $merchant);
+			}
 		}
 		
-		if (isset($order['bookMobile']) && !empty($order['bookMobile']) && stringUtil::isMobile($order['bookMobile'])) {
-			$mobile = $order['bookMobile'];
-			$msg = '您的鲜花已送达,感谢惠顾,祝您生活愉快。';
-			sms::send($mobile, $msg, $merchant);
-		}
-
+		//通知商家
 	}
 	
 }

+ 7 - 2
biz/order/classes/OrderClass.php

@@ -2,6 +2,8 @@
 
 namespace biz\order\classes;
 
+use biz\merchant\classes\MerchantClass;
+use biz\message\classes\InformAdminClass;
 use biz\message\classes\InformUserClass;
 use biz\stat\classes\StatOrderCountClass;
 use biz\user\classes\UserClass;
@@ -133,7 +135,10 @@ class OrderClass extends BaseClass
 		self::updateById($id, ['status' => OrderClass::ORDER_STATUS_COMPLETE, 'currentFlow' => 4]);
 		$userId = $order['userId'];
 		$user = UserClass::getById($userId);
-		InformUserClass::sendComplete($user,$order);
+		$merchantId = $order['merchantId'];
+		$merchant = MerchantClass::getById($merchantId);
+		InformUserClass::sendComplete($user, $order, $merchant);
+		InformAdminClass::sendComplete($order, $merchant);
 	}
 	
 	//转化出送到时间 shish 2020.3.15
@@ -149,5 +154,5 @@ class OrderClass extends BaseClass
 		}
 		return $reachTime;
 	}
-
+	
 }