正在显示
1 个修改的文件
包含
22 行增加
和
11 行删除
@@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository" |
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" |
11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" | ||
11 | ) | 12 | ) |
12 | 13 | ||
13 | type CancelDividendsEstimateService struct { | 14 | type CancelDividendsEstimateService struct { |
@@ -21,6 +22,12 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -21,6 +22,12 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
21 | var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 | 22 | var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 |
22 | var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储 | 23 | var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储 |
23 | 24 | ||
25 | + type orderGoodInfo struct { | ||
26 | + OrderGoodId int64 | ||
27 | + CompanyId int64 | ||
28 | + OrgId int64 | ||
29 | + } | ||
30 | + | ||
24 | // 分红预算单仓储初始化 | 31 | // 分红预算单仓储初始化 |
25 | if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil { | 32 | if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil { |
26 | return nil, err | 33 | return nil, err |
@@ -60,6 +67,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -60,6 +67,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
60 | var dividendsEstimatesCanceled []*domain.DividendsEstimate | 67 | var dividendsEstimatesCanceled []*domain.DividendsEstimate |
61 | var orderOrReturnOrderNums []string | 68 | var orderOrReturnOrderNums []string |
62 | var orderGoodIds []int64 | 69 | var orderGoodIds []int64 |
70 | + orderGoodMaps := make(map[string][]int64, 0) | ||
63 | for _, dividendsEstimate := range dividendsEstimates { | 71 | for _, dividendsEstimate := range dividendsEstimates { |
64 | if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销 | 72 | if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销 |
65 | // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 | 73 | // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 |
@@ -83,6 +91,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -83,6 +91,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
83 | // 获取相关订单/退货单号 | 91 | // 获取相关订单/退货单号 |
84 | orderOrReturnOrderNums = append(orderOrReturnOrderNums, dividendsEstimatesRelative[i].OrderOrReturnedOrderNum) | 92 | orderOrReturnOrderNums = append(orderOrReturnOrderNums, dividendsEstimatesRelative[i].OrderOrReturnedOrderNum) |
85 | orderGoodIds = append(orderGoodIds, dividendsEstimatesRelative[i].OrderGoodId) | 93 | orderGoodIds = append(orderGoodIds, dividendsEstimatesRelative[i].OrderGoodId) |
94 | + orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum] = append(orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum], dividendsEstimatesRelative[i].OrderGoodId) | ||
86 | } | 95 | } |
87 | dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) | 96 | dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) |
88 | if err3 != nil { | 97 | if err3 != nil { |
@@ -151,18 +160,20 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -151,18 +160,20 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
151 | }); err4 != nil { | 160 | }); err4 != nil { |
152 | return nil, err4 | 161 | return nil, err4 |
153 | } else { | 162 | } else { |
154 | - // orderGoodIds去重 | ||
155 | - newOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodIds) | 163 | + |
156 | if countDividendsOrder > 0 { | 164 | if countDividendsOrder > 0 { |
157 | for i, order := range orders { | 165 | for i, order := range orders { |
166 | + // 取消分红的订单产品 | ||
167 | + newOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodMaps[order.DividendsOrderNumber]) | ||
158 | var goodIds []int64 | 168 | var goodIds []int64 |
159 | for _, good := range order.Goods { | 169 | for _, good := range order.Goods { |
160 | if good.OrderGoodDividendsStatus == 2 { | 170 | if good.OrderGoodDividendsStatus == 2 { |
161 | goodIds = append(goodIds, good.OrderGoodId) | 171 | goodIds = append(goodIds, good.OrderGoodId) |
162 | } | 172 | } |
163 | } | 173 | } |
164 | - // goodIds去重 | 174 | + // goodIds去重 |
165 | newGoodIds := utils.RemoveDuplicationInt64(goodIds) | 175 | newGoodIds := utils.RemoveDuplicationInt64(goodIds) |
176 | + log.Logger.Info("") | ||
166 | if len(newGoodIds) == len(newOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,订单分红状态变更为未分红 | 177 | if len(newGoodIds) == len(newOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,订单分红状态变更为未分红 |
167 | orders[i].DividendStatus = 1 | 178 | orders[i].DividendStatus = 1 |
168 | } else if len(newGoodIds) > len(newOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,订单分红状态变更为部分分红 | 179 | } else if len(newGoodIds) > len(newOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,订单分红状态变更为部分分红 |
@@ -216,21 +227,21 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -216,21 +227,21 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
216 | }); err5 != nil { | 227 | }); err5 != nil { |
217 | return nil, err5 | 228 | return nil, err5 |
218 | } else { | 229 | } else { |
219 | - // orderGoodIds去重 | ||
220 | - newReturnedOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodIds) | ||
221 | - | ||
222 | if countDividendsReturnedOrder > 0 { | 230 | if countDividendsReturnedOrder > 0 { |
223 | for i, returnedOrder := range returnedOrders { | 231 | for i, returnedOrder := range returnedOrders { |
224 | - goods := make([]*domain.OrderGood, 0) | 232 | + // 已取消的退货单产品 |
233 | + newReturnedOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodMaps[returnedOrder.DividendsOrderNumber]) | ||
234 | + var goodIds []int64 | ||
225 | for _, good := range returnedOrder.Goods { | 235 | for _, good := range returnedOrder.Goods { |
226 | if good.OrderGoodDividendsStatus == 2 { | 236 | if good.OrderGoodDividendsStatus == 2 { |
227 | - goods = append(goods, good) | 237 | + goodIds = append(goodIds, good.OrderGoodId) |
228 | } | 238 | } |
229 | } | 239 | } |
230 | - | ||
231 | - if len(goods) == len(newReturnedOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,退货单分红状态变更为未分红 | 240 | + // goodIds去重 |
241 | + newGoodIds := utils.RemoveDuplicationInt64(goodIds) | ||
242 | + if len(newGoodIds) == len(newReturnedOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,退货单分红状态变更为未分红 | ||
232 | returnedOrders[i].DividendStatus = 1 | 243 | returnedOrders[i].DividendStatus = 1 |
233 | - } else if len(goods) > len(newReturnedOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,退货单分红状态变更为部分分红 | 244 | + } else if len(newGoodIds) > len(newReturnedOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,退货单分红状态变更为部分分红 |
234 | returnedOrders[i].DividendStatus = 3 | 245 | returnedOrders[i].DividendStatus = 3 |
235 | } | 246 | } |
236 | returnedOrders[i].DividendStatus = returnedOrder.DividendStatus | 247 | returnedOrders[i].DividendStatus = returnedOrder.DividendStatus |
-
请 注册 或 登录 后发表评论