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
3f227fc3
Commit
3f227fc3
authored
Jun 28, 2023
by
wangp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lakala-wxjsapi-alipay
parent
ce89200b
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
260 additions
and
200 deletions
+260
-200
notice.go
controller/api/v1/pay/notice.go
+17
-19
pay.go
controller/api/v1/pay/pay.go
+7
-2
jwt.go
middleware/jwt/jwt.go
+45
-52
pay.go
repository/pay/pay.go
+191
-127
No files found.
controller/api/v1/pay/notice.go
View file @
3f227fc3
...
...
@@ -4,6 +4,8 @@ import (
"fmt"
"github.com/gin-gonic/gin"
"system_pay/controller/base"
"system_pay/models"
"system_pay/repository/pay"
)
// 卡拉卡统一支付回调
...
...
@@ -36,24 +38,20 @@ func (l *PayController) WxNotice(c *gin.Context) {
//}
//fmt.Println(ph2)
//ph := new(models.WxNoticeInput)
//err := c.ShouldBindJSON(ph)
//if err != nil {
// response := new(base.ResponseDataWxNotice)
// response.Code = "FAIL"
// response.Message = "执行失败2"
// base.ResponseWxNotice(c, response)
// return
//}
////fmt.Println(ph)
//
//// 拉卡拉统一支付微信回调
//response, err := pay.WxNotice(ph)
//
//fmt.Println("拉卡拉微信回调end")
response
:=
new
(
base
.
ResponseDataWxNotice
)
response
.
Code
=
"SUCCESS"
response
.
Message
=
"执行成功"
ph
:=
new
(
models
.
WxNoticeInput
)
err
:=
c
.
ShouldBindJSON
(
ph
)
if
err
!=
nil
{
response
:=
new
(
base
.
ResponseDataWxNotice
)
response
.
Code
=
"FAIL"
response
.
Message
=
"执行失败2"
base
.
ResponseWxNotice
(
c
,
response
)
return
}
//fmt.Println(ph)
// 拉卡拉统一支付微信回调
response
,
err
:=
pay
.
WxNotice
(
ph
)
fmt
.
Println
(
"拉卡拉微信回调end"
)
base
.
ResponseWxNotice
(
c
,
response
)
}
controller/api/v1/pay/pay.go
View file @
3f227fc3
...
...
@@ -26,7 +26,7 @@ type PayController struct {
func
(
l
*
PayController
)
UnifiedOrder
(
c
*
gin
.
Context
)
{
ph
:=
new
(
models
.
PlaceAnOrderParamInput
)
fmt
.
Println
(
"ContentType="
+
c
.
ContentType
())
//
fmt.Println("ContentType="+c.ContentType())
err
:=
c
.
ShouldBindJSON
(
ph
)
if
err
!=
nil
{
zap
.
L
()
.
Error
(
err
.
Error
())
...
...
@@ -34,8 +34,13 @@ func (l *PayController) UnifiedOrder(c *gin.Context) {
return
}
// clientIp ip
//ip = c.Ctx.Input.IP()
ip
:=
c
.
ClientIP
()
fmt
.
Println
(
"ip="
+
ip
)
// 拉卡拉统一支付
rtn
,
err
:=
pay
.
UnifiedOrder
(
ph
)
rtn
,
err
:=
pay
.
UnifiedOrder
(
ph
,
ip
)
if
err
!=
nil
{
zap
.
L
()
.
Error
(
err
.
Error
())
//base.ResponseErrorWithMsg(c, base.ServerError)
...
...
middleware/jwt/jwt.go
View file @
3f227fc3
package
jwt
import
(
"fmt"
"github.com/gin-gonic/gin"
"system_pay/controller/base"
"system_pay/utils"
)
//var DataAnalysisCh chan models.DataAnalysisModel
func
init
()
{
...
...
@@ -15,51 +8,51 @@ func init() {
}
// JWTAuthMiddleWare 基于JWT的认证中间件
func
JWTAuthMiddleWare
()
func
(
c
*
gin
.
Context
)
{
return
func
(
c
*
gin
.
Context
)
{
//客户端携带Token放在请求头
authHeader
:=
c
.
Request
.
Header
.
Get
(
"Authorization"
)
if
authHeader
==
""
{
base
.
ResponseErrorWithMsg
(
c
,
base
.
AuthorizationEmpty
)
c
.
Abort
()
return
}
mc
,
err
:=
utils
.
ParseToken
(
authHeader
)
if
err
!=
nil
{
base
.
ResponseErrorWithMsg
(
c
,
base
.
AuthorizationEmpty
)
c
.
Abort
()
return
}
// des解密
phoneMob
:=
utils
.
ToDesDecrypt
(
mc
.
PhoneMob
)
userId
:=
utils
.
ToDesDecrypt
(
mc
.
UserId
)
userName
:=
utils
.
ToDesDecrypt
(
mc
.
UserName
)
//hospitalCode := utils.ToDesDecrypt(mc.HospitalCode)
//chainCode := utils.ToDesDecrypt(mc.ChainCode)
//hospitalID := utils.ToDesDecrypt(mc.HospitalID)
//hospitalName := utils.ToDesDecrypt(mc.HospitalName)
//ChainID := utils.ToDesDecrypt(mc.ChainID)
// 将当前请求的username信息保存到请求的上下文c上
c
.
Set
(
"phone_mob"
,
phoneMob
)
fmt
.
Println
(
phoneMob
)
c
.
Set
(
"user_id"
,
userId
)
fmt
.
Println
(
userId
)
c
.
Set
(
"user_name"
,
userName
)
fmt
.
Println
(
userName
)
//c.Set("hospital_code", hospitalCode)
//c.Set("chain_code", chainCode)
//c.Set("hospital_id", hospitalID)
//c.Set("hospital_name", hospitalName)
//c.Set("chain_id", ChainID)
// 后续的处理函数可以用过c.Get("username")来获取当前请求的用户信息
// 埋点生产者
//BuriedProducer(c, hospitalCode, hospitalName, hospitalID)
c
.
Next
()
}
}
//
func JWTAuthMiddleWare() func(c *gin.Context) {
//
return func(c *gin.Context) {
//
//客户端携带Token放在请求头
//
authHeader := c.Request.Header.Get("Authorization")
//
if authHeader == "" {
//
base.ResponseErrorWithMsg(c, base.AuthorizationEmpty)
//
c.Abort()
//
return
//
}
//
//
mc, err := utils.ParseToken(authHeader)
//
if err != nil {
//
base.ResponseErrorWithMsg(c, base.AuthorizationEmpty)
//
c.Abort()
//
return
//
}
//
//
// des解密
//
phoneMob := utils.ToDesDecrypt(mc.PhoneMob)
//
userId := utils.ToDesDecrypt(mc.UserId)
//
userName := utils.ToDesDecrypt(mc.UserName)
//
//hospitalCode := utils.ToDesDecrypt(mc.HospitalCode)
//
//chainCode := utils.ToDesDecrypt(mc.ChainCode)
//
//hospitalID := utils.ToDesDecrypt(mc.HospitalID)
//
//hospitalName := utils.ToDesDecrypt(mc.HospitalName)
//
//ChainID := utils.ToDesDecrypt(mc.ChainID)
//
// 将当前请求的username信息保存到请求的上下文c上
//
c.Set("phone_mob", phoneMob)
//
fmt.Println(phoneMob)
//
c.Set("user_id", userId)
//
fmt.Println(userId)
//
c.Set("user_name", userName)
//
fmt.Println(userName)
//
//c.Set("hospital_code", hospitalCode)
//
//c.Set("chain_code", chainCode)
//
//c.Set("hospital_id", hospitalID)
//
//c.Set("hospital_name", hospitalName)
//
//c.Set("chain_id", ChainID)
//
// 后续的处理函数可以用过c.Get("username")来获取当前请求的用户信息
//
//
// 埋点生产者
//
//BuriedProducer(c, hospitalCode, hospitalName, hospitalID)
//
c.Next()
//
}
//
}
// 埋点消费者
//func DataAnalysisChannel() {
...
...
repository/pay/pay.go
View file @
3f227fc3
This diff is collapsed.
Click to expand it.
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