作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !51
@@ -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 共创合约服务
@@ -982,10 +981,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -982,10 +981,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
982 } 981 }
983 982
984 // 获取待更新的共创合约 983 // 获取待更新的共创合约
985 - cooperationContract, err8 := cooperationContractRepository.FindOne(map[string]interface{}{ 984 + cooperationContract, err9 := cooperationContractRepository.FindOne(map[string]interface{}{
986 "cooperationContractId": updateCooperationContractCommand.CooperationContractId, 985 "cooperationContractId": updateCooperationContractCommand.CooperationContractId,
987 }) 986 })
988 - if err8 != nil { 987 + if err9 != nil {
989 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在") 988 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
990 } 989 }
991 if cooperationContract == nil { 990 if cooperationContract == nil {
@@ -993,8 +992,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -993,8 +992,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
993 } 992 }
994 993
995 // 更新合约基础信息 994 // 更新合约基础信息
996 - if err9 := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err9 != nil {  
997 - return nil, application.ThrowError(application.BUSINESS_ERROR, err9.Error()) 995 + if err10 := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err10 != nil {
  996 + return nil, application.ThrowError(application.BUSINESS_ERROR, err10.Error())
998 } 997 }
999 998
1000 // 更新发起人 999 // 更新发起人
@@ -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 {
@@ -1327,7 +1357,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1327,7 +1357,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1327 var moneyIncentivesRuleOriginal string 1357 var moneyIncentivesRuleOriginal string
1328 for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules { 1358 for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
1329 moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN + 1359 moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN +
1330 - ":" + 1360 + ":" + fmt.Sprint(moneyIncentivesRule.MoneyIncentivesAmount) +
1331 "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") + 1361 "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") +
1332 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) + 1362 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
1333 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";" 1363 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
@@ -1337,7 +1367,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1337,7 +1367,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1337 var moneyIncentivesRuleChanged string 1367 var moneyIncentivesRuleChanged string
1338 for _, moneyIncentivesRule := range cooperationContract.MoneyIncentivesRules { 1368 for _, moneyIncentivesRule := range cooperationContract.MoneyIncentivesRules {
1339 moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN + 1369 moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
1340 - ":" + 1370 + ":" + fmt.Sprint(moneyIncentivesRule.MoneyIncentivesAmount) +
1341 "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") + 1371 "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") +
1342 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) + 1372 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
1343 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";" 1373 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
@@ -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,
@@ -406,7 +406,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -406,7 +406,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
406 v := reflect.ValueOf(dividendsOrder) 406 v := reflect.ValueOf(dividendsOrder)
407 for k := 0; k < t.NumField(); k++ { 407 for k := 0; k < t.NumField(); k++ {
408 //fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()), ", yaml:", t.Field(k).Tag.Get("yaml")) 408 //fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()), ", yaml:", t.Field(k).Tag.Get("yaml"))
409 - if k != 7 && k != 8 { 409 + fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()))
  410 + if t.Field(k).Name != "RegionName" && t.Field(k).Name != "Expense" {
410 if v.Field(k).Interface() == "" { 411 if v.Field(k).Interface() == "" {
411 col := strconv.Itoa(k + 1) 412 col := strconv.Itoa(k + 1)
412 nullCell = append(nullCell, col) 413 nullCell = append(nullCell, col)
@@ -557,7 +558,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -557,7 +558,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
557 var dividendsOrderCommands = make(map[string]*command.CreateDividendsOrderCommand) 558 var dividendsOrderCommands = make(map[string]*command.CreateDividendsOrderCommand)
558 559
559 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData { 560 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData {
560 - hashValue := md5.Sum([]byte(dividendsOrder.OriginalOrderNum)) 561 + hashValue := md5.Sum([]byte(dividendsOrder.OriginalOrderNum + dividendsOrder.OrderTime))
561 hashString := hex.EncodeToString(hashValue[:]) 562 hashString := hex.EncodeToString(hashValue[:])
562 if _, ok := dividendsOrderCommands[hashString]; !ok { 563 if _, ok := dividendsOrderCommands[hashString]; !ok {
563 // 订单日期时间格式转换 564 // 订单日期时间格式转换
@@ -864,7 +865,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -864,7 +865,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
864 }) 865 })
865 866
866 // 计算分红订单金额 867 // 计算分红订单金额
867 - dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense)))).Float64() 868 + dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense))).Float64()
868 } 869 }
869 870
870 if len(orderGoodErrMap) > 0 { 871 if len(orderGoodErrMap) > 0 {
@@ -445,7 +445,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -445,7 +445,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
445 t := reflect.TypeOf(dividendsReturnedOrder) 445 t := reflect.TypeOf(dividendsReturnedOrder)
446 v := reflect.ValueOf(dividendsReturnedOrder) 446 v := reflect.ValueOf(dividendsReturnedOrder)
447 for k := 0; k < t.NumField(); k++ { 447 for k := 0; k < t.NumField(); k++ {
448 - if k != 5 && k != 8 { 448 + fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()))
  449 + if t.Field(k).Name != "RegionName" && t.Field(k).Name != "CooperationContractNumber" {
449 if v.Field(k).Interface() == "" { 450 if v.Field(k).Interface() == "" {
450 col := strconv.Itoa(k + 1) 451 col := strconv.Itoa(k + 1)
451 nullCell = append(nullCell, col) 452 nullCell = append(nullCell, col)
@@ -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 // 数据所属组织机构
@@ -25,8 +25,8 @@ func TransformToCooperationContractDomainModelFromPgModels( @@ -25,8 +25,8 @@ func TransformToCooperationContractDomainModelFromPgModels(
25 DividendsIncentivesPercentage: rule.DividendsIncentivesPercentage, 25 DividendsIncentivesPercentage: rule.DividendsIncentivesPercentage,
26 DividendsIncentivesStage: rule.DividendsIncentivesStage, 26 DividendsIncentivesStage: rule.DividendsIncentivesStage,
27 DividendsIncentivesStageCN: stageString, 27 DividendsIncentivesStageCN: stageString,
28 - DividendsIncentivesStageEnd: rule.DividendsIncentivesStageEnd,  
29 - DividendsIncentivesStageStart: rule.DividendsIncentivesStageStart, 28 + DividendsIncentivesStageEnd: rule.DividendsIncentivesStageEnd.Local(),
  29 + DividendsIncentivesStageStart: rule.DividendsIncentivesStageStart.Local(),
30 Org: rule.Org, 30 Org: rule.Org,
31 Company: rule.Company, 31 Company: rule.Company,
32 UpdatedAt: rule.UpdatedAt, 32 UpdatedAt: rule.UpdatedAt,
@@ -47,7 +47,7 @@ func TransformToCooperationContractDomainModelFromPgModels( @@ -47,7 +47,7 @@ func TransformToCooperationContractDomainModelFromPgModels(
47 MoneyIncentivesStageCN: stageString, 47 MoneyIncentivesStageCN: stageString,
48 MoneyIncentivesStageEnd: rule.MoneyIncentivesStageEnd, 48 MoneyIncentivesStageEnd: rule.MoneyIncentivesStageEnd,
49 MoneyIncentivesStageStart: rule.MoneyIncentivesStageStart, 49 MoneyIncentivesStageStart: rule.MoneyIncentivesStageStart,
50 - MoneyIncentivesTime: rule.MoneyIncentivesTime, 50 + MoneyIncentivesTime: rule.MoneyIncentivesTime.Local(),
51 ReferrerPercentage: rule.ReferrerPercentage, 51 ReferrerPercentage: rule.ReferrerPercentage,
52 SalesmanPercentage: rule.SalesmanPercentage, 52 SalesmanPercentage: rule.SalesmanPercentage,
53 Org: rule.Org, 53 Org: rule.Org,
@@ -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,
@@ -1111,7 +1111,7 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string @@ -1111,7 +1111,7 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string
1111 if err := cooperationContractUndertakerQuery. 1111 if err := cooperationContractUndertakerQuery.
1112 Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId). 1112 Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
1113 Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). 1113 Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
1114 - Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). 1114 + Where("cooperation_contract_id = ?", cooperationContractModel.CooperationContractId).
1115 Select(); err != nil { 1115 Select(); err != nil {
1116 return nil, fmt.Errorf("合约承接人不存在") 1116 return nil, fmt.Errorf("合约承接人不存在")
1117 } 1117 }
@@ -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 // 添加分红退货订单产品