Merge branch 'dev-lwl/fix_witdraw' into test
This commit is contained in:
commit
e7c977660d
|
@ -96,7 +96,9 @@ type WithdrawPageReq struct {
|
|||
}
|
||||
|
||||
type WithdrawPageData struct {
|
||||
WithdrawDiamonds int64 `json:"withdraw_diamonds"` // 可提现的钻石
|
||||
WithdrawDiamonds int64 `json:"withdraw_diamonds"` // 可提现的钻石
|
||||
Day7TotalDiamonds int64 `json:"day7_total_diamonds"` // 7天前0~24点总收益
|
||||
Day7TotalWithdrawDiamonds int64 `json:"day7_total_withdraw_diamonds"` // 7天前0~24点已结算总收益
|
||||
}
|
||||
|
||||
// 提现发送验证码
|
||||
|
|
|
@ -1158,3 +1158,44 @@ func (m *Mysql) CreateWithdrawDiamondsHis(ctx *gin.Context, tx *sqlx.Tx, h *dbst
|
|||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// 根据时间段获取收益钻石
|
||||
func (m *Mysql) GetIncomeList(ctx *gin.Context, tx *sqlx.Tx, mid, st, et int64) (list []*dbstruct.ConsumeHistory, err error) {
|
||||
list = make([]*dbstruct.ConsumeHistory, 0)
|
||||
tableName, err := m.ChTableName(&dbstruct.ConsumeHistory{Type: goproto.Int32(dbstruct.CHTypeIncome)})
|
||||
sqlStr := fmt.Sprintf("select order_id,`change` from %s where mid=? and ct>=? and ct<?", tableName)
|
||||
args := []any{mid, st, et}
|
||||
if tx != nil {
|
||||
err = tx.SelectContext(ctx, &list, sqlStr, args...)
|
||||
} else {
|
||||
db := m.getDBVas()
|
||||
err = db.SelectContext(ctx, &list, sqlStr, args...)
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 根据时间段获取结算收益
|
||||
func (m *Mysql) GetTotalFinishIncome(ctx *gin.Context, tx *sqlx.Tx, mid int64, orderIds []string) (int64, error) {
|
||||
type S struct {
|
||||
Dias int64 `json:"dias"`
|
||||
}
|
||||
var (
|
||||
tmp = S{}
|
||||
err error
|
||||
)
|
||||
sqlStr := fmt.Sprintf("select sum(`change`) as dias from %s where mid=? and order_id in (%s)", TableWithdrawDiamondsHis, util.Convert2SqlArr(orderIds))
|
||||
args := []any{mid}
|
||||
if tx != nil {
|
||||
err = tx.GetContext(ctx, &tmp, sqlStr, args...)
|
||||
} else {
|
||||
db := m.getDBVas()
|
||||
err = db.GetContext(ctx, &tmp, sqlStr, args...)
|
||||
}
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return tmp.Dias, nil
|
||||
}
|
||||
|
|
|
@ -3451,3 +3451,11 @@ func (v *Vas) payRefund(ctx *gin.Context, order *dbstruct.Order) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *Vas) GetIncomeList(ctx *gin.Context, tx *sqlx.Tx, mid, st, et int64) (list []*dbstruct.ConsumeHistory, err error) {
|
||||
return v.store.GetIncomeList(ctx, tx, mid, st, et)
|
||||
}
|
||||
|
||||
func (v *Vas) GetTotalFinishIncome(ctx *gin.Context, tx *sqlx.Tx, mid int64, orderIds []string) (int64, error) {
|
||||
return v.store.GetTotalFinishIncome(ctx, tx, mid, orderIds)
|
||||
}
|
||||
|
|
|
@ -510,6 +510,29 @@ func (s *Service) WithdrawPage(ctx *gin.Context, req *vasproto.WithdrawPageReq)
|
|||
if wallet != nil {
|
||||
data.WithdrawDiamonds = wallet.GetWithdrawDiamonds()
|
||||
}
|
||||
|
||||
st := util.GetTodayZeroTime().Unix() - 86400*7
|
||||
et := st + 86400
|
||||
// 获取 7天前0~24点总收益
|
||||
day7TotalDiamonds := int64(0)
|
||||
incomeList, err := _DefaultVas.GetIncomeList(ctx, nil, req.Mid, st, et)
|
||||
if err != nil {
|
||||
logger.Error("GetIncomeList fail, mid: %v, st: %v, et: %v, err: %v", req.Mid, st, et)
|
||||
}
|
||||
orderIds := make([]string, 0)
|
||||
for _, c := range incomeList {
|
||||
day7TotalDiamonds += c.GetChange()
|
||||
orderIds = append(orderIds, c.GetOrderId())
|
||||
}
|
||||
data.Day7TotalDiamonds = day7TotalDiamonds
|
||||
|
||||
// 获取 7天前0~24点已结算总收益
|
||||
day7TotalWithdrawDiamonds, err := _DefaultVas.GetTotalFinishIncome(ctx, nil, req.Mid, orderIds)
|
||||
if err != nil {
|
||||
logger.Error("GetTotalFinishIncome fail, mid: %v, st: %v, et: %v, err: %v", req.Mid, st, et)
|
||||
}
|
||||
data.Day7TotalWithdrawDiamonds = day7TotalWithdrawDiamonds
|
||||
|
||||
ec = errcode.ErrCodeOk
|
||||
return
|
||||
}
|
||||
|
|
|
@ -158,6 +158,7 @@ CREATE TABLE `vas_withdraw_diamonds_his`
|
|||
);
|
||||
CREATE INDEX ix_mid ON vas_withdraw_diamonds_his (mid);
|
||||
CREATE INDEX ix_ct ON vas_withdraw_diamonds_his (ct);
|
||||
CREATE INDEX ix_mid_ct ON vas_withdraw_diamonds_his (mid,ct);
|
||||
CREATE INDEX ix_order_id ON vas_withdraw_diamonds_his (order_id);
|
||||
CREATE INDEX ix_chid ON vas_withdraw_diamonds_his (income_ch_id);
|
||||
|
||||
|
|
Loading…
Reference in New Issue