Authored by huangyi

Merge branch 'feature/yohood' of http://git.yoho.cn/fe/yoho-activity-platform into feature/yohood

... ... @@ -13,8 +13,8 @@ const TABLE_ACT_PRIZE_PRODUCT_CONTENT = 'act_prize_product_content';
const TABLE_ACT_PRIZE_PRODUCT_USER = 'act_prize_product_user';
const MINUTE_TIMES = 60;
const PRODUCT_CACHE_TIMES = MINUTE_TIMES * 5; // 商品(列表&详情)缓存时间
const RECENT_CODE_CACHE_TIME = MINUTE_TIMES; // 最近获取记录缓存时间
const PRODUCT_CACHE_TIMES = MINUTE_TIMES / 6; // 商品(列表&详情)缓存时间
const RECENT_CODE_CACHE_TIME = MINUTE_TIMES / 12; // 最近获取记录缓存时间
const MAX_JOIN_TIMES = 5; // 最大活动参与次数
const MAX_RECOMEND_NUM = 10; // 最大推荐活动数目
const PAGE_SIZE = 10;
... ... @@ -303,7 +303,7 @@ module.exports = class extends global.yoho.BaseModel {
let info = await Promise.all([
mysqlCli.query(`select * from ${TABLE_ACT_PRIZE_PRODUCT}
where id = :actPrizeId limit 1;`, {actPrizeId}, {cache: MINUTE_TIMES / 2}),
where id = :actPrizeId limit 1;`, {actPrizeId}, {cache: PRODUCT_CACHE_TIMES}),
this.getUserJoinNum(actPrizeId, true).then(result => {
return result.data;
})
... ...
... ... @@ -199,6 +199,52 @@ const yohood = {
return req.ctx(YohoodModel).getShopProductsByShopId(shopId).then(result => {
return res.json(result);
});
},
async getCoupon(req, res) {
let {uid, couponId} = req.query;
console.log(uid, couponId);
if (!uid || !couponId) {
return res.json({
code: 400,
message: INVALID_PARAMS
});
}
let couponInfo = await req.ctx(YohoodModel).getCouponInfo(couponId);
let couponDetail = await req.ctx(YohoodModel).getCouponDetail(uid, couponId);
// console.log('couponDetail:', couponDetail);
// console.log('couponInfo', couponInfo.data[0].coupon_num);
if (couponDetail.code === 200 && couponDetail.data.length > 0) {
return res.json(couponDetail);
} else if (couponInfo.data[0].coupon_num > 0) {
let getCoupon = await req.ctx(YohoodModel).getOfflineStoreCoupon(uid, couponId);
// console.log('getCoupon:', getCoupon);
if (getCoupon.code === 200) {
couponDetail = await req.ctx(YohoodModel).getCouponDetail(uid, couponId);
return res.json(couponDetail);
} else if (getCoupon.code === 201) {
return res.json(couponDetail);
} else {
return res.json({
code: 203,
message: '领券失败'
});
}
} else {
return res.json({
code: 204,
message: '券已领完'
});
}
}
};
... ...
... ... @@ -2,6 +2,8 @@
* Created by qiujun on 2018/7/19.
*/
const service = global.yoho.StoreAPI;
class YohoodModel extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
... ... @@ -36,6 +38,40 @@ class YohoodModel extends global.yoho.BaseModel {
}
});
}
/**
* 获取线下店优惠券
* @param uid
* @param couponId
*/
async getOfflineStoreCoupon(uid, couponId) {
return await service.get('coupon/sendCoupon.do', {
uid: uid,
couponId: couponId
});
}
/**
* 获取用户下的券信息
* @param uid
* @param couponId
*/
async getCouponDetail(uid, couponId) {
return await service.get('coupon/getCouponDetail.do', {
uid: uid,
couponId: couponId
});
}
/**
* 获取券信息
* @param couponId
*/
async getCouponInfo(couponId) {
return await service.get('coupon/getCoupon.do', {
couponId: couponId
});
}
}
... ...
... ... @@ -44,6 +44,7 @@ router.get('/yohood/getNewsDetail', yohood.getNewsDetail);
router.get('/yohood/getRecommend', yohood.getRecommend);
router.get('/yohood/getResource', yohood.getYohoBuyResource);
router.get('/yohood/getShopProduct', yohood.getYohoBuyShopProduct);
router.get('/yohood/getCoupon', yohood.getCoupon);
// coupon
router.get('/coupon/getCouponList', coupon.couponList);
... ... @@ -51,4 +52,5 @@ router.get('/coupon/getCouponSendFlags', coupon.couponSendFlag);
router.post('/coupon/couponGet', coupon.couponGet);
router.get('/coupon/couponUserOwner', coupon.couponUserOwner);
module.exports = router;
... ...
... ... @@ -25,6 +25,7 @@ module.exports = {
singleApi: 'http://api.yoho.cn/',
api: 'http://api.yoho.cn/',
store: 'http://192.168.102.47:8080/portal-gateway/wechat/',
service: 'http://service.yoho.cn/',
serviceNotify: 'http://service.yoho.cn/',
platformApi: 'http://172.16.6.210:8088/',
... ... @@ -128,6 +129,7 @@ if (isProduction) {
assetUrl: `/yoho-activity-platform/${pkg.version}/`,
domains: {
api: 'http://api.yoho.yohoops.org/',
store: 'https://openstore.yohobuy.com',
service: 'http://api.yoho.yohoops.org/',
global: 'http://api-global.yohobuy.com',
liveApi: 'http://api.live.yoho.cn/',
... ... @@ -184,7 +186,7 @@ if (isProduction) {
api: process.env.TEST_API || 'http://api-test1.yohops.com:9999/',
service: process.env.TEST_SERVICE || 'http://service-test1.yohops.com:9999/',
global: process.env.TEST_GLOBAL || 'http://global-test-soa.yohops.com:9999/',
store: process.env.TEST_STORE || 'http://192.168.102.210:8080/portal-gateway/',
store: process.env.TEST_STORE || 'http://192.168.102.210:8080/portal-gateway/wechat/',
liveApi: process.env.TEST_LIVE || 'http://testapi.live.yohops.com:9999/',
singleApi: process.env.TEST_SINGLE || 'http://api-test1.yohops.com:9999/',
platformApi: 'http://192.168.102.48:8088/'
... ...