q-koa 7.7.2

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.
Files changed (116) hide show
  1. package/core/app.js +1813 -0
  2. package/core/config.js +124 -0
  3. package/core/file/plugins/administrator/config.js +17 -0
  4. package/core/file/plugins/administrator/controller.js +264 -0
  5. package/core/file/plugins/administrator/model.js +53 -0
  6. package/core/file/plugins/administrator/validate.js +41 -0
  7. package/core/file/plugins/alipay/controller.js +68 -0
  8. package/core/file/plugins/alipay/validate.js +9 -0
  9. package/core/file/plugins/cache/service.js +16 -0
  10. package/core/file/plugins/cloudfunction/config.js +4 -0
  11. package/core/file/plugins/cloudfunction/model.js +15 -0
  12. package/core/file/plugins/common/controller.js +398 -0
  13. package/core/file/plugins/common/validate.js +47 -0
  14. package/core/file/plugins/douyin/config.js +3 -0
  15. package/core/file/plugins/douyin/controller.js +521 -0
  16. package/core/file/plugins/douyin/validate.js +40 -0
  17. package/core/file/plugins/douyin_user/config.js +15 -0
  18. package/core/file/plugins/douyin_user/model.js +72 -0
  19. package/core/file/plugins/good_sku/controller.js +80 -0
  20. package/core/file/plugins/h5_user/config.js +19 -0
  21. package/core/file/plugins/h5_user/model.js +71 -0
  22. package/core/file/plugins/lang/config.js +4 -0
  23. package/core/file/plugins/lang/model.js +15 -0
  24. package/core/file/plugins/language/config.js +5 -0
  25. package/core/file/plugins/language/model.js +54 -0
  26. package/core/file/plugins/log/config.js +25 -0
  27. package/core/file/plugins/log/controller.js +31 -0
  28. package/core/file/plugins/log/model.js +51 -0
  29. package/core/file/plugins/model/config.js +12 -0
  30. package/core/file/plugins/model/controller.js +69 -0
  31. package/core/file/plugins/model/model.js +169 -0
  32. package/core/file/plugins/model/service.js +218 -0
  33. package/core/file/plugins/model/validate.js +42 -0
  34. package/core/file/plugins/model_attributes/config.js +12 -0
  35. package/core/file/plugins/model_attributes/model.js +114 -0
  36. package/core/file/plugins/mp_user/config.js +19 -0
  37. package/core/file/plugins/mp_user/model.js +59 -0
  38. package/core/file/plugins/permission/config.js +15 -0
  39. package/core/file/plugins/permission/model.js +91 -0
  40. package/core/file/plugins/role/config.js +27 -0
  41. package/core/file/plugins/role/controller.js +26 -0
  42. package/core/file/plugins/role/model.js +58 -0
  43. package/core/file/plugins/role_permission/config.js +12 -0
  44. package/core/file/plugins/role_permission/controller.js +27 -0
  45. package/core/file/plugins/role_permission/model.js +24 -0
  46. package/core/file/plugins/routes/config.js +17 -0
  47. package/core/file/plugins/routes/controller.js +153 -0
  48. package/core/file/plugins/routes/model.js +70 -0
  49. package/core/file/plugins/routes/service.js +22 -0
  50. package/core/file/plugins/setting/afterExecute.js +14 -0
  51. package/core/file/plugins/setting/config.js +14 -0
  52. package/core/file/plugins/setting/controller.js +50 -0
  53. package/core/file/plugins/setting/model.js +118 -0
  54. package/core/file/plugins/setting/validate.js +42 -0
  55. package/core/file/plugins/system/controller.js +501 -0
  56. package/core/file/plugins/system/service.js +148 -0
  57. package/core/file/plugins/system/validate.js +40 -0
  58. package/core/file/plugins/todolist/config.js +31 -0
  59. package/core/file/plugins/todolist/model.js +69 -0
  60. package/core/file/plugins/toutiao/controller.js +201 -0
  61. package/core/file/plugins/toutiao_user/config.js +15 -0
  62. package/core/file/plugins/toutiao_user/model.js +66 -0
  63. package/core/file/plugins/user/afterExecute.js +38 -0
  64. package/core/file/plugins/user/config.js +9 -0
  65. package/core/file/plugins/user/controller.js +329 -0
  66. package/core/file/plugins/user/model.js +96 -0
  67. package/core/file/plugins/user/test.js +71 -0
  68. package/core/file/plugins/user/validate.js +44 -0
  69. package/core/file/plugins/video/config.js +3 -0
  70. package/core/file/plugins/video/controller.js +15 -0
  71. package/core/file/plugins/video/validate.js +12 -0
  72. package/core/file/plugins/weixin/config.js +3 -0
  73. package/core/file/plugins/weixin/controller.js +994 -0
  74. package/core/file/plugins/weixin/service.js +105 -0
  75. package/core/file/plugins/weixin/validate.js +111 -0
  76. package/core/file/services/aliSms.js +45 -0
  77. package/core/file/services/alipay.js +123 -0
  78. package/core/file/services/amap.js +95 -0
  79. package/core/file/services/card.js +24 -0
  80. package/core/file/services/config.js +38 -0
  81. package/core/file/services/douyin.js +151 -0
  82. package/core/file/services/email.js +45 -0
  83. package/core/file/services/express.js +37 -0
  84. package/core/file/services/geo.js +71 -0
  85. package/core/file/services/qqVideo.js +64 -0
  86. package/core/file/services/toutiao.js +102 -0
  87. package/core/file/services/weixin.js +79 -0
  88. package/core/file/services/weixinArticle.js +53 -0
  89. package/core/file/services/weixinCrypt.js +34 -0
  90. package/core/file/services/weixinMP.js +435 -0
  91. package/core/file/services/weixinPay.js +35 -0
  92. package/core/file/services/xml.js +33 -0
  93. package/core/file/task/shop/index.js +589 -0
  94. package/core/file/task/shop/static/562e45760a44632de6fa7219bab78cce.png +0 -0
  95. package/core/file/task/shop/static/d7aeaeb6bfd68f71a00a83c0f5548363.png +0 -0
  96. package/core/file/utils/index.js +61 -0
  97. package/core/middlewares.js +120 -0
  98. package/core/restc/.npminstall.done +1 -0
  99. package/core/restc/LICENSE +21 -0
  100. package/core/restc/README.md +48 -0
  101. package/core/restc/faas/index.html +1112 -0
  102. package/core/restc/faas/index.txt +31 -0
  103. package/core/restc/faas/install_production.sh +6 -0
  104. package/core/restc/index.d.ts +7 -0
  105. package/core/restc/index.js +9 -0
  106. package/core/restc/lib/express.js +7 -0
  107. package/core/restc/lib/hapi.js +17 -0
  108. package/core/restc/lib/hapiLegacy.js +15 -0
  109. package/core/restc/lib/index.js +46 -0
  110. package/core/restc/lib/koa.js +9 -0
  111. package/core/restc/lib/koa2.js +9 -0
  112. package/core/restc/lib/utils/gateway.js +51 -0
  113. package/core/restc/package.json +41 -0
  114. package/core/validator.js +15 -0
  115. package/index.js +1 -0
  116. package/package.json +65 -0
