Authored by yyq

退换货方法注释

@@ -9,7 +9,9 @@ const mcHandler = require('../models/menu-crumb-handler'); @@ -9,7 +9,9 @@ const mcHandler = require('../models/menu-crumb-handler');
9 const returns = require('../models/returns'); 9 const returns = require('../models/returns');
10 const _ = require('lodash'); 10 const _ = require('lodash');
11 11
12 - 12 +/**
  13 + * 退换货列表页
  14 + */
13 const index = (req, res, next) => { 15 const index = (req, res, next) => {
14 const uid = global.yoho.uid; 16 const uid = global.yoho.uid;
15 const page = req.query.page; 17 const page = req.query.page;
@@ -27,6 +29,9 @@ const index = (req, res, next) => { @@ -27,6 +29,9 @@ const index = (req, res, next) => {
27 }).catch(next); 29 }).catch(next);
28 }; 30 };
29 31
  32 +/**
  33 + * 退货申请页
  34 + */
30 const refund = (req, res, next) => { 35 const refund = (req, res, next) => {
31 let uid = req.user.uid; 36 let uid = req.user.uid;
32 let code = parseInt(req.params.orderCode, 10); 37 let code = parseInt(req.params.orderCode, 10);
@@ -43,6 +48,10 @@ const refund = (req, res, next) => { @@ -43,6 +48,10 @@ const refund = (req, res, next) => {
43 }).catch(next); 48 }).catch(next);
44 }; 49 };
45 50
  51 +/**
  52 + * 退货申请提交
  53 + * @return { Object } 申请结果
  54 + */
46 const refundApply = (req, res, next) => { 55 const refundApply = (req, res, next) => {
47 let orderCode = req.body.orderCode, 56 let orderCode = req.body.orderCode,
48 uid = req.user.uid, 57 uid = req.user.uid,
@@ -62,6 +71,9 @@ const refundApply = (req, res, next) => { @@ -62,6 +71,9 @@ const refundApply = (req, res, next) => {
62 71
63 }; 72 };
64 73
  74 +/**
  75 + * 退货详情页
  76 + */
65 const refundDetail = (req, res, next) => { 77 const refundDetail = (req, res, next) => {
66 let applyId = parseInt(req.params.applyId, 10), 78 let applyId = parseInt(req.params.applyId, 10),
67 uid = req.user.uid; 79 uid = req.user.uid;
@@ -78,6 +90,9 @@ const refundDetail = (req, res, next) => { @@ -78,6 +90,9 @@ const refundDetail = (req, res, next) => {
78 }).catch(next); 90 }).catch(next);
79 }; 91 };
80 92
  93 +/**
  94 + * 换货申请页
  95 + */
81 const exchange = (req, res, next) => { 96 const exchange = (req, res, next) => {
82 const code = req.params.orderCode; 97 const code = req.params.orderCode;
83 const uid = req.user.uid || 8050882; 98 const uid = req.user.uid || 8050882;
@@ -95,6 +110,13 @@ const exchange = (req, res, next) => { @@ -95,6 +110,13 @@ const exchange = (req, res, next) => {
95 }).catch(next); 110 }).catch(next);
96 }; 111 };
97 112
  113 +/**
  114 + * 获取商品详情
  115 + * @function getProductInfo
  116 + * @param { number } productId 商品id
  117 + * @param { number } productSkn 商品skn
  118 + * @return { Object } 商品信息
  119 + */
98 const getProductInfo = (req, res, next) => { 120 const getProductInfo = (req, res, next) => {
99 const productId = req.query.productId; 121 const productId = req.query.productId;
100 const productSkn = req.query.productSkn; 122 const productSkn = req.query.productSkn;
@@ -104,6 +126,9 @@ const getProductInfo = (req, res, next) => { @@ -104,6 +126,9 @@ const getProductInfo = (req, res, next) => {
104 }).catch(next); 126 }).catch(next);
105 }; 127 };
106 128
  129 +/**
  130 + * 换货详情页
  131 + */
