fix(calculate_tenement):修复计算相关赋值问题
This commit is contained in:
parent
2844db1a86
commit
eaf45331f1
|
@ -283,6 +283,7 @@ func ShiftToAsiaShanghai(t time.Time) time.Time {
|
|||
func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
||||
summary calculate.Summary, meters MeterMap) []calculate.TenementCharge {
|
||||
result := make(map[string][]string)
|
||||
var tc []calculate.TenementCharge
|
||||
for _, t := range tenements {
|
||||
meterCodes := make([]string, 0)
|
||||
for _, m := range t.Meters {
|
||||
|
@ -292,7 +293,6 @@ func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
|||
result[t.Tenement.Id] = meterCodes
|
||||
}
|
||||
var Key Key
|
||||
var tc []calculate.TenementCharge
|
||||
for tCode, meterCodes := range result {
|
||||
relatedMeters := make([]calculate.Meter, 0)
|
||||
for _, code := range meterCodes {
|
||||
|
@ -302,6 +302,11 @@ func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
|||
relatedMeters = append(relatedMeters, meter)
|
||||
}
|
||||
}
|
||||
fmt.Println("---", relatedMeters[0].Valley)
|
||||
fmt.Println("---", relatedMeters[0].Flat)
|
||||
fmt.Println("---", relatedMeters[0].Peak)
|
||||
fmt.Println("---", relatedMeters[0].Overall)
|
||||
fmt.Println("---", relatedMeters[0].Critical)
|
||||
// 计算商户的合计电费信息
|
||||
var overall model.ConsumptionUnit
|
||||
var critical model.ConsumptionUnit
|
||||
|
@ -401,7 +406,6 @@ func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
|||
}
|
||||
|
||||
var CriticalProportion decimal.Decimal
|
||||
fmt.Println(summary.Critical.Amount == decimal.Zero)
|
||||
if summary.Critical.Amount.InexactFloat64() == decimal.Zero.InexactFloat64() {
|
||||
CriticalProportion = decimal.Zero
|
||||
} else {
|
||||
|
@ -429,28 +433,50 @@ func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
|||
ValleyProportion = decimal.NewFromFloat(valley.Amount.InexactFloat64() / summary.Valley.Amount.InexactFloat64())
|
||||
}
|
||||
|
||||
var lossProportion decimal.Decimal
|
||||
if summary.AuthoizeLoss.Amount == decimal.Zero {
|
||||
lossProportion = decimal.Zero
|
||||
} else {
|
||||
lossProportion = decimal.NewFromFloat(lossAmount.InexactFloat64() / summary.AuthoizeLoss.Amount.InexactFloat64())
|
||||
}
|
||||
tenementCharge := calculate.TenementCharge{
|
||||
Tenement: tCode,
|
||||
Overall: model.ConsumptionUnit{
|
||||
Amount: overall.Amount,
|
||||
Fee: overall.Fee,
|
||||
Price: summary.Overall.Price,
|
||||
Proportion: OverallProportion,
|
||||
},
|
||||
Critical: model.ConsumptionUnit{
|
||||
Amount: critical.Amount,
|
||||
Fee: critical.Fee,
|
||||
Price: summary.Critical.Price,
|
||||
Proportion: CriticalProportion,
|
||||
},
|
||||
Peak: model.ConsumptionUnit{
|
||||
Price: summary.Overall.Price,
|
||||
Amount: peak.Amount,
|
||||
Fee: peak.Fee,
|
||||
Price: summary.Peak.Price,
|
||||
Proportion: PeakProportion,
|
||||
},
|
||||
Flat: model.ConsumptionUnit{
|
||||
Price: summary.Overall.Price,
|
||||
Amount: flat.Amount,
|
||||
Fee: flat.Fee,
|
||||
Price: summary.Flat.Price,
|
||||
Proportion: FlatProportion,
|
||||
},
|
||||
Valley: model.ConsumptionUnit{
|
||||
Price: summary.Overall.Price,
|
||||
Amount: valley.Amount,
|
||||
Fee: valley.Fee,
|
||||
Price: summary.Valley.Price,
|
||||
Proportion: ValleyProportion,
|
||||
},
|
||||
Loss: model.ConsumptionUnit{
|
||||
Amount: lossAmount,
|
||||
Fee: lossPooled,
|
||||
Price: summary.AuthoizeLoss.Price,
|
||||
Proportion: lossProportion,
|
||||
},
|
||||
BasicFee: basicPooled,
|
||||
AdjustFee: adjustPooled,
|
||||
LossPooled: lossPooled,
|
||||
|
@ -462,10 +488,10 @@ func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
|||
Submeters: nil,
|
||||
Poolings: nil,
|
||||
}
|
||||
|
||||
fmt.Println("=====", tenementCharge)
|
||||
tc = append(tc, tenementCharge)
|
||||
}
|
||||
}
|
||||
fmt.Println(tc)
|
||||
//fmt.Println(len(tc))
|
||||
return tc
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user