q-koa 13.4.6 → 13.5.0
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.
|
@@ -16,6 +16,7 @@ const OSS = require('ali-oss')
|
|
|
16
16
|
const axios = require('axios')
|
|
17
17
|
const util = require('util')
|
|
18
18
|
const jwt = require('jsonwebtoken')
|
|
19
|
+
const pm2 = require('pm2')
|
|
19
20
|
|
|
20
21
|
const { getImageType } = require('../../utils')
|
|
21
22
|
const Email = require('../../services/email')
|
|
@@ -746,3 +747,27 @@ exports.copyDB = async (ctx) => {
|
|
|
746
747
|
|
|
747
748
|
ctx.SUCCESS('ok')
|
|
748
749
|
}
|
|
750
|
+
|
|
751
|
+
exports.restart = async (ctx) => {
|
|
752
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
753
|
+
|
|
754
|
+
const { hour: _hour } = ctx.request.query
|
|
755
|
+
|
|
756
|
+
const hour = moment().hour()
|
|
757
|
+
if (hour === Number(_hour)) {
|
|
758
|
+
pm2.connect((err) => {
|
|
759
|
+
console.log(err)
|
|
760
|
+
app.service.log.push({
|
|
761
|
+
app,
|
|
762
|
+
message: '重启了',
|
|
763
|
+
})
|
|
764
|
+
setTimeout(() => {
|
|
765
|
+
pm2.reload(appName)
|
|
766
|
+
}, 1000)
|
|
767
|
+
})
|
|
768
|
+
|
|
769
|
+
ctx.SUCCESS('ok')
|
|
770
|
+
} else {
|
|
771
|
+
return ctx.SUCCESS('?hour=')
|
|
772
|
+
}
|
|
773
|
+
}
|
|
@@ -1612,6 +1612,7 @@ exports.checkPay = async (ctx, _data) => {
|
|
|
1612
1612
|
pay_config = 'weixin_pay',
|
|
1613
1613
|
type = 'MP-WEIXIN',
|
|
1614
1614
|
out_trade_no: _out_trade_no,
|
|
1615
|
+
mch_id = '',
|
|
1615
1616
|
} = _data || ctx.request.body
|
|
1616
1617
|
|
|
1617
1618
|
const orderModel = prefix ? `${prefix}_order` : 'order'
|
|
@@ -1632,7 +1633,7 @@ exports.checkPay = async (ctx, _data) => {
|
|
|
1632
1633
|
|
|
1633
1634
|
const wxpay = WXPay({
|
|
1634
1635
|
appid: app_id,
|
|
1635
|
-
mch_id: mchId,
|
|
1636
|
+
mch_id: mch_id || mchId,
|
|
1636
1637
|
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
1637
1638
|
})
|
|
1638
1639
|
|
|
@@ -1669,6 +1670,7 @@ exports.checkPayOnly = async (ctx, _data) => {
|
|
|
1669
1670
|
pay_config = 'weixin_pay',
|
|
1670
1671
|
type = 'MP-WEIXIN',
|
|
1671
1672
|
out_trade_no: _out_trade_no,
|
|
1673
|
+
mch_id = '',
|
|
1672
1674
|
} = _data || ctx.request.body
|
|
1673
1675
|
|
|
1674
1676
|
const appConfig = getConfig(app)
|
|
@@ -1677,7 +1679,7 @@ exports.checkPayOnly = async (ctx, _data) => {
|
|
|
1677
1679
|
|
|
1678
1680
|
const wxpay = WXPay({
|
|
1679
1681
|
appid: app_id,
|
|
1680
|
-
mch_id: mchId,
|
|
1682
|
+
mch_id: mch_id || mchId,
|
|
1681
1683
|
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
1682
1684
|
})
|
|
1683
1685
|
|
|
@@ -615,6 +615,7 @@ exports.funds_order_pay = async ({ ctx, app, result }) => {
|
|
|
615
615
|
order: model,
|
|
616
616
|
order_price: amount / 100,
|
|
617
617
|
transactionid,
|
|
618
|
+
mch_id: result.order_info.mchid,
|
|
618
619
|
})
|
|
619
620
|
}
|
|
620
621
|
}
|
|
@@ -678,6 +679,85 @@ exports.funds_order_refund = async ({ ctx, app, result }) => {
|
|
|
678
679
|
}
|
|
679
680
|
}
|
|
680
681
|
|
|
682
|
+
exports.retail_refund_notify = async ({ ctx, app, result }) => {
|
|
683
|
+
if (result) {
|
|
684
|
+
let prefix = ''
|
|
685
|
+
let order_id = result.out_trade_no.split('_')[1]
|
|
686
|
+
if (order_id.includes('-')) {
|
|
687
|
+
const arr = order_id.split('-')
|
|
688
|
+
order_id = Number(arr[1])
|
|
689
|
+
;[prefix] = arr
|
|
690
|
+
} else {
|
|
691
|
+
order_id = Number(order_id)
|
|
692
|
+
}
|
|
693
|
+
const model = prefix ? `${prefix}_order` : 'order'
|
|
694
|
+
|
|
695
|
+
const trade_no = result.out_trade_no.split('_').slice(0, 2).join('_')
|
|
696
|
+
|
|
697
|
+
const type = trade_no.includes('_') ? trade_no.split('_')[1] : ''
|
|
698
|
+
|
|
699
|
+
if (app.service[model] && app.service[model].refund_notify) {
|
|
700
|
+
if (result.refund_status === 'REFUND_SUCC') {
|
|
701
|
+
await app.service[model].refund_notify({
|
|
702
|
+
ctx,
|
|
703
|
+
app,
|
|
704
|
+
order_id,
|
|
705
|
+
order: model,
|
|
706
|
+
refund_price: result.refund_amount / 100,
|
|
707
|
+
type,
|
|
708
|
+
mch_id: result.mchid,
|
|
709
|
+
})
|
|
710
|
+
} else {
|
|
711
|
+
app.service.log.push({
|
|
712
|
+
app,
|
|
713
|
+
message: JSON.stringify(result),
|
|
714
|
+
url: 'retail_refund_notify',
|
|
715
|
+
})
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
exports.retail_pay_notify = async ({ ctx, app, result }) => {
|
|
722
|
+
if (result) {
|
|
723
|
+
let prefix = ''
|
|
724
|
+
let order_id = result.out_trade_no.split('_')[1]
|
|
725
|
+
if (order_id.includes('-')) {
|
|
726
|
+
const arr = order_id.split('-')
|
|
727
|
+
order_id = Number(arr[1])
|
|
728
|
+
;[prefix] = arr
|
|
729
|
+
} else {
|
|
730
|
+
order_id = Number(order_id)
|
|
731
|
+
}
|
|
732
|
+
const model = prefix ? `${prefix}_order` : 'order'
|
|
733
|
+
let transactionid = ''
|
|
734
|
+
try {
|
|
735
|
+
transactionid = result.wxpay_transaction_id
|
|
736
|
+
} catch (e) {}
|
|
737
|
+
|
|
738
|
+
console.log(result.mchid)
|
|
739
|
+
if (app.service[model] && app.service[model].notify) {
|
|
740
|
+
if (result.pay_status === 'ORDER_PAY_SUCC') {
|
|
741
|
+
await app.service[model].notify({
|
|
742
|
+
ctx,
|
|
743
|
+
app,
|
|
744
|
+
order_id,
|
|
745
|
+
order: model,
|
|
746
|
+
order_price: result.amount.order_amount / 100,
|
|
747
|
+
transactionid,
|
|
748
|
+
mch_id: result.mchid,
|
|
749
|
+
})
|
|
750
|
+
} else {
|
|
751
|
+
app.service.log.push({
|
|
752
|
+
app,
|
|
753
|
+
message: JSON.stringify(result),
|
|
754
|
+
url: 'retail_pay_notify',
|
|
755
|
+
})
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
681
761
|
exports.pc_pay = async ({
|
|
682
762
|
ctx,
|
|
683
763
|
name,
|