Authored by yyq

退换货方法注释

... ... @@ -9,7 +9,9 @@ const mcHandler = require('../models/menu-crumb-handler');
const returns = require('../models/returns');
const _ = require('lodash');
/**
* 退换货列表页
*/
const index = (req, res, next) => {
const uid = global.yoho.uid;
const page = req.query.page;
... ... @@ -27,6 +29,9 @@ const index = (req, res, next) => {
}).catch(next);
};
/**
* 退货申请页
*/
const refund = (req, res, next) => {
let uid = req.user.uid;
let code = parseInt(req.params.orderCode, 10);
... ... @@ -43,6 +48,10 @@ const refund = (req, res, next) => {
}).catch(next);
};
/**
* 退货申请提交
* @return { Object } 申请结果
*/
const refundApply = (req, res, next) => {
let orderCode = req.body.orderCode,
uid = req.user.uid,
... ... @@ -62,6 +71,9 @@ const refundApply = (req, res, next) => {
};
/**
* 退货详情页
*/
const refundDetail = (req, res, next) => {
let applyId = parseInt(req.params.applyId, 10),
uid = req.user.uid;
... ... @@ -78,6 +90,9 @@ const refundDetail = (req, res, next) => {
}).catch(next);
};
/**
* 换货申请页
*/
const exchange = (req, res, next) => {
const code = req.params.orderCode;
const uid = req.user.uid || 8050882;
... ... @@ -95,6 +110,13 @@ const exchange = (req, res, next) => {
}).catch(next);
};
/**
* 获取商品详情
* @function getProductInfo
* @param { number } productId 商品id
* @param { number } productSkn 商品skn
* @return { Object } 商品信息
*/
const getProductInfo = (req, res, next) => {
const productId = req.query.productId;
const productSkn = req.query.productSkn;
... ... @@ -104,6 +126,9 @@ const getProductInfo = (req, res, next) => {
}).catch(next);
};
/**
* 换货详情页
*/
const exchangeDeatail = (req, res) => {
let id = parseInt(req.params.applyId, 10),
uid = req.user.uid;
... ... @@ -129,6 +154,9 @@ const exchangeDeatail = (req, res) => {
});
};
/**
* 换货申请提交
*/
const exchangeSubmit = (req, res, next) => {
const uid = req.user.uid || '8050882';
... ... @@ -137,6 +165,13 @@ const exchangeSubmit = (req, res, next) => {
}).catch(next);
};
/**
* 取消退换货申请
* @function cancelApply
* @param { string } uid 用户uid
* @param { string } type 退换货类型 refund--退货 exchange--换货
* @return { Object } 取消退换货结果
*/
const cancelApply = (req, res, next) => {
const uid = req.user.uid;
const id = req.body.id;
... ... @@ -151,6 +186,12 @@ const cancelApply = (req, res, next) => {
}).catch(next);
};
/**
* 设置寄回物流单号
* @function setEepress
* @param { Object } param 物流信息
* @return { Object } 潮流尖货状态
*/
const setEepress = (req, res, next) => {
const uid = req.user.uid;
const param = req.body;
... ...
... ... @@ -39,6 +39,13 @@ const returnAddress = {
// return d;
// };
/**
* 获取用户退换货列表
* @function getUserReturn
* @param { string } uid 用户uid
* @param { number } page 分页数量
* @return { Object } 退换货列表
*/
const getUserReturn = (uid, page) => {
return api.get('', {
... ... @@ -89,6 +96,12 @@ const getUserReturn = (uid, page) => {
});
};
/**
* 设置侧边栏列表
* @function _setSideMenu
* @param { string } type 当前所在模块类型
* @return { Object } 侧边栏列表
*/
const _setSideMenu = (type) => {
return {
nav: mcHandler.getMeCrumb(type),
... ... @@ -96,6 +109,13 @@ const _setSideMenu = (type) => {
};
};
/**
* 计算进度条进度
* @function _calcStatusRate
* @param { number } num 当前数量
* @param { number } total 总共数量
* @return { string } 进度条进度百分比
*/
const _calcStatusRate = (num, total) => {
let rate = 0;
... ... @@ -106,12 +126,25 @@ const _calcStatusRate = (num, total) => {
return rate;
};
/**
* 提交换货申请
* @function submitChange
* @param { Object } data 换货数据
* @param { number } uid 用户uid
* @return { Object } 换货申请结果
*/
const submitChange = (data, uid) => {
return returnsAPI.changeSubmitAsync(data, uid).then(result => {
return result;
});
};
/**
* 设置默认退换货状态进度信息
* @function _setDefaultStatus
* @param { string } type 退换货类型(退货/换货)
* @return { Object } 退换货状态进度信息
*/
const _setDefaultStatus = (type) => {
const list = ['提交申请', '审核通过', '商品寄回', '商品入库', `${type}完成`];
let statusList = [];
... ... @@ -133,6 +166,13 @@ const _setDefaultStatus = (type) => {
return resData;
};
/**
* 设置退换货状态进度信息
* @function _setReturnStatus
* @param { number } list 退换货进度列表
* @param { boolean } half 是否比正常进度多半格
* @return { Object } 退换货状态进度信息
*/
const _setReturnStatus = (list, half) => {
let resData = {};
... ... @@ -171,6 +211,12 @@ const _setReturnStatus = (list, half) => {
return resData;
};
/**
* 设置退货列表信息
* @function _setRefundGoodList
* @param { Object } data 接口返货订单信息
* @return { Object } 订单退货信息
*/
const _setRefundGoodList = (data) => {
let resData = {};
... ... @@ -207,6 +253,12 @@ const _setRefundGoodList = (data) => {
return resData;
};
/**
* 设置退货订单数据
* @function _setRefundDetailData
* @param { Object } data 接口返回退货订单数据
* @return { Object } 模板渲染退货订单数据
*/
const _setRefundDetailData = (data) => {
let resData = {
id: data.id || 0
... ... @@ -281,6 +333,12 @@ const _setRefundDetailData = (data) => {
return resData;
};
/**
* 设置物流公司列表
* @function _setExpressData
* @param { Object } data 接口返回物流公司列表
* @return { Array } 物流公司列表
*/
const _setExpressData = (data) => {
var resData = [];
... ... @@ -301,6 +359,12 @@ const _setExpressData = (data) => {
return resData;
};
/**
* 设置换货详情数据
* @function _setExchangeDetailData
* @param { Object } data 接口返回换货订单数据
* @return { Object } 模板渲染换货数据
*/
const _setExchangeDetailData = (data) => {
data = camelCase(data);
... ... @@ -337,6 +401,13 @@ const _setExchangeDetailData = (data) => {
return list;
};
/**
* 获取退货商品信息
* @function getRefundGoodsData
* @param { number } orderCode 订单号
* @param { number } uid 用户uid
* @return { Object } 退货商品信息
*/
const getRefundGoodsData = (orderCode, uid) => {
return returnsAPI.getRefundGoodsAsync(orderCode, uid).then(result => {
let resData = {};
... ... @@ -348,8 +419,6 @@ const getRefundGoodsData = (orderCode, uid) => {
refund: _setDefaultStatus('退货') || {}
};
// console.log(resData);
if (result.data) {
Object.assign(resData.returns.refund, _setRefundGoodList(result.data), {
orderCode: orderCode
... ... @@ -360,6 +429,13 @@ const getRefundGoodsData = (orderCode, uid) => {
});
};
/**
* 获取退货详情信息
* @function getRefundDetailData
* @param { number } applyId 退货申请id
* @param { number } uid 用户uid
* @return { Object } 退货详情信息
*/
const getRefundDetailData = (applyId, uid) => {
return Promise.all([
returnsAPI.getRefundDetailAsync(applyId, uid),
... ... @@ -393,6 +469,15 @@ const getRefundDetailData = (applyId, uid) => {
});
};
/**
* 保存退货信息
* @function saveRefund
* @param { number } orderCode 订单号
* @param { number } uid 用户uid
* @param { Object } goods 退货商品信息
* @param { Object } payment 退款信息
* @return { Object } 提交退货申请结果
*/
const saveRefund = (orderCode, uid, goods, payment) => {
return returnsAPI.getOrderInfoAsync(orderCode, uid, '').then(result => {
if (!_.isEmpty(result)) {
... ... @@ -413,6 +498,13 @@ const saveRefund = (orderCode, uid, goods, payment) => {
});
};
/**
* 获取商品详情
* @function getProductInfo
* @param { number } productId 商品id
* @param { number } productSkn 商品skn
* @return { Object } 商品详情信息
*/
const getProductInfo = (productId, productSkn) => {
return returnsAPI.getProductInfoAsync(productId, productSkn).then(result => {
if (result.code === 200) {
... ... @@ -425,6 +517,13 @@ const getProductInfo = (productId, productSkn) => {
});
};
/**
* 获取换货商品列表
* @function getChangeGoodsList
* @param { number } orderCode 订单号
* @param { number } uid 用户uid
* @return { Object } 换货商品列表信息
*/
const getChangeGoodsList = (orderCode, uid) => {
return returnsAPI.getChangeGoodsListAsync(orderCode, uid).then(result => {
const basicData = {
... ... @@ -456,6 +555,13 @@ const getChangeGoodsList = (orderCode, uid) => {
});
};
/**
* 获取换货详情信息
* @function getExchangeDetailData
* @param { number } id 换货申请单号
* @param { number } uid 用户uid
* @return { Object } 换货详情信息
*/
const getExchangeDetailData = (id, uid) => {
return Promise.all([
returnsAPI.getExchangeDetail(id, uid),
... ... @@ -501,6 +607,14 @@ const getExchangeDetailData = (id, uid) => {
});
};
/**
* 取消退换货申请
* @function cancelReturnApply
* @param { number } id 退换货id
* @param { number } uid 用户uid
* @param { string } type 退换货类型 refund--退货 exchange--换货
* @return { Object } 取消退换货申请结果
*/
const cancelReturnApply = (id, uid, type) => {
return returnsAPI.cancelReturnAsync(id, uid, type).then(result => {
let resData = result || {
... ... @@ -512,6 +626,13 @@ const cancelReturnApply = (id, uid, type) => {
});
};
/**
* 设置寄回物流信息
* @function setBackEepress
* @param { number } uid 用户uid
* @param { Object } param 物流参数
* @return { Object } 设置寄回物流信息结果
*/
const setBackEepress = (uid, param) => {
const type = param.type === 'exchange';
... ...