作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !35
... ... @@ -809,10 +809,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
dividendsReturnedOrderNumbers := make([]string, 0)
if len(estimateSuccessfullyDividendsOrders) > 0 {
for k, _ := range estimateSuccessfullyDividendsOrders {
if k[:2] == "RE" { // 分红退货单
dividendsReturnedOrderNumbers = append(dividendsReturnedOrderNumbers, k)
} else if k[:2] == "SL" { // 分红订单
dividendsOrderNumbers = append(dividendsOrderNumbers, k)
if k != "" {
if k[:2] == "RE" { // 分红退货单
dividendsReturnedOrderNumbers = append(dividendsReturnedOrderNumbers, k)
} else if k[:2] == "SL" { // 分红订单
dividendsOrderNumbers = append(dividendsOrderNumbers, k)
}
}
}
}
... ...
... ... @@ -1001,6 +1001,8 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 分红订单仓储初始化
var dividendsOrderRepository domain.DividendsOrderRepository
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -1010,6 +1012,16 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
dividendsOrderRepository = value
}
// 分红退货单仓储初始化
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsReturnedOrderRepository = value
}
dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误")
... ... @@ -1020,6 +1032,22 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
// 校验分红订单是否有退货单关联
for _, dividendsOrder := range dividendsOrders {
if countReturnedOrder, dividendsReturnedOrders, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
"dividendsOrderNumber": dividendsOrder.DividendsOrderNumber,
"companyId": dividendsOrder.Company.CompanyId,
"limit": 1,
"offset": 0,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if countReturnedOrder > 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsReturnedOrders[0].DividendsOrderNumber))
}
}
}
dividendsOrdersRemoved, err := dividendsOrderRepository.BatchRemove(dividendsOrders)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ...
... ... @@ -1007,6 +1007,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) BatchRemoveD
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 分红退货单仓储初始化
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -1149,6 +1151,16 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
cooperationContractRepository = value
}
// 产品仓储初始化
var orderGoodRepository domain.OrderGoodRepository
if value, err := factory.CreateOrderGoodRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
orderGoodRepository = value
}
// 查找合约
cooperationContractsMap := make(map[string]*domain.CooperationContract)
if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
... ... @@ -1175,6 +1187,14 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
}
// 获取产品
orderGoodFound, err4 := orderGoodRepository.FindOne(map[string]interface{}{
"orderGoodId": orderGoodId,
})
if err4 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
}
// 退货产品金额计算
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
... ... @@ -1209,6 +1229,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
DividendsReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber,
CooperationContractNumber: orderGood.CooperationContractNumber,
OrderGoodExpense: orderGood.OrderGoodExpense,
OrderGoodDividendsStatus: orderGoodFound.OrderGoodDividendsStatus,
OrgId: updateDividendsReturnedOrderCommand.OrgId,
CompanyId: updateDividendsReturnedOrderCommand.CompanyId,
CreatedAt: time.Time{},
... ...
... ... @@ -73,9 +73,6 @@ func (dividendsReturnedOrder *DividendsReturnedOrder) Identify() interface{} {
}
func (dividendsReturnedOrder *DividendsReturnedOrder) Update(data map[string]interface{}) error {
if dividendsReturnedOrderRefund, ok := data["dividendsReturnedOrderRefund"]; ok {
dividendsReturnedOrder.DividendsReturnedOrderRefund = dividendsReturnedOrderRefund.(float64)
}
if originalOrderNum, ok := data["originalOrderNum"]; ok {
dividendsReturnedOrder.OriginalOrderNum = originalOrderNum.(string)
}
... ...