作者 陈志颖

feat:共创合约编辑增加合约变更记录

@@ -801,6 +801,14 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -801,6 +801,14 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
801 sponsor = data 801 sponsor = data
802 } 802 }
803 803
  804 + // 获取操作人
  805 + var operator *domain.User
  806 + if data, err := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, updateCooperationContractCommand.UserId); err != nil {
  807 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  808 + } else {
  809 + operator = data
  810 + }
  811 +
804 // 更新发起人 812 // 更新发起人
805 cooperationContract.CooperationContractSponsor = sponsor 813 cooperationContract.CooperationContractSponsor = sponsor
806 814
@@ -947,28 +955,183 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -947,28 +955,183 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
947 // 更新金额激励规则列表 955 // 更新金额激励规则列表
948 cooperationContract.MoneyIncentivesRules = moneyIncentivesRules 956 cooperationContract.MoneyIncentivesRules = moneyIncentivesRules
949 957
  958 + // 判断激励规则变更
  959 + incentivesType := 0
  960 + if len(dividendsIncentivesRules) > 0 {
  961 + incentivesType = domain.TYPE_DIVIDNEDS_INCENTIVES
  962 + } else if len(moneyIncentivesRules) > 0 {
  963 + incentivesType = domain.TYPE_MONEY_INCENTIVES
  964 + }
  965 + cooperationContract.IncentivesType = int32(incentivesType)
  966 +
950 // 保存共创合约变更 967 // 保存共创合约变更
951 if cooperationContractSaved, err19 := cooperationContractRepository.Save(cooperationContract); err19 != nil { 968 if cooperationContractSaved, err19 := cooperationContractRepository.Save(cooperationContract); err19 != nil {
952 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err19.Error()) 969 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err19.Error())
953 } else { 970 } else {
954 - // TODO 保存共创合约变更记录  
955 - var incentivesRule string  
956 - var incentivesRuleDetail string  
957 - if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType { // 1.激励规则变更 971 + // 保存共创合约变更记录
  972 + // 原【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点),(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】-->更新后【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】
  973 + var incentivesRuleChange string
  974 + var incentivesRuleChangeDetail string
  975 + if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType && cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 1.激励类型变更
  976 + // 业绩分红-->金额激励
  977 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
  978 +
  979 + //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
  980 + // 原业绩分红激励规则
  981 + var dividendsIncentivesRuleOriginal string
  982 + for _, dividendsIncentivesRule := range cooperationContractFound.DividendsIncentivesRules {
  983 + dividendsIncentivesRuleOriginal = dividendsIncentivesRuleOriginal + dividendsIncentivesRule.DividendsIncentivesStageCN +
  984 + ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
  985 + "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
  986 + "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
  987 + "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
  988 + "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
  989 + }
  990 + dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleOriginal + "】"
  991 +
  992 + // 变更后的金额激励规则
  993 + var moneyIncentivesRuleChanged string
  994 + for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules {
  995 + moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
  996 + ":" +
  997 + "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
  998 + "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
  999 + "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
  1000 + }
  1001 + moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleChanged + "】"
958 1002
  1003 + // 拼接规则变更
  1004 + incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + moneyIncentivesRuleOriginalTmp
  1005 + } else if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType && cooperationContractFound.IncentivesType == domain.TYPE_MONEY_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES {
  1006 + // 金额激励-->业绩分红
  1007 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
  1008 + //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
  1009 +
  1010 + // 原金额激励规则
  1011 + var moneyIncentivesRuleOriginal string
  1012 + for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
  1013 + moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN +
  1014 + ":" +
  1015 + "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
  1016 + "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
  1017 + "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
  1018 + }
  1019 + moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
  1020 +
  1021 + // 变更后的业绩分红激励规则
  1022 + var dividendsIncentivesRuleChanged string
  1023 + for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
  1024 + dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN +
  1025 + ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
  1026 + "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
  1027 + "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
  1028 + "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
  1029 + "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
  1030 + }
  1031 + dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleChanged + "】"
  1032 +
  1033 + // 拼接规则变更
  1034 + incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleOriginalTmp
  1035 + } else { // 2.激励规则变更
  1036 + if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 业绩分红激励规则变更
  1037 + if !cooperationContract.DividendsIncentivesRuleSliceEqualBCE(cooperationContractFound.DividendsIncentivesRules, cooperationContractSaved.DividendsIncentivesRules) {
  1038 + // 业绩分红-->业绩分红
  1039 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
  1040 + //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
  1041 +
  1042 + // 原业绩分红激励规则
  1043 + var dividendsIncentivesRuleOriginal string
  1044 + for _, dividendsIncentivesRule := range cooperationContractFound.DividendsIncentivesRules {
  1045 + dividendsIncentivesRuleOriginal = dividendsIncentivesRuleOriginal + dividendsIncentivesRule.DividendsIncentivesStageCN +
  1046 + ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
  1047 + "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
  1048 + "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
  1049 + "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
  1050 + "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
  1051 + }
  1052 + dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleOriginal + "】"
  1053 +
  1054 + // 变更后的业绩分红激励规则
  1055 + var dividendsIncentivesRuleChanged string
  1056 + for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
  1057 + dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN +
  1058 + ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
  1059 + "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
  1060 + "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
  1061 + "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
  1062 + "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
  1063 + }
  1064 + dividendsIncentivesRuleChangedTmp := "【" + dividendsIncentivesRuleChanged + "】"
  1065 +
  1066 + // 拼接规则变更
  1067 + incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleChangedTmp
  1068 + }
  1069 + } else if cooperationContractFound.IncentivesType == domain.MONEY_INCENTIVES { // 金额激励规则变更
  1070 + if !cooperationContract.MoneyIncentivesRuleSliceEqualBCE(cooperationContractFound.MoneyIncentivesRules, cooperationContractSaved.MoneyIncentivesRules) {
  1071 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
  1072 + //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
  1073 +
  1074 + // 原金额激励规则
  1075 + var moneyIncentivesRuleOriginal string
  1076 + for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
  1077 + moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN +
  1078 + ":" +
  1079 + "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
  1080 + "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
  1081 + "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
  1082 + }
  1083 + moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
  1084 +
  1085 + // 变更后的激励规则
  1086 + var moneyIncentivesRuleChanged string
  1087 + for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules {
  1088 + moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
  1089 + ":" +
  1090 + "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
  1091 + "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
  1092 + "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
  1093 + }
  1094 + moneyIncentivesRuleChangedTmp := "【" + moneyIncentivesRuleChanged + "】"
  1095 +
  1096 + // 拼接规则变更
  1097 + incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + moneyIncentivesRuleChangedTmp
  1098 + }
  1099 + }
959 } 1100 }
960 1101
  1102 + // 【1(张三,李四,王五)2(买买买,,)】变更为【1(张三,,)】
  1103 + var undertakerChange string
  1104 + if !cooperationContract.UndertakerSliceEqualBCE(cooperationContractFound.Undertakers, cooperationContractSaved.Undertakers) { // 3.承接人变更
  1105 + // 原承接人
  1106 + var undertakersOriginal string
  1107 + for i, undertaker := range cooperationContractFound.Undertakers {
  1108 + undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
  1109 + }
  1110 + undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
  1111 + // 变更承接人
  1112 + var undertakersChanged string
  1113 + for i, undertaker := range cooperationContractSaved.Undertakers {
  1114 + undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
  1115 + }
  1116 + undertakerChangeTemp2 := "【" + undertakersChanged + "】"
  1117 + // 拼接承接人变更记录
  1118 + undertakerChange = undertakerChangeTmp1 + " 变更为 " + undertakerChangeTemp2
  1119 + }
  1120 +
  1121 + // 新增共创合约变更记录
