...
|
...
|
@@ -17,7 +17,7 @@ type ConfirmDividendsIncentivesEstimateService struct { |
|
|
}
|
|
|
|
|
|
// Confirm 确认业绩分红预算
|
|
|
func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood) ([]*service.DividendsEstimateDetail, error) {
|
|
|
func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64) ([]*service.DividendsEstimateDetail, error) {
|
|
|
var cooperationContractRepository domain.CooperationContractRepository // 共创合约仓储
|
|
|
var cooperationProjectRepository domain.CooperationProjectRepository // 共创项目仓储
|
|
|
var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
|
...
|
...
|
@@ -51,6 +51,22 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
|
|
dividendsReturnedOrderRepository = repo
|
|
|
}
|
|
|
|
|
|
// 查询共创合约
|
|
|
cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
|
|
|
if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
|
|
|
"companyId": companyId,
|
|
|
"orgId": orgId,
|
|
|
"offsetLimit": false,
|
|
|
}); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
if count > 0 {
|
|
|
for _, cooperationContractFound := range cooperationContractsFound {
|
|
|
cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 确认业绩分红预算
|
|
|
var dividendsEstimateDetails []*service.DividendsEstimateDetail
|
|
|
for _, orderGood := range orderGoods {
|
...
|
...
|
@@ -58,13 +74,29 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
|
|
"orderGood": orderGood,
|
|
|
})
|
|
|
|
|
|
if orderGood.CooperationContractNumber == "" {
|
|
|
var orderNumber string
|
|
|
if orderGood.DividendsOrderNumber != "" {
|
|
|
orderNumber = orderGood.DividendsOrderNumber
|
|
|
} else {
|
|
|
orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
}
|
|
|
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
DividendsUser: nil,
|
|
|
DividendsParticipateType: 0,
|
|
|
DividendsStage: 0,
|
|
|
DividendsAmount: 0,
|
|
|
OrderOrReturnedOrderNumber: orderNumber,
|
|
|
IsSuccessfully: false,
|
|
|
Reason: "产品未关联合约,不能进行分红预算",
|
|
|
})
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
var cooperationContract *domain.CooperationContract
|
|
|
|
|
|
// 获取合约
|
|
|
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
|
|
|
"cooperationContractNumber": orderGood.CooperationContractNumber,
|
|
|
"companyId": orderGood.CompanyId,
|
|
|
"orgId": orderGood.OrgId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
if _, ok := cooperationContractsMap[orderGood.CooperationContractNumber]; !ok {
|
|
|
var orderNumber string
|
|
|
if orderGood.DividendsOrderNumber != "" {
|
|
|
orderNumber = orderGood.DividendsOrderNumber
|
...
|
...
|
@@ -78,10 +110,36 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
|
|
DividendsAmount: 0,
|
|
|
OrderOrReturnedOrderNumber: orderNumber,
|
|
|
IsSuccessfully: false,
|
|
|
Reason: "共创合约错误",
|
|
|
Reason: "共创合约" + orderGood.CooperationContractNumber + "不存在",
|
|
|
})
|
|
|
continue
|
|
|
} else {
|
|
|
cooperationContract = cooperationContractsMap[orderGood.CooperationContractNumber]
|
|
|
}
|
|
|
|
|
|
//cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
|
|
|
// "cooperationContractNumber": orderGood.CooperationContractNumber,
|
|
|
// "companyId": orderGood.CompanyId,
|
|
|
// "orgId": orderGood.OrgId,
|
|
|
//})
|
|
|
//if err != nil {
|
|
|
// var orderNumber string
|
|
|
// if orderGood.DividendsOrderNumber != "" {
|
|
|
// orderNumber = orderGood.DividendsOrderNumber
|
|
|
// } else {
|
|
|
// orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
// }
|
|
|
// dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
// DividendsUser: nil,
|
|
|
// DividendsParticipateType: 0,
|
|
|
// DividendsStage: 0,
|
|
|
// DividendsAmount: 0,
|
|
|
// OrderOrReturnedOrderNumber: orderNumber,
|
|
|
// IsSuccessfully: false,
|
|
|
// Reason: "共创合约错误",
|
|
|
// })
|
|
|
// continue
|
|
|
//}
|
|
|
if cooperationContract == nil {
|
|
|
var orderNumber string
|
|
|
if orderGood.DividendsOrderNumber != "" {
|
...
|
...
|
|