...
|
...
|
@@ -272,6 +272,28 @@ func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.Divide |
|
|
return dividendsOrder, nil
|
|
|
}
|
|
|
|
|
|
func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domain.DividendsOrder) ([]*domain.DividendsOrder, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
var dividendsOrderModels []*models.DividendsOrder
|
|
|
for _, dividendsOrder := range dividendsOrders {
|
|
|
dividendsOrderModels = append(dividendsOrderModels, &models.DividendsOrder{
|
|
|
DividendsOrderId: dividendsOrder.Identify().(int64),
|
|
|
})
|
|
|
}
|
|
|
if _, err := tx.Model(÷ndsOrderModels).WherePK().Delete(); err != nil {
|
|
|
return dividendsOrders, err
|
|
|
} else {
|
|
|
for _, dividendsOrder := range dividendsOrders {
|
|
|
// 删除订单产品
|
|
|
var orderGoodModels []*models.OrderGood
|
|
|
if _, err := tx.Model(&orderGoodModels).Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).Delete(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return dividendsOrders, nil
|
|
|
}
|
|
|
|
|
|
func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsOrder, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
dividendsOrderModel := new(models.DividendsOrder)
|
...
|
...
|
@@ -304,7 +326,10 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa |
|
|
dividendsOrders := make([]*domain.DividendsOrder, 0)
|
|
|
query := sqlbuilder.BuildQuery(tx.Model(÷ndsOrderModels), queryOptions)
|
|
|
if dividendsOrderNumber, ok := queryOptions["dividendsOrderNumber"]; ok && dividendsOrderNumber != "" {
|
|
|
query.Where("dividends_order_number like ?", fmt.Sprintf("%%%s%%", dividendsOrderNumber))
|
|
|
query.Where("dividends_order_number ilike ?", fmt.Sprintf("%%%s%%", dividendsOrderNumber))
|
|
|
}
|
|
|
if customerName, ok := queryOptions["customerName"]; ok && customerName != "" {
|
|
|
query.Where("customer_name like ?", fmt.Sprintf("%%%s%%", customerName))
|
|
|
}
|
|
|
offsetLimitFlag := true
|
|
|
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
|
...
|
...
|
|