|
|
const _ = require('lodash');
|
|
|
const aes = require('../../../utils/aes');
|
|
|
const logger = global.yoho.logger;
|
|
|
const UfoApi = global.yoho.UfoAPI;
|
|
|
const _sender = global.yoho.sender;
|
|
|
const mysqlCli = global.yoho.utils.mysqlCli;
|
|
|
|
...
|
...
|
@@ -45,7 +46,8 @@ const prizeType = { |
|
|
1: '谢谢惠顾',
|
|
|
2: '红包',
|
|
|
3: '优惠券',
|
|
|
4: '实物奖品'
|
|
|
4: '实物奖品',
|
|
|
5: 'UFO优惠券'
|
|
|
};
|
|
|
|
|
|
class ActWheelSurfModelRedis extends global.yoho.BaseModel {
|
...
|
...
|
@@ -289,6 +291,7 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel { |
|
|
sendResult.data = sendResult.data || {};
|
|
|
sendMessage(0, {}, {succeedTimes: sendResult.data.amount || 0}, 0);
|
|
|
|
|
|
logger.info(`app.redpac.addRedpac=>uid: ${uid}, ${JSON.stringify(sendResult || {})}`);
|
|
|
if (sendResult.code === 200) {
|
|
|
if (!sendResult.data.amount) {
|
|
|
sendResult.code = 201; // 重复领取
|
...
|
...
|
@@ -312,6 +315,7 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel { |
|
|
|
|
|
sendMessage(1, {}, {succeedTimes: 1}, 0);
|
|
|
|
|
|
logger.info(`app.coupons.couponsSend=>uid: ${uid}, ${JSON.stringify(sendResult || {})}`);
|
|
|
if (sendResult && sendResult.code === 200) {
|
|
|
getPrize.desc = '恭喜您获得' + getPrize.name + '优惠券';
|
|
|
}
|
...
|
...
|
@@ -323,6 +327,31 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel { |
|
|
} else if (getPrize.type === 4) {
|
|
|
sendResult.code = 200;
|
|
|
getPrize.desc = '恭喜您获得' + getPrize.name;
|
|
|
} else if (getPrize.type === 5) {
|
|
|
// ufo优惠券
|
|
|
try {
|
|
|
sendResult = await this.get({
|
|
|
url: 'coupon',
|
|
|
data: {
|
|
|
method: 'ufo.coupons.send',
|
|
|
uid: uid,
|
|
|
coupon_tokens: getPrize.value,
|
|
|
sendType: 2
|
|
|
},
|
|
|
api: UfoApi
|
|
|
});
|
|
|
|
|
|
sendMessage(1, {}, {succeedTimes: 1}, 0);
|
|
|
|
|
|
logger.info(`ufo.coupons.send=>uid: ${uid}, ${JSON.stringify(sendResult || {})}`);
|
|
|
if (sendResult && sendResult.code === 200) {
|
|
|
getPrize.desc = '恭喜您获得' + getPrize.name + '优惠券';
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
|
logger.error(e);
|
|
|
sendMessage(1, {}, {message: e.message || 'interface error', stack: e}, 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 插入数据库
|
...
|
...
|
|