Merge branch 'dev-lwl/zone' into test
This commit is contained in:
commit
3dc8a84b7c
|
@ -95,3 +95,33 @@ type OpZoneUnlockCollaboratorsParam struct {
|
||||||
CollaboratorMids []int64 `json:"collaborator_mids"` // 协作者的mids
|
CollaboratorMids []int64 `json:"collaborator_mids"` // 协作者的mids
|
||||||
StreamerMid int64 `json:"streamer_mid"` // 主播的mid
|
StreamerMid int64 `json:"streamer_mid"` // 主播的mid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OpZoneRefundListParam struct {
|
||||||
|
Mid int64 `json:"mid"` // 用户mid
|
||||||
|
UserId int64 `json:"user_id"` // 用户user_id
|
||||||
|
Zid int64 `json:"zid"` // 空间id
|
||||||
|
OrderId string `json:"order_id"` // 订单id
|
||||||
|
St int64 `json:"st"` // 开始时间戳
|
||||||
|
Et int64 `json:"et"` // 结束时间戳
|
||||||
|
Offset int `json:"offset"`
|
||||||
|
Limit int `json:"limit"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OpZoneRefundVO struct {
|
||||||
|
OrderId string `json:"order_id"` // 订单id
|
||||||
|
OrderStatus int32 `json:"order_status"` // 订单状态
|
||||||
|
OrderStatusDesc string `json:"order_status_desc"` // 订单状态描述
|
||||||
|
Ct int64 `json:"ct"` // 订单创建时间
|
||||||
|
RefundT int64 `json:"refund_t"` // 订单退款时间
|
||||||
|
Zid int64 `json:"zid"` // 空间id
|
||||||
|
ProductName string `json:"product_name"` // 商品名
|
||||||
|
Money int64 `json:"money"` // 退款金额
|
||||||
|
Mid int64 `json:"mid"` // 购买用户 mid
|
||||||
|
UserUserId int64 `json:"user_user_id"` // 购买用户 user_id
|
||||||
|
Uid int64 `json:"uid"` // 主播 mid
|
||||||
|
StreamerUserId int64 `json:"streamer_user_id"` // 主播 user_id
|
||||||
|
}
|
||||||
|
|
||||||
|
type OpZoneRefundListData struct {
|
||||||
|
List []*OpZoneRefundVO `json:"list"`
|
||||||
|
}
|
||||||
|
|
|
@ -299,6 +299,7 @@ func Init(r *gin.Engine) {
|
||||||
opVasPayGroup.POST("refund_order", middleware.JSONParamValidator(vasproto.RefundOrderReq{}), RefundOrder)
|
opVasPayGroup.POST("refund_order", middleware.JSONParamValidator(vasproto.RefundOrderReq{}), RefundOrder)
|
||||||
opVasPayGroup.POST("refund_coin_order", middleware.JSONParamValidator(vasproto.RefundCoinOrderReq{}), RefundCoinOrder)
|
opVasPayGroup.POST("refund_coin_order", middleware.JSONParamValidator(vasproto.RefundCoinOrderReq{}), RefundCoinOrder)
|
||||||
opVasPayGroup.POST("wxpay_callback_manual", middleware.JSONParamValidator(vasproto.WxpayCallbackManualParam{}), WxpayCallbackManual)
|
opVasPayGroup.POST("wxpay_callback_manual", middleware.JSONParamValidator(vasproto.WxpayCallbackManualParam{}), WxpayCallbackManual)
|
||||||
|
opVasPayGroup.POST("zone_refund_list", middleware.JSONParamValidator(zoneproto.OpZoneRefundListParam{}), OpZoneRefundList)
|
||||||
|
|
||||||
// 验证码
|
// 验证码
|
||||||
opVeriCodeGroup := r.Group("/op/veri_code", PrepareOp())
|
opVeriCodeGroup := r.Group("/op/veri_code", PrepareOp())
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"service/api/errcode"
|
"service/api/errcode"
|
||||||
vasproto "service/api/proto/vas/proto"
|
vasproto "service/api/proto/vas/proto"
|
||||||
|
zoneproto "service/api/proto/zone/proto"
|
||||||
"service/app/mix/service"
|
"service/app/mix/service"
|
||||||
"service/bizcommon/util"
|
"service/bizcommon/util"
|
||||||
"service/library/logger"
|
"service/library/logger"
|
||||||
|
@ -42,3 +43,20 @@ func OpOrderList(ctx *gin.Context) {
|
||||||
}
|
}
|
||||||
ReplyOk(ctx, data)
|
ReplyOk(ctx, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func OpZoneRefundList(ctx *gin.Context) {
|
||||||
|
req := ctx.MustGet("client_req").(*zoneproto.OpZoneRefundListParam)
|
||||||
|
if req.Limit <= 0 {
|
||||||
|
req.Limit = 1000
|
||||||
|
}
|
||||||
|
list, ec := service.DefaultService.OpZoneRefundList(ctx, req)
|
||||||
|
if ec != errcode.ErrCodeVasSrvOk {
|
||||||
|
logger.Error("OpOrderList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||||
|
ReplyErrCodeMsg(ctx, ec)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data := &zoneproto.OpZoneRefundListData{
|
||||||
|
List: list,
|
||||||
|
}
|
||||||
|
ReplyOk(ctx, data)
|
||||||
|
}
|
||||||
|
|
|
@ -232,6 +232,25 @@ func (m *Mysql) GetOrdersByMid(ctx *gin.Context, tx *sqlx.Tx, mid int64, offset,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Mysql) GetOrdersByIds(ctx *gin.Context, tx *sqlx.Tx, ids []string) (list []*dbstruct.Order, err error) {
|
||||||
|
list = make([]*dbstruct.Order, 0)
|
||||||
|
sqlStr := fmt.Sprintf("select * from %s where id in (%s)", TableOrder, util.Convert2SqlArr(ids))
|
||||||
|
if tx != nil {
|
||||||
|
err = tx.SelectContext(ctx, &list, sqlStr)
|
||||||
|
} else {
|
||||||
|
db := m.getDBVas()
|
||||||
|
err = db.SelectContext(ctx, &list, sqlStr)
|
||||||
|
}
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
err = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 获取订单
|
// 获取订单
|
||||||
func (m *Mysql) GetOrders(ctx *gin.Context, tx *sqlx.Tx, mid, st, et int64, offset, limit int) (list []*dbstruct.Order, err error) {
|
func (m *Mysql) GetOrders(ctx *gin.Context, tx *sqlx.Tx, mid, st, et int64, offset, limit int) (list []*dbstruct.Order, err error) {
|
||||||
list = make([]*dbstruct.Order, 0)
|
list = make([]*dbstruct.Order, 0)
|
||||||
|
|
|
@ -462,3 +462,40 @@ func (m *Mysql) CreateZoneRefundHis(ctx *gin.Context, tx *sqlx.Tx, o *dbstruct.Z
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取空间退款记录
|
||||||
|
func (m *Mysql) GetZoneRefundHisList(ctx *gin.Context, tx *sqlx.Tx, mid, zid int64, orderId string, st, et int64, offset, limit int) (list []*dbstruct.ZoneRefundHis, err error) {
|
||||||
|
list = make([]*dbstruct.ZoneRefundHis, 0)
|
||||||
|
var (
|
||||||
|
sqlStr string
|
||||||
|
args = make([]any, 0)
|
||||||
|
)
|
||||||
|
switch {
|
||||||
|
case mid > 0:
|
||||||
|
sqlStr = fmt.Sprintf(fmt.Sprintf("select * from %s where mid=? order by ct desc", TableVasZoneRefundHis))
|
||||||
|
args = []any{mid}
|
||||||
|
case zid > 0:
|
||||||
|
sqlStr = fmt.Sprintf(fmt.Sprintf("select * from %s where zid=? order by ct desc", TableVasZoneRefundHis))
|
||||||
|
args = []any{zid}
|
||||||
|
case len(orderId) > 0:
|
||||||
|
sqlStr = fmt.Sprintf(fmt.Sprintf("select * from %s where order_id=? order by ct desc", TableVasZoneRefundHis))
|
||||||
|
args = []any{orderId}
|
||||||
|
default:
|
||||||
|
sqlStr = fmt.Sprintf("select * from %s where ct>=%d and ct<%d limit %d offset %d", TableVasZoneRefundHis, st, et, limit, offset)
|
||||||
|
}
|
||||||
|
|
||||||
|
if tx != nil {
|
||||||
|
err = tx.SelectContext(ctx, &list, sqlStr, args...)
|
||||||
|
} else {
|
||||||
|
db := m.getDBVas()
|
||||||
|
err = db.SelectContext(ctx, &list, sqlStr, args...)
|
||||||
|
}
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
err = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -1360,6 +1360,15 @@ func (v *Vas) GetOrderById(ctx *gin.Context, tx *sqlx.Tx, id string) (*dbstruct.
|
||||||
return v.store.GetOrderById(ctx, tx, id)
|
return v.store.GetOrderById(ctx, tx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *Vas) GetOrderMapByIds(ctx *gin.Context, tx *sqlx.Tx, ids []string) (map[string]*dbstruct.Order, error) {
|
||||||
|
m := make(map[string]*dbstruct.Order, 0)
|
||||||
|
list, _ := v.store.GetOrdersByIds(ctx, tx, ids)
|
||||||
|
for _, v := range list {
|
||||||
|
m[v.GetID()] = v
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (v *Vas) GetOrderCountGroupByStatus(ctx *gin.Context, req *vasproto.GetOrderByStatusReq) ([]*dbstruct.VasOrderStatusCount, error) {
|
func (v *Vas) GetOrderCountGroupByStatus(ctx *gin.Context, req *vasproto.GetOrderByStatusReq) ([]*dbstruct.VasOrderStatusCount, error) {
|
||||||
return v.store.GetOrderCountGroupByStatus(ctx, nil, req.OrderStatuses, req.CtStart, req.CtEnd)
|
return v.store.GetOrderCountGroupByStatus(ctx, nil, req.OrderStatuses, req.CtStart, req.CtEnd)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package logic
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
vasproto "service/api/proto/vas/proto"
|
vasproto "service/api/proto/vas/proto"
|
||||||
|
zoneproto "service/api/proto/zone/proto"
|
||||||
"service/dbstruct"
|
"service/dbstruct"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,3 +24,8 @@ func (v *Vas) OpOrderList(ctx *gin.Context, req *vasproto.OpOrderListReq) ([]*db
|
||||||
}
|
}
|
||||||
return v.store.GetOrders(ctx, nil, req.Mid, req.St, req.Et, req.Offset, req.Limit)
|
return v.store.GetOrders(ctx, nil, req.Mid, req.St, req.Et, req.Offset, req.Limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取订单
|
||||||
|
func (v *Vas) OpZoneRefundList(ctx *gin.Context, req *zoneproto.OpZoneRefundListParam) ([]*dbstruct.ZoneRefundHis, error) {
|
||||||
|
return v.store.GetZoneRefundHisList(ctx, nil, req.Mid, req.Zid, req.OrderId, req.St, req.Et, req.Offset, req.Limit)
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
accountproto "service/api/proto/account/proto"
|
accountproto "service/api/proto/account/proto"
|
||||||
vasproto "service/api/proto/vas/proto"
|
vasproto "service/api/proto/vas/proto"
|
||||||
vericodeproto "service/api/proto/vericode/proto"
|
vericodeproto "service/api/proto/vericode/proto"
|
||||||
|
zoneproto "service/api/proto/zone/proto"
|
||||||
"service/bizcommon/util"
|
"service/bizcommon/util"
|
||||||
"service/dbstruct"
|
"service/dbstruct"
|
||||||
"service/library/logger"
|
"service/library/logger"
|
||||||
|
@ -940,3 +941,76 @@ func (s *Service) ZoneExit(ctx *gin.Context, req *vasproto.ZoneExitReq) (ec errc
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Service) OpZoneRefundList(ctx *gin.Context, req *zoneproto.OpZoneRefundListParam) (list []*zoneproto.OpZoneRefundVO, ec errcode.ErrCode) {
|
||||||
|
list = make([]*zoneproto.OpZoneRefundVO, 0)
|
||||||
|
if req.UserId > 0 && req.Mid <= 0 {
|
||||||
|
a, _ := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{
|
||||||
|
UserId: goproto.Int64(req.UserId),
|
||||||
|
})
|
||||||
|
if a != nil && a.Mid != nil {
|
||||||
|
req.Mid = *a.Mid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取空间退款历史
|
||||||
|
hisList, err := _DefaultVas.OpZoneRefundList(ctx, req)
|
||||||
|
ec, err = errs.DealVasErr(err)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("OpZoneRefundList fail, req: %v, err: %v", util.ToJson(req), err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取订单
|
||||||
|
orderIds := make([]string, 0)
|
||||||
|
for _, h := range hisList {
|
||||||
|
orderIds = append(orderIds, h.GetOrderId())
|
||||||
|
}
|
||||||
|
orderMap, _ := _DefaultVas.GetOrderMapByIds(ctx, nil, orderIds)
|
||||||
|
|
||||||
|
// 获取用户
|
||||||
|
mids := make([]int64, 0)
|
||||||
|
for _, h := range hisList {
|
||||||
|
mids = append(mids, h.GetMid())
|
||||||
|
}
|
||||||
|
for _, o := range orderMap {
|
||||||
|
mids = append(mids, o.GetUid())
|
||||||
|
}
|
||||||
|
acntMap, _ := _DefaultAccount.GetAccountMapByMids(ctx, mids)
|
||||||
|
|
||||||
|
// 组装
|
||||||
|
for _, h := range hisList {
|
||||||
|
o := orderMap[h.GetOrderId()]
|
||||||
|
if o == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
userUserId = int64(0)
|
||||||
|
streamerUserId = int64(0)
|
||||||
|
)
|
||||||
|
if a, ok := acntMap[o.GetMid()]; ok {
|
||||||
|
userUserId = util.DerefInt64(a.UserId)
|
||||||
|
}
|
||||||
|
if a, ok := acntMap[o.GetUid()]; ok {
|
||||||
|
streamerUserId = util.DerefInt64(a.UserId)
|
||||||
|
}
|
||||||
|
|
||||||
|
item := &zoneproto.OpZoneRefundVO{
|
||||||
|
OrderId: o.GetID(),
|
||||||
|
OrderStatus: o.GetOrderStatus(),
|
||||||
|
OrderStatusDesc: dbstruct.OrderStatusDescMap[o.GetOrderStatus()],
|
||||||
|
Ct: o.GetCt(),
|
||||||
|
RefundT: h.GetCt(),
|
||||||
|
Zid: h.GetZid(),
|
||||||
|
ProductName: dbstruct.ProductIdDescMap[o.GetProductId()],
|
||||||
|
Money: o.GetPayAmount(),
|
||||||
|
Mid: o.GetMid(),
|
||||||
|
UserUserId: userUserId,
|
||||||
|
Uid: o.GetUid(),
|
||||||
|
StreamerUserId: streamerUserId,
|
||||||
|
}
|
||||||
|
list = append(list, item)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue