作者 陈志颖

refactor:优化合约变更记录

@@ -28,7 +28,7 @@ type UpdateCooperationContractCommand struct { @@ -28,7 +28,7 @@ type UpdateCooperationContractCommand struct {
28 // 金额激励规则列表 28 // 金额激励规则列表
29 MoneyIncentivesRules []*CreateMoneyIncentivesRulesCommand `cname:"金额激励规则列表" json:"moneyIncentivesRules,omitempty"` 29 MoneyIncentivesRules []*CreateMoneyIncentivesRulesCommand `cname:"金额激励规则列表" json:"moneyIncentivesRules,omitempty"`
30 // 承接方列表 30 // 承接方列表
31 - Undertakers []*CreateUndertakersCommand `cname:"承接方列表" json:"undertakers,omitempty"` 31 + Undertakers []*CreateUndertakersCommand `cname:"承接方列表" json:"undertakers" valid:"Required"`
32 // 相关人UID列表 32 // 相关人UID列表
33 RelevantIds []string `cname:"相关人列表" json:"relevantIds,omitempty"` 33 RelevantIds []string `cname:"相关人列表" json:"relevantIds,omitempty"`
34 // 公司ID,通过集成REST上下文获取 34 // 公司ID,通过集成REST上下文获取
@@ -3,11 +3,8 @@ package service @@ -3,11 +3,8 @@ package service
3 import ( 3 import (
4 "crypto/md5" 4 "crypto/md5"
5 "encoding/hex" 5 "encoding/hex"
  6 + "encoding/json"
6 "fmt" 7 "fmt"
7 - "strconv"  
8 - "time"  
9 - "unsafe"  
10 -  
11 "github.com/linmadan/egglib-go/core/application" 8 "github.com/linmadan/egglib-go/core/application"
12 "github.com/linmadan/egglib-go/utils/tool_funs" 9 "github.com/linmadan/egglib-go/utils/tool_funs"
13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command"
@@ -19,6 +16,8 @@ import ( @@ -19,6 +16,8 @@ import (
19 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" 16 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
20 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" 17 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
21 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" 18 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
  19 + "strconv"
  20 + "time"
22 ) 21 )
23 22
24 // CooperationContractService 共创合约服务 23 // CooperationContractService 共创合约服务
@@ -1270,18 +1269,33 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1270,18 +1269,33 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1270 } else if cooperationContractFound.IncentivesType == cooperationContract.IncentivesType { // 2.激励规则内容变更 1269 } else if cooperationContractFound.IncentivesType == cooperationContract.IncentivesType { // 2.激励规则内容变更
1271 if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 业绩分红规则内容变更 1270 if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 业绩分红规则内容变更
1272 // 计算原合约哈希值 1271 // 计算原合约哈希值
1273 - cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.DividendsIncentivesRules))  
1274 - cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundByte) 1272 + // cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.DividendsIncentivesRules))
  1273 + var cooperationContractFoundBytes []byte
  1274 + for _, rule := range cooperationContractFound.DividendsIncentivesRules {
  1275 + jsons, errs := json.Marshal(rule)
  1276 + if errs != nil {
  1277 + fmt.Println(errs.Error())
  1278 + }
  1279 + cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...)
  1280 + }
  1281 + cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundBytes)
1275 cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:]) 1282 cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:])
1276 1283
1277 // 计算更新后的合约哈希值 1284 // 计算更新后的合约哈希值
1278 - cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.DividendsIncentivesRules))  
1279 - cooperationContractHashValue := md5.Sum(cooperationContractByte) 1285 + // cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.DividendsIncentivesRules))
  1286 + var cooperationContractBytes []byte
  1287 + for _, rule := range cooperationContract.DividendsIncentivesRules {
  1288 + jsons, errs := json.Marshal(rule)
  1289 + if errs != nil {
  1290 + fmt.Println(errs.Error())
  1291 + }
  1292 + cooperationContractBytes = append(cooperationContractBytes, jsons...)
  1293 + }
  1294 + cooperationContractHashValue := md5.Sum(cooperationContractBytes)
1280 cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:]) 1295 cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:])
1281 1296
1282 if cooperationContractFoundHashString != cooperationContractHashString { 1297 if cooperationContractFoundHashString != cooperationContractHashString {
1283 // 业绩分红-->业绩分红 1298 // 业绩分红-->业绩分红
1284 -  
1285 incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContract.IncentivesType)) 1299 incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContract.IncentivesType))
1286 //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】 1300 //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
1287 // 原业绩分红激励规则 1301 // 原业绩分红激励规则
@@ -1311,13 +1325,29 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1311,13 +1325,29 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1311 } 1325 }
1312 } else if cooperationContractFound.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 金额激励规则内容变更 1326 } else if cooperationContractFound.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 金额激励规则内容变更
1313 // 计算原合约哈希值 1327 // 计算原合约哈希值
1314 - cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.MoneyIncentivesRules))  
1315 - cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundByte) 1328 + //cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.MoneyIncentivesRules))
  1329 + var cooperationContractFoundBytes []byte
  1330 + for _, rule := range cooperationContractFound.MoneyIncentivesRules {
  1331 + jsons, errs := json.Marshal(rule)
  1332 + if errs != nil {
  1333 + fmt.Println(errs.Error())
  1334 + }
  1335 + cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...)
  1336 + }
  1337 + cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundBytes)
1316 cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:]) 1338 cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:])
1317 1339
1318 // 计算更新后的合约哈希值 1340 // 计算更新后的合约哈希值
1319 - cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.MoneyIncentivesRules))  
1320 - cooperationContractHashValue := md5.Sum(cooperationContractByte) 1341 + //cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.MoneyIncentivesRules))
  1342 + var cooperationContractBytes []byte
  1343 + for _, rule := range cooperationContract.MoneyIncentivesRules {
  1344 + jsons, errs := json.Marshal(rule)
  1345 + if errs != nil {
  1346 + fmt.Println(errs.Error())
  1347 + }
  1348 + cooperationContractBytes = append(cooperationContractBytes, jsons...)
  1349 + }
  1350 + cooperationContractHashValue := md5.Sum(cooperationContractBytes)
1321 cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:]) 1351 cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:])
1322 1352
1323 if cooperationContractFoundHashString != cooperationContractHashString { 1353 if cooperationContractFoundHashString != cooperationContractHashString {
@@ -1351,13 +1381,28 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1351,13 +1381,28 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1351 1381
1352 /*********************************************** 承接人变更 *****************************************************/ 1382 /*********************************************** 承接人变更 *****************************************************/
1353 // 计算原合约哈希值 1383 // 计算原合约哈希值
1354 - cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.Undertakers))  
1355 - cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundByte) 1384 + //cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.Undertakers))
  1385 + var cooperationContractFoundBytes []byte
  1386 + for _, undertaker := range cooperationContractFound.Undertakers {
  1387 + jsons, errs := json.Marshal(undertaker)
  1388 + if errs != nil {
  1389 + fmt.Println(errs.Error())
  1390 + }
  1391 + cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...)
  1392 + }
  1393 + cooperationContractFoundHashValue := md5.Sum(cooperationContractFoundBytes)
1356 cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:]) 1394 cooperationContractFoundHashString := hex.EncodeToString(cooperationContractFoundHashValue[:])
1357 1395
1358 // 计算更新后的合约哈希值 1396 // 计算更新后的合约哈希值
1359 - cooperationContractByte := *(*[]byte)(unsafe.Pointer(&cooperationContract.Undertakers))  
1360 - cooperationContractHashValue := md5.Sum(cooperationContractByte) 1397 + var cooperationContractBytes []byte
  1398 + for _, undertaker := range cooperationContract.Undertakers {
  1399 + jsons, errs := json.Marshal(undertaker) //转换成JSON返回的是byte[]
  1400 + if errs != nil {
  1401 + fmt.Println(errs.Error())
  1402 + }
  1403 + cooperationContractBytes = append(cooperationContractBytes, jsons...)
  1404 + }
  1405 + cooperationContractHashValue := md5.Sum(cooperationContractBytes)
