q-koa 12.3.3 → 12.3.5

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
@@ -231,7 +231,7 @@ class APP {
231
231
  ) {
232
232
  return await next()
233
233
  }
234
- throw new Error('没有权限或登录失效,请重新登录')
234
+ throw new ServiceError('没有权限或登录失效,请重新登录')
235
235
  }
236
236
  await next()
237
237
  })
@@ -48,7 +48,7 @@ module.exports = class Singleton {
48
48
  .then((res) => res.data)
49
49
 
50
50
  if (data.status === 0) return data.result
51
- throw new Error(data.message)
51
+ throw new Error(`${this.key.split('-')[0]}${data.message}`)
52
52
  }
53
53
 
54
54
  async getToLngAndLat(name) {
@@ -61,7 +61,7 @@ module.exports = class Singleton {
61
61
  if (data.message === '查询无结果') {
62
62
  throw new Error(`找不到【${name}】,可能需要更详细一点(省市区)`)
63
63
  } else {
64
- throw new Error(data.message)
64
+ throw new Error(`${this.key.split('-')[0]}${data.message}`)
65
65
  }
66
66
  }
67
67
 
@@ -145,6 +145,39 @@ module.exports = class Singleton {
145
145
  }
146
146
  }
147
147
 
148
+ async getPrintList(machineCode, pageIndex = 1, pageSize = 10) {
149
+ const app = this.config.app
150
+ const accessToken = await this.getAccessToken()
151
+ try {
152
+ const RpcClient = new yly.RpcClient(accessToken, this.oauthConfig)
153
+ const Print = new yly.Printer(RpcClient)
154
+ const res = await Print.getOrderPagingList(
155
+ machineCode,
156
+ pageIndex,
157
+ pageSize
158
+ )
159
+
160
+ if (res && res.error_description !== 'success') {
161
+ throw new Error(res.error_description)
162
+ }
163
+ return res
164
+ } catch (e) {
165
+ await app.model.setting.update(
166
+ {
167
+ value: '',
168
+ },
169
+ {
170
+ where: {
171
+ code: 'print_token',
172
+ name: 'AccessToken',
173
+ },
174
+ }
175
+ )
176
+ throw new Error(`请重试,${e.message}`)
177
+ // return await this.print({ order_id, content })
178
+ }
179
+ }
180
+
148
181
  async cancelAll() {
149
182
  const app = this.config.app
150
183
  const accessToken = await this.getAccessToken()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "12.3.3",
3
+ "version": "12.3.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {