|
@@ -2,24 +2,37 @@ package service
|
|
|
|
|
|
import (
|
|
import (
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
"app.yhyue.com/moapp/jybase/encrypt"
|
|
"app.yhyue.com/moapp/jybase/encrypt"
|
|
|
|
+ "encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "github.com/gogf/gf/v2/container/gset"
|
|
|
|
+ "github.com/zeromicro/go-zero/core/logx"
|
|
IC "jyBXCore/rpc/init"
|
|
IC "jyBXCore/rpc/init"
|
|
|
|
+ "jyBXCore/rpc/model/mysql"
|
|
"jyBXCore/rpc/type/bxcore"
|
|
"jyBXCore/rpc/type/bxcore"
|
|
|
|
+ "jyBXCore/rpc/util"
|
|
"strings"
|
|
"strings"
|
|
)
|
|
)
|
|
|
|
|
|
const (
|
|
const (
|
|
- TableEntnicheUser = "entniche_user" // 企业用户表
|
|
|
|
- TableParticipateUser = "participate_user" // 参标用户表
|
|
|
|
- PositionTypeEnt = 1 // 职位类型企业
|
|
|
|
- PositionTypePersonal = 0 // 职位类型个人
|
|
|
|
- ButtonValueParticipate = 0 // 参标按钮 显示值 0-参标
|
|
|
|
- ButtonValueParticipated = 1 // 按钮显示值 列表页面 1-已参标
|
|
|
|
- RoleEntManager = 1 // 企业管理员角色
|
|
|
|
- RoleDepartManager = 2 // 部门管理员角色
|
|
|
|
- BidTypeDirect = 1 // 直接投标
|
|
|
|
- BidTypeChanel = 2 // 渠道投标
|
|
|
|
|
|
+ TableEntnicheUser = "entniche_user" // 企业用户表
|
|
|
|
+ TableParticipateUser = "participate_user" // 参标用户表
|
|
|
|
+
|
|
|
|
+ PositionTypeEnt = 1 // 职位类型企业
|
|
|
|
+ PositionTypePersonal = 0 // 职位类型个人
|
|
|
|
+
|
|
|
|
+ ButtonValueParticipate = 0 // 参标按钮 显示值 0-参标
|
|
|
|
+ ButtonValueParticipated = 1 // 按钮显示值 列表页面 1-已参标
|
|
|
|
+
|
|
|
|
+ RoleEntManager = 1 // 企业管理员角色
|
|
|
|
+ RoleDepartManager = 2 // 部门管理员角色
|
|
|
|
+
|
|
|
|
+ BidTypeDirect = 1 // 直接投标
|
|
|
|
+ BidTypeChanel = 2 // 渠道投标
|
|
|
|
+
|
|
|
|
+ RecordTypeBidStatus = 1 // 存储类型 1:投标状态更新
|
|
|
|
+
|
|
)
|
|
)
|
|
|
|
|
|
type ParticipateBid struct {
|
|
type ParticipateBid struct {
|
|
@@ -50,7 +63,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 state=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 { // 如果查到了 说明已经参标 这部分应该显示已参标
|
|
@@ -90,7 +103,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 state=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 { // 如果查到了 说明这个项目公司里面已经参标 处理一下信息用于后边判断是否是自己参标
|
|
@@ -141,7 +154,9 @@ func (p *ParticipateBid) DetailEntFormat(existProjectMap map[string]string, isVa
|
|
return
|
|
return
|
|
}
|
|
}
|
|
persons := ""
|
|
persons := ""
|
|
- for _, v := range existProjectMap { // 这是为了取参标人id信息 列表页是多条数据 详情页这里 map里面只会有一条数据
|
|
|
|
|
|
+ projectId := ""
|
|
|
|
+ for k, v := range existProjectMap { // 这是为了取参标人id信息 列表页是多条数据 详情页这里 map里面只会有一条数据
|
|
|
|
+ projectId = k
|
|
persons = v
|
|
persons = v
|
|
break
|
|
break
|
|
}
|
|
}
|
|
@@ -155,6 +170,7 @@ func (p *ParticipateBid) DetailEntFormat(existProjectMap map[string]string, isVa
|
|
}
|
|
}
|
|
// 如果是管理员 显示 终止参标按钮、转给同事按钮
|
|
// 如果是管理员 显示 终止参标按钮、转给同事按钮
|
|
if p.EntRoleId == RoleEntManager || p.EntRoleId == RoleDepartManager {
|
|
if p.EntRoleId == RoleEntManager || p.EntRoleId == RoleDepartManager {
|
|
|
|
+ formatData.ProjectId = encrypt.EncodeArticleId2ByCheck(projectId)
|
|
formatData.ShowStopParticipate = true
|
|
formatData.ShowStopParticipate = true
|
|
formatData.ShowTransfer = true
|
|
formatData.ShowTransfer = true
|
|
}
|
|
}
|
|
@@ -243,45 +259,314 @@ 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
|
|
}
|
|
}
|
|
|
|
|
|
-/*
|
|
|
|
-投标状态更新
|
|
|
|
-1. 验证参标人
|
|
|
|
-2. 更新 存操作记录
|
|
|
|
-*/
|
|
|
|
-// 更新投标状态
|
|
|
|
-func (p *ParticipateBid) updateBidStatus() {
|
|
|
|
|
|
+// CheckBidPower 投标状态更新/查看记录 验证权限(参标人或者是该企业下的管理员)
|
|
|
|
+func (p *ParticipateBid) CheckBidPower(projectId string, valid bool) (b bool) {
|
|
|
|
+
|
|
|
|
+ switch p.PositionType {
|
|
|
|
+ case PositionTypePersonal:
|
|
|
|
+ // 查个人id
|
|
|
|
+ b = mysql.CheckParticipatePersonal(projectId, p.PositionId, valid)
|
|
|
|
+ case PositionTypeEnt:
|
|
|
|
+ // 查企业
|
|
|
|
+ if p.EntRoleId == RoleEntManager || p.EntRoleId == RoleDepartManager {
|
|
|
|
+ b = mysql.CheckParticipateManager(projectId, p.EntId, valid)
|
|
|
|
+ } else {
|
|
|
|
+ // 查参标人
|
|
|
|
+ b = mysql.CheckParticipateEntUser(projectId, p.PositionId, valid)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// UpdateBidStatus 更新投标状态
|
|
|
|
+func (p *ParticipateBid) UpdateBidStatus(in *bxcore.UpdateBidStatusReq, projectId string) (flag bool) {
|
|
|
|
+ if p.PositionType == PositionTypeEnt {
|
|
|
|
+ pLock := util.GetParticipateLock(fmt.Sprintf("%d_%s", p.EntId, projectId))
|
|
|
|
+ pLock.Lock()
|
|
|
|
+ defer pLock.Unlock()
|
|
|
|
+ }
|
|
|
|
+ // 如果查出来旧的 那么就需要做新旧对比
|
|
|
|
+ oldMap := p.GetLastBidStatus(projectId) // 查询出最新的招标状态信息
|
|
|
|
+ // 新的
|
|
|
|
+ if in.BidStage == nil {
|
|
|
|
+ in.BidStage = []string{}
|
|
|
|
+ }
|
|
|
|
+ newMap := map[string]interface{}{
|
|
|
|
+ "bidType": in.BidType,
|
|
|
|
+ "bidStage": in.BidStage,
|
|
|
|
+ "isWin": in.IsWin,
|
|
|
|
+ "channelName": in.ChannelName,
|
|
|
|
+ "channelPerson": in.ChannelPerson,
|
|
|
|
+ "channelPhone": in.ChannelPhone,
|
|
|
|
+ "winner": in.Winner,
|
|
|
|
+ }
|
|
|
|
+ // 新旧对比 处理成要保存的字段
|
|
|
|
+ recordContent, err := processRecordStr(oldMap, newMap)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ // 保存
|
|
|
|
+ recordData := map[string]interface{}{
|
|
|
|
+ "ent_id": p.EntId,
|
|
|
|
+ "ent_user_id": p.EntUserId,
|
|
|
|
+ "position_id": p.PositionId,
|
|
|
|
+ "project_id": projectId,
|
|
|
|
+ "record_content": recordContent,
|
|
|
|
+ "record_type": RecordTypeBidStatus,
|
|
|
|
+ "create_date": date.NowFormat(date.Date_Full_Layout),
|
|
|
|
+ }
|
|
|
|
+ flag = mysql.InsertBidContent(recordData)
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// GetLastBidStatus 获取投标状态信息
|
|
|
|
+func (p *ParticipateBid) GetLastBidStatus(projectId string) map[string]interface{} {
|
|
|
|
+ rs := map[string]interface{}{}
|
|
|
|
+ // 查询项目投标信息 区分企业和个人
|
|
|
|
+ var result *[]map[string]interface{}
|
|
|
|
+ switch p.PositionType {
|
|
|
|
+ case PositionTypeEnt:
|
|
|
|
+ result = mysql.GetBidContentEnt(projectId, p.EntId)
|
|
|
|
+ case PositionTypePersonal:
|
|
|
|
+ result = mysql.GetBidContentPersonal(projectId, p.PositionId)
|
|
|
|
+ }
|
|
|
|
+ if rs != nil && len(*result) > 0 {
|
|
|
|
+ content := common.ObjToMap((*result)[0]["record_content"])
|
|
|
|
+ if content != nil {
|
|
|
|
+ bidStatus := common.ObjToMap((*content)["after"])
|
|
|
|
+ if bidStatus != nil {
|
|
|
|
+ rs = *bidStatus
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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 获取操作记录
|
|
|
|
+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 = mysql.GetBidRecordsEnt(projectId, p.EntId, page, pageSize)
|
|
|
|
+ case PositionTypePersonal:
|
|
|
|
+ // 个人版不展示姓名
|
|
|
|
+ rs, total = mysql.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)
|
|
|
|
|
|
- // 更新
|
|
|
|
|
|
+ }
|
|
|
|
+ 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 := mysql.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
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 处理操作动作
|
|
|
|
+var (
|
|
|
|
+ ParticipateBidContentKey = map[string]string{
|
|
|
|
+ "bidType": "投标类型",
|
|
|
|
+ "bidStage": "投标项目阶段",
|
|
|
|
+ "isWin": "是否中标",
|
|
|
|
+ "channelName": "渠道名称",
|
|
|
|
+ "channelPerson": "联系人",
|
|
|
|
+ "channelPhone": "联系电话",
|
|
|
|
+ "winner": "中标单位",
|
|
|
|
+ }
|
|
|
|
+ BidTypeMap = map[int]interface{}{
|
|
|
|
+ BidTypeDirect: "直接投标",
|
|
|
|
+ BidTypeChanel: "渠道投标",
|
|
|
|
+ }
|
|
|
|
+ WinMap = map[int]interface{}{
|
|
|
|
+ 1: "是",
|
|
|
|
+ 2: "否",
|
|
|
|
+ 0: "未选择",
|
|
|
|
+ }
|
|
|
|
+)
|
|
|
|
+
|
|
// 处理操作记录
|
|
// 处理操作记录
|
|
-//var (
|
|
|
|
-// BidTypeKey = map[string]interface{}{
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
-// ParticipateBidContentKey = map[string]interface{}{
|
|
|
|
-// "bidType":map[string]interface{}{
|
|
|
|
-// "name":"投标类型",
|
|
|
|
-// "updateAction":"调整",
|
|
|
|
-// "valueType":2,
|
|
|
|
-// "valueMap":map[int]interface{}{
|
|
|
|
-// BidTypeDirect:"直接投标",
|
|
|
|
-// BidTypeChanel:"渠道投标",
|
|
|
|
-// },
|
|
|
|
-// },
|
|
|
|
-// "isWin":map[string]interface{}{
|
|
|
|
-// "name":map[int]string{
|
|
|
|
-// 1:
|
|
|
|
-// },
|
|
|
|
-//
|
|
|
|
-// },
|
|
|
|
-// }
|
|
|
|
-//)
|
|
|
|
|
|
+func processRecordStr(oldMap, newMap map[string]interface{}) (recordContent string, err error) {
|
|
|
|
+ actonStr := "%s%s%s"
|
|
|
|
+ changeField := []string{}
|
|
|
|
+ result := []string{}
|
|
|
|
+ for k, fieldName := range ParticipateBidContentKey {
|
|
|
|
+ changeStr := ""
|
|
|
|
+ switch k {
|
|
|
|
+ case "bidType":
|
|
|
|
+ oldv := common.IntAll(oldMap[k])
|
|
|
|
+ newv := common.IntAll(newMap[k])
|
|
|
|
+ if oldv == newv { // 没有改变
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ newBidType := BidTypeMap[newv]
|
|
|
|
+ if newBidType == nil {
|
|
|
|
+ newBidType = "未选择"
|
|
|
|
+ }
|
|
|
|
+ if oldv == 0 && newv != 0 { // 说明是新增
|
|
|
|
+ changeStr = fmt.Sprintf(actonStr, fieldName, ": (新增)", newBidType)
|
|
|
|
+ } else { // 调整
|
|
|
|
+ changeStr = fmt.Sprintf(actonStr, fieldName, "(调整):", newBidType)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ case "isWin":
|
|
|
|
+ oldV := common.IntAll(oldMap[k])
|
|
|
|
+ newV := common.IntAll(newMap[k])
|
|
|
|
+ if oldV == newV { // 没有改变
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ fieldName := fieldName
|
|
|
|
+ if common.IntAll(newMap["bidType"]) == BidTypeChanel {
|
|
|
|
+ fieldName = fmt.Sprintf("%s%s", "渠道", fieldName)
|
|
|
|
+ }
|
|
|
|
+ changeStr = fmt.Sprintf(actonStr, fieldName, "(调整) 为", WinMap[newV])
|
|
|
|
+ case "bidStage":
|
|
|
|
+ bidAction := "%s%s"
|
|
|
|
+ bidChangeArr := []string{}
|
|
|
|
+ oldSet := gset.NewFrom(oldMap[k])
|
|
|
|
+ newSet := gset.NewFrom(newMap[k])
|
|
|
|
+ // 判断相等
|
|
|
|
+ if oldSet.Equal(newSet) {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ // 差集计算
|
|
|
|
+ // 取消勾选的
|
|
|
|
+ cancleSet := oldSet.Diff(newSet)
|
|
|
|
+ cancleSet.Iterator(func(v interface{}) bool {
|
|
|
|
+ bidChangeArr = append(bidChangeArr, fmt.Sprintf(bidAction, "(取消勾选)", v))
|
|
|
|
+ return true
|
|
|
|
+ })
|
|
|
|
+ // 新增的
|
|
|
|
+ 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, " ")
|
|
|
|
+ changeStr = fmt.Sprintf(actonStr, fieldName, " :", tmpStr)
|
|
|
|
+ default:
|
|
|
|
+ oldV := common.ObjToString(oldMap[k])
|
|
|
|
+ newV := common.ObjToString(newMap[k])
|
|
|
|
+ if oldV == newV { // 没有变化
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ changeStr = fmt.Sprintf(actonStr, fieldName, "(调整)为", fmt.Sprintf("\"%s\"", newV))
|
|
|
|
+ }
|
|
|
|
+ result = append(result, changeStr)
|
|
|
|
+ changeField = append(changeField, k)
|
|
|
|
+ }
|
|
|
|
+ recordMap := map[string]interface{}{
|
|
|
|
+ "content": strings.Join(result, ";"), // 变更内容 文字描述
|
|
|
|
+ "before": oldMap, // 变更前
|
|
|
|
+ "after": newMap, // 变更后
|
|
|
|
+ "changeField": changeField, // 涉及变更的字段
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ tmp, err := json.Marshal(recordMap)
|
|
|
|
+ if err != nil {
|
|
|
|
+ logx.Error("序列化操作记录失败:", err)
|
|
|
|
+ return "", err
|
|
|
|
+ }
|
|
|
|
+ if len(result) == 0 {
|
|
|
|
+ logx.Error("没有更新的内容:", recordContent)
|
|
|
|
+ err = fmt.Errorf("没有变更的内容,不用更新")
|
|
|
|
+ }
|
|
|
|
+ return string(tmp), err
|
|
|
|
+}
|