|
|
@@ -10,9 +10,7 @@ use common\components\configDict;
|
|
|
class xhTMessageService
|
|
|
{
|
|
|
|
|
|
- /**
|
|
|
- * 取所有的模板消息
|
|
|
- */
|
|
|
+ //取所有的模板消息
|
|
|
public static function getList($merchantId)
|
|
|
{
|
|
|
$tm = xhTMessage::getAllByCondition(['merchantId' => $merchantId]);
|
|
|
@@ -22,7 +20,6 @@ class xhTMessageService
|
|
|
$list[$val['shortTemplateId']] = $val['templateId'];
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return $list;
|
|
|
}
|
|
|
|
|
|
@@ -30,44 +27,25 @@ class xhTMessageService
|
|
|
{
|
|
|
$tm = xhTMessage::add($data);
|
|
|
$merchantId = isset($tm['merchantId']) ? $tm['merchantId'] : 0;
|
|
|
- self::refresh($merchantId);
|
|
|
return $tm;
|
|
|
}
|
|
|
|
|
|
public static function batch_add($data, $merchantId)
|
|
|
{
|
|
|
xhTMessage::batchAdd($data);
|
|
|
- self::refresh($merchantId);
|
|
|
}
|
|
|
|
|
|
public static function delByMerchantId($merchantId)
|
|
|
{
|
|
|
xhTMessage::deleteByCondition(['merchantId' => $merchantId]);
|
|
|
- self::refresh($merchantId);
|
|
|
}
|
|
|
|
|
|
- public static function refresh($merchantId)
|
|
|
- {
|
|
|
- $cacheKey = configDict::getCacheKey('tMessage') . $merchantId;
|
|
|
- Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
|
|
|
- $tm = xhTMessage::getAllByCondition(['merchantId' => $merchantId]);
|
|
|
- $list = [];
|
|
|
- if (!empty($tm)) {
|
|
|
- foreach ($tm as $val) {
|
|
|
- $list[$val['shortTemplateId']] = $val['templateId'];
|
|
|
- }
|
|
|
- }
|
|
|
- $sring = json_encode($list);
|
|
|
- Yii::$app->redis->executeCommand('SET', [$cacheKey, $sring]);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 初始化 商家 的模板消息
|
|
|
- */
|
|
|
+ //商家模板初始化 shish 2020.2.9
|
|
|
public static function init($merchant)
|
|
|
{
|
|
|
+ //设置模板消息所属行业 IT科技 互联网/电子商务 消费品 消费品
|
|
|
+ wxUtil::setTMIndustry($merchant, 1, 31);
|
|
|
$merchantId = $merchant['id'];
|
|
|
- wxUtil::setTMIndustry($merchant, 1, 31);//设置模板消息所属行业 IT科技 互联网/电子商务 消费品 消费品
|
|
|
$original = configDict::getConfig('tMessage');
|
|
|
if (!empty($original)) {
|
|
|
$preTMessage = wxUtil::getAllTMessage($merchant);//删除原有的
|
|
|
@@ -100,7 +78,7 @@ class xhTMessageService
|
|
|
}
|
|
|
self::batch_add($batchData, $merchantId);
|
|
|
}
|
|
|
- xhMerchantExtendService::updateByMerchantId($merchantId, ['wxTMessageInit' => 1]);//完成初始化
|
|
|
+ xhMerchantExtendService::updateByMerchantId($merchantId, ['wxTMessageInit' => 1]);
|
|
|
}
|
|
|
|
|
|
//发送到手机上 shish 2019.8.11
|
|
|
@@ -121,9 +99,7 @@ class xhTMessageService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 发送链接到手机上
|
|
|
- */
|
|
|
+ //发送链接到手机上
|
|
|
public static function sendUrl($url, $name = '访问链接', $merchant, $admin)
|
|
|
{
|
|
|
$merchantId = $merchant['id'];
|
|
|
@@ -142,6 +118,7 @@ class xhTMessageService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //补充缺失的模板 shish 2020.2.9
|
|
|
public static function supplement($merchant)
|
|
|
{
|
|
|
$merchantId = $merchant['id'];
|