作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !47
@@ -12,7 +12,7 @@ type UpdateCooperationContractCommand struct { @@ -12,7 +12,7 @@ type UpdateCooperationContractCommand struct {
12 // 共创合约id 12 // 共创合约id
13 CooperationContractId string `cname:"共创合约id" json:"cooperationContractId" valid:"Required"` 13 CooperationContractId string `cname:"共创合约id" json:"cooperationContractId" valid:"Required"`
14 // 共创合约描述 14 // 共创合约描述
15 - CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription"` 15 + CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription,omitempty"`
16 // 共创项目编号 16 // 共创项目编号
17 CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber"` 17 CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber"`
18 // 部门ID 18 // 部门ID
@@ -43,7 +43,7 @@ type UpdateCooperationContractCommand struct { @@ -43,7 +43,7 @@ type UpdateCooperationContractCommand struct {
43 43
44 func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(validation *validation.Validation) { 44 func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(validation *validation.Validation) {
45 // 激励规则自定义校验 45 // 激励规则自定义校验
46 - if len(updateCooperationContractCommand.DividendsIncentivesRules) <= 0 && len(updateCooperationContractCommand.MoneyIncentivesRules) <= 0 { 46 + if len(updateCooperationContractCommand.DividendsIncentivesRules) < 1 && len(updateCooperationContractCommand.MoneyIncentivesRules) < 1 {
47 validation.Error("激励规则不能为空") 47 validation.Error("激励规则不能为空")
48 } else { 48 } else {
49 for i, _ := range updateCooperationContractCommand.DividendsIncentivesRules { 49 for i, _ := range updateCooperationContractCommand.DividendsIncentivesRules {
@@ -58,7 +58,7 @@ func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid( @@ -58,7 +58,7 @@ func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(
58 } 58 }
59 } 59 }
60 // 承接人列表校验 60 // 承接人列表校验
61 - if len(updateCooperationContractCommand.Undertakers) <= 0 { 61 + if len(updateCooperationContractCommand.Undertakers) < 1 {
62 validation.Error("承接人不能为空") 62 validation.Error("承接人不能为空")
63 } else { 63 } else {
64 for i, _ := range updateCooperationContractCommand.Undertakers { 64 for i, _ := range updateCooperationContractCommand.Undertakers {
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "crypto/md5"
  5 + "encoding/hex"
4 "fmt" 6 "fmt"
5 "strconv" 7 "strconv"
6 "time" 8 "time"
  9 + "unsafe"
7 10
8 "github.com/linmadan/egglib-go/core/application" 11 "github.com/linmadan/egglib-go/core/application"
9 "github.com/linmadan/egglib-go/utils/tool_funs" 12 "github.com/linmadan/egglib-go/utils/tool_funs"
@@ -746,7 +749,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper @@ -746,7 +749,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper
746 if err != nil { 749 if err != nil {
747 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 750 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
748 } 751 }
749 - for _, cooperationContractOperated := range cooperationContractsOperated { 752 + for _, cooperationContractOperated := range cooperationContracts {
750 // 新增共创合约变更记录 753 // 新增共创合约变更记录
751 var operationType int32 754 var operationType int32
752 if batchOperateCooperationContractCommand.Action == 1 { 755 if batchOperateCooperationContractCommand.Action == 1 {
@@ -764,6 +767,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper @@ -764,6 +767,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper
764 Org: cooperationContractOperated.Org, 767 Org: cooperationContractOperated.Org,
765 Operator: operator, 768 Operator: operator,
766 CreatedAt: time.Now(), 769 CreatedAt: time.Now(),
  770 + OperatorTime: time.Now(),
767 } 771 }
768 772
769 // 保存共创合约变更记录 773 // 保存共创合约变更记录
@@ -939,24 +943,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -939,24 +943,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
939 } 943 }
940 944
941 // 获取待更新的共创合约 945 // 获取待更新的共创合约
942 - cooperationContract, err8 := cooperationContractRepository.FindOne(map[string]interface{}{ 946 + cooperationContractFound, err8 := cooperationContractRepository.FindOne(map[string]interface{}{
943 "cooperationContractId": updateCooperationContractCommand.CooperationContractId, 947 "cooperationContractId": updateCooperationContractCommand.CooperationContractId,
944 }) 948 })
945 if err8 != nil { 949 if err8 != nil {
946 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在") 950 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
947 } 951 }
948 - if cooperationContract == nil { 952 + if cooperationContractFound == nil {
949 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId))) 953 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId)))
950 } 954 }
951 955
952 - // 缓存共创合约  
953 - cooperationContractFound := cooperationContract  
954 -  
955 - // 更新合约基础信息  
956 - if err9 := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err9 != nil {  
957 - return nil, application.ThrowError(application.BUSINESS_ERROR, err9.Error())  
958 - }  
959 -  
960 // 用户REST服务初始化 956 // 用户REST服务初始化
961 var userService service.UserService 957 var userService service.UserService
962 if value, err10 := factory.CreateUserService(map[string]interface{}{}); err10 != nil { 958 if value, err10 := factory.CreateUserService(map[string]interface{}{}); err10 != nil {
@@ -985,6 +981,22 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -985,6 +981,22 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
985 operator = data 981 operator = data
986 } 982 }
987 983
  984 + // 获取待更新的共创合约
  985 + cooperationContract, err8 := cooperationContractRepository.FindOne(map[string]interface{}{
  986 + "cooperationContractId": updateCooperationContractCommand.CooperationContractId,
  987 + })
  988 + if err8 != nil {
  989 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
  990 + }
  991 + if cooperationContract == nil {
  992 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId)))
  993 + }
  994 +
  995 + // 更新合约基础信息
  996 + if err9 := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err9 != nil {
  997 + return nil, application.ThrowError(application.BUSINESS_ERROR, err9.Error())
  998 + }
  999 +
988 // 更新发起人 1000 // 更新发起人
989 cooperationContract.CooperationContractSponsor = sponsor 1001 cooperationContract.CooperationContractSponsor = sponsor
990 1002
@@ -1195,10 +1207,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1195,10 +1207,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1195 var undertakerChange string 1207 var undertakerChange string
1196 1208
1197 // 规则变更,原【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点),(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】-->更新后【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】 1209 // 规则变更,原【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点),(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】-->更新后【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】
1198 - if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType { // 1.激励规则类型变更  
1199 - if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 业绩分红变更为金额激励 1210 + if cooperationContractFound.IncentivesType != cooperationContract.IncentivesType { // 1.激励规则类型变更
  1211 + if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES && cooperationContract.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 业绩分红变更为金额激励
1200 // 业绩分红-->金额激励 1212 // 业绩分红-->金额激励
1201 - incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType)) 1213 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContract.IncentivesType))
1202 //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】 1214 //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
1203 // 原业绩分红激励规则 1215 // 原业绩分红激励规则
1204 var dividendsIncentivesRuleOriginal string 1216 var dividendsIncentivesRuleOriginal string
@@ -1214,10 +1226,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1214,10 +1226,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1214 1226
1215 // 变更后的金额激励规则 1227 // 变更后的金额激励规则
1216 var moneyIncentivesRuleChanged string 1228 var moneyIncentivesRuleChanged string
1217 - for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules { 1229 + for _, moneyIncentivesRule := range cooperationContract.MoneyIncentivesRules {
1218 moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN + 1230 moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
1219 ":" + 1231 ":" +
1220 - "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") + 1232 + "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") +
1221 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) + 1233 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
1222 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";" 1234 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
1223 } 1235 }
@@ -1225,16 +1237,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1225,16 +1237,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1225 1237
1226 // 拼接规则变更 1238 // 拼接规则变更
1227 incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + moneyIncentivesRuleOriginalTmp 1239 incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + moneyIncentivesRuleOriginalTmp
1228 - } else if cooperationContractFound.IncentivesType == domain.TYPE_MONEY_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 金额激励变更为业绩分红 1240 + } else if cooperationContractFound.IncentivesType == domain.TYPE_MONEY_INCENTIVES && cooperationContract.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 金额激励变更为业绩分红
1229 // 金额激励-->业绩分红 1241 // 金额激励-->业绩分红
1230 - incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType)) 1242 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContract.IncentivesType))
1231 //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】 1243 //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
1232 // 原金额激励规则 1244 // 原金额激励规则
1233 var moneyIncentivesRuleOriginal string 1245 var moneyIncentivesRuleOriginal string
1234 for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules { 1246 for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
1235 moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN + 1247 moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN +
1236 ":" + 1248 ":" +
1237 - "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") + 1249 + "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") +
1238 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) + 1250 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
1239 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";" 1251 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
1240 } 1252 }
@@ -1242,7 +1254,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1242,7 +1254,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1242 1254
1243 // 变更后的业绩分红激励规则 1255 // 变更后的业绩分红激励规则
1244 var dividendsIncentivesRuleChanged string 1256 var dividendsIncentivesRuleChanged string
1245 - for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules { 1257 + for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
1246 dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN + 1258 dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN +
1247 ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) + 1259 ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
1248 "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") + 1260 "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
@@ -1255,11 +1267,22 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1255,11 +1267,22 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1255 // 拼接规则变更 1267 // 拼接规则变更
1256 incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleOriginalTmp 1268 incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleOriginalTmp
1257 } 1269 }
1258 - } else if cooperationContractFound.IncentivesType == cooperationContractSaved.IncentivesType { // 2.激励规则内容变更 1270 + } else if cooperationContractFound.IncentivesType == cooperationContract.IncentivesType { // 2.激励规则内容变更
1259 if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 业绩分红规则内容变更 1271 if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 业绩分红规则内容变更
1260 - if !cooperationContract.DividendsIncentivesRuleSliceEqualBCE(cooperationContractFound.DividendsIncentivesRules, cooperationContractSaved.DividendsIncentivesRules) { 1272 + // 计算原合约哈希值
  1273 + cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.DividendsIncentivesRules))
  1274 + cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundByte)
  1275 + cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:])
  1276 +
  1277 + // 计算更新后的合约哈希值
  1278 + cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.DividendsIncentivesRules))
  1279 + cooperationContractHashValue := md5.Sum(cooperationContractByte)
  1280 + cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:])
  1281 +
  1282 + if cooperationContractFoundHashString != cooperationContractHashString {
1261 // 业绩分红-->业绩分红 1283 // 业绩分红-->业绩分红
1262 - incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType)) 1284 +
  1285 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContract.IncentivesType))
