q-koa 10.6.0 → 10.6.2
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.
|
@@ -909,14 +909,6 @@ exports.mp_pay = async (ctx) => {
|
|
|
909
909
|
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
910
910
|
})
|
|
911
911
|
|
|
912
|
-
const pay = (options) =>
|
|
913
|
-
new Promise((resolve, reject) => {
|
|
914
|
-
wxpay.getBrandWCPayRequestParams(options, (err, result) => {
|
|
915
|
-
if (err) return reject(err)
|
|
916
|
-
return resolve(result)
|
|
917
|
-
})
|
|
918
|
-
})
|
|
919
|
-
|
|
920
912
|
const userDetail =
|
|
921
913
|
type === 'H5-WEIXIN'
|
|
922
914
|
? ctx.request[`${appName}-user`].h5_user
|
|
@@ -931,7 +923,8 @@ exports.mp_pay = async (ctx) => {
|
|
|
931
923
|
const notify_url = `https://${
|
|
932
924
|
site_host || 'api.kuashou.com'
|
|
933
925
|
}/${appName}/weixin/notify`
|
|
934
|
-
|
|
926
|
+
|
|
927
|
+
const prePayResult = await wxpay.getBrandWCPayRequestParamsSync({
|
|
935
928
|
openid: userDetail.openid,
|
|
936
929
|
body: name,
|
|
937
930
|
detail: '公众号支付测试',
|
|
@@ -1550,115 +1543,64 @@ exports.messagePush = async (ctx) => {
|
|
|
1550
1543
|
exports.profitsharing = async (ctx) => {
|
|
1551
1544
|
const { app, appName } = getAppByCtx(ctx)
|
|
1552
1545
|
const {
|
|
1553
|
-
transaction_id
|
|
1554
|
-
out_order_no
|
|
1555
|
-
type
|
|
1556
|
-
amount
|
|
1557
|
-
openid
|
|
1558
|
-
description
|
|
1559
|
-
config
|
|
1560
|
-
pay_config
|
|
1546
|
+
transaction_id,
|
|
1547
|
+
out_order_no,
|
|
1548
|
+
type,
|
|
1549
|
+
amount,
|
|
1550
|
+
openid,
|
|
1551
|
+
description,
|
|
1552
|
+
config,
|
|
1553
|
+
pay_config,
|
|
1561
1554
|
} = ctx.request.body
|
|
1555
|
+
|
|
1562
1556
|
if (!amount) return ctx.ERROR('?amount分')
|
|
1563
1557
|
if (!transaction_id) return ctx.ERROR('?transaction_id')
|
|
1564
1558
|
if (!out_order_no) return ctx.ERROR('?out_order_no')
|
|
1565
1559
|
if (!openid) return ctx.ERROR('?openid')
|
|
1566
1560
|
|
|
1567
|
-
const
|
|
1568
|
-
|
|
1569
|
-
const { mchId, key, partner_key } = await appConfig.getObject(pay_config)
|
|
1570
|
-
|
|
1571
|
-
const app_id = (await appConfig.getObject(config)).app_id
|
|
1572
|
-
|
|
1573
|
-
const wxpay = WXPay({
|
|
1574
|
-
appid: app_id,
|
|
1575
|
-
mch_id: mchId,
|
|
1576
|
-
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
1577
|
-
pfx: await fsPromise.readFile(
|
|
1578
|
-
path.resolve(
|
|
1579
|
-
__dirname,
|
|
1580
|
-
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.p12`
|
|
1581
|
-
)
|
|
1582
|
-
),
|
|
1583
|
-
})
|
|
1584
|
-
|
|
1585
|
-
const res = await wxpay.profitsharingSync({
|
|
1561
|
+
const res = await app.service.weixin.profitsharing({
|
|
1562
|
+
ctx,
|
|
1586
1563
|
transaction_id,
|
|
1587
1564
|
out_order_no,
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
},
|
|
1595
|
-
],
|
|
1565
|
+
type,
|
|
1566
|
+
openid,
|
|
1567
|
+
description,
|
|
1568
|
+
amount,
|
|
1569
|
+
config,
|
|
1570
|
+
pay_config,
|
|
1596
1571
|
})
|
|
1597
1572
|
return ctx.SUCCESS(res)
|
|
1598
1573
|
}
|
|
1599
1574
|
|
|
1600
1575
|
exports.addreceiver = async (ctx) => {
|
|
1601
1576
|
const { app, appName } = getAppByCtx(ctx)
|
|
1602
|
-
const {
|
|
1603
|
-
type = 'PERSONAL_OPENID',
|
|
1604
|
-
openid = '',
|
|
1605
|
-
relation_type = 'USER',
|
|
1606
|
-
config = 'weixin_mp',
|
|
1607
|
-
pay_config = 'weixin_pay',
|
|
1608
|
-
} = ctx.request.body
|
|
1577
|
+
const { type, openid, relation_type, config, pay_config } = ctx.request.body
|
|
1609
1578
|
|
|
1610
1579
|
if (!openid) return ctx.ERROR('?openid')
|
|
1611
1580
|
|
|
1612
|
-
const
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
appid: app_id,
|
|
1620
|
-
mch_id: mchId,
|
|
1621
|
-
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
1622
|
-
})
|
|
1623
|
-
|
|
1624
|
-
const res = await wxpay.addreceiverSync({
|
|
1625
|
-
receiver: {
|
|
1626
|
-
type,
|
|
1627
|
-
account: openid,
|
|
1628
|
-
relation_type,
|
|
1629
|
-
},
|
|
1581
|
+
const res = await app.service.weixin.addreceiver({
|
|
1582
|
+
ctx,
|
|
1583
|
+
type,
|
|
1584
|
+
openid,
|
|
1585
|
+
relation_type,
|
|
1586
|
+
config,
|
|
1587
|
+
pay_config,
|
|
1630
1588
|
})
|
|
1631
1589
|
return ctx.SUCCESS(res)
|
|
1632
1590
|
}
|
|
1633
1591
|
|
|
1634
1592
|
exports.removereceiver = async (ctx) => {
|
|
1635
1593
|
const { app, appName } = getAppByCtx(ctx)
|
|
1636
|
-
const {
|
|
1637
|
-
type = 'PERSONAL_OPENID',
|
|
1638
|
-
openid = '',
|
|
1639
|
-
config = 'weixin_mp',
|
|
1640
|
-
pay_config = 'weixin_pay',
|
|
1641
|
-
} = ctx.request.body
|
|
1594
|
+
const { type, openid, config, pay_config } = ctx.request.body
|
|
1642
1595
|
|
|
1643
1596
|
if (!openid) return ctx.ERROR('?openid')
|
|
1644
1597
|
|
|
1645
|
-
const
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
const wxpay = WXPay({
|
|
1652
|
-
appid: app_id,
|
|
1653
|
-
mch_id: mchId,
|
|
1654
|
-
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
1655
|
-
})
|
|
1656
|
-
|
|
1657
|
-
const res = await wxpay.removereceiverSync({
|
|
1658
|
-
receiver: {
|
|
1659
|
-
type,
|
|
1660
|
-
account: openid,
|
|
1661
|
-
},
|
|
1598
|
+
const res = await app.service.weixin.removereceiver({
|
|
1599
|
+
ctx,
|
|
1600
|
+
type,
|
|
1601
|
+
openid,
|
|
1602
|
+
config,
|
|
1603
|
+
pay_config,
|
|
1662
1604
|
})
|
|
1663
1605
|
return ctx.SUCCESS(res)
|
|
1664
1606
|
}
|
|
@@ -19,6 +19,7 @@ exports.refund = async ({
|
|
|
19
19
|
out_trade_no: _out_trade_no,
|
|
20
20
|
...rest
|
|
21
21
|
}) => {
|
|
22
|
+
if (!ctx) throw new Error('?ctx')
|
|
22
23
|
const { app, appName } = getAppByCtx(ctx)
|
|
23
24
|
const appConfig = getConfig(app)
|
|
24
25
|
const { mchId, key, appId, partner_key } = await appConfig.getObject(
|
|
@@ -94,6 +95,7 @@ exports.refund_new = async ({
|
|
|
94
95
|
out_trade_no: _out_trade_no,
|
|
95
96
|
...rest
|
|
96
97
|
}) => {
|
|
98
|
+
if (!ctx) throw new Error('?ctx')
|
|
97
99
|
const { app, appName } = getAppByCtx(ctx)
|
|
98
100
|
const appConfig = getConfig(app)
|
|
99
101
|
|
|
@@ -162,6 +164,7 @@ exports.cash = async ({
|
|
|
162
164
|
number,
|
|
163
165
|
pay_config = 'weixin_pay',
|
|
164
166
|
}) => {
|
|
167
|
+
if (!ctx) throw new Error('?ctx')
|
|
165
168
|
const { app, appName } = getAppByCtx(ctx)
|
|
166
169
|
const appConfig = getConfig(app)
|
|
167
170
|
|
|
@@ -455,6 +458,7 @@ exports.pc_pay = async ({
|
|
|
455
458
|
type = 'PC-WEIXIN',
|
|
456
459
|
prefix = '',
|
|
457
460
|
}) => {
|
|
461
|
+
if (!ctx) throw new Error('?ctx')
|
|
458
462
|
if (!order_id) throw new Error('缺order_id')
|
|
459
463
|
if (!price) throw new Error('缺price')
|
|
460
464
|
if (!name) throw new Error('缺name')
|
|
@@ -509,3 +513,114 @@ exports.pc_pay = async ({
|
|
|
509
513
|
site_host || 'api.kuashou.com'
|
|
510
514
|
}/${appName}/common/createQr?url=${result.code_url}`
|
|
511
515
|
}
|
|
516
|
+
|
|
517
|
+
exports.profitsharing = async ({
|
|
518
|
+
ctx,
|
|
519
|
+
transaction_id = '',
|
|
520
|
+
out_order_no = '',
|
|
521
|
+
type = 'PERSONAL_OPENID',
|
|
522
|
+
amount = 0,
|
|
523
|
+
openid = '',
|
|
524
|
+
description = '手续费',
|
|
525
|
+
config = 'weixin_mp',
|
|
526
|
+
pay_config = 'weixin_pay',
|
|
527
|
+
}) => {
|
|
528
|
+
if (!ctx) throw new Error('?ctx')
|
|
529
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
530
|
+
|
|
531
|
+
const appConfig = getConfig(app)
|
|
532
|
+
|
|
533
|
+
const { mchId, key, partner_key } = await appConfig.getObject(pay_config)
|
|
534
|
+
|
|
535
|
+
const app_id = (await appConfig.getObject(config)).app_id
|
|
536
|
+
|
|
537
|
+
const wxpay = WXPay({
|
|
538
|
+
appid: app_id,
|
|
539
|
+
mch_id: mchId,
|
|
540
|
+
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
541
|
+
pfx: await fsPromise.readFile(
|
|
542
|
+
path.resolve(
|
|
543
|
+
__dirname,
|
|
544
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.p12`
|
|
545
|
+
)
|
|
546
|
+
),
|
|
547
|
+
})
|
|
548
|
+
|
|
549
|
+
const res = await wxpay.profitsharingSync({
|
|
550
|
+
transaction_id,
|
|
551
|
+
out_order_no,
|
|
552
|
+
receivers: [
|
|
553
|
+
{
|
|
554
|
+
type,
|
|
555
|
+
account: openid,
|
|
556
|
+
description,
|
|
557
|
+
amount,
|
|
558
|
+
},
|
|
559
|
+
],
|
|
560
|
+
})
|
|
561
|
+
return res
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
exports.addreceiver = async ({
|
|
565
|
+
ctx,
|
|
566
|
+
type = 'PERSONAL_OPENID',
|
|
567
|
+
openid = '',
|
|
568
|
+
relation_type = 'USER',
|
|
569
|
+
config = 'weixin_mp',
|
|
570
|
+
pay_config = 'weixin_pay',
|
|
571
|
+
}) => {
|
|
572
|
+
if (!ctx) throw new Error('?ctx')
|
|
573
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
574
|
+
|
|
575
|
+
const appConfig = getConfig(app)
|
|
576
|
+
|
|
577
|
+
const { mchId, key, partner_key } = await appConfig.getObject(pay_config)
|
|
578
|
+
|
|
579
|
+
const app_id = (await appConfig.getObject(config)).app_id
|
|
580
|
+
|
|
581
|
+
const wxpay = WXPay({
|
|
582
|
+
appid: app_id,
|
|
583
|
+
mch_id: mchId,
|
|
584
|
+
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
585
|
+
})
|
|
586
|
+
|
|
587
|
+
const res = await wxpay.addreceiverSync({
|
|
588
|
+
receiver: {
|
|
589
|
+
type,
|
|
590
|
+
account: openid,
|
|
591
|
+
relation_type,
|
|
592
|
+
},
|
|
593
|
+
})
|
|
594
|
+
return res
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
exports.removereceiver = async ({
|
|
598
|
+
ctx,
|
|
599
|
+
type = 'PERSONAL_OPENID',
|
|
600
|
+
openid = '',
|
|
601
|
+
config = 'weixin_mp',
|
|
602
|
+
pay_config = 'weixin_pay',
|
|
603
|
+
}) => {
|
|
604
|
+
if (!ctx) throw new Error('?ctx')
|
|
605
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
606
|
+
|
|
607
|
+
const appConfig = getConfig(app)
|
|
608
|
+
|
|
609
|
+
const { mchId, key, partner_key } = await appConfig.getObject(pay_config)
|
|
610
|
+
|
|
611
|
+
const app_id = (await appConfig.getObject(config)).app_id
|
|
612
|
+
|
|
613
|
+
const wxpay = WXPay({
|
|
614
|
+
appid: app_id,
|
|
615
|
+
mch_id: mchId,
|
|
616
|
+
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
617
|
+
})
|
|
618
|
+
|
|
619
|
+
const res = await wxpay.removereceiverSync({
|
|
620
|
+
receiver: {
|
|
621
|
+
type,
|
|
622
|
+
account: openid,
|
|
623
|
+
},
|
|
624
|
+
})
|
|
625
|
+
return res
|
|
626
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "q-koa",
|
|
3
|
-
"version": "10.6.
|
|
3
|
+
"version": "10.6.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"sequelize": "^5.21.3",
|
|
53
53
|
"static-koa-router": "^1.0.3",
|
|
54
54
|
"wechat-oauth": "^1.5.0",
|
|
55
|
-
"weixin-pay-fork": "^1.0.
|
|
55
|
+
"weixin-pay-fork": "^1.0.4",
|
|
56
56
|
"node-uuid": "^1.4.8",
|
|
57
57
|
"sha1": "^1.1.1",
|
|
58
58
|
"redis": "^4.0.3",
|