Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/allied-crea…
…tion-cooperation into test
正在显示
7 个修改的文件
包含
90 行增加
和
30 行删除
@@ -150,6 +150,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred | @@ -150,6 +150,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred | ||
150 | var goodAmountCount float64 | 150 | var goodAmountCount float64 |
151 | for _, dividendsEstimate := range dividendsEstimates { | 151 | for _, dividendsEstimate := range dividendsEstimates { |
152 | accountDetail = append(accountDetail, &domain.AccountDetail{ | 152 | accountDetail = append(accountDetail, &domain.AccountDetail{ |
153 | + DividendsEstimateOrderId: dividendsEstimate.DividendsEstimateId, | ||
153 | DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber, | 154 | DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber, |
154 | DividendsType: dividendsEstimate.DividendsType, | 155 | DividendsType: dividendsEstimate.DividendsType, |
155 | DividendsAmount: dividendsEstimate.DividendsAmount, | 156 | DividendsAmount: dividendsEstimate.DividendsAmount, |
@@ -393,6 +394,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred | @@ -393,6 +394,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred | ||
393 | defer func() { | 394 | defer func() { |
394 | _ = transactionContext.RollbackTransaction() | 395 | _ = transactionContext.RollbackTransaction() |
395 | }() | 396 | }() |
397 | + // 账期结算单仓储初始化 | ||
396 | var creditAccountRepository domain.CreditAccountRepository | 398 | var creditAccountRepository domain.CreditAccountRepository |
397 | if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{ | 399 | if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{ |
398 | "transactionContext": transactionContext, | 400 | "transactionContext": transactionContext, |
@@ -401,20 +403,55 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred | @@ -401,20 +403,55 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred | ||
401 | } else { | 403 | } else { |
402 | creditAccountRepository = value | 404 | creditAccountRepository = value |
403 | } | 405 | } |
404 | - creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{"creditAccountId": removeCreditAccountCommand.CreditAccountId}) | 406 | + |
407 | + // 分红预算单仓储初始化 | ||
408 | + var dividendsEstimateRepository domain.DividendsEstimateRepository | ||
409 | + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ | ||
410 | + "transactionContext": transactionContext, | ||
411 | + }); err != nil { | ||
412 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
413 | + } else { | ||
414 | + dividendsEstimateRepository = value | ||
415 | + } | ||
416 | + | ||
417 | + // 获取账期阶段单 | ||
418 | + creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{ | ||
419 | + "creditAccountId": removeCreditAccountCommand.CreditAccountId, | ||
420 | + }) | ||
405 | if err != nil { | 421 | if err != nil { |
406 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 422 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
407 | } | 423 | } |
408 | if creditAccount == nil { | 424 | if creditAccount == nil { |
409 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCreditAccountCommand.CreditAccountId, 10))) | 425 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCreditAccountCommand.CreditAccountId, 10))) |
410 | } | 426 | } |
411 | - if creditAccount, err := creditAccountRepository.Remove(creditAccount); err != nil { | 427 | + if creditAccountRemoved, err := creditAccountRepository.Remove(creditAccount); err != nil { |
412 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 428 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
413 | } else { | 429 | } else { |
430 | + // 更新相关分红预算单结算状态 | ||
431 | + dividendsEstimateIds := make([]int64, 0) | ||
432 | + if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ | ||
433 | + "dividendsEstimateIds": dividendsEstimateIds, | ||
434 | + }); err != nil { | ||
435 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
436 | + } else { | ||
437 | + if count > 0 { | ||
438 | + for i, dividendsEstimate := range dividendsEstimates { | ||
439 | + if !dividendsEstimate.IsCanceled { | ||
440 | + dividendsEstimates[i].DividendsAccountStatus = int32(1) | ||
441 | + } | ||
442 | + } | ||
443 | + // 保存分红预算单 | ||
444 | + _, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimates) | ||
445 | + if err3 != nil { | ||
446 | + return nil, err3 | ||
447 | + } | ||
448 | + } | ||
449 | + } | ||
450 | + | ||
414 | if err := transactionContext.CommitTransaction(); err != nil { | 451 | if err := transactionContext.CommitTransaction(); err != nil { |
415 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 452 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
416 | } | 453 | } |
417 | - return creditAccount, nil | 454 | + return creditAccountRemoved, nil |
418 | } | 455 | } |
419 | } | 456 | } |
420 | 457 |
@@ -237,7 +237,11 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat | @@ -237,7 +237,11 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat | ||
237 | 237 | ||
238 | // 校验是否能够取消 | 238 | // 校验是否能够取消 |
239 | if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销 | 239 | if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销 |
240 | - if count, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum}); err2 != nil { | 240 | + if count, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ |
241 | + "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, | ||
242 | + "companyId": dividendsEstimate.Company.CompanyId, | ||
243 | + "orgId": dividendsEstimate.Org.OrgId, | ||
244 | + }); err2 != nil { | ||
241 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error()) | 245 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error()) |
242 | } else { | 246 | } else { |
243 | if count > 0 { | 247 | if count > 0 { |
@@ -249,7 +253,11 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat | @@ -249,7 +253,11 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat | ||
249 | } | 253 | } |
250 | } | 254 | } |
251 | } else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红 | 255 | } else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红 |
252 | - if count, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(map[string]interface{}{"cooperationContractNumber": dividendsEstimate.CooperationContractNumber}); err3 != nil { | 256 | + if count, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(map[string]interface{}{ |
257 | + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | ||
258 | + "companyId": dividendsEstimate.Company.CompanyId, | ||
259 | + "orgId": dividendsEstimate.Org.OrgId, | ||
260 | + }); err3 != nil { | ||
253 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error()) | 261 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error()) |
254 | } else { | 262 | } else { |
255 | if count > 0 { | 263 | if count > 0 { |
@@ -347,10 +355,14 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | @@ -347,10 +355,14 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | ||
347 | 355 | ||
348 | // 校验是否能够取消 | 356 | // 校验是否能够取消 |
349 | if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销 | 357 | if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销 |
350 | - if count, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum}); err2 != nil { | 358 | + if countRelativeDividendsEstimates, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ |
359 | + "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, | ||
360 | + "companyId": dividendsEstimate.Company.CompanyId, | ||
361 | + "orgId": dividendsEstimate.Org.OrgId, | ||
362 | + }); err2 != nil { | ||
351 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error()) | 363 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error()) |
352 | } else { | 364 | } else { |
353 | - if count > 0 { | 365 | + if countRelativeDividendsEstimates > 0 { |
354 | for _, dividendsEstimateRelative := range dividendsEstimatesRelative { | 366 | for _, dividendsEstimateRelative := range dividendsEstimatesRelative { |
355 | if dividendsEstimateRelative.DividendsAccountStatus == domain.ACCOUNTED { | 367 | if dividendsEstimateRelative.DividendsAccountStatus == domain.ACCOUNTED { |
356 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已有相关分红预算单已结算,无法取消") | 368 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已有相关分红预算单已结算,无法取消") |
@@ -359,10 +371,14 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | @@ -359,10 +371,14 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | ||
359 | } | 371 | } |
360 | } | 372 | } |
361 | } else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红 | 373 | } else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红 |
362 | - if count, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(map[string]interface{}{"cooperationContractNumber": dividendsEstimate.CooperationContractNumber}); err3 != nil { | 374 | + if countRelativeDividendsEstimates, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(map[string]interface{}{ |
375 | + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | ||
376 | + "companyId": dividendsEstimate.Company.CompanyId, | ||
377 | + "orgId": dividendsEstimate.Org.OrgId, | ||
378 | + }); err3 != nil { | ||
363 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error()) | 379 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error()) |
364 | } else { | 380 | } else { |
365 | - if count > 0 { | 381 | + if countRelativeDividendsEstimates > 0 { |
366 | for _, dividendsEstimateRelative := range dividendsEstimatesRelative { | 382 | for _, dividendsEstimateRelative := range dividendsEstimatesRelative { |
367 | if dividendsEstimateRelative.DividendsAccountStatus == domain.ACCOUNTED { | 383 | if dividendsEstimateRelative.DividendsAccountStatus == domain.ACCOUNTED { |
368 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已有相关分红预算单已结算,无法取消") | 384 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已有相关分红预算单已结算,无法取消") |
@@ -1420,12 +1436,10 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | @@ -1420,12 +1436,10 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | ||
1420 | stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker) | 1436 | stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker) |
1421 | } | 1437 | } |
1422 | } | 1438 | } |
1423 | - break | ||
1424 | } else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励 | 1439 | } else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励 |
1425 | for i, _ := range stageUndertakerMap { | 1440 | for i, _ := range stageUndertakerMap { |
1426 | stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker) | 1441 | stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker) |
1427 | } | 1442 | } |
1428 | - break | ||
1429 | } | 1443 | } |
1430 | } | 1444 | } |
1431 | } | 1445 | } |
1 | package domain | 1 | package domain |
2 | 2 | ||
3 | type AccountDetail struct { | 3 | type AccountDetail struct { |
4 | - // 分红预算单号 | 4 | + // 分红预算单号ID |
5 | + DividendsEstimateOrderId int64 `json:"dividendsEstimateOrderId"` | ||
6 | + // 分红预算单编号 | ||
5 | DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"` | 7 | DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"` |
6 | // 分红类型,1订单分红,2退货冲销,3金额激励 | 8 | // 分红类型,1订单分红,2退货冲销,3金额激励 |
7 | DividendsType int32 `json:"dividendsType"` | 9 | DividendsType int32 `json:"dividendsType"` |
@@ -117,21 +117,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -117,21 +117,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
117 | continue | 117 | continue |
118 | } | 118 | } |
119 | 119 | ||
120 | - // 校验合约关联的项目是否已结束 | ||
121 | - //if cooperationProject.Status == 2 { | ||
122 | - // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ | ||
123 | - // DividendsUser: nil, | ||
124 | - // DividendsParticipateType: 0, | ||
125 | - // DividendsStage: 0, | ||
126 | - // DividendsAmount: 0, | ||
127 | - // OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber, | ||
128 | - // IsSuccessfully: false, | ||
129 | - // Reason: "共创项目" + orderGood.CooperationContractNumber + "已结束", | ||
130 | - // }) | ||
131 | - // continue | ||
132 | - // //return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s已结束", cooperationContract.CooperationProjectNumber)) | ||
133 | - //} | ||
134 | - | ||
135 | if orderGood.DividendsOrderNumber != "" { // 获取分红订单 | 120 | if orderGood.DividendsOrderNumber != "" { // 获取分红订单 |
136 | // 获取分红订单 | 121 | // 获取分红订单 |
137 | dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{ | 122 | dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{ |
@@ -190,6 +175,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -190,6 +175,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
190 | if dividendsIncentivesRuleMatched != nil { | 175 | if dividendsIncentivesRuleMatched != nil { |
191 | for _, undertaker := range cooperationContract.Undertakers { | 176 | for _, undertaker := range cooperationContract.Undertakers { |
192 | // 添加承接人分红预算信息详情 | 177 | // 添加承接人分红预算信息详情 |
178 | + if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 { | ||
193 | undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64() | 179 | undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64() |
194 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ | 180 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ |
195 | DividendsUser: &domain.User{ | 181 | DividendsUser: &domain.User{ |
@@ -212,8 +198,11 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -212,8 +198,11 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
212 | OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, | 198 | OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, |
213 | IsSuccessfully: true, | 199 | IsSuccessfully: true, |
214 | }) | 200 | }) |
201 | + } | ||
202 | + | ||
215 | // 添加推荐人分红预算信息详情 | 203 | // 添加推荐人分红预算信息详情 |
216 | if undertaker.Referrer != nil { | 204 | if undertaker.Referrer != nil { |
205 | + if dividendsIncentivesRuleMatched.ReferrerPercentage > 0 { | ||
217 | referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64() | 206 | referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64() |
218 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ | 207 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ |
219 | DividendsUser: &domain.User{ | 208 | DividendsUser: &domain.User{ |
@@ -236,8 +225,10 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -236,8 +225,10 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
236 | IsSuccessfully: true, | 225 | IsSuccessfully: true, |
237 | }) | 226 | }) |
238 | } | 227 | } |
228 | + } | ||
239 | // 添加关联业务员分红预算信息详情 | 229 | // 添加关联业务员分红预算信息详情 |
240 | if undertaker.Salesman != nil { | 230 | if undertaker.Salesman != nil { |
231 | + if dividendsIncentivesRuleMatched.SalesmanPercentage > 0 { | ||
241 | salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64() | 232 | salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64() |
242 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ | 233 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ |
243 | DividendsUser: &domain.User{ | 234 | DividendsUser: &domain.User{ |
@@ -262,6 +253,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -262,6 +253,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
262 | } | 253 | } |
263 | } | 254 | } |
264 | } | 255 | } |
256 | + } | ||
265 | } else if orderGood.DividendsReturnedOrderNumber != "" { // 获取退货单 | 257 | } else if orderGood.DividendsReturnedOrderNumber != "" { // 获取退货单 |
266 | dividendsReturnedOrder, err3 := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{ | 258 | dividendsReturnedOrder, err3 := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{ |
267 | "dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber, | 259 | "dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber, |
@@ -304,6 +296,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -304,6 +296,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
304 | // 计算分红 | 296 | // 计算分红 |
305 | for _, undertaker := range cooperationContract.Undertakers { | 297 | for _, undertaker := range cooperationContract.Undertakers { |
306 | // 添加承接人分红退货预算信息详情 | 298 | // 添加承接人分红退货预算信息详情 |
299 | + if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 { | ||
307 | undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64() | 300 | undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64() |
308 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ | 301 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ |
309 | DividendsUser: &domain.User{ | 302 | DividendsUser: &domain.User{ |
@@ -326,8 +319,11 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -326,8 +319,11 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
326 | OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsOrderNumber, | 319 | OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsOrderNumber, |
327 | IsSuccessfully: true, | 320 | IsSuccessfully: true, |
328 | }) | 321 | }) |
322 | + } | ||
323 | + | ||
329 | // 添加推荐人分红退货预算信息详情 | 324 | // 添加推荐人分红退货预算信息详情 |
330 | if undertaker.Referrer != nil { | 325 | if undertaker.Referrer != nil { |
326 | + if dividendsIncentivesRuleMatched.ReferrerPercentage > 0 { | ||
331 | referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64() | 327 | referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64() |
332 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ | 328 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ |
333 | DividendsUser: &domain.User{ | 329 | DividendsUser: &domain.User{ |
@@ -350,8 +346,11 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -350,8 +346,11 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
350 | IsSuccessfully: true, | 346 | IsSuccessfully: true, |
351 | }) | 347 | }) |
352 | } | 348 | } |
349 | + } | ||
350 | + | ||
353 | // 添加关联业务员分红退货预算信息详情 | 351 | // 添加关联业务员分红退货预算信息详情 |
354 | if undertaker.Salesman != nil { | 352 | if undertaker.Salesman != nil { |
353 | + if dividendsIncentivesRuleMatched.SalesmanPercentage > 0 { | ||
355 | salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64() | 354 | salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64() |
356 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ | 355 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ |
357 | DividendsUser: &domain.User{ | 356 | DividendsUser: &domain.User{ |
@@ -374,6 +373,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -374,6 +373,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
374 | IsSuccessfully: true, | 373 | IsSuccessfully: true, |
375 | }) | 374 | }) |
376 | } | 375 | } |
376 | + | ||
377 | + } | ||
377 | } | 378 | } |
378 | } | 379 | } |
379 | } | 380 | } |
1 | package transform | 1 | package transform |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "github.com/shopspring/decimal" | ||
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" |
6 | ) | 7 | ) |
7 | 8 | ||
8 | func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel *models.DividendsEstimate) (*domain.DividendsEstimate, error) { | 9 | func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel *models.DividendsEstimate) (*domain.DividendsEstimate, error) { |
10 | + dividendsAmount, _ := decimal.NewFromFloatWithExponent(dividendsEstimateModel.DividendsAmount, -2).Float64() | ||
9 | return &domain.DividendsEstimate{ | 11 | return &domain.DividendsEstimate{ |
10 | DividendsEstimateId: dividendsEstimateModel.DividendsEstimateId, | 12 | DividendsEstimateId: dividendsEstimateModel.DividendsEstimateId, |
11 | DividendsAccountStatus: dividendsEstimateModel.DividendsAccountStatus, | 13 | DividendsAccountStatus: dividendsEstimateModel.DividendsAccountStatus, |
12 | - DividendsAmount: dividendsEstimateModel.DividendsAmount, | 14 | + DividendsAmount: dividendsAmount, |
13 | DividendsEstimateOrderNumber: dividendsEstimateModel.DividendsEstimateOrderNumber, | 15 | DividendsEstimateOrderNumber: dividendsEstimateModel.DividendsEstimateOrderNumber, |
14 | DividendsEstimateTime: dividendsEstimateModel.DividendsEstimateTime, | 16 | DividendsEstimateTime: dividendsEstimateModel.DividendsEstimateTime, |
15 | DividendsParticipateType: dividendsEstimateModel.DividendsParticipateType, | 17 | DividendsParticipateType: dividendsEstimateModel.DividendsParticipateType, |
1 | package transform | 1 | package transform |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "github.com/shopspring/decimal" | ||
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" |
6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" |
@@ -8,10 +9,11 @@ import ( | @@ -8,10 +9,11 @@ import ( | ||
8 | 9 | ||
9 | func TransformToMoneyIncentivesRuleDomainModelFromPgModels(moneyIncentivesRuleModel *models.MoneyIncentivesRule) (*domain.MoneyIncentivesRule, error) { | 10 | func TransformToMoneyIncentivesRuleDomainModelFromPgModels(moneyIncentivesRuleModel *models.MoneyIncentivesRule) (*domain.MoneyIncentivesRule, error) { |
10 | stageString := utils.NumberToCNNumber(int(moneyIncentivesRuleModel.MoneyIncentivesStage)) | 11 | stageString := utils.NumberToCNNumber(int(moneyIncentivesRuleModel.MoneyIncentivesStage)) |
12 | + moneyIncentivesAmount, _ := decimal.NewFromFloatWithExponent(moneyIncentivesRuleModel.MoneyIncentivesAmount, -2).Float64() | ||
11 | return &domain.MoneyIncentivesRule{ | 13 | return &domain.MoneyIncentivesRule{ |
12 | MoneyIncentivesRuleId: moneyIncentivesRuleModel.MoneyIncentivesRuleId, | 14 | MoneyIncentivesRuleId: moneyIncentivesRuleModel.MoneyIncentivesRuleId, |
13 | CooperationContractNumber: moneyIncentivesRuleModel.CooperationContractNumber, | 15 | CooperationContractNumber: moneyIncentivesRuleModel.CooperationContractNumber, |
14 | - MoneyIncentivesAmount: moneyIncentivesRuleModel.MoneyIncentivesAmount, | 16 | + MoneyIncentivesAmount: moneyIncentivesAmount, |
15 | MoneyIncentivesStage: moneyIncentivesRuleModel.MoneyIncentivesStage, | 17 | MoneyIncentivesStage: moneyIncentivesRuleModel.MoneyIncentivesStage, |
16 | MoneyIncentivesStageCN: stageString, | 18 | MoneyIncentivesStageCN: stageString, |
17 | MoneyIncentivesStageEnd: moneyIncentivesRuleModel.MoneyIncentivesStageEnd, | 19 | MoneyIncentivesStageEnd: moneyIncentivesRuleModel.MoneyIncentivesStageEnd, |
1 | package transform | 1 | package transform |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "github.com/shopspring/decimal" | ||
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" |
6 | ) | 7 | ) |
7 | 8 | ||
8 | func TransformToOrderGoodDomainModelFromPgModels(orderGoodModel *models.OrderGood) (*domain.OrderGood, error) { | 9 | func TransformToOrderGoodDomainModelFromPgModels(orderGoodModel *models.OrderGood) (*domain.OrderGood, error) { |
10 | + orderGoodAmount, _ := decimal.NewFromFloatWithExponent(orderGoodModel.OrderGoodAmount, -2).Float64() | ||
9 | return &domain.OrderGood{ | 11 | return &domain.OrderGood{ |
10 | OrderGoodId: orderGoodModel.OrderGoodId, | 12 | OrderGoodId: orderGoodModel.OrderGoodId, |
11 | - OrderGoodAmount: orderGoodModel.OrderGoodAmount, | 13 | + OrderGoodAmount: orderGoodAmount, |
12 | OrderGoodName: orderGoodModel.OrderGoodName, | 14 | OrderGoodName: orderGoodModel.OrderGoodName, |
13 | OrderGoodPrice: orderGoodModel.OrderGoodPrice, | 15 | OrderGoodPrice: orderGoodModel.OrderGoodPrice, |
14 | OrderGoodQuantity: orderGoodModel.OrderGoodQuantity, | 16 | OrderGoodQuantity: orderGoodModel.OrderGoodQuantity, |
-
请 注册 或 登录 后发表评论