107 const exchangeDeatail = (req, res) => { 132 const exchangeDeatail = (req, res) => {
108 let id = parseInt(req.params.applyId, 10), 133 let id = parseInt(req.params.applyId, 10),
109 uid = req.user.uid; 134 uid = req.user.uid;
@@ -129,6 +154,9 @@ const exchangeDeatail = (req, res) => { @@ -129,6 +154,9 @@ const exchangeDeatail = (req, res) => {
129 }); 154 });
130 }; 155 };
131 156
  157 +/**
  158 + * 换货申请提交
  159 + */
132 const exchangeSubmit = (req, res, next) => { 160 const exchangeSubmit = (req, res, next) => {
133 const uid = req.user.uid || '8050882'; 161 const uid = req.user.uid || '8050882';
134 162
@@ -137,6 +165,13 @@ const exchangeSubmit = (req, res, next) => { @@ -137,6 +165,13 @@ const exchangeSubmit = (req, res, next) => {
137 }).catch(next); 165 }).catch(next);
138 }; 166 };
139 167
  168 +/**
  169 + * 取消退换货申请
  170 + * @function cancelApply
  171 + * @param { string } uid 用户uid
  172 + * @param { string } type 退换货类型 refund--退货 exchange--换货
  173 + * @return { Object } 取消退换货结果
  174 + */
140 const cancelApply = (req, res, next) => { 175 const cancelApply = (req, res, next) => {
141 const uid = req.user.uid; 176 const uid = req.user.uid;
142 const id = req.body.id; 177 const id = req.body.id;
@@ -151,6 +186,12 @@ const cancelApply = (req, res, next) => { @@ -151,6 +186,12 @@ const cancelApply = (req, res, next) => {
151 }).catch(next); 186 }).catch(next);
152 }; 187 };
153 188
  189 +/**
  190 + * 设置寄回物流单号
  191 + * @function setEepress
  192 + * @param { Object } param 物流信息
  193 + * @return { Object } 潮流尖货状态
  194 + */
154 const setEepress = (req, res, next) => { 195 const setEepress = (req, res, next) => {
155 const uid = req.user.uid; 196 const uid = req.user.uid;
156 const param = req.body; 197 const param = req.body;
@@ -39,6 +39,13 @@ const returnAddress = { @@ -39,6 +39,13 @@ const returnAddress = {
39 // return d; 39 // return d;
40 // }; 40 // };
41 41
  42 +/**
  43 + * 获取用户退换货列表
  44 + * @function getUserReturn
  45 + * @param { string } uid 用户uid
  46 + * @param { number } page 分页数量
  47 + * @return { Object } 退换货列表
  48 + */
42 const getUserReturn = (uid, page) => { 49 const getUserReturn = (uid, page) => {
43 50
44 return api.get('', { 51 return api.get('', {
@@ -89,6 +96,12 @@ const getUserReturn = (uid, page) => { @@ -89,6 +96,12 @@ const getUserReturn = (uid, page) => {
89 }); 96 });
90 }; 97 };
91 98
  99 +/**
  100 + * 设置侧边栏列表
  101 + * @function _setSideMenu
  102 + * @param { string } type 当前所在模块类型
  103 + * @return { Object } 侧边栏列表
  104 + */
92 const _setSideMenu = (type) => { 105 const _setSideMenu = (type) => {
93 return { 106 return {
94 nav: mcHandler.getMeCrumb(type), 107 nav: mcHandler.getMeCrumb(type),
@@ -96,6 +109,13 @@ const _setSideMenu = (type) => { @@ -96,6 +109,13 @@ const _setSideMenu = (type) => {
96 }; 109 };
97 }; 110 };
98 111
  112 +/**
  113 + * 计算进度条进度
  114 + * @function _calcStatusRate
  115 + * @param { number } num 当前数量
  116 + * @param { number } total 总共数量
  117 + * @return { string } 进度条进度百分比
  118 + */
99 const _calcStatusRate = (num, total) => { 119 const _calcStatusRate = (num, total) => {
100 let rate = 0; 120 let rate = 0;
101 121
@@ -106,12 +126,25 @@ const _calcStatusRate = (num, total) => { @@ -106,12 +126,25 @@ const _calcStatusRate = (num, total) => {
106 return rate; 126 return rate;
107 }; 127 };
108 128
  129 +/**
  130 + * 提交换货申请
  131 + * @function submitChange
  132 + * @param { Object } data 换货数据
  133 + * @param { number } uid 用户uid
  134 + * @return { Object } 换货申请结果
  135 + */
109 const submitChange = (data, uid) => { 136 const submitChange = (data, uid) => {
110 return returnsAPI.changeSubmitAsync(data, uid).then(result => { 137 return returnsAPI.changeSubmitAsync(data, uid).then(result => {
111 return result; 138 return result;
112 }); 139 });
113 }; 140 };
114 141
  142 +/**
  143 + * 设置默认退换货状态进度信息
  144 + * @function _setDefaultStatus
  145 + * @param { string } type 退换货类型(退货/换货)
  146 + * @return { Object } 退换货状态进度信息
  147 + */
115 const _setDefaultStatus = (type) => { 148 const _setDefaultStatus = (type) => {
116 const list = ['提交申请', '审核通过', '商品寄回', '商品入库', `${type}完成`]; 149 const list = ['提交申请', '审核通过', '商品寄回', '商品入库', `${type}完成`];
117 let statusList = []; 150 let statusList = [];
@@ -133,6 +166,13 @@ const _setDefaultStatus = (type) => { @@ -133,6 +166,13 @@ const _setDefaultStatus = (type) => {
133 return resData; 166 return resData;
134 }; 167 };
135 168
  169 +/**
  170 + * 设置退换货状态进度信息
  171 + * @function _setReturnStatus
  172 + * @param { number } list 退换货进度列表
  173 + * @param { boolean } half 是否比正常进度多半格
  174 + * @return { Object } 退换货状态进度信息
  175 + */
136 const _setReturnStatus = (list, half) => { 176 const _setReturnStatus = (list, half) => {
137 let resData = {}; 177 let resData = {};
138 178
@@ -171,6 +211,12 @@ const _setReturnStatus = (list, half) => { @@ -171,6 +211,12 @@ const _setReturnStatus = (list, half) => {
171 return resData; 211 return resData;
172 }; 212 };
173 213
  214 +/**
  215 + * 设置退货列表信息
  216 + * @function _setRefundGoodList
  217 + * @param { Object } data 接口返货订单信息
  218 + * @return { Object } 订单退货信息
  219 + */
174 const _setRefundGoodList = (data) => { 220 const _setRefundGoodList = (data) => {
175 let resData = {}; 221 let resData = {};
176 222
@@ -207,6 +253,12 @@ const _setRefundGoodList = (data) => { @@ -207,6 +253,12 @@ const _setRefundGoodList = (data) => {
207 return resData; 253 return resData;
208 }; 254 };
209 255
  256 +/**
  257 + * 设置退货订单数据
  258 + * @function _setRefundDetailData
  259 + * @param { Object } data 接口返回退货订单数据
  260 + * @return { Object } 模板渲染退货订单数据
  261 + */
210 const _setRefundDetailData = (data) => { 262 const _setRefundDetailData = (data) => {
211 let resData = { 263 let resData = {
212 id: data.id || 0 264 id: data.id || 0
@@ -281,6 +333,12 @@ const _setRefundDetailData = (data) => { @@ -281,6 +333,12 @@ const _setRefundDetailData = (data) => {
281 return resData; 333 return resData;
282 }; 334 };
283 335
  336 +/**
  337 + * 设置物流公司列表
  338 + * @function _setExpressData
  339 + * @param { Object } data 接口返回物流公司列表
  340 + * @return { Array } 物流公司列表
  341 + */
284 const _setExpressData = (data) => { 342 const _setExpressData = (data) => {
285 var resData = []; 343 var resData = [];
286 344
@@ -301,6 +359,12 @@ const _setExpressData = (data) => { @@ -301,6 +359,12 @@ const _setExpressData = (data) => {
301 return resData; 359 return resData;
302 }; 360 };
303 361
  362 +/**
  363 + * 设置换货详情数据
  364 + * @function _setExchangeDetailData
  365 + * @param { Object } data 接口返回换货订单数据
  366 + * @return { Object } 模板渲染换货数据
  367 + */
304 const _setExchangeDetailData = (data) => { 368 const _setExchangeDetailData = (data) => {
305 data = camelCase(data); 369 data = camelCase(data);
306 370
@@ -337,6 +401,13 @@ const _setExchangeDetailData = (data) => { @@ -337,6 +401,13 @@ const _setExchangeDetailData = (data) => {
337 return list; 401 return list;
338 }; 402 };
339 403
  404 +/**
  405 + * 获取退货商品信息
  406 + * @function getRefundGoodsData
  407 + * @param { number } orderCode 订单号
  408 + * @param { number } uid 用户uid
  409 + * @return { Object } 退货商品信息
  410 + */
340 const getRefundGoodsData = (orderCode, uid) => { 411 const getRefundGoodsData = (orderCode, uid) => {
341 return returnsAPI.getRefundGoodsAsync(orderCode, uid).then(result => { 412 return returnsAPI.getRefundGoodsAsync(orderCode, uid).then(result => {
342 let resData = {}; 413 let resData = {};
@@ -348,8 +419,6 @@ const getRefundGoodsData = (orderCode, uid) => { @@ -348,8 +419,6 @@ const getRefundGoodsData = (orderCode, uid) => {
348 refund: _setDefaultStatus('退货') || {} 419 refund: _setDefaultStatus('退货') || {}
349 }; 420 };
350 421
351 - // console.log(resData);  
352 -  
353 if (result.data) { 422 if (result.data) {
354 Object.assign(resData.returns.refund, _setRefundGoodList(result.data), { 423 Object.assign(resData.returns.refund, _setRefundGoodList(result.data), {
355 orderCode: orderCode 424 orderCode: orderCode
@@ -360,6 +429,13 @@ const getRefundGoodsData = (orderCode, uid) => { @@ -360,6 +429,13 @@ const getRefundGoodsData = (orderCode, uid) => {
360 }); 429 });
361 }; 430 };
362 431
  432 +/**
  433 + * 获取退货详情信息
  434 + * @function getRefundDetailData
  435 + * @param { number } applyId 退货申请id
  436 + * @param { number } uid 用户uid
  437 + * @return { Object } 退货详情信息
  438 + */
363 const getRefundDetailData = (applyId, uid) => { 439 const getRefundDetailData = (applyId, uid) => {
364 return Promise.all([ 440 return Promise.all([
365 returnsAPI.getRefundDetailAsync(applyId, uid), 441 returnsAPI.getRefundDetailAsync(applyId, uid),
@@ -393,6 +469,15 @@ const getRefundDetailData = (applyId, uid) => { @@ -393,6 +469,15 @@ const getRefundDetailData = (applyId, uid) => {
393 }); 469 });
394 }; 470 };
395 471
  472 +/**
  473 + * 保存退货信息
  474 + * @function saveRefund
  475 + * @param { number } orderCode 订单号
  476 + * @param { number } uid 用户uid
  477 + * @param { Object } goods 退货商品信息
  478 + * @param { Object } payment 退款信息
  479 + * @return { Object } 提交退货申请结果
  480 + */
396 const saveRefund = (orderCode, uid, goods, payment) => { 481 const saveRefund = (orderCode, uid, goods, payment) => {
397 return returnsAPI.getOrderInfoAsync(orderCode, uid, '').then(result => { 482 return returnsAPI.getOrderInfoAsync(orderCode, uid, '').then(result => {
398 if (!_.isEmpty(result)) { 483 if (!_.isEmpty(result)) {
@@ -413,6 +498,13 @@ const saveRefund = (orderCode, uid, goods, payment) => { @@ -413,6 +498,13 @@ const saveRefund = (orderCode, uid, goods, payment) => {
413 }); 498 });
414 }; 499 };
415 500
  501 +/**
  502 + * 获取商品详情
  503 + * @function getProductInfo
  504 + * @param { number } productId 商品id
  505 + * @param { number } productSkn 商品skn
  506 + * @return { Object } 商品详情信息
  507 + */
416 const getProductInfo = (productId, productSkn) => { 508 const getProductInfo = (productId, productSkn) => {
417 return returnsAPI.getProductInfoAsync(productId, productSkn).then(result => { 509 return returnsAPI.getProductInfoAsync(productId, productSkn).then(result => {
418 if (result.code === 200) { 510 if (result.code === 200) {
@@ -425,6 +517,13 @@ const getProductInfo = (productId, productSkn) => { @@ -425,6 +517,13 @@ const getProductInfo = (productId, productSkn) => {
425 }); 517 });
426 }; 518 };
427 519
  520 +/**
  521 + * 获取换货商品列表
  522 + * @function getChangeGoodsList
  523 + * @param { number } orderCode 订单号
  524 + * @param { number } uid 用户uid
  525 + * @return { Object } 换货商品列表信息
  526 + */
428 const getChangeGoodsList = (orderCode, uid) => { 527 const getChangeGoodsList = (orderCode, uid) => {
429 return returnsAPI.getChangeGoodsListAsync(orderCode, uid).then(result => { 528 return returnsAPI.getChangeGoodsListAsync(orderCode, uid).then(result => {
430 const basicData = { 529 const basicData = {
@@ -456,6 +555,13 @@ const getChangeGoodsList = (orderCode, uid) => { @@ -456,6 +555,13 @@ const getChangeGoodsList = (orderCode, uid) => {
456 }); 555 });
457 }; 556 };
458 557
  558 +/**
  559 + * 获取换货详情信息
  560 + * @function getExchangeDetailData
  561 + * @param { number } id 换货申请单号
  562 + * @param { number } uid 用户uid
  563 + * @return { Object } 换货详情信息
  564 + */
459 const getExchangeDetailData = (id, uid) => { 565 const getExchangeDetailData = (id, uid) => {
460 return Promise.all([ 566 return Promise.all([
461 returnsAPI.getExchangeDetail(id, uid), 567 returnsAPI.getExchangeDetail(id, uid),
@@ -501,6 +607,14 @@ const getExchangeDetailData = (id, uid) => { @@ -501,6 +607,14 @@ const getExchangeDetailData = (id, uid) => {
501 }); 607 });
502 }; 608 };
503 609
  610 +/**
  611 + * 取消退换货申请
  612 + * @function cancelReturnApply
  613 + * @param { number } id 退换货id
  614 + * @param { number } uid 用户uid
  615 + * @param { string } type 退换货类型 refund--退货 exchange--换货
  616 + * @return { Object } 取消退换货申请结果
  617 + */
504 const cancelReturnApply = (id, uid, type) => { 618 const cancelReturnApply = (id, uid, type) => {
505 return returnsAPI.cancelReturnAsync(id, uid, type).then(result => { 619 return returnsAPI.cancelReturnAsync(id, uid, type).then(result => {
506 let resData = result || { 620 let resData = result || {
@@ -512,6 +626,13 @@ const cancelReturnApply = (id, uid, type) => { @@ -512,6 +626,13 @@ const cancelReturnApply = (id, uid, type) => {
512 }); 626 });
513 }; 627 };
514 628
  629 +/**
  630 + * 设置寄回物流信息
  631 + * @function setBackEepress
  632 + * @param { number } uid 用户uid
  633 + * @param { Object } param 物流参数
  634 + * @return { Object } 设置寄回物流信息结果
  635 + */
515 const setBackEepress = (uid, param) => { 636 const setBackEepress = (uid, param) => {
516 const type = param.type === 'exchange'; 637 const type = param.type === 'exchange';
517 638