作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-cooperation into dev
@@ -449,12 +449,29 @@ func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.Divide @@ -449,12 +449,29 @@ func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.Divide
449 return dividendsOrder, err 449 return dividendsOrder, err
450 } else { 450 } else {
451 // 删除订单产品 451 // 删除订单产品
  452 + //var orderGoodModels []*models.OrderGood
  453 + //if _, err := tx.Model(&orderGoodModels).
  454 + // Where("company_id = ?", dividendsOrderModel.Company.CompanyId).
  455 + // Where("org_id = ?", dividendsOrderModel.Org.OrgId).
  456 + // Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).Delete(); err != nil {
  457 + // return nil, err
  458 + //}
  459 +
  460 + // 删除订单产品
452 var orderGoodModels []*models.OrderGood 461 var orderGoodModels []*models.OrderGood
453 - if _, err := tx.Model(&orderGoodModels).  
454 - Where("company_id = ?", dividendsOrderModel.Company.CompanyId).  
455 - Where("org_id = ?", dividendsOrderModel.Org.OrgId).  
456 - Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).Delete(); err != nil { 462 + orderGoodQuery := tx.Model(&orderGoodModels)
  463 + if err := orderGoodQuery.
  464 + Where("company_id = ?", dividendsOrder.Company.CompanyId).
  465 + Where("org_id = ?", dividendsOrder.Org.OrgId).
  466 + Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).
  467 + Select(); err != nil {
457 return nil, err 468 return nil, err
  469 + } else {
  470 + if len(orderGoodModels) > 0 {
  471 + if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil {
  472 + return nil, err
  473 + }
  474 + }
458 } 475 }
459 } 476 }
460 return dividendsOrder, nil 477 return dividendsOrder, nil
@@ -473,12 +490,29 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai @@ -473,12 +490,29 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai
473 } else { 490 } else {
474 for _, dividendsOrder := range dividendsOrders { 491 for _, dividendsOrder := range dividendsOrders {
475 // 删除订单产品 492 // 删除订单产品
  493 + //var orderGoodModels []*models.OrderGood
  494 + //if _, err := tx.Model(&orderGoodModels).
  495 + // Where("company_id = ?", dividendsOrder.Company.CompanyId).
  496 + // Where("org_id = ?", dividendsOrder.Org.OrgId).
  497 + // Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).WherePK().Delete(); err != nil {
  498 + // return nil, err
  499 + //}
  500 +
  501 + // 删除订单产品
476 var orderGoodModels []*models.OrderGood 502 var orderGoodModels []*models.OrderGood
477 - if _, err := tx.Model(&orderGoodModels). 503 + orderGoodQuery := tx.Model(&orderGoodModels)
  504 + if err := orderGoodQuery.
478 Where("company_id = ?", dividendsOrder.Company.CompanyId). 505 Where("company_id = ?", dividendsOrder.Company.CompanyId).
479 Where("org_id = ?", dividendsOrder.Org.OrgId). 506 Where("org_id = ?", dividendsOrder.Org.OrgId).
480 - Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).WherePK().Delete(); err != nil { 507 + Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).
  508 + Select(); err != nil {
481 return nil, err 509 return nil, err
  510 + } else {
  511 + if len(orderGoodModels) > 0 {
  512 + if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil {
  513 + return nil, err
  514 + }
  515 + }
482 } 516 }
483 } 517 }
484 } 518 }
@@ -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
@@ -471,13 +488,30 @@ func (repository *DividendsReturnedOrderRepository) BatchRemove(dividendsReturne @@ -471,13 +488,30 @@ func (repository *DividendsReturnedOrderRepository) BatchRemove(dividendsReturne
471 } else { 488 } else {
472 for _, dividendsReturnedOrder := range dividendsReturnedOrders { 489 for _, dividendsReturnedOrder := range dividendsReturnedOrders {
473 // 删除退货单产品 490 // 删除退货单产品
  491 + //var orderGoodModels []*models.OrderGood
  492 + //if _, err := tx.Model(&orderGoodModels).
  493 + // Where("company_id = ?", dividendsReturnedOrder.Company.CompanyId).
  494 + // Where("org_id = ?", dividendsReturnedOrder.Org.OrgId).
  495 + // Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber).
  496 + // Delete(); err != nil {
  497 + // return nil, err
  498 + //}
  499 +
  500 + // 删除分红退货单产品
474 var orderGoodModels []*models.OrderGood 501 var orderGoodModels []*models.OrderGood
475 - if _, err := tx.Model(&orderGoodModels). 502 + orderGoodQuery := tx.Model(&orderGoodModels)
  503 + if err := orderGoodQuery.
476 Where("company_id = ?", dividendsReturnedOrder.Company.CompanyId). 504 Where("company_id = ?", dividendsReturnedOrder.Company.CompanyId).
477 Where("org_id = ?", dividendsReturnedOrder.Org.OrgId). 505 Where("org_id = ?", dividendsReturnedOrder.Org.OrgId).
478 Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber). 506 Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber).
479 - Delete(); err != nil { 507 + Select(); err != nil {
480 return nil, err 508 return nil, err
  509 + } else {
  510 + if len(orderGoodModels) > 0 {
  511 + if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil {
  512 + return nil, err
  513 + }
  514 + }
481 } 515 }
482 } 516 }
483 } 517 }