Sfoglia il codice sorgente

Merge branch 'dev/v1.1.20_fuwencai' of BaseService/jyMicroservices into feature/v1.1.20

fuwencai 2 anni fa
parent
commit
a8a0349b23

+ 1 - 0
jyBXCore/api/bxcore.api

@@ -106,6 +106,7 @@ type (
 	// 当前部门/企业下参标人员信息
 	participatePersonsReq {
 		baseParam
+		ProjectId string `json:"projectId,optional"` //项目id
 	}
 
 	//投标状态更新:投标类型-投标项目阶段

+ 18 - 2
jyBXCore/api/internal/logic/participatePersonsLogic.go

@@ -2,6 +2,7 @@ package logic
 
 import (
 	"context"
+	"jyBXCore/rpc/type/bxcore"
 	"net/http"
 
 	"jyBXCore/api/internal/svc"
@@ -27,7 +28,22 @@ func NewParticipatePersonsLogic(ctx context.Context, svcCtx *svc.ServiceContext,
 }
 
 func (l *ParticipatePersonsLogic) ParticipatePersons(req *types.ParticipatePersonsReq) (resp *types.CommonResp, err error) {
-	// todo: add your logic here and delete this line
-
+	res, err := l.svcCtx.BxCore.ParticipatePersons(l.ctx, &bxcore.ParticipatePersonsReq{
+		EntId:        req.EntId,
+		EntUserId:    req.EntUserId,
+		PositionId:   req.PositionId,
+		PositionType: req.PositionType,
+		MgoUserId:    req.MgoUserId,
+		AppId:        req.AppId,
+		UserId:       req.UserId,
+		NewUserId:    req.NewUserId,
+		AccountId:    req.AccountId,
+		ProjectId:    req.ProjectId, //项目信息id 移动需要
+	})
+	return &types.CommonResp{
+		Err_code: res.ErrCode,
+		Err_msg:  res.ErrMsg,
+		Data:     res.Data,
+	}, nil
 	return
 }

+ 1 - 0
jyBXCore/api/internal/types/types.go

@@ -99,6 +99,7 @@ type ParticipateRecordsReq struct {
 
 type ParticipatePersonsReq struct {
 	BaseParam
+	ProjectId string `json:"projectId,optional"` //项目id
 }
 
 type BidTypeReq struct {

+ 20 - 11
jyBXCore/rpc/bxcore.proto

@@ -176,6 +176,7 @@ message ParticipateDetailInfo{
   string userName = 4;//参标人姓名 逗号分割
   string projectId = 5;// 项目id
   int64 bidEndTime = 6 ;// 投标截止时间
+  int64 currentTime = 7 ;// 服务器当前时间
 
 }
 message ParticipateInfoRes{
@@ -283,14 +284,20 @@ message ParticipatePersonsReq{
   string mgoUserId = 5;  //原userId
   string appId = 6;//剑鱼默认10000
   string  userId = 7;//用户id
-  string  newUserId = 8;//base_user_id 新用户id
-  string accountId = 9; //账户id
-
+  int64  newUserId = 8;//base_user_id 新用户id
+  int64 accountId = 9; //账户id
+  string projectId = 10; //项目id  移动端需要
 }
 
 message ParticipatePerson{
-  string userId = 1;
-  string name = 2;
+  string id = 1;
+  string name = 2;//项目名称
+  int64  pid = 3;//父级id
+  int64  power = 4;//是否有权限
+  string phone = 5;//手机号
+  string role = 6;//角色
+  int64  isPart = 7;//当前项目是否参标
+  repeated ParticipatePerson users = 8;//人员
 }
 
 message ParticipatePersonsRes{
@@ -391,15 +398,17 @@ message  ParticipateList{
   string buyer = 3;//采购单位
   string budget = 4;//预算
   string participants = 5;//参标人 多个,号隔开
-  string bidTime = 6;//招标日期
-  string bidEndTime = 7;//投标截止日期
-  string bidOpenTime = 8;//投标截止日期
-  string updateStatusTime = 9;//更新状态时间
+  int64 bidTime = 6;//招标日期
+  int64 bidEndTime = 7;//投标截止日期
+  int64 bidOpenTime = 8;//投标截止日期
+  int64 updateStatusTime = 9;//更新状态时间
   string updateStatusCon = 10;//投标状态更新
 }
 message  ParticipateData{
-  int64 count = 1;
-  repeated ParticipateList list = 2;
+  int64 nowTime = 1;//当前系统时间
+  bool isAllow = 2;//是否允许多人参标
+  int64 count = 3;
+  repeated ParticipateList list = 4;
 }
 message ParticipateListRes{
   int64 err_code = 1;

+ 1 - 1
jyBXCore/rpc/internal/logic/participatecontentlogic.go

@@ -51,7 +51,7 @@ func (l *ParticipateContentLogic) ParticipateContent(in *bxcore.ParticipateConte
 	// 根据标讯id 查询项目信息
 	projectInfos := es.GetProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
-		result.ErrMsg = "未查询到项目信息"
+		result.ErrCode = 0
 		return result, nil
 	}
 	// 验证身份

+ 2 - 2
jyBXCore/rpc/internal/logic/participateinfologic.go

@@ -55,14 +55,14 @@ func (l *ParticipateInfoLogic) ParticipateInfo(in *bxcore.ParticipateInfoReq) (*
 	// 2. 根据标讯id 查询项目信息
 	projectInfos := es.GetProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
-		result.ErrMsg = "未查询到项目信息"
+		result.ErrCode = 0
 		return &result, nil
 	}
 	// 判断是否已经过了开标时间
 	var isValid bool
 	bidopentime := common.Int64All((*projectInfos)[0]["bidopentime"])
 	bidendtime := common.Int64All((*projectInfos)[0]["bidendtime"])
-	if time.Now().Unix() >= bidopentime || bidopentime == 0 {
+	if time.Now().Unix() < bidopentime || bidopentime == 0 {
 		isValid = true
 	}
 	//   获取项目id

+ 2 - 3
jyBXCore/rpc/internal/logic/participatepersonslogic.go

@@ -2,6 +2,7 @@ package logic
 
 import (
 	"context"
+	"jyBXCore/rpc/service"
 
 	"jyBXCore/rpc/internal/svc"
 	"jyBXCore/rpc/type/bxcore"
@@ -25,7 +26,5 @@ func NewParticipatePersonsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 
 //  当前部门/企业下参标人员信息
 func (l *ParticipatePersonsLogic) ParticipatePersons(in *bxcore.ParticipatePersonsReq) (*bxcore.ParticipatePersonsRes, error) {
-	// todo: add your logic here and delete this line
-
-	return &bxcore.ParticipatePersonsRes{}, nil
+	return service.GetParticipatePersonInfo(in), nil
 }

+ 1 - 1
jyBXCore/rpc/internal/logic/participaterecordslogic.go

@@ -51,7 +51,7 @@ func (l *ParticipateRecordsLogic) ParticipateRecords(in *bxcore.ParticipateRecor
 	// 根据标讯id 查询项目信息
 	projectInfos := es.GetProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
-		result.ErrMsg = "未查询到项目信息"
+		result.ErrCode = 0
 		return result, nil
 	}
 	// 验证身份

+ 1 - 1
jyBXCore/rpc/internal/logic/participateshowlogic.go

@@ -52,7 +52,7 @@ func (l *ParticipateShowLogic) ParticipateShow(in *bxcore.ParticipateShowReq) (*
 	// 查有效项目id信息
 	projectInfos := es.GetValidProjectByInfoId(infoList)
 	if projectInfos == nil || len(*projectInfos) == 0 {
-		result.ErrMsg = "未查询到信息"
+		result.ErrCode = 0
 		return &result, nil
 	}
 	// 记录信息id和项目id的映射  用于最后处理返回数据

+ 1 - 1
jyBXCore/rpc/internal/logic/updatebidstatuslogic.go

@@ -58,7 +58,7 @@ func (l *UpdateBidStatusLogic) UpdateBidStatus(in *bxcore.UpdateBidStatusReq) (*
 	var isValid bool
 	bidopentime := common.Int64All((*projectInfos)[0]["bidopentime"])
 	projectId := common.ObjToString((*projectInfos)[0]["_id"])
-	if time.Now().Unix() >= bidopentime || bidopentime == 0 {
+	if time.Now().Unix() < bidopentime || bidopentime == 0 {
 		isValid = true
 	}
 	if !isValid {

+ 16 - 2
jyBXCore/rpc/model/es/project.go

@@ -33,8 +33,22 @@ 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": {"bidopentime": {"gte": ` + fmt.Sprint(nowTime) + `}}},
-        {"constant_score": {"filter": {"missing": {"field": "bidopentime"
-                    } } } }] }}]}}}`
+        {
+    "bool": {
+        "must_not": [
+            {
+                "constant_score": {
+                    "filter": {
+                        "exists": {
+                            "field": "bidopentime"
+                        }
+                    }
+                }
+            }
+        ]
+    }
+}
+] }}]}}}`
 
 	projectResult := elastic.Get(IndexProjectSet, TypeProjectSet, query)
 	return projectResult

+ 192 - 73
jyBXCore/rpc/model/mysql/participateBid.go

@@ -49,13 +49,13 @@ func TransferParticipateInfo(projectId string, in *bxcore.ParticipateActionReq)
 	//保存或更新新跟踪人
 	if !IC.BaseMysql.ExecTx("划转参标信息", func(tx *sql.Tx) bool {
 		var (
-			b1            = true
-			b2, b3        bool
-			now           = time.Now()
-			content       = "%s划转给%s%s"
-			lastNotes     = ",保留原参标人"
-			fromUserNames []string
-			ids           []int
+			b1                                             = true
+			b2, b3                                         bool
+			now                                            = time.Now()
+			content                                        = "%s划转给%s%s"
+			lastNotes                                      = ",保留原参标人"
+			fromEntUserNames, toEntUserNames, toEntUserIds []string
+			ids                                            []int
 		)
 		partInfo := IC.BaseMysql.SelectBySqlByTx(tx, "SELECT id,position_id FROM "+ParticipateUserTable+" WHERE  project_id = ?  AND ent_id = ? AND state > -1", projectId, in.EntId)
 		if partInfo == nil || len(*partInfo) == 0 {
@@ -67,11 +67,11 @@ func TransferParticipateInfo(projectId string, in *bxcore.ParticipateActionReq)
 				positionId := MC.Int64All(v["position_id"])
 				userInfo := IC.Middleground.UserCenter.IdentityByPositionId(positionId)
 				if userInfo.EntUserName != "" {
-					fromUserNames = append(fromUserNames, userInfo.EntUserName)
+					fromEntUserNames = append(fromEntUserNames, userInfo.EntUserName)
 				}
 			}
 		}
-		if len(fromUserNames) == 0 {
+		if len(fromEntUserNames) == 0 {
 			logx.Info("原参标人信息查询有误")
 			return false
 		}
@@ -89,48 +89,70 @@ func TransferParticipateInfo(projectId string, in *bxcore.ParticipateActionReq)
 				"update_date": date.FormatDate(&now, date.Date_Full_Layout),
 			})
 		}
-		//查询划转人信息
-		entUserId, _ := strconv.ParseInt(in.ToEntUserId, 10, 64)
-		userInfo := IC.Middleground.UserCenter.IdentityByEntUserId(entUserId)
-		positionId := userInfo.PositionId
-		content = fmt.Sprintf(content, strings.Join(fromUserNames, ","), userInfo.EntUserName, lastNotes)
+		//移动端 划转对象是多选
+		//划转对象entuserid 解密
+		for _, toEntUserId := range strings.Split(in.ToEntUserId, ",") {
+			toEntUserId = encrypt.SE.Decode4HexByCheck(toEntUserId)
+			if toEntUserId == "" {
+				logx.Info("划转对象不能为空", in.ProjectIds, in.EntId)
+				continue
+			}
+			//查询划转人信息
+			entUserId, _ := strconv.ParseInt(toEntUserId, 10, 64)
+			userInfo := IC.Middleground.UserCenter.IdentityByEntUserId(entUserId)
+			positionId := userInfo.PositionId
+			//保存参标--participate_user
+			//查看是否参标过当前项目
+			if c := IC.BaseMysql.CountBySql("SELECT count(id) FROM "+ParticipateUserTable+" WHERE position_id = ? AND project_id = ?  AND ent_id = ?", positionId, projectId, in.EntId); c > 0 {
+				//更新
+				b3 = IC.BaseMysql.UpdateByTx(tx, ParticipateUserTable, map[string]interface{}{
+					"position_id": positionId,
+					"project_id":  projectId,
+					"ent_id":      in.EntId,
+				}, map[string]interface{}{
+					"state":       0,
+					"mark":        1, //0:参标;1:被划入;-1:终止参标;-2:被划走
+					"update_date": date.FormatDate(&now, date.Date_Full_Layout),
+				})
+			} else {
+				//保存
+				b3 = IC.BaseMysql.InsertByTx(tx, ParticipateUserTable, map[string]interface{}{
+					"ent_id":      in.EntId,
+					"ent_user_id": entUserId,
+					"position_id": positionId,
+					"project_id":  projectId,
+					"user_id":     in.MgoUserId,
+					"state":       0,
+					"mark":        1, //0:参标;1:被划入;-1:终止参标;-2:被划走
+					"create_date": date.FormatDate(&now, date.Date_Full_Layout),
+					"update_date": date.FormatDate(&now, date.Date_Full_Layout),
+				}) > 0
+			}
+			if b3 {
+				toEntUserIds = append(toEntUserIds, toEntUserId)
+				toEntUserNames = append(toEntUserNames, userInfo.EntUserName)
+			}
+		}
+		//保存多个用户时  如果个别用户划转参标项目异常,直接跳过此用户,保存其他用户信息
+		//防止最后一个用户保存异常
+		if len(toEntUserIds) > 0 {
+			b3 = true
+		}
+		//移动端单个项目划转给多个用户,划转记录保存一份,当前企业下参过标的或当前正在参标的人都能看到次记录
+		//企业下 根据企业id 和项目id查询划转记录
+		//个人版 根据职位id 和项目id查询划转记录
 		//划转记录
 		b2 = IC.BaseMysql.InsertByTx(tx, ParticipateBidRecordsTable, map[string]interface{}{
-			"ent_id":         in.EntId,
-			"ent_user_id":    entUserId,
-			"position_id":    positionId,
-			"project_id":     projectId,
-			"record_type":    0,
-			"record_content": content,
-			"create_date":    date.FormatDate(&now, date.Date_Full_Layout),
+			"ent_id":               in.EntId,
+			"ent_user_id":          in.EntUserId,
+			"position_id":          in.PositionId,
+			"project_id":           projectId,
+			"record_type":          0,
+			"transfer_ent_user_id": strings.Join(toEntUserIds, ","),
+			"record_content":       fmt.Sprintf(content, strings.Join(fromEntUserNames, "、"), strings.Join(toEntUserNames, "、"), lastNotes),
+			"create_date":          date.FormatDate(&now, date.Date_Full_Layout),
 		}) > 0
-		//保存参标--participate_user
-		//查看是否参标过当前项目
-		if c := IC.BaseMysql.CountBySql("SELECT count(id) FROM "+ParticipateUserTable+" WHERE position_id = ? AND project_id = ?  AND ent_id = ?", positionId, projectId, in.EntId); c > 0 {
-			//更新
-			b3 = IC.BaseMysql.UpdateByTx(tx, ParticipateUserTable, map[string]interface{}{
-				"position_id": positionId,
-				"project_id":  projectId,
-				"ent_id":      in.EntId,
-			}, map[string]interface{}{
-				"state":       0,
-				"mark":        1, //0:参标;1:被划入;-1:终止参标;-2:被划走
-				"update_date": date.FormatDate(&now, date.Date_Full_Layout),
-			})
-		} else {
-			//保存
-			b3 = IC.BaseMysql.InsertByTx(tx, ParticipateUserTable, map[string]interface{}{
-				"ent_id":      in.EntId,
-				"ent_user_id": entUserId,
-				"position_id": positionId,
-				"project_id":  projectId,
-				"user_id":     in.MgoUserId,
-				"state":       0,
-				"mark":        1, //0:参标;1:被划入;-1:终止参标;-2:被划走
-				"create_date": date.FormatDate(&now, date.Date_Full_Layout),
-				"update_date": date.FormatDate(&now, date.Date_Full_Layout),
-			}) > 0
-		}
+
 		return b1 && b2 && b3
 	}) {
 		logx.Info(in.PositionId, "---终止---", projectId)
@@ -196,13 +218,13 @@ func SaveParticipateInfo(in *bxcore.ParticipateActionReq) error {
 		if c := IC.BaseMysql.CountBySql("SELECT count(id) FROM "+ParticipateUserTable+" WHERE position_id = ? AND project_id = ?  AND ent_id = ?", in.PositionId, in.ProjectIds, in.EntId); c > 0 {
 			//更新
 			b1 = IC.BaseMysql.UpdateByTx(tx, ParticipateUserTable, map[string]interface{}{
-				"state":       0,
-				"mark":        0,
-				"update_date": date.FormatDate(&now, date.Date_Full_Layout),
-			}, map[string]interface{}{
 				"position_id": in.PositionId,
 				"ent_id":      in.EntId,
 				"project_id":  in.ProjectIds,
+			}, map[string]interface{}{
+				"state":       0,
+				"mark":        0,
+				"update_date": date.FormatDate(&now, date.Date_Full_Layout),
 			})
 		} else {
 			//保存
@@ -236,10 +258,10 @@ func SaveParticipateInfo(in *bxcore.ParticipateActionReq) error {
 		}
 		//保存或更新项目信息
 		//有问题 其他回滚,项目信息不用回滚
-		b3 = UpdateProjectInfo(in.ProjectIds, es.GetProjectInfo(in.ProjectIds), es.GetBiddingInfo(in.BidIds)) == nil
+		b3 = UpdateProjectInfo(in.ProjectIds, es.GetProjectInfo(in.ProjectIds)) == nil
 		return b1 && b2 && b3
 	}) {
-		logx.Info(in.PositionId, "---保存---", in.BidIds)
+		logx.Info(in.PositionId, "---保存---", in.ProjectIds)
 		return fmt.Errorf("保存参标信息出错")
 	}
 	return nil
@@ -249,7 +271,7 @@ func SaveParticipateInfo(in *bxcore.ParticipateActionReq) error {
 func IsParticipatedByBidId(in *bxcore.ParticipateActionReq) bool {
 	defer MC.Catch()
 	//如果不允许多人参标 当前项目是否已经有企业其他人员参标
-	query := fmt.Sprintf(`SELECT count(id) FROM `+ParticipateUserTable+` WHERE %s AND project_id = %s AND state >-1`, "%s", in.BidIds)
+	query := fmt.Sprintf(`SELECT count(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 { //个人版
@@ -374,7 +396,7 @@ func GetParticipateSetInfo(in *bxcore.ParticipateSetUpInfoReq) (*bxcore.Particip
 }
 
 //保存或更新tidb 项目信息
-func UpdateProjectInfo(id string, pInfo map[string]interface{}, bInfo map[string]interface{}) error {
+func UpdateProjectInfo(id string, pInfo map[string]interface{}) error {
 	//id 项目id
 	//name 项目名称
 	//area  省份
@@ -382,8 +404,8 @@ func UpdateProjectInfo(id string, pInfo map[string]interface{}, bInfo map[string
 	//buyer 采购单位
 	//budget 预算
 	//bid_open_time  开标时间
-	//bid_time 招标时间  bidding表
-	//bid_end_time 开标结束时间  bidding表
+	//zbtime 招标时间
+	//bid_end_time 开标结束时间  bidding表 由 数据组 重新生索引到project表
 	//pici 批次 轮询更新数据
 	//
 	projectInfo := map[string]interface{}{
@@ -407,8 +429,8 @@ func UpdateProjectInfo(id string, pInfo map[string]interface{}, bInfo map[string
 		bidTime := pInfo["zbtime"]
 		projectInfo["bid_time"] = date.FormatDateWithObj(&bidTime, date.Date_Full_Layout)
 	}
-	if bInfo["bidendtime"] != nil {
-		bidEndTime := bInfo["bidendtime"]
+	if pInfo["bidendtime"] != nil {
+		bidEndTime := pInfo["bidendtime"]
 		projectInfo["bid_end_time"] = date.FormatDateWithObj(&bidEndTime, date.Date_Full_Layout)
 	}
 	if c := IC.BaseMysql.CountBySql(`SELECT COUNT(id) FROM project WHERE id = ?`, id); c > 0 {
@@ -585,8 +607,9 @@ func ParticipateListSql(in *bxcore.ParticipateListReq) string {
 func SingleParticipateList(in *bxcore.ParticipateListReq, conditionSql string) (data *bxcore.ParticipateData, err error) {
 	defer MC.Catch()
 	data = &bxcore.ParticipateData{
-		Count: 0,
-		List:  []*bxcore.ParticipateList{},
+		NowTime: time.Now().Unix(),
+		Count:   0,
+		List:    []*bxcore.ParticipateList{},
 	}
 	//员工|个人列表
 	singlePersonSql := `SELECT %s FROM ` + ParticipateUserTable + ` pug LEFT JOIN project pt ON pug.project_id = pt.id WHERE pug.position_id = ? `
@@ -601,15 +624,38 @@ func SingleParticipateList(in *bxcore.ParticipateListReq, conditionSql string) (
 		list := IC.BaseMysql.SelectBySql(listSql, in.PositionId)
 		if list != nil && len(*list) > 0 {
 			for _, v := range *list {
+				bidTimeStr := MC.ObjToString(v["bid_time"])
+				bidEndTimeStr := MC.ObjToString(v["bid_end_time"])
+				bidOpenTimeStr := MC.ObjToString(v["bid_open_time"])
+				updateStatusTimeStr := MC.ObjToString(v["update_date"])
+				var bidTime, bidEndTime, bidOpenTime, updateStatusTime int64
+				if bidTimeStr != "" {
+					bidTime_, _ := time.ParseInLocation(date.Date_Full_Layout, bidTimeStr, time.Local)
+					bidTime = bidTime_.Unix()
+				}
+
+				if bidEndTimeStr != "" {
+					bidEndTime_, _ := time.ParseInLocation(date.Date_Full_Layout, bidEndTimeStr, time.Local)
+					bidEndTime = bidEndTime_.Unix()
+				}
+
+				if bidOpenTimeStr != "" {
+					bidOpenTime_, _ := time.ParseInLocation(date.Date_Full_Layout, bidOpenTimeStr, time.Local)
+					bidOpenTime = bidOpenTime_.Unix()
+				}
+				if updateStatusTimeStr != "" {
+					updateStatusTime_, _ := time.ParseInLocation(date.Date_Full_Layout, updateStatusTimeStr, time.Local)
+					updateStatusTime = updateStatusTime_.Unix()
+				}
 				data.List = append(data.List, &bxcore.ParticipateList{
 					Id:               encrypt.EncodeArticleId2ByCheck(MC.ObjToString(v["id"])),
 					ProjectName:      MC.ObjToString(v["name"]),
 					Buyer:            MC.ObjToString(v["buyer"]),
 					Budget:           MC.ObjToString(v["budget"]),
-					BidTime:          MC.ObjToString(v["bid_time"]),
-					BidEndTime:       MC.ObjToString(v["bid_end_time"]),
-					BidOpenTime:      MC.ObjToString(v["bid_open_time"]),
-					UpdateStatusTime: MC.ObjToString(v["update_date"]),
+					BidTime:          bidTime,
+					BidEndTime:       bidEndTime,
+					BidOpenTime:      bidOpenTime,
+					UpdateStatusTime: updateStatusTime,
 					UpdateStatusCon:  GetParticipateContent("s", in.PositionId, MC.ObjToString(v["id"])), //查询最后一次 投标状态更新,
 				})
 			}
@@ -624,8 +670,9 @@ func SingleParticipateList(in *bxcore.ParticipateListReq, conditionSql string) (
 func AdminParticipateList(in *bxcore.ParticipateListReq, conditionSql string) (data *bxcore.ParticipateData, err error) {
 	defer MC.Catch()
 	data = &bxcore.ParticipateData{
-		Count: 0,
-		List:  []*bxcore.ParticipateList{},
+		NowTime: time.Now().Unix(),
+		Count:   0,
+		List:    []*bxcore.ParticipateList{},
 	}
 	adminSql := `SELECT %s FROM (SELECT pu.ent_id, pu.project_id, GROUP_CONCAT(pu.ent_user_id SEPARATOR ',') ent_user_id, MAX(pu.update_date) update_date,MAX(pu.state) state FROM ` + ParticipateUserTable + ` pu WHERE pu.ent_id = ? AND NOT EXISTS ( SELECT 1 FROM ` + ParticipateUserTable + ` WHERE project_id = pu.project_id AND state > pu. state ) GROUP BY pu.project_id ) pug LEFT JOIN project pt ON pug.project_id = pt.id`
 	adminCountSql := fmt.Sprintf(adminSql, "COUNT(pt.id)") + conditionSql
@@ -638,15 +685,39 @@ func AdminParticipateList(in *bxcore.ParticipateListReq, conditionSql string) (d
 		list := IC.BaseMysql.SelectBySql(adminListSql, in.EntId)
 		if list != nil && len(*list) > 0 {
 			for _, v := range *list {
+				bidTimeStr := MC.ObjToString(v["bid_time"])
+				bidEndTimeStr := MC.ObjToString(v["bid_end_time"])
+				bidOpenTimeStr := MC.ObjToString(v["bid_open_time"])
+				updateStatusTimeStr := MC.ObjToString(v["update_date"])
+				var bidTime, bidEndTime, bidOpenTime, updateStatusTime int64
+				if bidTimeStr != "" {
+					bidTime_, _ := time.ParseInLocation(date.Date_Full_Layout, bidTimeStr, time.Local)
+					bidTime = bidTime_.Unix()
+				}
+
+				if bidEndTimeStr != "" {
+					bidEndTime_, _ := time.ParseInLocation(date.Date_Full_Layout, bidEndTimeStr, time.Local)
+					bidEndTime = bidEndTime_.Unix()
+				}
+
+				if bidOpenTimeStr != "" {
+					bidOpenTime_, _ := time.ParseInLocation(date.Date_Full_Layout, bidOpenTimeStr, time.Local)
+					bidOpenTime = bidOpenTime_.Unix()
+				}
+				if updateStatusTimeStr != "" {
+					updateStatusTime_, _ := time.ParseInLocation(date.Date_Full_Layout, updateStatusTimeStr, time.Local)
+					updateStatusTime = updateStatusTime_.Unix()
+				}
+
 				data.List = append(data.List, &bxcore.ParticipateList{
 					Id:               encrypt.EncodeArticleId2ByCheck(MC.ObjToString(v["id"])),
 					ProjectName:      MC.ObjToString(v["name"]),
 					Buyer:            MC.ObjToString(v["buyer"]),
 					Budget:           MC.ObjToString(v["budget"]),
-					BidTime:          MC.ObjToString(v["bid_time"]),
-					BidEndTime:       MC.ObjToString(v["bid_end_time"]),
-					BidOpenTime:      MC.ObjToString(v["bid_open_time"]),
-					UpdateStatusTime: MC.ObjToString(v["update_date"]),
+					BidTime:          bidTime,
+					BidEndTime:       bidEndTime,
+					BidOpenTime:      bidOpenTime,
+					UpdateStatusTime: updateStatusTime,
 					UpdateStatusCon:  GetParticipateContent("e", in.EntId, MC.ObjToString(v["id"])), //查询最后一次 投标状态更新
 					Participants:     GetParticipateUserName(MC.ObjToString(v["ent_user_id"])),      //参标人信息
 				})
@@ -828,7 +899,55 @@ func ParticipateProjectEnt(entId int64, projectId []string) *[]map[string]interf
 		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 "
+	query := "select GROUP_CONCAT(ent_user_id) as personIds ,project_id from " + ParticipateUserTable + " 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
 }
+
+//查询企业人员信息
+func GetPersonInfo(entId, entUserId int64, participateMap map[int64]bool) []*bxcore.ParticipatePerson {
+	r := IC.MainMysql.SelectBySql(`SELECT a.id,a.pid,a.name,c.id as user_id,c.name as user_name,c.phone as user_phone,c.power as user_power,e.name as role from entniche_department a 
+			INNER JOIN entniche_department_user b on (a.ent_id=? and a.id=b.dept_id) 
+			INNER JOIN entniche_user c on (b.user_id=c.id) 
+			LEFT JOIN entniche_user_role d on (c.id=d.user_id) 
+			LEFT JOIN entniche_role e on (d.role_id=e.id) 
+			order by a.id,convert(c.name using gbk) COLLATE gbk_chinese_ci asc`, entId)
+	var (
+		list   []*bxcore.ParticipatePerson
+		prevId int64 = 0
+	)
+	for _, v := range *r {
+		if entUserId == MC.Int64All(v["user_id"]) {
+			continue
+		}
+		id := MC.Int64All(v["id"])
+		userId := strconv.FormatInt(MC.Int64All(v["user_id"]), 10)
+		user := &bxcore.ParticipatePerson{
+			Id:    encrypt.SE.Encode2HexByCheck(userId),
+			Power: MC.Int64All(v["user_power"]),
+			Name:  MC.ObjToString(v["user_name"]),
+			Phone: MC.ObjToString(v["user_phone"]),
+			Role:  MC.ObjToString(v["role"]),
+		}
+		if participateMap != nil {
+			if participateMap[MC.Int64All(v["user_id"])] {
+				user.IsPart = 1
+			}
+		}
+		if prevId == id {
+			users := list[len(list)-1].Users
+			users = append(users, user)
+			list[len(list)-1].Users = users
+		} else {
+			seId := strconv.FormatInt(id, 10)
+			list = append(list, &bxcore.ParticipatePerson{
+				Id:    encrypt.SE.Encode2HexByCheck(seId),
+				Name:  MC.ObjToString(v["name"]),
+				Pid:   MC.Int64All(v["pid"]),
+				Users: []*bxcore.ParticipatePerson{user},
+			})
+		}
+		prevId = id
+	}
+	return list
+}

+ 75 - 56
jyBXCore/rpc/service/participate.go

@@ -10,6 +10,7 @@ import (
 	"jyBXCore/rpc/model/mysql"
 	"jyBXCore/rpc/type/bxcore"
 	"jyBXCore/rpc/util"
+	"strconv"
 	"strings"
 )
 
@@ -62,15 +63,6 @@ func ParticipateList(in *bxcore.ParticipateListReq) (*bxcore.ParticipateListRes,
 //参标动作:参标、终止参标、划转:in:参标;out:终止参标;transfer:划转
 func ParticipateDo(in *bxcore.ParticipateActionReq) error {
 	defer MC.Catch()
-	var (
-		tip = "参标"
-	)
-	switch in.ActionType {
-	case "out":
-		tip = "终止参标"
-	case "transfer":
-		tip = "划转"
-	}
 	//企业版 判断是否是管理员
 	//判断用户身份
 	userInfo := IC.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntId, in.PositionType, in.PositionId)
@@ -79,45 +71,8 @@ func ParticipateDo(in *bxcore.ParticipateActionReq) error {
 		if in.BidIds == "" && in.ProjectIds == "" {
 			return fmt.Errorf("缺少参数")
 		}
-		if in.ProjectIds != "" {
-			in.ProjectIds = strings.Split(in.ProjectIds, ",")[0]
-			in.ProjectIds = encrypt.DecodeArticleId2ByCheck(in.ProjectIds)[0]
-			if in.ProjectIds == "" {
-				return fmt.Errorf("当前招标信息有误")
-			}
-			//当前项目是否符合参标条件
-			projectInfos := es.GetBidInfoByPId(in.ProjectIds)
-			if projectInfos == nil || len(*projectInfos) == 0 {
-				return fmt.Errorf(fmt.Sprintf("当前项目信息不满足%s条件", tip))
-			}
-			//符合参标项目id
-			projectInfo := (*projectInfos)[0]
-			if projectInfo["sourceinfoid"] != nil && MC.ObjToString(projectInfo["sourceinfoid"]) != "" {
-				//招标信息id
-				in.BidIds = MC.ObjToString(projectInfo["sourceinfoid"])
-			} else {
-				return fmt.Errorf("当前项目信息有误")
-			}
-		} else {
-			in.BidIds = strings.Split(in.BidIds, ",")[0]
-			//招标信息解密
-			in.BidIds = encrypt.DecodeArticleId2ByCheck(in.BidIds)[0]
-			if in.BidIds == "" {
-				return fmt.Errorf("当前招标信息有误")
-			}
-			//当前项目是否符合参标条件
-			projectInfos := es.GetProjectByInfoId(strings.Split(in.BidIds, ","))
-			if projectInfos == nil || len(*projectInfos) == 0 {
-				return fmt.Errorf(fmt.Sprintf("当前项目信息不满足%s条件", tip))
-			}
-			//符合参标项目id
-			projectInfo := (*projectInfos)[0]
-			if projectInfo["_id"] != nil && MC.ObjToString(projectInfo["_id"]) != "" {
-				//项目信息id
-				in.ProjectIds = MC.ObjToString(projectInfo["_id"])
-			} else {
-				return fmt.Errorf("当前项目信息有误")
-			}
+		if err := GetProjectInfoByES(in); err != nil {
+			return err
 		}
 		//是否允许多人参标
 		if isAllow := util.IsALLow(in.EntId); !isAllow {
@@ -130,19 +85,18 @@ func ParticipateDo(in *bxcore.ParticipateActionReq) error {
 			return err
 		}
 	case "out": //终止参标
-		if in.ProjectIds == "" {
-			return fmt.Errorf("项目信息有误")
+		if in.BidIds == "" && in.ProjectIds == "" {
+			return fmt.Errorf("缺少参数")
 		}
-		in.ProjectIds = strings.Split(in.ProjectIds, ",")[0]
-		//招标信息解密
-		in.ProjectIds = encrypt.DecodeArticleId2ByCheck(in.ProjectIds)[0]
-		if in.ProjectIds == "" {
-			return fmt.Errorf("当前项目信息有误")
+		if err := GetProjectInfoByES(in); err != nil {
+			return err
 		}
 		if err := mysql.CancelParticipateInfo(in, userInfo.Ent.EntRoleId); err != nil {
 			return err
 		}
 	case "transfer":
+		//PC端 多个项目-》一个人
+		//移动端  一个项目-》多个人
 		if in.ProjectIds == "" {
 			return fmt.Errorf("项目信息有误")
 		}
@@ -160,7 +114,7 @@ func ParticipateDo(in *bxcore.ParticipateActionReq) error {
 		}
 		//是否保留原跟踪人?
 		isAllow := util.IsALLow(in.EntId)
-		if in.IsRetain && !isAllow {
+		if (in.IsRetain || len(strings.Split(in.ToEntUserId, ",")) > 1) && !isAllow {
 			//不允许多人参标,但是前端参数又是保留原参标人 互相矛盾
 			return fmt.Errorf("当前项目只允许一人参标")
 		}
@@ -212,3 +166,68 @@ func GetParticipateSetInfo(in *bxcore.ParticipateSetUpInfoReq) (*bxcore.Particip
 	}
 	return res, nil
 }
+
+//参标企业人员信息
+func GetParticipatePersonInfo(in *bxcore.ParticipatePersonsReq) *bxcore.ParticipatePersonsRes {
+	var (
+		participateMap = map[int64]bool{}
+	)
+	if in.ProjectId != "" {
+		participateInfos := mysql.ParticipateProjectEnt(in.EntId, strings.Split(in.ProjectId, ","))
+		if participateInfos != nil && len(*participateInfos) > 0 {
+			participateInfo := (*participateInfos)[0]
+			personIds := MC.ObjToString(participateInfo["personIds"])
+			if personIds != "" {
+				for _, p := range strings.Split(personIds, ",") {
+					personId, _ := strconv.ParseInt(p, 10, 64)
+					participateMap[personId] = true
+				}
+			}
+		}
+	}
+	//查询企业人员信息
+	personInfos := mysql.GetPersonInfo(in.EntId, in.EntUserId, participateMap)
+	return &bxcore.ParticipatePersonsRes{
+		Data: personInfos,
+	}
+}
+
+//获取项目信息
+func GetProjectInfoByES(in *bxcore.ParticipateActionReq) error {
+	//参标和终止参标 单个项目;不进行批量操作
+	in.ProjectIds = MC.If(in.ProjectIds != "", in.ProjectIds, in.BidIds).(string)
+	var (
+		tip = "参标"
+	)
+	switch in.ActionType {
+	case "out":
+		tip = "终止参标"
+		//case "transfer":
+		//	tip = "划转"
+	}
+	in.ProjectIds = strings.Split(in.ProjectIds, ",")[0]
+	in.ProjectIds = encrypt.DecodeArticleId2ByCheck(in.ProjectIds)[0]
+	if in.ProjectIds == "" {
+		return fmt.Errorf("当前招标信息有误")
+	}
+	//当前项目是否符合参标条件
+	//根据项目id查询project
+	projectInfos := es.GetBidInfoByPId(in.ProjectIds)
+	if projectInfos == nil || len(*projectInfos) == 0 {
+		//当前项目是否符合参标条件
+		//根据招标信息id 查询bidding
+		projectInfos = es.GetProjectByInfoId(strings.Split(in.ProjectIds, ","))
+		if projectInfos == nil || len(*projectInfos) == 0 {
+			return fmt.Errorf(fmt.Sprintf("当前项目信息不满足%s条件", tip))
+		}
+		//符合参标项目id
+		projectInfo := (*projectInfos)[0]
+		if projectInfo["_id"] != nil && MC.ObjToString(projectInfo["_id"]) != "" {
+			//项目信息id
+			in.ProjectIds = MC.ObjToString(projectInfo["_id"])
+		} else {
+			return fmt.Errorf("当前项目信息有误")
+		}
+	}
+	return nil
+}

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

@@ -12,6 +12,7 @@ import (
 	"jyBXCore/rpc/type/bxcore"
 	"jyBXCore/rpc/util"
 	"strings"
+	"time"
 )
 
 const (
@@ -130,6 +131,7 @@ func (p *ParticipateBid) DetailEntFormat(existProjectMap map[string]string, isVa
 		formatData.ShowParticipate = true
 		return
 	}
+	formatData.CurrentTime = time.Now().Unix()
 	formatData.BidEndTime = bidEndTime
 	persons := ""
 	projectId := ""
@@ -171,6 +173,7 @@ func (p *ParticipateBid) DetailPersonalFormat(existProjectSet map[string]struct{
 	}
 	// 存在在说明已经参标  显示终止参标
 	if len(existProjectSet) > 0 {
+		formatData.CurrentTime = time.Now().Unix()
 		formatData.BidEndTime = bidEndTime
 		formatData.ShowStopParticipate = true
 	} else {

File diff suppressed because it is too large
+ 491 - 395
jyBXCore/rpc/type/bxcore/bxcore.pb.go


+ 1 - 1
jyBXCore/rpc/type/bxcore/bxcore_grpc.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
 // versions:
 // - protoc-gen-go-grpc v1.2.0
-// - protoc             v3.19.4
+// - protoc             v3.15.5
 // source: bxcore.proto
 
 package bxcore

Some files were not shown because too many files changed in this diff