|
@@ -1,12 +1,15 @@
|
|
package mysql
|
|
package mysql
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
"app.yhyue.com/moapp/jybase/date"
|
|
"app.yhyue.com/moapp/jybase/date"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
IC "jyBXCore/rpc/init"
|
|
IC "jyBXCore/rpc/init"
|
|
"jyBXCore/rpc/util"
|
|
"jyBXCore/rpc/util"
|
|
|
|
+ "log"
|
|
|
|
+ "strconv"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
@@ -16,75 +19,128 @@ type ParStage struct {
|
|
EntUserId int64
|
|
EntUserId int64
|
|
PositionId int64
|
|
PositionId int64
|
|
ProjectId string
|
|
ProjectId string
|
|
- Stage string //参标、终止参标(划转没有记录)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-func NewParStage(entId int64, projectId, stage string) *ParStage {
|
|
|
|
|
|
+func NewParStage(entId, entUserId, positionId int64, projectId string) *ParStage {
|
|
return &ParStage{
|
|
return &ParStage{
|
|
- EntId: entId,
|
|
|
|
- ProjectId: projectId,
|
|
|
|
- Stage: stage,
|
|
|
|
|
|
+ EntId: entId,
|
|
|
|
+ EntUserId: entUserId,
|
|
|
|
+ PositionId: positionId,
|
|
|
|
+ ProjectId: projectId,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+type StageInfo struct {
|
|
|
|
+ Value string
|
|
|
|
+ Date string
|
|
|
|
+}
|
|
|
|
+
|
|
func (p *ParStage) UpdateStage() {
|
|
func (p *ParStage) UpdateStage() {
|
|
var (
|
|
var (
|
|
- recordsMap = map[string]string{}
|
|
|
|
|
|
+ recordsMap = map[string]*StageInfo{}
|
|
updateInsertMap = map[string]interface{}{
|
|
updateInsertMap = map[string]interface{}{
|
|
"ent_id": p.EntId,
|
|
"ent_id": p.EntId,
|
|
"project_id": p.ProjectId,
|
|
"project_id": p.ProjectId,
|
|
}
|
|
}
|
|
- now = time.Now()
|
|
|
|
- createDate string
|
|
|
|
|
|
+ now = time.Now()
|
|
|
|
+ createDate string
|
|
|
|
+ entUserIdBool = map[string]bool{}
|
|
|
|
+ positionIdBool = map[string]bool{}
|
|
|
|
+ entUserIds, positionIds []string
|
|
|
|
+ findSql = map[string]interface{}{
|
|
|
|
+ "project_id": p.ProjectId,
|
|
|
|
+ "ent_id": p.EntId,
|
|
|
|
+ }
|
|
|
|
+ state = "已完成"
|
|
|
|
+ isParticipate bool
|
|
)
|
|
)
|
|
- 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 p.EntId == 0 {
|
|
|
|
+ findSql["position_id"] = p.PositionId
|
|
|
|
+ }
|
|
|
|
+ recordsContentData := IC.BaseMysql.Find(ParticipateBidRecordsTable, findSql, "", "create_date", -1, -1)
|
|
|
|
+ //判断 当前企业或用户是否已参标
|
|
|
|
+ findSql["state"] = 0
|
|
|
|
+ if count := IC.BaseMysql.Count("participate_user", findSql); count > 0 {
|
|
|
|
+ isParticipate = true
|
|
|
|
+ }
|
|
|
|
+ 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
|
|
|
|
+ entUserId = strconv.FormatInt(gconv.Int64(rv["ent_user_id"]), 10)
|
|
|
|
+ positionId = strconv.FormatInt(gconv.Int64(rv["position_id"]), 10)
|
|
|
|
+ )
|
|
|
|
+ createDate = gconv.String(rv["create_date"])
|
|
|
|
+ if ok {
|
|
|
|
+ contentMap = gconv.Map(content)
|
|
if contentMap["afterMap"] != nil {
|
|
if contentMap["afterMap"] != nil {
|
|
- after, _ := util.ConvertJSONString(gconv.String(contentMap["afterMap"]))
|
|
|
|
- afterM := gconv.Map(after)
|
|
|
|
|
|
+ afterMap, _ := util.ConvertJSONString(gconv.String(contentMap["afterMap"]))
|
|
|
|
+ afterM := gconv.Map(afterMap)
|
|
if afterM != nil {
|
|
if afterM != nil {
|
|
if bidStage := gconv.Map(afterM["bidStage"]); bidStage != nil {
|
|
if bidStage := gconv.Map(afterM["bidStage"]); bidStage != nil {
|
|
status := gconv.String(bidStage["status"])
|
|
status := gconv.String(bidStage["status"])
|
|
values := gconv.SliceStr(bidStage["value"])
|
|
values := gconv.SliceStr(bidStage["value"])
|
|
if len(values) > 0 {
|
|
if len(values) > 0 {
|
|
for _, bv := range values {
|
|
for _, bv := range values {
|
|
- if status == "调整" || recordsMap[bv] == "" {
|
|
|
|
- recordsMap[bv] = createDate
|
|
|
|
|
|
+ if status == "调整" || recordsMap[fmt.Sprintf("%s(阶段)", bv)].Date == "" {
|
|
|
|
+ recordsMap[fmt.Sprintf("%s(阶段)", bv)] = &StageInfo{
|
|
|
|
+ Value: state,
|
|
|
|
+ Date: createDate,
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if bidType := gconv.Map(afterM["bidType"]); bidType != nil {
|
|
if bidType := gconv.Map(afterM["bidType"]); bidType != nil {
|
|
- values := gconv.String(bidType["value"])
|
|
|
|
- if values != "" {
|
|
|
|
- recordsMap[values] = createDate
|
|
|
|
|
|
+ value := gconv.String(bidType["value"])
|
|
|
|
+ if value != "" {
|
|
|
|
+ recordsMap["投标类型"] = &StageInfo{
|
|
|
|
+ Value: value,
|
|
|
|
+ Date: createDate,
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if p.Stage == "终止参标" {
|
|
|
|
- recordsMap["终止参标"] = date.FormatDate(&now, date.Date_Full_Layout)
|
|
|
|
|
|
+ afterMap, _ := util.ConvertJSONString(gconv.String(contentMap["after"]))
|
|
|
|
+ afterM := gconv.Map(afterMap)
|
|
|
|
+ if afterM != nil {
|
|
|
|
+ updateInsertMap["bid_way"] = gconv.Int64(afterM["bidType"])
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ contentStr = gconv.String(content)
|
|
|
|
+ //参标:多人参标同一个项目,查看当前项目是否已被当前企业其他员工参标,如果已被其他员工参标,则参标时间不更新。
|
|
|
|
+ //参标后 未被 终止参标
|
|
|
|
+ if strings.TrimSpace(contentStr) == "参标" {
|
|
|
|
+ recordsMap["参标状态"] = &StageInfo{
|
|
|
|
+ Value: "已参标",
|
|
|
|
+ Date: createDate,
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //终止参标--
|
|
|
|
+ if strings.Contains(contentStr, "终止参标") {
|
|
|
|
+ if !isParticipate {
|
|
|
|
+ recordsMap[contentStr] = &StageInfo{
|
|
|
|
+ Value: "已终止",
|
|
|
|
+ Date: createDate,
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //entUserIds 操作和被操作企业用户id集合 408
|
|
|
|
+ if !entUserIdBool[entUserId] {
|
|
|
|
+ entUserIdBool[entUserId] = true
|
|
|
|
+ entUserIds = append(entUserIds, entUserId)
|
|
|
|
+ }
|
|
|
|
+ //职位id
|
|
|
|
+ if !positionIdBool[positionId] {
|
|
|
|
+ positionIdBool[positionId] = true
|
|
|
|
+ positionIds = append(positionIds, positionId)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if recordsMap != nil {
|
|
if recordsMap != nil {
|
|
@@ -95,19 +151,27 @@ func (p *ParStage) UpdateStage() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
updateInsertMap["stage"] = string(jsonData)
|
|
updateInsertMap["stage"] = string(jsonData)
|
|
- if c := IC.BaseMysql.Count(ParticipateStage, map[string]interface{}{
|
|
|
|
- "ent_id": p.EntId,
|
|
|
|
- "project_id": p.ProjectId,
|
|
|
|
- }); c > 0 {
|
|
|
|
|
|
+ updateInsertMap["ent_user_ids"] = strings.Join(entUserIds, ",")
|
|
|
|
+ updateInsertMap["is_participate"] = common.If(isParticipate, 1, 0).(int)
|
|
|
|
+ updateInsertMap["position_ids"] = strings.Join(positionIds, ",")
|
|
|
|
+ updateSelectSlq := fmt.Sprintf(`SELECT * FROM %s WHERE ent_id = ? and project_id = ? `, ParticipateStage)
|
|
|
|
+ if p.EntId == 0 {
|
|
|
|
+ add := fmt.Sprintf(" and FIND_IN_SET('%s', position_ids) > 0", strconv.FormatInt(p.PositionId, 10))
|
|
|
|
+ updateSelectSlq = fmt.Sprintf("%s%s", updateSelectSlq, add)
|
|
|
|
+ }
|
|
|
|
+ if s := IC.BaseMysql.SelectBySql(updateSelectSlq, p.EntId, p.ProjectId); len(*s) > 0 {
|
|
updateInsertMap["update_date"] = createDate
|
|
updateInsertMap["update_date"] = createDate
|
|
- IC.BaseMysql.UpdateOrDeleteBySql(ParticipateStage, map[string]interface{}{
|
|
|
|
- "ent_id": p.EntId,
|
|
|
|
- "project_id": p.ProjectId,
|
|
|
|
- }, updateInsertMap)
|
|
|
|
|
|
+ if ok := IC.BaseMysql.Update(ParticipateStage, map[string]interface{}{
|
|
|
|
+ "id": gconv.Int64((*s)[0]["id"]),
|
|
|
|
+ }, updateInsertMap); !ok {
|
|
|
|
+ log.Println("参标操作记录 更新异常:", gconv.Int64((*s)[0]["id"]))
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
updateInsertMap["create_date"] = date.FormatDate(&now, date.Date_Full_Layout)
|
|
updateInsertMap["create_date"] = date.FormatDate(&now, date.Date_Full_Layout)
|
|
updateInsertMap["update_date"] = createDate
|
|
updateInsertMap["update_date"] = createDate
|
|
- IC.BaseMysql.Insert(ParticipateStage, updateInsertMap)
|
|
|
|
|
|
+ if i := IC.BaseMysql.Insert(ParticipateStage, updateInsertMap); i == 0 {
|
|
|
|
+ log.Println("参标操作记录 插入异常:", updateInsertMap)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|