...
|
...
|
@@ -3,6 +3,12 @@ |
|
|
const api = global.yoho.API;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const _ = require('lodash');
|
|
|
const moment = require('moment');
|
|
|
|
|
|
// 格式年月日
|
|
|
const _formatDay = (day) => {
|
|
|
return moment(day).format('YYYY-MM-DD');
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 会员等级
|
...
|
...
|
@@ -49,11 +55,45 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
});
|
|
|
}
|
|
|
|
|
|
getGrowthVip(uid) {
|
|
|
let options = {
|
|
|
data: {
|
|
|
method: 'app.passport.growthvip',
|
|
|
uid: uid
|
|
|
},
|
|
|
param: {
|
|
|
code: 200
|
|
|
}
|
|
|
};
|
|
|
|
|
|
return this.get(options).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
getHis(params) {
|
|
|
let options = {
|
|
|
data: {
|
|
|
method: 'app.passport.growthhistory',
|
|
|
uid: params.uid,
|
|
|
page: params.page
|
|
|
},
|
|
|
param: {
|
|
|
code: 200
|
|
|
}
|
|
|
};
|
|
|
|
|
|
return this.get(options).then(result => {
|
|
|
return result;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
index(param) {
|
|
|
if (param.uid) {
|
|
|
return api.all([
|
|
|
this.getGradeGrade(param.uid, param.channel),
|
|
|
this.getGradeUser(param.uid, param.channel)
|
|
|
this.getGradeUser(param.uid, param.channel),
|
|
|
this.getGrowthVip(param.uid)
|
|
|
]).then((result) => {
|
|
|
|
|
|
let resu = {
|
...
|
...
|
@@ -106,31 +146,9 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
|
|
|
}
|
|
|
|
|
|
let upg = (1 * (result[0].data.upgrade_need_cost)).toFixed(2);
|
|
|
|
|
|
obj = _.assign(obj, {
|
|
|
costOfThisYear: result[0].data.current_year_cost,
|
|
|
sumCost: result[0].data.current_total_cost,
|
|
|
allUrl: helpers.urlFormat('/home/privilege'),
|
|
|
costGap: upg
|
|
|
allUrl: helpers.urlFormat('/home/privilege')
|
|
|
});
|
|
|
|
|
|
if (result[0].data.next_need_cost === 0 || result[0].data.next_need_cost === '') {
|
|
|
// 当vip等级升至顶级时,进度条满格
|
|
|
obj = _.assign(obj, {
|
|
|
percent: 100
|
|
|
});
|
|
|
} else {
|
|
|
|
|
|
let perf = (100 * (result[0].data.current_year_cost /
|
|
|
result[0].data.next_need_cost)).toFixed(2);
|
|
|
|
|
|
obj = _.assign(obj, {
|
|
|
percent: perf
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (result[1] && result[1].data) {
|
...
|
...
|
@@ -140,12 +158,104 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
});
|
|
|
}
|
|
|
|
|
|
resu.vipGrade.push(obj);
|
|
|
if (result[2] && result[2].data) {
|
|
|
let nowGrowth = parseInt(result[2].data.current_total_growth, 10);
|
|
|
let nextGrowth = parseInt(result[2].data.upgrade_need_growth, 10) || 0;
|
|
|
|
|
|
obj = _.assign(obj, {
|
|
|
nowGrowth: nowGrowth,
|
|
|
nextGrowth: nextGrowth,
|
|
|
percent: nowGrowth < 7000 ? nowGrowth / 70 : 100
|
|
|
});
|
|
|
}
|
|
|
resu.vipGrade.push(obj);
|
|
|
return resu;
|
|
|
});
|
|
|
} else {
|
|
|
return Promise.resolve({});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
grow(param) {
|
|
|
return api.all([
|
|
|
this.getGrowthVip(param.uid),
|
|
|
this.getHis(param)
|
|
|
]).then((result) => {
|
|
|
let resu = {
|
|
|
levelHis: [],
|
|
|
detailHis: []
|
|
|
};
|
|
|
|
|
|
if (result) {
|
|
|
if (result[0] && result[0].data) {
|
|
|
let build = [];
|
|
|
|
|
|
if (result[0].data.sliver_start_time) {
|
|
|
build.push({
|
|
|
tip: '普通升级为银卡',
|
|
|
time: _formatDay(result[0].data.sliver_start_time * 1000)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (result[0].data.gold_start_time) {
|
|
|
build.push({
|
|
|
tip: '银卡升级为金卡',
|
|
|
time: _formatDay(result[0].data.gold_start_time * 1000)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (result[0].data.whitegold_start_time) {
|
|
|
build.push({
|
|
|
tip: '金卡升级为白金',
|
|
|
time: _formatDay(result[0].data.whitegold_start_time * 1000)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
resu.levelHis = build;
|
|
|
}
|
|
|
|
|
|
if (result[1] && result[1].data && result[1].data.data) {
|
|
|
let build = [];
|
|
|
|
|
|
_.forEach(result[1].data.data, function(val) {
|
|
|
build.push({
|
|
|
title: val.typeDesc,
|
|
|
time: _formatDay(val.createTime),
|
|
|
value: val.growthValue
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.detailHis = build;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
getHisAjax(param) {
|
|
|
return api.all([
|
|
|
this.getHis(param)
|
|
|
]).then((result) => {
|
|
|
let resu = {
|
|
|
detailHis: []
|
|
|
};
|
|
|
|
|
|
if (result && result[0] && result[0].data) {
|
|
|
let build = [];
|
|
|
|
|
|
_.forEach(result[0].data.data, function(val) {
|
|
|
build.push({
|
|
|
title: val.typeDesc,
|
|
|
time: _formatDay(val.createTime),
|
|
|
value: val.growthValue
|
|
|
});
|
|
|
});
|
|
|
|
|
|
resu.detailHis = build;
|
|
|
}
|
|
|
|
|
|
return resu;
|
|
|
});
|
|
|
}
|
|
|
}; |
...
|
...
|
|