作者 陈志颖

fix:调整分红退货单聚合key值

@@ -684,7 +684,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -684,7 +684,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
684 orderGoodsToConfirm := make([]*domain.OrderGood, 0) 684 orderGoodsToConfirm := make([]*domain.OrderGood, 0)
685 orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood) 685 orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
686 // 分红订单产品预算 686 // 分红订单产品预算
687 - if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm); err != nil { 687 + if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId); err != nil {
688 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 688 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
689 } else { 689 } else {
690 for _, dividendsEstimateDetail := range dividendsEstimateDetails { 690 for _, dividendsEstimateDetail := range dividendsEstimateDetails {
@@ -740,7 +740,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -740,7 +740,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
740 orderGoodsToConfirm := make([]*domain.OrderGood, 0) 740 orderGoodsToConfirm := make([]*domain.OrderGood, 0)
741 orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood) 741 orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
742 // 分红退货单产品预算 742 // 分红退货单产品预算
743 - if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm); err != nil { 743 + if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId); err != nil {
744 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 744 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
745 } else { 745 } else {
746 for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails { 746 for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
@@ -591,7 +591,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -591,7 +591,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
591 var dividendsReturnedOrderCommands = make(map[string]*command.CreateDividendsReturnedOrderCommand) 591 var dividendsReturnedOrderCommands = make(map[string]*command.CreateDividendsReturnedOrderCommand)
592 592
593 for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { 593 for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
594 - hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum)) 594 + hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum + dividendsReturnedOrder.DividendsReturnedDate))
595 hashString := hex.EncodeToString(hashValue[:]) 595 hashString := hex.EncodeToString(hashValue[:])
596 if _, ok := dividendsReturnedOrderCommands[hashString]; !ok { 596 if _, ok := dividendsReturnedOrderCommands[hashString]; !ok {
597 // 订单日期时间格式转换 597 // 订单日期时间格式转换
@@ -43,5 +43,5 @@ func (DividendsEstimateDetail *DividendsEstimateDetail) GenerateSpecificDividend @@ -43,5 +43,5 @@ func (DividendsEstimateDetail *DividendsEstimateDetail) GenerateSpecificDividend
43 43
44 type ConfirmDividendsIncentivesEstimateService interface { 44 type ConfirmDividendsIncentivesEstimateService interface {
45 coreDomain.DomainEventPublisher 45 coreDomain.DomainEventPublisher
46 - Confirm(orderGoods []*domain.OrderGood) ([]*DividendsEstimateDetail, error) 46 + Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64) ([]*DividendsEstimateDetail, error)
47 } 47 }
@@ -17,7 +17,7 @@ type ConfirmDividendsIncentivesEstimateService struct { @@ -17,7 +17,7 @@ type ConfirmDividendsIncentivesEstimateService struct {
17 } 17 }
18 18
19 // Confirm 确认业绩分红预算 19 // Confirm 确认业绩分红预算
20 -func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood) ([]*service.DividendsEstimateDetail, error) { 20 +func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64) ([]*service.DividendsEstimateDetail, error) {
21 var cooperationContractRepository domain.CooperationContractRepository // 共创合约仓储 21 var cooperationContractRepository domain.CooperationContractRepository // 共创合约仓储
22 var cooperationProjectRepository domain.CooperationProjectRepository // 共创项目仓储 22 var cooperationProjectRepository domain.CooperationProjectRepository // 共创项目仓储
23 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储 23 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
@@ -51,6 +51,22 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -51,6 +51,22 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
51 dividendsReturnedOrderRepository = repo 51 dividendsReturnedOrderRepository = repo
52 } 52 }
53 53
  54 + // 查询共创合约
  55 + cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
  56 + if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
  57 + "companyId": companyId,
  58 + "orgId": orgId,
  59 + "offsetLimit": false,
  60 + }); err != nil {
  61 + return nil, err
  62 + } else {
  63 + if count > 0 {
  64 + for _, cooperationContractFound := range cooperationContractsFound {
  65 + cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
  66 + }
  67 + }
  68 + }
  69 +
