|
@@ -62,7 +62,7 @@ func (p *ParticipateBid) PersonalExistProject(projectId []string) map[string]str
|
|
value = append(value, projectId[i])
|
|
value = append(value, projectId[i])
|
|
}
|
|
}
|
|
argStr := strings.Join(arg, ",")
|
|
argStr := strings.Join(arg, ",")
|
|
- query := "select project_id from " + TableParticipateUser + " where position_id = ? and project_id in (%s) and state>=0"
|
|
|
|
|
|
+ query := "select project_id from " + TableParticipateUser + " where position_id = ? and project_id in (%s) and status=0"
|
|
rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
|
|
rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
|
|
existProjectSet := map[string]struct{}{}
|
|
existProjectSet := map[string]struct{}{}
|
|
if rs != nil && len(*rs) > 0 { // 如果查到了 说明已经参标 这部分应该显示已参标
|
|
if rs != nil && len(*rs) > 0 { // 如果查到了 说明已经参标 这部分应该显示已参标
|
|
@@ -102,7 +102,7 @@ func (p *ParticipateBid) EntExistProject(projectId []string) map[string]string {
|
|
value = append(value, projectId[i])
|
|
value = append(value, projectId[i])
|
|
}
|
|
}
|
|
argStr := strings.Join(arg, ",")
|
|
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 "
|
|
|
|
|
|
+ query := "select GROUP_CONCAT(ent_user_id) as personIds ,project_id from " + TableParticipateUser + " where ent_id=? and project_id in (%s) and status=0 group by project_id "
|
|
rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
|
|
rs := IC.BaseMysql.SelectBySql(fmt.Sprintf(query, argStr), value...)
|
|
existProjectMap := map[string]string{}
|
|
existProjectMap := map[string]string{}
|
|
if rs != nil && len(*rs) > 0 { // 如果查到了 说明这个项目公司里面已经参标 处理一下信息用于后边判断是否是自己参标
|
|
if rs != nil && len(*rs) > 0 { // 如果查到了 说明这个项目公司里面已经参标 处理一下信息用于后边判断是否是自己参标
|
|
@@ -258,25 +258,24 @@ func ContainId(ids string, objId string) bool {
|
|
// 返回: "张三,李四,王五..."
|
|
// 返回: "张三,李四,王五..."
|
|
func GetNameByUserIds(ids string) *[]map[string]interface{} {
|
|
func GetNameByUserIds(ids string) *[]map[string]interface{} {
|
|
query := "select group_concat(name) as name from " + TableEntnicheUser + " where id in (" + ids + ") "
|
|
query := "select group_concat(name) as name from " + TableEntnicheUser + " where id in (" + ids + ") "
|
|
- fmt.Println(query)
|
|
|
|
rs := IC.MainMysql.SelectBySql(query)
|
|
rs := IC.MainMysql.SelectBySql(query)
|
|
return rs
|
|
return rs
|
|
}
|
|
}
|
|
|
|
|
|
-// CheckUpdateBidPower 投标状态更新验证权限(参标人或者是该企业下的管理员)
|
|
|
|
-func (p *ParticipateBid) CheckUpdateBidPower(projectId string) (b bool) {
|
|
|
|
|
|
+// CheckBidPower 投标状态更新/查看记录 验证权限(参标人或者是该企业下的管理员)
|
|
|
|
+func (p *ParticipateBid) CheckBidPower(projectId string, valid bool) (b bool) {
|
|
|
|
|
|
switch p.PositionType {
|
|
switch p.PositionType {
|
|
case PositionTypePersonal:
|
|
case PositionTypePersonal:
|
|
// 查个人id
|
|
// 查个人id
|
|
- b = tidb.CheckParticipatePersonal(projectId, p.PositionId)
|
|
|
|
|
|
+ b = tidb.CheckParticipatePersonal(projectId, p.PositionId, valid)
|
|
case PositionTypeEnt:
|
|
case PositionTypeEnt:
|
|
// 查企业
|
|
// 查企业
|
|
if p.EntRoleId == RoleEntManager || p.EntRoleId == RoleDepartManager {
|
|
if p.EntRoleId == RoleEntManager || p.EntRoleId == RoleDepartManager {
|
|
- b = tidb.CheckParticipateManager(projectId, p.EntId)
|
|
|
|
|
|
+ b = tidb.CheckParticipateManager(projectId, p.EntId, valid)
|
|
} else {
|
|
} else {
|
|
// 查参标人
|
|
// 查参标人
|
|
- b = tidb.CheckParticipateEntUser(projectId, p.PositionId)
|
|
|
|
|
|
+ b = tidb.CheckParticipateEntUser(projectId, p.PositionId, valid)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
return
|
|
@@ -287,6 +286,9 @@ func (p *ParticipateBid) UpdateBidStatus(in *bxcore.UpdateBidStatusReq, projectI
|
|
// 如果查出来旧的 那么就需要做新旧对比
|
|
// 如果查出来旧的 那么就需要做新旧对比
|
|
oldMap := p.GetLastBidStatus(projectId) // 查询出最新的招标状态信息
|
|
oldMap := p.GetLastBidStatus(projectId) // 查询出最新的招标状态信息
|
|
// 新的
|
|
// 新的
|
|
|
|
+ if in.BidStage == nil {
|
|
|
|
+ in.BidStage = []string{}
|
|
|
|
+ }
|
|
newMap := map[string]interface{}{
|
|
newMap := map[string]interface{}{
|
|
"bidType": in.BidType,
|
|
"bidType": in.BidType,
|
|
"bidStage": in.BidStage,
|
|
"bidStage": in.BidStage,
|
|
@@ -339,13 +341,116 @@ func (p *ParticipateBid) GetLastBidStatus(projectId string) map[string]interface
|
|
return rs
|
|
return rs
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+func (p ParticipateBid) ParticipateContentFormat(data map[string]interface{}) (rs bxcore.ParticipateContentData) {
|
|
|
|
+ if data == nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ rs.BidType = common.Int64All(data["bidType"])
|
|
|
|
+ rs.ChannelPhone = common.ObjToString(data["channelPhone"])
|
|
|
|
+ rs.ChannelPerson = common.ObjToString(data["channelPerson"])
|
|
|
|
+ rs.ChannelName = common.ObjToString(data["channelName"])
|
|
|
|
+ rs.IsWin = common.Int64All(data["isWin"])
|
|
|
|
+ rs.Winner = common.ObjToString(data["winner"])
|
|
|
|
+ tmp := data["bidStage"].([]interface{})
|
|
|
|
+ rs.BidStage = common.ObjArrToStringArr(tmp)
|
|
|
|
+
|
|
|
|
+ return rs
|
|
|
|
+}
|
|
|
|
|
|
// GetBidRecords 获取操作记录
|
|
// GetBidRecords 获取操作记录
|
|
-func (p *ParticipateBid) GetBidRecords(page, pageSize int) {
|
|
|
|
|
|
+func (p *ParticipateBid) GetBidRecords(projectId string, page, pageSize int64) *bxcore.ParticipateRecordsData {
|
|
|
|
+ data := bxcore.ParticipateRecordsData{}
|
|
|
|
+ var rs *[]map[string]interface{}
|
|
|
|
+ var total int64
|
|
|
|
+ if page < 1 {
|
|
|
|
+ page = 1
|
|
|
|
+ }
|
|
|
|
+ if pageSize == 0 {
|
|
|
|
+ pageSize = 500
|
|
|
|
+ }
|
|
|
|
+ switch p.PositionType {
|
|
|
|
+ case PositionTypeEnt:
|
|
|
|
+ // 1. 查询出操作记录
|
|
|
|
+ rs, total = tidb.GetBidRecordsEnt(projectId, p.EntId, page, pageSize)
|
|
|
|
+ case PositionTypePersonal:
|
|
|
|
+ // 个人版不展示姓名
|
|
|
|
+ rs, total = tidb.GetBidRecordsPersonal(projectId, p.PositionId, page, pageSize)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if rs == nil || len(*rs) == 0 {
|
|
|
|
+ return &data
|
|
|
|
+ }
|
|
|
|
+ data.Total = total
|
|
|
|
+ data.List = p.BidRecordsFormat(*rs)
|
|
|
|
+ return &data
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// BidRecordsFormat 获取操作记录格式化
|
|
|
|
+func (p ParticipateBid) BidRecordsFormat(data []map[string]interface{}) []*bxcore.ParticipateRecords {
|
|
|
|
+ records := []*bxcore.ParticipateRecords{}
|
|
|
|
+ switch p.PositionType {
|
|
|
|
+
|
|
|
|
+ case PositionTypeEnt:
|
|
|
|
+ // 用户id
|
|
|
|
+ // 拿到所有的用户id
|
|
|
|
+ userIdArr := []string{}
|
|
|
|
+ userIdMap := map[int64]string{}
|
|
|
|
+ for i := 0; i < len(data); i++ {
|
|
|
|
+ userId := common.Int64All(data[i]["ent_user_id"])
|
|
|
|
+ if _, ok := userIdMap[userId]; !ok {
|
|
|
|
+ userIdMap[userId] = ""
|
|
|
|
+ userIdArr = append(userIdArr, fmt.Sprint(userId))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 根据id查询出姓名{id:name}
|
|
|
|
+ userIdMap = getUserIdName(userIdArr)
|
|
|
|
+ // 遍历数据 换成姓名
|
|
|
|
+ for i := 0; i < len(data); i++ {
|
|
|
|
+ id := common.Int64All(data[i]["ent_user_id"])
|
|
|
|
+ person := ""
|
|
|
|
+ if name, ok := userIdMap[id]; ok {
|
|
|
|
+ person = name
|
|
|
|
+ }
|
|
|
|
+ tmp := bxcore.ParticipateRecords{
|
|
|
|
+ RecordsData: common.ObjToString(data[i]["record_content"]),
|
|
|
|
+ UpdateDate: common.ObjToString(data[i]["create_date"]),
|
|
|
|
+ UpdatePerson: person,
|
|
|
|
+ }
|
|
|
|
+ records = append(records, &tmp)
|
|
|
|
|
|
- // 1. 查询出操作记录
|
|
|
|
- //tidb.GetBidRecordsEnt()
|
|
|
|
- // 2. todo 补充上操作人姓名
|
|
|
|
|
|
+ }
|
|
|
|
+ case PositionTypePersonal:
|
|
|
|
+ // 遍历数据 换成姓名
|
|
|
|
+ for i := 0; i < len(data); i++ {
|
|
|
|
+ tmp := bxcore.ParticipateRecords{
|
|
|
|
+ RecordsData: common.ObjToString(data[i]["record_content"]),
|
|
|
|
+ UpdateDate: common.ObjToString(data[i]["create_date"]),
|
|
|
|
+ }
|
|
|
|
+ records = append(records, &tmp)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return records
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 获取id和姓名的对应关系
|
|
|
|
+func getUserIdName(userIdArr []string) map[int64]string {
|
|
|
|
+ rs := map[int64]string{}
|
|
|
|
+ if len(userIdArr) > 0 {
|
|
|
|
+ userIdStr := strings.Join(userIdArr, ",")
|
|
|
|
+ userRs := tidb.GetUserMap(userIdStr)
|
|
|
|
+ if userRs == nil || len(*userRs) == 0 {
|
|
|
|
+ return rs
|
|
|
|
+ }
|
|
|
|
+ for i := 0; i < len(*userRs); i++ {
|
|
|
|
+ user := (*userRs)[i]
|
|
|
|
+ id := common.Int64All(user["id"])
|
|
|
|
+ name := common.ObjToString(user["name"])
|
|
|
|
+ rs[id] = name
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return rs
|
|
}
|
|
}
|
|
|
|
|
|
// 处理操作动作
|
|
// 处理操作动作
|
|
@@ -370,6 +475,7 @@ var (
|
|
}
|
|
}
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+// 处理操作记录
|
|
func processRecordStr(oldMap, newMap map[string]interface{}) (recordContent string, err error) {
|
|
func processRecordStr(oldMap, newMap map[string]interface{}) (recordContent string, err error) {
|
|
actonStr := "%s%s%s"
|
|
actonStr := "%s%s%s"
|
|
changeField := []string{}
|
|
changeField := []string{}
|
|
@@ -442,10 +548,15 @@ func processRecordStr(oldMap, newMap map[string]interface{}) (recordContent stri
|
|
"after": newMap, // 变更后
|
|
"after": newMap, // 变更后
|
|
"changeField": changeField, // 涉及变更的字段
|
|
"changeField": changeField, // 涉及变更的字段
|
|
}
|
|
}
|
|
|
|
+
|
|
tmp, err := json.Marshal(recordMap)
|
|
tmp, err := json.Marshal(recordMap)
|
|
if err != nil {
|
|
if err != nil {
|
|
logx.Error("序列化操作记录失败:", err)
|
|
logx.Error("序列化操作记录失败:", err)
|
|
return "", err
|
|
return "", err
|
|
}
|
|
}
|
|
- return string(tmp), nil
|
|
|
|
|
|
+ if len(result) == 0 {
|
|
|
|
+ logx.Error("没有更新的内容:", recordContent)
|
|
|
|
+ err = fmt.Errorf("没有变更的内容,不用更新")
|
|
|
|
+ }
|
|
|
|
+ return string(tmp), err
|
|
}
|
|
}
|