q-koa 12.1.0 → 12.1.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.
- package/core/app.js +14 -2
- package/core/file/plugins/weixin/service.js +29 -6
- package/package.json +1 -1
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
|
-
|
|
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,
|
|
@@ -1975,6 +1976,7 @@ APP.Validator = Validator
|
|
|
1975
1976
|
APP.ServiceError = ServiceError
|
|
1976
1977
|
APP.TransactionError = TransactionError
|
|
1977
1978
|
APP.moment = moment
|
|
1979
|
+
APP.is_dev = is_dev
|
|
1978
1980
|
|
|
1979
1981
|
global.moment = moment
|
|
1980
1982
|
global.Sequelize = Sequelize
|
|
@@ -2016,6 +2018,16 @@ APP.getUserByCtx = (ctx) => {
|
|
|
2016
2018
|
return 0
|
|
2017
2019
|
}
|
|
2018
2020
|
}
|
|
2021
|
+
|
|
2022
|
+
APP.getUserNameByCtx = (ctx) => {
|
|
2023
|
+
try {
|
|
2024
|
+
const appName = ctx.router.opts.prefix.substring(1)
|
|
2025
|
+
return ctx.request[`${appName}-user`].name || ''
|
|
2026
|
+
} catch (e) {
|
|
2027
|
+
return ''
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2019
2031
|
APP.getClientTypeByCtx = (ctx) => {
|
|
2020
2032
|
const typeEnum = {
|
|
2021
2033
|
1: 'admin',
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
const {
|
|
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
|
|
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
|
|
758
|
-
4,
|
|
759
|
-
6
|
|
760
|
-
)}-${orderdate.slice(6, 8)}`,
|
|
783
|
+
order_date,
|
|
761
784
|
}
|
|
762
785
|
}),
|
|
763
786
|
totalHeader: arr[arr.length - 3],
|