...
|
...
|
@@ -256,6 +256,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder |
|
|
}
|
|
|
return dividendsReturnedOrder, nil
|
|
|
}
|
|
|
|
|
|
func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrder *domain.DividendsReturnedOrder) (*domain.DividendsReturnedOrder, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
dividendsReturnedOrderModel := new(models.DividendsReturnedOrder)
|
...
|
...
|
@@ -263,19 +264,15 @@ func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrde |
|
|
if _, err := tx.Model(dividendsReturnedOrderModel).WherePK().Delete(); err != nil {
|
|
|
return dividendsReturnedOrder, err
|
|
|
} else {
|
|
|
// 获取退货单产品
|
|
|
// 删除分红退货单产品
|
|
|
var orderGoodModels []*models.OrderGood
|
|
|
orderGoodModelQuery := tx.Model(&orderGoodModels)
|
|
|
if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsOrderNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
// 批量删除退货单产品
|
|
|
if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil {
|
|
|
if _, err := tx.Model(&orderGoodModels).Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsOrderNumber).Delete(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
|
|
return dividendsReturnedOrder, nil
|
|
|
}
|
|
|
|
|
|
func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsReturnedOrder, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
dividendsReturnedOrderModel := new(models.DividendsReturnedOrder)
|
...
|
...
|
@@ -301,6 +298,7 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str |
|
|
return transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.DividendsReturnedOrder, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
var dividendsReturnedOrderModels []*models.DividendsReturnedOrder
|
...
|
...
|
@@ -333,6 +331,7 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string |
|
|
return int64(count), dividendsReturnedOrders, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func NewDividendsReturnedOrderRepository(transactionContext *pgTransaction.TransactionContext) (*DividendsReturnedOrderRepository, error) {
|
|
|
if transactionContext == nil {
|
|
|
return nil, fmt.Errorf("transactionContext参数不能为nil")
|
...
|
...
|
|