Просмотр исходного кода

feat:bxcore 返回值状态码调整、es调整查询开标时间有效、info接口新增是否展示更新投标状态字段

fuwencai 2 лет назад
Родитель
Сommit
4154415645

+ 1 - 0
jyBXCore/rpc/bxcore.proto

@@ -180,6 +180,7 @@ message ParticipateDetailInfo{
   string projectId = 5;// 项目id
   int64 bidEndTime = 6 ;// 投标截止时间
   int64 currentTime = 7 ;// 服务器当前时间
+  bool  showUpdate   = 8;// 当前用户能否更新  true 显示更新模块
 
 }
 message ParticipateInfoRes{

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

@@ -30,9 +30,7 @@ func NewParticipateContentLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 // 获取投标状态信息
 func (l *ParticipateContentLogic) ParticipateContent(in *bxcore.ParticipateContentReq) (*bxcore.ParticipateContentRes, error) {
 	// 验证权限
-	result := &bxcore.ParticipateContentRes{
-		ErrCode: -1,
-	}
+	result := &bxcore.ParticipateContentRes{}
 	b, entRoleId := util.IsAllowedParticipate(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
 	if !b {
 		result.ErrMsg = "暂无权限"
@@ -43,13 +41,13 @@ func (l *ParticipateContentLogic) ParticipateContent(in *bxcore.ParticipateConte
 	// 信息id解密
 	infoList, _ := service.DecodeId(in.Sid)
 	if len(infoList) == 0 {
+		result.ErrCode = -1
 		result.ErrMsg = "信息id无效"
 		return result, nil
 	}
 	// 根据标讯id 查询项目信息
 	projectInfos := es.GetProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
-		result.ErrCode = 0
 		return result, nil
 	}
 	// 验证身份
@@ -63,8 +61,7 @@ func (l *ParticipateContentLogic) ParticipateContent(in *bxcore.ParticipateConte
 	if err == nil {
 		formatData := participateService.ParticipateContentFormat(data)
 		return &bxcore.ParticipateContentRes{
-			ErrCode: 0,
-			Data:    &formatData,
+			Data: &formatData,
 		}, nil
 	}
 	return &bxcore.ParticipateContentRes{

+ 7 - 8
jyBXCore/rpc/internal/logic/participateinfologic.go

@@ -34,9 +34,7 @@ func NewParticipateInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *P
 func (l *ParticipateInfoLogic) ParticipateInfo(in *bxcore.ParticipateInfoReq) (*bxcore.ParticipateInfoRes, error) {
 	format := &bxcore.ParticipateDetailInfo{}
 	result := bxcore.ParticipateInfoRes{
-		ErrMsg:  "",
-		ErrCode: -1,
-		Data:    format,
+		Data: format,
 	}
 	b, entRoleId := util.IsAllowedParticipate(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
 	if !b {
@@ -48,21 +46,23 @@ func (l *ParticipateInfoLogic) ParticipateInfo(in *bxcore.ParticipateInfoReq) (*
 	// 信息id解密
 	infoList, infoSet := service.DecodeId(in.Sid)
 	if len(infoList) == 0 {
+		result.ErrCode = -1
 		result.ErrMsg = "信息id无效"
 		return &result, nil
 	}
 	// 2. 根据标讯id 查询项目信息
 	projectInfos := es.GetProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
-		//result.ErrCode = 0
 		result.ErrMsg = "未查到此项目信息"
 		return &result, nil
 	}
 	// 判断是否已经过了投标截止时间
-	var isValid bool
+	isValid := true
 	bidendtime := common.Int64All((*projectInfos)[0]["bidendtime"])
-	if time.Now().Unix() < bidendtime || bidendtime == 0 {
-		isValid = true
+	bidopentime := common.Int64All((*projectInfos)[0]["bidopentime"])
+	now := time.Now().Unix()
+	if (now > bidopentime && bidopentime != 0) || (now > bidendtime && bidendtime != 0) {
+		isValid = false
 	}
 	//   获取项目id
 	_, projectIds := service.HandlerProjectId(*projectInfos, infoSet)
@@ -78,7 +78,6 @@ func (l *ParticipateInfoLogic) ParticipateInfo(in *bxcore.ParticipateInfoReq) (*
 		formatData = participateService.DetailEntFormat(existList, isValid, isAllow, bidendtime) // 格式化数据
 	}
 	formatData.ProjectId = encrypt.EncodeArticleId2ByCheck(projectIds[0])
-	result.ErrCode = 0
 	result.Data = formatData
 	return &result, nil
 

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

@@ -30,9 +30,7 @@ func NewParticipateRecordsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 // 参标操作记录
 func (l *ParticipateRecordsLogic) ParticipateRecords(in *bxcore.ParticipateRecordsReq) (*bxcore.ParticipateRecordsRes, error) {
 	// 验证权限
-	result := &bxcore.ParticipateRecordsRes{
-		ErrCode: -1,
-	}
+	result := &bxcore.ParticipateRecordsRes{}
 	b, entRoleId := util.IsAllowedParticipate(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
 	if !b {
 		result.ErrMsg = "没有权限"
@@ -43,13 +41,13 @@ func (l *ParticipateRecordsLogic) ParticipateRecords(in *bxcore.ParticipateRecor
 	// 信息id解密
 	infoList, _ := service.DecodeId(in.Sid)
 	if len(infoList) == 0 {
+		result.ErrCode = -1
 		result.ErrMsg = "无效的信息id"
 		return result, nil
 	}
 	// 根据标讯id 查询项目信息
 	projectInfos := es.GetProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
-		result.ErrCode = 0
 		return result, nil
 	}
 	// 验证身份
@@ -60,7 +58,6 @@ func (l *ParticipateRecordsLogic) ParticipateRecords(in *bxcore.ParticipateRecor
 	//  查询
 	data := participateService.GetBidRecords(projectId, in.Page, in.PageSize)
 	return &bxcore.ParticipateRecordsRes{
-		ErrCode: 0,
-		Data:    data,
+		Data: data,
 	}, nil
 }

+ 2 - 5
jyBXCore/rpc/internal/logic/participateshowlogic.go

@@ -28,9 +28,7 @@ func NewParticipateShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *P
 // 列表数据参标信息接口
 func (l *ParticipateShowLogic) ParticipateShow(in *bxcore.ParticipateShowReq) (*bxcore.ParticipateShowRes, error) {
 	result := bxcore.ParticipateShowRes{
-		ErrMsg:  "",
-		ErrCode: -1,
-		Data:    []*bxcore.ShowInfo{},
+		Data: []*bxcore.ShowInfo{},
 	}
 	b, entRoleId := util.IsAllowedParticipate(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
 	if !b {
@@ -43,13 +41,13 @@ func (l *ParticipateShowLogic) ParticipateShow(in *bxcore.ParticipateShowReq) (*
 	// 信息id解密
 	infoList, infoSet := service.DecodeId(in.Ids)
 	if len(infoList) == 0 {
+		result.ErrCode = -1
 		result.ErrMsg = "信息id无效"
 		return &result, nil
 	}
 	// 查有效项目id信息
 	projectInfos := es.GetValidProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
-		result.ErrCode = 0
 		return &result, nil
 	}
 	// 记录信息id和项目id的映射  用于最后处理返回数据
@@ -65,7 +63,6 @@ func (l *ParticipateShowLogic) ParticipateShow(in *bxcore.ParticipateShowReq) (*
 		existList := participateService.EntExistProject(projectIds)              // 查询出已经存在的
 		formatList = participateService.ListEntFormat(existList, infoM, isAllow) // 格式化数据
 	}
-	result.ErrCode = 0
 	result.Data = formatList
 	return &result, nil
 }

+ 4 - 2
jyBXCore/rpc/internal/logic/updatebidstatuslogic.go

@@ -59,13 +59,15 @@ func (l *UpdateBidStatusLogic) UpdateBidStatus(in *bxcore.UpdateBidStatusReq) (*
 	}
 	// 判断是否已经过了投标截止时间
 	bidendtime := common.Int64All((*projectInfos)[0]["bidendtime"])
+	bidopentime := common.Int64All((*projectInfos)[0]["bidopentime"])
 	projectId := common.ObjToString((*projectInfos)[0]["_id"])
-	if !(time.Now().Unix() < bidendtime || bidendtime == 0) {
+	now := time.Now().Unix()
+	if (now > bidopentime && bidopentime != 0) || (now > bidendtime && bidendtime != 0) {
 		result.ErrMsg = "已经过投标截止时间,无法更新"
 		return result, nil
 	}
 	// 验证身份
-	if !participateService.CheckBidPower(projectId, true) {
+	if !participateService.CheckUpdateBidPower(projectId, true) {
 		result.ErrMsg = "没有更新权限"
 		return result, nil
 	}

+ 8 - 1
jyBXCore/rpc/model/es/project.go

@@ -32,7 +32,14 @@ func GetValidProjectByInfoId(infoIds []string) *[]map[string]interface{} {
 	}
 	nowTime := time.Now().Unix()
 	query := `{"_source":["_id","list.infoid"],"query": {"bool": {"must": [{"terms": {"list.infoid": ["` + strings.Join(infoIds, "\",\"") + `"]}},
-        {"bool": {"should": [{"range": {"bidendtime": {"gte": ` + fmt.Sprint(nowTime) + `}}},
+                {"bool": {"should": [{"range": {"bidopentime": {"gte": ` + fmt.Sprint(nowTime) + `}}},
+               {"bool": {"must_not": [{"constant_score": {"filter": {"exists": {"field": "bidopentime"
+                        }
+                    }
+                }
+            }
+]}}] }},
+{"bool": {"should": [{"range": {"bidendtime": {"gte": ` + fmt.Sprint(nowTime) + `}}},
         {
     "bool": {
         "must_not": [

+ 16 - 3
jyBXCore/rpc/service/participateBid.go

@@ -154,6 +154,7 @@ func (p *ParticipateBid) DetailEntFormat(existProjectMap map[string]string, isVa
 	// 如果包含自己 显示终止参标按钮
 	if ContainId(persons, common.InterfaceToStr(p.EntUserId)) {
 		formatData.ShowStopParticipate = true
+		formatData.ShowUpdate = true
 	} else if isAllow { // 如果允许多人 显示参标按钮
 		formatData.ShowParticipate = true
 	}
@@ -173,6 +174,7 @@ func (p *ParticipateBid) DetailPersonalFormat(existProjectSet map[string]struct{
 		formatData.CurrentTime = time.Now().Unix()
 		formatData.BidEndTime = bidEndTime
 		formatData.ShowStopParticipate = true
+		formatData.ShowUpdate = true
 	} else {
 		// 不存在则说明 未参标 参标按钮展示
 		formatData.ShowParticipate = true
@@ -233,7 +235,7 @@ func ContainId(ids string, objId string) bool {
 	return false
 }
 
-// CheckBidPower 投标状态更新/查看记录 验证权限(参标人或者是该企业下的管理员)
+// CheckBidPower 查看记录 验证权限(参标人或者是该企业下的管理员)
 func (p *ParticipateBid) CheckBidPower(projectId string, valid bool) (b bool) {
 	switch p.PositionType {
 	case PositionTypePersonal:
@@ -251,6 +253,19 @@ func (p *ParticipateBid) CheckBidPower(projectId string, valid bool) (b bool) {
 	return
 }
 
+// CheckUpdateBidPower 验证投标状态更新权限
+func (p *ParticipateBid) CheckUpdateBidPower(projectId string, valid bool) (b bool) {
+	switch p.PositionType {
+	case PositionTypePersonal:
+		// 查个人id
+		b = mysql.CheckParticipatePersonal(projectId, p.PositionId, valid)
+	case PositionTypeEnt:
+		// 查参标人
+		b = mysql.CheckParticipateEntUser(projectId, p.EntUserId, valid)
+	}
+	return
+}
+
 // UpdateBidStatus 更新投标状态
 func (p *ParticipateBid) UpdateBidStatus(in *bxcore.UpdateBidStatusReq, projectId string) error {
 	if p.PositionType == PositionTypeEnt {
@@ -316,8 +331,6 @@ func (p *ParticipateBid) GetLastBidStatus(projectId string) (map[string]interfac
 				rs = *bidStatus
 			}
 		}
-	} else {
-		return rs, fmt.Errorf("暂无参标状态更新记录")
 	}
 	return rs, nil
 

+ 12 - 2
jyBXCore/rpc/type/bxcore/bxcore.pb.go

@@ -1572,6 +1572,7 @@ type ParticipateDetailInfo struct {
 	ProjectId           string `protobuf:"bytes,5,opt,name=projectId,proto3" json:"projectId,omitempty"`                      // 项目id
 	BidEndTime          int64  `protobuf:"varint,6,opt,name=bidEndTime,proto3" json:"bidEndTime,omitempty"`                   // 投标截止时间
 	CurrentTime         int64  `protobuf:"varint,7,opt,name=currentTime,proto3" json:"currentTime,omitempty"`                 // 服务器当前时间
+	ShowUpdate          bool   `protobuf:"varint,8,opt,name=showUpdate,proto3" json:"showUpdate,omitempty"`                   // 当前用户能否更新  true 显示更新模块
 }
 
 func (x *ParticipateDetailInfo) Reset() {
@@ -1655,6 +1656,13 @@ func (x *ParticipateDetailInfo) GetCurrentTime() int64 {
 	return 0
 }
 
+func (x *ParticipateDetailInfo) GetShowUpdate() bool {
+	if x != nil {
+		return x.ShowUpdate
+	}
+	return false
+}
+
 type ParticipateInfoRes struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -4314,7 +4322,7 @@ var file_bxcore_proto_rawDesc = []byte{
 	0x6e, 0x74, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75,
 	0x6e, 0x74, 0x49, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x65, 0x6e, 0x74, 0x41,
 	0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e,
-	0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x93,
+	0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0xb3,
 	0x02, 0x0a, 0x15, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x65, 0x44, 0x65,
 	0x74, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x68, 0x6f, 0x77,
 	0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
@@ -4332,7 +4340,9 @@ var file_bxcore_proto_rawDesc = []byte{
 	0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x62, 0x69, 0x64, 0x45, 0x6e, 0x64, 0x54, 0x69,
 	0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d,
 	0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74,
-	0x54, 0x69, 0x6d, 0x65, 0x22, 0x7b, 0x0a, 0x12, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70,
+	0x54, 0x69, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x68, 0x6f, 0x77, 0x55, 0x70, 0x64, 0x61,
+	0x74, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, 0x68, 0x6f, 0x77, 0x55, 0x70,
+	0x64, 0x61, 0x74, 0x65, 0x22, 0x7b, 0x0a, 0x12, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70,
 	0x61, 0x74, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x72,
 	0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x65, 0x72,
 	0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x65, 0x72, 0x72, 0x5f, 0x6d, 0x73, 0x67,