|
@@ -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 != "" {
|