enhance(publicity):调整公示报表数据结构与计算。

This commit is contained in:
徐涛 2022-09-21 16:44:01 +08:00
parent c716de21aa
commit 9f68d3adea
2 changed files with 25 additions and 30 deletions

View File

@ -71,19 +71,17 @@ type LossPart struct {
}
type OtherShouldCollectionPart struct {
MaintenanceFee decimal.NullDecimal `json:"maintenanceFee"`
LossFee decimal.NullDecimal `json:"lossFee"`
BasicFees decimal.Decimal `json:"basicFees"`
}
type MaintenancePart struct {
BasicFees decimal.Decimal `json:"basicFees"`
LossFee decimal.Decimal `json:"lossFee"`
PublicConsumptionFee decimal.Decimal `json:"publicConsumptionFee"`
MaintenanceFee decimal.Decimal `json:"maintenanceFee"`
FinalMaintenance decimal.Decimal `json:"finalMaintenance"`
MaintenanceProportion decimal.Decimal `json:"maintenanceProportion"`
MaintenancePrice decimal.Decimal `json:"maintenancePrice"`
PriceRatio decimal.Decimal `json:"priceRatio"`
AdjustFee decimal.Decimal `json:"adjustFee"`
LossProportion decimal.Decimal `json:"lossProporttion"`
AdjustProportion decimal.Decimal `json:"adjustProportion"`
AdjustPrice decimal.Decimal `json:"adjustPrice"`
}
type EndUserSummary struct {

View File

@ -678,31 +678,28 @@ func (_ReportService) AssembleReportPublicity(reportId string) (*model.Publicity
Proportion: report.Summary.Publics.Proportion.Decimal,
}
otherCollection := model.OtherShouldCollectionPart{
MaintenanceFee: report.Summary.MaintenanceOverall,
LossFee: report.Summary.AuthorizeLossFee,
BasicFees: report.Summary.BasicFee.Add(report.Summary.AdjustFee),
}
finalMaintenance := lossPart.ConsumptionFee.Add(publicSummary.ConsumptionFee).Add(otherCollection.MaintenanceFee.Decimal).Add(otherCollection.BasicFees)
var maintenancePrice = decimal.Zero
finalAdjustFee := lossPart.AuthorizeConsumptionFee.Add(otherCollection.BasicFees)
var adjustPrice = decimal.Zero
if !endUserSummary.Overall.Equal(decimal.Zero) {
maintenancePrice = finalMaintenance.Div(endUserSummary.Overall).RoundBank(8)
adjustPrice = finalAdjustFee.Div(endUserSummary.Overall).RoundBank(8)
}
var maintenanceProportion = decimal.Zero
if !paidPart.OverallFee.Equal(decimal.Zero) || !otherCollection.MaintenanceFee.Decimal.Equal(decimal.Zero) {
maintenanceProportion = finalMaintenance.Div(paidPart.OverallFee.Add(otherCollection.MaintenanceFee.Decimal)).RoundBank(8)
}
var priceRatio = decimal.Zero
if !report.Summary.OverallPrice.Decimal.Equal(decimal.Zero) {
priceRatio = maintenancePrice.Div(report.Summary.OverallPrice.Decimal).RoundBank(8)
var adjustProportion = decimal.Zero
if !paidPart.OverallFee.Equal(decimal.Zero) {
adjustProportion = finalAdjustFee.Div(paidPart.OverallFee.Add(finalAdjustFee)).RoundBank(8)
}
maintenanceFees := model.MaintenancePart{
BasicFees: otherCollection.BasicFees,
LossFee: lossPart.ConsumptionFee,
PublicConsumptionFee: publicSummary.ConsumptionFee,
MaintenanceFee: otherCollection.MaintenanceFee.Decimal,
FinalMaintenance: finalMaintenance,
MaintenanceProportion: maintenanceProportion,
MaintenancePrice: maintenancePrice,
PriceRatio: priceRatio,
LossFee: lossPart.AuthorizeConsumptionFee,
AdjustFee: finalAdjustFee,
LossProportion: lossPart.Proportion,
AdjustPrice: adjustPrice,
AdjustProportion: adjustProportion,
}
if maintenanceFees.LossProportion.GreaterThan(decimal.NewFromFloat(0.1)) {
maintenanceFees.LossProportion = decimal.NewFromFloat(0.1)
}
endUsers := lo.Map(
report.EndUsers,