Pārlūkot izejas kodu

fix:积分详情带用户信息

jimmyyem 1 mēnesi atpakaļ
vecāks
revīzija
c8a456028a

+ 1 - 0
desc/wechat/credit_usage.api

@@ -7,6 +7,7 @@ type (
 
         // user_id | 用户ID 
         UserId  *string `json:"userId,optional"`
+		UserInfo UserInfo `json:"userInfo,optional"`
 
         // number | 积分改变量 
         Number  *float32 `json:"number,optional"`

+ 2 - 0
internal/logic/credit_balance/operate_credit_balance_logic.go

@@ -49,6 +49,7 @@ func (l *OperateCreditBalanceLogic) OperateCreditBalance(req *types.CreditBalanc
 		ntype = 1
 	}
 
+	userId := l.ctx.Value("userId").(string)
 	tx, err := l.svcCtx.DB.Tx(context.Background())
 	_, err = tx.CreditUsage.Create().
 		SetUserID("").
@@ -58,6 +59,7 @@ func (l *OperateCreditBalanceLogic) OperateCreditBalance(req *types.CreditBalanc
 		SetTable("").
 		SetReason(*req.Reason).
 		SetOrganizationID(*req.OrganizationId).
+		SetOperator(userId).
 		Save(l.ctx)
 	if err != nil {
 		l.Logger.Errorf("create credit_usage error:%v\n", err)

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

@@ -51,6 +51,16 @@ func (l *GetCreditUsageListLogic) GetCreditUsageList(req *types.CreditUsageListR
 	}
 
 	for _, v := range data.List {
+		bUserInfo := types.UserInfo{}
+		if v.UserID != "" {
+			userInfo, _ := l.svcCtx.CoreRpc.GetUserById(l.ctx, &core.UUIDReq{Id: v.UserID})
+			if userInfo != nil {
+				bUserInfo.Id = userInfo.Id
+				bUserInfo.Username = userInfo.Username
+				bUserInfo.Nickname = userInfo.Nickname
+				bUserInfo.Avatar = userInfo.Avatar
+			}
+		}
 		resp.Data.Data = append(resp.Data.Data,
 			types.CreditUsageInfo{
 				BaseIDInfo: types.BaseIDInfo{
@@ -59,6 +69,7 @@ func (l *GetCreditUsageListLogic) GetCreditUsageList(req *types.CreditUsageListR
 					UpdatedAt: pointy.GetPointer(v.UpdatedAt.UnixMilli()),
 				},
 				UserId:           &v.UserID,
+				UserInfo:         bUserInfo,
 				Number:           &v.Number,
 				Status:           &v.Status,
 				Ntype:            &v.Ntype,

+ 2 - 1
internal/types/types.go

@@ -3303,7 +3303,8 @@ type CreditBalanceOperateReq struct {
 type CreditUsageInfo struct {
 	BaseIDInfo
 	// user_id | 用户ID
-	UserId *string `json:"userId,optional"`
+	UserId   *string  `json:"userId,optional"`
+	UserInfo UserInfo `json:"userInfo,optional"`
 	// number | 积分改变量
 	Number *float32 `json:"number,optional"`
 	// status | 状态 1-正常 2-禁用