q-koa 12.0.9 → 12.1.1

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
@@ -1534,8 +1534,9 @@ class APP {
1534
1534
  app[appName].attributes[modelName] &&
1535
1535
  app[appName].attributes[modelName][controller + '_id']
1536
1536
  ) {
1537
- const { required, include, where, ...rest } =
1538
- myInclude[j]
1537
+ const { required, include, where, ...rest } = myInclude[
1538
+ j
1539
+ ]
1539
1540
  const list = await model.findAll({
1540
1541
  where: {
1541
1542
  [controller + '_id']: target.id,
@@ -2016,6 +2017,16 @@ APP.getUserByCtx = (ctx) => {
2016
2017
  return 0
2017
2018
  }
2018
2019
  }
2020
+
2021
+ APP.getUserNameByCtx = (ctx) => {
2022
+ try {
2023
+ const appName = ctx.router.opts.prefix.substring(1)
2024
+ return ctx.request[`${appName}-user`].name || ''
2025
+ } catch (e) {
2026
+ return ''
2027
+ }
2028
+ }
2029
+
2019
2030
  APP.getClientTypeByCtx = (ctx) => {
2020
2031
  const typeEnum = {
2021
2032
  1: 'admin',
@@ -59,7 +59,7 @@ exports.login = async (ctx) => {
59
59
  name,
60
60
  },
61
61
  attributes: {
62
- exclude: ['createdid', 'updated_at', 'created_at', 'password'],
62
+ exclude: ['createdid', 'updated_at', 'created_at'],
63
63
  },
64
64
  include: [
65
65
  {
@@ -131,7 +131,7 @@ exports.checkLogin = async (ctx) => {
131
131
  password: ctx.request[`${appName}-user`].password || '',
132
132
  },
133
133
  attributes: {
134
- exclude: ['createdid', 'updated_at', 'created_at', 'password'],
134
+ exclude: ['createdid', 'updated_at', 'created_at'],
135
135
  },
136
136
  include: [
137
137
  {
@@ -1,4 +1,10 @@
1
- const { getAppByCtx, getAppConfig, getConfig, lodash } = require('q-koa')
1
+ const {
2
+ getAppByCtx,
3
+ getAppConfig,
4
+ getConfig,
5
+ lodash,
6
+ moment,
7
+ } = require('q-koa')
2
8
  const { Pay } = require('@sigodenjs/wechatpay')
3
9
  const WXPay = require('weixin-pay-fork')
4
10
  const path = require('path')
@@ -744,20 +750,37 @@ exports.downloadBill = async ({ ctx, pay_config = 'weixin_pay', ...rest }) => {
744
750
  result: list.map((item) => {
745
751
  const array = item.split(',')
746
752
  const orderdate = array[20].substring(1).slice(2, 10)
753
+ const orderPrefix = array[6].substring(1).split('_')[1]
754
+ let order_id = 0
755
+ let prefix = ''
756
+ if (orderPrefix.includes('-')) {
757
+ order_id = Number(orderPrefix.split('-')[1])
758
+ prefix = orderPrefix.split('-')[0]
759
+ } else {
760
+ order_id = Number(orderPrefix)
761
+ }
762
+ let order_date
763
+ if (prefix) {
764
+ order_date = moment(array[0].substring(1)).format('YYYY-MM-DD') + ''
765
+ } else {
766
+ order_date = moment(
767
+ `${orderdate.slice(0, 4)}-${orderdate.slice(
768
+ 4,
769
+ 6
770
+ )}-${orderdate.slice(6, 8)}`
771
+ ).format('YYYY-MM-DD')
772
+ }
747
773
  return {
748
774
  created_at: array[0].substring(1),
749
775
  transactionid: array[5].substring(1),
750
- order_id: Number(array[6].substring(1).split('_')[1]),
776
+ [`${[prefix, 'order_id'].filter(Boolean).join('_')}`]: order_id,
751
777
  openid: array[7].substring(1),
752
778
  price: Number(array[12].substring(1)),
753
779
  refund_price: Number(array[16].substring(1)),
754
780
  remark: array[20].substring(1),
755
781
  rate_price: Number(array[22].substring(1)),
756
782
  type: array[9].substring(1),
757
- order_date: `${orderdate.slice(0, 4)}-${orderdate.slice(
758
- 4,
759
- 6
760
- )}-${orderdate.slice(6, 8)}`,
783
+ order_date,
761
784
  }
762
785
  }),
763
786
  totalHeader: arr[arr.length - 3],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "12.0.9",
3
+ "version": "12.1.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {