Explorar o código

fix:credit_usage/list

jimmyyem hai 2 semanas
pai
achega
a6cea85c23

+ 1 - 0
desc/wechat/credit_usage.api

@@ -36,6 +36,7 @@ type (
 
         // operator | 积分变动人 
         Operator  *string `json:"operator,optional"`
+		OperatorName *string `json:"operatorName,optional"`
     }
 
     // The response data of credit usage list | CreditUsage列表数据

+ 1 - 0
internal/logic/UsageDetail/get_usage_detail_list_logic.go

@@ -108,6 +108,7 @@ func (l *GetUsageDetailListLogic) GetUsageDetailList(req *types.UsageDetailListR
 			departmentInfo, err := l.svcCtx.CoreRpc.GetDepartmentById(l.ctx, &core.IDReq{Id: v.OrganizationID})
 			if err == nil {
 				organizationName = *departmentInfo.Name
+				orgaMap[v.OrganizationID] = organizationName
 			}
 		}
 

+ 19 - 0
internal/logic/credit_usage/get_credit_usage_list_logic.go

@@ -76,6 +76,7 @@ func (l *GetCreditUsageListLogic) GetCreditUsageList(req *types.CreditUsageListR
 	resp.Data.Total = data.PageDetails.Total
 
 	orgaMap := make(map[uint64]string)
+	operMap := make(map[string]string)
 
 	for _, v := range data.List {
 		organizationName := ""
@@ -85,6 +86,23 @@ func (l *GetCreditUsageListLogic) GetCreditUsageList(req *types.CreditUsageListR
 			departmentInfo, err := l.svcCtx.CoreRpc.GetDepartmentById(l.ctx, &core.IDReq{Id: v.OrganizationID})
 			if err == nil {
 				organizationName = *departmentInfo.Name
+				orgaMap[v.OrganizationID] = organizationName
+			}
+		}
+
+		operatorName := ""
+		if v.Operator != "" {
+			if uname, ok := operMap[v.Operator]; ok {
+				operatorName = uname
+			} else {
+				userInfo, err := l.svcCtx.CoreRpc.GetUserById(l.ctx, &core.UUIDReq{Id: v.Operator})
+				if err == nil {
+					operatorName = *userInfo.Nickname
+					if operatorName == "" {
+						operatorName = *userInfo.Username
+					}
+					operMap[v.Operator] = operatorName
+				}
 			}
 		}
 
@@ -108,6 +126,7 @@ func (l *GetCreditUsageListLogic) GetCreditUsageList(req *types.CreditUsageListR
 				Nid:              &v.Nid,
 				Reason:           &v.Reason,
 				Operator:         &v.Operator,
+				OperatorName:     &operatorName,
 			})
 	}
 

+ 2 - 1
internal/types/types.go

@@ -3689,7 +3689,8 @@ type CreditUsageInfo struct {
 	// reason | 积分变动原因
 	Reason *string `json:"reason,optional"`
 	// operator | 积分变动人
-	Operator *string `json:"operator,optional"`
+	Operator     *string `json:"operator,optional"`
+	OperatorName *string `json:"operatorName,optional"`
 }
 
 // The response data of credit usage list | CreditUsage列表数据