961 newCooperationContractChangeLog := &domain.CooperationContractChangeLog{ 1122 newCooperationContractChangeLog := &domain.CooperationContractChangeLog{
962 - IncentivesRule: incentivesRule,  
963 - IncentivesRuleDetail: incentivesRuleDetail,  
964 - OperationType: 0,  
965 - Undertakers: "", 1123 + IncentivesRule: incentivesRuleChange,
  1124 + IncentivesRuleDetail: incentivesRuleChangeDetail,
  1125 + OperationType: domain.EDIT,
  1126 + Undertakers: undertakerChange,
966 CooperationContractNumber: cooperationContractSaved.CooperationContractNumber, 1127 CooperationContractNumber: cooperationContractSaved.CooperationContractNumber,
967 Company: company, 1128 Company: company,
968 - Operator: nil, 1129 + Operator: operator,
969 UpdatedAt: time.Time{}, 1130 UpdatedAt: time.Time{},
970 CreatedAt: time.Now(), 1131 CreatedAt: time.Now(),
971 } 1132 }
  1133 +
  1134 + // 保存共创合约变更记录
972 if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil { 1135 if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil {
973 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error()) 1136 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error())
974 } 1137 }
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "github.com/beego/beego/v2/core/validation" 5 "github.com/beego/beego/v2/core/validation"
6 "reflect" 6 "reflect"
7 "strings" 7 "strings"
  8 + "time"