1361 cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:]) 1406 cooperationContractHashString := hex.EncodeToString(cooperationContractHashValue[:])
1362 1407
1363 if cooperationContractFoundHashString != cooperationContractHashString { // 【1(张三,李四,王五)2(买买买,,)】变更为【1(张三,,)】 1408 if cooperationContractFoundHashString != cooperationContractHashString { // 【1(张三,李四,王五)2(买买买,,)】变更为【1(张三,,)】
@@ -710,6 +710,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -710,6 +710,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
710 OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber, 710 OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber,
711 CooperationContractNumber: orderGood.CooperationContractNumber, 711 CooperationContractNumber: orderGood.CooperationContractNumber,
712 DividendsUser: dividendsEstimateDetail.DividendsUser, 712 DividendsUser: dividendsEstimateDetail.DividendsUser,
  713 + DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
713 DividendsStage: dividendsEstimateDetail.DividendsStage, 714 DividendsStage: dividendsEstimateDetail.DividendsStage,
714 Org: organization, 715 Org: organization,
715 Company: company, 716 Company: company,
@@ -765,6 +766,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -765,6 +766,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
765 OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber, 766 OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber,
766 CooperationContractNumber: orderGood.CooperationContractNumber, 767 CooperationContractNumber: orderGood.CooperationContractNumber,
767 DividendsUser: dividendsReturnedEstimateDetail.DividendsUser, 768 DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,
  769 + DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,
768 DividendsStage: dividendsReturnedEstimateDetail.DividendsStage, 770 DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
769 Org: organization, 771 Org: organization,
770 Company: company, 772 Company: company,
@@ -1108,6 +1110,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives @@ -1108,6 +1110,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
1108 OrderOrReturnedOrderNum: "", 1110 OrderOrReturnedOrderNum: "",
1109 CooperationContractNumber: cooperationContract.CooperationContractNumber, 1111 CooperationContractNumber: cooperationContract.CooperationContractNumber,
1110 DividendsUser: dividendsEstimateDetail.DividendsUser, 1112 DividendsUser: dividendsEstimateDetail.DividendsUser,
  1113 + DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
1111 DividendsStage: dividendsEstimateDetail.DividendsStage, 1114 DividendsStage: dividendsEstimateDetail.DividendsStage,
1112 Org: organization, 1115 Org: organization,
1113 Company: company, 1116 Company: company,
@@ -557,7 +557,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -557,7 +557,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
557 var dividendsOrderCommands = make(map[string]*command.CreateDividendsOrderCommand) 557 var dividendsOrderCommands = make(map[string]*command.CreateDividendsOrderCommand)
558 558
559 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData { 559 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData {
560 - hashValue := md5.Sum([]byte(dividendsOrder.OriginalOrderNum)) 560 + hashValue := md5.Sum([]byte(dividendsOrder.OriginalOrderNum + dividendsOrder.OrderTime))
561 hashString := hex.EncodeToString(hashValue[:]) 561 hashString := hex.EncodeToString(hashValue[:])
562 if _, ok := dividendsOrderCommands[hashString]; !ok { 562 if _, ok := dividendsOrderCommands[hashString]; !ok {
563 // 订单日期时间格式转换 563 // 订单日期时间格式转换
@@ -47,6 +47,8 @@ type DividendsEstimate struct { @@ -47,6 +47,8 @@ type DividendsEstimate struct {
47 CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId"` 47 CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId"`
48 // 分红用户(共创参与) 48 // 分红用户(共创参与)
49 DividendsUser *User `json:"dividendsUser"` 49 DividendsUser *User `json:"dividendsUser"`
  50 + // 分红比例
  51 + DividendsPercentage float64 `json:"dividendsPercentage"`
50 // 分红阶段 52 // 分红阶段
51 DividendsStage int32 `json:"dividendsStage"` 53 DividendsStage int32 `json:"dividendsStage"`
52 // 数据所属组织机构 54 // 数据所属组织机构
@@ -31,11 +31,11 @@ type DividendsIncentivesRule struct { @@ -31,11 +31,11 @@ type DividendsIncentivesRule struct {
31 // 公司 31 // 公司
32 Company *Company `json:"company"` 32 Company *Company `json:"company"`
33 // 更新时间 33 // 更新时间
34 - UpdatedAt time.Time `json:"updatedAt"` 34 + UpdatedAt time.Time `json:"-"`
35 // 删除时间 35 // 删除时间
36 - DeletedAt time.Time `json:"deletedAt"` 36 + DeletedAt time.Time `json:"-"`
37 // 创建时间 37 // 创建时间
38 - CreatedAt time.Time `json:"createdAt"` 38 + CreatedAt time.Time `json:"-"`
39 } 39 }
40 40
41 type DividendsIncentivesRuleRepository interface { 41 type DividendsIncentivesRuleRepository interface {
@@ -33,11 +33,11 @@ type MoneyIncentivesRule struct { @@ -33,11 +33,11 @@ type MoneyIncentivesRule struct {
33 // 公司 33 // 公司
34 Company *Company `json:"company"` 34 Company *Company `json:"company"`
35 // 更新时间 35 // 更新时间
36 - UpdatedAt time.Time `json:"updatedAt"` 36 + UpdatedAt time.Time `json:"-"`
37 // 删除时间 37 // 删除时间
38 - DeletedAt time.Time `json:"deletedAt"` 38 + DeletedAt time.Time `json:"-"`
39 // 创建时间 39 // 创建时间
40 - CreatedAt time.Time `json:"createdAt"` 40 + CreatedAt time.Time `json:"-"`
41 } 41 }
42 42
43 type MoneyIncentivesRuleRepository interface { 43 type MoneyIncentivesRuleRepository interface {
@@ -9,6 +9,7 @@ import ( @@ -9,6 +9,7 @@ import (
9 9
10 type DividendsEstimateDetail struct { 10 type DividendsEstimateDetail struct {
11 DividendsUser *domain.User `json:"dividendsUser"` // 共创参与(分红用户) 11 DividendsUser *domain.User `json:"dividendsUser"` // 共创参与(分红用户)
  12 + DividendsPercentage float64 `json:"dividendsPercentage"` // 分红比例
12 DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型 1承接人,2推荐人,3关联业务员 13 DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型 1承接人,2推荐人,3关联业务员
13 DividendsStage int32 `json:"dividendsStage"` // 分红阶段 14 DividendsStage int32 `json:"dividendsStage"` // 分红阶段
14 DividendsAmount float64 `json:"dividendsAmount"` // 分红金额 15 DividendsAmount float64 `json:"dividendsAmount"` // 分红金额
@@ -249,9 +249,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -249,9 +249,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
249 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, 249 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
250 IsSuccessfully: true, 250 IsSuccessfully: true,
251 CooperationContractUndertakerId: undertaker.UndertakerId, 251 CooperationContractUndertakerId: undertaker.UndertakerId,
  252 + DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
252 }) 253 })
253 } 254 }
254 -  
255 // 添加推荐人分红预算信息详情 255 // 添加推荐人分红预算信息详情
256 if undertaker.Referrer != nil { 256 if undertaker.Referrer != nil {
257 if dividendsIncentivesRuleMatched.ReferrerPercentage > 0 { 257 if dividendsIncentivesRuleMatched.ReferrerPercentage > 0 {
@@ -276,6 +276,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -276,6 +276,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
276 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, 276 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
277 IsSuccessfully: true, 277 IsSuccessfully: true,
278 CooperationContractUndertakerId: undertaker.UndertakerId, 278 CooperationContractUndertakerId: undertaker.UndertakerId,
  279 + DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
279 }) 280 })
280 } 281 }
281 } 282 }
@@ -303,6 +304,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -303,6 +304,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
303 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, 304 OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
304 IsSuccessfully: true, 305 IsSuccessfully: true,
305 CooperationContractUndertakerId: undertaker.UndertakerId, 306 CooperationContractUndertakerId: undertaker.UndertakerId,
  307 + DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
306 }) 308 })
307 } 309 }
308 } 310 }
@@ -373,6 +375,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -373,6 +375,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
373 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, 375 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
374 IsSuccessfully: true, 376 IsSuccessfully: true,
375 CooperationContractUndertakerId: undertaker.UndertakerId, 377 CooperationContractUndertakerId: undertaker.UndertakerId,
  378 + DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
376 }) 379 })
377 } 380 }
378 381
@@ -400,6 +403,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -400,6 +403,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
400 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, 403 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
401 IsSuccessfully: true, 404 IsSuccessfully: true,
402 CooperationContractUndertakerId: undertaker.UndertakerId, 405 CooperationContractUndertakerId: undertaker.UndertakerId,
  406 + DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
403 }) 407 })
404 } 408 }
405 } 409 }
@@ -428,9 +432,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -428,9 +432,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
428 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, 432 OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
429 IsSuccessfully: true, 433 IsSuccessfully: true,
430 CooperationContractUndertakerId: undertaker.UndertakerId, 434 CooperationContractUndertakerId: undertaker.UndertakerId,
  435 + DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
431 }) 436 })
432 } 437 }
433 -  
434 } 438 }
435 } 439 }
436 } 440 }
@@ -126,9 +126,9 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -126,9 +126,9 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
126 DividendsStage: stage, 126 DividendsStage: stage,
127 DividendsAmount: undertakerDividendsAmount, 127 DividendsAmount: undertakerDividendsAmount,
128 CooperationContractUndertakerId: undertaker.UndertakerId, 128 CooperationContractUndertakerId: undertaker.UndertakerId,
  129 + DividendsPercentage: moneyIncentivesRuleMatched.SalesmanPercentage,
129 }) 130 })
130 } 131 }
131 -  
132 } 132 }
133 133
134 // 判断推荐人在当前阶段是否已经分红 134 // 判断推荐人在当前阶段是否已经分红
@@ -167,6 +167,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -167,6 +167,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
167 DividendsStage: stage, 167 DividendsStage: stage,
168 DividendsAmount: undertakerDividendsAmount, 168 DividendsAmount: undertakerDividendsAmount,
169 CooperationContractUndertakerId: undertaker.UndertakerId, 169 CooperationContractUndertakerId: undertaker.UndertakerId,
  170 + DividendsPercentage: moneyIncentivesRuleMatched.ReferrerPercentage,
170 }) 171 })
171 } 172 }
172 } 173 }
@@ -33,6 +33,8 @@ type DividendsEstimate struct { @@ -33,6 +33,8 @@ type DividendsEstimate struct {
33 CooperationContractUndertakerId int64 `comment:"共创合约承接人ID"` 33 CooperationContractUndertakerId int64 `comment:"共创合约承接人ID"`
34 // 分红用户 34 // 分红用户
35 DividendsUser *domain.User `comment:"分红用户"` 35 DividendsUser *domain.User `comment:"分红用户"`
  36 + // 分红比例
  37 + DividendsPercentage float64 `comment:"分红比例"`
36 // 分红阶段 38 // 分红阶段
37 DividendsStage int32 `comment:"分红阶段"` 39 DividendsStage int32 `comment:"分红阶段"`
38 // 数据所属组织机构 40 // 数据所属组织机构
@@ -22,6 +22,7 @@ func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel @@ -22,6 +22,7 @@ func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel
22 CooperationContractNumber: dividendsEstimateModel.CooperationContractNumber, 22 CooperationContractNumber: dividendsEstimateModel.CooperationContractNumber,
23 CooperationContractUndertakerId: dividendsEstimateModel.CooperationContractUndertakerId, 23 CooperationContractUndertakerId: dividendsEstimateModel.CooperationContractUndertakerId,
24 DividendsUser: dividendsEstimateModel.DividendsUser, 24 DividendsUser: dividendsEstimateModel.DividendsUser,
  25 + DividendsPercentage: dividendsEstimateModel.DividendsPercentage,
25 DividendsStage: dividendsEstimateModel.DividendsStage, 26 DividendsStage: dividendsEstimateModel.DividendsStage,
26 Org: dividendsEstimateModel.Org, 27 Org: dividendsEstimateModel.Org,
27 Company: dividendsEstimateModel.Company, 28 Company: dividendsEstimateModel.Company,
@@ -38,6 +38,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -38,6 +38,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
38 "order_or_returned_order_num", 38 "order_or_returned_order_num",
39 "cooperation_contract_number", 39 "cooperation_contract_number",
40 "dividends_user", 40 "dividends_user",
  41 + "dividends_percentage",
41 "dividends_stage", 42 "dividends_stage",
42 "org", 43 "org",
43 "company", 44 "company",
@@ -77,6 +78,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -77,6 +78,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
77 &dividendsEstimate.OrderOrReturnedOrderNum, 78 &dividendsEstimate.OrderOrReturnedOrderNum,
78 &dividendsEstimate.CooperationContractNumber, 79 &dividendsEstimate.CooperationContractNumber,
79 &dividendsEstimate.DividendsUser, 80 &dividendsEstimate.DividendsUser,
  81 + &dividendsEstimate.DividendsPercentage,
80 &dividendsEstimate.DividendsStage, 82 &dividendsEstimate.DividendsStage,
81 &dividendsEstimate.Org, 83 &dividendsEstimate.Org,
82 &dividendsEstimate.Company, 84 &dividendsEstimate.Company,
@@ -102,6 +104,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -102,6 +104,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
102 dividendsEstimate.OrderOrReturnedOrderNum, 104 dividendsEstimate.OrderOrReturnedOrderNum,
103 dividendsEstimate.CooperationContractNumber, 105 dividendsEstimate.CooperationContractNumber,
104 dividendsEstimate.DividendsUser, 106 dividendsEstimate.DividendsUser,
  107 + dividendsEstimate.DividendsPercentage,
105 dividendsEstimate.DividendsStage, 108 dividendsEstimate.DividendsStage,
106 dividendsEstimate.Org, 109 dividendsEstimate.Org,
107 dividendsEstimate.Company, 110 dividendsEstimate.Company,
@@ -131,6 +134,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -131,6 +134,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
131 &dividendsEstimate.OrderOrReturnedOrderNum, 134 &dividendsEstimate.OrderOrReturnedOrderNum,
132 &dividendsEstimate.CooperationContractNumber, 135 &dividendsEstimate.CooperationContractNumber,
133 &dividendsEstimate.DividendsUser, 136 &dividendsEstimate.DividendsUser,
  137 + &dividendsEstimate.DividendsPercentage,
134 &dividendsEstimate.DividendsStage, 138 &dividendsEstimate.DividendsStage,
135 &dividendsEstimate.Org, 139 &dividendsEstimate.Org,
136 &dividendsEstimate.Company, 140 &dividendsEstimate.Company,
@@ -156,6 +160,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -156,6 +160,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
156 dividendsEstimate.OrderOrReturnedOrderNum, 160 dividendsEstimate.OrderOrReturnedOrderNum,
157 dividendsEstimate.CooperationContractNumber, 161 dividendsEstimate.CooperationContractNumber,
158 dividendsEstimate.DividendsUser, 162 dividendsEstimate.DividendsUser,
  163 + dividendsEstimate.DividendsPercentage,
159 dividendsEstimate.DividendsStage, 164 dividendsEstimate.DividendsStage,
160 dividendsEstimate.Org, 165 dividendsEstimate.Org,
161 dividendsEstimate.Company, 166 dividendsEstimate.Company,
@@ -200,6 +205,7 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do @@ -200,6 +205,7 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do
200 OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum, 205 OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum,
201 CooperationContractNumber: dividendsEstimate.CooperationContractNumber, 206 CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
202 DividendsUser: dividendsEstimate.DividendsUser, 207 DividendsUser: dividendsEstimate.DividendsUser,
  208 + DividendsPercentage: dividendsEstimate.DividendsPercentage,
203 DividendsStage: dividendsEstimate.DividendsStage, 209 DividendsStage: dividendsEstimate.DividendsStage,
204 Org: dividendsEstimate.Org, 210 Org: dividendsEstimate.Org,
205 Company: dividendsEstimate.Company, 211 Company: dividendsEstimate.Company,
@@ -247,6 +253,7 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* @@ -247,6 +253,7 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*
247 OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum, 253 OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum,
248 CooperationContractNumber: dividendsEstimate.CooperationContractNumber, 254 CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
249 DividendsUser: dividendsEstimate.DividendsUser, 255 DividendsUser: dividendsEstimate.DividendsUser,
  256 + DividendsPercentage: dividendsEstimate.DividendsPercentage,
250 DividendsStage: dividendsEstimate.DividendsStage, 257 DividendsStage: dividendsEstimate.DividendsStage,
251 Org: dividendsEstimate.Org, 258 Org: dividendsEstimate.Org,
252 Company: dividendsEstimate.Company, 259 Company: dividendsEstimate.Company,
@@ -236,9 +236,9 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -236,9 +236,9 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
236 OrgId: goodDomain.OrgId, 236 OrgId: goodDomain.OrgId,
237 CompanyId: goodDomain.CompanyId, 237 CompanyId: goodDomain.CompanyId,
238 OrderGoodDividendsStatus: goodDomain.OrderGoodDividendsStatus, 238 OrderGoodDividendsStatus: goodDomain.OrderGoodDividendsStatus,
239 - CreatedAt: time.Time{}, 239 + CreatedAt: time.Now(),
240 DeletedAt: time.Time{}, 240 DeletedAt: time.Time{},
241 - UpdatedAt: time.Now(), 241 + UpdatedAt: time.Time{},
242 }) 242 })
243 } 243 }
244 // 添加分红退货订单产品 244 // 添加分红退货订单产品