Parcourir la source

Merge branch 'dev/v1.1.20_fuwencai' of http://192.168.3.207:8080/BaseService/jyMicroservices into dev/v1.1.20_fuwencai

wangshan il y a 2 ans
Parent
commit
925bd879ad

+ 13 - 7
jyBXCore/rpc/internal/logic/participatecontentlogic.go

@@ -3,7 +3,6 @@ package logic
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"context"
-	"fmt"
 	IC "jyBXCore/rpc/init"
 	"jyBXCore/rpc/model/es"
 	"jyBXCore/rpc/service"
@@ -31,34 +30,41 @@ func NewParticipateContentLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 //  获取投标状态信息
 func (l *ParticipateContentLogic) ParticipateContent(in *bxcore.ParticipateContentReq) (*bxcore.ParticipateContentRes, error) {
 	// 验证权限
-	result := &bxcore.ParticipateContentRes{}
+	result := &bxcore.ParticipateContentRes{
+		ErrCode: -1,
+	}
 	// 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("没权限")
+		result.ErrMsg = "没有权限"
+		return result, nil
 	}
 	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无效")
+		result.ErrMsg = "信息id无效"
+		return result, nil
 	}
 	// 根据标讯id 查询项目信息
 	projectInfos := es.GetProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
-		return result, fmt.Errorf("无效的信息id")
+		result.ErrMsg = "未查询到项目信息"
+		return result, nil
 	}
 	// 验证身份
 	projectId := common.ObjToString((*projectInfos)[0]["_id"])
 	if !participateService.CheckBidPower(projectId, false) {
-		return result, fmt.Errorf("没有权限")
+		result.ErrMsg = "没有查看权限"
+		return result, nil
 	}
 	//  查询
 	data := participateService.GetLastBidStatus(projectId)
 	formatData := participateService.ParticipateContentFormat(data)
 	return &bxcore.ParticipateContentRes{
-		Data: &formatData,
+		ErrCode: 0,
+		Data:    &formatData,
 	}, nil
 }

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

@@ -3,7 +3,6 @@ package logic
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"context"
-	"fmt"
 	IC "jyBXCore/rpc/init"
 	"jyBXCore/rpc/model/es"
 	"jyBXCore/rpc/service"
@@ -35,25 +34,28 @@ func (l *ParticipateInfoLogic) ParticipateInfo(in *bxcore.ParticipateInfoReq) (*
 	format := &bxcore.ParticipateDetailInfo{}
 	result := bxcore.ParticipateInfoRes{
 		ErrMsg:  "",
-		ErrCode: 0,
+		ErrCode: -1,
 		Data:    format,
 	}
 	// 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("没权限")
+		result.ErrMsg = "没有权限"
+		return &result, nil
 	}
 	participateService := service.NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
 	participateService.EntRoleId = userInfo.Ent.EntRoleId
 	// 信息id解密
 	infoList, infoSet := service.DecodeId(in.Sid)
 	if len(infoList) == 0 {
-		return &result, fmt.Errorf("信息id无效")
+		result.ErrMsg = "信息id无效"
+		return &result, nil
 	}
 	// 2. 根据标讯id 查询项目信息
 	projectInfos := es.GetProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
+		result.ErrMsg = "未查询到项目信息"
 		return &result, nil
 	}
 	// 判断是否已经过了开标时间
@@ -76,6 +78,7 @@ func (l *ParticipateInfoLogic) ParticipateInfo(in *bxcore.ParticipateInfoReq) (*
 		existList := participateService.EntExistProject(projectIds)                              // 查询出已经存在的
 		formatData = participateService.DetailEntFormat(existList, isValid, isAllow, bidendtime) // 格式化数据
 	}
+	result.ErrCode = 0
 	result.Data = formatData
 	return &result, nil
 

+ 13 - 7
jyBXCore/rpc/internal/logic/participaterecordslogic.go

