Authored by yyq

mobile

... ... @@ -62,10 +62,6 @@ const convertCoupons = (req, res, next) => {
// 获取礼品卡列表
const getGiftCards = (req, res, next) => {
req.ctx(oeModel).getGiftCards(req.user.uid).then(data => {
if (data.data) {
data.data.userMobile = req.user.mobile;
}
res.send(data);
}).catch(next);
};
... ...
... ... @@ -85,14 +85,26 @@ module.exports = class extends global.yoho.BaseModel {
// 获取礼品卡列表
getGiftCards(uid) {
return new EnsureApi(this.ctx).getGiftCardAsync(uid).then(result => {
if (!_.isEmpty(_.get(result, 'data.usable_giftCards', []))) {
_.map(result.data.usable_giftCards, value => {
const ensureApiModel = new EnsureApi(this.ctx);
return Promise.all([
ensureApiModel.getGiftCardAsync(uid),
ensureApiModel.getUserProfileAsync(uid)
]).then(result => {
let resData = result[0];
if (!_.isEmpty(_.get(resData, 'data.usable_giftCards', []))) {
_.map(resData.data.usable_giftCards, value => {
return Object.assign(value, {price: _.replace(value.remainAmount, /[^(0-9.)]/ig, '')});
});
}
return result;
if (result[1].code === 200) {
_.set(resData, 'data.userMobile', _.get(result[1], 'data.verify_mobile'));
}
return resData;
});
}
... ...