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
4bacb07d
Commit
4bacb07d
authored
Jun 27, 2023
by
wangp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lakala
parent
13ef1742
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
100 additions
and
110 deletions
+100
-110
config.yaml
conf/dev/config.yaml
+2
-1
config.yaml
conf/prod/config.yaml
+2
-1
mysql.go
mysql/mysql.go
+52
-20
notice.go
repository/pay/notice.go
+7
-18
pay.go
repository/pay/pay.go
+16
-47
setting.go
setting/setting.go
+1
-0
mysql.go
utils/mysql.go
+20
-23
No files found.
conf/dev/config.yaml
View file @
4bacb07d
...
@@ -15,7 +15,8 @@ app:
...
@@ -15,7 +15,8 @@ app:
database
:
database
:
type
:
'
mysql'
type
:
'
mysql'
#crmdb: "root:abc123456@tcp(39.96.85.45:3307)/dbc_crm_manage?charset=utf8"
#crmdb: "root:abc123456@tcp(39.96.85.45:3307)/dbc_crm_manage?charset=utf8"
shopdb
:
"
root:abc123456@tcp(39.96.85.45:3307)/dbc_shop?charset=utf8"
#shopdb: "root:abc123456@tcp(39.96.85.45:3307)/dbc_shop?charset=utf8"
systemdb
:
"
root:abc123456@tcp(39.96.85.45:3307)/sys_pay?charset=utf8"
#accountdb: 'dbc_saas:dbc_saas888888@tcp(rm-2zepcf8kag0aol0q48o.mysql.rds.aliyuncs.com:3306)/hos_database?charset=utf8'
#accountdb: 'dbc_saas:dbc_saas888888@tcp(rm-2zepcf8kag0aol0q48o.mysql.rds.aliyuncs.com:3306)/hos_database?charset=utf8'
#userdb: 'root_dbc:dbc_root888888@tcp(rm-2ze8jnj44l6ta299pro.mysql.rds.aliyuncs.com:3306)/mysql?charset=utf8'
#userdb: 'root_dbc:dbc_root888888@tcp(rm-2ze8jnj44l6ta299pro.mysql.rds.aliyuncs.com:3306)/mysql?charset=utf8'
#seconddb: 'root_dbc:dbc_root888888@tcp(rm-2ze095l91j14r251wno.mysql.rds.aliyuncs.com:3306)/mysql?charset=utf8'
#seconddb: 'root_dbc:dbc_root888888@tcp(rm-2ze095l91j14r251wno.mysql.rds.aliyuncs.com:3306)/mysql?charset=utf8'
...
...
conf/prod/config.yaml
View file @
4bacb07d
...
@@ -15,7 +15,8 @@ app:
...
@@ -15,7 +15,8 @@ app:
database
:
database
:
type
:
'
mysql'
type
:
'
mysql'
#crmdb: "root_shop:DBC_shopqwe@tcp(rm-2zenl1z0v6209a4jrbo.mysql.rds.aliyuncs.com:3306)/dbc_crm_manage?charset=utf8"
#crmdb: "root_shop:DBC_shopqwe@tcp(rm-2zenl1z0v6209a4jrbo.mysql.rds.aliyuncs.com:3306)/dbc_crm_manage?charset=utf8"
shopdb
:
"
root_shop:DBC_shopqwe@tcp(rm-2zenl1z0v6209a4jrbo.mysql.rds.aliyuncs.com:3306)/dbc_shop?charset=utf8"
# shopdb: "root_shop:DBC_shopqwe@tcp(rm-2zenl1z0v6209a4jrbo.mysql.rds.aliyuncs.com:3306)/dbc_shop?charset=utf8"
systemdb
:
"
system_pay:Pay_123456@tcp(rm-2zenl1z0v6209a4jrbo.mysql.rds.aliyuncs.com:3306)/sys_pay?charset=utf8"
# accountdb: 'dbc_saas:dbc_saas888888@tcp(rm-2zepcf8kag0aol0q48o.mysql.rds.aliyuncs.com:3306)/hos_database?charset=utf8'
# accountdb: 'dbc_saas:dbc_saas888888@tcp(rm-2zepcf8kag0aol0q48o.mysql.rds.aliyuncs.com:3306)/hos_database?charset=utf8'
# userdb: 'root_dbc:dbc_root888888@tcp(rm-2ze8jnj44l6ta299pro.mysql.rds.aliyuncs.com:3306)/mysql?charset=utf8'
# userdb: 'root_dbc:dbc_root888888@tcp(rm-2ze8jnj44l6ta299pro.mysql.rds.aliyuncs.com:3306)/mysql?charset=utf8'
# seconddb: 'root_dbc:dbc_root888888@tcp(rm-2ze095l91j14r251wno.mysql.rds.aliyuncs.com:3306)/mysql?charset=utf8'
# seconddb: 'root_dbc:dbc_root888888@tcp(rm-2ze095l91j14r251wno.mysql.rds.aliyuncs.com:3306)/mysql?charset=utf8'
...
...
mysql/mysql.go
View file @
4bacb07d
package
mysql
package
mysql
import
(
import
(
"database/sql"
_
"github.com/go-sql-driver/mysql"
_
"github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
"system_pay/setting"
"system_pay/setting"
)
)
//var (
// shopDB *sqlx.DB
// //db *sqlx.DB
// // 0 ~ h
// //userDB *sqlx.DB
// // i ~ z
// //secondDB *sqlx.DB
// // PayDB 支付
// //payDB *sqlx.DB
// err error
//)
// NewShopConn is 连接谛宝多多库
//func NewShopConn() (*sqlx.DB, error) {
// if shopDB == nil {
// shopDB, err = sqlx.Connect("mysql", setting.Conf.DatabaseSetting.ShopDB)
// return shopDB, err
// }
// //shopDB.SetMaxOpenConns(setting.Conf.DatabaseSetting.MaxOpenConns)
// return shopDB, err
//}
//
//// ShopDBClose 关闭MySQL连接
//func ShopDBClose() {
// _ = shopDB.Close()
//}
var
(
var
(
shopDB
*
sqlx
.
DB
systemdb
*
sql
.
DB
//db *sqlx.DB
err
error
// 0 ~ h
//userDB *sqlx.DB
// i ~ z
//secondDB *sqlx.DB
// PayDB 支付
//payDB *sqlx.DB
err
error
)
)
// NewShopConn is 连接谛宝多多库
// NewPayConn is 连接支付库
func
NewShopConn
()
(
*
sqlx
.
DB
,
error
)
{
func
NewPayConn
()
(
*
sql
.
DB
,
error
)
{
if
shopDB
==
nil
{
if
systemdb
==
nil
{
shopDB
,
err
=
sqlx
.
Connect
(
"mysql"
,
setting
.
Conf
.
DatabaseSetting
.
ShopDB
)
//systemdb, err = sql.Open("mysql", beego.AppConfig.String("PayURL"))
return
shopDB
,
err
systemdb
,
err
=
sql
.
Open
(
"mysql"
,
setting
.
Conf
.
DatabaseSetting
.
SystemDB
)
//systemdb, err = sqlx.Connect("mysql", setting.Conf.DatabaseSetting.SystemDB)
return
systemdb
,
err
}
}
//shopDB.SetMaxOpenConns(setting.Conf.DatabaseSetting.MaxOpenConns)
return
systemdb
,
nil
return
shopDB
,
err
}
}
// ShopDBClose 关闭MySQL连接
// CloseTx is 有错误则关闭事务、没错则提交事务
func
ShopDBClose
()
{
func
CloseTx
(
tx
*
sql
.
Tx
,
err
error
)
{
_
=
shopDB
.
Close
()
if
err
!=
nil
{
tx
.
Rollback
()
}
tx
.
Commit
()
}
}
// NewAccountConn is 连接医院用户库
// NewAccountConn is 连接医院用户库
//func NewAccountConn() (*sqlx.DB, error) {
//func NewAccountConn() (*sqlx.DB, error) {
// if db == nil {
// if db == nil {
...
...
repository/pay/notice.go
View file @
4bacb07d
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
"system_pay/controller/base"
"system_pay/controller/base"
"system_pay/models"
"system_pay/models"
"system_pay/mysql"
"system_pay/mysql"
"system_pay/utils"
)
)
// 拉卡拉微信支付回调 - AliPayNotice
// 拉卡拉微信支付回调 - AliPayNotice
...
@@ -27,7 +26,7 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
...
@@ -27,7 +26,7 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
//}
//}
// 插入数据库
// 插入数据库
db
,
err
:=
utils
.
NewPayConn
()
db
,
err
:=
mysql
.
NewPayConn
()
if
err
!=
nil
{
if
err
!=
nil
{
return
response
,
err
return
response
,
err
}
}
...
@@ -37,14 +36,14 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
...
@@ -37,14 +36,14 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
return
response
,
err
return
response
,
err
}
}
defer
utils
.
CloseTx
(
tx
,
err
)
defer
mysql
.
CloseTx
(
tx
,
err
)
fmt
.
Println
(
"111"
)
fmt
.
Println
(
"111"
)
//1.订单存在check
//1.订单存在check
var
billID
int64
var
billID
int64
var
attach
,
url
string
var
attach
,
url
string
err
=
db
.
QueryRow
(
"select ifnull(id, 0), attach, notify_pay_url from pay_bill where payment_order_code = ?"
,
err
=
db
.
QueryRow
(
"select ifnull(id, 0), attach, notify_pay_url from
system_
pay_bill where payment_order_code = ?"
,
input
.
OutOrderNo
)
.
Scan
(
&
billID
,
&
attach
,
&
url
)
input
.
OutOrderNo
)
.
Scan
(
&
billID
,
&
attach
,
&
url
)
if
err
!=
nil
||
billID
==
0
||
billID
==
2
{
if
err
!=
nil
||
billID
==
0
||
billID
==
2
{
response
.
Code
=
"FAIL"
response
.
Code
=
"FAIL"
...
@@ -118,17 +117,12 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
...
@@ -118,17 +117,12 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
// InsertPayBillDetailNoticeRequestBody is 插入支付订单详情表中的 下单参数字段 notice_request_body
// InsertPayBillDetailNoticeRequestBody is 插入支付订单详情表中的 下单参数字段 notice_request_body
func
InsertPayBillDetailNoticeRequestBody
(
tx
*
sql
.
Tx
,
billID
int64
,
noticeRequestBody
interface
{})
error
{
func
InsertPayBillDetailNoticeRequestBody
(
tx
*
sql
.
Tx
,
billID
int64
,
noticeRequestBody
interface
{})
error
{
db
,
err
:=
mysql
.
NewShopConn
()
if
err
!=
nil
{
return
err
}
body
,
err
:=
json
.
Marshal
(
noticeRequestBody
)
body
,
err
:=
json
.
Marshal
(
noticeRequestBody
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
insertPayBillDetailSQL
:=
`update pay_bill_detail set notice_request_body = ? where pay_bill_id = ?`
insertPayBillDetailSQL
:=
`update
system_
pay_bill_detail set notice_request_body = ? where pay_bill_id = ?`
result
,
err
:=
db
.
Exec
(
insertPayBillDetailSQL
,
string
(
body
),
billID
)
result
,
err
:=
tx
.
Exec
(
insertPayBillDetailSQL
,
string
(
body
),
billID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -143,17 +137,12 @@ func InsertPayBillDetailNoticeRequestBody(tx *sql.Tx, billID int64, noticeReques
...
@@ -143,17 +137,12 @@ func InsertPayBillDetailNoticeRequestBody(tx *sql.Tx, billID int64, noticeReques
// InsertPayBillDetailNoticeResponseBody is 插入支付订单详情表中的 下单参数字段 notice_response_body
// InsertPayBillDetailNoticeResponseBody is 插入支付订单详情表中的 下单参数字段 notice_response_body
func
InsertPayBillDetailNoticeResponseBody
(
tx
*
sql
.
Tx
,
billID
int64
,
noticeResponseBody
interface
{})
error
{
func
InsertPayBillDetailNoticeResponseBody
(
tx
*
sql
.
Tx
,
billID
int64
,
noticeResponseBody
interface
{})
error
{
db
,
err
:=
mysql
.
NewShopConn
()
if
err
!=
nil
{
return
err
}
body
,
err
:=
json
.
Marshal
(
noticeResponseBody
)
body
,
err
:=
json
.
Marshal
(
noticeResponseBody
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
insertPayBillDetailSQL
:=
`update pay_bill_detail set notice_response_body = ? where pay_bill_id = ?`
insertPayBillDetailSQL
:=
`update
system_
pay_bill_detail set notice_response_body = ? where pay_bill_id = ?`
result
,
err
:=
db
.
Exec
(
insertPayBillDetailSQL
,
string
(
body
),
billID
)
result
,
err
:=
tx
.
Exec
(
insertPayBillDetailSQL
,
string
(
body
),
billID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
repository/pay/pay.go
View file @
4bacb07d
...
@@ -19,7 +19,6 @@ import (
...
@@ -19,7 +19,6 @@ import (
"strings"
"strings"
"system_pay/models"
"system_pay/models"
"system_pay/mysql"
"system_pay/mysql"
"system_pay/utils"
"time"
"time"
)
)
...
@@ -51,7 +50,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput) (interface{}, error) {
...
@@ -51,7 +50,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput) (interface{}, error) {
input
.
AttachInfo
=
string
(
attach
)
input
.
AttachInfo
=
string
(
attach
)
// 插入数据库
// 插入数据库
db
,
err
:=
utils
.
NewPayConn
()
db
,
err
:=
mysql
.
NewPayConn
()
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
...
@@ -61,7 +60,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput) (interface{}, error) {
...
@@ -61,7 +60,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput) (interface{}, error) {
return
nil
,
err
return
nil
,
err
}
}
defer
utils
.
CloseTx
(
tx
,
err
)
defer
mysql
.
CloseTx
(
tx
,
err
)
billID
,
err
:=
InsertPayBill
(
tx
,
input
,
orderID
)
billID
,
err
:=
InsertPayBill
(
tx
,
input
,
orderID
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -595,15 +594,10 @@ func GetNoticeURL(sourceCode uint8) string {
...
@@ -595,15 +594,10 @@ func GetNoticeURL(sourceCode uint8) string {
// BillPayStateSuccess is 微信回调后 把订单状态 置为结算成功
// BillPayStateSuccess is 微信回调后 把订单状态 置为结算成功
func
BillPayStateSuccess
(
billID
int64
)
error
{
func
BillPayStateSuccess
(
tx
*
sql
.
Tx
,
billID
int64
)
error
{
db
,
err
:=
mysql
.
NewShopConn
()
insertPayBillDetailSQL
:=
`update system_pay_bill set result_code = 1 where id = ?`
if
err
!=
nil
{
result
,
err
:=
tx
.
Exec
(
insertPayBillDetailSQL
,
billID
)
return
err
}
insertPayBillDetailSQL
:=
`update pay_bill set result_code = 1 where id = ?`
result
,
err
:=
db
.
Exec
(
insertPayBillDetailSQL
,
billID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -616,15 +610,10 @@ func BillPayStateSuccess(billID int64) error {
...
@@ -616,15 +610,10 @@ func BillPayStateSuccess(billID int64) error {
}
}
// BillPayStateFail is 微信回调后 把订单状态 置为结算失败
// BillPayStateFail is 微信回调后 把订单状态 置为结算失败
func
BillPayStateFail
(
billID
int64
)
error
{
func
BillPayStateFail
(
tx
*
sql
.
Tx
,
billID
int64
)
error
{
db
,
err
:=
mysql
.
NewShopConn
()
if
err
!=
nil
{
return
err
}
insertPayBillDetailSQL
:=
`update pay_bill set result_code = 2 where id = ?`
insertPayBillDetailSQL
:=
`update
system_
pay_bill set result_code = 2 where id = ?`
result
,
err
:=
db
.
Exec
(
insertPayBillDetailSQL
,
billID
)
result
,
err
:=
tx
.
Exec
(
insertPayBillDetailSQL
,
billID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -641,18 +630,13 @@ func BillPayStateFail(billID int64) error {
...
@@ -641,18 +630,13 @@ func BillPayStateFail(billID int64) error {
//InsertPayBill is 插入 支付订单表中
//InsertPayBill is 插入 支付订单表中
func
InsertPayBill
(
tx
*
sql
.
Tx
,
p
*
models
.
PlaceAnOrderParamInput
,
orderID
string
)
(
int64
,
error
)
{
func
InsertPayBill
(
tx
*
sql
.
Tx
,
p
*
models
.
PlaceAnOrderParamInput
,
orderID
string
)
(
int64
,
error
)
{
db
,
err
:=
mysql
.
NewShopConn
()
if
err
!=
nil
{
return
0
,
err
}
var
billID
int64
var
billID
int64
insertSQL
:=
`insert pay_bill set platform_type = ?, platform_info = ?,
insertSQL
:=
`insert
system_
pay_bill set platform_type = ?, platform_info = ?,
source_code = ?, payment_order_code = ?, paymoney = ?*1000, commodity_describe = ?,
source_code = ?, payment_order_code = ?, paymoney = ?*1000, commodity_describe = ?,
commodity_detail = ?, attach = ?, notify_pay_url = ?, pay_type = ?, is_serve = ?`
commodity_detail = ?, attach = ?, notify_pay_url = ?, pay_type = ?, is_serve = ?`
result
,
err
:=
db
.
Exec
(
insertSQL
,
p
.
PlatformType
,
p
.
PlatformInfo
,
p
.
SourceCode
,
result
,
err
:=
tx
.
Exec
(
insertSQL
,
p
.
PlatformType
,
p
.
PlatformInfo
,
p
.
SourceCode
,
orderID
,
p
.
GoodsPrice
,
p
.
GoodsDes
,
p
.
GoodsDetail
,
p
.
AttachInfo
,
p
.
NoticeURL
,
p
.
PayType
,
p
.
IsServe
)
orderID
,
p
.
GoodsPrice
,
p
.
GoodsDes
,
p
.
GoodsDetail
,
p
.
AttachInfo
,
p
.
NoticeURL
,
p
.
PayType
,
p
.
IsServe
)
if
err
!=
nil
{
if
err
!=
nil
{
return
billID
,
err
return
billID
,
err
...
@@ -668,17 +652,12 @@ commodity_detail = ?, attach = ?, notify_pay_url = ?, pay_type = ?, is_serve = ?
...
@@ -668,17 +652,12 @@ commodity_detail = ?, attach = ?, notify_pay_url = ?, pay_type = ?, is_serve = ?
// InsertPayBillDetailRequestBody is 插入支付订单详情表中的 下单参数字段 request_body
// InsertPayBillDetailRequestBody is 插入支付订单详情表中的 下单参数字段 request_body
func
InsertPayBillDetailRequestBody
(
tx
*
sql
.
Tx
,
billID
int64
,
requestBody
interface
{})
error
{
func
InsertPayBillDetailRequestBody
(
tx
*
sql
.
Tx
,
billID
int64
,
requestBody
interface
{})
error
{
db
,
err
:=
mysql
.
NewShopConn
()
if
err
!=
nil
{
return
err
}
body
,
err
:=
json
.
Marshal
(
requestBody
)
body
,
err
:=
json
.
Marshal
(
requestBody
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
insertPayBillDetailSQL
:=
`insert pay_bill_detail set pay_bill_id = ?, request_body = ?`
insertPayBillDetailSQL
:=
`insert
system_
pay_bill_detail set pay_bill_id = ?, request_body = ?`
result
,
err
:=
db
.
Exec
(
insertPayBillDetailSQL
,
billID
,
string
(
body
))
result
,
err
:=
tx
.
Exec
(
insertPayBillDetailSQL
,
billID
,
string
(
body
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -693,17 +672,12 @@ func InsertPayBillDetailRequestBody(tx *sql.Tx, billID int64, requestBody interf
...
@@ -693,17 +672,12 @@ func InsertPayBillDetailRequestBody(tx *sql.Tx, billID int64, requestBody interf
// InsertPayBillDetailResponseBody is 插入支付订单详情表中的 下单参数字段 response_body
// InsertPayBillDetailResponseBody is 插入支付订单详情表中的 下单参数字段 response_body
func
InsertPayBillDetailResponseBody
(
tx
*
sql
.
Tx
,
billID
int64
,
responseBody
interface
{})
error
{
func
InsertPayBillDetailResponseBody
(
tx
*
sql
.
Tx
,
billID
int64
,
responseBody
interface
{})
error
{
db
,
err
:=
mysql
.
NewShopConn
()
if
err
!=
nil
{
return
err
}
body
,
err
:=
json
.
Marshal
(
responseBody
)
body
,
err
:=
json
.
Marshal
(
responseBody
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
insertPayBillDetailSQL
:=
`update pay_bill_detail set response_body = ? where pay_bill_id = ?`
insertPayBillDetailSQL
:=
`update
system_
pay_bill_detail set response_body = ? where pay_bill_id = ?`
result
,
err
:=
db
.
Exec
(
insertPayBillDetailSQL
,
string
(
body
),
billID
)
result
,
err
:=
tx
.
Exec
(
insertPayBillDetailSQL
,
string
(
body
),
billID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -717,13 +691,8 @@ func InsertPayBillDetailResponseBody(tx *sql.Tx, billID int64, responseBody inte
...
@@ -717,13 +691,8 @@ func InsertPayBillDetailResponseBody(tx *sql.Tx, billID int64, responseBody inte
func
InsertPayBillDetailResponseBodyString
(
tx
*
sql
.
Tx
,
billID
int64
,
responseBody
string
)
error
{
func
InsertPayBillDetailResponseBodyString
(
tx
*
sql
.
Tx
,
billID
int64
,
responseBody
string
)
error
{
db
,
err
:=
mysql
.
NewShopConn
()
insertPayBillDetailSQL
:=
`update system_pay_bill_detail set response_body = ? where pay_bill_id = ?`
if
err
!=
nil
{
result
,
err
:=
tx
.
Exec
(
insertPayBillDetailSQL
,
responseBody
,
billID
)
return
err
}
insertPayBillDetailSQL
:=
`update pay_bill_detail set response_body = ? where pay_bill_id = ?`
result
,
err
:=
db
.
Exec
(
insertPayBillDetailSQL
,
responseBody
,
billID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
setting/setting.go
View file @
4bacb07d
...
@@ -59,6 +59,7 @@ type Server struct {
...
@@ -59,6 +59,7 @@ type Server struct {
type
Database
struct
{
type
Database
struct
{
Type
string
`mapstructure:"type""`
Type
string
`mapstructure:"type""`
ShopDB
string
`mapstructure:"shopdb"`
ShopDB
string
`mapstructure:"shopdb"`
SystemDB
string
`mapstructure:"systemdb"`
UserDB
string
`mapstructure:"userdb"`
UserDB
string
`mapstructure:"userdb"`
SecondDB
string
`mapstructure:"seconddb"`
SecondDB
string
`mapstructure:"seconddb"`
AccountDB
string
`mapstructure:"accountdb"`
AccountDB
string
`mapstructure:"accountdb"`
...
...
utils/mysql.go
View file @
4bacb07d
package
utils
package
utils
import
(
import
(
"database/sql"
"github.com/astaxie/beego"
// import mysql
// import mysql
_
"github.com/go-sql-driver/mysql"
_
"github.com/go-sql-driver/mysql"
)
)
var
(
//
var (
db
*
sql
.
DB
//
db *sql.DB
err
error
//
err error
)
//
)
//
// NewPayConn is 连接支付库
//
//
NewPayConn is 连接支付库
func
NewPayConn
()
(
*
sql
.
DB
,
error
)
{
//
func NewPayConn() (*sql.DB, error) {
if
db
==
nil
{
//
if db == nil {
db
,
err
=
sql
.
Open
(
"mysql"
,
beego
.
AppConfig
.
String
(
"PayURL"
))
//
db, err = sql.Open("mysql", beego.AppConfig.String("PayURL"))
return
db
,
err
//
return db, err
}
//
}
return
db
,
nil
//
return db, nil
}
//
}
// GetResultRow is 获取返回值, 获取一条
// GetResultRow is 获取返回值, 获取一条
//func GetResultRow(rows *sql.Rows) map[string]string {
//func GetResultRow(rows *sql.Rows) map[string]string {
...
@@ -65,10 +62,10 @@ func NewPayConn() (*sql.DB, error) {
...
@@ -65,10 +62,10 @@ func NewPayConn() (*sql.DB, error) {
// return result
// return result
//}
//}
// CloseTx is 有错误则关闭事务、没错则提交事务
//
//
CloseTx is 有错误则关闭事务、没错则提交事务
func
CloseTx
(
tx
*
sql
.
Tx
,
err
error
)
{
//
func CloseTx(tx *sql.Tx, err error) {
if
err
!=
nil
{
//
if err != nil {
tx
.
Rollback
()
//
tx.Rollback()
}
//
}
tx
.
Commit
()
//
tx.Commit()
}
//
}
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