|
@@ -17,87 +17,97 @@ type ParStage struct {
|
|
|
EntUserId int64
|
|
|
PositionId int64
|
|
|
ProjectId string
|
|
|
+ Stage string //参标、终止参标(划转没有记录)
|
|
|
}
|
|
|
|
|
|
-func NewParStage(entId, entUserId, positionId int64, projectId string) *ParStage {
|
|
|
+func NewParStage(entId, entUserId, positionId int64, projectId, stage string) *ParStage {
|
|
|
return &ParStage{
|
|
|
EntId: entId,
|
|
|
EntUserId: entUserId,
|
|
|
PositionId: positionId,
|
|
|
ProjectId: projectId,
|
|
|
+ Stage: stage,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p *ParStage) UpdateStage() {
|
|
|
- recordsContentData := IC.BaseMysql.SelectBySql(`SELECT * FROM participate_bid_records WHERE position_id =? and project_id =? order by create_date `, p.PositionId, p.ProjectId)
|
|
|
- if recordsContentData != nil && len(*recordsContentData) > 0 {
|
|
|
- var (
|
|
|
- recordsMap = map[string]string{}
|
|
|
- updateInsertMap = map[string]interface{}{
|
|
|
- "ent_id": p.EntId,
|
|
|
- "ent_user_id": p.EntUserId,
|
|
|
- "position_id": p.PositionId,
|
|
|
- "project_id": p.ProjectId,
|
|
|
- }
|
|
|
- now = time.Now()
|
|
|
- createDate string
|
|
|
- )
|
|
|
- for _, rv := range *recordsContentData {
|
|
|
- var (
|
|
|
- recordContent = gconv.String(rv["record_content"])
|
|
|
- content, ok = util.ConvertJSONString(recordContent)
|
|
|
- contentMap = map[string]interface{}{}
|
|
|
- contentStr string
|
|
|
- )
|
|
|
- createDate = gconv.String(rv["create_date"])
|
|
|
- if ok {
|
|
|
- contentMap = gconv.Map(content)
|
|
|
- } else {
|
|
|
- contentStr = gconv.String(content)
|
|
|
- }
|
|
|
- if strings.TrimSpace(contentStr) == "参标" || strings.Contains(contentStr, "终止参标") {
|
|
|
- recordsMap[contentStr] = createDate
|
|
|
- }
|
|
|
- if contentMap["afterMap"] != nil {
|
|
|
- after, _ := util.ConvertJSONString(gconv.String(contentMap["afterMap"]))
|
|
|
- afterM := gconv.Map(after)
|
|
|
- if afterM != nil {
|
|
|
- if bidStage := gconv.Map(afterM["bidStage"]); bidStage != nil {
|
|
|
- status := gconv.String(bidStage["status"])
|
|
|
- values := gconv.SliceStr(bidStage["value"])
|
|
|
- if len(values) > 0 {
|
|
|
- for _, bv := range values {
|
|
|
- if status == "调整" || recordsMap[bv] == "" {
|
|
|
- recordsMap[bv] = createDate
|
|
|
+ var (
|
|
|
+ recordsMap = map[string]string{}
|
|
|
+ updateInsertMap = map[string]interface{}{
|
|
|
+ "ent_id": p.EntId,
|
|
|
+ "ent_user_id": p.EntUserId,
|
|
|
+ "position_id": p.PositionId,
|
|
|
+ "project_id": p.ProjectId,
|
|
|
+ }
|
|
|
+ now = time.Now()
|
|
|
+ createDate string
|
|
|
+ )
|
|
|
+ if p.Stage == "参标" {
|
|
|
+ recordsMap["参标"] = date.FormatDate(&now, date.Date_Full_Layout)
|
|
|
+ } else {
|
|
|
+ recordsContentData := IC.BaseMysql.SelectBySql(`SELECT * FROM participate_bid_records WHERE position_id =? and project_id =? order by create_date `, p.PositionId, p.ProjectId)
|
|
|
+ if recordsContentData != nil && len(*recordsContentData) > 0 {
|
|
|
+
|
|
|
+ for _, rv := range *recordsContentData {
|
|
|
+ var (
|
|
|
+ recordContent = gconv.String(rv["record_content"])
|
|
|
+ content, ok = util.ConvertJSONString(recordContent)
|
|
|
+ contentMap = map[string]interface{}{}
|
|
|
+ contentStr string
|
|
|
+ )
|
|
|
+ createDate = gconv.String(rv["create_date"])
|
|
|
+ if ok {
|
|
|
+ contentMap = gconv.Map(content)
|
|
|
+ } else {
|
|
|
+ contentStr = gconv.String(content)
|
|
|
+ }
|
|
|
+ if strings.TrimSpace(contentStr) == "参标" || strings.Contains(contentStr, "终止参标") {
|
|
|
+ recordsMap[contentStr] = createDate
|
|
|
+ }
|
|
|
+ if contentMap["afterMap"] != nil {
|
|
|
+ after, _ := util.ConvertJSONString(gconv.String(contentMap["afterMap"]))
|
|
|
+ afterM := gconv.Map(after)
|
|
|
+ if afterM != nil {
|
|
|
+ if bidStage := gconv.Map(afterM["bidStage"]); bidStage != nil {
|
|
|
+ status := gconv.String(bidStage["status"])
|
|
|
+ values := gconv.SliceStr(bidStage["value"])
|
|
|
+ if len(values) > 0 {
|
|
|
+ for _, bv := range values {
|
|
|
+ if status == "调整" || recordsMap[bv] == "" {
|
|
|
+ recordsMap[bv] = createDate
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if p.Stage == "终止参标" {
|
|
|
+ recordsMap["终止参标"] = date.FormatDate(&now, date.Date_Full_Layout)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if recordsMap != nil {
|
|
|
- // 转换结构体数组为JSON字符串
|
|
|
- jsonData, err := json.Marshal(recordsMap)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("Failed to marshal struct array to JSON:", err)
|
|
|
- return
|
|
|
- }
|
|
|
- updateInsertMap["stage"] = string(jsonData)
|
|
|
- if c := IC.BaseMysql.Count(mysql.ParticipateStage, map[string]interface{}{
|
|
|
+ }
|
|
|
+ if recordsMap != nil {
|
|
|
+ // 转换结构体数组为JSON字符串
|
|
|
+ jsonData, err := json.Marshal(recordsMap)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Failed to marshal struct array to JSON:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ updateInsertMap["stage"] = string(jsonData)
|
|
|
+ if c := IC.BaseMysql.Count(mysql.ParticipateStage, map[string]interface{}{
|
|
|
+ "position_id": p.PositionId,
|
|
|
+ "project_id": p.ProjectId,
|
|
|
+ }); c > 0 {
|
|
|
+ updateInsertMap["update_date"] = createDate
|
|
|
+ IC.BaseMysql.UpdateOrDeleteBySql(mysql.ParticipateStage, map[string]interface{}{
|
|
|
"position_id": p.PositionId,
|
|
|
"project_id": p.ProjectId,
|
|
|
- }); c > 0 {
|
|
|
- updateInsertMap["update_date"] = createDate
|
|
|
- IC.BaseMysql.UpdateOrDeleteBySql(mysql.ParticipateStage, map[string]interface{}{
|
|
|
- "position_id": p.PositionId,
|
|
|
- "project_id": p.ProjectId,
|
|
|
- }, updateInsertMap)
|
|
|
- } else {
|
|
|
- updateInsertMap["create_date"] = date.FormatDate(&now, date.Date_Full_Layout)
|
|
|
- updateInsertMap["update_date"] = createDate
|
|
|
- IC.BaseMysql.Insert(mysql.ParticipateStage, updateInsertMap)
|
|
|
- }
|
|
|
+ }, updateInsertMap)
|
|
|
+ } else {
|
|
|
+ updateInsertMap["create_date"] = date.FormatDate(&now, date.Date_Full_Layout)
|
|
|
+ updateInsertMap["update_date"] = createDate
|
|
|
+ IC.BaseMysql.Insert(mysql.ParticipateStage, updateInsertMap)
|
|
|
}
|
|
|
}
|
|
|
}
|