1263 //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】 1286 //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
1264 // 原业绩分红激励规则 1287 // 原业绩分红激励规则
1265 var dividendsIncentivesRuleOriginal string 1288 var dividendsIncentivesRuleOriginal string
@@ -1274,7 +1297,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1274,7 +1297,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1274 dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleOriginal + "】" 1297 dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleOriginal + "】"
1275 // 变更后的业绩分红激励规则 1298 // 变更后的业绩分红激励规则
1276 var dividendsIncentivesRuleChanged string 1299 var dividendsIncentivesRuleChanged string
1277 - for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules { 1300 + for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
1278 dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN + 1301 dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN +
1279 ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) + 1302 ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
1280 "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") + 1303 "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
@@ -1286,26 +1309,36 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1286,26 +1309,36 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1286 // 拼接规则变更 1309 // 拼接规则变更
1287 incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleChangedTmp 1310 incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleChangedTmp
1288 } 1311 }
1289 - } else if cooperationContractFound.IncentivesType == domain.MONEY_INCENTIVES { // 金额激励规则内容变更  
1290 - if !cooperationContract.MoneyIncentivesRuleSliceEqualBCE(cooperationContractFound.MoneyIncentivesRules, cooperationContractSaved.MoneyIncentivesRules) {  
1291 - incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType)) 1312 + } else if cooperationContractFound.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 金额激励规则内容变更
  1313 + // 计算原合约哈希值
  1314 + cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.MoneyIncentivesRules))
  1315 + cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundByte)
  1316 + cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:])
  1317 +
  1318 + // 计算更新后的合约哈希值
  1319 + cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.MoneyIncentivesRules))
  1320 + cooperationContractHashValue := md5.Sum(cooperationContractByte)
  1321 + cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:])
  1322 +
  1323 + if cooperationContractFoundHashString != cooperationContractHashString {
  1324 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContract.IncentivesType))
