shish 6 gadi atpakaļ
vecāks
revīzija
14c67ab8c1

+ 19 - 17
biz/coupon/classes/CouponAssetClass.php

@@ -51,26 +51,28 @@ class CouponAssetClass extends BaseClass
 				$addData['createTime'] = $date;
 				CouponClass::add($addData);
 				if (isset($user['subscribe']) && $user['subscribe'] == 1) {
-					$allTM = xhTMessageService::getList($merchantId);
+					$tm = xhTMessageService::getList($merchantId);
 					$shortTempId = 'OPENTM207422813';//收入提醒
-					$tempId = $allTM[$shortTempId];
-					$openId = $user['openId'];
-					$data = [
-						"touser" => $openId,
-						"template_id" => $tempId,
-						"url" => Yii::$app->params['mallDomain'] . '/center/coupon?account=' . $merchantId,
-						"data" => [
-							"first" => ["value" => "送您一张代金劵。", "color" => "#173177"],
-							"keyword1" => ["value" => '代金劵', "color" => "#173177"],
-							"keyword2" => ["value" => $amount . '元', "color" => "#173177"],
-							"keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
-							"remark" => ["value" => "点击查看详情", "color" => "#173177"]
-						]
-					];
-					wxUtil::sendTaskInform($data, $merchant);
+					$tempId = isset($tm[$shortTempId]) ? $tm[$shortTempId] : '';
+					$openId = isset($user['openId']) ? $user['openId'] : '';
+					if (!empty($tempId) && !empty($openId)) {
+						$data = [
+							"touser" => $openId,
+							"template_id" => $tempId,
+							"url" => Yii::$app->params['mallDomain'] . '/center/coupon?account=' . $merchantId,
+							"data" => [
+								"first" => ["value" => "送您一张代金劵。", "color" => "#173177"],
+								"keyword1" => ["value" => '代金劵', "color" => "#173177"],
+								"keyword2" => ["value" => $amount . '元', "color" => "#173177"],
+								"keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
+								"remark" => ["value" => "点击查看详情", "color" => "#173177"]
+							]
+						];
+						wxUtil::sendTaskInform($data, $merchant);
+					}
 				}
 			}
 		}
 	}
-	
+
 }

+ 1 - 1
common/services/xhTMessageService.php

@@ -23,7 +23,7 @@ class xhTMessageService
 		}
 		return $list;
 	}
-	
+
 	public static function add($data)
 	{
 		$tm = xhTMessage::add($data);