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
af1afef6
Commit
af1afef6
authored
Jul 05, 2023
by
wangp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lakala
parent
2d3b8c66
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
388 additions
and
115 deletions
+388
-115
notice.go
controller/api/v1/pay/notice.go
+1
-1
pay.go
controller/api/v1/pay/pay.go
+34
-0
docs.go
docs/docs.go
+49
-1
swagger.json
docs/swagger.json
+49
-1
swagger.yaml
docs/swagger.yaml
+32
-1
notice.go
models/notice.go
+31
-12
pay.go
models/pay.go
+7
-1
notice.go
repository/pay/notice.go
+27
-2
pay.go
repository/pay/pay.go
+155
-96
pay_router.go
router/v1/pay_router.go
+3
-0
No files found.
controller/api/v1/pay/notice.go
View file @
af1afef6
...
@@ -47,7 +47,7 @@ func (l *PayController) WxNotice(c *gin.Context) {
...
@@ -47,7 +47,7 @@ func (l *PayController) WxNotice(c *gin.Context) {
base
.
ResponseWxNotice
(
c
,
response
)
base
.
ResponseWxNotice
(
c
,
response
)
return
return
}
}
//
fmt.Println(ph)
fmt
.
Println
(
ph
)
// 拉卡拉统一支付微信回调
// 拉卡拉统一支付微信回调
response
,
err
:=
pay
.
WxNotice
(
ph
)
response
,
err
:=
pay
.
WxNotice
(
ph
)
...
...
controller/api/v1/pay/pay.go
View file @
af1afef6
...
@@ -50,3 +50,37 @@ func (l *PayController) UnifiedOrder(c *gin.Context) {
...
@@ -50,3 +50,37 @@ func (l *PayController) UnifiedOrder(c *gin.Context) {
base
.
ResponseSuccess
(
c
,
rtn
)
base
.
ResponseSuccess
(
c
,
rtn
)
}
}
// UnifiedRefund 拉卡拉退款
// @Summary 拉卡拉退款
// @Description 拉卡拉退款
// @Tags 拉卡拉退款
// @Accept application/json
// @Produce application/json
// @Param body body models.RefundParamInput true "参数"
// @Param language header string ture "语言类型 zh-CN简体中文 en-US英文 ja 日文 默认中文"
// @Success 200
// @router /api/v1/pay/unified_refund [post]
func
(
l
*
PayController
)
UnifiedRefund
(
c
*
gin
.
Context
)
{
ph
:=
new
(
models
.
RefundParamInput
)
err
:=
c
.
ShouldBindJSON
(
ph
)
if
err
!=
nil
{
zap
.
L
()
.
Error
(
err
.
Error
())
base
.
ResponseErrorWithMsg
(
c
,
base
.
ServerError
)
return
}
ip
:=
c
.
ClientIP
()
fmt
.
Println
(
"ip="
+
ip
)
// 拉卡拉退款
rtn
,
err
:=
pay
.
UnifiedRefund
(
ph
,
ip
)
if
err
!=
nil
{
zap
.
L
()
.
Error
(
err
.
Error
())
base
.
ResponseErrorMsg
(
c
,
err
.
Error
())
return
}
base
.
ResponseSuccess
(
c
,
rtn
)
}
\ No newline at end of file
docs/docs.go
View file @
af1afef6
...
@@ -60,6 +60,43 @@ var doc = `{
...
@@ -60,6 +60,43 @@ var doc = `{
}
}
}
}
},
},
"/api/v1/pay/unified_refund": {
"post": {
"description": "拉卡拉退款",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"拉卡拉退款"
],
"summary": "拉卡拉退款",
"parameters": [
{
"description": "参数",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.RefundParamInput"
}
},
{
"type": "string",
"description": "语言类型 zh-CN简体中文 en-US英文 ja 日文 默认中文",
"name": "language",
"in": "header"
}
],
"responses": {
"200": {
"description": ""
}
}
}
},
"/api/v1/pay/wx_notice": {
"/api/v1/pay/wx_notice": {
"post": {
"post": {
"description": "拉卡拉统一支付微信回调",
"description": "拉卡拉统一支付微信回调",
...
@@ -167,6 +204,17 @@ var doc = `{
...
@@ -167,6 +204,17 @@ var doc = `{
}
}
}
}
},
},
"models.RefundParamInput": {
"type": "object",
"properties": {
"goods_price": {
"type": "number"
},
"order_id": {
"type": "string"
}
}
},
"models.WxNoticeInput": {
"models.WxNoticeInput": {
"type": "object",
"type": "object",
"properties": {
"properties": {
...
@@ -204,7 +252,7 @@ var doc = `{
...
@@ -204,7 +252,7 @@ var doc = `{
"type": "string"
"type": "string"
},
},
"total_amount": {
"total_amount": {
"type": "
string
"
"type": "
number
"
},
},
"trans_merchant_no": {
"trans_merchant_no": {
"type": "string"
"type": "string"
...
...
docs/swagger.json
View file @
af1afef6
...
@@ -44,6 +44,43 @@
...
@@ -44,6 +44,43 @@
}
}
}
}
},
},
"/api/v1/pay/unified_refund"
:
{
"post"
:
{
"description"
:
"拉卡拉退款"
,
"consumes"
:
[
"application/json"
],
"produces"
:
[
"application/json"
],
"tags"
:
[
"拉卡拉退款"
],
"summary"
:
"拉卡拉退款"
,
"parameters"
:
[
{
"description"
:
"参数"
,
"name"
:
"body"
,
"in"
:
"body"
,
"required"
:
true
,
"schema"
:
{
"$ref"
:
"#/definitions/models.RefundParamInput"
}
},
{
"type"
:
"string"
,
"description"
:
"语言类型 zh-CN简体中文 en-US英文 ja 日文 默认中文"
,
"name"
:
"language"
,
"in"
:
"header"
}
],
"responses"
:
{
"200"
:
{
"description"
:
""
}
}
}
},
"/api/v1/pay/wx_notice"
:
{
"/api/v1/pay/wx_notice"
:
{
"post"
:
{
"post"
:
{
"description"
:
"拉卡拉统一支付微信回调"
,
"description"
:
"拉卡拉统一支付微信回调"
,
...
@@ -151,6 +188,17 @@
...
@@ -151,6 +188,17 @@
}
}
}
}
},
},
"models.RefundParamInput"
:
{
"type"
:
"object"
,
"properties"
:
{
"goods_price"
:
{
"type"
:
"number"
},
"order_id"
:
{
"type"
:
"string"
}
}
},
"models.WxNoticeInput"
:
{
"models.WxNoticeInput"
:
{
"type"
:
"object"
,
"type"
:
"object"
,
"properties"
:
{
"properties"
:
{
...
@@ -188,7 +236,7 @@
...
@@ -188,7 +236,7 @@
"type"
:
"string"
"type"
:
"string"
},
},
"total_amount"
:
{
"total_amount"
:
{
"type"
:
"
string
"
"type"
:
"
number
"
},
},
"trans_merchant_no"
:
{
"trans_merchant_no"
:
{
"type"
:
"string"
"type"
:
"string"
...
...
docs/swagger.yaml
View file @
af1afef6
...
@@ -44,6 +44,13 @@ definitions:
...
@@ -44,6 +44,13 @@ definitions:
wap_url
:
wap_url
:
type
:
string
type
:
string
type
:
object
type
:
object
models.RefundParamInput
:
properties
:
goods_price
:
type
:
number
order_id
:
type
:
string
type
:
object
models.WxNoticeInput
:
models.WxNoticeInput
:
properties
:
properties
:
channel_id
:
channel_id
:
...
@@ -69,7 +76,7 @@ definitions:
...
@@ -69,7 +76,7 @@ definitions:
term_no
:
term_no
:
type
:
string
type
:
string
total_amount
:
total_amount
:
type
:
string
type
:
number
trans_merchant_no
:
trans_merchant_no
:
type
:
string
type
:
string
trans_term_no
:
trans_term_no
:
...
@@ -105,6 +112,30 @@ paths:
...
@@ -105,6 +112,30 @@ paths:
summary
:
拉卡拉统一支付
summary
:
拉卡拉统一支付
tags
:
tags
:
-
拉卡拉统一支付
-
拉卡拉统一支付
/api/v1/pay/unified_refund
:
post
:
consumes
:
-
application/json
description
:
拉卡拉退款
parameters
:
-
description
:
参数
in
:
body
name
:
body
required
:
true
schema
:
$ref
:
'
#/definitions/models.RefundParamInput'
-
description
:
语言类型 zh-CN简体中文 en-US英文 ja 日文 默认中文
in
:
header
name
:
language
type
:
string
produces
:
-
application/json
responses
:
"
200"
:
description
:
"
"
summary
:
拉卡拉退款
tags
:
-
拉卡拉退款
/api/v1/pay/wx_notice
:
/api/v1/pay/wx_notice
:
post
:
post
:
consumes
:
consumes
:
...
...
models/notice.go
View file @
af1afef6
...
@@ -2,22 +2,41 @@ package models
...
@@ -2,22 +2,41 @@ package models
// WxNoticeInput 微信回调输入参数
// WxNoticeInput 微信回调输入参数
type
WxNoticeInput
struct
{
type
WxNoticeInput
struct
{
ChannelId
string
`json:"channel_id" description:"平台类型 1: saas 2: shop 3: shop mobile 4: 收银台
"`
ChannelId
string
`json:"channel_id" description:"渠道号
"`
MerchantNo
string
`json:"merchant_no" description:"平台信息
"`
MerchantNo
string
`json:"merchant_no" description:"结算商户号
"`
OrderCreateTime
string
`json:"order_create_time" description:"商品描述
"`
OrderCreateTime
string
`json:"order_create_time" description:"订单创建时间
"`
OrderEfficientTime
string
`json:"order_efficient_time" description:"商品详情
"`
OrderEfficientTime
string
`json:"order_efficient_time" description:"订单有效时间
"`
OrderInfo
string
`json:"order_info" description:"附加信息
"`
OrderInfo
string
`json:"order_info" description:"订单描述
"`
OrderStatus
string
`json:"order_status" description:"商品金额,个位为分
"`
OrderStatus
string
`json:"order_status" description:"订单状态
"`
OutOrderNo
string
`json:"out_order_no" description:"客户端回调的url
"`
OutOrderNo
string
`json:"out_order_no" description:"商户订单号
"`
PayOrderNo
string
`json:"pay_order_no" description:"1: 微信,2: 支付宝, 3: 拉卡拉 4: 收钱吧
"`
PayOrderNo
string
`json:"pay_order_no" description:"支付订单号
"`
TermNo
string
`json:"term_no" description:"1: 微信 Native 2:微信小程序 3:微信内支付 4:h5 跳微信 5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile) 7:alipay(app) 9: B2C 10:bk支付宝web 11:bk 支付宝手机
"`
TermNo
string
`json:"term_no" description:"结算终端号
"`
TotalAmount
float64
`json:"total_amount" description:"此参数 支付类型是 JS API 的时候 必传
"`
TotalAmount
int64
`json:"total_amount" description:"订单金额,单位:分
"`
TransMerchantNo
string
`json:"trans_merchant_no" description:"WAP网站URL地址, 支付方式为微信MWEB时 必传
"`
TransMerchantNo
string
`json:"trans_merchant_no" description:"交易商户号
"`
TransTermNo
string
`json:"trans_term_no" description:"WAP网站名称, 支付方式为微信MWEB时 必传
"`
TransTermNo
string
`json:"trans_term_no" description:"交易终端号
"`
OrderTradeInfo
interface
{}
`json:"order_trade_info" description:""`
OrderTradeInfo
interface
{}
`json:"order_trade_info" description:""`
SplitInfo
interface
{}
`json:"split_info" description:""`
SplitInfo
interface
{}
`json:"split_info" description:""`
}
}
//订单交易信息
//type OrderTradeInfo struct {
// AccTradeNo string `json:"acc_trade_no"`
// AccType string `json:"acc_type"`
// BusiType string `json:"busi_type"`
// LogNo string `json:"log_no"`
// PayMode string `json:"pay_mode"`
// PayerAmount int64 `json:"payer_amount"`
// SettleMerchantNo string `json:"settle_merchant_no"`
// SettleTermNo string `json:"settle_term_no"`
// TradeAmount int64 `json:"trade_amount"`
// TradeNo string `json:"trade_no"`
// TradeStatus string `json:"trade_status"`
// TradeTime string `json:"trade_time"`
// TradeType string `json:"trade_type"`
// UserId1 string `json:"user_id1"`
// UserId2 string `json:"user_id2"`
//}
// CallbackResponse is 回调给业务方的信息
// CallbackResponse is 回调给业务方的信息
type
CallbackResponse
struct
{
type
CallbackResponse
struct
{
OutTradeNo
string
`json:"out_trade_no"`
// 订单号
OutTradeNo
string
`json:"out_trade_no"`
// 订单号
...
...
models/pay.go
View file @
af1afef6
package
models
package
models
//支付
type
PlaceAnOrderParamInput
struct
{
type
PlaceAnOrderParamInput
struct
{
PlatformType
uint8
`json:"platform_type" description:"平台类型 1: saas 2: shop 3: shop mobile 4: 收银台"`
PlatformType
uint8
`json:"platform_type" description:"平台类型 1: saas 2: shop 3: shop mobile 4: 收银台"`
PlatformInfo
string
`json:"platform_info" description:"平台信息"`
PlatformInfo
string
`json:"platform_info" description:"平台信息"`
...
@@ -45,6 +46,12 @@ type PlaceAnOrderParamInput struct {
...
@@ -45,6 +46,12 @@ type PlaceAnOrderParamInput struct {
// return nil
// return nil
//}
//}
//退款
type
RefundParamInput
struct
{
OrderId
string
`json:"order_id" description:"订单号"`
GoodsPrice
float64
`json:"goods_price" description:"商品金额,个位为分"`
}
type
LakalaParamInput
struct
{
type
LakalaParamInput
struct
{
Version
string
`json:"version" description:"版本"`
Version
string
`json:"version" description:"版本"`
ReqTime
string
`json:"req_time" description:"请求时间"`
ReqTime
string
`json:"req_time" description:"请求时间"`
...
@@ -59,7 +66,6 @@ type LakalaParamData struct {
...
@@ -59,7 +66,6 @@ type LakalaParamData struct {
OrderEfficientTime
string
`json:"order_efficient_time" description:"订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天"`
OrderEfficientTime
string
`json:"order_efficient_time" description:"订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天"`
NotifyUrl
string
`json:"notify_url" description:"订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com"`
NotifyUrl
string
`json:"notify_url" description:"订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com"`
CallbackUrl
string
`json:"callback_url" description:"客户端下单完成支付后返回的商户网页跳转地址"`
CallbackUrl
string
`json:"callback_url" description:"客户端下单完成支付后返回的商户网页跳转地址"`
OrderInfo
string
`json:"order_info" description:"订单标题,在使用收银台扫码支付时必输入,交易时送往账户端"`
OrderInfo
string
`json:"order_info" description:"订单标题,在使用收银台扫码支付时必输入,交易时送往账户端"`
GoodsMark
string
`json:"goods_mark" description:"商品信息标识 (1:含商品信息,不填默认不含商品信息)"`
GoodsMark
string
`json:"goods_mark" description:"商品信息标识 (1:含商品信息,不填默认不含商品信息)"`
...
...
repository/pay/notice.go
View file @
af1afef6
...
@@ -52,12 +52,38 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
...
@@ -52,12 +52,38 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
fmt
.
Println
(
"222"
)
fmt
.
Println
(
"222"
)
//if noticeRequest.ReturnCode == "SUCCESS" {
// 把订单状态置为 结算成功
err
=
BillPayStateSuccess
(
tx
,
billID
)
if
err
!=
nil
{
//beego.Error("微信回调, 根据订单id 把订单置为结算成功 失败: ", err)
//response.ReturnCode = "FAIL"
//response.ReturnMsg = "db operation fail"
//return response, nil
response
.
Code
=
"FAIL"
response
.
Message
=
"db operation fail2"
InsertPayBillDetailNoticeResponseBody
(
tx
,
billID
,
response
)
return
response
,
err
}
//} else {
//
// // 把订单状态置为 结算失败
// err = repository.BillPayStateFail(tx, billID)
// if err != nil {
// beego.Error("微信回调, 根据订单id 把订单置为结算成功 失败: ", err)
// response.ReturnCode = "FAIL"
// response.ReturnMsg = "db operation fail"
// return response, nil
// }
//}
//2.存入 notice_request_body
//2.存入 notice_request_body
err
=
InsertPayBillDetailNoticeRequestBody
(
tx
,
billID
,
input
)
err
=
InsertPayBillDetailNoticeRequestBody
(
tx
,
billID
,
input
)
if
err
!=
nil
{
if
err
!=
nil
{
//beego.Error("微信回调, 根据订单id 插入回调Request参数 失败: ", err)
//beego.Error("微信回调, 根据订单id 插入回调Request参数 失败: ", err)
response
.
Code
=
"FAIL"
response
.
Code
=
"FAIL"
response
.
Message
=
"db operation fail
2
"
response
.
Message
=
"db operation fail
3
"
InsertPayBillDetailNoticeResponseBody
(
tx
,
billID
,
response
)
InsertPayBillDetailNoticeResponseBody
(
tx
,
billID
,
response
)
return
response
,
err
return
response
,
err
}
}
...
@@ -66,7 +92,6 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
...
@@ -66,7 +92,6 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
//3.拉卡拉订收银台订单查询 - check todo
//3.拉卡拉订收银台订单查询 - check todo
//3.存入 notice_response_body
//3.存入 notice_response_body
//err = InsertPayBillDetailNoticeResponseBody(billID, response)
//err = InsertPayBillDetailNoticeResponseBody(billID, response)
//if err != nil {
//if err != nil {
...
...
repository/pay/pay.go
View file @
af1afef6
This diff is collapsed.
Click to expand it.
router/v1/pay_router.go
View file @
af1afef6
...
@@ -15,5 +15,8 @@ func PayRouter (r *gin.Engine) {
...
@@ -15,5 +15,8 @@ func PayRouter (r *gin.Engine) {
// 卡拉卡统一支付回调
// 卡拉卡统一支付回调
r
.
POST
(
pack
.
PayUrlPacking
(
"wx_notice"
),
PayController
.
WxNotice
)
r
.
POST
(
pack
.
PayUrlPacking
(
"wx_notice"
),
PayController
.
WxNotice
)
// 卡拉卡统一支付
r
.
POST
(
pack
.
PayUrlPacking
(
"unified_refund"
),
PayController
.
UnifiedRefund
)
}
}
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