1292 //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】 1325 //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
1293 // 原金额激励规则 1326 // 原金额激励规则
1294 var moneyIncentivesRuleOriginal string 1327 var moneyIncentivesRuleOriginal string
1295 for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules { 1328 for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
1296 moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN + 1329 moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN +
1297 ":" + 1330 ":" +
1298 - "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") + 1331 + "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") +
1299 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) + 1332 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
1300 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";" 1333 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
1301 } 1334 }
1302 moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】" 1335 moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
1303 // 变更后的激励规则 1336 // 变更后的激励规则
1304 var moneyIncentivesRuleChanged string 1337 var moneyIncentivesRuleChanged string
1305 - for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules { 1338 + for _, moneyIncentivesRule := range cooperationContract.MoneyIncentivesRules {
1306 moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN + 1339 moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
1307 ":" + 1340 ":" +
1308 - "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") + 1341 + "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") +
1309 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) + 1342 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
1310 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";" 1343 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
1311 } 1344 }
@@ -1316,8 +1349,18 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1316,8 +1349,18 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1316 } 1349 }
1317 } 1350 }
1318 1351
1319 - // 承接人变更  
1320 - if !cooperationContract.UndertakerSliceEqualBCE(cooperationContractFound.Undertakers, cooperationContractSaved.Undertakers) { // 【1(张三,李四,王五)2(买买买,,)】变更为【1(张三,,)】 1352 + /*********************************************** 承接人变更 *****************************************************/
  1353 + // 计算原合约哈希值
  1354 + cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.Undertakers))
  1355 + cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundByte)
  1356 + cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:])
  1357 +
  1358 + // 计算更新后的合约哈希值
  1359 + cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.Undertakers))
  1360 + cooperationContractHashValue := md5.Sum(cooperationContractByte)
  1361 + cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:])
  1362 +
  1363 + if cooperationContractFoundHashString != cooperationContractHashString { // 【1(张三,李四,王五)2(买买买,,)】变更为【1(张三,,)】
1321 // 原承接人 1364 // 原承接人
1322 var undertakersOriginal string 1365 var undertakersOriginal string
1323 for i, undertaker := range cooperationContractFound.Undertakers { 1366 for i, undertaker := range cooperationContractFound.Undertakers {
@@ -1357,7 +1400,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1357,7 +1400,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1357 1400
1358 // 变更承接人 1401 // 变更承接人
1359 var undertakersChanged string 1402 var undertakersChanged string
1360 - for i, undertaker := range cooperationContractSaved.Undertakers { 1403 + for i, undertaker := range cooperationContract.Undertakers {
1361 if undertaker.Referrer == nil { 1404 if undertaker.Referrer == nil {
1362 undertaker.Referrer = &domain.Referrer{ 1405 undertaker.Referrer = &domain.Referrer{
1363 UserId: 0, 1406 UserId: 0,
@@ -1401,7 +1444,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1401,7 +1444,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1401 IncentivesRuleDetail: incentivesRuleChangeDetail, 1444 IncentivesRuleDetail: incentivesRuleChangeDetail,
1402 OperationType: domain.EDIT, 1445 OperationType: domain.EDIT,
1403 Undertakers: undertakerChange, 1446 Undertakers: undertakerChange,
1404 - CooperationContractNumber: cooperationContractSaved.CooperationContractNumber, 1447 + CooperationContractNumber: cooperationContract.CooperationContractNumber,
1405 Company: company, 1448 Company: company,
1406 Org: organization, 1449 Org: organization,
1407 Operator: operator, 1450 Operator: operator,
@@ -635,7 +635,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro @@ -635,7 +635,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
635 } else { 635 } else {
636 if count > 0 { 636 if count > 0 {
637 for _, cooperationApplication := range cooperationApplications { 637 for _, cooperationApplication := range cooperationApplications {
638 - applicantTypes[cooperationApplication.CooperationApplicationApplicant.UserType] = cooperationApplication.CooperationApplicationApplicant.UserType 638 + applicantTypes[cooperationApplication.CooperationApplicationApplicant.UserType] = 1
639 } 639 }
640 } 640 }
641 } 641 }
@@ -652,7 +652,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro @@ -652,7 +652,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
652 } 652 }
653 } 653 }
654 if k1 != 0 && k2 != 0 { 654 if k1 != 0 && k2 != 0 {
655 - undertakerTypes = append(undertakerTypes, 4) 655 + undertakerTypes = append(undertakerTypes, 3)
656 } 656 }
657 // 校验可以修改的承接人(申请人)类型 657 // 校验可以修改的承接人(申请人)类型
658 for _, t := range undertakerTypes { 658 for _, t := range undertakerTypes {
@@ -3,6 +3,7 @@ package dao @@ -3,6 +3,7 @@ package dao
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "github.com/go-pg/pg/v10" 5 "github.com/go-pg/pg/v10"
  6 + "github.com/go-pg/pg/v10/orm"
6 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" 7 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 8 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
@@ -69,7 +70,11 @@ func (dao *CooperationContractDao) CheckUndertakerTypesUncheckedAvailable(queryO @@ -69,7 +70,11 @@ func (dao *CooperationContractDao) CheckUndertakerTypesUncheckedAvailable(queryO
69 query = query.Where(`cooperation_contract.org @> '{"orgId":"?"}'`, orgId) 70 query = query.Where(`cooperation_contract.org @> '{"orgId":"?"}'`, orgId)
70 } 71 }
71 if user, ok := queryOptions["user"]; ok && user.(bool) != false { 72 if user, ok := queryOptions["user"]; ok && user.(bool) != false {
72 - query = query.Where("user_type = ?", 1) 73 + query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
  74 + q.WhereOr("user_type = ?", 1)
  75 + q.WhereOr("user_type = ?", 1025)
  76 + return q, nil
  77 + })
73 } 78 }
74 if partner, ok := queryOptions["partner"]; ok && partner.(bool) != false { 79 if partner, ok := queryOptions["partner"]; ok && partner.(bool) != false {
75 query = query.Where("user_type = ?", 2) 80 query = query.Where("user_type = ?", 2)
@@ -2,6 +2,7 @@ package dao @@ -2,6 +2,7 @@ package dao
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "github.com/go-pg/pg/v10/orm"
5 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
@@ -73,7 +74,11 @@ func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOp @@ -73,7 +74,11 @@ func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOp
73 queryUndertaker := tx.Model(&cooperationContractUndertakerModels) 74 queryUndertaker := tx.Model(&cooperationContractUndertakerModels)
74 queryUndertaker.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber) 75 queryUndertaker.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber)
75 if user, ok := queryOptions["user"]; ok && user.(bool) != false { 76 if user, ok := queryOptions["user"]; ok && user.(bool) != false {
76 - query = query.Where("user_type = ?", 1) 77 + query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
  78 + q.WhereOr("user_type = ?", 1)
  79 + q.WhereOr("user_type = ?", 1025)
  80 + return q, nil
  81 + })
77 } 82 }
78 if partner, ok := queryOptions["partner"]; ok && partner.(bool) != false { 83 if partner, ok := queryOptions["partner"]; ok && partner.(bool) != false {
79 query = query.Where("user_type = ?", 2) 84 query = query.Where("user_type = ?", 2)
1 package utils 1 package utils
2 2
3 import ( 3 import (
  4 + "bytes"
  5 + "encoding/binary"
4 "fmt" 6 "fmt"
5 "github.com/shopspring/decimal" 7 "github.com/shopspring/decimal"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
6 "strconv" 9 "strconv"
7 "strings" 10 "strings"
8 ) 11 )
@@ -160,3 +163,13 @@ func IsContain64(items []int64, item int64) bool { @@ -160,3 +163,13 @@ func IsContain64(items []int64, item int64) bool {
160 } 163 }
161 return false 164 return false
162 } 165 }
  166 +
  167 +func AnyToHex(any interface{}) []byte {
  168 + buff := new(bytes.Buffer)
  169 + //数据写入buff
  170 + err := binary.Write(buff, binary.BigEndian, any)
  171 + if err != nil {
  172 + log.Logger.Error(err.Error())
  173 + }
  174 + return buff.Bytes()
  175 +}