q-koa 12.0.2 → 12.0.4

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.
package/core/app.js CHANGED
@@ -1877,9 +1877,13 @@ class APP {
1877
1877
  )
1878
1878
 
1879
1879
  const flag = await app[appName].model[controller][fn]({
1880
- createdid: ctx.request[`${appName}-user`]
1881
- ? ctx.request[`${appName}-user`].id
1882
- : 0,
1880
+ ...(ctx.request.clientType === 1
1881
+ ? {}
1882
+ : {
1883
+ createdid: ctx.request[`${appName}-user`]
1884
+ ? ctx.request[`${appName}-user`].id
1885
+ : 0,
1886
+ }),
1883
1887
  ...newData,
1884
1888
  })
1885
1889
  if (fn === 'create') {
@@ -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
+ 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
+ })
63
+
55
64
  try {
56
65
  const refundRecords = lodash.get(orderDetail, 'order_refund_records', [])
57
66
  const refundNumber = refundRecords.length + 1
58
-
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 ? type + '-' + refundNumber : ''}`,
63
- total_fee: Math.round((total_fee || refund_fee || price) * 100),
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
- const { result_code, err_code_des, out_refund_no } = await payObj.refund(
70
- data
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "12.0.2",
3
+ "version": "12.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {