Browse Source

feat:core 调整

fuwencai 2 years ago
parent
commit
6557f7ba5c
2 changed files with 45 additions and 35 deletions
  1. 42 0
      jyBXCore/rpc/model/mysql/participateBid.go
  2. 3 35
      jyBXCore/rpc/service/participateBid.go

+ 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"    // 企业用户表
 )
 
 //划转参标信息
@@ -729,3 +730,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) {