Merge branch 'dev-chenzhiying' into dev
正在显示
2 个修改的文件
包含
38 行增加
和
4 行删除
@@ -473,12 +473,29 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai | @@ -473,12 +473,29 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai | ||
473 | } else { | 473 | } else { |
474 | for _, dividendsOrder := range dividendsOrders { | 474 | for _, dividendsOrder := range dividendsOrders { |
475 | // 删除订单产品 | 475 | // 删除订单产品 |
476 | + //var orderGoodModels []*models.OrderGood | ||
477 | + //if _, err := tx.Model(&orderGoodModels). | ||
478 | + // Where("company_id = ?", dividendsOrder.Company.CompanyId). | ||
479 | + // Where("org_id = ?", dividendsOrder.Org.OrgId). | ||
480 | + // Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).WherePK().Delete(); err != nil { | ||
481 | + // return nil, err | ||
482 | + //} | ||
483 | + | ||
484 | + // 删除订单产品 | ||
476 | var orderGoodModels []*models.OrderGood | 485 | var orderGoodModels []*models.OrderGood |
477 | - if _, err := tx.Model(&orderGoodModels). | 486 | + orderGoodQuery := tx.Model(&orderGoodModels) |
487 | + if err := orderGoodQuery. | ||
478 | Where("company_id = ?", dividendsOrder.Company.CompanyId). | 488 | Where("company_id = ?", dividendsOrder.Company.CompanyId). |
479 | Where("org_id = ?", dividendsOrder.Org.OrgId). | 489 | Where("org_id = ?", dividendsOrder.Org.OrgId). |
480 | - Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).WherePK().Delete(); err != nil { | 490 | + Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber). |
491 | + Select(); err != nil { | ||
481 | return nil, err | 492 | return nil, err |
493 | + } else { | ||
494 | + if len(orderGoodModels) > 0 { | ||
495 | + if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil { | ||
496 | + return nil, err | ||
497 | + } | ||
498 | + } | ||
482 | } | 499 | } |
483 | } | 500 | } |
484 | } | 501 | } |
@@ -447,12 +447,29 @@ func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrde | @@ -447,12 +447,29 @@ func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrde | ||
447 | return dividendsReturnedOrder, err | 447 | return dividendsReturnedOrder, err |
448 | } else { | 448 | } else { |
449 | // 删除分红退货单产品 | 449 | // 删除分红退货单产品 |
450 | + //var orderGoodModels []*models.OrderGood | ||
451 | + //if _, err := tx.Model(&orderGoodModels). | ||
452 | + // Where("company_id = ?", dividendsReturnedOrder.Company.CompanyId). | ||
453 | + // Where("org_id = ?", dividendsReturnedOrder.Org.OrgId). | ||
454 | + // Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber).Delete(); err != nil { | ||
455 | + // return nil, err | ||
456 | + //} | ||
457 | + | ||
458 | + // 删除分红退货单产品 | ||
450 | var orderGoodModels []*models.OrderGood | 459 | var orderGoodModels []*models.OrderGood |
451 | - if _, err := tx.Model(&orderGoodModels). | 460 | + orderGoodQuery := tx.Model(&orderGoodModels) |
461 | + if err := orderGoodQuery. | ||
452 | Where("company_id = ?", dividendsReturnedOrder.Company.CompanyId). | 462 | Where("company_id = ?", dividendsReturnedOrder.Company.CompanyId). |
453 | Where("org_id = ?", dividendsReturnedOrder.Org.OrgId). | 463 | Where("org_id = ?", dividendsReturnedOrder.Org.OrgId). |
454 | - Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber).Delete(); err != nil { | 464 | + Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber). |
465 | + Select(); err != nil { | ||
455 | return nil, err | 466 | return nil, err |
467 | + } else { | ||
468 | + if len(orderGoodModels) > 0 { | ||
469 | + if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil { | ||
470 | + return nil, err | ||
471 | + } | ||
472 | + } | ||
456 | } | 473 | } |
457 | } | 474 | } |
458 | return dividendsReturnedOrder, nil | 475 | return dividendsReturnedOrder, nil |
-
请 注册 或 登录 后发表评论