正在显示
3 个修改的文件
包含
29 行增加
和
1 行删除
@@ -47,6 +47,7 @@ type DividendsOrder struct { | @@ -47,6 +47,7 @@ type DividendsOrder struct { | ||
47 | type DividendsOrderRepository interface { | 47 | type DividendsOrderRepository interface { |
48 | Save(dividendsOrder *DividendsOrder) (*DividendsOrder, error) | 48 | Save(dividendsOrder *DividendsOrder) (*DividendsOrder, error) |
49 | Remove(dividendsOrder *DividendsOrder) (*DividendsOrder, error) | 49 | Remove(dividendsOrder *DividendsOrder) (*DividendsOrder, error) |
50 | + BatchRemove(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error) | ||
50 | FindOne(queryOptions map[string]interface{}) (*DividendsOrder, error) | 51 | FindOne(queryOptions map[string]interface{}) (*DividendsOrder, error) |
51 | Find(queryOptions map[string]interface{}) (int64, []*DividendsOrder, error) | 52 | Find(queryOptions map[string]interface{}) (int64, []*DividendsOrder, error) |
52 | } | 53 | } |
@@ -272,6 +272,28 @@ func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.Divide | @@ -272,6 +272,28 @@ func (repository *DividendsOrderRepository) Remove(dividendsOrder *domain.Divide | ||
272 | return dividendsOrder, nil | 272 | return dividendsOrder, nil |
273 | } | 273 | } |
274 | 274 | ||
275 | +func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domain.DividendsOrder) ([]*domain.DividendsOrder, error) { | ||
276 | + tx := repository.transactionContext.PgTx | ||
277 | + var dividendsOrderModels []*models.DividendsOrder | ||
278 | + for _, dividendsOrder := range dividendsOrders { | ||
279 | + dividendsOrderModels = append(dividendsOrderModels, &models.DividendsOrder{ | ||
280 | + DividendsOrderId: dividendsOrder.Identify().(int64), | ||
281 | + }) | ||
282 | + } | ||
283 | + if _, err := tx.Model(÷ndsOrderModels).WherePK().Delete(); err != nil { | ||
284 | + return dividendsOrders, err | ||
285 | + } else { | ||
286 | + for _, dividendsOrder := range dividendsOrders { | ||
287 | + // 删除订单产品 | ||
288 | + var orderGoodModels []*models.OrderGood | ||
289 | + if _, err := tx.Model(&orderGoodModels).Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).Delete(); err != nil { | ||
290 | + return nil, err | ||
291 | + } | ||
292 | + } | ||
293 | + } | ||
294 | + return dividendsOrders, nil | ||
295 | +} | ||
296 | + | ||
275 | func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsOrder, error) { | 297 | func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsOrder, error) { |
276 | tx := repository.transactionContext.PgTx | 298 | tx := repository.transactionContext.PgTx |
277 | dividendsOrderModel := new(models.DividendsOrder) | 299 | dividendsOrderModel := new(models.DividendsOrder) |
@@ -304,7 +326,10 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa | @@ -304,7 +326,10 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa | ||
304 | dividendsOrders := make([]*domain.DividendsOrder, 0) | 326 | dividendsOrders := make([]*domain.DividendsOrder, 0) |
305 | query := sqlbuilder.BuildQuery(tx.Model(÷ndsOrderModels), queryOptions) | 327 | query := sqlbuilder.BuildQuery(tx.Model(÷ndsOrderModels), queryOptions) |
306 | if dividendsOrderNumber, ok := queryOptions["dividendsOrderNumber"]; ok && dividendsOrderNumber != "" { | 328 | if dividendsOrderNumber, ok := queryOptions["dividendsOrderNumber"]; ok && dividendsOrderNumber != "" { |
307 | - query.Where("dividends_order_number like ?", fmt.Sprintf("%%%s%%", dividendsOrderNumber)) | 329 | + query.Where("dividends_order_number ilike ?", fmt.Sprintf("%%%s%%", dividendsOrderNumber)) |
330 | + } | ||
331 | + if customerName, ok := queryOptions["customerName"]; ok && customerName != "" { | ||
332 | + query.Where("customer_name like ?", fmt.Sprintf("%%%s%%", customerName)) | ||
308 | } | 333 | } |
309 | offsetLimitFlag := true | 334 | offsetLimitFlag := true |
310 | if offsetLimit, ok := queryOptions["offsetLimit"]; ok { | 335 | if offsetLimit, ok := queryOptions["offsetLimit"]; ok { |
@@ -70,6 +70,7 @@ func (controller *DividendsOrderController) RemoveDividendsOrder() { | @@ -70,6 +70,7 @@ func (controller *DividendsOrderController) RemoveDividendsOrder() { | ||
70 | func (controller *DividendsOrderController) SearchDividendsOrder() { | 70 | func (controller *DividendsOrderController) SearchDividendsOrder() { |
71 | dividendsOrderService := service.NewDividendsOrderService(nil) | 71 | dividendsOrderService := service.NewDividendsOrderService(nil) |
72 | searchDividendsOrderQuery := &query.SearchDividendsOrderQuery{} | 72 | searchDividendsOrderQuery := &query.SearchDividendsOrderQuery{} |
73 | + _ = controller.Unmarshal(searchDividendsOrderQuery) | ||
73 | header := controller.GetRequestHeader(controller.Ctx) | 74 | header := controller.GetRequestHeader(controller.Ctx) |
74 | searchDividendsOrderQuery.CompanyId = header.CompanyId | 75 | searchDividendsOrderQuery.CompanyId = header.CompanyId |
75 | searchDividendsOrderQuery.OrgId = header.OrgId | 76 | searchDividendsOrderQuery.OrgId = header.OrgId |
@@ -82,6 +83,7 @@ func (controller *DividendsOrderController) SearchDividendsOrder() { | @@ -82,6 +83,7 @@ func (controller *DividendsOrderController) SearchDividendsOrder() { | ||
82 | func (controller *DividendsOrderController) SearchDividendsOrderNumber() { | 83 | func (controller *DividendsOrderController) SearchDividendsOrderNumber() { |
83 | dividendsOrderService := service.NewDividendsOrderService(nil) | 84 | dividendsOrderService := service.NewDividendsOrderService(nil) |
84 | searchDividendsOrderNumberQuery := &query.SearchDividendsOrderNumberQuery{} | 85 | searchDividendsOrderNumberQuery := &query.SearchDividendsOrderNumberQuery{} |
86 | + _ = controller.Unmarshal(searchDividendsOrderNumberQuery) | ||
85 | header := controller.GetRequestHeader(controller.Ctx) | 87 | header := controller.GetRequestHeader(controller.Ctx) |
86 | searchDividendsOrderNumberQuery.CompanyId = header.CompanyId | 88 | searchDividendsOrderNumberQuery.CompanyId = header.CompanyId |
87 | searchDividendsOrderNumberQuery.OrgId = header.OrgId | 89 | searchDividendsOrderNumberQuery.OrgId = header.OrgId |
-
请 注册 或 登录 后发表评论