|
@@ -249,14 +249,14 @@ func (p *ParticipateBid) CheckBidPower(projectId string, valid bool) (b bool) {
|
|
|
b = mysql.CheckParticipateManager(projectId, p.EntId, valid)
|
|
|
} else {
|
|
|
// 查参标人
|
|
|
- b = mysql.CheckParticipateEntUser(projectId, p.PositionId, valid)
|
|
|
+ b = mysql.CheckParticipateEntUser(projectId, p.EntUserId, valid)
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdateBidStatus 更新投标状态
|
|
|
-func (p *ParticipateBid) UpdateBidStatus(in *bxcore.UpdateBidStatusReq, projectId string) (flag bool) {
|
|
|
+func (p *ParticipateBid) UpdateBidStatus(in *bxcore.UpdateBidStatusReq, projectId string) error {
|
|
|
if p.PositionType == PositionTypeEnt {
|
|
|
pLock := util.GetParticipateLock(fmt.Sprintf("%d_%s", p.EntId, projectId))
|
|
|
pLock.Lock()
|
|
@@ -280,7 +280,7 @@ func (p *ParticipateBid) UpdateBidStatus(in *bxcore.UpdateBidStatusReq, projectI
|
|
|
// 新旧对比 处理成要保存的字段
|
|
|
recordContent, err := processRecordStr(oldMap, newMap)
|
|
|
if err != nil {
|
|
|
- return false
|
|
|
+ return err
|
|
|
}
|
|
|
// 保存
|
|
|
recordData := map[string]interface{}{
|
|
@@ -292,8 +292,10 @@ func (p *ParticipateBid) UpdateBidStatus(in *bxcore.UpdateBidStatusReq, projectI
|
|
|
"record_type": RecordTypeBidStatus,
|
|
|
"create_date": date.NowFormat(date.Date_Full_Layout),
|
|
|
}
|
|
|
- flag = mysql.InsertBidContent(recordData)
|
|
|
- return
|
|
|
+ if flag := mysql.InsertBidContent(recordData); !flag {
|
|
|
+ return fmt.Errorf("更新失败")
|
|
|
+ }
|
|
|
+ return nil
|
|
|
|
|
|
}
|
|
|
|
|
@@ -362,7 +364,6 @@ func (p *ParticipateBid) GetBidRecords(projectId string, page, pageSize int64) *
|
|
|
func (p ParticipateBid) BidRecordsFormat(data []map[string]interface{}) []*bxcore.ParticipateRecords {
|
|
|
records := []*bxcore.ParticipateRecords{}
|
|
|
switch p.PositionType {
|
|
|
-
|
|
|
case PositionTypeEnt:
|
|
|
// 用户id
|
|
|
// 拿到所有的用户id
|
|
@@ -375,7 +376,6 @@ func (p ParticipateBid) BidRecordsFormat(data []map[string]interface{}) []*bxcor
|
|
|
userIdArr = append(userIdArr, fmt.Sprint(userId))
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// 根据id查询出姓名{id:name}
|
|
|
userIdMap = getUserIdName(userIdArr)
|
|
|
// 遍历数据 换成姓名
|
|
@@ -392,7 +392,6 @@ func (p ParticipateBid) BidRecordsFormat(data []map[string]interface{}) []*bxcor
|
|
|
RecordType: common.Int64All(data[i]["record_type"]),
|
|
|
}
|
|
|
records = append(records, &tmp)
|
|
|
-
|
|
|
}
|
|
|
case PositionTypePersonal:
|
|
|
// 遍历数据
|
|
@@ -403,7 +402,6 @@ func (p ParticipateBid) BidRecordsFormat(data []map[string]interface{}) []*bxcor
|
|
|
RecordType: common.Int64All(data[i]["record_type"]),
|
|
|
}
|
|
|
records = append(records, &tmp)
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
return records
|
|
@@ -439,11 +437,11 @@ var (
|
|
|
"channelPhone": "联系电话",
|
|
|
"winner": "中标单位",
|
|
|
}
|
|
|
- BidTypeMap = map[int]interface{}{
|
|
|
+ BidTypeMap = map[int]string{
|
|
|
BidTypeDirect: "直接投标",
|
|
|
BidTypeChanel: "渠道投标",
|
|
|
}
|
|
|
- WinMap = map[int]interface{}{
|
|
|
+ WinMap = map[int]string{
|
|
|
1: "是",
|
|
|
2: "否",
|
|
|
0: "未选择",
|
|
@@ -452,35 +450,54 @@ var (
|
|
|
|
|
|
// 处理操作记录
|
|
|
func processRecordStr(oldMap, newMap map[string]interface{}) (recordContent string, err error) {
|
|
|
- actonStr := "%s%s%s"
|
|
|
- changeField := []string{}
|
|
|
- result := []string{}
|
|
|
+ var (
|
|
|
+ actonStr = "%s%s%s"
|
|
|
+ changeField = []string{}
|
|
|
+ result = []string{}
|
|
|
+ afterMap = map[string]interface{}{}
|
|
|
+ )
|
|
|
for k, fieldName := range ParticipateBidContentKey {
|
|
|
- changeStr := ""
|
|
|
+ var (
|
|
|
+ value interface{}
|
|
|
+ status, changeStr string
|
|
|
+ )
|
|
|
switch k {
|
|
|
case "bidType":
|
|
|
oldv := common.IntAll(oldMap[k])
|
|
|
newv := common.IntAll(newMap[k])
|
|
|
- if oldv == newv { // 没有改变
|
|
|
- continue
|
|
|
- }
|
|
|
newBidType := BidTypeMap[newv]
|
|
|
- if newBidType == nil {
|
|
|
+ if newBidType == "" {
|
|
|
newBidType = "未选择"
|
|
|
}
|
|
|
+ value = newBidType
|
|
|
+ if oldv == newv { // 没有改变
|
|
|
+ afterMap[k] = map[string]interface{}{
|
|
|
+ "status": status,
|
|
|
+ "value": value,
|
|
|
+ }
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ value = newBidType
|
|
|
if oldv == 0 && newv != 0 { // 说明是新增
|
|
|
+ status = "新增"
|
|
|
changeStr = fmt.Sprintf(actonStr, fieldName, ": (新增)", newBidType)
|
|
|
} else { // 调整
|
|
|
+ status = "调整"
|
|
|
changeStr = fmt.Sprintf(actonStr, fieldName, "(调整):", newBidType)
|
|
|
-
|
|
|
}
|
|
|
case "isWin":
|
|
|
oldV := common.IntAll(oldMap[k])
|
|
|
newV := common.IntAll(newMap[k])
|
|
|
+ value = WinMap[newV]
|
|
|
if oldV == newV { // 没有改变
|
|
|
+ afterMap[k] = map[string]interface{}{
|
|
|
+ "status": status,
|
|
|
+ "value": value,
|
|
|
+ }
|
|
|
continue
|
|
|
}
|
|
|
- fieldName := fieldName
|
|
|
+ status = "调整"
|
|
|
+ //fieldName := fieldName
|
|
|
if common.IntAll(newMap["bidType"]) == BidTypeChanel {
|
|
|
fieldName = fmt.Sprintf("%s%s", "渠道", fieldName)
|
|
|
}
|
|
@@ -490,10 +507,16 @@ func processRecordStr(oldMap, newMap map[string]interface{}) (recordContent stri
|
|
|
bidChangeArr := []string{}
|
|
|
oldSet := gset.NewFrom(oldMap[k])
|
|
|
newSet := gset.NewFrom(newMap[k])
|
|
|
+ value = newMap[k]
|
|
|
// 判断相等
|
|
|
if oldSet.Equal(newSet) {
|
|
|
+ afterMap[k] = map[string]interface{}{
|
|
|
+ "status": status,
|
|
|
+ "value": value,
|
|
|
+ }
|
|
|
continue
|
|
|
}
|
|
|
+ status = "调整"
|
|
|
// 差集计算
|
|
|
// 取消勾选的
|
|
|
cancleSet := oldSet.Diff(newSet)
|
|
@@ -505,7 +528,6 @@ func processRecordStr(oldMap, newMap map[string]interface{}) (recordContent stri
|
|
|
addSet := newSet.Diff(oldSet)
|
|
|
addSet.Iterator(func(v interface{}) bool {
|
|
|
bidChangeArr = append(bidChangeArr, fmt.Sprintf(bidAction, "(新增)", v))
|
|
|
- fmt.Println(v)
|
|
|
return true
|
|
|
})
|
|
|
tmpStr := strings.Join(bidChangeArr, " ")
|
|
@@ -513,19 +535,31 @@ func processRecordStr(oldMap, newMap map[string]interface{}) (recordContent stri
|
|
|
default:
|
|
|
oldV := common.ObjToString(oldMap[k])
|
|
|
newV := common.ObjToString(newMap[k])
|
|
|
+ value = newV
|
|
|
if oldV == newV { // 没有变化
|
|
|
+ afterMap[k] = map[string]interface{}{
|
|
|
+ "status": status,
|
|
|
+ "value": value,
|
|
|
+ }
|
|
|
continue
|
|
|
}
|
|
|
changeStr = fmt.Sprintf(actonStr, fieldName, "(调整)为", fmt.Sprintf("\"%s\"", newV))
|
|
|
+ status = "调整"
|
|
|
}
|
|
|
result = append(result, changeStr)
|
|
|
changeField = append(changeField, k)
|
|
|
+ afterMap[k] = map[string]interface{}{
|
|
|
+ "status": status,
|
|
|
+ "value": value,
|
|
|
+ }
|
|
|
}
|
|
|
+ b, _ := json.Marshal(afterMap)
|
|
|
recordMap := map[string]interface{}{
|
|
|
"content": strings.Join(result, ";"), // 变更内容 文字描述
|
|
|
"before": oldMap, // 变更前
|
|
|
"after": newMap, // 变更后
|
|
|
"changeField": changeField, // 涉及变更的字段
|
|
|
+ "afterMap": string(b), // 涉及变更内容
|
|
|
}
|
|
|
|
|
|
tmp, err := json.Marshal(recordMap)
|