q-koa 12.2.9 → 12.3.1
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.
|
@@ -30,6 +30,7 @@ exports.refund = async ({
|
|
|
30
30
|
}) => {
|
|
31
31
|
if (!ctx) throw new Error('?ctx')
|
|
32
32
|
const { app, appName } = getAppByCtx(ctx)
|
|
33
|
+
const isPem = is_pem || lodash.get(app, 'appConfig.is_pem', false)
|
|
33
34
|
const appConfig = getConfig(app)
|
|
34
35
|
const { mchId, key, appId, partner_key } = await appConfig.getObject(
|
|
35
36
|
pay_config
|
|
@@ -64,7 +65,7 @@ exports.refund = async ({
|
|
|
64
65
|
appid: appId,
|
|
65
66
|
mch_id: mchId,
|
|
66
67
|
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
67
|
-
...(
|
|
68
|
+
...(isPem
|
|
68
69
|
? {
|
|
69
70
|
cert_pem: await fsPromise.readFile(
|
|
70
71
|
path.resolve(
|
|
@@ -103,7 +104,7 @@ exports.refund = async ({
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
console.log(data)
|
|
106
|
-
const { result_code, err_code_des, ...restData } =
|
|
107
|
+
const { result_code, err_code_des, ...restData } = isPem
|
|
107
108
|
? await wxpay.refund(data)
|
|
108
109
|
: await payObj.refund(data)
|
|
109
110
|
if (result_code === 'SUCCESS') {
|
|
@@ -143,6 +144,7 @@ exports.refundOnly = async ({
|
|
|
143
144
|
}) => {
|
|
144
145
|
if (!ctx) throw new Error('?ctx')
|
|
145
146
|
const { app, appName } = getAppByCtx(ctx)
|
|
147
|
+
const isPem = is_pem || lodash.get(app, 'appConfig.is_pem', false)
|
|
146
148
|
const appConfig = getConfig(app)
|
|
147
149
|
const { mchId, key, appId, partner_key } = await appConfig.getObject(
|
|
148
150
|
pay_config
|
|
@@ -168,7 +170,7 @@ exports.refundOnly = async ({
|
|
|
168
170
|
appid: appId,
|
|
169
171
|
mch_id: mchId,
|
|
170
172
|
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
171
|
-
...(
|
|
173
|
+
...(isPem
|
|
172
174
|
? {
|
|
173
175
|
cert_pem: await fsPromise.readFile(
|
|
174
176
|
path.resolve(
|
|
@@ -197,7 +199,7 @@ exports.refundOnly = async ({
|
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
console.log(data)
|
|
200
|
-
const { result_code, err_code_des, ...restData } = (await
|
|
202
|
+
const { result_code, err_code_des, ...restData } = (await isPem)
|
|
201
203
|
? await wxpay.refund(data)
|
|
202
204
|
: await payObj.refund(data)
|
|
203
205
|
if (result_code === 'SUCCESS') {
|
|
@@ -659,6 +661,9 @@ exports.profitsharing = async ({
|
|
|
659
661
|
pay_config = 'weixin_pay',
|
|
660
662
|
}) => {
|
|
661
663
|
if (!ctx) throw new Error('?ctx')
|
|
664
|
+
if (amount === 0) throw new Error(`amount不能为0`)
|
|
665
|
+
if (amount % 1 !== 0) throw new Error(`amount需要是整数`)
|
|
666
|
+
|
|
662
667
|
const { app, appName } = getAppByCtx(ctx)
|
|
663
668
|
|
|
664
669
|
const appConfig = getConfig(app)
|