浏览代码

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

wangshan 2 年之前
父节点
当前提交
0f58be7a30

+ 3 - 4
jyBXCore/rpc/internal/logic/updatebidstatuslogic.go

@@ -71,12 +71,11 @@ func (l *UpdateBidStatusLogic) UpdateBidStatus(in *bxcore.UpdateBidStatusReq) (*
 		return result, nil
 	}
 	// 2. 更新
-	flag := participateService.UpdateBidStatus(in, projectId)
-	if !flag {
-		result.ErrMsg = "更新失败"
+	if err := participateService.UpdateBidStatus(in, projectId); err != nil {
+		result.ErrMsg = err.Error()
 	} else {
+		result.Data = true
 		result.ErrCode = 0
 	}
-	result.Data = flag
 	return result, nil
 }

+ 3 - 3
jyBXCore/rpc/model/mysql/participateBid.go

@@ -656,7 +656,7 @@ func SingleParticipateList(in *bxcore.ParticipateListReq, conditionSql string) (
 					BidEndTime:       bidEndTime,
 					BidOpenTime:      bidOpenTime,
 					UpdateStatusTime: updateStatusTime,
-					UpdateStatusCon:  GetParticipateContent("s", in.PositionId, MC.ObjToString(v["id"])), //查询最后一次 投标状态更新,
+					//UpdateStatusCon:  GetParticipateContent("s", in.PositionId, MC.ObjToString(v["id"])), //查询最后一次 投标状态更新,
 				})
 			}
 			return data, nil
@@ -718,8 +718,8 @@ func AdminParticipateList(in *bxcore.ParticipateListReq, conditionSql string) (d
 					BidEndTime:       bidEndTime,
 					BidOpenTime:      bidOpenTime,
 					UpdateStatusTime: updateStatusTime,
-					UpdateStatusCon:  GetParticipateContent("e", in.EntId, MC.ObjToString(v["id"])), //查询最后一次 投标状态更新
-					Participants:     GetParticipateUserName(MC.ObjToString(v["ent_user_id"])),      //参标人信息
+					//UpdateStatusCon:  GetParticipateContent("e", in.EntId, MC.ObjToString(v["id"])), //查询最后一次 投标状态更新
+					Participants: GetParticipateUserName(MC.ObjToString(v["ent_user_id"])), //参标人信息
 				})
 			}
 			return data, nil

+ 56 - 22
jyBXCore/rpc/service/participateBid.go

@@ -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)