作者 陈志颖

Merge branch 'dev-chenzhiying' into dev

... ... @@ -473,12 +473,29 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai
} else {
for _, dividendsOrder := range dividendsOrders {
// 删除订单产品
//var orderGoodModels []*models.OrderGood
//if _, err := tx.Model(&orderGoodModels).
// Where("company_id = ?", dividendsOrder.Company.CompanyId).
// Where("org_id = ?", dividendsOrder.Org.OrgId).
// Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).WherePK().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 = ?", dividendsOrder.Company.CompanyId).
Where("org_id = ?", dividendsOrder.Org.OrgId).
Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).WherePK().Delete(); err != nil {
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
}
}
}
}
}
... ...
... ... @@ -447,12 +447,29 @@ func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrde
return dividendsReturnedOrder, err
} else {
// 删除分红退货单产品
//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 {
Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber).
Select(); err != nil {
return nil, err
} else {
if len(orderGoodModels) > 0 {
if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil {
return nil, err
}
}
}
}
return dividendsReturnedOrder, nil
... ...