...
|
...
|
@@ -110,8 +110,8 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend |
|
|
OrderGoodName: good.OrderGoodName,
|
|
|
OrderGoodPrice: good.OrderGoodPrice,
|
|
|
OrderGoodQuantity: good.OrderGoodQuantity,
|
|
|
DividendsOrderNumber: good.DividendsOrderNumber,
|
|
|
DividendsReturnedOrderNumber: good.DividendsReturnedOrderNumber,
|
|
|
DividendsOrderNumber: dividendsOrder.DividendsOrderNumber,
|
|
|
DividendsReturnedOrderNumber: "",
|
|
|
CooperationContractNumber: good.CooperationContractNumber,
|
|
|
CompanyId: good.CompanyId,
|
|
|
OrgId: good.OrgId,
|
...
|
...
|
@@ -334,7 +334,10 @@ func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.Divide |
|
|
} else {
|
|
|
// 删除订单产品
|
|
|
var orderGoodModels []*models.OrderGood
|
|
|
if _, err := tx.Model(&orderGoodModels).Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).Delete(); err != nil {
|
|
|
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
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -355,7 +358,10 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai |
|
|
for _, dividendsOrder := range dividendsOrders {
|
|
|
// 删除订单产品
|
|
|
var orderGoodModels []*models.OrderGood
|
|
|
if _, err := tx.Model(&orderGoodModels).Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).Delete(); err != nil {
|
|
|
if _, err := tx.Model(&orderGoodModels).
|
|
|
Where("company_id = ?", dividendsOrder.Company.CompanyId).
|
|
|
Where("org_id = ?", dividendsOrder.Org.OrgId).
|
|
|
Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).Delete(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -368,7 +374,6 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte |
|
|
dividendsOrderModel := new(models.DividendsOrder)
|
|
|
query := sqlbuilder.BuildQuery(tx.Model(dividendsOrderModel), queryOptions)
|
|
|
query.SetWhereByQueryOption("dividends_order.dividends_order_id = ?", "dividendsOrderId")
|
|
|
//query.SetWhereByQueryOption("dividends_order.dividends_order_number = ?", "dividendsOrderNumber")
|
|
|
if dividendsOrderNumber, ok := queryOptions["dividendsOrderNumber"]; ok && dividendsOrderNumber != "" {
|
|
|
query.Where("dividends_order.dividends_order_number = ?", dividendsOrderNumber)
|
|
|
}
|
...
|
...
|
@@ -385,7 +390,10 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte |
|
|
// 获取订单产品
|
|
|
var orderGoodModels []*models.OrderGood
|
|
|
orderGoodModelQuery := tx.Model(&orderGoodModels)
|
|
|
if err := orderGoodModelQuery.Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil {
|
|
|
if err := orderGoodModelQuery.
|
|
|
Where("company_id = ?", dividendsOrderModel.Company.CompanyId).
|
|
|
Where("org_id = ?", dividendsOrderModel.Org.OrgId).
|
|
|
Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
// 聚合分红订单
|
...
|
...
|
@@ -434,8 +442,8 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa |
|
|
var orderGoodModels []*models.OrderGood
|
|
|
orderGoodModelQuery := tx.Model(&orderGoodModels)
|
|
|
if err := orderGoodModelQuery.
|
|
|
Where("company->>'companyId' = '?'", dividendsOrderModel.Company.CompanyId).
|
|
|
Where("org->>'orgId' = '?'", dividendsOrderModel.Org.OrgId).
|
|
|
Where("company_id = ?", dividendsOrderModel.Company.CompanyId).
|
|
|
Where("org_id = ?", dividendsOrderModel.Org.OrgId).
|
|
|
Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).
|
|
|
Select(); err != nil {
|
|
|
return 0, nil, err
|
...
|
...
|
|