...
|
...
|
@@ -64,27 +64,64 @@ exports.getCouponData = (channel, params) => { |
|
|
};
|
|
|
|
|
|
val.data.forEach(function(item) {
|
|
|
const cou = {
|
|
|
obj.coupons.push({
|
|
|
id: crypto.encryption('yoho9646abcdefgh', item.couponID), // 加密优惠券号
|
|
|
img: helpers.image(item.image.src, 0, 0), // 优惠券图片
|
|
|
url: item.image.url.replace('http:', '') // 去逛逛链接
|
|
|
};
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 领取状态判断
|
|
|
switch (item.status) {
|
|
|
case 3:
|
|
|
cou.got = true; // 优惠券已领取
|
|
|
break;
|
|
|
case 2:
|
|
|
result.categories.push(obj);
|
|
|
i++;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
while (false);
|
|
|
return result;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
exports.getCouponStatus = (params) => {
|
|
|
return Promise.coroutine(function*() {
|
|
|
const coupon = yield api.get('', Object.assign(params, {
|
|
|
method: 'app.promotion.queryCouponCenter'
|
|
|
}));
|
|
|
const result = {
|
|
|
code: coupon.code,
|
|
|
categories: []
|
|
|
};
|
|
|
|
|
|
do {
|
|
|
if (!coupon.data || !Array.isArray(coupon.data) || coupon.data.length === 0) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
let i = 0;
|
|
|
|
|
|
coupon.data.forEach(function(val, index) {
|
|
|
if (val.template_name === 'getCoupon') {
|
|
|
// 优惠券楼层
|
|
|
if (!coupon.data[index - 1].data || !coupon.data[index - 1].data.text) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
val.data.forEach(function(item) {
|
|
|
const status = Number(item.status);
|
|
|
|
|
|
if ([2, 3].indexOf(status) > -1) {
|
|
|
const cou = {
|
|
|
id: crypto.encryption('yoho9646abcdefgh', item.couponID) // 加密优惠券号
|
|
|
};
|
|
|
|
|
|
if (status === 2) {
|
|
|
cou.empty = true; // 优惠券已抢光
|
|
|
break;
|
|
|
default:
|
|
|
cou.normal = true; // 可领取优惠券
|
|
|
} else if (status === 3) {
|
|
|
cou.got = true; // 优惠券已领取
|
|
|
}
|
|
|
|
|
|
result.categories.push(cou);
|
|
|
}
|
|
|
obj.coupons.push(cou);
|
|
|
});
|
|
|
|
|
|
result.categories.push(obj);
|
|
|
i++;
|
|
|
}
|
|
|
});
|
...
|
...
|
|