合并分支 'dev' 到 'test'
Dev 查看合并请求 !35
正在显示
4 个修改的文件
包含
51 行增加
和
3 行删除
@@ -809,6 +809,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -809,6 +809,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
809 | dividendsReturnedOrderNumbers := make([]string, 0) | 809 | dividendsReturnedOrderNumbers := make([]string, 0) |
810 | if len(estimateSuccessfullyDividendsOrders) > 0 { | 810 | if len(estimateSuccessfullyDividendsOrders) > 0 { |
811 | for k, _ := range estimateSuccessfullyDividendsOrders { | 811 | for k, _ := range estimateSuccessfullyDividendsOrders { |
812 | + if k != "" { | ||
812 | if k[:2] == "RE" { // 分红退货单 | 813 | if k[:2] == "RE" { // 分红退货单 |
813 | dividendsReturnedOrderNumbers = append(dividendsReturnedOrderNumbers, k) | 814 | dividendsReturnedOrderNumbers = append(dividendsReturnedOrderNumbers, k) |
814 | } else if k[:2] == "SL" { // 分红订单 | 815 | } else if k[:2] == "SL" { // 分红订单 |
@@ -816,6 +817,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -816,6 +817,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
816 | } | 817 | } |
817 | } | 818 | } |
818 | } | 819 | } |
820 | + } | ||
819 | 821 | ||
820 | log.Logger.Info("分红订单", map[string]interface{}{ | 822 | log.Logger.Info("分红订单", map[string]interface{}{ |
821 | "dividendsOrderNumbers": dividendsOrderNumbers, | 823 | "dividendsOrderNumbers": dividendsOrderNumbers, |
@@ -1001,6 +1001,8 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | @@ -1001,6 +1001,8 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | ||
1001 | defer func() { | 1001 | defer func() { |
1002 | _ = transactionContext.RollbackTransaction() | 1002 | _ = transactionContext.RollbackTransaction() |
1003 | }() | 1003 | }() |
1004 | + | ||
1005 | + // 分红订单仓储初始化 | ||
1004 | var dividendsOrderRepository domain.DividendsOrderRepository | 1006 | var dividendsOrderRepository domain.DividendsOrderRepository |
1005 | if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{ | 1007 | if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{ |
1006 | "transactionContext": transactionContext, | 1008 | "transactionContext": transactionContext, |
@@ -1010,6 +1012,16 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | @@ -1010,6 +1012,16 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | ||
1010 | dividendsOrderRepository = value | 1012 | dividendsOrderRepository = value |
1011 | } | 1013 | } |
1012 | 1014 | ||
1015 | + // 分红退货单仓储初始化 | ||
1016 | + var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository | ||
1017 | + if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{ | ||
1018 | + "transactionContext": transactionContext, | ||
1019 | + }); err != nil { | ||
1020 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1021 | + } else { | ||
1022 | + dividendsReturnedOrderRepository = value | ||
1023 | + } | ||
1024 | + | ||
1013 | dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds) | 1025 | dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds) |
1014 | if err != nil { | 1026 | if err != nil { |
1015 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误") | 1027 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误") |
@@ -1020,6 +1032,22 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | @@ -1020,6 +1032,22 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | ||
1020 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1032 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1021 | } else { | 1033 | } else { |
1022 | if count > 0 { | 1034 | if count > 0 { |
1035 | + // 校验分红订单是否有退货单关联 | ||
1036 | + for _, dividendsOrder := range dividendsOrders { | ||
1037 | + if countReturnedOrder, dividendsReturnedOrders, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{ | ||
1038 | + "dividendsOrderNumber": dividendsOrder.DividendsOrderNumber, | ||
1039 | + "companyId": dividendsOrder.Company.CompanyId, | ||
1040 | + "limit": 1, | ||
1041 | + "offset": 0, | ||
1042 | + }); err != nil { | ||
1043 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1044 | + } else { | ||
1045 | + if countReturnedOrder > 0 { | ||
1046 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsReturnedOrders[0].DividendsOrderNumber)) | ||
1047 | + } | ||
1048 | + } | ||
1049 | + } | ||
1050 | + | ||
1023 | dividendsOrdersRemoved, err := dividendsOrderRepository.BatchRemove(dividendsOrders) | 1051 | dividendsOrdersRemoved, err := dividendsOrderRepository.BatchRemove(dividendsOrders) |
1024 | if err != nil { | 1052 | if err != nil { |
1025 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1053 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -1007,6 +1007,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) BatchRemoveD | @@ -1007,6 +1007,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) BatchRemoveD | ||
1007 | defer func() { | 1007 | defer func() { |
1008 | _ = transactionContext.RollbackTransaction() | 1008 | _ = transactionContext.RollbackTransaction() |
1009 | }() | 1009 | }() |
1010 | + | ||
1011 | + // 分红退货单仓储初始化 | ||
1010 | var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository | 1012 | var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository |
1011 | if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{ | 1013 | if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{ |
1012 | "transactionContext": transactionContext, | 1014 | "transactionContext": transactionContext, |
@@ -1149,6 +1151,16 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | @@ -1149,6 +1151,16 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | ||
1149 | cooperationContractRepository = value | 1151 | cooperationContractRepository = value |
1150 | } | 1152 | } |
1151 | 1153 | ||
1154 | + // 产品仓储初始化 | ||
1155 | + var orderGoodRepository domain.OrderGoodRepository | ||
1156 | + if value, err := factory.CreateOrderGoodRepository(map[string]interface{}{ | ||
1157 | + "transactionContext": transactionContext, | ||
1158 | + }); err != nil { | ||
1159 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1160 | + } else { | ||
1161 | + orderGoodRepository = value | ||
1162 | + } | ||
1163 | + | ||
1152 | // 查找合约 | 1164 | // 查找合约 |
1153 | cooperationContractsMap := make(map[string]*domain.CooperationContract) | 1165 | cooperationContractsMap := make(map[string]*domain.CooperationContract) |
1154 | if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{ | 1166 | if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{ |
@@ -1175,6 +1187,14 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | @@ -1175,6 +1187,14 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | ||
1175 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error()) | 1187 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error()) |
1176 | } | 1188 | } |
1177 | 1189 | ||
1190 | + // 获取产品 | ||
1191 | + orderGoodFound, err4 := orderGoodRepository.FindOne(map[string]interface{}{ | ||
1192 | + "orderGoodId": orderGoodId, | ||
1193 | + }) | ||
1194 | + if err4 != nil { | ||
1195 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error()) | ||
1196 | + } | ||
1197 | + | ||
1178 | // 退货产品金额计算 | 1198 | // 退货产品金额计算 |
1179 | orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64() | 1199 | orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64() |
1180 | 1200 | ||
@@ -1209,6 +1229,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | @@ -1209,6 +1229,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | ||
1209 | DividendsReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, | 1229 | DividendsReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, |
1210 | CooperationContractNumber: orderGood.CooperationContractNumber, | 1230 | CooperationContractNumber: orderGood.CooperationContractNumber, |
1211 | OrderGoodExpense: orderGood.OrderGoodExpense, | 1231 | OrderGoodExpense: orderGood.OrderGoodExpense, |
1232 | + OrderGoodDividendsStatus: orderGoodFound.OrderGoodDividendsStatus, | ||
1212 | OrgId: updateDividendsReturnedOrderCommand.OrgId, | 1233 | OrgId: updateDividendsReturnedOrderCommand.OrgId, |
1213 | CompanyId: updateDividendsReturnedOrderCommand.CompanyId, | 1234 | CompanyId: updateDividendsReturnedOrderCommand.CompanyId, |
1214 | CreatedAt: time.Time{}, | 1235 | CreatedAt: time.Time{}, |
@@ -73,9 +73,6 @@ func (dividendsReturnedOrder *DividendsReturnedOrder) Identify() interface{} { | @@ -73,9 +73,6 @@ func (dividendsReturnedOrder *DividendsReturnedOrder) Identify() interface{} { | ||
73 | } | 73 | } |
74 | 74 | ||
75 | func (dividendsReturnedOrder *DividendsReturnedOrder) Update(data map[string]interface{}) error { | 75 | func (dividendsReturnedOrder *DividendsReturnedOrder) Update(data map[string]interface{}) error { |
76 | - if dividendsReturnedOrderRefund, ok := data["dividendsReturnedOrderRefund"]; ok { | ||
77 | - dividendsReturnedOrder.DividendsReturnedOrderRefund = dividendsReturnedOrderRefund.(float64) | ||
78 | - } | ||
79 | if originalOrderNum, ok := data["originalOrderNum"]; ok { | 76 | if originalOrderNum, ok := data["originalOrderNum"]; ok { |
80 | dividendsReturnedOrder.OriginalOrderNum = originalOrderNum.(string) | 77 | dividendsReturnedOrder.OriginalOrderNum = originalOrderNum.(string) |
81 | } | 78 | } |
-
请 注册 或 登录 后发表评论