...
|
...
|
@@ -10,6 +10,7 @@ const _ = require('lodash'); |
|
|
// const path = require('path');
|
|
|
const Promise = require('bluebird');
|
|
|
const returnAPI = require('./returns-api');
|
|
|
const ordersAPI = require('./orders-api');
|
|
|
|
|
|
const pager = require(`${global.utils}/pager`).setPager;
|
|
|
|
...
|
...
|
@@ -76,6 +77,7 @@ function getGoodsData(goods) { |
|
|
*/
|
|
|
const getExpressCompany = (expressList) => {
|
|
|
let data = [];
|
|
|
|
|
|
_.forEach(expressList, function(value) {
|
|
|
data.push(value);
|
|
|
});
|
...
|
...
|
@@ -251,6 +253,59 @@ const getOrderRefund = (orderCode, uid) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 提交退货申请
|
|
|
* @param $orderCode
|
|
|
* @param $uid
|
|
|
* @param array $goods
|
|
|
* @param array $payment
|
|
|
* @return array|mixed
|
|
|
*/
|
|
|
const saveRefund = (req, uid) => {
|
|
|
let process = function*() {
|
|
|
let orderCode = req.body.orderCode,
|
|
|
goods = req.body.goods,
|
|
|
payment = req.body.payment;
|
|
|
|
|
|
|
|
|
if (_.isEmpty(orderCode) || orderCode < 1 ||
|
|
|
_.isEmpty(goods) || _.isEmpty(payment)) {
|
|
|
return {
|
|
|
code: 203,
|
|
|
message: '非法提交'
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 调用模型提交退货申请
|
|
|
let order = yield ordersAPI.viewOrderData(orderCode, uid);
|
|
|
|
|
|
if (_.isEmpty(order)) {
|
|
|
return {
|
|
|
code: 403,
|
|
|
message: '没有找到该订单'
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 组装站内信内容
|
|
|
let title = '您有一笔订单提交退货申请:';
|
|
|
let content = '您的订单' + orderCode + '申请退货,给您带来不便敬请谅解!请至订单中心查看详情!';
|
|
|
|
|
|
// 调用接口保存退货申请
|
|
|
let result = yield returnAPI.refundSubmit(orderCode, uid, goods, payment);
|
|
|
|
|
|
if (_.get(result, 'code') === 200) {
|
|
|
// 退货成功发送站内信
|
|
|
let da = yield returnAPI.sendMessage(uid, title, content);
|
|
|
console.log(da);
|
|
|
result.data.refer = helpers.urlFormat('/home/returns/refundSuccess', {orderCode: orderCode});
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
return co(process)();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取退货详情页数据
|
|
|
* @param $uid
|
|
|
* @param $id
|
...
|
...
|
@@ -500,11 +555,12 @@ const getCancelChange = (id, uid) => { |
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getReturnsList,
|
|
|
getOrderRefund,
|
|
|
getRefundDetail,
|
|
|
getChangeDetail,
|
|
|
getOrderExchange,
|
|
|
getReturnsList, // 我的订单,退换货列表
|
|
|
getOrderRefund, // 我的订单,申请退货
|
|
|
saveRefund, // 退货提交
|
|
|
getRefundDetail, // 退货详情
|
|
|
getChangeDetail, // 换货详情
|
|
|
getOrderExchange, // 我的订单,申请换货
|
|
|
getCancelRefund, // 取消退货申请
|
|
|
getCancelChange // 取消换货申请
|
|
|
}; |
...
|
...
|
|