Merge pull request 'by Robin at 20240628' (#571) from feat-IRONFANS-148-Robin into main
Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/571
This commit is contained in:
commit
c5ba290745
|
@ -5407,6 +5407,24 @@ func (m *Mongo) ClearSingleDistributeLock(ctx *gin.Context, mid int64) (err erro
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Mongo) GetAndDecSingleDistributeLock(ctx *gin.Context, mid int64) (singleDistributeLock *dbstruct.SingleDistributeLock, err error) {
|
||||||
|
col := m.getColSingleDistributeLock()
|
||||||
|
|
||||||
|
change := qmgo.Change{
|
||||||
|
Update: qmgo.M{"$inc": qmgo.M{"lock": -1}},
|
||||||
|
Upsert: true,
|
||||||
|
ReturnNew: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
singleDistributeLockInstance := dbstruct.SingleDistributeLock{}
|
||||||
|
if err = col.Find(ctx, qmgo.M{"_id": mid}).Apply(change, &singleDistributeLockInstance); err != nil {
|
||||||
|
logger.Error("change error : %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return &singleDistributeLockInstance, err
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Mongo) GetSingleDistributeHisById(ctx *gin.Context, id string) (*dbstruct.SingleDistributeHis, error) {
|
func (m *Mongo) GetSingleDistributeHisById(ctx *gin.Context, id string) (*dbstruct.SingleDistributeHis, error) {
|
||||||
one := &dbstruct.SingleDistributeHis{}
|
one := &dbstruct.SingleDistributeHis{}
|
||||||
col := m.getColSingleDistributeHis()
|
col := m.getColSingleDistributeHis()
|
||||||
|
|
|
@ -3497,13 +3497,21 @@ func (s *Service) ApiHvyogoSingleDistribute(ctx *gin.Context, req *hvyogoproto.A
|
||||||
|
|
||||||
// 发起单侧提现申请
|
// 发起单侧提现申请
|
||||||
diamonds := int64(float64(distributeAmount) / 10)
|
diamonds := int64(float64(distributeAmount) / 10)
|
||||||
resp, err := _DefaultVas.UnilaterallyHvyogoWithdrawApply(ctx, &vasproto.UnilaterallyWithdrawApplyReq{
|
resp, err, isValidTimeErr := _DefaultVas.UnilaterallyHvyogoWithdrawApply(ctx, &vasproto.UnilaterallyWithdrawApplyReq{
|
||||||
BaseRequest: req.BaseRequest,
|
BaseRequest: req.BaseRequest,
|
||||||
Diamonds: diamonds,
|
Diamonds: diamonds,
|
||||||
}, extWithdrawFunc)
|
}, extWithdrawFunc)
|
||||||
ec, err = errs.DealVasErr(err)
|
ec, err = errs.DealVasErr(err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("WithdrawApply fail, req: %v, err: %v", util.ToJson(req), err)
|
logger.Error("WithdrawApply fail, req: %v, err: %v", util.ToJson(req), err)
|
||||||
|
if isValidTimeErr { //是验证时错误,锁-1
|
||||||
|
_, err = _DefaultSingleDistributeHis.GetAndDecLock(ctx, req.BaseRequest.Mid)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("_DefaultSingleDistributeHis GetAndDecLock failed : %v", err)
|
||||||
|
ec, err = errcode.ErrCodeSingleDistributeHisSrvFail, nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
err = nil
|
err = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,15 @@ func (p *SingleDistributeHis) ClearLock(ctx *gin.Context, mid int64) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *SingleDistributeHis) GetAndDecLock(ctx *gin.Context, mid int64) (*dbstruct.SingleDistributeLock, error) {
|
||||||
|
lock, err := p.store.GetAndDecSingleDistributeLock(ctx, mid)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("DecSingleDistributeLock fail, err: %v", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return lock, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (p *SingleDistributeHis) GetById(ctx *gin.Context, id string) (*dbstruct.SingleDistributeHis, error) {
|
func (p *SingleDistributeHis) GetById(ctx *gin.Context, id string) (*dbstruct.SingleDistributeHis, error) {
|
||||||
list, err := p.store.GetSingleDistributeHisById(ctx, id)
|
list, err := p.store.GetSingleDistributeHisById(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3825,19 +3825,20 @@ func (v *Vas) GetRefundRateGroupByMid(ctx *gin.Context, tx *sqlx.Tx) ([]*dbstruc
|
||||||
}
|
}
|
||||||
|
|
||||||
// 单侧提现申请
|
// 单侧提现申请
|
||||||
func (v *Vas) UnilaterallyHvyogoWithdrawApply(ctx *gin.Context, req *vasproto.UnilaterallyWithdrawApplyReq, extWithdrawFunc func(orderId string) (*hvyogoproto.SingleDistributeVO, error)) (resp *hvyogoproto.SingleDistributeVO, err error) {
|
func (v *Vas) UnilaterallyHvyogoWithdrawApply(ctx *gin.Context, req *vasproto.UnilaterallyWithdrawApplyReq, extWithdrawFunc func(orderId string) (*hvyogoproto.SingleDistributeVO, error)) (resp *hvyogoproto.SingleDistributeVO, err error, isValidTimeErr bool) {
|
||||||
var (
|
var (
|
||||||
mid = req.Mid
|
mid = req.Mid
|
||||||
diamonds = req.Diamonds
|
diamonds = req.Diamonds
|
||||||
money = req.Diamonds * 10
|
money = req.Diamonds * 10
|
||||||
)
|
)
|
||||||
|
isValidTimeErr = false // 是否验证时错误
|
||||||
|
|
||||||
// 今日提现次数
|
// 今日提现次数
|
||||||
st := util.GetTodayZeroTime().Unix()
|
st := util.GetTodayZeroTime().Unix()
|
||||||
et := st + 86400
|
et := st + 86400
|
||||||
list, _ := v.store.GetWithdrawOrdersByMid(ctx, nil, mid, st, et)
|
list, _ := v.store.GetWithdrawOrdersByMid(ctx, nil, mid, st, et)
|
||||||
if len(list) > 0 {
|
if len(list) > 0 {
|
||||||
err = errs.ErrVasOverTodayWithdrawCnt
|
err, isValidTimeErr = errs.ErrVasOverTodayWithdrawCnt, true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3846,11 +3847,11 @@ func (v *Vas) UnilaterallyHvyogoWithdrawApply(ctx *gin.Context, req *vasproto.Un
|
||||||
// 检查余额
|
// 检查余额
|
||||||
wallet, _ := v.CheckWalletExist(ctx, nil, mid)
|
wallet, _ := v.CheckWalletExist(ctx, nil, mid)
|
||||||
if wallet == nil {
|
if wallet == nil {
|
||||||
err = errs.ErrVasWalletNotExist
|
err, isValidTimeErr = errs.ErrVasWalletNotExist, true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if wallet.GetWithdrawDiamonds() < diamonds {
|
if wallet.GetWithdrawDiamonds() < diamonds {
|
||||||
err = errs.ErrVasNoEnoughWithdrawDias
|
err, isValidTimeErr = errs.ErrVasNoEnoughWithdrawDias, true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue