Authored by yyq

Merge branch 'feature/1215' into release/6.9.17

... ... @@ -103,9 +103,20 @@ exports.couponSend = (req, res, next) => {
if (uid === '' || uid === 0 || token === '' || token === 0) {
return res.jsonp(resultData);
}
const promise = couponType === 'ufo' ?
req.ctx(model).couponSendUFO(uid, token) :
req.ctx(model).couponSend(uid, token);
let promise;
switch (couponType) {
case 'storeTrial':
promise = req.ctx(model).couponSendStoreTrial(uid, token);
break;
case 'ufo':
promise = req.ctx(model).couponSendUFO(uid, token);
break;
default:
promise = req.ctx(model).couponSend(uid, token);
break;
}
promise.then(result => {
res.set({
... ... @@ -182,6 +193,11 @@ exports.couponCheckMiddle = (req, res, next) => {
data: ''
};
if (couponType === 'storeTrial') {
req.couponCheckRequired = false;
return next();
}
if (token === '' || token === 0) {
return res.jsonp(resultData);
}
... ...
... ... @@ -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: {
... ...
... ... @@ -23,6 +23,7 @@ let _getProduct = function(o) {
sales_price: o.collage_price || o.sales_price, // 新需求,如果有拼团价则优先显示拼团价格
cn_alphabet: o.cn_alphabet,
default_images: o.default_images,
total_sales_num: o.total_sales_num || 0,
goods_id: Array.isArray(o.goods_list) && o.goods_list.length ? o.goods_list[0].goods_id : void 0
};
... ...
... ... @@ -38,7 +38,7 @@ const domains = {
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api',
global: 'http://api-global.yohobuy.com',
store: 'http://192.168.102.47:8080/portal-gateway/',
store: 'http://192.168.102.47:8080/portal-gateway/wechat/',
platformApi: 'http://192.168.102.48:8088/',
extstore: 'http://extstore.yohobuy.com',
... ...