Authored by hongyong.zhao

发送微信模板消息添加按渠道发送不同miniapptype

... ... @@ -583,6 +583,7 @@ module.exports = class extends global.yoho.BaseModel {
data: Object.assign({
method: 'wechat.message.send',
sendScene: 'MINI_ACTIVITY_JOIN',
miniAppType: +extra.miniAppType,
params: JSON.stringify({
activityTitle: extra.actName,
activityTime: `${timeFormat(extra.actStartTime)} - ${timeFormat(extra.actEndTime)}`,
... ...
... ... @@ -60,10 +60,11 @@ const zeroBuy = {
zeroBuyPublish(req, res, next) {
let ctx = req.ctx(ActivityModel);
let id = req.body.id;
let channel = req.body.channel;
ctx.editZerobuyStatus(id, 2).then(result => {
if (result.code === 200) {
ctx.sendWechatMessage(id);
ctx.sendWechatMessage(id, channel);
}
res.json(result);
... ...
... ... @@ -714,7 +714,8 @@ class AdminModel extends global.yoho.BaseModel {
* @param id
* @returns {*}
*/
async sendWechatMessage(id) {
async sendWechatMessage(id, channel = 0) {
let info = await Promise.all([
mysqlCli.query(`select name from ${TABLE_ACT_PRIZE_PRODUCT}
where id = :id limit 1`, {id}),
... ... @@ -722,6 +723,7 @@ class AdminModel extends global.yoho.BaseModel {
where act_prize_id = :id`, {id})
]);
let productInfo = _.get(info, '[0][0]');
let userList = [];
... ... @@ -735,10 +737,11 @@ class AdminModel extends global.yoho.BaseModel {
let msgData = {
method: 'wechat.message.send',
sendScene: 'MINI_WINNING_NOTICE',
miniAppType: (channel === 1 ? 63 : 29),
params: JSON.stringify({
activityTitle: productInfo.name,
activityTime: moment().format('YYYY-MM-DD HH:mm') + ':00',
pageUrl: 'page/subPackage/pages/zeroSell/detail?actPrizeId=' + id
pageUrl: 'pages/zeroSell/detail?actPrizeId=' + id
})
};
... ...
... ... @@ -58,7 +58,7 @@
</td>
<td class="text-center">
{{# btns}}
<button class="btn btn-{{color}} btn-{{type}}" data-id="{{../id}}">{{name}}</button>
<button class="btn btn-{{color}} btn-{{type}}" data-id="{{../id}}" data-channel="{{../channel}}">{{name}}</button>
{{/ btns}}
</td>
</tr>
... ...
... ... @@ -66,7 +66,8 @@ function bindListPageEvent() {
method: 'post',
url: '/admin/activity/zerobuy/publish',
data: {
id: $confirm.data('id')
id: $confirm.data('id'),
channel: $confirm.data('channel')
}
}).then(res => {
if (res.code === 200) {
... ... @@ -87,6 +88,7 @@ function bindListPageEvent() {
$('.btn-export').on('click', exportFn);
$('.btn-publish').on('click', function() {
$confirm.data('id', $(this).data('id'));
$confirm.data('channel', $(this).data('channel'))
$confirm.modal('show');
});
$('.sure-publish-btn').on('click', publishFn);
... ...