q-koa 10.7.4 → 10.7.6

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.
@@ -474,11 +474,50 @@ exports.dashboard = async (ctx) => {
474
474
  ctx.SUCCESS(result)
475
475
  }
476
476
 
477
+ exports.showAllModel = async (ctx) => {
478
+ const { app, appName } = getAppByCtx(ctx)
479
+ const { is_count = false } = ctx.request.body
480
+ const result = await app.sequelize.showAllSchemas()
481
+ const list = result.map(
482
+ (item) => item[`Tables_in_${app.sequelize.config.database}`]
483
+ )
484
+ let tableList = []
485
+ for (let i = 0; i < list.length; i++) {
486
+ if (!app.model[list[i]]) continue
487
+ const defaultConfigPath = path.resolve(__dirname, `../${list[i]}/config.js`)
488
+ const defaultConfigExist = fs.existsSync(defaultConfigPath)
489
+ const target =
490
+ app.config[list[i]] &&
491
+ Object.keys(app.config[list[i]]).length === 0 &&
492
+ defaultConfigExist
493
+ ? require(defaultConfigPath)
494
+ : app.config[list[i]]
495
+ let count = 0
496
+ if (is_count) {
497
+ count = await app.model[list[i]].count()
498
+ }
499
+ tableList = [
500
+ ...tableList,
501
+ {
502
+ count,
503
+ name: target.name,
504
+ model: list[i],
505
+ count,
506
+ },
507
+ ]
508
+ }
509
+ return ctx.SUCCESS(
510
+ tableList.map((item) => lodash.omit(item, is_count ? [] : ['count']))
511
+ )
512
+ }
513
+
477
514
  exports.drop = async (ctx) => {
478
515
  const { app, appName } = getAppByCtx(ctx)
479
516
 
480
517
  const result = await app.sequelize.showAllSchemas()
481
- const list = result.map((item) => item[`Tables_in_${appName}`])
518
+ const list = result.map(
519
+ (item) => item[`Tables_in_${app.sequelize.config.database}`]
520
+ )
482
521
  const filterList = list.filter((item) => !app.model[item])
483
522
  await Promise.all(
484
523
  filterList.map((folder) => {
@@ -542,7 +581,9 @@ exports.copyOther = async (ctx) => {
542
581
  list = [model]
543
582
  } else {
544
583
  const result = await app.sequelize.showAllSchemas()
545
- list = result.map((item) => item[`Tables_in_${appName}`])
584
+ list = result.map(
585
+ (item) => item[`Tables_in_${app.sequelize.config.database}`]
586
+ )
546
587
  }
547
588
  }
548
589
 
@@ -879,12 +879,12 @@ exports.app_pay = async (ctx) => {
879
879
 
880
880
  if (price === 0) throw new Error('价格不能为0')
881
881
 
882
- if (
883
- !ctx.request[`${appName}-user`] ||
884
- !ctx.request[`${appName}-user`].open_user
885
- ) {
886
- throw new Error('请先微信登录')
887
- }
882
+ // if (
883
+ // !ctx.request[`${appName}-user`] ||
884
+ // !ctx.request[`${appName}-user`].open_user
885
+ // ) {
886
+ // throw new Error('请先微信登录')
887
+ // }
888
888
  const appConfig = getConfig(app)
889
889
 
890
890
  const { mchId, key, partner_key, appId: appid } = await appConfig.getObject(
@@ -911,7 +911,7 @@ exports.app_pay = async (ctx) => {
911
911
  site_host || 'api.kuashou.com'
912
912
  }/${appName}/weixin/notify`
913
913
 
914
- const result = await wxpay.getBrandWCPayRequestParamsSync({
914
+ const result = await wxpay.appPaySync({
915
915
  trade_type: 'APP',
916
916
  body: name,
917
917
  detail: '公众号支付测试',
@@ -922,19 +922,21 @@ exports.app_pay = async (ctx) => {
922
922
  })
923
923
 
924
924
  const {
925
- nonceStr: nonce_str,
926
- package: prepay_id,
925
+ noncestr,
926
+ package,
927
927
  paySign: sign,
928
- timeStamp: timestamp,
928
+ timestamp,
929
+ partnerid,
930
+ prepayid,
929
931
  } = result
930
932
 
931
933
  const returnObj = {
932
934
  appid,
933
- partnerid: mchId,
934
- nonce_str,
935
- prepay_id,
935
+ partnerid,
936
+ noncestr,
937
+ package,
938
+ prepayid,
936
939
  sign,
937
- return_url,
938
940
  timestamp,
939
941
  }
940
942
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "10.7.4",
3
+ "version": "10.7.6",
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.5",
55
+ "weixin-pay-fork": "^1.0.6",
56
56
  "node-uuid": "^1.4.8",
57
57
  "sha1": "^1.1.1",
58
58
  "redis": "^4.0.3",