@@ -30,33 +30,39 @@ func NewParticipateRecordsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 //  参标操作记录
 func (l *ParticipateRecordsLogic) ParticipateRecords(in *bxcore.ParticipateRecordsReq) (*bxcore.ParticipateRecordsRes, error) {
 	// 验证权限
-	result := &bxcore.ParticipateRecordsRes{}
-	// 1. 判断身份是否有权限 不是超级订阅也不是大会员  则直接返回不展示
+	result := &bxcore.ParticipateRecordsRes{
+		ErrCode: -1,
+	}
+	// 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("没权限")
+		result.ErrMsg = "没有权限"
+		return result, nil
 	}
 	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无效")
+		result.ErrMsg = "无效的信息id"
+		return result, nil
 	}
 	// 根据标讯id 查询项目信息
 	projectInfos := es.GetProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
-		return result, fmt.Errorf("无效的信息id")
+		result.ErrMsg = "未查询到项目信息"
+		return result, nil
 	}
 	// 验证身份
 	projectId := common.ObjToString((*projectInfos)[0]["_id"])
 	if !participateService.CheckBidPower(projectId, false) {
-		return result, fmt.Errorf("没有权限")
+		return result, fmt.Errorf("没有该项目操作记录查看权限")
 	}
 	//  查询
 	data := participateService.GetBidRecords(projectId, in.Page, in.PageSize)
 	return &bxcore.ParticipateRecordsRes{
-		Data: data,
+		ErrCode: 0,
+		Data:    data,
 	}, nil
 }

+ 7 - 4
jyBXCore/rpc/internal/logic/participateshowlogic.go

@@ -2,7 +2,6 @@ package logic
 
 import (
 	"context"
-	"fmt"
 	IC "jyBXCore/rpc/init"
 	"jyBXCore/rpc/internal/svc"
 	"jyBXCore/rpc/model/es"
@@ -31,14 +30,15 @@ func NewParticipateShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *P
 func (l *ParticipateShowLogic) ParticipateShow(in *bxcore.ParticipateShowReq) (*bxcore.ParticipateShowRes, error) {
 	result := bxcore.ParticipateShowRes{
 		ErrMsg:  "",
-		ErrCode: 0,
+		ErrCode: -1,
 		Data:    []*bxcore.ShowInfo{},
 	}
 	// 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("没权限")
+		result.ErrMsg = "没有权限"
+		return &result, nil
 	}
 	participateService := service.NewParticipateBid(in.EntId, in.EntUserId, in.PositionType, in.PositionId)
 	participateService.EntRoleId = userInfo.Ent.EntRoleId
@@ -46,11 +46,13 @@ func (l *ParticipateShowLogic) ParticipateShow(in *bxcore.ParticipateShowReq) (*
 	// 信息id解密
 	infoList, infoSet := service.DecodeId(in.Ids)
 	if len(infoList) == 0 {
-		return &result, fmt.Errorf("信息id无效")
+		result.ErrMsg = "信息id无效"
+		return &result, nil
 	}
 	// 查有效项目id信息
 	projectInfos := es.GetValidProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
+		result.ErrMsg = "未查询到信息"
 		return &result, nil
 	}
 	// 记录信息id和项目id的映射  用于最后处理返回数据
@@ -66,6 +68,7 @@ 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
 }

+ 17 - 10
jyBXCore/rpc/internal/logic/updatebidstatuslogic.go

@@ -3,7 +3,6 @@ package logic
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"context"
-	"fmt"
 	IC "jyBXCore/rpc/init"
 	"jyBXCore/rpc/model/es"
 	"jyBXCore/rpc/service"
@@ -31,24 +30,29 @@ func NewUpdateBidStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *U
 
 //   投标状态更新
 func (l *UpdateBidStatusLogic) UpdateBidStatus(in *bxcore.UpdateBidStatusReq) (*bxcore.UpdateBidStatusRes, error) {
-	result := &bxcore.UpdateBidStatusRes{}
+	result := &bxcore.UpdateBidStatusRes{
+		ErrCode: -1,
+	}
 	// 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("没权限")
+		result.ErrMsg = "没有权限"
+		return result, nil
 	}
 	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无效")
