...
|
...
|
@@ -626,17 +626,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
|
for _, orderGood := range orderGoods {
|
|
|
dividendsEstimate := &domain.DividendsEstimate{}
|
|
|
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
|
|
|
//dividendsOrder, err3 := dividendsOrderRepository.FindOne(map[string]interface{}{
|
|
|
// "dividendsOrderNumber": orderGood.DividendsOrderNumber,
|
|
|
// "companyId": orderGood.CompanyId,
|
|
|
// "orgId": orderGood.OrgId,
|
|
|
//})
|
|
|
//if err3 != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
|
|
|
//}
|
|
|
//if dividendsOrder == nil {
|
|
|
// return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红订单%s不存在", orderGood.DividendsOrderNumber))
|
|
|
//}
|
|
|
// 分红订单产品预算
|
|
|
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -753,21 +742,24 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
|
}
|
|
|
|
|
|
// 获取订单产品
|
|
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
|
|
"orderGoodIds": orderGoodSavedIds,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if countOrderGood > 0 {
|
|
|
for i, _ := range orderGoodsFound {
|
|
|
orderGoodsFound[i].OrderGoodDividendsStatus = int32(2) // 已分红
|
|
|
}
|
|
|
if _, err6 := orderGoodRepository.UpdateMany(orderGoodsFound); err6 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err6.Error())
|
|
|
if len(orderGoodSavedIds) > 0 {
|
|
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
|
|
"orderGoodIds": orderGoodSavedIds,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if countOrderGood > 0 {
|
|
|
for i, _ := range orderGoodsFound {
|
|
|
orderGoodsFound[i].OrderGoodDividendsStatus = int32(2) // 已分红
|
|
|
}
|
|
|
if _, err6 := orderGoodRepository.UpdateMany(orderGoodsFound); err6 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err6.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 完成第一阶段事务提交
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -788,7 +780,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
|
failedReasonStr = "无"
|
|
|
}
|
|
|
|
|
|
// 开启薪事务
|
|
|
// 开启第二阶段事务:处理订单和产品状态
|
|
|
newTransactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -893,6 +885,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 完成第二阶段事务提交
|
|
|
if err := newTransactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|