q-koa 10.7.8 → 10.8.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/file/plugins/alipay/controller.js +69 -0
- package/core/file/plugins/language/config.js +41 -4
- package/core/file/plugins/language/model.js +12 -44
- package/package.json +2 -1
- package/core/file/plugins/lang/config.js +0 -4
- package/core/file/plugins/lang/model.js +0 -15
- package/core/file/plugins/language copy/config.js +0 -42
- package/core/file/plugins/language copy/model.js +0 -21
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const Alipay = require('../../services/alipay')
|
|
2
2
|
|
|
3
3
|
const { getAppByCtx, getConfig } = require('q-koa')
|
|
4
|
+
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const fs = require('fs')
|
|
7
|
+
const AlipaySdk = require('alipay-sdk').default
|
|
8
|
+
|
|
4
9
|
exports.h5_pay = async (ctx) => {
|
|
5
10
|
const { app, appName } = getAppByCtx(ctx)
|
|
6
11
|
|
|
@@ -66,3 +71,67 @@ exports.notify = async (ctx) => {
|
|
|
66
71
|
ctx.body = 'success'
|
|
67
72
|
}
|
|
68
73
|
}
|
|
74
|
+
|
|
75
|
+
exports.mp_pay = async (ctx) => {
|
|
76
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
77
|
+
const appConfig = getConfig(app)
|
|
78
|
+
const { is_dev, site_host } = await appConfig.getObject('base')
|
|
79
|
+
const {
|
|
80
|
+
app_id,
|
|
81
|
+
alipay_public_key,
|
|
82
|
+
key,
|
|
83
|
+
is_sandbox,
|
|
84
|
+
...rest
|
|
85
|
+
} = await appConfig.getObject('alipay')
|
|
86
|
+
|
|
87
|
+
const {
|
|
88
|
+
name,
|
|
89
|
+
out_trade_no: _out_trade_no,
|
|
90
|
+
prefix = '',
|
|
91
|
+
order_id,
|
|
92
|
+
type,
|
|
93
|
+
price,
|
|
94
|
+
is_admin = false,
|
|
95
|
+
buyer_id = '2088722007804916',
|
|
96
|
+
} = ctx.request.body
|
|
97
|
+
|
|
98
|
+
const gateway = is_sandbox
|
|
99
|
+
? `https://openapi.alipaydev.com/gateway.do`
|
|
100
|
+
: 'https://openapi.alipay.com/gateway.do'
|
|
101
|
+
|
|
102
|
+
const notify_url = `https://${
|
|
103
|
+
site_host || 'api.kuashou.com'
|
|
104
|
+
}/${appName}/alipay/notify`
|
|
105
|
+
|
|
106
|
+
const alipaySdk = new AlipaySdk({
|
|
107
|
+
appId: app_id,
|
|
108
|
+
signType: 'RSA2', // 签名算法,默认 RSA2
|
|
109
|
+
gateway, // 支付宝网关地址 ,沙箱环境下使用时需要修改
|
|
110
|
+
alipayPublicKey: alipay_public_key,
|
|
111
|
+
privateKey: fs.readFileSync(
|
|
112
|
+
path.resolve(__dirname, 'private-key.pem'),
|
|
113
|
+
'ascii'
|
|
114
|
+
),
|
|
115
|
+
notify_url,
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const out_trade_no = _out_trade_no
|
|
119
|
+
? _out_trade_no
|
|
120
|
+
: prefix
|
|
121
|
+
? `${key.length > 10 ? appName : key}_${prefix}-${order_id}_${type}`
|
|
122
|
+
: `${key.length > 10 ? appName : key}_${order_id}_${type}`
|
|
123
|
+
|
|
124
|
+
const res = await alipaySdk.exec('alipay.trade.create', {
|
|
125
|
+
bizContent: {
|
|
126
|
+
out_trade_no,
|
|
127
|
+
total_amount: is_admin || is_dev ? 1 : Math.round(price * 100),
|
|
128
|
+
subject: name,
|
|
129
|
+
buyer_id,
|
|
130
|
+
},
|
|
131
|
+
})
|
|
132
|
+
if (res.code !== '10000') {
|
|
133
|
+
throw new Error(res.subMsg)
|
|
134
|
+
}
|
|
135
|
+
const { code, msg, tradeNo, ...other } = res
|
|
136
|
+
return ctx.SUCCESS(tradeNo)
|
|
137
|
+
}
|
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
name: '
|
|
3
|
-
belongs: '
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
name: '语言设置',
|
|
3
|
+
belongs: 'page',
|
|
4
|
+
multiple: false,
|
|
5
|
+
availableSort: false,
|
|
6
|
+
order: [],
|
|
7
|
+
referenceSelect: [],
|
|
8
|
+
select: [
|
|
9
|
+
{ key: 'name', symbol: '$like' },
|
|
10
|
+
{
|
|
11
|
+
key: 'type',
|
|
12
|
+
admin: {
|
|
13
|
+
name: 'admin',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
excludes: [],
|
|
18
|
+
limit: 20,
|
|
19
|
+
defaultOrder: [{ sort: 'descending', type: 'id' }],
|
|
20
|
+
comment: {},
|
|
21
|
+
sortOrder: 1,
|
|
22
|
+
reference: [
|
|
23
|
+
{ key: 'operate_language', name: '设置', width: 300, common: true },
|
|
24
|
+
],
|
|
25
|
+
excludeAuth: [],
|
|
26
|
+
include: ((app) => {
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
model: app.model.language_value,
|
|
30
|
+
},
|
|
31
|
+
]
|
|
32
|
+
}).toString(),
|
|
33
|
+
initList: ['language_type'],
|
|
34
|
+
editInline: {},
|
|
35
|
+
autoData: {},
|
|
36
|
+
is_split: false,
|
|
37
|
+
is_split_count: false,
|
|
38
|
+
show_virtual: false,
|
|
39
|
+
modelQuery: {},
|
|
40
|
+
deleteCheckList: [],
|
|
41
|
+
bulkCreateList: [],
|
|
42
|
+
}
|
|
@@ -1,53 +1,21 @@
|
|
|
1
|
-
const { Sequelize } = require('q-koa')
|
|
1
|
+
const { Sequelize, Random } = require('q-koa')
|
|
2
2
|
|
|
3
3
|
exports.name = {
|
|
4
4
|
type: Sequelize.STRING,
|
|
5
|
-
comment: '
|
|
5
|
+
comment: '说明',
|
|
6
6
|
allowNull: false,
|
|
7
|
+
is_mock: true,
|
|
7
8
|
defaultValue: '',
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
msg: '名字不允许为空',
|
|
11
|
-
},
|
|
12
|
-
notEmpty: {
|
|
13
|
-
msg: '名字不允许为空',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
9
|
+
sortOrder: 1,
|
|
10
|
+
mock: () => Random.ctitle(),
|
|
16
11
|
}
|
|
17
12
|
|
|
18
|
-
exports.
|
|
19
|
-
type: Sequelize.
|
|
20
|
-
comment: '
|
|
13
|
+
exports.type = {
|
|
14
|
+
type: Sequelize.ENUM('input', 'textarea', 'content'),
|
|
15
|
+
comment: '类型',
|
|
21
16
|
allowNull: false,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
type: Sequelize.STRING,
|
|
27
|
-
comment: 'key值',
|
|
28
|
-
allowNull: false,
|
|
29
|
-
defaultValue: '',
|
|
30
|
-
validate: {
|
|
31
|
-
notNull: {
|
|
32
|
-
msg: 'key值不允许为空',
|
|
33
|
-
},
|
|
34
|
-
notEmpty: {
|
|
35
|
-
msg: 'key值不允许为空',
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exports.value = {
|
|
41
|
-
type: Sequelize.STRING,
|
|
42
|
-
comment: 'value值',
|
|
43
|
-
allowNull: false,
|
|
44
|
-
defaultValue: '',
|
|
45
|
-
validate: {
|
|
46
|
-
notNull: {
|
|
47
|
-
msg: 'value值不允许为空',
|
|
48
|
-
},
|
|
49
|
-
notEmpty: {
|
|
50
|
-
msg: 'value值不允许为空',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
17
|
+
is_mock: true,
|
|
18
|
+
defaultValue: 'input',
|
|
19
|
+
sortOrder: 2,
|
|
20
|
+
mock: () => ['input', 'textarea', 'content'][Random.integer(0, 2)],
|
|
53
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "q-koa",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.8.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"author": "",
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"alipay-sdk": "^3.2.0",
|
|
19
20
|
"@alicloud/pop-core": "^1.7.9",
|
|
20
21
|
"@sigodenjs/wechatpay": "^2.1.1",
|
|
21
22
|
"ali-oss": "^6.11.2",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const { Sequelize } = require('q-koa')
|
|
2
|
-
|
|
3
|
-
exports.name = {
|
|
4
|
-
type: Sequelize.STRING,
|
|
5
|
-
comment: '名字',
|
|
6
|
-
allowNull: false,
|
|
7
|
-
defaultValue: '',
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
exports.key = {
|
|
11
|
-
type: Sequelize.STRING,
|
|
12
|
-
comment: 'key',
|
|
13
|
-
allowNull: false,
|
|
14
|
-
defaultValue: '',
|
|
15
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
name: '语言设置',
|
|
3
|
-
belongs: 'page',
|
|
4
|
-
multiple: false,
|
|
5
|
-
availableSort: false,
|
|
6
|
-
order: [],
|
|
7
|
-
referenceSelect: [],
|
|
8
|
-
select: [
|
|
9
|
-
{ key: 'name', symbol: '$like' },
|
|
10
|
-
{
|
|
11
|
-
key: 'type',
|
|
12
|
-
admin: {
|
|
13
|
-
name: 'admin',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
excludes: [],
|
|
18
|
-
limit: 20,
|
|
19
|
-
defaultOrder: [{ sort: 'descending', type: 'id' }],
|
|
20
|
-
comment: {},
|
|
21
|
-
sortOrder: 1,
|
|
22
|
-
reference: [
|
|
23
|
-
{ key: 'operate_language', name: '设置', width: 300, common: true },
|
|
24
|
-
],
|
|
25
|
-
excludeAuth: [],
|
|
26
|
-
include: ((app) => {
|
|
27
|
-
return [
|
|
28
|
-
{
|
|
29
|
-
model: app.model.language_value,
|
|
30
|
-
},
|
|
31
|
-
]
|
|
32
|
-
}).toString(),
|
|
33
|
-
initList: ['language_type'],
|
|
34
|
-
editInline: {},
|
|
35
|
-
autoData: {},
|
|
36
|
-
is_split: false,
|
|
37
|
-
is_split_count: false,
|
|
38
|
-
show_virtual: false,
|
|
39
|
-
modelQuery: {},
|
|
40
|
-
deleteCheckList: [],
|
|
41
|
-
bulkCreateList: [],
|
|
42
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const { Sequelize, Random } = require('q-koa')
|
|
2
|
-
|
|
3
|
-
exports.name = {
|
|
4
|
-
type: Sequelize.STRING,
|
|
5
|
-
comment: '说明',
|
|
6
|
-
allowNull: false,
|
|
7
|
-
is_mock: true,
|
|
8
|
-
defaultValue: '',
|
|
9
|
-
sortOrder: 1,
|
|
10
|
-
mock: () => Random.ctitle(),
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
exports.type = {
|
|
14
|
-
type: Sequelize.ENUM('input', 'textarea', 'content'),
|
|
15
|
-
comment: '类型',
|
|
16
|
-
allowNull: false,
|
|
17
|
-
is_mock: true,
|
|
18
|
-
defaultValue: 'input',
|
|
19
|
-
sortOrder: 2,
|
|
20
|
-
mock: () => ['input', 'textarea', 'content'][Random.integer(0, 2)],
|
|
21
|
-
}
|