Merge branch 'feat-IRONFANS-70' into test
This commit is contained in:
commit
6ed2b69550
|
@ -332,12 +332,14 @@ func (m *Mysql) CreateWallet(ctx *gin.Context, tx *sqlx.Tx, mid int64) error {
|
|||
}
|
||||
|
||||
// 获取钱包
|
||||
func (m *Mysql) GetWalletByMid(ctx *gin.Context, mid int64) (wallet *dbstruct.Wallet, err error) {
|
||||
var (
|
||||
db = m.getDBVas()
|
||||
tmpWallet dbstruct.Wallet
|
||||
)
|
||||
func (m *Mysql) GetWalletByMid(ctx *gin.Context, tx *sqlx.Tx, mid int64) (wallet *dbstruct.Wallet, err error) {
|
||||
var tmpWallet dbstruct.Wallet
|
||||
if tx != nil {
|
||||
err = tx.GetContext(ctx, &tmpWallet, fmt.Sprintf("select * from %s where id = ?", TableWallet), mid)
|
||||
} else {
|
||||
db := m.getDBVas()
|
||||
err = db.GetContext(ctx, &tmpWallet, fmt.Sprintf("select * from %s where id = ?", TableWallet), mid)
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -390,7 +390,7 @@ func (s *Service) ApiGetAccountListByMid(ctx *gin.Context, req *accountproto.Api
|
|||
vo = &accountproto.ApiListVO{}
|
||||
vo.CopyAccount(account)
|
||||
|
||||
wallet, _ := _DefaultVas.CheckWalletExist(ctx, util.DerefInt64(req.Mid))
|
||||
wallet, _ := _DefaultVas.CheckWalletExist(ctx, nil, util.DerefInt64(req.Mid))
|
||||
vo.CopyWallet(wallet)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -328,20 +328,20 @@ func (v *Vas) CreateOrder(ctx *gin.Context, req *vasproto.CreateOrderReq) (data
|
|||
return
|
||||
}
|
||||
|
||||
func (v *Vas) CheckWalletExist(ctx *gin.Context, mid int64) (wallet *dbstruct.Wallet, exist bool) {
|
||||
func (v *Vas) CheckWalletExist(ctx *gin.Context, tx *sqlx.Tx, mid int64) (wallet *dbstruct.Wallet, exist bool) {
|
||||
if mid <= 0 {
|
||||
return
|
||||
}
|
||||
wallet, err := v.store.GetWalletByMid(ctx, mid)
|
||||
wallet, err := v.store.GetWalletByMid(ctx, tx, mid)
|
||||
switch err {
|
||||
case sql.ErrNoRows:
|
||||
err = v.store.CreateWallet(ctx, nil, mid)
|
||||
err = v.store.CreateWallet(ctx, tx, mid)
|
||||
if err != nil {
|
||||
logger.Error("CreateWallet fail, mid: %v, err: %v", mid, err)
|
||||
return
|
||||
}
|
||||
logger.Info("CreateWallet success, mid: %v", mid)
|
||||
wallet, err = v.store.GetWalletByMid(ctx, mid)
|
||||
wallet, err = v.store.GetWalletByMid(ctx, tx, mid)
|
||||
if err != nil {
|
||||
logger.Error("GetWalletByMid after create fail, mid: %v, err: %v", mid, err)
|
||||
return
|
||||
|
@ -388,7 +388,7 @@ func (v *Vas) OpCreateOrder(ctx *gin.Context, req *vasproto.OpCreateOrderReq) (e
|
|||
req.Money = coins / 10
|
||||
|
||||
// 检查钱包
|
||||
wallet, has := v.CheckWalletExist(ctx, mid)
|
||||
wallet, has := v.CheckWalletExist(ctx, nil, mid)
|
||||
if !has {
|
||||
err = errs.ErrVasWalletNotExist
|
||||
return
|
||||
|
@ -490,7 +490,7 @@ func (v *Vas) PreUnlockContact(ctx *gin.Context, req *vasproto.PreUnlockContactR
|
|||
)
|
||||
|
||||
// 获取用户钱包
|
||||
wallet, has := v.CheckWalletExist(ctx, mid)
|
||||
wallet, has := v.CheckWalletExist(ctx, nil, mid)
|
||||
if !has {
|
||||
err = errs.ErrVasWalletNotExist
|
||||
return
|
||||
|
@ -575,13 +575,13 @@ func (v *Vas) OneStepUnlockContact(ctx *gin.Context, req *vasproto.OneStepUnlock
|
|||
)
|
||||
|
||||
// 检查钱包
|
||||
_, has := v.CheckWalletExist(ctx, mid)
|
||||
_, has := v.CheckWalletExist(ctx, nil, mid)
|
||||
if !has {
|
||||
err = errs.ErrVasWalletNotExist
|
||||
return
|
||||
}
|
||||
|
||||
v.CheckWalletExist(ctx, common.OfficialMid)
|
||||
v.CheckWalletExist(ctx, nil, common.OfficialMid)
|
||||
|
||||
// 是否已经解锁过
|
||||
unlockInfo, _ := v.store.GetUserVasUnlock(ctx, nil, mid, uid, contactProductId)
|
||||
|
@ -1041,7 +1041,7 @@ func (v *Vas) H5DirectUnlockWechat(ctx *gin.Context, req *vasproto.H5DirectUnloc
|
|||
}
|
||||
|
||||
// 检查钱包
|
||||
wallet, _ := v.CheckWalletExist(ctx, req.Mid)
|
||||
wallet, _ := v.CheckWalletExist(ctx, nil, req.Mid)
|
||||
|
||||
// 金币够不够
|
||||
if wallet.GetCoins() >= uVas.GetH5WechatCoinPrice() {
|
||||
|
@ -1160,7 +1160,7 @@ func (v *Vas) PayCallback(ctx *gin.Context, p *vasproto.PayCallbackParamIn) {
|
|||
}
|
||||
|
||||
// 钱包
|
||||
_, hasWallet := v.CheckWalletExist(ctx, checkOrder.GetMid())
|
||||
_, hasWallet := v.CheckWalletExist(ctx, nil, checkOrder.GetMid())
|
||||
if !hasWallet {
|
||||
logger.Error("CheckWalletExist fail, mid: %v", checkOrder.GetMid())
|
||||
return
|
||||
|
@ -1428,7 +1428,7 @@ func (v *Vas) WithdrawApply(ctx *gin.Context, req *vasproto.WithdrawApplyReq) (t
|
|||
// todo 分布式锁
|
||||
|
||||
// 检查余额
|
||||
wallet, _ := v.CheckWalletExist(ctx, mid)
|
||||
wallet, _ := v.CheckWalletExist(ctx, nil, mid)
|
||||
if wallet == nil {
|
||||
err = errs.ErrVasWalletNotExist
|
||||
return
|
||||
|
|
|
@ -30,7 +30,7 @@ func (v *Vas) CheckZoneUnlockExist(ctx *gin.Context, tx *sqlx.Tx, mid, zid int64
|
|||
logger.Error("CreateZoneUnlock fail, mid: %v, zid: %v, err: %v", mid, zid, err)
|
||||
return
|
||||
}
|
||||
logger.Info("CreateWallet success, mid: %v, zid: %v", mid, zid)
|
||||
logger.Info("CreateZoneUnlock success, mid: %v, zid: %v", mid, zid)
|
||||
zu, err = v.store.GetZoneUnlock(ctx, tx, mid, zid)
|
||||
if err != nil {
|
||||
logger.Error("GetWalletByMid after create fail, mid: %v, zid: %v, err: %v", mid, zid, err)
|
||||
|
@ -490,10 +490,11 @@ func (v *Vas) calcAndUpdateIncome(ctx *gin.Context, tx *sqlx.Tx, streamerMid, ui
|
|||
// 有空间,有代运营
|
||||
list = v._calcWithZoneWithTp(streamerMid, totalDias, defaultIncomeSType, tp, zclrList)
|
||||
}
|
||||
logger.Info("incomeList: %v", util.ToJson(list))
|
||||
|
||||
// 检查所有人钱包
|
||||
for _, ii := range list {
|
||||
_, exists := v.CheckWalletExist(ctx, ii.Mid)
|
||||
_, exists := v.CheckWalletExist(ctx, tx, ii.Mid)
|
||||
if !exists {
|
||||
err = errs.ErrVasWalletNotExist
|
||||
return make([]IncomeInfo, 0), err
|
||||
|
@ -503,7 +504,7 @@ func (v *Vas) calcAndUpdateIncome(ctx *gin.Context, tx *sqlx.Tx, streamerMid, ui
|
|||
// 写记录
|
||||
for _, ii := range list {
|
||||
// 写消费记录
|
||||
wallet, _ := v.CheckWalletExist(ctx, ii.Mid)
|
||||
wallet, _ := v.CheckWalletExist(ctx, tx, ii.Mid)
|
||||
ch := &dbstruct.ConsumeHistory{
|
||||
Mid: goproto.Int64(ii.Mid),
|
||||
Uid: goproto.Int64(uid),
|
||||
|
|
|
@ -42,7 +42,7 @@ func (p *ZoneMoment) OpCreate(ctx *gin.Context, req *zonemomentproto.OpCreateReq
|
|||
logger.Error("CreateZoneMoment fail, err: %v", err)
|
||||
return err, 0
|
||||
}
|
||||
return nil, 0
|
||||
return nil, zoneMomentIdSeq.Seq
|
||||
}
|
||||
|
||||
func (p *ZoneMoment) OpUpdate(ctx *gin.Context, req *zonemomentproto.OpUpdateReq) error {
|
||||
|
|
|
@ -396,7 +396,7 @@ func (s *Service) PayCallback(ctx *gin.Context, req *vasproto.PayCallbackParamIn
|
|||
// 提现页面
|
||||
func (s *Service) WithdrawPage(ctx *gin.Context, req *vasproto.WithdrawPageReq) (data *vasproto.WithdrawPageData, ec errcode.ErrCode) {
|
||||
data = new(vasproto.WithdrawPageData)
|
||||
wallet, _ := _DefaultVas.CheckWalletExist(ctx, req.Mid)
|
||||
wallet, _ := _DefaultVas.CheckWalletExist(ctx, nil, req.Mid)
|
||||
if wallet != nil {
|
||||
data.WithdrawDiamonds = wallet.GetWithdrawDiamonds()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue