...
|
...
|
@@ -9,6 +9,7 @@ const mRoot = '../models'; |
|
|
const headerModel = require('../../../doraemon/models/header');
|
|
|
const listModel = require(`${mRoot}/list`);
|
|
|
const _ = require('lodash');
|
|
|
const crypto = global.yoho.crypto;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -390,25 +391,37 @@ const userCoupon = (req, res, next) => { |
|
|
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
|
|
|
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
|
|
|
|
|
if (!req.body.couponID) {
|
|
|
if (!req.query.couponID) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let cryptCouponId = crypto.decrypt('', req.query.couponID);
|
|
|
|
|
|
if (req.user.uid) {
|
|
|
listModel.receiveCoupon(
|
|
|
req.user.uid,
|
|
|
crypto.decrypt('', req.body.couponID)
|
|
|
).then(result => {
|
|
|
req.json(result);
|
|
|
});
|
|
|
req.user.uid,
|
|
|
cryptCouponId
|
|
|
).then(result => {
|
|
|
res.json(result);
|
|
|
}).catch(next);
|
|
|
} else {
|
|
|
|
|
|
// TODO TAR
|
|
|
let toUrl = '';
|
|
|
let refer = req.headers.Referer || req.headers.origin;
|
|
|
let toUrl = helpers.urlFormat('/signin.html', {refer: refer});
|
|
|
|
|
|
if (req.yoho.isApp) {
|
|
|
toUrl += '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' +
|
|
|
refer +
|
|
|
'","param":{}},"requesturl":{"param":{"method":"app.promotion.getCoupon","couponId":"' +
|
|
|
cryptCouponId +
|
|
|
'"},"url":"' +
|
|
|
_.get(global, 'yoho.API.Http.ApiUrl', '') +
|
|
|
'"},"priority":"Y"}}';
|
|
|
}
|
|
|
|
|
|
req.json({
|
|
|
res.json({
|
|
|
code: 4401,
|
|
|
url: helpers.urlFormat('/signin.html', {refer: ''})
|
|
|
url: toUrl
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -425,5 +438,6 @@ module.exports = { |
|
|
shopAppCookie,
|
|
|
shopFav,
|
|
|
baseShopFav,
|
|
|
shopCategory
|
|
|
shopCategory,
|
|
|
userCoupon
|
|
|
}; |
...
|
...
|
|