forked from free-lancers/electricity_bill_calc_service
		
	enhance(publicity):调整公示报表数据结构与计算。
This commit is contained in:
		| @@ -71,19 +71,17 @@ type LossPart struct { | ||||
| } | ||||
|  | ||||
| type OtherShouldCollectionPart struct { | ||||
| 	MaintenanceFee decimal.NullDecimal `json:"maintenanceFee"` | ||||
| 	BasicFees      decimal.Decimal     `json:"basicFees"` | ||||
| 	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"` | ||||
| 	BasicFees        decimal.Decimal `json:"basicFees"` | ||||
| 	LossFee          decimal.Decimal `json:"lossFee"` | ||||
| 	AdjustFee        decimal.Decimal `json:"adjustFee"` | ||||
| 	LossProportion   decimal.Decimal `json:"lossProporttion"` | ||||
| 	AdjustProportion decimal.Decimal `json:"adjustProportion"` | ||||
| 	AdjustPrice      decimal.Decimal `json:"adjustPrice"` | ||||
| } | ||||
|  | ||||
| type EndUserSummary struct { | ||||
|   | ||||
| @@ -678,31 +678,28 @@ func (_ReportService) AssembleReportPublicity(reportId string) (*model.Publicity | ||||
| 		Proportion:     report.Summary.Publics.Proportion.Decimal, | ||||
| 	} | ||||
| 	otherCollection := model.OtherShouldCollectionPart{ | ||||
| 		MaintenanceFee: report.Summary.MaintenanceOverall, | ||||
| 		BasicFees:      report.Summary.BasicFee.Add(report.Summary.AdjustFee), | ||||
| 		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, | ||||
| 		BasicFees:        otherCollection.BasicFees, | ||||
| 		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, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user