+		result.ErrMsg = "信息id无效"
+		return result, nil
 	}
 	// 根据标讯id 查询项目信息
 	projectInfos := es.GetProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
-		return result, fmt.Errorf("无效的信息id")
+		result.ErrMsg = "未查询到项目信息"
+		return result, nil
 	}
 	// 判断是否已经过了开标时间
 	var isValid bool
@@ -58,18 +62,21 @@ func (l *UpdateBidStatusLogic) UpdateBidStatus(in *bxcore.UpdateBidStatusReq) (*
 		isValid = true
 	}
 	if !isValid {
-		return result, fmt.Errorf("已经过开标时间,无法更新")
+		result.ErrMsg = "已经过开标时间,无法更新"
+		return result, nil
 	}
 	// 验证身份
 	if !participateService.CheckBidPower(projectId, true) {
-		return result, fmt.Errorf("没有权限")
+		result.ErrMsg = "没有更新权限"
+		return result, nil
 	}
 	// 2. 更新
 	flag := participateService.UpdateBidStatus(in, projectId)
-	var err error
 	if !flag {
-		err = fmt.Errorf("更新失败")
+		result.ErrMsg = "更新失败"
+	} else {
+		result.ErrCode = 0
 	}
 	result.Data = flag
-	return result, err
+	return result, nil
 }

+ 42 - 0
jyBXCore/rpc/model/mysql/participateBid.go

@@ -40,6 +40,7 @@ var (
 	PartTable                  = "participate"
 	ParticipateBidRecordsTable = "participate_bid_records"
 	ParticipateUserTable       = "participate_user" // 参标用户表
+	EntnicheUserTable          = "entniche_user"    // 企业用户表
 )
 
 //划转参标信息
@@ -787,3 +788,44 @@ func CheckParticipatePersonal(projectId string, positionId int64, valid bool) (f
 	query := "SELECT count(id) FROM " + ParticipateUserTable + " where project_id=? and position_id=?" + stateStr
 	return IC.BaseMysql.CountBySql(query, projectId, positionId) > 0
 }
+
+// GetNameByUserIds 获取用户名字符串
+//  参数:逗号分割的用户id "11,22,333..."
+//  返回: "张三,李四,王五..."
+func GetNameByUserIds(ids string) *[]map[string]interface{} {
+	query := "select  group_concat(name) as name  from " + EntnicheUserTable + " where id in (" + ids + ") "
+	rs := IC.MainMysql.SelectBySql(query)
+	return rs
+}
+
+// ParticipateProjectPersonal 查询给定项目id中已经参标的项目id
+func ParticipateProjectPersonal(positionId int64, projectId []string) *[]map[string]interface{} {
+	// 1. 查询出已经参标的
+	var arg []string
+	var value []interface{}
+	value = append(value, positionId)
+	for i := 0; i < len(projectId); i++ {
+		arg = append(arg, "?")
+		value = append(value, projectId[i])
+	}
+	argStr := strings.Join(arg, ",")
+	query := "select project_id from " + ParticipateUserTable + " where position_id = ? and project_id in (%s)  and state=0"
+	rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
+	return rs
+}
+
+// ParticipateProjectEnt 查询给定项目id中已经参标的项目id
+func ParticipateProjectEnt(entId int64, projectId []string) *[]map[string]interface{} {
+	// 1. 查询出已经参标的
+	var arg []string
+	var value []interface{}
+	value = append(value, entId)
+	for i := 0; i < len(projectId); i++ {
+		arg = append(arg, "?")
+		value = append(value, projectId[i])
+	}
+	argStr := strings.Join(arg, ",")
+	query := "select GROUP_CONCAT(ent_user_id) as personIds ,project_id from " + EntnicheUserTable + " where ent_id=? and  project_id in (%s) and state=0  group by project_id "
+	rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
+	return rs
+}

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

