...
|
...
|
@@ -8,6 +8,8 @@ const UserData = require('./user-data'); |
|
|
const helpers = global.yoho.helpers;
|
|
|
const path = require('path');
|
|
|
const _ = require('lodash');
|
|
|
const moment = require('moment');
|
|
|
|
|
|
// 使用 product中的分页逻辑
|
|
|
const pagerPath = path.join(global.appRoot, '/apps/product/models/public-handler.js');
|
|
|
const pager = require(pagerPath).handlePagerData;
|
...
|
...
|
@@ -27,6 +29,7 @@ const getCouponsList = (uid, type, page, limit)=>{ |
|
|
};
|
|
|
}
|
|
|
let coupons = _.get(couponsInfo, 'data.couponList');
|
|
|
|
|
|
if (coupons) {
|
|
|
coupons.forEach(function(item, i) {
|
|
|
result[i] = {};
|
...
|
...
|
@@ -36,8 +39,8 @@ const getCouponsList = (uid, type, page, limit)=>{ |
|
|
// 格式化有效日期 "couponValidity": "2016.03.15-2016.03.31"
|
|
|
let dates = item.couponValidity.split('-');
|
|
|
|
|
|
result[i].beginTime = dates[0].replace('.', '-');
|
|
|
result[i].endTime = dates[1].replace('.', '-');
|
|
|
result[i].beginTime = _.replace(dates[0], /\./g, '-');
|
|
|
result[i].endTime = _.replace(dates[1], /\./g, '-');
|
|
|
|
|
|
if (!item.couponImageUrl) {
|
|
|
result[i].img = '//static.yohobuy.com/images/v2/activity/default_coupon.jpg';
|
...
|
...
|
@@ -53,11 +56,10 @@ const getCouponsList = (uid, type, page, limit)=>{ |
|
|
result[i].validity = item.couponValidity;
|
|
|
result[i].useRemark = item.couponDetailInfomation;
|
|
|
|
|
|
|
|
|
|
|
|
if (type === USED) {
|
|
|
result[i].orderNum = _.get(item, 'orderCode', '');
|
|
|
result[i].orderDetailUrl = helpers.urlFormat('/home/orders/detail', {orderCode: item.orderCode || ''});
|
|
|
result[i].orderDetailUrl = helpers.urlFormat('/home/orders/detail',
|
|
|
{orderCode: item.orderCode || ''});
|
|
|
result[i].orderSum = _.get(item, 'orderPrice', 0).toFixed(2);
|
|
|
result[i].payment = _.get(item, 'actuallyPaid', 0).toFixed(2);
|
|
|
let data = result[i].usedTime ? moment(result[i].usedTime).format('YYYY-MM-DD') : 0;
|
...
|
...
|
@@ -72,7 +74,7 @@ const getCouponsList = (uid, type, page, limit)=>{ |
|
|
}
|
|
|
if (item.couponType) {
|
|
|
result[i].type = item.couponType;
|
|
|
if (item.couponType == 5) {
|
|
|
if (Number(item.couponType) === 5) {
|
|
|
result[i].value = '免邮';
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -83,7 +85,7 @@ const getCouponsList = (uid, type, page, limit)=>{ |
|
|
page: page,
|
|
|
limit: limit,
|
|
|
type: type
|
|
|
})
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
list: result,
|
...
|
...
|
@@ -104,7 +106,7 @@ const couponsData = (uid, params)=>{ |
|
|
return co(function*() {
|
|
|
let coupons = yield getCouponsList(uid, type, page, limit);
|
|
|
let data = {};
|
|
|
console.log(coupons);
|
|
|
|
|
|
if (type === UNUSED) {
|
|
|
data.unUseCoupons = !coupons.list.length ? {empty: '您没有优惠券'} : coupons.list;
|
|
|
data.unUse = true;
|
...
|
...
|
|