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 { type OtherShouldCollectionPart struct {
MaintenanceFee decimal.NullDecimal `json:"maintenanceFee"` LossFee decimal.NullDecimal `json:"lossFee"`
BasicFees decimal.Decimal `json:"basicFees"` BasicFees decimal.Decimal `json:"basicFees"`
} }
type MaintenancePart struct { type MaintenancePart struct {
BasicFees decimal.Decimal `json:"basicFees"` BasicFees decimal.Decimal `json:"basicFees"`
LossFee decimal.Decimal `json:"lossFee"` LossFee decimal.Decimal `json:"lossFee"`
PublicConsumptionFee decimal.Decimal `json:"publicConsumptionFee"` AdjustFee decimal.Decimal `json:"adjustFee"`
MaintenanceFee decimal.Decimal `json:"maintenanceFee"` LossProportion decimal.Decimal `json:"lossProporttion"`
FinalMaintenance decimal.Decimal `json:"finalMaintenance"` AdjustProportion decimal.Decimal `json:"adjustProportion"`
MaintenanceProportion decimal.Decimal `json:"maintenanceProportion"` AdjustPrice decimal.Decimal `json:"adjustPrice"`
MaintenancePrice decimal.Decimal `json:"maintenancePrice"`
PriceRatio decimal.Decimal `json:"priceRatio"`
} }
type EndUserSummary struct { type EndUserSummary struct {

View File

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