merge
This commit is contained in:
commit
0241e75edb
|
@ -313,23 +313,13 @@ type IncomePageReq struct {
|
|||
base.BaseRequest
|
||||
}
|
||||
|
||||
type WeekDashboardSt struct {
|
||||
Date string `json:"date"` // 日期 x轴
|
||||
Income int64 `json:"income"` // 收入 y轴
|
||||
}
|
||||
|
||||
type IncomeFromDashboardSt struct {
|
||||
Desc string `json:"desc"` // 描述
|
||||
Income int64 `json:"income"` // 收入
|
||||
}
|
||||
|
||||
type IncomePageData struct {
|
||||
Diamonds int64 `json:"diamonds"` // 当前钻石
|
||||
WithdrawDiamonds int64 `json:"withdraw_diamonds"` // 待提现钻石
|
||||
TodayIncome int64 `json:"today_income"` // 今日收益钻石
|
||||
WaitDealIncome int64 `json:"wait_deal_income"` // 待结算钻石
|
||||
WeekDashboard []WeekDashboardSt `json:"week_dashboard"` // 周收益看板
|
||||
IncomeFromDashboard []IncomeFromDashboardSt `json:"income_from_dashboard"` // 收益来源看板
|
||||
Diamonds int64 `json:"diamonds"` // 当前钻石
|
||||
WithdrawDiamonds int64 `json:"withdraw_diamonds"` // 待提现钻石
|
||||
TodayIncome int64 `json:"today_income"` // 今日收益钻石
|
||||
WaitDealIncome int64 `json:"wait_deal_income"` // 待结算钻石
|
||||
WeekDashboard []dbstruct.WeekDashboardSt `json:"week_dashboard"` // 周收益看板
|
||||
IncomeFromDashboard []dbstruct.IncomeFromDashboardSt `json:"income_from_dashboard"` // 收益来源看板
|
||||
}
|
||||
|
||||
type IncomePageResp struct {
|
||||
|
|
|
@ -301,7 +301,7 @@ func Init(r *gin.Engine) {
|
|||
vasPayGroup.POST("deal_one_coin_order", middleware.JSONParamValidator(vasproto.DealOneCoinOrderReq{}), DealOneCoinOrder)
|
||||
vasPayGroup.POST("deal_one_order", middleware.JSONParamValidator(vasproto.DealOneOrderReq{}), DealOneOrder)
|
||||
vasPayGroup.POST("moment_order_list", middleware.JSONParamValidator(vasproto.ZoneMomentOrderListReq{}), ZoneMomentOrderList)
|
||||
//vasPayGroup.POST("income_page", middleware.JSONParamValidator(vasproto.IncomePageReq{}), nil)
|
||||
vasPayGroup.POST("income_page", middleware.JSONParamValidator(vasproto.IncomePageReq{}), IncomePage)
|
||||
|
||||
extVasPayGroup := r.Group("/ext/vas")
|
||||
extVasPayGroup.POST("alipay_callback", AlipayCallback)
|
||||
|
|
|
@ -408,3 +408,18 @@ func RefundCoinOrder(ctx *gin.Context) {
|
|||
}
|
||||
ReplyOk(ctx, nil)
|
||||
}
|
||||
|
||||
func IncomePage(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*vasproto.IncomePageReq)
|
||||
data, ec, err := service.DefaultService.VasIncomePage(ctx, req)
|
||||
if ec != errcode.ErrCodeVasSrvOk {
|
||||
logger.Error("RefundCoinOrder fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
if err != nil {
|
||||
ReplyErrorMsg(ctx, err.Error())
|
||||
return
|
||||
}
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
ReplyOk(ctx, data)
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ const (
|
|||
COLZoneVas = "zone_vas"
|
||||
COLZoneMomentPrice = "zone_moment_price"
|
||||
COLZoneMomentStat = "zone_moment_stat"
|
||||
COLUserIncome = "user_income"
|
||||
|
||||
DBCatalog = "catalog"
|
||||
COLCatalog = "catalog"
|
||||
|
@ -249,6 +250,11 @@ func (m *Mongo) getColZoneMomentStat() *qmgo.Collection {
|
|||
return m.clientMix.Database(DBVas).Collection(COLZoneMomentStat)
|
||||
}
|
||||
|
||||
// 用户收入看板
|
||||
func (m *Mongo) getColUserIncome() *qmgo.Collection {
|
||||
return m.clientMix.Database(DBVas).Collection(COLUserIncome)
|
||||
}
|
||||
|
||||
// 订单操作记录
|
||||
func (m *Mongo) getColOplogOrder(orderId string) *qmgo.Collection {
|
||||
orderIdInt64, _ := strconv.ParseInt(orderId[:13], 10, 64)
|
||||
|
|
|
@ -263,3 +263,21 @@ func (m *Mongo) GetZoneMomentStatByIds(ctx *gin.Context, momentIds []int64) ([]*
|
|||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// 获取收入看板
|
||||
func (m *Mongo) GetZoneUserIncome(ctx *gin.Context, mid int64) (*dbstruct.UserIncome, error) {
|
||||
doc := new(dbstruct.UserIncome)
|
||||
col := m.getColUserIncome()
|
||||
query := qmgo.M{
|
||||
"_id": mid,
|
||||
}
|
||||
err := col.Find(ctx, query).One(&doc)
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
err = nil
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return doc, nil
|
||||
}
|
||||
|
|
|
@ -1279,3 +1279,31 @@ func (m *Mysql) GetRefundRateGroupByMid(ctx *gin.Context, tx *sqlx.Tx) ([]*dbstr
|
|||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// 获取今日收入
|
||||
func (m *Mysql) GetTodayIncome(ctx *gin.Context, tx *sqlx.Tx, mid int64) (int64, error) {
|
||||
type S struct {
|
||||
Income int64 `json:"income"`
|
||||
}
|
||||
var (
|
||||
err error
|
||||
s = S{}
|
||||
et = util.GetTodayZeroTime().Unix()
|
||||
st = et - 86400
|
||||
)
|
||||
sqlStr := fmt.Sprintf("select sum(`change`) as income from %s where mid=? and ct>=? and ct<?", TableConsumeHistoryIncome)
|
||||
args := []any{mid, st, et}
|
||||
if tx != nil {
|
||||
err = tx.GetContext(ctx, &s, sqlStr, args...)
|
||||
} else {
|
||||
db := m.getDBVas()
|
||||
err = db.GetContext(ctx, &s, sqlStr, args...)
|
||||
}
|
||||
if err == sql.ErrNoRows {
|
||||
return 0, nil
|
||||
}
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return s.Income, nil
|
||||
}
|
||||
|
|
|
@ -1261,3 +1261,31 @@ func (v *Vas) GetZoneMemberCountGroupByZoneMemberType(ctx *gin.Context, zids []i
|
|||
|
||||
return countMp, nil
|
||||
}
|
||||
|
||||
// 空间收入页面
|
||||
func (v *Vas) ZoneGetIncomePage(ctx *gin.Context, mid int64) (*vasproto.IncomePageData, error) {
|
||||
data := new(vasproto.IncomePageData)
|
||||
// 获取钻石、可提现钻石、待结算钻石
|
||||
wallet, _ := v.CheckWalletExist(ctx, nil, mid)
|
||||
data.Diamonds = wallet.GetDiamonds()
|
||||
data.WithdrawDiamonds = wallet.GetWithdrawDiamonds()
|
||||
data.WaitDealIncome = wallet.GetDiamonds() - wallet.GetWithdrawDiamonds()
|
||||
|
||||
// 获取今日收入
|
||||
todayIncome, err := v.store.GetTodayIncome(ctx, nil, mid)
|
||||
if err != nil {
|
||||
logger.Error("GetTodayIncome fail, mid: %v, err: %v", mid, err)
|
||||
}
|
||||
data.TodayIncome = todayIncome
|
||||
|
||||
// 获取看病
|
||||
doc, err := v.store.GetZoneUserIncome(ctx, mid)
|
||||
if err != nil {
|
||||
logger.Error("GetZoneUserIncome fail, mid: %v, err: %v", mid, err)
|
||||
}
|
||||
if doc != nil {
|
||||
data.WeekDashboard = doc.WeekDashboard
|
||||
data.IncomeFromDashboard = doc.WeekFromDashboard
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
|
|
@ -1165,3 +1165,13 @@ func (s *Service) ApplepayCallback(ctx *gin.Context, notify applepaycli.Applepay
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) VasIncomePage(ctx *gin.Context, req *vasproto.IncomePageReq) (data *vasproto.IncomePageData, ec errcode.ErrCode, err error) {
|
||||
data, err = _DefaultVas.ZoneGetIncomePage(ctx, req.Mid)
|
||||
ec, err = errs.DealVasErr(err)
|
||||
if err != nil {
|
||||
logger.Error("ZoneGetIncomePage fail, err: %v", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -155,3 +155,20 @@ type ZoneMomentStat struct {
|
|||
Ct int64 `json:"ct" bson:"ct"` //
|
||||
Ut int64 `json:"ut" bson:"ut"` //
|
||||
}
|
||||
|
||||
// 收入表
|
||||
type WeekDashboardSt struct {
|
||||
Date string `json:"date" bson:"date"` // 日期 x轴
|
||||
Income int64 `json:"income" bson:"income"` // 收入 y轴
|
||||
}
|
||||
|
||||
type IncomeFromDashboardSt struct {
|
||||
Desc string `json:"desc" bson:"desc"` // 描述
|
||||
Income int64 `json:"income" bson:"income"` // 收入
|
||||
}
|
||||
|
||||
type UserIncome struct {
|
||||
Mid int64 `json:"mid" bson:"_id"`
|
||||
WeekDashboard []WeekDashboardSt `json:"week_dashboard" bson:"week_dashboard"`
|
||||
WeekFromDashboard []IncomeFromDashboardSt `json:"week_from_dashboard" bson:"week_from_dashboard"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue