Authored by 郝肖肖

'退货价格分摊'

... ... @@ -211,6 +211,16 @@ const setExpressNumber = (req, res, next) => {
};
const refundCompute = (req, res, next) => {
let uid = req.user.uid;
let orderCode = req.query.orderCode;
let goods = req.query.goods;
returnsModel.refundCompute(uid, orderCode, goods).then(d => {
res.json(d);
}).catch(next);
};
module.exports = {
index,
refundApply,
... ... @@ -224,5 +234,6 @@ module.exports = {
getDelivery,
cancelRefund,
cancelChange,
setExpressNumber
setExpressNumber,
refundCompute
};
... ...
... ... @@ -201,7 +201,6 @@ const getDeliveryAsync = (areaCode, uid, gender, channel) => {
return api.post('', options);
};
/**
* 发送站内信
* @param int $uid
... ... @@ -228,6 +227,24 @@ const sendMessage = (uid, title, content, type, verifyKey, sendUid) =>{
return api.post('', options);
};
/**
* [退货结算]
* @param {[type]} uid [uid]
* @param {[type]} orderCode [订单号]
* @param {[type]} goods [商品详细]
* @return {[type]} [{}]
*/
const refundComputeAsync = (uid, orderCode, goods) => {
let options = {
method: 'app.refund.compute',
order_code: orderCode,
uid: uid,
goods: goods
};
return api.get('', options);
};
module.exports = {
getRefundGoodsAsync,
refundSubmit,
... ... @@ -241,5 +258,6 @@ module.exports = {
cancelRefundAsync,
cancelChangeAsync,
getDeliveryAsync,
setExpressNumberAsync
setExpressNumberAsync,
refundComputeAsync
};
... ...
... ... @@ -175,8 +175,7 @@ const getOrderRefund = (orderCode, uid) => {
if (result.data) {
let goods = [];
let returnReason = result.data.return_reason,
remarks = _.split(_.get(result, 'data.special_notice.remark', ''), ' ', 2), // 使用3个空格拆分
amount = 0;
remarks = _.split(_.get(result, 'data.special_notice.remark', ''), ' ', 2); // 使用3个空格拆分
_.forEach(_.get(result, 'data.goods_list', []), value => {
... ... @@ -187,7 +186,8 @@ const getOrderRefund = (orderCode, uid) => {
name: value.product_name,
color: value.factory_color_name,
size: value.size_name,
price: value.last_price,
lastPrice: value.last_price,
price: value.real_pay_price,
skn: value.product_skn,
skc: value.product_skc,
sku: value.product_sku,
... ... @@ -196,8 +196,6 @@ const getOrderRefund = (orderCode, uid) => {
reason: returnReason
};
amount += parseInt(value.last_price, 10);
// tar note 为每个特殊商品都添加标识
if (value.is_limit_skn === 'Y') {
item.specialNoticeBo = {
... ... @@ -228,14 +226,7 @@ const getOrderRefund = (orderCode, uid) => {
Object.assign(resData, {
goods: goods,
orderCode: orderCode,
// 计算相关支付细节
amount: amount - _.get(result, 'data.yoho_coin_num', 0) -
_.get(result, 'data.coupon_amount', 0),
yohoCoin: result.data.yoho_coin_num,
coupon: result.data.coupon_amount,
cash: amount
orderCode: orderCode
});
_.forEach(result.data.return_amount_mode, (val, key) => {
... ... @@ -528,7 +519,8 @@ const getOrderExchange = (orderCode, uid) => {
name: value.product_name,
color: value.color_name,
size: value.size_name,
price: value.last_price,
lastPrice: value.last_price,
price: value.real_pay_price,
skn: value.product_skn,
skc: value.product_skc,
sku: value.product_sku,
... ... @@ -647,6 +639,10 @@ const setExpressNumber = (id, expressId, expressNumber, uid, expressCompany, isC
});
};
const refundCompute = (uid, orderCode, goods) => {
return returnAPI.refundComputeAsync(uid, orderCode, goods);
};
module.exports = {
getReturnsList, // 我的订单,退换货列表
getOrderRefund, // 我的订单,申请退货
... ... @@ -658,5 +654,6 @@ module.exports = {
getDelivery, // 获取换货方式
getCancelRefund, // 取消退货申请
getCancelChange, // 取消换货申请
setExpressNumber // 设置快递
setExpressNumber, // 设置快递
refundCompute, // 退货结算
};
... ...
... ... @@ -91,6 +91,7 @@ router.post('/returns/getDelivery', tabsMiddleware.getCommonHeader, returnsContr
router.post('/returns/cancelRefund', tabsMiddleware.getCommonHeader, returnsController.cancelRefund);// 取消退货
router.post('/returns/cancelChange', tabsMiddleware.getCommonHeader, returnsController.cancelChange);// 取消换货
router.post('/returns/setExpressNumber', tabsMiddleware.getCommonHeader, returnsController.setExpressNumber);// 设置快递
router.post('/returns/api/refundCompute', returnsController.refundCompute);
router.get('/returns/success', returnsController.index);
... ...
... ... @@ -33,7 +33,7 @@
<input type="hidden" value="{{skn}}" name="skn">
<input type="hidden" value="{{skc}}" name="skc">
<input type="hidden" value="{{sku}}" name="sku">
<input type="hidden" value="{{price}}" name="price">
<input type="hidden" value="{{lastPrice}}" name="lastPrice">
<input type="hidden" value="{{goods_type_id}}" name="typeid">
<input type="checkbox" checked="true">
{{/unless}}
... ... @@ -154,7 +154,7 @@
<table id="goods-table" class="goods-list-table">
<tr>
<th colspan="3">请选择退货商品</th>
<th>价(元)</th>
<th>成交价(元)</th>
<th>退货原因</th>
</tr>
{{# goods}}
... ... @@ -164,7 +164,7 @@
<input type="hidden" value="{{skn}}" name="skn">
<input type="hidden" value="{{skc}}" name="skc">
<input type="hidden" value="{{sku}}" name="sku">
<input type="hidden" value="{{price}}" name="price">
<input type="hidden" value="{{lastPrice}}" name="lastPrice">
<input type="hidden" value="{{goods_type_id}}" name="typeid">
{{#unless isLimitSkn}}
<input type="checkbox" checked="true">
... ... @@ -211,7 +211,7 @@
{{/ goods}}
<tr>
<td colspan="5">
<p class="re-tips">订单金额:¥{{amount}} (¥{{cash}} 现金 - ¥{{yohoCoin}} 有货币 - ¥{{coupon}} 优惠券)</p>
<p class="re-tips"></p>
</td>
</tr>
</table>
... ...
... ... @@ -11,7 +11,7 @@ const isTest = process.env.NODE_ENV === 'test';
module.exports = {
app: 'web',
appVersion: '5.7.0', // 调用api的版本
appVersion: '5.8.0', // 调用api的版本
port: 6002,
siteUrl: 'http://www.yohobuy.com',
cookieDomain: '.yohobuy.com',
... ...
{{#if return_amount}}退款总金额:¥{{return_amount}}{{/if}}{{#if return_asset_desc}}({{return_asset_desc}}){{/if}}
... ...
... ... @@ -7,6 +7,8 @@ var $ = require('yoho-jquery'),
Addr = require('./common-address'),
_dialog = require('../common/dialog');
var reTipsHbs = require('hbs/home/orders/re-tips.hbs');
var stringHandle = require('../common/stringHandle');
var $goodsTable = $('#goods-table'),
... ... @@ -75,6 +77,47 @@ if (defaultPhone) {
$exchange.find('input[name="phone"]').val(disPhone);
}
// 退货结算
function getRefundCompute () {
var goods = [];
if (!pageType) {
return false;
}
$goodsTable.find('input[type="checkbox"]:checked').each(function() {
var $par = $(this).closest('tr'),
goodsInfo;
goodsInfo = {
product_skn: $par.find('input[name="skn"]').val(),
product_skc: $par.find('input[name="skc"]').val(),
product_sku: $par.find('input[name="sku"]').val(),
goods_type: $par.find('input[name="typeid"]').val(),
last_price: $par.find('input[name="lastPrice"]').val()
};
goods.push(goodsInfo);
});
if (goods.length <= 0) {
return false;
}
$.ajax({
type: 'POST',
url: '/home/returns/api/refundCompute',
data: {
orderCode: orderCode,
goods: JSON.stringify(goods)
}
}).then(function(d) {
if (d.code === 200) {
$('.re-tips').html(reTipsHbs(d.data));
}
});
}
function syncRefundMode(code) {
$.ajax({
type: 'POST',
... ... @@ -236,6 +279,8 @@ $checkBox.change(function() {
$par.find('select').val(0).prop('disabled', true);
$par.next().hide();
}
getRefundCompute();
});
$goodsTable.on('change', '.exchange-color', function() {
... ... @@ -374,7 +419,7 @@ function packGoogsList() {
product_skc: $par.find('input[name="skc"]').val(),
product_sku: $par.find('input[name="sku"]').val(),
goods_type: $par.find('input[name="typeid"]').val(),
last_price: $par.find('input[name="price"]').val(),
last_price: $par.find('input[name="lastPrice"]').val(),
reason: $par.find('.return-reason').val() * 1
};
... ... @@ -626,3 +671,6 @@ $('.save-btn').click(function() {
}
});
// 退货结算
getRefundCompute();
... ...
... ... @@ -149,6 +149,7 @@
text-align: left;
padding-left: 10px;
color: #666;
min-height: 18px;
}
.problem-description {
... ...
... ... @@ -110,4 +110,16 @@
display: none;
}
}
.cancel-return {
padding-left: 12px;
a {
color: #fff;
border-radius: 4px;
padding: 4px 8px;
background: #000;
display: inline-block;
}
}
}
... ...