q-koa 12.0.1 → 12.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -52,23 +52,36 @@ exports.refund = async ({
|
|
|
52
52
|
include: app.model.order_refund_record,
|
|
53
53
|
})
|
|
54
54
|
if (!orderDetail) throw new Error('不存在该订单')
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const wxpay = WXPay({
|
|
56
|
+
appid: appId,
|
|
57
|
+
mch_id: mchId,
|
|
58
|
+
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
59
|
+
})
|
|
60
|
+
const payResult = await wxpay.queryOrderSync({
|
|
61
|
+
out_trade_no,
|
|
62
|
+
})
|
|
58
63
|
|
|
64
|
+
try {
|
|
65
|
+
const refundRecords = lodash.get(orderDetail, 'order_refund_records', [])
|
|
66
|
+
const refundNumber = refundRecords.length + 1
|
|
67
|
+
console.log(refundNumber, `${prefix}-${id}_${type}-${refundNumber}`)
|
|
59
68
|
const data = {
|
|
60
69
|
...rest,
|
|
61
70
|
out_trade_no,
|
|
62
|
-
out_refund_no: `${prefix}-${id}_${type
|
|
63
|
-
total_fee:
|
|
71
|
+
out_refund_no: `${prefix}-${id}_${type}-${refundNumber}`,
|
|
72
|
+
total_fee: Number(payResult.total_fee),
|
|
64
73
|
refund_fee: Math.round((refund_fee || price) * 100),
|
|
65
74
|
notify_url: `https://${
|
|
66
75
|
site_host || 'api.kuashou.com'
|
|
67
76
|
}/${appName}/weixin/refund_notify/${pay_config}`,
|
|
68
77
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
|
|
79
|
+
const {
|
|
80
|
+
result_code,
|
|
81
|
+
err_code_des,
|
|
82
|
+
out_refund_no,
|
|
83
|
+
...restData
|
|
84
|
+
} = await payObj.refund(data)
|
|
72
85
|
if (result_code === 'SUCCESS') {
|
|
73
86
|
const hasResult = await app.model.order_refund_record.findOne({
|
|
74
87
|
where: {
|
|
@@ -84,7 +97,7 @@ exports.refund = async ({
|
|
|
84
97
|
throw new Error(err_code_des)
|
|
85
98
|
}
|
|
86
99
|
} catch (e) {
|
|
87
|
-
throw new Error(e)
|
|
100
|
+
throw new Error(e.message)
|
|
88
101
|
}
|
|
89
102
|
}
|
|
90
103
|
|