正在显示
6 个修改的文件
包含
46 行增加
和
13 行删除
@@ -75,7 +75,11 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive | @@ -75,7 +75,11 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive | ||
75 | for _, orderGood := range orderGoods { | 75 | for _, orderGood := range orderGoods { |
76 | dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{} | 76 | dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{} |
77 | if orderGood.DividendsOrderNumber != "" { // 查询分红订单 | 77 | if orderGood.DividendsOrderNumber != "" { // 查询分红订单 |
78 | - dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber}) | 78 | + dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{ |
79 | + "dividendsOrderNumber": orderGood.DividendsOrderNumber, | ||
80 | + "companyId": orderGood.CompanyId, | ||
81 | + "orgId": orderGood.OrgId, | ||
82 | + }) | ||
79 | if err != nil { | 83 | if err != nil { |
80 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 84 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
81 | } | 85 | } |
@@ -615,7 +619,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -615,7 +619,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
615 | for _, orderGood := range orderGoods { | 619 | for _, orderGood := range orderGoods { |
616 | dividendsEstimate := &domain.DividendsEstimate{} | 620 | dividendsEstimate := &domain.DividendsEstimate{} |
617 | if orderGood.DividendsOrderNumber != "" { // 查询分红订单 | 621 | if orderGood.DividendsOrderNumber != "" { // 查询分红订单 |
618 | - dividendsOrder, err3 := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber}) | 622 | + dividendsOrder, err3 := dividendsOrderRepository.FindOne(map[string]interface{}{ |
623 | + "dividendsOrderNumber": orderGood.DividendsOrderNumber, | ||
624 | + "companyId": orderGood.CompanyId, | ||
625 | + "orgId": orderGood.OrgId, | ||
626 | + }) | ||
619 | if err3 != nil { | 627 | if err3 != nil { |
620 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在") | 628 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在") |
621 | } | 629 | } |
@@ -1098,7 +1106,11 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti | @@ -1098,7 +1106,11 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti | ||
1098 | for _, orderGood := range orderGoods { | 1106 | for _, orderGood := range orderGoods { |
1099 | dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{} | 1107 | dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{} |
1100 | if orderGood.DividendsOrderNumber != "" { // 查询分红订单 | 1108 | if orderGood.DividendsOrderNumber != "" { // 查询分红订单 |
1101 | - dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber}) | 1109 | + dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{ |
1110 | + "dividendsOrderNumber": orderGood.DividendsOrderNumber, | ||
1111 | + "companyId": orderGood.CompanyId, | ||
1112 | + "orgId": orderGood.OrgId, | ||
1113 | + }) | ||
1102 | if err != nil { | 1114 | if err != nil { |
1103 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1115 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1104 | } | 1116 | } |
@@ -53,6 +53,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -53,6 +53,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
53 | // 获取分红订单 | 53 | // 获取分红订单 |
54 | dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{ | 54 | dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{ |
55 | "dividendsOrderNumber": orderGood.DividendsOrderNumber, | 55 | "dividendsOrderNumber": orderGood.DividendsOrderNumber, |
56 | + "companyId": orderGood.CompanyId, | ||
57 | + "orgId": orderGood.OrgId, | ||
56 | }) | 58 | }) |
57 | if err2 != nil { | 59 | if err2 != nil { |
58 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在") | 60 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在") |
@@ -440,7 +440,11 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m | @@ -440,7 +440,11 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m | ||
440 | DividendsUser: item.DividendsUser, | 440 | DividendsUser: item.DividendsUser, |
441 | } | 441 | } |
442 | if item.DividendsType == 1 { | 442 | if item.DividendsType == 1 { |
443 | - order, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": item.OrderOrReturnedOrderNum}) | 443 | + order, err := dividendsOrderRepository.FindOne(map[string]interface{}{ |
444 | + "dividendsOrderNumber": item.OrderOrReturnedOrderNum, | ||
445 | + "companyId": item.Company.CompanyId, | ||
446 | + "orgId": item.Org.OrgId, | ||
447 | + }) | ||
444 | if err != nil { | 448 | if err != nil { |
445 | return nil, err | 449 | return nil, err |
446 | } | 450 | } |
@@ -178,7 +178,11 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend | @@ -178,7 +178,11 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend | ||
178 | // 更新分红订单产品 | 178 | // 更新分红订单产品 |
179 | var orderGoodsFetched []*models.OrderGood | 179 | var orderGoodsFetched []*models.OrderGood |
180 | orderGoodsQuery := tx.Model(&orderGoodsFetched) | 180 | orderGoodsQuery := tx.Model(&orderGoodsFetched) |
181 | - if err := orderGoodsQuery.Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).Select(); err != nil { | 181 | + if err := orderGoodsQuery. |
182 | + Where("company_id = ?", dividendsOrder.Company.CompanyId). | ||
183 | + Where("org_id = ?", dividendsOrder.Org.OrgId). | ||
184 | + Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber). | ||
185 | + Select(); err != nil { | ||
182 | return nil, err | 186 | return nil, err |
183 | } | 187 | } |
184 | 188 | ||
@@ -190,6 +194,7 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend | @@ -190,6 +194,7 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend | ||
190 | 194 | ||
191 | // 待更新分红产品 | 195 | // 待更新分红产品 |
192 | var orderGoodsToUpdate []*domain.OrderGood | 196 | var orderGoodsToUpdate []*domain.OrderGood |
197 | + | ||
193 | // 待添加分红产品 | 198 | // 待添加分红产品 |
194 | var orderGoodsToAdd []*domain.OrderGood | 199 | var orderGoodsToAdd []*domain.OrderGood |
195 | for _, good := range dividendsOrder.Goods { | 200 | for _, good := range dividendsOrder.Goods { |
@@ -230,10 +235,10 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend | @@ -230,10 +235,10 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend | ||
230 | }) | 235 | }) |
231 | } | 236 | } |
232 | // 添加分红订单产品 | 237 | // 添加分红订单产品 |
238 | + if len(orderGoodsToAddModels) > 0 { | ||
233 | log.Logger.Info("待添加的分红订单产品", map[string]interface{}{ | 239 | log.Logger.Info("待添加的分红订单产品", map[string]interface{}{ |
234 | "orderGoodsToAddModels": orderGoodsToAddModels, | 240 | "orderGoodsToAddModels": orderGoodsToAddModels, |
235 | }) | 241 | }) |
236 | - if len(orderGoodsToAddModels) > 0 { | ||
237 | if _, err := tx.Model(&orderGoodsToAddModels).Insert(); err != nil { | 242 | if _, err := tx.Model(&orderGoodsToAddModels).Insert(); err != nil { |
238 | return nil, err | 243 | return nil, err |
239 | } | 244 | } |
@@ -491,6 +496,12 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | @@ -491,6 +496,12 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | ||
491 | if dividendsOrderNumber, ok := queryOptions["dividendsOrderNumber"]; ok && dividendsOrderNumber != "" { | 496 | if dividendsOrderNumber, ok := queryOptions["dividendsOrderNumber"]; ok && dividendsOrderNumber != "" { |
492 | query.Where("dividends_order.dividends_order_number = ?", dividendsOrderNumber) | 497 | query.Where("dividends_order.dividends_order_number = ?", dividendsOrderNumber) |
493 | } | 498 | } |
499 | + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { | ||
500 | + query.Where("company->>'companyId' = '?'", companyId) | ||
501 | + } | ||
502 | + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { | ||
503 | + query.Where("org->>'orgId' = '?'", orgId) | ||
504 | + } | ||
494 | if err := query.First(); err != nil { | 505 | if err := query.First(); err != nil { |
495 | if err.Error() == "pg: no rows in result set" { | 506 | if err.Error() == "pg: no rows in result set" { |
496 | return nil, fmt.Errorf("分红订单不存在") | 507 | return nil, fmt.Errorf("分红订单不存在") |
@@ -475,7 +475,8 @@ func (repository *DividendsReturnedOrderRepository) BatchRemove(dividendsReturne | @@ -475,7 +475,8 @@ func (repository *DividendsReturnedOrderRepository) BatchRemove(dividendsReturne | ||
475 | if _, err := tx.Model(&orderGoodModels). | 475 | if _, err := tx.Model(&orderGoodModels). |
476 | Where("company_id = ?", dividendsReturnedOrder.Company.CompanyId). | 476 | Where("company_id = ?", dividendsReturnedOrder.Company.CompanyId). |
477 | Where("org_id = ?", dividendsReturnedOrder.Org.OrgId). | 477 | Where("org_id = ?", dividendsReturnedOrder.Org.OrgId). |
478 | - Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber).Delete(); err != nil { | 478 | + Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber). |
479 | + Delete(); err != nil { | ||
479 | return nil, err | 480 | return nil, err |
480 | } | 481 | } |
481 | } | 482 | } |
@@ -505,7 +506,8 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str | @@ -505,7 +506,8 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str | ||
505 | if err := orderGoodModelQuery. | 506 | if err := orderGoodModelQuery. |
506 | Where("company_id = ?", dividendsReturnedOrderModel.Company.CompanyId). | 507 | Where("company_id = ?", dividendsReturnedOrderModel.Company.CompanyId). |
507 | Where("org_id = ?", dividendsReturnedOrderModel.Org.OrgId). | 508 | Where("org_id = ?", dividendsReturnedOrderModel.Org.OrgId). |
508 | - Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber).Select(); err != nil { | 509 | + Where("dividends_returned_order_number = ?", dividendsReturnedOrderModel.DividendsReturnedOrderNumber). |
510 | + Select(); err != nil { | ||
509 | return nil, fmt.Errorf("分红退货单关联的产品不存在") | 511 | return nil, fmt.Errorf("分红退货单关联的产品不存在") |
510 | } | 512 | } |
511 | // 聚合分红退货单 | 513 | // 聚合分红退货单 |
@@ -15,14 +15,11 @@ import ( | @@ -15,14 +15,11 @@ import ( | ||
15 | 15 | ||
16 | type MoneyIncentivesRuleRepository struct { | 16 | type MoneyIncentivesRuleRepository struct { |
17 | transactionContext *pgTransaction.TransactionContext | 17 | transactionContext *pgTransaction.TransactionContext |
18 | + IdWorker *snowflake.IdWorker | ||
18 | } | 19 | } |
19 | 20 | ||
20 | func (repository *MoneyIncentivesRuleRepository) nextIdentify() (int64, error) { | 21 | func (repository *MoneyIncentivesRuleRepository) nextIdentify() (int64, error) { |
21 | - IdWorker, err := snowflake.NewIdWorker(1) | ||
22 | - if err != nil { | ||
23 | - return 0, err | ||
24 | - } | ||
25 | - id, err := IdWorker.NextId() | 22 | + id, err := repository.IdWorker.NextId() |
26 | return id, err | 23 | return id, err |
27 | } | 24 | } |
28 | 25 | ||
@@ -202,8 +199,13 @@ func NewMoneyIncentivesRuleRepository(transactionContext *pgTransaction.Transact | @@ -202,8 +199,13 @@ func NewMoneyIncentivesRuleRepository(transactionContext *pgTransaction.Transact | ||
202 | if transactionContext == nil { | 199 | if transactionContext == nil { |
203 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 200 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
204 | } else { | 201 | } else { |
202 | + idWorker, err := snowflake.NewIdWorker(1) | ||
203 | + if err != nil { | ||
204 | + return nil, err | ||
205 | + } | ||
205 | return &MoneyIncentivesRuleRepository{ | 206 | return &MoneyIncentivesRuleRepository{ |
206 | transactionContext: transactionContext, | 207 | transactionContext: transactionContext, |
208 | + IdWorker: idWorker, | ||
207 | }, nil | 209 | }, nil |
208 | } | 210 | } |
209 | } | 211 | } |
-
请 注册 或 登录 后发表评论