作者 陈志颖

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

... ... @@ -684,7 +684,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
// 分红订单产品预算
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm); err != nil {
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsEstimateDetail := range dividendsEstimateDetails {
... ... @@ -740,7 +740,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
// 分红退货单产品预算
if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm); err != nil {
if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
... ...
... ... @@ -591,7 +591,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
var dividendsReturnedOrderCommands = make(map[string]*command.CreateDividendsReturnedOrderCommand)
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum))
hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum + dividendsReturnedOrder.DividendsReturnedDate))
hashString := hex.EncodeToString(hashValue[:])
if _, ok := dividendsReturnedOrderCommands[hashString]; !ok {
// 订单日期时间格式转换
... ...
... ... @@ -43,5 +43,5 @@ func (DividendsEstimateDetail *DividendsEstimateDetail) GenerateSpecificDividend
type ConfirmDividendsIncentivesEstimateService interface {
coreDomain.DomainEventPublisher
Confirm(orderGoods []*domain.OrderGood) ([]*DividendsEstimateDetail, error)
Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64) ([]*DividendsEstimateDetail, error)
}
... ...
... ... @@ -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 != "" {
... ...
... ... @@ -32,7 +32,7 @@ func init() {
}
}
//https支持
web.BConfig.Listen.EnableHTTPS = true
web.BConfig.Listen.EnableHTTPS = false
web.BConfig.Listen.HTTPSPort = 443
web.BConfig.Listen.HTTPSCertFile = "./config/fjmaimaimai.com_bundle.crt"
web.BConfig.Listen.HTTPSKeyFile = "./config/fjmaimaimai.com.key"
... ...