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
db77506e
Commit
db77506e
authored
Sep 19, 2023
by
wangp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拉卡拉支付查询开发
parent
84c14c43
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
31 deletions
+38
-31
pay.go
controller/api/v1/pay/pay.go
+0
-6
pay.go
models/pay.go
+5
-0
pay.go
repository/pay/pay.go
+33
-25
No files found.
controller/api/v1/pay/pay.go
View file @
db77506e
...
...
@@ -97,7 +97,6 @@ func (l *PayController) UnifiedRefund(c *gin.Context) {
func
(
l
*
PayController
)
OrderState
(
c
*
gin
.
Context
)
{
ph
:=
new
(
models
.
OrderStateInput
)
//fmt.Println("ContentType="+c.ContentType())
err
:=
c
.
ShouldBindJSON
(
ph
)
if
err
!=
nil
{
zap
.
L
()
.
Error
(
err
.
Error
())
//logs错误日志
...
...
@@ -105,15 +104,10 @@ func (l *PayController) OrderState(c *gin.Context) {
return
}
//// clientIp ip
//ip := c.ClientIP()
////fmt.Println("ip="+ip)
// 拉卡拉支付查询
rtn
,
err
:=
pay
.
OrderState
(
ph
)
if
err
!=
nil
{
zap
.
L
()
.
Error
(
err
.
Error
())
//base.ResponseErrorWithMsg(c, base.ServerError)
base
.
ResponseErrorMsg
(
c
,
err
.
Error
())
return
}
...
...
models/pay.go
View file @
db77506e
...
...
@@ -58,4 +58,9 @@ type LakalaParamData struct {
CallbackUrl
string
`json:"callback_url"`
//客户端下单完成支付后返回的商户网页跳转地址
OrderInfo
string
`json:"order_info"`
//订单标题,在使用收银台扫码支付时必输入,交易时送往账户端
GoodsMark
string
`json:"goods_mark"`
//商品信息标识 (1:含商品信息,不填默认不含商品信息)
}
//订单查询
type
OrderState
struct
{
State
uint8
`json:"state" description:"订单状态 0: 未结算 1: 结算成功 2: 结算失败"`
}
\ No newline at end of file
repository/pay/pay.go
View file @
db77506e
...
...
@@ -602,7 +602,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro
defer
mysql
.
CloseTx
(
tx
,
err
)
//退款订单存在check
log_no
,
trans_term_no
,
source_code
,
platform_type
,
order_create_time
,
err
:=
selectRefundBill
(
tx
,
input
)
log_no
,
trans_term_no
,
source_code
,
platform_type
,
order_create_time
,
payer_account_no
,
err
:=
selectRefundBill
(
tx
,
input
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -723,7 +723,8 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro
//快捷支付(银行卡)
data2
[
"origin_biz_type"
]
=
"4"
//原交易类型:1 银行卡,2 外卡,3 扫码,4 线上
data2
[
"refund_type"
]
=
"00"
//当商户进件时退货模式配置的为 指定模式退货时,该字段有效。00:退货帐户,05:商户余额退货,06:终端余额退货
data2
[
"origin_card_no"
]
=
"621700*********0114"
//原交易银行卡号,银行卡退款必填
//data2["origin_card_no"] = "621700*********0114" todo
data2
[
"origin_card_no"
]
=
payer_account_no
//原交易银行卡号,银行卡退款必填
//data2["origin_trade_no"] = //原交易拉卡拉交易订单号
data2
[
"origin_trade_date"
]
=
order_create_time
//原交易日期:yyyyMMdd
}
...
...
@@ -786,7 +787,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro
}
//退款订单存在check
func
selectRefundBill
(
tx
*
sql
.
Tx
,
input
*
models
.
RefundParamInput
)
(
string
,
string
,
uint8
,
uint8
,
string
,
error
)
{
func
selectRefundBill
(
tx
*
sql
.
Tx
,
input
*
models
.
RefundParamInput
)
(
string
,
string
,
uint8
,
uint8
,
string
,
string
,
error
)
{
var
billID
int64
var
createtime
string
...
...
@@ -795,7 +796,7 @@ func selectRefundBill(tx *sql.Tx, input *models.RefundParamInput) (string, strin
var
source_code
uint8
var
notice_request
interface
{}
var
notice_request2
[]
byte
notice_request2
=
[]
byte
(
`abc`
)
//payment_order_code, paymoney
selectRefundBillSQL
:=
`select b.id, DATE_FORMAT(b.createtime, '%Y%m%d') createtime,
b.result_code, b.source_code, b.platform_type, bd.notice_request_body
...
...
@@ -804,19 +805,19 @@ func selectRefundBill(tx *sql.Tx, input *models.RefundParamInput) (string, strin
where b._type=0 and b.payment_order_code=?`
err
:=
tx
.
QueryRow
(
selectRefundBillSQL
,
input
.
RefundNo
)
.
Scan
(
&
billID
,
&
createtime
,
&
status
,
&
source_code
,
&
platform_type
,
&
notice_request2
)
if
err
!=
nil
{
return
""
,
""
,
0
,
0
,
""
,
err
return
""
,
""
,
0
,
0
,
""
,
""
,
err
}
if
source_code
==
2
||
source_code
==
3
||
source_code
==
9
{
//聚合扫码+聚合被扫
notice_request
=
new
(
models
.
ScanNoticeInput
)
}
else
{
//
其它支付
//
聚合收银台
notice_request
=
new
(
models
.
CashierNoticeInput
)
}
if
err
:=
json
.
Unmarshal
(
notice_request2
,
&
notice_request
);
err
!=
nil
{
return
""
,
""
,
0
,
0
,
""
,
err
return
""
,
""
,
0
,
0
,
""
,
""
,
err
}
//fmt.Println(notice_request2)
...
...
@@ -831,40 +832,42 @@ func selectRefundBill(tx *sql.Tx, input *models.RefundParamInput) (string, strin
// 订单不存在
if
billID
<=
0
{
return
""
,
""
,
0
,
0
,
""
,
errors
.
New
(
"订单不存在2"
)
return
""
,
""
,
0
,
0
,
""
,
""
,
errors
.
New
(
"订单不存在2"
)
}
// 订单未结算
if
status
!=
1
{
return
""
,
""
,
0
,
0
,
""
,
errors
.
New
(
"订单未结算"
)
return
""
,
""
,
0
,
0
,
""
,
""
,
errors
.
New
(
"订单未结算"
)
}
if
source_code
==
0
{
return
""
,
""
,
0
,
0
,
""
,
errors
.
New
(
"「source_code」错误,有效值为[1-6,9,15-17]"
)
return
""
,
""
,
0
,
0
,
""
,
""
,
errors
.
New
(
"「source_code」错误,有效值为[1-6,9,15-17]"
)
}
// 获取「对账单流水号」
和「交易终端
号」,退款用
var
log_no
,
trans_term_no
string
// 获取「对账单流水号」
、「交易终端号」和「付款人账
号」,退款用
var
log_no
,
trans_term_no
,
payer_account_no
string
if
source_code
==
2
||
source_code
==
3
||
source_code
==
9
{
//聚合扫码+聚合被扫
log_no
=
notice_request
.
(
*
models
.
ScanNoticeInput
)
.
LogNo
if
log_no
==
""
{
return
""
,
""
,
0
,
0
,
""
,
errors
.
New
(
"「对账单流水号」未取得错误"
)
return
""
,
""
,
0
,
0
,
""
,
""
,
errors
.
New
(
"「对账单流水号」未取得错误"
)
}
}
else
{
//其它支付
// 针对有的支付,不需要传「交易终端号」时,需要用支付返回的「交易终端号」进行退款
log_no
=
notice_request
.
(
*
models
.
CashierNoticeInput
)
.
OrderTradeInfo
.
(
map
[
string
]
interface
{})[
"log_no"
]
.
(
string
)
if
log_no
==
""
{
return
""
,
""
,
0
,
0
,
""
,
errors
.
New
(
"「对账单流水号」未取得错误"
)
return
""
,
""
,
0
,
0
,
""
,
""
,
errors
.
New
(
"「对账单流水号」未取得错误"
)
}
trans_term_no
=
notice_request
.
(
*
models
.
CashierNoticeInput
)
.
TransTermNo
if
trans_term_no
==
""
{
return
""
,
""
,
0
,
0
,
""
,
errors
.
New
(
"「交易终端号」未取得错误"
)
return
""
,
""
,
0
,
0
,
""
,
""
,
errors
.
New
(
"「交易终端号」未取得错误"
)
}
// 银行卡支付时,获取付款人账号
payer_account_no
=
notice_request
.
(
*
models
.
CashierNoticeInput
)
.
OrderTradeInfo
.
(
map
[
string
]
interface
{})[
"payer_account_no"
]
.
(
string
)
}
return
log_no
,
trans_term_no
,
source_code
,
platform_type
,
createtime
,
nil
return
log_no
,
trans_term_no
,
source_code
,
platform_type
,
createtime
,
payer_account_no
,
nil
}
//InsertRefundBill is 插入 支付订单表中
...
...
@@ -930,10 +933,11 @@ func OrderState(input *models.OrderStateInput) (interface{}, error) {
return
nil
,
fmt
.
Errorf
(
"账单不存在"
)
}
//todo 删除不需要的变量
querySQL
:=
`select id, source_code, result_code, payment_order_code, attach, _type from pay_bill where payment_order_code = ?`
//
result := new(models.OrderState)
var
result_code
uint8
result
:=
new
(
models
.
OrderState
)
//
var result_code uint8
var
sourceCode
uint
var
paymentOrderCode
string
var
attach
string
...
...
@@ -941,23 +945,23 @@ func OrderState(input *models.OrderStateInput) (interface{}, error) {
var
billType
uint8
err
=
db
.
QueryRow
(
querySQL
,
order_id
)
.
Scan
(
&
billID
,
&
sourceCode
,
&
result
_cod
e
,
&
paymentOrderCode
,
&
attach
,
&
billType
)
&
result
.
Stat
e
,
&
paymentOrderCode
,
&
attach
,
&
billType
)
if
err
!=
nil
{
return
nil
,
err
}
// 如果是 未结算成功、并且是收钱吧渠道的账单
if
result
_cod
e
==
0
&&
sourceCode
==
9
{
//todo wangpei
if
result
.
Stat
e
==
0
&&
sourceCode
==
9
{
//todo wangpei
// 查询收钱吧支付是否成功
state
,
err
:=
SqbQueryOrderState
(
tx
,
paymentOrderCode
,
attach
,
billID
,
billType
)
if
err
!=
nil
{
return
nil
,
err
}
result
_cod
e
=
state
result
.
Stat
e
=
state
}
return
result
_code
,
nil
return
result
,
nil
}
//订单状态 0: 未结算 1: 结算成功 2: 结算失败
...
...
@@ -984,11 +988,15 @@ func SqbQueryOrderState(tx *sql.Tx, paymentOrderCode, attach string, billID int6
url
:=
setting
.
Conf
.
Lakala
.
UrlOrderState
//统一退货接口
//todo 参数赋值
merchant_no
:=
""
;
term_no
:=
""
;
//todo 参数赋值
data
:=
make
(
map
[
string
]
interface
{})
//
data["merchant_no"] = merchant_no //商户号
//data["term_no"] = term_no
//终端号
//data["out_trade_no"] = out_trade_no
//商户交易流水号
data
[
"merchant_no"
]
=
merchant_no
//商户号
data
[
"term_no"
]
=
term_no
//终端号
data
[
"out_trade_no"
]
=
paymentOrderCode
//商户交易流水号
//data["trade_no"] = trade_no //拉卡拉交易流水号
data_json
,
err
:=
json
.
Marshal
(
data
)
if
err
!=
nil
{
...
...
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