Commit 17e936c6 by 朱继来

添加支付记录

parent 236b365d
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
// 随机数 // 随机数
func RandInt(min, max int) int { func RandInt(min, max int) int {
if min >= max || min==0 || max==0{ if min >= max || max == 0{
return max return max
} }
...@@ -147,3 +147,11 @@ func GetDiffDay(start, end string) int { ...@@ -147,3 +147,11 @@ func GetDiffDay(start, end string) int {
return diff_day return diff_day
} }
// 随机获取支付名称
func GetRandPayName() string {
var pay_name = [5]string{"微信支付", "支付宝", "银联支付(B2B)", "银联支付(B2C)", "交通银行"}
var n = RandInt(0, 5)
return pay_name[n]
}
\ No newline at end of file
...@@ -214,6 +214,18 @@ func CreateOrder(user_id int, create_time int64) { ...@@ -214,6 +214,18 @@ func CreateOrder(user_id int, create_time int64) {
return return
} }
// 添加lie_pay_log 支付记录
pay_name := handle.GetRandPayName()
rand_time := int64(handle.RandInt(200, 1000))
last_time := create_time + rand_time // 支付时间
_, err = conn.Exec("insert into lie_pay_log (user_id, order_id, order_sn, pay_name, pay_amount, is_paid, create_time, pay_time) values (?, ?, ?, ?, ?, ?, ?, ?)", user_id,
order_id, order_sn, pay_name, order_amount, 1, last_time, last_time)
if err != nil {
conn.Rollback() //回滚
return
}
conn.Commit() // 提交事务 conn.Commit() // 提交事务
fmt.Println("生成竞调订单ID:" + strconv.Itoa(order_id)) fmt.Println("生成竞调订单ID:" + strconv.Itoa(order_id))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment