...
|
...
|
@@ -4,6 +4,7 @@ |
|
|
* @date: 19/07/2018
|
|
|
*/
|
|
|
const _ = require('lodash');
|
|
|
const moment = require('moment');
|
|
|
const mysqlCli = global.yoho.utils.mysqlCli;
|
|
|
const MemoryCache = require('../../../utils/memory-cache');
|
|
|
|
...
|
...
|
@@ -20,6 +21,14 @@ const PAGE_SIZE = 10; |
|
|
|
|
|
const userTimesCache = new MemoryCache();
|
|
|
|
|
|
const timeFormat = (time) => {
|
|
|
if (_.isNumber(time)) {
|
|
|
time = moment.unix(time);
|
|
|
}
|
|
|
|
|
|
return moment(time).format('YYYY-MM-DD HH:mm:ss');
|
|
|
};
|
|
|
|
|
|
function handelResult(result) {
|
|
|
return {
|
|
|
code: 200,
|
...
|
...
|
@@ -278,7 +287,9 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
message: '活动已结束或已达人数上限'
|
|
|
};
|
|
|
|
|
|
let status = getActivityStatus(_.get(info, '[0][0]'), _.get(info, '[1].join_num', 0));
|
|
|
let productInfo = _.get(info, '[0][0]');
|
|
|
|
|
|
let status = getActivityStatus(productInfo, _.get(info, '[1].join_num', 0));
|
|
|
|
|
|
if (!status || status >= 3) {
|
|
|
return errorData;
|
...
|
...
|
@@ -292,7 +303,12 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
this.sendPrizeCode(extra.shareUid, actPrizeId, {isShareTake: true});
|
|
|
}
|
|
|
|
|
|
return this.sendPrizeCode(uid, actPrizeId, Object.assign(extra, {isShareTake: false}));
|
|
|
return this.sendPrizeCode(uid, actPrizeId, Object.assign(extra, {
|
|
|
isShareTake: false,
|
|
|
actName: productInfo.name,
|
|
|
actStartTime: productInfo.start_time,
|
|
|
actEndTime: productInfo.end_time
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -409,6 +425,10 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
}
|
|
|
|
|
|
if (_.isNumber(insert)) {
|
|
|
if (userJoinTimes < 1 && extra.actName) {
|
|
|
this.sendWechatMessage(uid, actPrizeId, extra);
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
code: 200,
|
|
|
data: {prizeCode},
|
...
|
...
|
@@ -418,4 +438,26 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
return errorData;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 向用户发送获得抽奖码消息
|
|
|
* @param uid
|
|
|
* @param actPrizeId
|
|
|
* @param extra
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
sendWechatMessage(uid, actPrizeId, extra = {}) {
|
|
|
return this.post({
|
|
|
url: '/yoho-message-controller/MessageRest/sendMessage',
|
|
|
data: {
|
|
|
sendScene: 'MINI_ACTIVITY_JOIN',
|
|
|
params: JSON.stringify({
|
|
|
activityTitle: extra.actName,
|
|
|
activityTime: `${timeFormat(extra.actStartTime)} - ${timeFormat(extra.actEndTime)}`,
|
|
|
pageUrl: '/page/subPackage/pages/zeroSell/detail?actPrizeId=' + actPrizeId
|
|
|
}),
|
|
|
uidList: [uid]
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}; |
...
|
...
|
|