@@ -0,0 +1,589 @@
1
+ const fsExtra = require('fs-extra');
2
+ const path = require('path');
3
+ const _ = require('lodash');
4
+
5
+ const filterNoNeed = item => _.omit(item, ['created_at', 'updated_at']);
6
+ exports.payType = async (app) => {
7
+ const list = [
8
+ {
9
+ name: '微信',
10
+ key: 'weixin',
11
+ image: '/upload/562e45760a44632de6fa7219bab78cce.png',
12
+ id: 1,
13
+ },
14
+ {
15
+ name: '支付宝',
16
+ key: 'alipay',
17
+ image: '/upload/d7aeaeb6bfd68f71a00a83c0f5548363.png',
18
+ id: 2,
19
+ },
20
+ {
21
+ name: '余额支付',
22
+ key: 'balance',
23
+ image: '',
24
+ id: 3,
25
+ }];
26
+ for (let i = 0; i < list.length; i++) {
27
+ await app.model.pay_type.upsert(list[i]);
28
+ }
29
+
30
+ return true;
31
+ };
32
+
33
+ exports.setting = async (app) => {
34
+ const list = [
35
+ {
36
+ name: '基础设置',
37
+ code: 'base',
38
+ type: 'input',
39
+ value: '',
40
+ parent_id: 0,
41
+ id: 1,
42
+ created_at: '2019-10-04T14:18:48.000Z',
43
+ updated_at: '2019-10-04T14:18:48.000Z',
44
+ },
45
+ {
46
+ name: '网站名',
47
+ code: 'site_name',
48
+ type: 'input',
49
+ value: '京东商城',
50
+ parent_id: 1,
51
+ id: 2,
52
+ created_at: '2019-10-04T14:19:09.000Z',
53
+ updated_at: '2019-10-04T14:19:09.000Z',
54
+ },
55
+ {
56
+ name: '语言包',
57
+ code: 'lang',
58
+ type: 'input',
59
+ value: '',
60
+ parent_id: 0,
61
+ id: 3,
62
+ created_at: '2019-10-04T14:42:01.000Z',
63
+ updated_at: '2019-10-04T14:42:01.000Z',
64
+ },
65
+ {
66
+ name: '版权说明',
67
+ code: 'copyright',
68
+ type: 'input',
69
+ value: '@copyright by 苏晓光',
70
+ parent_id: 3,
71
+ id: 4,
72
+ created_at: '2019-10-04T14:42:48.000Z',
73
+ updated_at: '2019-10-04T14:42:48.000Z',
74
+ },
75
+ {
76
+ name: '域名',
77
+ code: 'site_host',
78
+ type: 'input',
79
+ value: 'www.jd.com',
80
+ parent_id: 1,
81
+ id: 5,
82
+ created_at: '2019-10-04T14:49:39.000Z',
83
+ updated_at: '2019-10-04T14:49:39.000Z',
84
+ },
85
+ {
86
+ name: 'Logo图片',
87
+ code: 'logo_img',
88
+ type: 'image',
89
+ value: 'https://misc.360buyimg.com/jdf/1.0.0/unit/global-header/5.0.0/i/jdlogo-201708-@1x.png',
90
+ parent_id: 1,
91
+ id: 6,
92
+ created_at: '2019-10-04T14:54:47.000Z',
93
+ updated_at: '2019-10-04T14:54:47.000Z',
94
+ },
95
+ {
96
+ name: '短信配置',
97
+ code: 'sms',
98
+ type: 'input',
99
+ value: '',
100
+ parent_id: 0,
101
+ id: 13,
102
+ created_at: '2019-10-05T09:47:40.000Z',
103
+ updated_at: '2019-10-05T09:47:40.000Z',
104
+ },
105
+ {
106
+ name: '账号唯一标识',
107
+ code: 'sid',
108
+ type: 'input',
109
+ value: 'e23cfbe4425fda035ac8afa77330deff',
110
+ parent_id: 13,
111
+ id: 14,
112
+ created_at: '2019-10-05T09:48:02.000Z',
113
+ updated_at: '2019-10-05T09:48:02.000Z',
114
+ },
115
+ {
116
+ name: '应用ID',
117
+ code: 'appid',
118
+ type: 'input',
119
+ value: 'f9b475e4f90e4e4ea2226206ebf9c449',
120
+ parent_id: 13,
121
+ id: 15,
122
+ created_at: '2019-10-05T09:48:26.000Z',
123
+ updated_at: '2019-10-05T09:48:26.000Z',
124
+ },
125
+ {
126
+ name: '用户密钥',
127
+ code: 'token',
128
+ type: 'input',
129
+ value: 'f3aebd9d70b05122c542cebde7315123',
130
+ parent_id: 13,
131
+ id: 16,
132
+ created_at: '2019-10-05T09:48:46.000Z',
133
+ updated_at: '2019-10-05T09:48:46.000Z',
134
+ },
135
+ {
136
+ name: '模板ID',
137
+ code: 'templateid',
138
+ type: 'input',
139
+ value: '500487',
140
+ parent_id: 13,
141
+ id: 17,
142
+ created_at: '2019-10-05T09:49:05.000Z',
143
+ updated_at: '2019-10-05T09:49:05.000Z',
144
+ },
145
+ {
146
+ name: '小程序设置',
147
+ code: 'weixin_mp',
148
+ type: 'input',
149
+ value: '',
150
+ parent_id: 0,
151
+ id: 18,
152
+ created_at: '2019-11-08T12:28:22.000Z',
153
+ updated_at: '2019-11-08T12:28:22.000Z',
154
+ },
155
+ {
156
+ name: 'APP_ID',
157
+ code: 'app_id',
158
+ type: 'input',
159
+ value: 'wxaa3a21a0ee590ff9',
160
+ parent_id: 18,
161
+ id: 19,
162
+ created_at: '2019-11-08T12:29:07.000Z',
163
+ updated_at: '2019-11-08T12:29:07.000Z',
164
+ },
165
+ {
166
+ name: 'APP_SECRECT',
167
+ code: 'app_secrect',
168
+ type: 'input',
169
+ value: '098e45c89c000ccd40437604499024a7',
170
+ parent_id: 18,
171
+ id: 20,
172
+ created_at: '2019-11-08T12:29:26.000Z',
173
+ updated_at: '2019-11-08T12:29:26.000Z',
174
+ },
175
+ {
176
+ name: '微信公众号设置',
177
+ code: 'weixin_h5',
178
+ type: 'input',
179
+ value: '',
180
+ parent_id: 0,
181
+ id: 21,
182
+ created_at: '2019-11-09T10:36:00.000Z',
183
+ updated_at: '2019-11-09T10:36:00.000Z',
184
+ },
185
+ {
186
+ name: 'APP_ID',
187
+ code: 'app_id',
188
+ type: 'input',
189
+ value: 'wxc87b24223b65d6fc',
190
+ parent_id: 21,
191
+ id: 22,
192
+ created_at: '2019-11-09T10:37:19.000Z',
193
+ updated_at: '2019-11-09T10:37:19.000Z',
194
+ },
195
+ {
196
+ name: 'APP_SECRECT',
197
+ code: 'app_secrect',
198
+ type: 'input',
199
+ value: '6934d56c7e772b5b99141f710495bb1e',
200
+ parent_id: 21,
201
+ id: 23,
202
+ created_at: '2019-11-09T10:37:57.000Z',
203
+ updated_at: '2019-11-09T10:37:57.000Z',
204
+ },
205
+ {
206
+ name: '域名(授权用)',
207
+ code: 'host_link',
208
+ type: 'input',
209
+ value: 'http://compserviceplat.shenzhenbenwo.com',
210
+ parent_id: 21,
211
+ id: 24,
212
+ created_at: '2019-11-09T13:31:01.000Z',
213
+ updated_at: '2019-11-09T13:31:01.000Z',
214
+ },
215
+ {
216
+ name: '微信支付',
217
+ code: 'weixin_pay',
218
+ type: 'input',
219
+ value: '',
220
+ parent_id: 0,
221
+ id: 25,
222
+ created_at: '2019-11-11T16:15:36.000Z',
223
+ updated_at: '2019-11-11T16:15:36.000Z',
224
+ },
225
+ {
226
+ name: '商户号',
227
+ code: 'mch_id',
228
+ type: 'input',
229
+ value: '1559499381',
230
+ parent_id: 25,
231
+ id: 26,
232
+ created_at: '2019-11-11T16:16:02.000Z',
233
+ updated_at: '2019-11-11T16:16:02.000Z',
234
+ },
235
+ {
236
+ name: '密钥',
237
+ code: 'key',
238
+ type: 'input',
239
+ value: 'lljjlljjlljjlljjlljjlljjlljjlljj',
240
+ parent_id: 25,
241
+ id: 27,
242
+ created_at: '2019-11-11T16:16:21.000Z',
243
+ updated_at: '2019-11-11T16:16:21.000Z',
244
+ },
245
+ {
246
+ name: 'API证书',
247
+ code: 'key',
248
+ type: 'image',
249
+ value: '',
250
+ parent_id: 25,
251
+ id: 28,
252
+ created_at: '2019-11-11T16:23:48.000Z',
253
+ updated_at: '2019-11-11T16:23:48.000Z',
254
+ },
255
+ {
256
+ name: 'Logo图片',
257
+ code: 'logo_img',
258
+ type: 'file',
259
+ value: '/upload/ab45df2d626306c933079dd7611f5c8e.psd',
260
+ parent_id: 1,
261
+ id: 29,
262
+ created_at: '2019-11-12T02:24:27.000Z',
263
+ updated_at: '2019-11-12T02:24:27.000Z',
264
+ },
265
+ {
266
+ name: '快递查询',
267
+ code: 'express',
268
+ type: 'input',
269
+ value: '',
270
+ parent_id: 0,
271
+ id: 30,
272
+ created_at: '2019-12-13T01:05:30.000Z',
273
+ updated_at: '2019-12-13T01:05:30.000Z',
274
+ },
275
+ {
276
+ name: '分销比例',
277
+ code: 'spread_rate',
278
+ type: 'decimal',
279
+ value: '0.15',
280
+ parent_id: 32,
281
+ id: 31,
282
+ created_at: null,
283
+ updated_at: null,
284
+ },
285
+ {
286
+ name: '分销设置',
287
+ code: 'spread',
288
+ type: 'input',
289
+ value: '',
290
+ parent_id: 0,
291
+ id: 32,
292
+ created_at: null,
293
+ updated_at: null,
294
+ },
295
+ {
296
+ name: '分销开启',
297
+ code: 'spread_avaiable',
298
+ type: 'switch',
299
+ value: '1',
300
+ parent_id: 32,
301
+ id: 33,
302
+ created_at: null,
303
+ updated_at: null,
304
+ },
305
+ {
306
+ name: 'APP CODE',
307
+ code: 'app_code',
308
+ type: 'input',
309
+ value: '59f7e9da22e84913a5414cb959cef1e4',
310
+ parent_id: 30,
311
+ id: 34,
312
+ created_at: null,
313
+ updated_at: null,
314
+ },
315
+ {
316
+ name: '积分设置',
317
+ code: 'integral',
318
+ type: 'input',
319
+ value: '',
320
+ parent_id: 0,
321
+ id: 35,
322
+ created_at: null,
323
+ updated_at: null,
324
+ },
325
+ {
326
+ name: '赠送积分开启',
327
+ code: 'integral_avaiable',
328
+ type: 'switch',
329
+ value: '1',
330
+ parent_id: 35,
331
+ id: 36,
332
+ created_at: null,
333
+ updated_at: null,
334
+ },
335
+ {
336
+ name: '赠送积分比例',
337
+ code: 'integral_rate',
338
+ type: 'decimal',
339
+ value: '1',
340
+ parent_id: 35,
341
+ id: 37,
342
+ created_at: null,
343
+ updated_at: null,
344
+ },
345
+ {
346
+ name: '默认头像',
347
+ code: 'default_avatar',
348
+ type: 'image',
349
+ value: '',
350
+ parent_id: 1,
351
+ id: 38,
352
+ created_at: null,
353
+ updated_at: null,
354
+ },
355
+ {
356
+ name: '签到设置',
357
+ code: 'sign',
358
+ type: 'input',
359
+ value: '',
360
+ parent_id: 0,
361
+ id: 39,
362
+ created_at: '2020-01-02T03:47:34.000Z',
363
+ updated_at: '2020-01-02T03:47:34.000Z',
364
+ },
365
+ {
366
+ name: '签到积分',
367
+ code: 'sign_integral',
368
+ type: 'decimal',
369
+ value: '10',
370
+ parent_id: 39,
371
+ id: 40,
372
+ created_at: '2020-01-02T03:48:14.000Z',
373
+ updated_at: '2020-01-02T03:48:14.000Z',
374
+ },
375
+ {
376
+ name: '签到赠送积分开启',
377
+ code: 'sign_avaiable',
378
+ type: 'switch',
379
+ value: '1',
380
+ parent_id: 39,
381
+ id: 41,
382
+ created_at: '2020-01-02T08:28:20.000Z',
383
+ updated_at: '2020-01-02T08:28:20.000Z',
384
+ },
385
+ ];
386
+ const result = list.map(item => ({
387
+ ...item,
388
+ value: `${item.value}`,
389
+ })).map(filterNoNeed);
390
+ for (let i = 0; i < result.length; i++) {
391
+ await app.model.setting.upsert(result[i]);
392
+ }
393
+
394
+ return true;
395
+ };
396
+
397
+
398
+ exports.language = async (app) => {
399
+ const lang = [
400
+ {
401
+ name: '中文',
402
+ key: 'cn',
403
+ id: 1,
404
+ created_at: '2019-11-01T14:39:40.000Z',
405
+ updated_at: '2019-11-01T14:39:40.000Z',
406
+ },
407
+ {
408
+ name: '英语',
409
+ key: 'en',
410
+ id: 2,
411
+ created_at: '2019-11-02T02:41:29.000Z',
412
+ updated_at: '2019-11-02T02:41:29.000Z',
413
+ },
414
+ ].map(filterNoNeed);
415
+ const language = [
416
+ {
417
+ name: '你好',
418
+ lang_id: 1,
419
+ key: 'hello',
420
+ value: '你好',
421
+ id: 1,
422
+ created_at: '2019-11-01T14:41:24.000Z',
423
+ updated_at: '2019-11-01T14:41:24.000Z',
424
+ },
425
+ {
426
+ name: '你好',
427
+ lang_id: 2,
428
+ key: 'hello',
429
+ value: 'hello',
430
+ id: 2,
431
+ created_at: '2019-11-02T02:41:42.000Z',
432
+ updated_at: '2019-11-02T02:41:42.000Z',
433
+ },
434
+ {
435
+ name: '登录',
436
+ lang_id: 1,
437
+ key: 'login',
438
+ value: '登录',
439
+ id: 3,
440
+ created_at: '2019-11-03T09:05:44.000Z',
441
+ updated_at: '2019-11-03T09:05:44.000Z',
442
+ },
443
+ {
444
+ name: '登录',
445
+ lang_id: 2,
446
+ key: 'login',
447
+ value: 'login',
448
+ id: 4,
449
+ created_at: '2019-11-03T09:05:55.000Z',
450
+ updated_at: '2019-11-03T09:05:55.000Z',
451
+ },
452
+ {
453
+ name: '登出',
454
+ lang_id: 1,
455
+ key: 'logout',
456
+ value: '登出',
457
+ id: 5,
458
+ created_at: '2019-11-03T09:06:16.000Z',
459
+ updated_at: '2019-11-03T09:06:16.000Z',
460
+ },
461
+ {
462
+ name: '登出',
463
+ lang_id: 2,
464
+ key: 'logout',
465
+ value: 'logout',
466
+ id: 6,
467
+ created_at: '2019-11-03T09:06:31.000Z',
468
+ updated_at: '2019-11-03T09:06:31.000Z',
469
+ },
470
+ {
471
+ name: '注册',
472
+ lang_id: 1,
473
+ key: 'register',
474
+ value: '注册',
475
+ id: 7,
476
+ created_at: '2019-11-03T09:07:56.000Z',
477
+ updated_at: '2019-11-03T09:07:56.000Z',
478
+ },
479
+ {
480
+ name: '注册',
481
+ lang_id: 2,
482
+ key: 'register',
483
+ value: 'register',
484
+ id: 8,
485
+ created_at: '2019-11-03T09:08:06.000Z',
486
+ updated_at: '2019-11-03T09:08:06.000Z',
487
+ },
488
+ {
489
+ name: '我的订单',
490
+ lang_id: 1,
491
+ key: 'my_order',
492
+ value: '我的订单',
493
+ id: 9,
494
+ created_at: '2019-11-03T09:44:56.000Z',
495
+ updated_at: '2019-11-03T09:44:56.000Z',
496
+ },
497
+ {
498
+ name: '我的订单',
499
+ lang_id: 2,
500
+ key: 'my_order',
501
+ value: 'my order',
502
+ id: 10,
503
+ created_at: '2019-11-03T09:45:13.000Z',
504
+ updated_at: '2019-11-03T09:45:13.000Z',
505
+ },
506
+ {
507
+ name: '个人中心',
508
+ lang_id: 1,
509
+ key: 'person_center',
510
+ value: '个人中心',
511
+ id: 11,
512
+ created_at: '2019-11-03T09:46:13.000Z',
513
+ updated_at: '2019-11-03T09:46:13.000Z',
514
+ },
515
+ {
516
+ name: '个人中心',
517
+ lang_id: 2,
518
+ key: 'person_center',
519
+ value: 'person center',
520
+ id: 12,
521
+ created_at: '2019-11-03T09:46:37.000Z',
522
+ updated_at: '2019-11-03T09:46:37.000Z',
523
+ },
524
+ {
525
+ name: '购物车',
526
+ lang_id: 1,
527
+ key: 'person_cart',
528
+ value: '购物车',
529
+ id: 13,
530
+ created_at: '2019-11-03T10:04:48.000Z',
531
+ updated_at: '2019-11-03T10:04:48.000Z',
532
+ },
533
+ {
534
+ name: '购物车',
535
+ lang_id: 2,
536
+ key: 'person_cart',
537
+ value: 'cart',
538
+ id: 14,
539
+ created_at: '2019-11-03T10:05:10.000Z',
540
+ updated_at: '2019-11-03T10:05:10.000Z',
541
+ },
542
+ ].map(filterNoNeed);
543
+ for (let i = 0; i < lang.length; i++) {
544
+ await app.model.lang.upsert(lang[i]);
545
+ }
546
+ for (let i = 0; i < language.length; i++) {
547
+ await app.model.language.upsert(language[i]);
548
+ }
549
+ return true;
550
+ };
551
+
552
+
553
+ exports.orderStatus = async (app) => {
554
+ const order_status = [
555
+ {
556
+ name: '待付款',
557
+ intro: '提交订单',
558
+ id: 1,
559
+ created_at: '2019-11-16T03:49:38.000Z',
560
+ updated_at: '2019-11-16T03:49:38.000Z',
561
+ },
562
+ {
563
+ name: '待发货',
564
+ intro: '付款成功',
565
+ id: 2,
566
+ created_at: '2019-11-16T03:49:38.000Z',
567
+ updated_at: '2019-11-16T03:49:38.000Z',
568
+ },
569
+ {
570
+ name: '待收货',
571
+ intro: '商品出库',
572
+ id: 3,
573
+ created_at: '2019-11-16T03:49:38.000Z',
574
+ updated_at: '2019-11-16T03:49:38.000Z',
575
+ },
576
+ {
577
+ name: '已完成',
578
+ intro: '完成',
579
+ id: 4,
580
+ created_at: '2019-11-16T03:49:38.000Z',
581
+ updated_at: '2019-11-16T03:49:38.000Z',
582
+ },
583
+ ].map(filterNoNeed);
584
+
585
+
586
+ for (let i = 0; i < order_status.length; i++) {
587
+ await app.model.order_status.upsert(order_status[i]);
588
+ }
589
+ };
@@ -0,0 +1,61 @@
1
+ const { lodash } = require('multiple-quick-koa')
2
+
3
+ exports.getSetting = (config) => (type) =>
4
+ config.find((i) => i.key === type).value
5
+
6
+ exports.getName = (config) => (type) => {
7
+ const obj = config.find((i) => i.code === type)
8
+ return lodash.get(obj, 'type', '')
9
+ }
10
+
11
+ exports.getList = (config) => (type) => {
12
+ const obj = config.find((i) => i.code === type)
13
+ if (!obj) throw new Error(`找不到${type}相关设置`)
14
+ const list = config.filter((i) => i.parent_id === obj.id)
15
+ return list
16
+ }
17
+
18
+ exports.getObject = (config) => (type) => {
19
+ const obj = config.find((i) => i.code === type)
20
+ if (!obj) throw new Error(`找不到${type}相关设置`)
21
+ const list = config.filter((i) => i.parent_id === obj.id)
22
+ const temObj = {}
23
+ for (let i = 0; i < list.length; i++) {
24
+ if (list[i].type === 'decimal') {
25
+ temObj[list[i].code] = Number(list[i].value)
26
+ } else if (list[i].type === 'switch') {
27
+ temObj[list[i].code] = Boolean(Number(list[i].value))
28
+ } else {
29
+ temObj[list[i].code] = list[i].value
30
+ }
31
+ }
32
+ return temObj
33
+ }
34
+
35
+ exports.hashFn = (str, asString = false, seed = false) => {
36
+ var i
37
+ var l
38
+
39
+ var hval = seed === undefined ? 0x811c9dc5 : seed
40
+
41
+ for (i = 0, l = str.length; i < l; i++) {
42
+ hval ^= str.charCodeAt(i)
43
+
44
+ hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24)
45
+ }
46
+
47
+ if (asString) {
48
+ // Convert to 8 digit hex string
49
+
50
+ return ('0000000' + (hval >>> 0).toString(16)).substr(-8)
51
+ }
52
+
53
+ return hval >>> 0
54
+ }
55
+
56
+ exports.safeSplit = (mainStr, str) => {
57
+ if (mainStr.includes(str)) {
58
+ return mainStr.split(str)
59
+ }
60
+ return ['', '']
61
+ }