8 ) 9 )
9 10
10 type OrderGoods struct { 11 type OrderGoods struct {
@@ -36,7 +37,7 @@ type CreateDividendsReturnedOrderCommand struct { @@ -36,7 +37,7 @@ type CreateDividendsReturnedOrderCommand struct {
36 // 备注 37 // 备注
37 Remarks string `cname:"备注" json:"remarks" valid:"Required"` 38 Remarks string `cname:"备注" json:"remarks" valid:"Required"`
38 // 退货日期 39 // 退货日期
39 - DividendsReturnedDate string `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"` 40 + DividendsReturnedDate time.Time `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"`
40 // 退货区域名称 41 // 退货区域名称
41 RegionName string `cname:"退货区域名称" json:"regionName,omitempty"` 42 RegionName string `cname:"退货区域名称" json:"regionName,omitempty"`
42 // 订单产品列表 43 // 订单产品列表
@@ -135,7 +135,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide @@ -135,7 +135,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
135 OriginalOrderNum: createDividendsReturnedOrderCommand.OriginalOrderNum, 135 OriginalOrderNum: createDividendsReturnedOrderCommand.OriginalOrderNum,
136 DividendsOrderNumber: createDividendsReturnedOrderCommand.DividendsOrderNumber, 136 DividendsOrderNumber: createDividendsReturnedOrderCommand.DividendsOrderNumber,
137 DividendsReturnedCustomerName: createDividendsReturnedOrderCommand.DividendsReturnedCustomerName, 137 DividendsReturnedCustomerName: createDividendsReturnedOrderCommand.DividendsReturnedCustomerName,
138 - DividendsReturnedDate: time.Time{}, 138 + DividendsReturnedDate: createDividendsReturnedOrderCommand.DividendsReturnedDate,
139 Region: &domain.RegionInfo{ 139 Region: &domain.RegionInfo{
140 RegionNumber: "", 140 RegionNumber: "",
141 RegionName: createDividendsReturnedOrderCommand.RegionName, 141 RegionName: createDividendsReturnedOrderCommand.RegionName,
@@ -147,7 +147,6 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide @@ -147,7 +147,6 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
147 Org: organization, 147 Org: organization,
148 Company: company, 148 Company: company,
149 CreatedAt: time.Now(), 149 CreatedAt: time.Now(),
150 - DeletedAt: time.Time{},  
151 UpdatedAt: time.Time{}, 150 UpdatedAt: time.Time{},
152 Operator: operator, 151 Operator: operator,
153 OperateTime: time.Now(), 152 OperateTime: time.Now(),
@@ -9,6 +9,28 @@ const ( @@ -9,6 +9,28 @@ const (
9 TYPE_MONEY_INCENTIVES 9 TYPE_MONEY_INCENTIVES
10 ) 10 )
11 11
  12 +type IncentivesType int32
  13 +
  14 +const (
  15 + DividendsIncentives IncentivesType = 1
  16 + MoneyIncentives IncentivesType = 2
  17 +)
  18 +
  19 +func (p IncentivesType) String() string {
  20 + switch p {
  21 + case DividendsIncentives:
  22 + return "业绩分红"
  23 + case MoneyIncentives:
  24 + return "金额激励"
  25 + default:
  26 + return "未知类型"
  27 + }
  28 +}
  29 +
  30 +func (cooperationContract *CooperationContract) ReturnIncentivesName(p IncentivesType) string {
  31 + return p.String()
  32 +}
  33 +
12 // CooperationContract 共创项目合约实体 34 // CooperationContract 共创项目合约实体
13 type CooperationContract struct { 35 type CooperationContract struct {
14 // 共创合约ID 36 // 共创合约ID
@@ -101,3 +123,54 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface @@ -101,3 +123,54 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface
101 } 123 }
102 return nil 124 return nil
103 } 125 }
  126 +
  127 +// UndertakerSliceEqualBCE 判断承接人Slice是否一样
  128 +func (cooperationContract *CooperationContract) UndertakerSliceEqualBCE(a, b []*Undertaker) bool {
  129 + if len(a) != len(b) {
  130 + return false
  131 + }
  132 + if (a == nil) != (b == nil) {
  133 + return false
  134 + }
  135 + b = b[:len(a)]
  136 + for i, v := range a {
  137 + if v != b[i] {
  138 + return false
  139 + }
  140 + }
  141 + return true
  142 +}
  143 +
  144 +// DividendsIncentivesRuleSliceEqualBCE 判断业绩分红激励规则Slice是否一样
  145 +func (cooperationContract *CooperationContract) DividendsIncentivesRuleSliceEqualBCE(a, b []*DividendsIncentivesRule) bool {
  146 + if len(a) != len(b) {
  147 + return false
  148 + }
  149 + if (a == nil) != (b == nil) {
  150 + return false
  151 + }
  152 + b = b[:len(a)]
  153 + for i, v := range a {
  154 + if v != b[i] {
  155 + return false
  156 + }
  157 + }
  158 + return true
  159 +}
  160 +
  161 +// MoneyIncentivesRuleSliceEqualBCE 判断金额激励规则Slice是否一样
  162 +func (cooperationContract *CooperationContract) MoneyIncentivesRuleSliceEqualBCE(a, b []*MoneyIncentivesRule) bool {
  163 + if len(a) != len(b) {
  164 + return false
  165 + }
  166 + if (a == nil) != (b == nil) {
  167 + return false
  168 + }
  169 + b = b[:len(a)]
  170 + for i, v := range a {
  171 + if v != b[i] {
  172 + return false
  173 + }
  174 + }
  175 + return true
  176 +}
@@ -2,6 +2,12 @@ package domain @@ -2,6 +2,12 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
  5 +const (
  6 + EDIT = iota + 1 // 编辑
  7 + PAUSE // 暂停
  8 + RECOVER // 恢复
  9 +)
  10 +
5 // CooperationContractChangeLog 共创合约变更日志 11 // CooperationContractChangeLog 共创合约变更日志
6 type CooperationContractChangeLog struct { 12 type CooperationContractChangeLog struct {
7 // 共创合约变更日志 13 // 共创合约变更日志
@@ -20,6 +26,8 @@ type CooperationContractChangeLog struct { @@ -20,6 +26,8 @@ type CooperationContractChangeLog struct {
20 Company *Company `json:"company"` 26 Company *Company `json:"company"`
21 // 操作人 27 // 操作人
22 Operator *User `json:"operator"` 28 Operator *User `json:"operator"`
  29 + // 操作时间
  30 + OperatorTime time.Time `json:"operatorTime"`
23 // 更新时间 31 // 更新时间
24 UpdatedAt time.Time `json:"updatedAt"` 32 UpdatedAt time.Time `json:"updatedAt"`
25 // 删除时间 33 // 删除时间
@@ -58,56 +66,5 @@ func (cooperationContractChangeLog *CooperationContractChangeLog) Update(data ma @@ -58,56 +66,5 @@ func (cooperationContractChangeLog *CooperationContractChangeLog) Update(data ma
58 if undertakers, ok := data["undertakers"]; ok { 66 if undertakers, ok := data["undertakers"]; ok {
59 cooperationContractChangeLog.Undertakers = undertakers.(string) 67 cooperationContractChangeLog.Undertakers = undertakers.(string)
60 } 68 }
61 - if companyId, ok := data["companyId"]; ok {  
62 - cooperationContractChangeLog.Company.CompanyId = companyId.(int64)  
63 - }  
64 - if companyLogo, ok := data["companyLogo"]; ok {  
65 - cooperationContractChangeLog.Company.CompanyLogo = companyLogo.(string)  
66 - }  
67 - if companyName, ok := data["companyName"]; ok {  
68 - cooperationContractChangeLog.Company.CompanyName = companyName.(string)  
69 - }  
70 - if userId, ok := data["userId"]; ok {  
71 - cooperationContractChangeLog.Operator.UserId = userId.(int64)  
72 - }  
73 - if userBaseId, ok := data["userBaseId"]; ok {  
74 - cooperationContractChangeLog.Operator.UserBaseId = userBaseId.(int64)  
75 - }  
76 - if orgId, ok := data["orgId"]; ok {  
77 - cooperationContractChangeLog.Operator.Org.OrgId = orgId.(int64)  
78 - }  
79 - if orgName, ok := data["orgName"]; ok {  
80 - cooperationContractChangeLog.Operator.Org.OrgName = orgName.(string)  
81 - }  
82 - if departmentId, ok := data["departmentId"]; ok {  
83 - cooperationContractChangeLog.Operator.Department.DepartmentId = departmentId.(int64)  
84 - }  
85 - if departmentName, ok := data["departmentName"]; ok {  
86 - cooperationContractChangeLog.Operator.Department.DepartmentName = departmentName.(string)  
87 - }  
88 - if departmentNumber, ok := data["departmentNumber"]; ok {  
89 - cooperationContractChangeLog.Operator.Department.DepartmentNumber = departmentNumber.(string)  
90 - }  
91 - if userAvatar, ok := data["userAvatar"]; ok {  
92 - cooperationContractChangeLog.Operator.UserInfo.UserAvatar = userAvatar.(string)  
93 - }  
94 - if userEmail, ok := data["userEmail"]; ok {  
95 - cooperationContractChangeLog.Operator.UserInfo.UserEmail = userEmail.(string)  
96 - }  
97 - if userName, ok := data["userName"]; ok {  
98 - cooperationContractChangeLog.Operator.UserInfo.UserName = userName.(string)  
99 - }  
100 - if userPhone, ok := data["userPhone"]; ok {  
101 - cooperationContractChangeLog.Operator.UserInfo.UserPhone = userPhone.(string)  
102 - }  
103 - if userAccount, ok := data["userAccount"]; ok {  
104 - cooperationContractChangeLog.Operator.UserInfo.UserAccount = userAccount.(string)  
105 - }  
106 - if userType, ok := data["userType"]; ok {  
107 - cooperationContractChangeLog.Operator.UserType = userType.(int32)  
108 - }  
109 - if status, ok := data["status"]; ok {  
110 - cooperationContractChangeLog.Operator.Status = status.(int32)  
111 - }  
112 return nil 69 return nil
113 } 70 }
@@ -23,6 +23,8 @@ type CooperationContractChangeLog struct { @@ -23,6 +23,8 @@ type CooperationContractChangeLog struct {
23 Company *domain.Company `comment:"公司"` 23 Company *domain.Company `comment:"公司"`
24 // 操作人 24 // 操作人
25 Operator *domain.User `comment:"操作人"` 25 Operator *domain.User `comment:"操作人"`
  26 + // 操作时间
  27 + OperatorTime time.Time `comment:"操作时间"`
26 // 更新时间 28 // 更新时间
27 UpdatedAt time.Time `comment:"更新时间"` 29 UpdatedAt time.Time `comment:"更新时间"`
28 // 删除时间 30 // 删除时间
@@ -34,6 +34,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra @@ -34,6 +34,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
34 "undertakers", 34 "undertakers",
35 "company", 35 "company",
36 "operator", 36 "operator",
  37 + "operator_time",
37 "updated_at", 38 "updated_at",
38 "deleted_at", 39 "deleted_at",
39 "created_at", 40 "created_at",
@@ -60,6 +61,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra @@ -60,6 +61,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
60 &cooperationContractChangeLog.Undertakers, 61 &cooperationContractChangeLog.Undertakers,
61 &cooperationContractChangeLog.Company, 62 &cooperationContractChangeLog.Company,
62 &cooperationContractChangeLog.Operator, 63 &cooperationContractChangeLog.Operator,
  64 + &cooperationContractChangeLog.OperatorTime,
63 &cooperationContractChangeLog.UpdatedAt, 65 &cooperationContractChangeLog.UpdatedAt,
64 &cooperationContractChangeLog.DeletedAt, 66 &cooperationContractChangeLog.DeletedAt,
65 &cooperationContractChangeLog.CreatedAt, 67 &cooperationContractChangeLog.CreatedAt,
@@ -72,6 +74,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra @@ -72,6 +74,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
72 cooperationContractChangeLog.Undertakers, 74 cooperationContractChangeLog.Undertakers,
73 cooperationContractChangeLog.Company, 75 cooperationContractChangeLog.Company,
74 cooperationContractChangeLog.Operator, 76 cooperationContractChangeLog.Operator,
  77 + cooperationContractChangeLog.OperatorTime,
75 cooperationContractChangeLog.UpdatedAt, 78 cooperationContractChangeLog.UpdatedAt,
76 nil, 79 nil,
77 cooperationContractChangeLog.CreatedAt, 80 cooperationContractChangeLog.CreatedAt,
@@ -88,6 +91,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra @@ -88,6 +91,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
88 &cooperationContractChangeLog.Undertakers, 91 &cooperationContractChangeLog.Undertakers,
89 &cooperationContractChangeLog.Company, 92 &cooperationContractChangeLog.Company,
90 &cooperationContractChangeLog.Operator, 93 &cooperationContractChangeLog.Operator,
  94 + &cooperationContractChangeLog.OperatorTime,
91 &cooperationContractChangeLog.UpdatedAt, 95 &cooperationContractChangeLog.UpdatedAt,
92 &cooperationContractChangeLog.DeletedAt, 96 &cooperationContractChangeLog.DeletedAt,
93 &cooperationContractChangeLog.CreatedAt, 97 &cooperationContractChangeLog.CreatedAt,
@@ -100,6 +104,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra @@ -100,6 +104,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
100 cooperationContractChangeLog.Undertakers, 104 cooperationContractChangeLog.Undertakers,
101 cooperationContractChangeLog.Company, 105 cooperationContractChangeLog.Company,
102 cooperationContractChangeLog.Operator, 106 cooperationContractChangeLog.Operator,
  107 + cooperationContractChangeLog.OperatorTime,
103 cooperationContractChangeLog.UpdatedAt, 108 cooperationContractChangeLog.UpdatedAt,
104 nil, 109 nil,
105 cooperationContractChangeLog.CreatedAt, 110 cooperationContractChangeLog.CreatedAt,