Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
system_pay
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王沛
system_pay
Commits
fbce7a23
Commit
fbce7a23
authored
Jun 21, 2023
by
wangp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
40a19fed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
24 deletions
+60
-24
code.go
controller/base/code.go
+8
-4
response.go
controller/base/response.go
+35
-9
pay.go
repository/pay/pay.go
+17
-11
No files found.
controller/base/code.go
View file @
fbce7a23
...
...
@@ -6,11 +6,14 @@ package base
const
(
// Success 请求成功
Success
=
1000
//Success = 1000
Success
=
0
// ServerError 服务器错误
ServerError
=
1100
//ServerError = 1100
ServerError
=
9
// Warning 警告
Warning
=
1200
//Warning = 1200
Warning
=
1
// FailedToObtainVerificationCode 验证码获取失败
//FailedToObtainVerificationCode = 1001
...
...
@@ -19,7 +22,8 @@ const (
// VerificationCodeError 验证码错误
//VerificationCodeError = 1003
// AuthorizationEmpty token为空
AuthorizationEmpty
=
1004
//AuthorizationEmpty = 1004
AuthorizationEmpty
=
4
// ThisAccountDoesNotHavePermission 此账号没有权限
//ThisAccountDoesNotHavePermission = 1005
// ParameterValidationFailed 参数效验失败
...
...
controller/base/response.go
View file @
fbce7a23
...
...
@@ -15,35 +15,61 @@ import (
*/
// ResponseData 统一返回数据
//type ResponseData struct {
// Code int `json:"code"`
// Msg interface{} `json:"msg"`
// Data interface{} `json:"data,omitempty"`
//}
type
ResponseData
struct
{
Code
int
`json:"code
"`
M
sg
interface
{}
`json:"msg
"`
Data
interface
{}
`json:"d
ata,omitempty"`
Status
int
`json:"Status
"`
M
essage
interface
{}
`json:"Message
"`
Data
interface
{}
`json:"D
ata,omitempty"`
}
// ResponseErrorWithMsg 返回错误
//func ResponseErrorWithMsg(c *gin.Context, code int) {
// c.JSON(http.StatusOK, &ResponseData{
// Code: code,
// Msg: InternationalizedMsg(c, code),
// Data: nil,
// })
//}
func
ResponseErrorWithMsg
(
c
*
gin
.
Context
,
code
int
)
{
c
.
JSON
(
http
.
StatusOK
,
&
ResponseData
{
Code
:
code
,
M
sg
:
InternationalizedMsg
(
c
,
code
),
Status
:
code
,
M
essage
:
InternationalizedMsg
(
c
,
code
),
Data
:
nil
,
})
}
// ResponseSuccess 返回正确
//func ResponseSuccess(c *gin.Context, data interface{}) {
// c.JSON(http.StatusOK, &ResponseData{
// Code: Success,
// Msg: InternationalizedMsg(c, Success),
// Data: data,
// })
//}
func
ResponseSuccess
(
c
*
gin
.
Context
,
data
interface
{})
{
c
.
JSON
(
http
.
StatusOK
,
&
ResponseData
{
Code
:
Success
,
M
sg
:
InternationalizedMsg
(
c
,
Success
),
Status
:
Success
,
M
essage
:
InternationalizedMsg
(
c
,
Success
),
Data
:
data
,
})
}
// ResponseErrorMsg 直接返回msg
//func ResponseErrorMsg(c *gin.Context, msg string) {
// c.JSON(http.StatusOK, &ResponseData{
// Code: Warning,
// Msg: msg,
// Data: nil,
// })
//}
func
ResponseErrorMsg
(
c
*
gin
.
Context
,
msg
string
)
{
c
.
JSON
(
http
.
StatusOK
,
&
ResponseData
{
Code
:
Warning
,
M
sg
:
msg
,
Status
:
Warning
,
M
essage
:
msg
,
Data
:
nil
,
})
}
\ No newline at end of file
repository/pay/pay.go
View file @
fbce7a23
...
...
@@ -18,16 +18,6 @@ import (
"time"
)
func
RandomString
(
n
int
)
string
{
var
letters
=
[]
byte
(
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
)
result
:=
make
([]
byte
,
n
)
rand2
.
Seed
(
time
.
Now
()
.
Unix
())
for
i
:=
range
result
{
result
[
i
]
=
letters
[
rand2
.
Intn
(
len
(
letters
))]
}
return
string
(
result
)
}
// 拉卡拉支付
func
UnifiedOrder
(
input
*
models
.
PlaceAnOrderParamInput
)
(
interface
{},
error
)
{
...
...
@@ -41,6 +31,9 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput) (interface{}, error) {
//}
//rtn := make(map[string]string)
fmt
.
Println
(
"接口输入参数"
)
fmt
.
Println
(
input
)
data
:=
make
(
map
[
string
]
interface
{})
data
[
"req_time"
]
=
"20220714160009"
data
[
"version"
]
=
"3.0"
...
...
@@ -64,6 +57,9 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput) (interface{}, error) {
// "extend_info": "自动化测试",
// "callback_url": ""
input
.
NoticeURL
=
"https://test.pet-dbc.cn/uni/api/repayment/PayCallBack"
input
.
ReturnURL
=
"https://test.pet-dbc.cn"
data2
:=
make
(
map
[
string
]
interface
{})
//data2["out_trade_no"] = "FD660E1FAA3A4470933CDEDAE1EC1DUU"
data2
[
"out_trade_no"
]
=
RandomString
(
32
)
...
...
@@ -392,7 +388,6 @@ func lakala_post(url string, data_json []byte) (error, string) {
temp2
,
_
:=
temp
[
"resp_data"
]
.
(
map
[
string
]
interface
{})
if
temp2
[
"counter_url"
]
==
""
{
fmt
.
Println
(
temp2
)
return
errors
.
New
(
"拉卡拉返回值「counter_url」为空错误"
),
""
}
...
...
@@ -497,3 +492,14 @@ func genPriKey(privateKey []byte, privateKeyType int64) (*rsa.PrivateKey, error)
}
return
priKey
,
nil
}
//生产随机字符串
func
RandomString
(
n
int
)
string
{
var
letters
=
[]
byte
(
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
)
result
:=
make
([]
byte
,
n
)
rand2
.
Seed
(
time
.
Now
()
.
Unix
())
for
i
:=
range
result
{
result
[
i
]
=
letters
[
rand2
.
Intn
(
len
(
letters
))]
}
return
string
(
result
)
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment