作者 陈志颖

feat:分红退货单仓储删除功能调整

@@ -256,6 +256,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -256,6 +256,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
256 } 256 }
257 return dividendsReturnedOrder, nil 257 return dividendsReturnedOrder, nil
258 } 258 }
  259 +
259 func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrder *domain.DividendsReturnedOrder) (*domain.DividendsReturnedOrder, error) { 260 func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrder *domain.DividendsReturnedOrder) (*domain.DividendsReturnedOrder, error) {
260 tx := repository.transactionContext.PgTx 261 tx := repository.transactionContext.PgTx
261 dividendsReturnedOrderModel := new(models.DividendsReturnedOrder) 262 dividendsReturnedOrderModel := new(models.DividendsReturnedOrder)
@@ -263,19 +264,15 @@ func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrde @@ -263,19 +264,15 @@ func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrde
263 if _, err := tx.Model(dividendsReturnedOrderModel).WherePK().Delete(); err != nil { 264 if _, err := tx.Model(dividendsReturnedOrderModel).WherePK().Delete(); err != nil {
264 return dividendsReturnedOrder, err 265 return dividendsReturnedOrder, err
265 } else { 266 } else {
266 - // 获取退货单产品 267 + // 删除分红退货单产品
267 var orderGoodModels []*models.OrderGood 268 var orderGoodModels []*models.OrderGood
268 - orderGoodModelQuery := tx.Model(&orderGoodModels)  
269 - if err := orderGoodModelQuery.Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsOrderNumber).Select(); err != nil {  
270 - return nil, err  
271 - }  
272 - // 批量删除退货单产品  
273 - if _, err := tx.Model(&orderGoodModels).WherePK().Delete(); err != nil { 269 + if _, err := tx.Model(&orderGoodModels).Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsOrderNumber).Delete(); err != nil {
274 return nil, err 270 return nil, err
275 } 271 }
276 } 272 }
277 return dividendsReturnedOrder, nil 273 return dividendsReturnedOrder, nil
278 } 274 }
  275 +
279 func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsReturnedOrder, error) { 276 func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsReturnedOrder, error) {
280 tx := repository.transactionContext.PgTx 277 tx := repository.transactionContext.PgTx
281 dividendsReturnedOrderModel := new(models.DividendsReturnedOrder) 278 dividendsReturnedOrderModel := new(models.DividendsReturnedOrder)
@@ -301,6 +298,7 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str @@ -301,6 +298,7 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str
301 return transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels) 298 return transform.TransformToDividendsReturnedOrderDomainModelFromPgModels(dividendsReturnedOrderModel, orderGoodModels)
302 } 299 }
303 } 300 }
  301 +
304 func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.DividendsReturnedOrder, error) { 302 func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.DividendsReturnedOrder, error) {
305 tx := repository.transactionContext.PgTx 303 tx := repository.transactionContext.PgTx
306 var dividendsReturnedOrderModels []*models.DividendsReturnedOrder 304 var dividendsReturnedOrderModels []*models.DividendsReturnedOrder
@@ -333,6 +331,7 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string @@ -333,6 +331,7 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string
333 return int64(count), dividendsReturnedOrders, nil 331 return int64(count), dividendsReturnedOrders, nil
334 } 332 }
335 } 333 }
  334 +
336 func NewDividendsReturnedOrderRepository(transactionContext *pgTransaction.TransactionContext) (*DividendsReturnedOrderRepository, error) { 335 func NewDividendsReturnedOrderRepository(transactionContext *pgTransaction.TransactionContext) (*DividendsReturnedOrderRepository, error) {
337 if transactionContext == nil { 336 if transactionContext == nil {
338 return nil, fmt.Errorf("transactionContext参数不能为nil") 337 return nil, fmt.Errorf("transactionContext参数不能为nil")