...
|
...
|
@@ -2,7 +2,10 @@ |
|
|
const _ = require('lodash');
|
|
|
const api = global.yoho.API;
|
|
|
const UfoApi = global.yoho.UfoAPI;
|
|
|
const StoreApi = global.yoho.StoreAPI;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const crypto = global.yoho.crypto;
|
|
|
const cache = global.yoho.cache.master;
|
|
|
const yasProcess = require('../../../utils/yas-process');
|
|
|
|
|
|
class featureModel extends global.yoho.BaseModel {
|
...
|
...
|
@@ -653,6 +656,73 @@ class featureModel extends global.yoho.BaseModel { |
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 线下门店体验券
|
|
|
* @param uid
|
|
|
* @param token
|
|
|
*/
|
|
|
async couponSendStoreTrial(uid, token) {
|
|
|
let code;
|
|
|
|
|
|
try {
|
|
|
code = crypto.decrypt('yoho9646__coupon', decodeURIComponent(token));
|
|
|
code = _.trim(code).split('::');
|
|
|
} catch (e) {}// eslint-disable-line
|
|
|
|
|
|
if (!code || !code[2]) {
|
|
|
return {
|
|
|
code: 400,
|
|
|
message: '获取优惠券信息失败,请稍后重试'
|
|
|
};
|
|
|
}
|
|
|
|
|
|
let key = `activityStoreTrialCoupon:${code[0]}:${uid}:${code[1]}`;
|
|
|
|
|
|
const getStatus = await cache.getAsync(key);
|
|
|
|
|
|
if (getStatus) {
|
|
|
return {
|
|
|
code: 400,
|
|
|
message: '您已领过该优惠券'
|
|
|
};
|
|
|
}
|
|
|
|
|
|
let apis = [];
|
|
|
|
|
|
code[2].split(',').forEach(id => {
|
|
|
apis.push(this.get({
|
|
|
url: 'coupon/sendCouponForMars.do',
|
|
|
data: {
|
|
|
uid,
|
|
|
couponId: id
|
|
|
},
|
|
|
api: StoreApi
|
|
|
}));
|
|
|
});
|
|
|
|
|
|
let res = await Promise.all(apis);
|
|
|
let pass = false;
|
|
|
let errMsg = '领取失败';
|
|
|
|
|
|
res.forEach(r => {
|
|
|
if (r.code === 200) {
|
|
|
pass = true;
|
|
|
} else {
|
|
|
r.message && (errMsg = r.message);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
cache.setAsync(key, JSON.stringify({
|
|
|
time: Date.parse(new Date())
|
|
|
}), 30 * 12 * 60 * 60);
|
|
|
|
|
|
return {
|
|
|
code: pass ? 200 : 400,
|
|
|
message: pass ? '领取成功' : errMsg
|
|
|
};
|
|
|
}
|
|
|
|
|
|
getTplPraiseInfo(ids, udid) {
|
|
|
return this.get({
|
|
|
data: {
|
...
|
...
|
|