|
@@ -4,6 +4,7 @@ |
|
@@ -4,6 +4,7 @@ |
4
|
* @date: 19/07/2018
|
4
|
* @date: 19/07/2018
|
5
|
*/
|
5
|
*/
|
6
|
const _ = require('lodash');
|
6
|
const _ = require('lodash');
|
|
|
7
|
+const moment = require('moment');
|
7
|
const mysqlCli = global.yoho.utils.mysqlCli;
|
8
|
const mysqlCli = global.yoho.utils.mysqlCli;
|
8
|
const MemoryCache = require('../../../utils/memory-cache');
|
9
|
const MemoryCache = require('../../../utils/memory-cache');
|
9
|
|
10
|
|
|
@@ -20,6 +21,14 @@ const PAGE_SIZE = 10; |
|
@@ -20,6 +21,14 @@ const PAGE_SIZE = 10; |
20
|
|
21
|
|
21
|
const userTimesCache = new MemoryCache();
|
22
|
const userTimesCache = new MemoryCache();
|
22
|
|
23
|
|
|
|
24
|
+const timeFormat = (time) => {
|
|
|
25
|
+ if (_.isNumber(time)) {
|
|
|
26
|
+ time = moment.unix(time);
|
|
|
27
|
+ }
|
|
|
28
|
+
|
|
|
29
|
+ return moment(time).format('YYYY-MM-DD HH:mm:ss');
|
|
|
30
|
+};
|
|
|
31
|
+
|
23
|
function handelResult(result) {
|
32
|
function handelResult(result) {
|
24
|
return {
|
33
|
return {
|
25
|
code: 200,
|
34
|
code: 200,
|
|
@@ -278,7 +287,9 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -278,7 +287,9 @@ module.exports = class extends global.yoho.BaseModel { |
278
|
message: '活动已结束或已达人数上限'
|
287
|
message: '活动已结束或已达人数上限'
|
279
|
};
|
288
|
};
|
280
|
|
289
|
|
281
|
- let status = getActivityStatus(_.get(info, '[0][0]'), _.get(info, '[1].join_num', 0));
|
290
|
+ let productInfo = _.get(info, '[0][0]');
|
|
|
291
|
+
|
|
|
292
|
+ let status = getActivityStatus(productInfo, _.get(info, '[1].join_num', 0));
|
282
|
|
293
|
|
283
|
if (!status || status >= 3) {
|
294
|
if (!status || status >= 3) {
|
284
|
return errorData;
|
295
|
return errorData;
|
|
@@ -292,7 +303,12 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -292,7 +303,12 @@ module.exports = class extends global.yoho.BaseModel { |
292
|
this.sendPrizeCode(extra.shareUid, actPrizeId, {isShareTake: true});
|
303
|
this.sendPrizeCode(extra.shareUid, actPrizeId, {isShareTake: true});
|
293
|
}
|
304
|
}
|
294
|
|
305
|
|
295
|
- return this.sendPrizeCode(uid, actPrizeId, Object.assign(extra, {isShareTake: false}));
|
306
|
+ return this.sendPrizeCode(uid, actPrizeId, Object.assign(extra, {
|
|
|
307
|
+ isShareTake: false,
|
|
|
308
|
+ actName: productInfo.name,
|
|
|
309
|
+ actStartTime: productInfo.start_time,
|
|
|
310
|
+ actEndTime: productInfo.end_time
|
|
|
311
|
+ }));
|
296
|
}
|
312
|
}
|
297
|
|
313
|
|
298
|
/**
|
314
|
/**
|
|
@@ -409,6 +425,10 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -409,6 +425,10 @@ module.exports = class extends global.yoho.BaseModel { |
409
|
}
|
425
|
}
|
410
|
|
426
|
|
411
|
if (_.isNumber(insert)) {
|
427
|
if (_.isNumber(insert)) {
|
|
|
428
|
+ if (userJoinTimes < 1 && extra.actName) {
|
|
|
429
|
+ this.sendWechatMessage(uid, actPrizeId, extra);
|
|
|
430
|
+ }
|
|
|
431
|
+
|
412
|
return {
|
432
|
return {
|
413
|
code: 200,
|
433
|
code: 200,
|
414
|
data: {prizeCode},
|
434
|
data: {prizeCode},
|
|
@@ -418,4 +438,26 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -418,4 +438,26 @@ module.exports = class extends global.yoho.BaseModel { |
418
|
return errorData;
|
438
|
return errorData;
|
419
|
}
|
439
|
}
|
420
|
}
|
440
|
}
|
|
|
441
|
+
|
|
|
442
|
+ /**
|
|
|
443
|
+ * 向用户发送获得抽奖码消息
|
|
|
444
|
+ * @param uid
|
|
|
445
|
+ * @param actPrizeId
|
|
|
446
|
+ * @param extra
|
|
|
447
|
+ * @returns {*}
|
|
|
448
|
+ */
|
|
|
449
|
+ sendWechatMessage(uid, actPrizeId, extra = {}) {
|
|
|
450
|
+ return this.post({
|
|
|
451
|
+ url: '/yoho-message-controller/MessageRest/sendMessage',
|
|
|
452
|
+ data: {
|
|
|
453
|
+ sendScene: 'MINI_ACTIVITY_JOIN',
|
|
|
454
|
+ params: JSON.stringify({
|
|
|
455
|
+ activityTitle: extra.actName,
|
|
|
456
|
+ activityTime: `${timeFormat(extra.actStartTime)} - ${timeFormat(extra.actEndTime)}`,
|
|
|
457
|
+ pageUrl: '/page/subPackage/pages/zeroSell/detail?actPrizeId=' + actPrizeId
|
|
|
458
|
+ }),
|
|
|
459
|
+ uidList: [uid]
|
|
|
460
|
+ }
|
|
|
461
|
+ });
|
|
|
462
|
+ }
|
421
|
}; |
463
|
}; |