54 // 确认业绩分红预算 70 // 确认业绩分红预算
55 var dividendsEstimateDetails []*service.DividendsEstimateDetail 71 var dividendsEstimateDetails []*service.DividendsEstimateDetail
56 for _, orderGood := range orderGoods { 72 for _, orderGood := range orderGoods {
@@ -58,13 +74,29 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -58,13 +74,29 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
58 "orderGood": orderGood, 74 "orderGood": orderGood,
59 }) 75 })
60 76
  77 + if orderGood.CooperationContractNumber == "" {
  78 + var orderNumber string
  79 + if orderGood.DividendsOrderNumber != "" {
  80 + orderNumber = orderGood.DividendsOrderNumber
  81 + } else {
  82 + orderNumber = orderGood.DividendsReturnedOrderNumber
  83 + }
  84 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  85 + DividendsUser: nil,
  86 + DividendsParticipateType: 0,
  87 + DividendsStage: 0,
  88 + DividendsAmount: 0,
  89 + OrderOrReturnedOrderNumber: orderNumber,
  90 + IsSuccessfully: false,
  91 + Reason: "产品未关联合约,不能进行分红预算",
  92 + })
  93 + continue
  94 + }
  95 +
  96 + var cooperationContract *domain.CooperationContract
  97 +
61 // 获取合约 98 // 获取合约
62 - cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{  
63 - "cooperationContractNumber": orderGood.CooperationContractNumber,  
64 - "companyId": orderGood.CompanyId,  
65 - "orgId": orderGood.OrgId,  
66 - })  
67 - if err != nil { 99 + if _, ok := cooperationContractsMap[orderGood.CooperationContractNumber]; !ok {
68 var orderNumber string 100 var orderNumber string
69 if orderGood.DividendsOrderNumber != "" { 101 if orderGood.DividendsOrderNumber != "" {
70 orderNumber = orderGood.DividendsOrderNumber 102 orderNumber = orderGood.DividendsOrderNumber
@@ -78,10 +110,36 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -78,10 +110,36 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
78 DividendsAmount: 0, 110 DividendsAmount: 0,
79 OrderOrReturnedOrderNumber: orderNumber, 111 OrderOrReturnedOrderNumber: orderNumber,
80 IsSuccessfully: false, 112 IsSuccessfully: false,
81 - Reason: "共创合约错误", 113 + Reason: "共创合约" + orderGood.CooperationContractNumber + "不存在",
82 }) 114 })
83 continue 115 continue
  116 + } else {
  117 + cooperationContract = cooperationContractsMap[orderGood.CooperationContractNumber]
84 } 118 }
  119 +
  120 + //cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
  121 + // "cooperationContractNumber": orderGood.CooperationContractNumber,
  122 + // "companyId": orderGood.CompanyId,
  123 + // "orgId": orderGood.OrgId,
  124 + //})
  125 + //if err != nil {
  126 + // var orderNumber string
  127 + // if orderGood.DividendsOrderNumber != "" {
  128 + // orderNumber = orderGood.DividendsOrderNumber
  129 + // } else {
  130 + // orderNumber = orderGood.DividendsReturnedOrderNumber
  131 + // }
  132 + // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  133 + // DividendsUser: nil,
  134 + // DividendsParticipateType: 0,
  135 + // DividendsStage: 0,
  136 + // DividendsAmount: 0,
  137 + // OrderOrReturnedOrderNumber: orderNumber,
  138 + // IsSuccessfully: false,
  139 + // Reason: "共创合约错误",
  140 + // })
  141 + // continue
  142 + //}
85 if cooperationContract == nil { 143 if cooperationContract == nil {
86 var orderNumber string 144 var orderNumber string
87 if orderGood.DividendsOrderNumber != "" { 145 if orderGood.DividendsOrderNumber != "" {
@@ -32,7 +32,7 @@ func init() { @@ -32,7 +32,7 @@ func init() {
32 } 32 }
33 } 33 }
34 //https支持 34 //https支持
35 - web.BConfig.Listen.EnableHTTPS = true 35 + web.BConfig.Listen.EnableHTTPS = false
36 web.BConfig.Listen.HTTPSPort = 443 36 web.BConfig.Listen.HTTPSPort = 443
37 web.BConfig.Listen.HTTPSCertFile = "./config/fjmaimaimai.com_bundle.crt" 37 web.BConfig.Listen.HTTPSCertFile = "./config/fjmaimaimai.com_bundle.crt"
38 web.BConfig.Listen.HTTPSKeyFile = "./config/fjmaimaimai.com.key" 38 web.BConfig.Listen.HTTPSKeyFile = "./config/fjmaimaimai.com.key"