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
4fa1273d
Commit
4fa1273d
authored
Jun 30, 2023
by
wangp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lakala
parent
da55a1f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
159 additions
and
128 deletions
+159
-128
pay.go
repository/pay/pay.go
+159
-128
No files found.
repository/pay/pay.go
View file @
4fa1273d
...
...
@@ -23,9 +23,9 @@ import (
// 拉卡拉支付
func
UnifiedOrder
(
input
*
models
.
PlaceAnOrderParamInput
,
ip
string
)
(
interface
{},
error
)
{
//if input.ChainCode=="" || input.HospitalCode=="" || input.VendorId=="" || seller_id==""
{
// return nil, errors.New("输入项为空
")
//
}
if
input
.
SourceCode
==
0
{
return
nil
,
errors
.
New
(
"输入项「source_code」为空错误
"
)
}
fmt
.
Println
(
"谛宝多多输入参数"
)
fmt
.
Println
(
input
)
...
...
@@ -61,135 +61,160 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
//数据重组 - start
data
:=
make
(
map
[
string
]
interface
{})
var
url
string
//source_code 1: 微信 Native 2:微信小程序 3:微信内支付 4:h5 跳微信
//5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile) 7:alipay(app)
if
input
.
SourceCode
==
4
||
input
.
SourceCode
==
6
{
//聚合收银台(微信H5、支付宝H5、微信扫码、支付宝扫码)
url
=
"https://test.wsmsd.cn/sit/api/v3/ccss/counter/order/create"
//聚合收银台
//9: B2C 10:bk支付宝web 11:bk 支付宝手机
if
input
.
SourceCode
==
4
||
input
.
SourceCode
==
6
||
input
.
SourceCode
==
1
||
input
.
SourceCode
==
5
{
//聚合收银台(微信H5、支付宝H5、微信扫码、支付宝扫码)
url
=
"https://test.wsmsd.cn/sit/api/v3/ccss/counter/order/create"
//聚合收银台
data
[
"req_time"
]
=
"20230626100000"
data
[
"version"
]
=
"3.0"
data
[
"out_org_code"
]
=
"OP00000003"
//input.ReturnURL = "https://test.pet-dbc.cn"
// 构造回调url
input
.
NoticeURL
=
GetNoticeURL
(
input
.
SourceCode
)
// 传递给支付渠道的
//p.ServeNoticeUrl = noticeURLx
data2
:=
make
(
map
[
string
]
interface
{})
//data2["merchant_no"] = "8222900701107M5"
//data2["merchant_no"] = "8221210701101SB"
//data2["merchant_no"] = "8222900581201QB"
data2
[
"merchant_no"
]
=
"8221210594300JY"
//data2["term_no"] = "29034705" //不需要传?
//data2["total_amount"] = "1"
data2
[
"total_amount"
]
=
input
.
GoodsPrice
*
100
//data2["out_trade_no"] = orderID //随机生成的订单号 //商户交易流水号
//data2["out_trade_no"] = RandomString(32)
data2
[
"out_order_no"
]
=
orderID
//随机生成的订单号 //商户订单号
//data2["out_order_no"] = RandomString(32)
//data2["out_trade_no"] = input.AttachInfo
//data2["out_order_no"] = input.AttachInfo
if
input
.
SourceCode
<
5
{
//微信
data2
[
"counter_param"
]
=
"{
\"
pay_mode
\"
:
\"
WECHAT
\"
}"
}
else
{
//支付宝
data2
[
"counter_param"
]
=
"{
\"
pay_mode
\"
:
\"
ALIPAY
\"
}"
}
data
[
"req_time"
]
=
"20230626100000"
data
[
"version"
]
=
"3.0"
data
[
"out_org_code"
]
=
"OP00000003"
data2
[
"order_efficient_time"
]
=
"20230630235959"
//订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天
data2
[
"notify_url"
]
=
input
.
NoticeURL
//订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com
data2
[
"callback_url"
]
=
input
.
ReturnURL
//客户端下单完成支付后返回的商户网页跳转地址
data2
[
"order_info"
]
=
"必康测试订单标题2"
//订单标题,在使用收银台扫码支付时必输入,交易时送往账户端
//data2["goods_mark"] = input.AttachInfo //商品信息标识 (1:含商品信息,不填默认不含商品信息)
data
[
"req_data"
]
=
make
(
map
[
string
]
interface
{})
data
[
"req_data"
]
=
data2
}
else
if
input
.
SourceCode
==
2
||
input
.
SourceCode
==
3
{
//聚合主扫(微信JSAPI、微信小程序)
url
=
"https://test.wsmsd.cn/sit/api/v3/labs/trans/preorder"
//聚合主扫
data
[
"req_time"
]
=
"20230626100000"
data
[
"version"
]
=
"3.0"
data
[
"out_org_code"
]
=
"OP00000003"
//input.ReturnURL = "https://test.pet-dbc.cn"
// 构造回调url
input
.
NoticeURL
=
GetNoticeURL
(
input
.
SourceCode
)
// 传递给支付渠道的
//p.ServeNoticeUrl = noticeURL
data2
:=
make
(
map
[
string
]
interface
{})
//data2["merchant_no"] = "8222900701107M5"
//data2["term_no"] = "A1062976"
//data2["merchant_no"] = "8221210701101SB"
data2
[
"merchant_no"
]
=
"8222900581201QB"
data2
[
"term_no"
]
=
"D0027598"
//tempMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", p.GoodsPrice*100), 64)
data2
[
"total_amount"
]
=
input
.
GoodsPrice
*
100
data2
[
"out_trade_no"
]
=
orderID
//随机生成的订单号 //商户交易流水号
data2
[
"order_efficient_time"
]
=
"20230630235959"
//订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天
data2
[
"notify_url"
]
=
input
.
NoticeURL
//订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com
data2
[
"callback_url"
]
=
input
.
ReturnURL
//客户端下单完成支付后返回的商户网页跳转地址
data2
[
"order_info"
]
=
"必康测试订单标题2"
//订单标题,在使用收银台扫码支付时必输入,交易时送往账户端
//data2["goods_mark"] = input.AttachInfo //商品信息标识 (1:含商品信息,不填默认不含商品信息)
if
input
.
SourceCode
==
1
{
//微信native
data2
[
"counter_param"
]
=
"{
\"
pay_mode
\"
:
\"
WECHAT
\"
}"
data2
[
"account_type"
]
=
"WECHAT"
//钱包类型
data2
[
"trans_type"
]
=
"41"
//接入方式
}
else
if
input
.
SourceCode
==
5
{
//支付宝native
data2
[
"counter_param"
]
=
"{
\"
pay_mode
\"
:
\"
ALIPAY
\"
}"
data2
[
"account_type"
]
=
"ALIPAY"
//钱包类型
data2
[
"trans_type"
]
=
"41"
//接入方式
}
else
{
//微信JSAPI、微信小程序
data2
[
"counter_param"
]
=
"{
\"
pay_mode
\"
:
\"
WECHAT
\"
}"
data2
[
"account_type"
]
=
"WECHAT"
//钱包类型
data2
[
"trans_type"
]
=
"51"
//接入方式
}
//input.ReturnURL = "https://test.pet-dbc.cn"
//地址位置信息
data3
:=
make
(
map
[
string
]
interface
{})
data3
[
"request_ip"
]
=
ip
data2
[
"location_info"
]
=
make
(
map
[
string
]
interface
{})
data2
[
"location_info"
]
=
data3
// 构造回调url
input
.
NoticeURL
=
GetNoticeURL
(
input
.
SourceCode
)
// 传递给支付渠道的
//p.ServeNoticeUrl = noticeURLx
//地址位置信息
data4
:=
make
(
map
[
string
]
interface
{})
//data4["open_id"] = input.OpenID //此参数 支付类型是 JS API 的时候 必传
data2
:=
make
(
map
[
string
]
interface
{})
//data2["merchant_no"] = "8222900701107M5"
data2
[
"merchant_no"
]
=
"8221210701101SB"
//data2["term_no"] = "29034705" //不需要传?
//data2["total_amount"] = "1"
data2
[
"total_amount"
]
=
input
.
GoodsPrice
*
100
//data2["out_trade_no"] = orderID //随机生成的订单号 //商户交易流水号
//data2["out_trade_no"] = RandomString(32)
data2
[
"out_order_no"
]
=
orderID
//随机生成的订单号 //商户订单号
//data2["out_order_no"] = RandomString(32)
//data2["out_trade_no"] = input.AttachInfo
//data2["out_order_no"] = input.AttachInfo
if
input
.
SourceCode
<
5
{
//微信
data2
[
"counter_param"
]
=
"{
\"
pay_mode
\"
:
\"
WECHAT
\"
}"
}
else
{
//支付宝
data2
[
"counter_param"
]
=
"{
\"
pay_mode
\"
:
\"
ALIPAY
\"
}"
}
data4
[
"sub_appid"
]
=
"wxc3e4d1682da3053c"
data4
[
"user_id"
]
=
"oLvoQ5deygCMj2WrDjPVPvV1L1t8"
data2
[
"order_efficient_time"
]
=
"20230630235959"
//订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天
data2
[
"notify_url"
]
=
input
.
NoticeURL
//订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com
data2
[
"callback_url"
]
=
input
.
ReturnURL
//客户端下单完成支付后返回的商户网页跳转地址
data2
[
"order_info"
]
=
"必康测试订单标题2"
//订单标题,在使用收银台扫码支付时必输入,交易时送往账户端
//data2["goods_mark"] = input.AttachInfo //商品信息标识 (1:含商品信息,不填默认不含商品信息)
data2
[
"acc_busi_fields"
]
=
make
(
map
[
string
]
interface
{})
data2
[
"acc_busi_fields"
]
=
data4
data
[
"req_data"
]
=
make
(
map
[
string
]
interface
{})
data
[
"req_data"
]
=
data2
data
[
"req_data"
]
=
make
(
map
[
string
]
interface
{})
data
[
"req_data"
]
=
data2
}
else
if
input
.
SourceCode
==
2
||
input
.
SourceCode
==
3
||
input
.
SourceCode
==
1
||
input
.
SourceCode
==
5
{
//聚合主扫(微信JSAPI、微信小程序)
url
=
"https://test.wsmsd.cn/sit/api/v3/labs/trans/preorder"
//聚合主扫
}
else
if
input
.
SourceCode
==
9
{
//收钱吧(扫码枪)
if
input
.
DynamicID
==
""
{
return
nil
,
errors
.
New
(
"输入项「dynamic_id」为空错误"
)
}
data
[
"req_time"
]
=
"20230626100000"
data
[
"version"
]
=
"3.0"
data
[
"out_org_code"
]
=
"OP00000003"
url
=
"https://test.wsmsd.cn/sit/api/v3/labs/trans/micropay"
//聚合被扫
//input.ReturnURL = "https://test.pet-dbc.cn"
data
[
"req_time"
]
=
"20220714160009"
data
[
"version"
]
=
"3.0"
data
[
"out_org_code"
]
=
"OP00000003"
// 构造回调url
input
.
NoticeURL
=
GetNoticeURL
(
input
.
SourceCode
)
// 传递给支付渠道的
//p.ServeNoticeUrl = noticeURLx
data2
:=
make
(
map
[
string
]
interface
{})
data2
[
"merchant_no"
]
=
"822290070111135"
data2
[
"term_no"
]
=
"29034705"
data2
[
"out_trade_no"
]
=
orderID
//随机生成的订单号 //商户交易流水号
//data2["out_trade_no"] = RandomString(32)
//扫码支付授权码,设备读取用户APP中的条码或者二维码信息,用户付款码条形码规则见说明
//data2["auth_code"] = "135178236713755038"
data2
[
"auth_code"
]
=
input
.
DynamicID
data2
[
"total_amount"
]
=
input
.
GoodsPrice
*
100
data2
:=
make
(
map
[
string
]
interface
{})
//data2["merchant_no"] = "8222900701107M5"
//data2["term_no"] = "A1062976"
//data2["merchant_no"] = "8221210701101SB"
data2
[
"merchant_no"
]
=
"8222900581201QB"
data2
[
"term_no"
]
=
"D0027598"
//data2["total_amount"] = "1"
//tempMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", p.GoodsPrice*100), 64)
data2
[
"total_amount"
]
=
input
.
GoodsPrice
*
100
data2
[
"out_trade_no"
]
=
orderID
//随机生成的订单号 //商户交易流水号
//data2["out_trade_no"] = RandomString(32)
//data2["out_order_no"] = orderID //随机生成的订单号 //商户订单号
//data2["out_order_no"] = RandomString(32)
//data2["out_trade_no"] = input.AttachInfo
//data2["out_order_no"] = input.AttachInfo
data2
[
"order_efficient_time"
]
=
"20230630235959"
//订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天
data2
[
"notify_url"
]
=
input
.
NoticeURL
//订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com
data2
[
"callback_url"
]
=
input
.
ReturnURL
//客户端下单完成支付后返回的商户网页跳转地址
data2
[
"order_info"
]
=
"必康测试订单标题2"
//订单标题,在使用收银台扫码支付时必输入,交易时送往账户端
//data2["goods_mark"] = input.AttachInfo //商品信息标识 (1:含商品信息,不填默认不含商品信息)
data3
:=
make
(
map
[
string
]
interface
{})
//data3["request_ip"] = "10.176.1.192"
data3
[
"request_ip"
]
=
ip
//data3["location"] = "+37.123456789,-121.123456789"
data2
[
"location_info"
]
=
make
(
map
[
string
]
interface
{})
data2
[
"location_info"
]
=
data3
data
[
"req_data"
]
=
make
(
map
[
string
]
interface
{})
data
[
"req_data"
]
=
data2
if
input
.
SourceCode
==
1
{
//微信native
data2
[
"counter_param"
]
=
"{
\"
pay_mode
\"
:
\"
WECHAT
\"
}"
data2
[
"account_type"
]
=
"WECHAT"
//钱包类型
data2
[
"trans_type"
]
=
"41"
//接入方式
}
else
if
input
.
SourceCode
==
5
{
//支付宝native
data2
[
"counter_param"
]
=
"{
\"
pay_mode
\"
:
\"
ALIPAY
\"
}"
data2
[
"account_type"
]
=
"ALIPAY"
//钱包类型
data2
[
"trans_type"
]
=
"41"
//接入方式
}
else
{
//微信JSAPI、微信小程序
data2
[
"counter_param"
]
=
"{
\"
pay_mode
\"
:
\"
WECHAT
\"
}"
data2
[
"account_type"
]
=
"WECHAT"
//钱包类型
data2
[
"trans_type"
]
=
"51"
//接入方式
return
nil
,
errors
.
New
(
"输入参数「source_code」错误,有效值为[1-6,9]"
)
}
//地址位置信息
data3
:=
make
(
map
[
string
]
interface
{})
data3
[
"request_ip"
]
=
ip
data2
[
"location_info"
]
=
make
(
map
[
string
]
interface
{})
data2
[
"location_info"
]
=
data3
//地址位置信息
data4
:=
make
(
map
[
string
]
interface
{})
//data4["open_id"] = input.OpenID //此参数 支付类型是 JS API 的时候 必传
data4
[
"sub_appid"
]
=
"wxc3e4d1682da3053c"
data4
[
"user_id"
]
=
"oLvoQ5deygCMj2WrDjPVPvV1L1t8"
data2
[
"acc_busi_fields"
]
=
make
(
map
[
string
]
interface
{})
data2
[
"acc_busi_fields"
]
=
data4
data
[
"req_data"
]
=
make
(
map
[
string
]
interface
{})
data
[
"req_data"
]
=
data2
}
else
{
return
nil
,
errors
.
New
(
"输入参数「source_code」错误"
)
}
//数据重组 - end
fmt
.
Println
(
"拉卡拉输入参数"
)
fmt
.
Println
(
data
)
...
...
@@ -209,10 +234,6 @@ if input.SourceCode==4 || input.SourceCode==6 {
return
nil
,
err
}
//url := "https://test.wsmsd.cn/sit/api/v3/labs/trans/preorder" //聚合主扫
//url := "https://test.wsmsd.cn/sit/api/v3/labs/trans/micropay" //聚合被扫
//url := "https://test.wsmsd.cn/sit/api/v3/ccss/counter/order/create" //聚合收银台
//调拉卡拉接口
err
,
response
,
lakala_rtn
:=
lakala_post
(
input
.
SourceCode
,
url
,
data_json
)
if
err
!=
nil
{
...
...
@@ -220,9 +241,6 @@ if input.SourceCode==4 || input.SourceCode==6 {
return
nil
,
err
}
//response := make(map[string]string)
//response["m_web_url"] = m_web_url
// 插入下单成功后返回的参数
err
=
InsertPayBillDetailResponseBody
(
tx
,
billID
,
lakala_rtn
)
if
err
!=
nil
{
...
...
@@ -230,10 +248,16 @@ if input.SourceCode==4 || input.SourceCode==6 {
return
nil
,
err
}
if
input
.
SourceCode
==
9
{
//收钱吧(扫码枪)
response
:=
make
(
map
[
string
]
string
)
response
[
"payment_order_code"
]
=
orderID
//随机生成的订单号
return
response
,
nil
}
return
response
,
nil
}
func
lakala_post
(
source_code
uint8
,
url
string
,
data_json
[]
byte
)
(
error
,
interface
{},
interface
{})
{
authorization
,
err
:=
getAuthorization
(
string
(
data_json
))
if
err
!=
nil
{
...
...
@@ -277,15 +301,21 @@ func lakala_post(source_code uint8, url string, data_json []byte) (error, interf
if
temp2
[
"counter_url"
]
==
""
{
return
errors
.
New
(
"拉卡拉返回值「counter_url」为空错误"
),
""
,
temp
}
response
[
"m_web_url"
]
=
temp2
[
"counter_url"
]
.
(
string
)
if
source_code
==
4
||
source_code
==
6
{
//微信H5、支付宝H5
response
[
"m_web_url"
]
=
temp2
[
"counter_url"
]
.
(
string
)
}
else
{
//微信扫码、支付宝扫码
response
[
"qr_code_url"
]
=
temp2
[
"counter_url"
]
.
(
string
)
}
}
else
if
source_code
==
2
||
source_code
==
3
{
//聚合主扫(微信JSAPI+微信小程序)
temp2
,
_
:=
temp
[
"resp_data"
]
.
(
map
[
string
]
interface
{})
temp3
,
_
:=
temp2
[
"acc_resp_fields"
]
.
(
map
[
string
]
interface
{})
//if temp3["counter_url
"]=="" {
// return errors.New("拉卡拉返回值「counter_url
」为空错误"), "", temp
//
}
if
temp2
[
"acc_resp_fields
"
]
==
""
{
return
errors
.
New
(
"拉卡拉返回值「acc_resp_fields
」为空错误"
),
""
,
temp
}
response
[
"app_id"
]
=
temp3
[
"app_id"
]
.
(
string
)
response
[
"nonce_str"
]
=
temp3
[
"nonce_str"
]
.
(
string
)
response
[
"package"
]
=
temp3
[
"package"
]
.
(
string
)
...
...
@@ -293,6 +323,7 @@ func lakala_post(source_code uint8, url string, data_json []byte) (error, interf
response
[
"prepay_id"
]
=
temp3
[
"prepay_id"
]
.
(
string
)
response
[
"sign_type"
]
=
temp3
[
"sign_type"
]
.
(
string
)
response
[
"timeStamp"
]
=
temp3
[
"time_stamp"
]
.
(
string
)
}
else
{
return
errors
.
New
(
"输入参数「source_code」错误"
),
""
,
temp
}
...
...
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