...
|
...
|
@@ -194,13 +194,35 @@ const updateOrderPayBank = (code, payment, bankCode) => { |
|
|
*/
|
|
|
const sendPayConfirm = (code, payment, uid) => {
|
|
|
return co(function *() {
|
|
|
let data = yield payApi.sendPayConfirm(code, payment, uid);
|
|
|
|
|
|
return data;
|
|
|
return yield payApi.sendPayConfirm(code, payment, uid);
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* [公共支付成功数据处理]
|
|
|
* @param {[type]} orderInfo [订单信息]
|
|
|
* @param {[type]} fraudData [资源位数据]
|
|
|
* @return {[type]} [{}]
|
|
|
*/
|
|
|
const _execOrderData = (orderInfo, fraudData) => {
|
|
|
let fraud = _.result(_.find(fraudData, {template_name: 'text'}), 'data') || {};
|
|
|
|
|
|
return {
|
|
|
paymentTypes: (orderInfo.payment_type === 1 ? '在线支付' : '货到付款'),
|
|
|
multiPackage: orderInfo.is_multi_package === 'Y',
|
|
|
ordersUrl: helpers.urlFormat('/home/orders'),
|
|
|
vipUrl: helpers.urlFormat('/help/detail', {id: 9}),
|
|
|
returnGoodsUrl: helpers.urlFormat('/help/detail', {id: 49}),
|
|
|
yohoCoinUrl: helpers.urlFormat('/help/detail', {id: 105, contId: 233}),
|
|
|
detailUrl: helpers.urlFormat('/home/orders/detail', {
|
|
|
orderCode: orderInfo.order_code
|
|
|
}),
|
|
|
packageTitle: orderInfo.package_title || '商品需要品牌商调货',
|
|
|
fraudTip: fraud.text || ''
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 支付成功,前端回调时,处理订单信息
|
|
|
* @param payResult
|
|
|
* @param uid
|
...
|
...
|
@@ -217,16 +239,12 @@ const procOrderData = (payResult, uid) => { |
|
|
|
|
|
return Promise.all([orderDetail(uid, orderCode), payApi.getResourceData(FRAUD_CONTENT_CODE)]).then(procData => {
|
|
|
let orderInfo = procData[0].code === 200 && procData[0].data;
|
|
|
let fraudData = _.result(_.find(procData[1].data, {template_name: 'text'}), 'data') || {};
|
|
|
let resultOrder;
|
|
|
|
|
|
if (!orderInfo) {
|
|
|
result.message = '订单不存在!';
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
let amount = orderInfo.payment_amount;
|
|
|
|
|
|
if (orderInfo.is_cancel === 'Y') {
|
|
|
logger.warn('front pay success but order is cancel.', {payResult: payResult, order: orderInfo});
|
|
|
return {code: 417, message: '支付成功,但订单已取消,需联系客服!'};
|
...
|
...
|
@@ -236,7 +254,7 @@ const procOrderData = (payResult, uid) => { |
|
|
logger.warn('front pay success but may be notify fail');
|
|
|
}
|
|
|
|
|
|
if (_.round(parseFloat(amount), 2) !== _.round(parseFloat(payResult.totalFee), 2)) {
|
|
|
if (_.round(parseFloat(orderInfo.payment_amount), 2) !== _.round(parseFloat(payResult.totalFee), 2)) {
|
|
|
logger.warn('front pay success but the amount is not same.', {payResult: payResult, order: orderInfo});
|
|
|
return {
|
|
|
code: 415,
|
...
|
...
|
@@ -244,24 +262,11 @@ const procOrderData = (payResult, uid) => { |
|
|
};
|
|
|
}
|
|
|
|
|
|
resultOrder = {
|
|
|
paymentTypes: (orderInfo.payment_type === 1 ? '在线支付' : '货到付款'),
|
|
|
multiPackage: orderInfo.is_multi_package === 'Y',
|
|
|
ordersUrl: helpers.urlFormat('/home/orders'),
|
|
|
vipUrl: helpers.urlFormat('/help/detail', {id: 9}),
|
|
|
returnGoodsUrl: helpers.urlFormat('/help/detail', {id: 49}),
|
|
|
yohoCoinUrl: helpers.urlFormat('/help/detail', {id: 105, contId: 233}),
|
|
|
detailUrl: helpers.urlFormat('/home/orders/detail', {
|
|
|
orderCode: orderInfo.order_code
|
|
|
}),
|
|
|
packageTitle: orderInfo.package_title || '商品需要品牌商调货',
|
|
|
fraudTip: fraudData.text || ''
|
|
|
};
|
|
|
return {
|
|
|
code: 200,
|
|
|
message: '支付成功,请等待发货',
|
|
|
data: {
|
|
|
order: Object.assign(orderInfo, resultOrder)
|
|
|
order: Object.assign(orderInfo, _execOrderData(orderInfo, procData[1] && procData[1].data || {}))
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
@@ -269,6 +274,17 @@ const procOrderData = (payResult, uid) => { |
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* [0元订单或者货到付款-成功处理]
|
|
|
* @param {[type]} orderInfo [订单详情]
|
|
|
* @return {[type]} [{}]
|
|
|
*/
|
|
|
const deliveryData = (orderInfo) => {
|
|
|
return payApi.getResourceData(FRAUD_CONTENT_CODE).then(procData => {
|
|
|
return Object.assign(orderInfo, _execOrderData(orderInfo, procData && procData.data || {}));
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
orderDetail,
|
|
|
getPayInfo,
|
...
|
...
|
@@ -279,6 +295,7 @@ module.exports = { |
|
|
sendPayConfirm,
|
|
|
procOrderData,
|
|
|
updateOrderPayment,
|
|
|
payments
|
|
|
payments,
|
|
|
deliveryData
|
|
|
};
|
|
|
|
...
|
...
|
|