op order_list

This commit is contained in:
lwl0608 2024-01-17 21:57:45 +08:00
parent 15e2a33218
commit c6085f42d6
6 changed files with 108 additions and 19 deletions

View File

@ -10,8 +10,8 @@ type OpCreateOrderReq struct {
type OpCreateOrderData struct{}
// 获取订单列表
type OpOrderListReq struct {
// 获取金币订单列表
type OpCoinOrderListReq struct {
Mid int64 `json:"mid"` // 用户mid
UserName int64 `json:"user_name"` // 用户昵称
St int64 `json:"st"` // 开始时间戳
@ -21,11 +21,20 @@ type OpOrderListReq struct {
Limit int `json:"limit"`
}
type OpOrderVO struct {
type OpCoinOrderVO struct {
Mid int64 `json:"mid"`
UserUserId int64 `json:"user_user_id"`
Uid int64 `json:"uid"`
StreamerUserId int64 `json:"streamer_user_id"`
OrderId string `json:"order_id"`
OrderStatus int32 `json:"order_status"`
OrderStatusDesc string `json:"order_status_desc"`
Coins int64 `json:"coins"`
Ct int64 `json:"ct"`
}
type OpOrderListData struct {
List []*OpOrderVO `json:"list"`
Offset int `json:"offset"`
More int `json:"more"`
type OpCoinOrderListData struct {
List []*OpCoinOrderVO `json:"list"`
//Offset int `json:"offset"`
//More int `json:"more"`
}

View File

@ -198,7 +198,7 @@ func Init(r *gin.Engine) {
opVasPayGroup := r.Group("/op/vas", PrepareOp())
opVasPayGroup.POST("create_order", middleware.JSONParamValidator(vasproto.OpCreateOrderReq{}), OpCreateOrder)
opVasPayGroup.POST("order_list")
opVasPayGroup.POST("order_list", middleware.JSONParamValidator(vasproto.OpCoinOrderListReq{}), OpOrderList)
// 验证码
opVeriCodeGroup := r.Group("/op/veri_code", PrepareOp())

View File

@ -2,15 +2,23 @@ package controller
import (
"github.com/gin-gonic/gin"
"service/api/errcode"
vasproto "service/api/proto/vas/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
)
func OpOrderList(ctx *gin.Context) {
//req := ctx.MustGet("client_req").(*vasproto.OpOrderListReq)
//data, ec := service.DefaultService.H5DirectUnlockWechat(ctx, req)
//if ec != errcode.ErrCodeVasSrvOk {
// logger.Error("H5DirectUnlockWechat fail, req: %v, ec: %v", util.ToJson(req), ec)
// ReplyErrCodeMsg(ctx, ec)
// return
//}
//ReplyOk(ctx, data)
req := ctx.MustGet("client_req").(*vasproto.OpCoinOrderListReq)
list, ec := service.DefaultService.OpCoinOrderList(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("OpCoinOrderList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &vasproto.OpCoinOrderListData{
List: list,
}
ReplyOk(ctx, data)
}

View File

@ -408,6 +408,25 @@ func (m *Mysql) GetCoinOrderById(ctx *gin.Context, tx *sqlx.Tx, id string) (orde
return
}
// 获取金币订单
func (m *Mysql) GetCoinOrders(ctx *gin.Context, tx *sqlx.Tx, mid, st, et int64) (list []*dbstruct.CoinOrder, err error) {
list = make([]*dbstruct.CoinOrder, 0)
sqlStr := fmt.Sprintf("select * from %s where ct>=%d and ct<%d", TableCoinOrder, st, et)
if mid > 0 {
sqlStr = fmt.Sprintf("select * from %s where mid=%d", TableCoinOrder, mid)
}
if tx != nil {
err = tx.SelectContext(ctx, &list, sqlStr)
} else {
db := m.getDBVas()
err = db.SelectContext(ctx, &list, sqlStr)
}
if err != nil {
return
}
return
}
// 获取金币订单 for update
func (m *Mysql) GetCoinOrderByIdForUpdate(ctx *gin.Context, tx *sqlx.Tx, id string) (order *dbstruct.CoinOrder, err error) {
var tmpOrder dbstruct.CoinOrder

View File

@ -1,6 +1,12 @@
package logic
import (
"github.com/gin-gonic/gin"
vasproto "service/api/proto/vas/proto"
"service/dbstruct"
)
// 获取订单
//func (v *Vas) GetOrders(ctx *gin.Context, mid int64) (*dbstruct.CoinOrder, error) {
// return v.store.GetCoinOrderById(ctx, nil, id)
//}
func (v *Vas) OpCoinOrderList(ctx *gin.Context, req *vasproto.OpCoinOrderListReq) ([]*dbstruct.CoinOrder, error) {
return v.store.GetCoinOrders(ctx, nil, req.Mid, req.St, req.Et)
}

View File

@ -447,3 +447,50 @@ func (s *Service) WithdrawApply(ctx *gin.Context, req *vasproto.WithdrawApplyReq
}
return
}
func (s *Service) OpCoinOrderList(ctx *gin.Context, req *vasproto.OpCoinOrderListReq) (list []*vasproto.OpCoinOrderVO, ec errcode.ErrCode) {
list = make([]*vasproto.OpCoinOrderVO, 0)
// 获取金币订单
coinOrders, err := _DefaultVas.OpCoinOrderList(ctx, req)
ec, err = errs.DealVasErr(err)
if err != nil {
logger.Error("OpCoinOrderList fail, req: %v, err: %v", util.ToJson(req), err)
return
}
// 获取用户信息
mids := make([]int64, 0)
for _, co := range coinOrders {
mids = append(mids, co.GetMid())
mids = append(mids, co.GetUid())
}
acntMap, _ := _DefaultAccount.GetAccountMapByMids(ctx, mids)
// 组装
for _, co := range coinOrders {
var (
userUserId = int64(0)
streamerUserId = int64(0)
)
if a, ok := acntMap[co.GetMid()]; ok {
userUserId = util.DerefInt64(a.UserId)
}
if a, ok := acntMap[co.GetUid()]; ok {
streamerUserId = util.DerefInt64(a.UserId)
}
item := &vasproto.OpCoinOrderVO{
Mid: co.GetMid(),
UserUserId: userUserId,
Uid: co.GetUid(),
StreamerUserId: streamerUserId,
OrderId: co.GetID(),
OrderStatus: co.GetOrderStatus(),
OrderStatusDesc: dbstruct.CoinOrderStatusDescMap[co.GetOrderStatus()],
Coins: co.GetCoins(),
Ct: co.GetCt(),
}
list = append(list, item)
}
return
}