q-koa 12.2.2 → 12.2.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.
@@ -71,6 +71,9 @@ exports.loadModel = async ({ app, appName }) => {
71
71
  app,
72
72
  model: result[i],
73
73
  })
74
+ if (countNumber >= 100000) {
75
+ console.warn('数据量大,请注意', result[i], countNumber)
76
+ }
74
77
  if (tableIndexList.length <= 1) {
75
78
  console.warn(`${result[i]} count ${countNumber}没有索引`)
76
79
  }
@@ -1417,7 +1417,7 @@ exports.article = async (ctx) => {
1417
1417
  return ctx.SUCCESS(result)
1418
1418
  }
1419
1419
 
1420
- exports.checkPay = async (ctx) => {
1420
+ exports.checkPay = async (ctx, _data) => {
1421
1421
  const { app, appName, controller } = getAppByCtx(ctx)
1422
1422
 
1423
1423
  const {
@@ -1427,15 +1427,19 @@ exports.checkPay = async (ctx) => {
1427
1427
  pay_config = 'weixin_pay',
1428
1428
  type = 'MP-WEIXIN',
1429
1429
  out_trade_no: _out_trade_no,
1430
- } = ctx.request.body
1430
+ } = _data || ctx.request.body
1431
1431
 
1432
1432
  const orderModel = prefix ? `${prefix}_order` : 'order'
1433
+
1433
1434
  const result = await app.model[orderModel].findOne({
1434
1435
  where: {
1435
1436
  id,
1436
1437
  },
1437
1438
  })
1438
- if (!result) return ctx.SUCCESS('找不到')
1439
+ if (!result) {
1440
+ ctx.SUCCESS('找不到')
1441
+ throw new Error(`找不到`)
1442
+ }
1439
1443
 
1440
1444
  const appConfig = getConfig(app)
1441
1445
  const app_id = (await appConfig.getObject(config)).app_id
@@ -1467,6 +1471,7 @@ exports.checkPay = async (ctx) => {
1467
1471
  }
1468
1472
 
1469
1473
  ctx.SUCCESS({ prefix, out_trade_no, ...payResult })
1474
+ return { prefix, out_trade_no, ...payResult }
1470
1475
  }
1471
1476
 
1472
1477
  exports.checkPayOnly = async (ctx) => {
@@ -89,6 +89,62 @@ module.exports = class Singleton {
89
89
  }
90
90
  }
91
91
 
92
+ async addPrinter(machineCode, msign, nickName = '', phone = '') {
93
+ const app = this.config.app
94
+ const accessToken = await this.getAccessToken()
95
+ try {
96
+ const RpcClient = new yly.RpcClient(accessToken, this.oauthConfig)
97
+ const Print = new yly.Printer(RpcClient)
98
+ const res = await Print.addPrinter(machineCode, msign, nickName, phone)
99
+
100
+ if (res && res.error_description !== 'success') {
101
+ throw new Error(res.error_description)
102
+ }
103
+ } catch (e) {
104
+ await app.model.setting.update(
105
+ {
106
+ value: '',
107
+ },
108
+ {
109
+ where: {
110
+ code: 'print_token',
111
+ name: 'AccessToken',
112
+ },
113
+ }
114
+ )
115
+ throw new Error(`请重试,${e.message}`)
116
+ // return await this.print({ order_id, content })
117
+ }
118
+ }
119
+
120
+ async deletePrinter(machineCode) {
121
+ const app = this.config.app
122
+ const accessToken = await this.getAccessToken()
123
+ try {
124
+ const RpcClient = new yly.RpcClient(accessToken, this.oauthConfig)
125
+ const Print = new yly.Printer(RpcClient)
126
+ const res = await Print.deletePrinter(machineCode)
127
+
128
+ if (res && res.error_description !== 'success') {
129
+ throw new Error(res.error_description)
130
+ }
131
+ } catch (e) {
132
+ await app.model.setting.update(
133
+ {
134
+ value: '',
135
+ },
136
+ {
137
+ where: {
138
+ code: 'print_token',
139
+ name: 'AccessToken',
140
+ },
141
+ }
142
+ )
143
+ throw new Error(`请重试,${e.message}`)
144
+ // return await this.print({ order_id, content })
145
+ }
146
+ }
147
+
92
148
  async cancelAll() {
93
149
  const app = this.config.app
94
150
  const accessToken = await this.getAccessToken()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "12.2.2",
3
+ "version": "12.2.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {