fix: 修复评价争议参与者 ID 映射
This commit is contained in:
@@ -9,4 +9,5 @@ type Config struct {
|
||||
rest.RestConf
|
||||
DisputeRpcConf zrpc.RpcClientConf
|
||||
OrderRpcConf zrpc.RpcClientConf
|
||||
PlayerRpcConf zrpc.RpcClientConf
|
||||
}
|
||||
|
||||
@@ -53,11 +53,16 @@ func (l *CreateDisputeLogic) CreateDispute(req *types.CreateDisputeReq) (resp *t
|
||||
return nil, errors.New("order status does not allow disputes")
|
||||
}
|
||||
|
||||
consumerID, playerUserID, err := orderParticipantUserIDs(l.ctx, l.svcCtx, order)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var respondentID int64
|
||||
if uid == order.GetConsumerId() {
|
||||
respondentID = order.GetPlayerId()
|
||||
} else if uid == order.GetPlayerId() {
|
||||
respondentID = order.GetConsumerId()
|
||||
if uid == consumerID {
|
||||
respondentID = playerUserID
|
||||
} else if uid == playerUserID {
|
||||
respondentID = consumerID
|
||||
} else {
|
||||
return nil, errors.New("not a participant of this order")
|
||||
}
|
||||
|
||||
@@ -44,7 +44,11 @@ func (l *GetOrderDisputeLogic) GetOrderDispute(req *types.DisputePathId) (resp *
|
||||
if order == nil {
|
||||
return nil, errors.New("order not found")
|
||||
}
|
||||
if uid != order.GetConsumerId() && uid != order.GetPlayerId() {
|
||||
consumerID, playerUserID, err := orderParticipantUserIDs(l.ctx, l.svcCtx, order)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if uid != consumerID && uid != playerUserID {
|
||||
return nil, errors.New("not a participant of this order")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package dispute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"juwan-backend/app/dispute/api/internal/svc"
|
||||
"juwan-backend/app/dispute/api/internal/types"
|
||||
"juwan-backend/app/dispute/rpc/disputeservice"
|
||||
"juwan-backend/app/order/rpc/orderservice"
|
||||
"juwan-backend/app/player/rpc/playerservice"
|
||||
)
|
||||
|
||||
func formatUnix(ts int64) string {
|
||||
@@ -95,3 +100,18 @@ func detailsJSON(values map[string]any) string {
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func orderParticipantUserIDs(ctx context.Context, svcCtx *svc.ServiceContext, order *orderservice.Orders) (int64, int64, error) {
|
||||
if order == nil {
|
||||
return 0, 0, errors.New("order not found")
|
||||
}
|
||||
playerResp, err := svcCtx.PlayerRpc.GetPlayersById(ctx, &playerservice.GetPlayersByIdReq{Id: order.GetPlayerId()})
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
player := playerResp.GetPlayers()
|
||||
if player == nil || player.GetUserId() <= 0 {
|
||||
return 0, 0, errors.New("player not found")
|
||||
}
|
||||
return order.GetConsumerId(), player.GetUserId(), nil
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"juwan-backend/app/dispute/api/internal/config"
|
||||
"juwan-backend/app/dispute/rpc/disputeservice"
|
||||
"juwan-backend/app/order/rpc/orderservice"
|
||||
"juwan-backend/app/player/rpc/playerservice"
|
||||
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
)
|
||||
@@ -12,6 +13,7 @@ type ServiceContext struct {
|
||||
Config config.Config
|
||||
DisputeRpc disputeservice.DisputeService
|
||||
OrderRpc orderservice.OrderService
|
||||
PlayerRpc playerservice.PlayerService
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
@@ -19,5 +21,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
Config: c,
|
||||
DisputeRpc: disputeservice.NewDisputeService(zrpc.MustNewClient(c.DisputeRpcConf)),
|
||||
OrderRpc: orderservice.NewOrderService(zrpc.MustNewClient(c.OrderRpcConf)),
|
||||
PlayerRpc: playerservice.NewPlayerService(zrpc.MustNewClient(c.PlayerRpcConf)),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user