aa
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/client/orm"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -33,7 +34,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func (p *PayHandler) CreatePay() (err error) {
|
||||
func (p *PayHandler) CreatePay(txDB orm.TxOrmer) (err error) {
|
||||
switch p.PayType {
|
||||
case model.PayTypeTL:
|
||||
param := &tonglianpayapi.CreateUnitorderOrderParam{
|
||||
@@ -53,7 +54,7 @@ func (p *PayHandler) CreatePay() (err error) {
|
||||
json.Unmarshal([]byte(result.PayInfo), &result2)
|
||||
p.Order.PrepayID = result2.Package[strings.LastIndex(result2.Package, "=")+1 : len(result2.Package)]
|
||||
p.Order.TransactionID = result.TrxID
|
||||
_, err = dao.UpdateEntity(dao.GetDB(), p.Order, "PrepayID", "TransactionID")
|
||||
_, err = dao.UpdateEntityTx(txDB, p.Order, "PrepayID", "TransactionID")
|
||||
}
|
||||
case model.PayTypeWX:
|
||||
param := &wxpayapi.CreateOrderParam{
|
||||
@@ -96,7 +97,7 @@ func (p *PayHandler) CreatePay() (err error) {
|
||||
p.WxPayParam = wxPay
|
||||
p.Order.PrepayID = result.PrepayID
|
||||
p.Order.Comment = result.CodeURL
|
||||
_, err = dao.UpdateEntity(dao.GetDB(), p.Order, "PrepayID", "Comment")
|
||||
_, err = dao.UpdateEntityTx(txDB, p.Order, "PrepayID", "Comment")
|
||||
} else {
|
||||
return err2
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func OnPayFinished(order *model.Order) (err error) {
|
||||
case model.OrderTypePay:
|
||||
//如果是账户充值(发布任务等)
|
||||
//账户收入
|
||||
if err = AddIncomeUpdateAccount(db, userBill, model.BillTypeInvest, order.PayPrice, 0); err != nil {
|
||||
if err = AddIncomeUpdateAccount(txDB, userBill, model.BillTypeInvest, order.PayPrice, 0); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
}
|
||||
default:
|
||||
@@ -93,7 +93,7 @@ func OnCashFinished(order *model.Order) (err error) {
|
||||
case model.OrderTypeCash:
|
||||
//如果是账户提现
|
||||
//账户支出
|
||||
if err = AddExpendUpdateAccount(db, userBill, model.BillTypeCash, order.PayPrice, 0); err != nil {
|
||||
if err = AddExpendUpdateAccount(txDB, userBill, model.BillTypeCash, order.PayPrice, 0); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user