Pārlūkot izejas kodu

feat:单人参标按钮

wangshan 2 gadi atpakaļ
vecāks
revīzija
1ae09e159e

+ 14 - 5
jyBXCore/rpc/model/mysql/participateBid.go

@@ -267,16 +267,24 @@ func SaveParticipateInfo(in *bxcore.ParticipateActionReq) error {
 }
 
 // 查询当前招标信息是否已被参标
-func IsParticipatedByBidId(in *bxcore.ParticipateActionReq) bool {
+func IsParticipatedByBidId(in *bxcore.ParticipateActionReq) (entUserName string) {
 	defer MC.Catch()
 	//如果不允许多人参标 当前项目是否已经有企业其他人员参标
-	query := fmt.Sprintf(`SELECT count(id) FROM `+ParticipateUserTable+` WHERE %s AND project_id = %s AND state >-1`, "%s", in.ProjectIds)
+	query := fmt.Sprintf(`SELECT ent_id,ent_user_id FROM `+ParticipateUserTable+` WHERE %s AND project_id = '%s' AND state >-1`, "%s", in.ProjectIds)
 	if in.PositionType > 0 { //企业版
 		query = fmt.Sprintf(query, fmt.Sprintf("ent_id = %d", in.EntId))
 	} else { //个人版
 		query = fmt.Sprintf(query, fmt.Sprintf("position_id = %d", in.PositionId))
 	}
-	return IC.BaseMysql.CountBySql(query) > 0
+	data := IC.BaseMysql.SelectBySql(query)
+	if data != nil && len(*data) > 0 {
+		partInfo := (*data)[0]
+		if entUserId := MC.Int64All(partInfo["ent_user_id"]); entUserId > 0 {
+			userInfo := IC.Middleground.UserCenter.IdentityByEntUserId(entUserId)
+			entUserName = userInfo.EntUserName
+		}
+	}
+	return
 }
 
 // 获取参标权限
@@ -310,8 +318,9 @@ func UpdateParticipateSetInfo(in *bxcore.ParticipateSetUpInfoReq) error {
 	if in.IsAllow != "" {
 		if in.IsAllow == "0" { //修改为允许单人参标
 			//判断是否有多人参标的项目
-			pSql := `SELECT project_id,COUNT(id) AS c FROM ` + ParticipateUserTable + ` WHERE ent_id = ?  AND state =0 GROUP BY project_id ORDER BY c DESC;`
-			data := IC.BaseMysql.SelectBySql(pSql, in.EntId)
+			//pSql := `SELECT project_id,COUNT(id) AS c FROM ` + ParticipateUserTable + ` WHERE ent_id = ?  AND state =0 GROUP BY project_id ORDER BY c DESC;`
+			pSql := `SELECT pu.project_id,COUNT(pu.id) AS c,p.bid_end_time,p.bid_open_time FROM ` + ParticipateUserTable + ` pu LEFT JOIN project p ON pu.project_id = p.id WHERE pu.ent_id = ?  AND pu.state =0 AND ((p.bid_open_time IS NOT NULL AND p.bid_open_time > ?) OR (p.bid_open_time IS NULL  AND p.bid_end_time IS NOT NULL AND p.bid_end_time > ?)) GROUP BY pu.project_id ORDER BY c DESC`
+			data := IC.BaseMysql.SelectBySql(pSql, in.EntId, time.Now().Format(date.Date_Full_Layout), time.Now().Format(date.Date_Full_Layout))
 			if data != nil && len(*data) > 0 {
 				if max := MC.IntAll((*data)[0]["c"]); max > 1 {
 					return fmt.Errorf("公司当前有项目多人参标的情况,请先确保项目都是单人参标的前提下再调整配置。\n前往”企业参标项目列表“查看具体情况。")

+ 2 - 2
jyBXCore/rpc/service/participate.go

@@ -86,8 +86,8 @@ func ParticipateDo(in *bxcore.ParticipateActionReq) error {
 		}
 		//是否允许多人参标
 		if isAllow := mysql.IsALLow(in.EntId); !isAllow {
-			if ok := mysql.IsParticipatedByBidId(in); ok {
-				return fmt.Errorf("当前项目不允许多人参标")
+			if entUserName := mysql.IsParticipatedByBidId(in); entUserName != "" {
+				return fmt.Errorf(fmt.Sprintf("该项目已被 %s 参标", entUserName))
 			}
 		}
 		//保存参标信息  更新当前企业参标项目记录