q-koa 10.5.1 → 10.5.3
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
CHANGED
|
@@ -362,15 +362,16 @@ class APP {
|
|
|
362
362
|
)
|
|
363
363
|
|
|
364
364
|
try {
|
|
365
|
-
const
|
|
365
|
+
const dbName = this.config.db.name || appName
|
|
366
|
+
const db = connectDatabase(dbName)(this.config.db)
|
|
366
367
|
if (!is_dev) {
|
|
367
368
|
if (!dbFlag) {
|
|
368
|
-
console.log(chalk.green(
|
|
369
|
+
console.log(chalk.green(`${appName}检查数据库${dbName}`))
|
|
369
370
|
await db.authenticate()
|
|
370
371
|
dbFlag = true
|
|
371
372
|
}
|
|
372
373
|
} else {
|
|
373
|
-
console.log(chalk.green(
|
|
374
|
+
console.log(chalk.green(`${appName}检查数据库${dbName}`))
|
|
374
375
|
await db.authenticate()
|
|
375
376
|
}
|
|
376
377
|
const configPath = `${rootDirectory}/${APP_DIR}/${appName}/config.js`
|
|
@@ -527,3 +527,52 @@ exports.mockPay = async (ctx) => {
|
|
|
527
527
|
})
|
|
528
528
|
ctx.SUCCESS('ok')
|
|
529
529
|
}
|
|
530
|
+
|
|
531
|
+
exports.copyOther = async (ctx) => {
|
|
532
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
533
|
+
|
|
534
|
+
const { model, source } = ctx.request.body
|
|
535
|
+
if (!model) return ctx.ERROR('model?')
|
|
536
|
+
if (!source) return ctx.ERROR('source? https://www.kuashou.com/kuashou')
|
|
537
|
+
let list = []
|
|
538
|
+
if (Array.isArray(model)) {
|
|
539
|
+
list = model
|
|
540
|
+
} else {
|
|
541
|
+
if (model !== 'all') {
|
|
542
|
+
list = [model]
|
|
543
|
+
} else {
|
|
544
|
+
const result = await app.sequelize.showAllSchemas()
|
|
545
|
+
list = result.map((item) => item[`Tables_in_${appName}`])
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const prefix = `${source}`
|
|
550
|
+
let successList = []
|
|
551
|
+
let failList = []
|
|
552
|
+
for (let i = 0; i < list.length; i++) {
|
|
553
|
+
const url = `${prefix}/${list[i]}/findAll`
|
|
554
|
+
|
|
555
|
+
const result = await axios.post(url).then((res) => res.data)
|
|
556
|
+
console.log(list[i])
|
|
557
|
+
if (result.code === 200) {
|
|
558
|
+
await app.model[list[i]].sync({
|
|
559
|
+
force: true,
|
|
560
|
+
})
|
|
561
|
+
try {
|
|
562
|
+
await app.model[list[i]].bulkCreate(
|
|
563
|
+
result.data.map((i) => lodash.omitBy(i, lodash.isNull)),
|
|
564
|
+
{}
|
|
565
|
+
)
|
|
566
|
+
successList = [...successList, list[i]]
|
|
567
|
+
} catch (e) {
|
|
568
|
+
console.log(e.message)
|
|
569
|
+
failList = [...failList, list[i]]
|
|
570
|
+
}
|
|
571
|
+
} else {
|
|
572
|
+
console.log(url, result.data)
|
|
573
|
+
failList = [...failList, list[i]]
|
|
574
|
+
continue
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
ctx.SUCCESS({ successList, failList })
|
|
578
|
+
}
|
|
@@ -1202,6 +1202,7 @@ exports.refund = async (ctx) => {
|
|
|
1202
1202
|
config = 'weixin_mp',
|
|
1203
1203
|
pay_config = 'weixin_pay',
|
|
1204
1204
|
is_new_pay = false,
|
|
1205
|
+
out_trade_no,
|
|
1205
1206
|
} = ctx.request.body
|
|
1206
1207
|
|
|
1207
1208
|
const fn = is_new_pay ? 'refund_new' : 'refund'
|
|
@@ -1214,6 +1215,7 @@ exports.refund = async (ctx) => {
|
|
|
1214
1215
|
price,
|
|
1215
1216
|
config,
|
|
1216
1217
|
pay_config,
|
|
1218
|
+
out_trade_no,
|
|
1217
1219
|
})
|
|
1218
1220
|
ctx.SUCCESS('ok')
|
|
1219
1221
|
}
|