diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 6a47b312..81672d20 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -87,6 +87,7 @@ const ( COLZoneMomentPrice = "zone_moment_price" COLZoneMomentStat = "zone_moment_stat" COLUserIncome = "user_income" + COLWithdrawHis = "withdraw_his" DBCatalog = "catalog" COLCatalog = "catalog" @@ -277,6 +278,11 @@ func (m *Mongo) getColOplogCoinOrder(orderId string) *qmgo.Collection { return m.clientMix.Database(DBVas).Collection(fmt.Sprintf(COLOpLogCoinOrder, mod)) } +// 提现历史 +func (m *Mongo) getColWithdrawHis() *qmgo.Collection { + return m.clientMix.Database(DBVas).Collection(COLWithdrawHis) +} + // 分类表 func (m *Mongo) getColCatalog() *qmgo.Collection { return m.clientMix.Database(DBCatalog).Collection(COLCatalog) diff --git a/app/mix/dao/mongo_vas.go b/app/mix/dao/mongo_vas.go index 8df57ba9..c58c932b 100644 --- a/app/mix/dao/mongo_vas.go +++ b/app/mix/dao/mongo_vas.go @@ -281,3 +281,10 @@ func (m *Mongo) GetZoneUserIncome(ctx *gin.Context, mid int64) (*dbstruct.UserIn } return doc, nil } + +// 收入历史 +func (m *Mongo) AddWithdrawHis(ctx *gin.Context, doc *dbstruct.WithdrawHis) error { + col := m.getColWithdrawHis() + _, err := col.InsertOne(ctx, doc) + return err +} diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index db696411..e8c83738 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -109,8 +109,16 @@ func (v *Vas) GetMembershipProductList(ctx *gin.Context, req *vasproto.GetMember return } +var CreateOrderBlacklist = map[int64]bool{ + 241685: true, + 347607: true, + 351461: true, + 359669: true, + 358643: true, +} + func (v *Vas) CreateOrder(ctx *gin.Context, req *vasproto.CreateOrderReq) (data *vasproto.CreateOrderData, err error) { - if req.Mid == 241685 { + if CreateOrderBlacklist[req.Mid] { err = fmt.Errorf("账号已受限,解限请联系客服") return } @@ -1784,8 +1792,9 @@ func (v *Vas) WithdrawApply(ctx *gin.Context, req *vasproto.WithdrawApplyReq) (t alipayName := string(alipayNameBytes) var ( - wOrder *dbstruct.WithdrawOrder - orderId = idgenerator.GenWithdrawOrderId() + wOrder *dbstruct.WithdrawOrder + orderId = idgenerator.GenWithdrawOrderId() + errMsgSt = make(map[string]interface{}) ) // 开启事务 @@ -1795,9 +1804,28 @@ func (v *Vas) WithdrawApply(ctx *gin.Context, req *vasproto.WithdrawApplyReq) (t return } defer func() { + wHis := &dbstruct.WithdrawHis{ + Id: orderId, + Mid: mid, + Did: req.Did, + Status: dbstruct.WithdrawStatusOk, + Ct: time.Now().Unix(), + } if err != nil { logger.Error("global err, req: %v, err: %v", util.ToJson(req), err) + wHis.Status = dbstruct.WithdrawStatusFail + wHis.Err = err.Error() } + if len(errMsgSt) > 0 { + wHis.Err = util.ToJson(errMsgSt) + } + + // 提现历史 + errHis := v.store.AddWithdrawHis(ctx, wHis) + if errHis != nil { + logger.Error("AddWithdrawHis fail, wHis: %v, errHis: %v", util.ToJson(wHis), errHis) + } + errTx := v.store.DealTxCR(tx, err) if errTx != nil { logger.Error("DealTxCR fail, err: %v", errTx) @@ -1896,11 +1924,21 @@ func (v *Vas) WithdrawApply(ctx *gin.Context, req *vasproto.WithdrawApplyReq) (t } if transferResp.Response == nil { err = errors.New("invalid transfer resp") + errMsgSt = map[string]interface{}{ + "req": req, + "transferParam": transferParam, + "transferResp": transferResp, + } logger.Error("Invalid transfer resp response, param: %v, resp: %v, err: %v", util.ToJson(transferParam), util.ToJson(transferResp), err) return } if transferResp.Response.Status != "SUCCESS" { err = errs.ErrVasAlipayUniTransferFail + errMsgSt = map[string]interface{}{ + "req": req, + "transferParam": transferParam, + "transferResp": transferResp, + } logger.Error("UniTransfer fail, param: %v, resp: %v, err: %v", util.ToJson(transferParam), util.ToJson(transferResp), err) return } diff --git a/dbstruct/vas_mongo.go b/dbstruct/vas_mongo.go index 0019795f..72987c4c 100644 --- a/dbstruct/vas_mongo.go +++ b/dbstruct/vas_mongo.go @@ -172,3 +172,18 @@ type UserIncome struct { WeekDashboard []WeekDashboardSt `json:"week_dashboard" bson:"week_dashboard"` WeekFromDashboard []IncomeFromDashboardSt `json:"week_from_dashboard" bson:"week_from_dashboard"` } + +// 提现历史 +const ( + WithdrawStatusOk = 1 + WithdrawStatusFail = 2 +) + +type WithdrawHis struct { + Id string `json:"id" bson:"_id"` + Mid int64 `json:"mid" bson:"mid"` + Did string `json:"did" bson:"did"` + Status int `json:"status" bson:"status"` // 见: WithdrawStatusOk + Err string `json:"err" bson:"err"` + Ct int64 `json:"ct" bson:"ct"` +}