作者 陈志颖

fix:删除分红退货单

... ... @@ -449,12 +449,29 @@ func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.Divide
return dividendsOrder, err
} else {
// 删除订单产品
//var orderGoodModels []*models.OrderGood
//if _, err := tx.Model(&orderGoodModels).
// Where("company_id = ?", dividendsOrderModel.Company.CompanyId).
// Where("org_id = ?", dividendsOrderModel.Org.OrgId).
// Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).Delete(); err != nil {
// return nil, err
//}
// 删除订单产品
var orderGoodModels []*models.OrderGood
if _, err := tx.Model(&orderGoodModels).
Where("company_id = ?", dividendsOrderModel.Company.CompanyId).
Where("org_id = ?", dividendsOrderModel.Org.OrgId).
Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).Delete(); err != nil {
orderGoodQuery := tx.Model(&orderGoodModels)
if err := orderGoodQuery.
Where("company_id = ?", dividendsOrder.Company.CompanyId).
Where("org_id = ?", dividendsOrder.Org.OrgId).
Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).
Select(); err != nil {
return nil, err
} else {
if len(orderGoodModels) > 0 {
if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil {
return nil, err
}
}
}
}
return dividendsOrder, nil
... ...
... ... @@ -488,13 +488,30 @@ func (repository *DividendsReturnedOrderRepository) BatchRemove(dividendsReturne
} else {
for _, dividendsReturnedOrder := range dividendsReturnedOrders {
// 删除退货单产品
//var orderGoodModels []*models.OrderGood
//if _, err := tx.Model(&orderGoodModels).
// Where("company_id = ?", dividendsReturnedOrder.Company.CompanyId).
// Where("org_id = ?", dividendsReturnedOrder.Org.OrgId).
// Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber).
// Delete(); err != nil {
// return nil, err
//}
// 删除分红退货单产品
var orderGoodModels []*models.OrderGood
if _, err := tx.Model(&orderGoodModels).
orderGoodQuery := tx.Model(&orderGoodModels)
if err := orderGoodQuery.
Where("company_id = ?", dividendsReturnedOrder.Company.CompanyId).
Where("org_id = ?", dividendsReturnedOrder.Org.OrgId).
Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber).
Delete(); err != nil {
Select(); err != nil {
return nil, err
} else {
if len(orderGoodModels) > 0 {
if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil {
return nil, err
}
}
}
}
}
... ...