q-koa 7.9.3 → 7.9.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/config.js
CHANGED
|
@@ -104,7 +104,7 @@ exports.showTables = async (ctx) => {
|
|
|
104
104
|
: app.config[_model]
|
|
105
105
|
// const target = Object.keys(app.config[model])
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
if (!target) throw new Error(`检查是否有${_model}/config.js`)
|
|
108
108
|
const model = target.model ? target.model : _model
|
|
109
109
|
return {
|
|
110
110
|
modelName: _model,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const md5 = require('js-md5')
|
|
2
|
-
const { getAppByCtx, getConfig } = require('q-koa')
|
|
2
|
+
const { getAppByCtx, getConfig, lodash } = require('q-koa')
|
|
3
3
|
|
|
4
4
|
exports.login = async (ctx) => {
|
|
5
5
|
const { app, appName } = getAppByCtx(ctx)
|
|
@@ -331,10 +331,12 @@ exports.checkLogin = async (ctx) => {
|
|
|
331
331
|
const token = await app.sign({
|
|
332
332
|
user: tokenResult,
|
|
333
333
|
})
|
|
334
|
-
|
|
334
|
+
console.log('app.appConfig.loginData', app.appConfig.loginData)
|
|
335
335
|
return ctx.SUCCESS({
|
|
336
336
|
token,
|
|
337
|
-
user:
|
|
337
|
+
user: app.appConfig.loginData
|
|
338
|
+
? lodash.omit(result.toJSON(), app.appConfig.loginData.omit)
|
|
339
|
+
: result,
|
|
338
340
|
})
|
|
339
341
|
}
|
|
340
342
|
|
|
@@ -739,10 +739,11 @@ exports.h5_pay = async (ctx) => {
|
|
|
739
739
|
return_url,
|
|
740
740
|
type,
|
|
741
741
|
is_admin = false,
|
|
742
|
+
pay_config = 'weixin_pay',
|
|
742
743
|
} = ctx.request.body
|
|
743
744
|
|
|
744
745
|
const appConfig = getConfig(app)
|
|
745
|
-
const { appId, key, mchId } = await appConfig.getObject(
|
|
746
|
+
const { appId, key, mchId } = await appConfig.getObject(pay_config)
|
|
746
747
|
const { is_dev, site_host } = await appConfig.getObject('base')
|
|
747
748
|
|
|
748
749
|
const payObj = new WeixinPay({
|
|
@@ -782,6 +783,7 @@ exports.mp_pay = async (ctx) => {
|
|
|
782
783
|
out_trade_no,
|
|
783
784
|
is_admin = false,
|
|
784
785
|
config = 'weixin_mp',
|
|
786
|
+
pay_config = 'weixin_pay',
|
|
785
787
|
} = ctx.request.body
|
|
786
788
|
|
|
787
789
|
if (price === 0) throw new Error('价格不能为0')
|
|
@@ -801,7 +803,7 @@ exports.mp_pay = async (ctx) => {
|
|
|
801
803
|
}
|
|
802
804
|
const appConfig = getConfig(app)
|
|
803
805
|
|
|
804
|
-
const { mchId, key } = await appConfig.getObject(
|
|
806
|
+
const { mchId, key } = await appConfig.getObject(pay_config)
|
|
805
807
|
const { is_dev, site_host } = await appConfig.getObject('base')
|
|
806
808
|
// 公众号支付用 服务号 appid,其他用小程序 appid
|
|
807
809
|
const app_id =
|
|
@@ -1047,9 +1049,10 @@ const getRefundResultJson = async ({ req_info, app_key }) => {
|
|
|
1047
1049
|
exports.refund_notify = async (ctx) => {
|
|
1048
1050
|
const { app } = getAppByCtx(ctx)
|
|
1049
1051
|
const result = ctx.request.xmlBody
|
|
1052
|
+
const pay_config = ctx.request.query.pay_config || 'weixin_pay'
|
|
1050
1053
|
|
|
1051
1054
|
const appConfig = getConfig(app)
|
|
1052
|
-
const { key } = await appConfig.getObject(
|
|
1055
|
+
const { key } = await appConfig.getObject(pay_config)
|
|
1053
1056
|
|
|
1054
1057
|
const { req_info } = result.xml
|
|
1055
1058
|
const refundResult = await getRefundResultJson({
|
|
@@ -1110,7 +1113,12 @@ exports.article = async (ctx) => {
|
|
|
1110
1113
|
exports.checkPay = async (ctx) => {
|
|
1111
1114
|
const { app, appName, controller } = getAppByCtx(ctx)
|
|
1112
1115
|
|
|
1113
|
-
const {
|
|
1116
|
+
const {
|
|
1117
|
+
id,
|
|
1118
|
+
prefix,
|
|
1119
|
+
config = 'weixin_mp',
|
|
1120
|
+
pay_config = 'weixin_pay',
|
|
1121
|
+
} = ctx.request.body
|
|
1114
1122
|
|
|
1115
1123
|
const orderModel = prefix ? `${prefix}_order` : 'order'
|
|
1116
1124
|
const result = await app.model[orderModel].findOne({
|
|
@@ -1121,8 +1129,8 @@ exports.checkPay = async (ctx) => {
|
|
|
1121
1129
|
if (!result) return ctx.SUCCESS('找不到')
|
|
1122
1130
|
|
|
1123
1131
|
const appConfig = getConfig(app)
|
|
1124
|
-
const app_id = (await appConfig.getObject(
|
|
1125
|
-
const { mchId, key } = await appConfig.getObject(
|
|
1132
|
+
const app_id = (await appConfig.getObject(config)).app_id
|
|
1133
|
+
const { mchId, key } = await appConfig.getObject(pay_config)
|
|
1126
1134
|
|
|
1127
1135
|
const wxpay = WXPay({
|
|
1128
1136
|
appid: app_id,
|
|
@@ -1162,18 +1170,22 @@ exports.init_mp_openid = async (ctx) => {
|
|
|
1162
1170
|
const { app, appName } = getAppByCtx(ctx)
|
|
1163
1171
|
|
|
1164
1172
|
const list = await app.model.user.findAll({
|
|
1173
|
+
limit: 1000,
|
|
1174
|
+
order: [['id', 'DESC']],
|
|
1165
1175
|
where: {
|
|
1166
1176
|
mp_openid: '',
|
|
1167
1177
|
},
|
|
1168
1178
|
include: app.model.mp_user,
|
|
1169
1179
|
})
|
|
1170
1180
|
|
|
1171
|
-
const result = list
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1181
|
+
const result = list
|
|
1182
|
+
.filter((item) => item.mp_user && item.mp_user.openid)
|
|
1183
|
+
.map((item) => {
|
|
1184
|
+
return {
|
|
1185
|
+
id: item.id,
|
|
1186
|
+
mp_openid: item.mp_user.openid,
|
|
1187
|
+
}
|
|
1188
|
+
})
|
|
1177
1189
|
|
|
1178
1190
|
await app.model.user.bulkCreate(result, {
|
|
1179
1191
|
updateOnDuplicate: ['mp_openid'],
|
|
@@ -12,11 +12,12 @@ exports.refund = async ({
|
|
|
12
12
|
refund_fee,
|
|
13
13
|
price,
|
|
14
14
|
type = '',
|
|
15
|
+
pay_config = 'weixin_pay',
|
|
15
16
|
...rest
|
|
16
17
|
}) => {
|
|
17
18
|
const { app, appName } = getAppByCtx(ctx)
|
|
18
19
|
const appConfig = getConfig(app)
|
|
19
|
-
const { mchId, key, appId } = await appConfig.getObject(
|
|
20
|
+
const { mchId, key, appId } = await appConfig.getObject(pay_config)
|
|
20
21
|
const { site_host } = await appConfig.getObject('base')
|
|
21
22
|
|
|
22
23
|
const payObj = new Pay({
|
|
@@ -49,7 +50,7 @@ exports.refund = async ({
|
|
|
49
50
|
refund_fee: Math.round((refund_fee || price) * 100),
|
|
50
51
|
notify_url: `https://${
|
|
51
52
|
site_host || 'api.kuashou.com'
|
|
52
|
-
}/${appName}/weixin/refund_notify`,
|
|
53
|
+
}/${appName}/weixin/refund_notify?pay_config=weixin_pay`,
|
|
53
54
|
})
|
|
54
55
|
if (result_code === 'SUCCESS') {
|
|
55
56
|
return true
|
|
@@ -63,9 +64,9 @@ exports.refund = async ({
|
|
|
63
64
|
|
|
64
65
|
exports.cash = async ({ ctx, id, user_id, number }) => {
|
|
65
66
|
const { app, appName } = getAppByCtx(ctx)
|
|
66
|
-
|
|
67
|
+
const { pay_config = 'weixin_pay' } = ctx.request.body
|
|
67
68
|
const appConfig = getConfig(app)
|
|
68
|
-
const { mchId, key, appId } = await appConfig.getObject(
|
|
69
|
+
const { mchId, key, appId } = await appConfig.getObject(pay_config)
|
|
69
70
|
|
|
70
71
|
const { is_dev } = await appConfig.getObject('base')
|
|
71
72
|
|