@@ -8,7 +8,6 @@ import (
 	"fmt"
 	"github.com/gogf/gf/v2/container/gset"
 	"github.com/zeromicro/go-zero/core/logx"
-	IC "jyBXCore/rpc/init"
 	"jyBXCore/rpc/model/mysql"
 	"jyBXCore/rpc/type/bxcore"
 	"jyBXCore/rpc/util"
@@ -16,9 +15,6 @@ import (
 )
 
 const (
-	TableEntnicheUser    = "entniche_user"    // 企业用户表
-	TableParticipateUser = "participate_user" // 参标用户表
-
 	PositionTypeEnt      = 1 // 职位类型企业
 	PositionTypePersonal = 0 // 职位类型个人
 
@@ -54,17 +50,7 @@ func NewParticipateBid(entId, entUserId, positionType, positionId int64) Partici
 
 // PersonalExistProject 个人版要展示的参标按钮  查询出已经参标的项目信息 用于后边格式化数据
 func (p *ParticipateBid) PersonalExistProject(projectId []string) map[string]struct{} {
-	// 1. 查询出已经参标的
-	var arg []string
-	var value []interface{}
-	value = append(value, p.PositionId)
-	for i := 0; i < len(projectId); i++ {
-		arg = append(arg, "?")
-		value = append(value, projectId[i])
-	}
-	argStr := strings.Join(arg, ",")
-	query := "select project_id from " + TableParticipateUser + " where position_id = ? and project_id in (%s)  and state=0"
-	rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
+	rs := mysql.ParticipateProjectPersonal(p.PositionId, projectId)
 	existProjectSet := map[string]struct{}{}
 	if rs != nil && len(*rs) > 0 { // 如果查到了  说明已经参标 这部分应该显示已参标
 		// 处理成map
@@ -95,16 +81,7 @@ func (p *ParticipateBid) ListPersonalFormat(existProjectSet map[string]struct{},
 
 // EntExistProject 企业版 查出来企业下已经参标的这个项目的以及参标人信息  用于后边格式化数据判断有没有自己
 func (p *ParticipateBid) EntExistProject(projectId []string) map[string]string {
-	var arg []string
-	var value []interface{}
-	value = append(value, p.EntId)
-	for i := 0; i < len(projectId); i++ {
-		arg = append(arg, "?")
-		value = append(value, projectId[i])
-	}
-	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 "
-	rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
+	rs := mysql.ParticipateProjectEnt(p.EntId, projectId)
 	existProjectMap := map[string]string{}
 	if rs != nil && len(*rs) > 0 { // 如果查到了  说明这个项目公司里面已经参标 处理一下信息用于后边判断是否是自己参标
 		// 处理成map
@@ -162,7 +139,7 @@ func (p *ParticipateBid) DetailEntFormat(existProjectMap map[string]string, isVa
 		break
 	}
 	// 参标人信息 处理成姓名
-	nameRs := GetNameByUserIds(persons)
+	nameRs := mysql.GetNameByUserIds(persons)
 	if nameRs != nil && len(*nameRs) > 0 {
 		formatData.UserName = common.ObjToString((*nameRs)[0]["name"])
 	}
@@ -256,15 +233,6 @@ func ContainId(ids string, objId string) bool {
 	return false
 }
 
-// GetNameByUserIds 获取用户名字符串
-//  参数:逗号分割的用户id "11,22,333..."
-//  返回: "张三,李四,王五..."
-func GetNameByUserIds(ids string) *[]map[string]interface{} {
-	query := "select  group_concat(name) as name  from " + TableEntnicheUser + " where id in (" + ids + ") "
-	rs := IC.MainMysql.SelectBySql(query)
-	return rs
-}
-
 // CheckBidPower 投标状态更新/查看记录 验证权限(参标人或者是该企业下的管理员)
 func (p *ParticipateBid) CheckBidPower(projectId string, valid bool) (b bool) {