summer-web.js
3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
var couponModel = require('../../models/coupon'),
cookie = require('../../util/cookie'),
errUtil = require('../../util/error'),
msgModel = require('../../models/message');
/**
* 夏季领券第一波
*/
exports.first = (req, res) => {
var renderData = {
layout: false, // 原有活动移植,忽略公有模板
module: 'coupon/summer-1-web',
title: 'YOHO!BUY有货【夏日新品节】',
couponUrl: 'http://www.yohobuy.com/home/coupons', // 个人中心优惠券
banner: {
img: 'http://img01.yohoboys.com/staticimg/2016/04/08/18/01c4a1c0eab42c0df420ae91a63bd855ed.jpg',
url: 'http://www.yohobuy.com/special_14838_0411PCHOME.html'
}
};
var uid = cookie.getUid(req);
var couponId = res.app.locals.proEnv ? '20455,20457,20459' : '12463,12461,12459';
renderData.activityId = res.app.locals.proEnv ? 564 : 499;
couponModel({
uid: uid,
couponId: couponId.split(',')
}).then((couponData) => {
var couponInfo = JSON.parse(couponData[0]);
if (couponData.length && couponInfo.code === 200) {
// 发送站内信有问题
msgModel.sendSingleMessage({
uid: uid,
title: '【优惠券】您有3张夏日新品节优惠券。',
content: '尊敬的客户:恭喜您成功获得3张夏日新品节优惠券 !您可以在个人中心查看优惠券详情。'
});
}
return couponData;
}).then((couponData) => {
var couponInfo = JSON.parse(couponData[0]);
if (couponInfo.code === 401) {
renderData.geted = true;
}
if (couponInfo.code !== 401 && couponInfo.code !== 200) {
renderData.fail = true;
}
res.render('coupon/summer/index-web', renderData); // 渲染页面
}).catch((err) => {
errUtil.webError(err, res); // 抓取 Promise 链的错误
});
};
/**
* 夏季领券第二波
*/
exports.second = (req, res) => {
var renderData = {
layout: false, // 原有活动移植,忽略公有模板
module: 'coupon/summer-2-web',
title: 'YOHO!BUY有货【夏日新品节】',
couponUrl: 'http://www.yohobuy.com/home/coupons', // 个人中心优惠券
banner: {
img: 'http://img01.yohoboys.com/staticimg/2016/04/15/14/019e7f29f91b86847fe0afbba9d2e0a91a.jpg',
url: 'http://www.yohobuy.com/special_14964_0418PCHOME.html'
}
};
var uid = cookie.getUid(req);
var couponId = res.app.locals.proEnv ? '20989,20991,20993' : '12503,12505,12507';
renderData.activityId = res.app.locals.proEnv ? 580 : 499; // 正式活动 ID 580
couponModel({
uid: uid,
couponId: couponId.split(',')
}).then((couponData) => {
var couponInfo = JSON.parse(couponData[0]);
if (couponData.length && couponInfo.code === 200) {
// 发送站内信有问题
msgModel.sendSingleMessage({
uid: uid,
title: '【优惠券】您有3张夏日新品节优惠券。',
content: '尊敬的客户:恭喜您成功获得3张夏日新品节优惠券 !您可以在个人中心查看优惠券详情。'
});
}
return couponData;
}).then((couponData) => {
var couponInfo = JSON.parse(couponData[0]);
if (couponInfo.code === 401) {
renderData.geted = true;
}
if (couponInfo.code !== 401 && couponInfo.code !== 200) {
renderData.fail = true;
}
res.render('coupon/summer/index-web', renderData); // 渲染页面
}).catch((err) => {
errUtil.webError(err, res); // 抓取 Promise 链的错误
});
};