q-koa 12.2.5 → 12.2.8
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 +16 -11
- package/core/file/plugins/weixin/service.js +49 -5
- package/package.json +2 -2
package/core/app.js
CHANGED
|
@@ -527,6 +527,11 @@ class APP {
|
|
|
527
527
|
const pluginDirResult = pluginDirList.filter(
|
|
528
528
|
(item) => !excludesModel.includes(item)
|
|
529
529
|
)
|
|
530
|
+
const log_push_url = _.get(
|
|
531
|
+
this.app[appName],
|
|
532
|
+
'appConfig.log_push_url',
|
|
533
|
+
'https://api.day.app/ieaRfoE3LiPveGbY5qmUwk'
|
|
534
|
+
)
|
|
530
535
|
for (let i = 0; i < pluginDirResult.length; i++) {
|
|
531
536
|
const folder = pluginDirResult[i]
|
|
532
537
|
const isFolder = fs
|
|
@@ -625,11 +630,7 @@ class APP {
|
|
|
625
630
|
'indexList',
|
|
626
631
|
[]
|
|
627
632
|
)
|
|
628
|
-
|
|
629
|
-
this.app[appName],
|
|
630
|
-
'appConfig.log_push_url',
|
|
631
|
-
[]
|
|
632
|
-
)
|
|
633
|
+
|
|
633
634
|
const instance = this.app[appName].sequelize.define(
|
|
634
635
|
folder,
|
|
635
636
|
attributes,
|
|
@@ -647,13 +648,17 @@ class APP {
|
|
|
647
648
|
beforeCreate: (res, t) => {
|
|
648
649
|
try {
|
|
649
650
|
if (folder === 'log' && log_push_url) {
|
|
650
|
-
|
|
651
|
-
.
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
651
|
+
const logUrl = `${log_push_url}/${appName}/${encodeURIComponent(
|
|
652
|
+
res.toJSON().message
|
|
653
|
+
)}`
|
|
654
|
+
console.log(logUrl)
|
|
655
|
+
axios({
|
|
656
|
+
url: logUrl,
|
|
657
|
+
method: 'get',
|
|
658
|
+
timeout: 3000,
|
|
659
|
+
})
|
|
656
660
|
.then((res) => res.data)
|
|
661
|
+
.catch((e) => console.log(e.message))
|
|
657
662
|
}
|
|
658
663
|
if (res.toJSON().user_id) {
|
|
659
664
|
res.createdid = res.toJSON().user_id
|
|
@@ -25,6 +25,7 @@ exports.refund = async ({
|
|
|
25
25
|
pay_config = 'weixin_pay',
|
|
26
26
|
out_trade_no: _out_trade_no,
|
|
27
27
|
out_refund_no: _out_refund_no,
|
|
28
|
+
is_pem = false,
|
|
28
29
|
...rest
|
|
29
30
|
}) => {
|
|
30
31
|
if (!ctx) throw new Error('?ctx')
|
|
@@ -44,7 +45,7 @@ exports.refund = async ({
|
|
|
44
45
|
__dirname,
|
|
45
46
|
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.p12`
|
|
46
47
|
)
|
|
47
|
-
),
|
|
48
|
+
),
|
|
48
49
|
})
|
|
49
50
|
const orderModel = prefix ? `${prefix}_order` : 'order'
|
|
50
51
|
const out_trade_no = _out_trade_no
|
|
@@ -63,6 +64,22 @@ exports.refund = async ({
|
|
|
63
64
|
appid: appId,
|
|
64
65
|
mch_id: mchId,
|
|
65
66
|
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
67
|
+
...(is_pem
|
|
68
|
+
? {
|
|
69
|
+
cert_pem: await fsPromise.readFile(
|
|
70
|
+
path.resolve(
|
|
71
|
+
__dirname,
|
|
72
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.pem`
|
|
73
|
+
)
|
|
74
|
+
),
|
|
75
|
+
key_pem: await fsPromise.readFile(
|
|
76
|
+
path.resolve(
|
|
77
|
+
__dirname,
|
|
78
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_key.pem`
|
|
79
|
+
)
|
|
80
|
+
),
|
|
81
|
+
}
|
|
82
|
+
: {}),
|
|
66
83
|
})
|
|
67
84
|
const payResult = await wxpay.queryOrderSync({
|
|
68
85
|
out_trade_no,
|
|
@@ -86,7 +103,9 @@ exports.refund = async ({
|
|
|
86
103
|
}
|
|
87
104
|
|
|
88
105
|
console.log(data)
|
|
89
|
-
const { result_code, err_code_des, ...restData } =
|
|
106
|
+
const { result_code, err_code_des, ...restData } = is_pem
|
|
107
|
+
? await wxpay.refund(data)
|
|
108
|
+
: await payObj.refund(data)
|
|
90
109
|
if (result_code === 'SUCCESS') {
|
|
91
110
|
const hasResult = await app.model.order_refund_record.findOne({
|
|
92
111
|
where: {
|
|
@@ -119,6 +138,7 @@ exports.refundOnly = async ({
|
|
|
119
138
|
pay_config = 'weixin_pay',
|
|
120
139
|
out_trade_no: _out_trade_no,
|
|
121
140
|
out_refund_no: _out_refund_no,
|
|
141
|
+
is_pem = false,
|
|
122
142
|
...rest
|
|
123
143
|
}) => {
|
|
124
144
|
if (!ctx) throw new Error('?ctx')
|
|
@@ -148,6 +168,22 @@ exports.refundOnly = async ({
|
|
|
148
168
|
appid: appId,
|
|
149
169
|
mch_id: mchId,
|
|
150
170
|
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
171
|
+
...(is_pem
|
|
172
|
+
? {
|
|
173
|
+
cert_pem: await fsPromise.readFile(
|
|
174
|
+
path.resolve(
|
|
175
|
+
__dirname,
|
|
176
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.pem`
|
|
177
|
+
)
|
|
178
|
+
),
|
|
179
|
+
key_pem: await fsPromise.readFile(
|
|
180
|
+
path.resolve(
|
|
181
|
+
__dirname,
|
|
182
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_key.pem`
|
|
183
|
+
)
|
|
184
|
+
),
|
|
185
|
+
}
|
|
186
|
+
: {}),
|
|
151
187
|
})
|
|
152
188
|
|
|
153
189
|
try {
|
|
@@ -161,7 +197,9 @@ exports.refundOnly = async ({
|
|
|
161
197
|
}
|
|
162
198
|
|
|
163
199
|
console.log(data)
|
|
164
|
-
const { result_code, err_code_des, ...restData } = await
|
|
200
|
+
const { result_code, err_code_des, ...restData } = (await is_pem)
|
|
201
|
+
? await wxpay.refund(data)
|
|
202
|
+
: await payObj.refund(data)
|
|
165
203
|
if (result_code === 'SUCCESS') {
|
|
166
204
|
return restData
|
|
167
205
|
} else {
|
|
@@ -633,10 +671,16 @@ exports.profitsharing = async ({
|
|
|
633
671
|
appid: app_id,
|
|
634
672
|
mch_id: mchId,
|
|
635
673
|
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
636
|
-
|
|
674
|
+
cert_pem: await fsPromise.readFile(
|
|
637
675
|
path.resolve(
|
|
638
676
|
__dirname,
|
|
639
|
-
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.
|
|
677
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.pem`
|
|
678
|
+
)
|
|
679
|
+
),
|
|
680
|
+
key_pem: await fsPromise.readFile(
|
|
681
|
+
path.resolve(
|
|
682
|
+
__dirname,
|
|
683
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_key.pem`
|
|
640
684
|
)
|
|
641
685
|
),
|
|
642
686
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "q-koa",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"sequelize": "^5.21.3",
|
|
55
55
|
"static-koa-router": "^1.0.3",
|
|
56
56
|
"wechat-oauth": "^1.5.0",
|
|
57
|
-
"weixin-pay-fork": "^1.0.
|
|
57
|
+
"weixin-pay-fork": "^1.0.7",
|
|
58
58
|
"node-uuid": "^1.4.8",
|
|
59
59
|
"sha1": "^1.1.1",
|
|
60
60
|
"redis": "^4.0.3",
|