fix: 修复评价争议参与者 ID 映射
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user