Explorar o código

feat:core 投标状态更新操作记录查询

fuwencai %!s(int64=2) %!d(string=hai) anos
pai
achega
b6fc0fa7ad

+ 9 - 8
jyBXCore/rpc/bxcore.proto

@@ -233,6 +233,7 @@ message ParticipateContentData{
   string channelName = 4; // 渠道名称
   string channelName = 4; // 渠道名称
   string channelPerson = 5; // 联系人
   string channelPerson = 5; // 联系人
   string channelPhone = 6; //联系电话
   string channelPhone = 6; //联系电话
+  string winner = 7;// 中标单位
 }
 }
 
 
 message ParticipateContentRes{
 message ParticipateContentRes{
@@ -258,18 +259,18 @@ message ParticipateRecordsReq{
 }
 }
 // 参标操作记录返回
 // 参标操作记录返回
 message ParticipateRecords{
 message ParticipateRecords{
-  string recordsData = 1;
-  string updateDate = 2;
-  string updatePerson = 3;
+  string recordsData = 1; // 操作记录
+  string updateDate = 2;  // 更新时间
+  string updatePerson = 3; // 更新人
+}
+message ParticipateRecordsData {
+  repeated ParticipateRecords list = 1; // 操作记录
+  int64 total = 2 ;
 }
 }
-
 message ParticipateRecordsRes{
 message ParticipateRecordsRes{
   int64 err_code = 1;
   int64 err_code = 1;
   string err_msg = 2;
   string err_msg = 2;
-  message Data {
-    repeated ParticipateRecords list = 1; // 操作记录
-    int64 total = 2 ;
-  }
+  ParticipateRecordsData data = 3;
 }
 }
 // 当前部门/企业下参标人员信息
 // 当前部门/企业下参标人员信息
 message ParticipatePersonsReq{
 message ParticipatePersonsReq{

+ 37 - 37
jyBXCore/rpc/bxcore/bxcore.go

@@ -13,43 +13,43 @@ import (
 )
 )
 
 
 type (
 type (
-	BidTypeReq                 = bxcore.BidTypeReq
-	PInfo                      = bxcore.PInfo
-	ParticipateActionReq       = bxcore.ParticipateActionReq
-	ParticipateActionRes       = bxcore.ParticipateActionRes
-	ParticipateContentData     = bxcore.ParticipateContentData
-	ParticipateContentReq      = bxcore.ParticipateContentReq
-	ParticipateContentRes      = bxcore.ParticipateContentRes
-	ParticipateData            = bxcore.ParticipateData
-	ParticipateDetailInfo      = bxcore.ParticipateDetailInfo
-	ParticipateInfoReq         = bxcore.ParticipateInfoReq
-	ParticipateInfoRes         = bxcore.ParticipateInfoRes
-	ParticipateList            = bxcore.ParticipateList
-	ParticipateListReq         = bxcore.ParticipateListReq
-	ParticipateListRes         = bxcore.ParticipateListRes
-	ParticipatePerson          = bxcore.ParticipatePerson
-	ParticipatePersonsReq      = bxcore.ParticipatePersonsReq
-	ParticipatePersonsRes      = bxcore.ParticipatePersonsRes
-	ParticipateRecords         = bxcore.ParticipateRecords
-	ParticipateRecordsReq      = bxcore.ParticipateRecordsReq
-	ParticipateRecordsRes      = bxcore.ParticipateRecordsRes
-	ParticipateRecordsRes_Data = bxcore.ParticipateRecordsRes_Data
-	ParticipateSetUpInfo       = bxcore.ParticipateSetUpInfo
-	ParticipateSetUpInfoReq    = bxcore.ParticipateSetUpInfoReq
-	ParticipateSetUpInfoRes    = bxcore.ParticipateSetUpInfoRes
-	ParticipateShowReq         = bxcore.ParticipateShowReq
-	ParticipateShowRes         = bxcore.ParticipateShowRes
-	RemindRuleReq              = bxcore.RemindRuleReq
-	SearchData                 = bxcore.SearchData
-	SearchLimitReq             = bxcore.SearchLimitReq
-	SearchLimitResp            = bxcore.SearchLimitResp
-	SearchList                 = bxcore.SearchList
-	SearchReq                  = bxcore.SearchReq
-	SearchResp                 = bxcore.SearchResp
-	ShowInfo                   = bxcore.ShowInfo
-	UpdateBidStatusReq         = bxcore.UpdateBidStatusReq
-	UpdateBidStatusRes         = bxcore.UpdateBidStatusRes
-	WinnerInfo                 = bxcore.WinnerInfo
+	BidTypeReq              = bxcore.BidTypeReq
+	PInfo                   = bxcore.PInfo
+	ParticipateActionReq    = bxcore.ParticipateActionReq
+	ParticipateActionRes    = bxcore.ParticipateActionRes
+	ParticipateContentData  = bxcore.ParticipateContentData
+	ParticipateContentReq   = bxcore.ParticipateContentReq
+	ParticipateContentRes   = bxcore.ParticipateContentRes
+	ParticipateData         = bxcore.ParticipateData
+	ParticipateDetailInfo   = bxcore.ParticipateDetailInfo
+	ParticipateInfoReq      = bxcore.ParticipateInfoReq
+	ParticipateInfoRes      = bxcore.ParticipateInfoRes
+	ParticipateList         = bxcore.ParticipateList
+	ParticipateListReq      = bxcore.ParticipateListReq
+	ParticipateListRes      = bxcore.ParticipateListRes
+	ParticipatePerson       = bxcore.ParticipatePerson
+	ParticipatePersonsReq   = bxcore.ParticipatePersonsReq
+	ParticipatePersonsRes   = bxcore.ParticipatePersonsRes
+	ParticipateRecords      = bxcore.ParticipateRecords
+	ParticipateRecordsData  = bxcore.ParticipateRecordsData
+	ParticipateRecordsReq   = bxcore.ParticipateRecordsReq
+	ParticipateRecordsRes   = bxcore.ParticipateRecordsRes
+	ParticipateSetUpInfo    = bxcore.ParticipateSetUpInfo
+	ParticipateSetUpInfoReq = bxcore.ParticipateSetUpInfoReq
+	ParticipateSetUpInfoRes = bxcore.ParticipateSetUpInfoRes
+	ParticipateShowReq      = bxcore.ParticipateShowReq
+	ParticipateShowRes      = bxcore.ParticipateShowRes
+	RemindRuleReq           = bxcore.RemindRuleReq
+	SearchData              = bxcore.SearchData
+	SearchLimitReq          = bxcore.SearchLimitReq
+	SearchLimitResp         = bxcore.SearchLimitResp
+	SearchList              = bxcore.SearchList
+	SearchReq               = bxcore.SearchReq
+	SearchResp              = bxcore.SearchResp
+	ShowInfo                = bxcore.ShowInfo
+	UpdateBidStatusReq      = bxcore.UpdateBidStatusReq
+	UpdateBidStatusRes      = bxcore.UpdateBidStatusRes
+	WinnerInfo              = bxcore.WinnerInfo
 
 
 	BxCore interface {
 	BxCore interface {
 		// 标讯搜索结果列表数据
 		// 标讯搜索结果列表数据

+ 36 - 3
jyBXCore/rpc/internal/logic/participatecontentlogic.go

@@ -1,7 +1,12 @@
 package logic
 package logic
 
 
 import (
 import (
+	"app.yhyue.com/moapp/jybase/common"
 	"context"
 	"context"
+	"fmt"
+	IC "jyBXCore/rpc/init"
+	"jyBXCore/rpc/model/es"
+	"jyBXCore/rpc/service"
 
 
 	"jyBXCore/rpc/internal/svc"
 	"jyBXCore/rpc/internal/svc"
 	"jyBXCore/rpc/type/bxcore"
 	"jyBXCore/rpc/type/bxcore"
@@ -25,7 +30,35 @@ func NewParticipateContentLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 
 
 //  获取投标状态信息
 //  获取投标状态信息
 func (l *ParticipateContentLogic) ParticipateContent(in *bxcore.ParticipateContentReq) (*bxcore.ParticipateContentRes, error) {
 func (l *ParticipateContentLogic) ParticipateContent(in *bxcore.ParticipateContentReq) (*bxcore.ParticipateContentRes, error) {
-	// todo: add your logic here and delete this line
-
-	return &bxcore.ParticipateContentRes{}, nil
+	// 验证权限
+	result := &bxcore.ParticipateContentRes{}
+	// 1. 判断身份是否有权限 不是超级订阅也不是大会员  则直接返回不展示
+	userInfo := IC.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntId, in.PositionType, in.PositionId)
+	// 不是超级订阅 也不是大会员
+	if userInfo.Vip.Status <= 0 && userInfo.Member.Status <= 0 {
+		return result, fmt.Errorf("没权限")
+	}
+	participateService := service.NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
+	participateService.EntRoleId = userInfo.Ent.EntRoleId
+	// 信息id解密
+	infoList, _ := service.DecodeId(in.Sid)
+	if len(infoList) == 0 {
+		return result, fmt.Errorf("信息id无效")
+	}
+	// 根据标讯id 查询项目信息
+	projectInfos := es.GetProjectByInfoId(infoList)
+	if projectInfos == nil || len(*projectInfos) == 0 {
+		return result, fmt.Errorf("无效的信息id")
+	}
+	// 验证身份
+	projectId := common.ObjToString((*projectInfos)[0]["_id"])
+	if !participateService.CheckBidPower(projectId, false) {
+		return result, fmt.Errorf("没有权限")
+	}
+	//  查询
+	data := participateService.GetLastBidStatus(projectId)
+	formatData := participateService.ParticipateContentFormat(data)
+	return &bxcore.ParticipateContentRes{
+		Data: &formatData,
+	}, nil
 }
 }

+ 6 - 5
jyBXCore/rpc/internal/logic/participaterecordslogic.go

@@ -29,7 +29,6 @@ func NewParticipateRecordsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 
 
 //  参标操作记录
 //  参标操作记录
 func (l *ParticipateRecordsLogic) ParticipateRecords(in *bxcore.ParticipateRecordsReq) (*bxcore.ParticipateRecordsRes, error) {
 func (l *ParticipateRecordsLogic) ParticipateRecords(in *bxcore.ParticipateRecordsReq) (*bxcore.ParticipateRecordsRes, error) {
-	// todo: add your logic here and delete this line
 	// 验证权限
 	// 验证权限
 	result := &bxcore.ParticipateRecordsRes{}
 	result := &bxcore.ParticipateRecordsRes{}
 	// 1. 判断身份是否有权限 不是超级订阅也不是大会员  则直接返回不展示
 	// 1. 判断身份是否有权限 不是超级订阅也不是大会员  则直接返回不展示
@@ -52,10 +51,12 @@ func (l *ParticipateRecordsLogic) ParticipateRecords(in *bxcore.ParticipateRecor
 	}
 	}
 	// 验证身份
 	// 验证身份
 	projectId := common.ObjToString((*projectInfos)[0]["_id"])
 	projectId := common.ObjToString((*projectInfos)[0]["_id"])
-	if !participateService.CheckUpdateBidPower(projectId) {
+	if !participateService.CheckBidPower(projectId, false) {
 		return result, fmt.Errorf("没有权限")
 		return result, fmt.Errorf("没有权限")
 	}
 	}
-	// todo 查询
-	//participateService.GetBidRecords(in.Page, in.PageSize)
-	return &bxcore.ParticipateRecordsRes{}, nil
+	//  查询
+	data := participateService.GetBidRecords(projectId, in.Page, in.PageSize)
+	return &bxcore.ParticipateRecordsRes{
+		Data: data,
+	}, nil
 }
 }

+ 7 - 5
jyBXCore/rpc/internal/logic/updatebidstatuslogic.go

@@ -61,14 +61,16 @@ func (l *UpdateBidStatusLogic) UpdateBidStatus(in *bxcore.UpdateBidStatusReq) (*
 		return result, fmt.Errorf("已经过开标时间,无法更新")
 		return result, fmt.Errorf("已经过开标时间,无法更新")
 	}
 	}
 	// 验证身份
 	// 验证身份
-	if !participateService.CheckUpdateBidPower(projectId) {
+	if !participateService.CheckBidPower(projectId, true) {
 		return result, fmt.Errorf("没有权限")
 		return result, fmt.Errorf("没有权限")
 	}
 	}
-	// 2. 更新
-	// todo 取锁
+	// 2. todo 更新
 	flag := participateService.UpdateBidStatus(in, projectId)
 	flag := participateService.UpdateBidStatus(in, projectId)
-	// 释放锁
+	var err error
+	if !flag {
+		err = fmt.Errorf("更新失败")
+	}
 	return &bxcore.UpdateBidStatusRes{
 	return &bxcore.UpdateBidStatusRes{
 		Data: flag,
 		Data: flag,
-	}, nil
+	}, err
 }
 }

+ 40 - 15
jyBXCore/rpc/model/tidb/tidb.go

@@ -339,7 +339,7 @@ func GetBidContentEnt(projectId string, entId int64) *[]map[string]interface{} {
 
 
 // GetBidContentPersonal 个人版 获取投标状态更新内容
 // GetBidContentPersonal 个人版 获取投标状态更新内容
 func GetBidContentPersonal(projectId string, positionId int64) *[]map[string]interface{} {
 func GetBidContentPersonal(projectId string, positionId int64) *[]map[string]interface{} {
-	query := "SELECT * FROM " + ParticipateBidRecordsTable + " where project_id=? and position_id=? and and record_type=1  order by create_date desc limit 1;"
+	query := "SELECT * FROM " + ParticipateBidRecordsTable + " where project_id=? and position_id=? and  record_type=1  order by create_date desc limit 1;"
 	return IC.BaseMysql.SelectBySql(query, projectId, positionId)
 	return IC.BaseMysql.SelectBySql(query, projectId, positionId)
 }
 }
 
 
@@ -355,33 +355,58 @@ func InsertBidContent(recordData map[string]interface{}) (flag bool) {
 	return r2 > 0
 	return r2 > 0
 }
 }
 
 
-// GetBidRecordsEnt 获取操作记录列表
-func GetBidRecordsEnt(projectId string, entId, page, pageSize int) *[]map[string]interface{} {
-	query := "SELECT * FROM " + ParticipateBidRecordsTable + " where project_id=? and ent_id=? and and record_type=1  order by create_date desc limit ?,?;"
-	return IC.BaseMysql.SelectBySql(query, projectId, entId, page, pageSize*(page-1))
+// GetBidRecordsEnt 获取操作记录列表企业
+func GetBidRecordsEnt(projectId string, entId, page, pageSize int64) (rs *[]map[string]interface{}, total int64) {
+	query := "SELECT * FROM " + ParticipateBidRecordsTable + " where project_id=? and ent_id=?   order by create_date desc limit ?,?"
+	countQuery := "SELECT count(id) FROM " + ParticipateBidRecordsTable + " where project_id=? and ent_id=? ;"
+	rs = IC.BaseMysql.SelectBySql(query, projectId, entId, (page-1)*pageSize, pageSize)
+	total = IC.BaseMysql.CountBySql(countQuery, projectId, entId)
+	return rs, total
 }
 }
 
 
-// GetBidRecordsPersonal 获取操作记录列表 todo 测试
-func GetBidRecordsPersonal(projectId string, positionId, page, pageSize int) *[]map[string]interface{} {
-	query := "SELECT * FROM " + ParticipateBidRecordsTable + " where project_id=? and position_id=? and and record_type=1  order by create_date desc limit ?,?;"
-	return IC.BaseMysql.SelectBySql(query, projectId, positionId, page, pageSize*(page-1))
+// GetBidRecordsPersonal 获取操作记录列表个人
+func GetBidRecordsPersonal(projectId string, positionId, page, pageSize int64) (rs *[]map[string]interface{}, total int64) {
+	query := "SELECT * FROM " + ParticipateBidRecordsTable + " where project_id=? and position_id=?   order by create_date desc limit ?,?;"
+	countQuery := "SELECT count(id) FROM " + ParticipateBidRecordsTable + " where project_id=? and position_id=? ;"
+	rs = IC.BaseMysql.SelectBySql(query, projectId, positionId, (page-1)*pageSize, pageSize)
+	total = IC.BaseMysql.CountBySql(countQuery, projectId, positionId)
+	return rs, total
+}
+
+// GetUserMap 查询用户id的姓名
+func GetUserMap(userIds string) (rs *[]map[string]interface{}) {
+	query := fmt.Sprintf("select id,name from entniche_user where id in (%s)", userIds)
+	rs = IC.MainMysql.SelectBySql(query)
+	return rs
 }
 }
 
 
 // CheckParticipateManager 验证项目id是否是该管理员企业下的参标项目
 // CheckParticipateManager 验证项目id是否是该管理员企业下的参标项目
-func CheckParticipateManager(projectId string, entId int64) (flag bool) {
-	query := "SELECT count(id) FROM " + ParticipateUserTable + " where project_id=? and ent_id=?;"
+func CheckParticipateManager(projectId string, entId int64, valid bool) (flag bool) {
+	statusStr := "" // 是否需要验证是正在参标
+	if valid {
+		statusStr = " and status=0"
+	}
+	query := "SELECT count(id) FROM " + ParticipateUserTable + " where project_id=? and ent_id=?" + statusStr
 	return IC.BaseMysql.CountBySql(query, projectId, entId) > 0
 	return IC.BaseMysql.CountBySql(query, projectId, entId) > 0
 }
 }
 
 
 // CheckParticipateEntUser 验证项目id是否是该企业用户参标的项目
 // CheckParticipateEntUser 验证项目id是否是该企业用户参标的项目
-func CheckParticipateEntUser(projectId string, entUserId int64) (flag bool) {
-	query := "SELECT count(id) FROM " + ParticipateUserTable + " where project_id=? and ent_user_id=?;"
+func CheckParticipateEntUser(projectId string, entUserId int64, valid bool) (flag bool) {
+	statusStr := "" // 是否需要验证是正在参标
+	if valid {
+		statusStr = " and status=0"
+	}
+	query := "SELECT count(id) FROM " + ParticipateUserTable + " where project_id=? and ent_user_id=?" + statusStr
 	return IC.BaseMysql.CountBySql(query, projectId, entUserId) > 0
 	return IC.BaseMysql.CountBySql(query, projectId, entUserId) > 0
 
 
 }
 }
 
 
 // CheckParticipatePersonal 查询项目id是否是该用户参标项目
 // CheckParticipatePersonal 查询项目id是否是该用户参标项目
-func CheckParticipatePersonal(projectId string, positionId int64) (flag bool) {
-	query := "SELECT count(id) FROM " + ParticipateUserTable + " where project_id=? and position_id=?;"
+func CheckParticipatePersonal(projectId string, positionId int64, valid bool) (flag bool) {
+	statusStr := "" // 是否需要验证是正在参标 终止参标的用户还能查看记录,但是不能更新状态
+	if valid {
+		statusStr = " and status=0"
+	}
+	query := "SELECT count(id) FROM " + ParticipateUserTable + " where project_id=? and position_id=?" + statusStr
 	return IC.BaseMysql.CountBySql(query, projectId, positionId) > 0
 	return IC.BaseMysql.CountBySql(query, projectId, positionId) > 0
 }
 }

+ 124 - 13
jyBXCore/rpc/service/participateBid.go

@@ -62,7 +62,7 @@ func (p *ParticipateBid) PersonalExistProject(projectId []string) map[string]str
 		value = append(value, projectId[i])
 		value = append(value, projectId[i])
 	}
 	}
 	argStr := strings.Join(arg, ",")
 	argStr := strings.Join(arg, ",")
-	query := "select project_id from " + TableParticipateUser + " where position_id = ? and project_id in (%s)  and state>=0"
+	query := "select project_id from " + TableParticipateUser + " where position_id = ? and project_id in (%s)  and status=0"
 	rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
 	rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
 	existProjectSet := map[string]struct{}{}
 	existProjectSet := map[string]struct{}{}
 	if rs != nil && len(*rs) > 0 { // 如果查到了  说明已经参标 这部分应该显示已参标
 	if rs != nil && len(*rs) > 0 { // 如果查到了  说明已经参标 这部分应该显示已参标
@@ -102,7 +102,7 @@ func (p *ParticipateBid) EntExistProject(projectId []string) map[string]string {
 		value = append(value, projectId[i])
 		value = append(value, projectId[i])
 	}
 	}
 	argStr := strings.Join(arg, ",")
 	argStr := strings.Join(arg, ",")
-	query := "select GROUP_CONCAT(ent_user_id) as personIds ,project_id from " + TableParticipateUser + " where ent_id=? and  project_id in (%s) and state>=0  group by project_id "
+	query := "select GROUP_CONCAT(ent_user_id) as personIds ,project_id from " + TableParticipateUser + " where ent_id=? and  project_id in (%s) and status=0  group by project_id "
 	rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
 	rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
 	existProjectMap := map[string]string{}
 	existProjectMap := map[string]string{}
 	if rs != nil && len(*rs) > 0 { // 如果查到了  说明这个项目公司里面已经参标 处理一下信息用于后边判断是否是自己参标
 	if rs != nil && len(*rs) > 0 { // 如果查到了  说明这个项目公司里面已经参标 处理一下信息用于后边判断是否是自己参标
@@ -258,25 +258,24 @@ func ContainId(ids string, objId string) bool {
 //  返回: "张三,李四,王五..."
 //  返回: "张三,李四,王五..."
 func GetNameByUserIds(ids string) *[]map[string]interface{} {
 func GetNameByUserIds(ids string) *[]map[string]interface{} {
 	query := "select  group_concat(name) as name  from " + TableEntnicheUser + " where id in (" + ids + ") "
 	query := "select  group_concat(name) as name  from " + TableEntnicheUser + " where id in (" + ids + ") "
-	fmt.Println(query)
 	rs := IC.MainMysql.SelectBySql(query)
 	rs := IC.MainMysql.SelectBySql(query)
 	return rs
 	return rs
 }
 }
 
 
-// CheckUpdateBidPower 投标状态更新验证权限(参标人或者是该企业下的管理员)
-func (p *ParticipateBid) CheckUpdateBidPower(projectId string) (b bool) {
+// CheckBidPower 投标状态更新/查看记录 验证权限(参标人或者是该企业下的管理员)
+func (p *ParticipateBid) CheckBidPower(projectId string, valid bool) (b bool) {
 
 
 	switch p.PositionType {
 	switch p.PositionType {
 	case PositionTypePersonal:
 	case PositionTypePersonal:
 		// 查个人id
 		// 查个人id
-		b = tidb.CheckParticipatePersonal(projectId, p.PositionId)
+		b = tidb.CheckParticipatePersonal(projectId, p.PositionId, valid)
 	case PositionTypeEnt:
 	case PositionTypeEnt:
 		// 查企业
 		// 查企业
 		if p.EntRoleId == RoleEntManager || p.EntRoleId == RoleDepartManager {
 		if p.EntRoleId == RoleEntManager || p.EntRoleId == RoleDepartManager {
-			b = tidb.CheckParticipateManager(projectId, p.EntId)
+			b = tidb.CheckParticipateManager(projectId, p.EntId, valid)
 		} else {
 		} else {
 			// 查参标人
 			// 查参标人
-			b = tidb.CheckParticipateEntUser(projectId, p.PositionId)
+			b = tidb.CheckParticipateEntUser(projectId, p.PositionId, valid)
 		}
 		}
 	}
 	}
 	return
 	return
@@ -287,6 +286,9 @@ func (p *ParticipateBid) UpdateBidStatus(in *bxcore.UpdateBidStatusReq, projectI
 	// 如果查出来旧的 那么就需要做新旧对比
 	// 如果查出来旧的 那么就需要做新旧对比
 	oldMap := p.GetLastBidStatus(projectId) // 查询出最新的招标状态信息
 	oldMap := p.GetLastBidStatus(projectId) // 查询出最新的招标状态信息
 	// 新的
 	// 新的
+	if in.BidStage == nil {
+		in.BidStage = []string{}
+	}
 	newMap := map[string]interface{}{
 	newMap := map[string]interface{}{
 		"bidType":       in.BidType,
 		"bidType":       in.BidType,
 		"bidStage":      in.BidStage,
 		"bidStage":      in.BidStage,
@@ -339,13 +341,116 @@ func (p *ParticipateBid) GetLastBidStatus(projectId string) map[string]interface
 	return rs
 	return rs
 
 
 }
 }
+func (p ParticipateBid) ParticipateContentFormat(data map[string]interface{}) (rs bxcore.ParticipateContentData) {
+	if data == nil {
+		return
+	}
+	rs.BidType = common.Int64All(data["bidType"])
+	rs.ChannelPhone = common.ObjToString(data["channelPhone"])
+	rs.ChannelPerson = common.ObjToString(data["channelPerson"])
+	rs.ChannelName = common.ObjToString(data["channelName"])
+	rs.IsWin = common.Int64All(data["isWin"])
+	rs.Winner = common.ObjToString(data["winner"])
+	tmp := data["bidStage"].([]interface{})
+	rs.BidStage = common.ObjArrToStringArr(tmp)
+
+	return rs
+}
 
 
 // GetBidRecords 获取操作记录
 // GetBidRecords 获取操作记录
-func (p *ParticipateBid) GetBidRecords(page, pageSize int) {
+func (p *ParticipateBid) GetBidRecords(projectId string, page, pageSize int64) *bxcore.ParticipateRecordsData {
+	data := bxcore.ParticipateRecordsData{}
+	var rs *[]map[string]interface{}
+	var total int64
+	if page < 1 {
+		page = 1
+	}
+	if pageSize == 0 {
+		pageSize = 500
+	}
+	switch p.PositionType {
+	case PositionTypeEnt:
+		// 1. 查询出操作记录
+		rs, total = tidb.GetBidRecordsEnt(projectId, p.EntId, page, pageSize)
+	case PositionTypePersonal:
+		//  个人版不展示姓名
+		rs, total = tidb.GetBidRecordsPersonal(projectId, p.PositionId, page, pageSize)
+
+	}
+	if rs == nil || len(*rs) == 0 {
+		return &data
+	}
+	data.Total = total
+	data.List = p.BidRecordsFormat(*rs)
+	return &data
+}
+
+// BidRecordsFormat 获取操作记录格式化
+func (p ParticipateBid) BidRecordsFormat(data []map[string]interface{}) []*bxcore.ParticipateRecords {
+	records := []*bxcore.ParticipateRecords{}
+	switch p.PositionType {
+
+	case PositionTypeEnt:
+		// 用户id
+		// 拿到所有的用户id
+		userIdArr := []string{}
+		userIdMap := map[int64]string{}
+		for i := 0; i < len(data); i++ {
+			userId := common.Int64All(data[i]["ent_user_id"])
+			if _, ok := userIdMap[userId]; !ok {
+				userIdMap[userId] = ""
+				userIdArr = append(userIdArr, fmt.Sprint(userId))
+			}
+		}
+
+		// 根据id查询出姓名{id:name}
+		userIdMap = getUserIdName(userIdArr)
+		// 遍历数据  换成姓名
+		for i := 0; i < len(data); i++ {
+			id := common.Int64All(data[i]["ent_user_id"])
+			person := ""
+			if name, ok := userIdMap[id]; ok {
+				person = name
+			}
+			tmp := bxcore.ParticipateRecords{
+				RecordsData:  common.ObjToString(data[i]["record_content"]),
+				UpdateDate:   common.ObjToString(data[i]["create_date"]),
+				UpdatePerson: person,
+			}
+			records = append(records, &tmp)
 
 
-	// 1. 查询出操作记录
-	//tidb.GetBidRecordsEnt()
-	// 2. todo 补充上操作人姓名
+		}
+	case PositionTypePersonal:
+		// 遍历数据  换成姓名
+		for i := 0; i < len(data); i++ {
+			tmp := bxcore.ParticipateRecords{
+				RecordsData: common.ObjToString(data[i]["record_content"]),
+				UpdateDate:  common.ObjToString(data[i]["create_date"]),
+			}
+			records = append(records, &tmp)
+
+		}
+	}
+	return records
+}
+
+// 获取id和姓名的对应关系
+func getUserIdName(userIdArr []string) map[int64]string {
+	rs := map[int64]string{}
+	if len(userIdArr) > 0 {
+		userIdStr := strings.Join(userIdArr, ",")
+		userRs := tidb.GetUserMap(userIdStr)
+		if userRs == nil || len(*userRs) == 0 {
+			return rs
+		}
+		for i := 0; i < len(*userRs); i++ {
+			user := (*userRs)[i]
+			id := common.Int64All(user["id"])
+			name := common.ObjToString(user["name"])
+			rs[id] = name
+		}
+	}
+	return rs
 }
 }
 
 
 // 处理操作动作
 // 处理操作动作
@@ -370,6 +475,7 @@ var (
 	}
 	}
 )
 )
 
 
+// 处理操作记录
 func processRecordStr(oldMap, newMap map[string]interface{}) (recordContent string, err error) {
 func processRecordStr(oldMap, newMap map[string]interface{}) (recordContent string, err error) {
 	actonStr := "%s%s%s"
 	actonStr := "%s%s%s"
 	changeField := []string{}
 	changeField := []string{}
@@ -442,10 +548,15 @@ func processRecordStr(oldMap, newMap map[string]interface{}) (recordContent stri
 		"after":       newMap,                    // 变更后
 		"after":       newMap,                    // 变更后
 		"changeField": changeField,               // 涉及变更的字段
 		"changeField": changeField,               // 涉及变更的字段
 	}
 	}
+
 	tmp, err := json.Marshal(recordMap)
 	tmp, err := json.Marshal(recordMap)
 	if err != nil {
 	if err != nil {
 		logx.Error("序列化操作记录失败:", err)
 		logx.Error("序列化操作记录失败:", err)
 		return "", err
 		return "", err
 	}
 	}
-	return string(tmp), nil
+	if len(result) == 0 {
+		logx.Error("没有更新的内容:", recordContent)
+		err = fmt.Errorf("没有变更的内容,不用更新")
+	}
+	return string(tmp), err
 }
 }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 397 - 375
jyBXCore/rpc/type/bxcore/bxcore.pb.go


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio