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,
|
func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
||||||
summary calculate.Summary, meters MeterMap) []calculate.TenementCharge {
|
summary calculate.Summary, meters MeterMap) []calculate.TenementCharge {
|
||||||
result := make(map[string][]string)
|
result := make(map[string][]string)
|
||||||
|
var tc []calculate.TenementCharge
|
||||||
for _, t := range tenements {
|
for _, t := range tenements {
|
||||||
meterCodes := make([]string, 0)
|
meterCodes := make([]string, 0)
|
||||||
for _, m := range t.Meters {
|
for _, m := range t.Meters {
|
||||||
|
@ -292,7 +293,6 @@ func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
||||||
result[t.Tenement.Id] = meterCodes
|
result[t.Tenement.Id] = meterCodes
|
||||||
}
|
}
|
||||||
var Key Key
|
var Key Key
|
||||||
var tc []calculate.TenementCharge
|
|
||||||
for tCode, meterCodes := range result {
|
for tCode, meterCodes := range result {
|
||||||
relatedMeters := make([]calculate.Meter, 0)
|
relatedMeters := make([]calculate.Meter, 0)
|
||||||
for _, code := range meterCodes {
|
for _, code := range meterCodes {
|
||||||
|
@ -302,6 +302,11 @@ func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
||||||
relatedMeters = append(relatedMeters, meter)
|
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 overall model.ConsumptionUnit
|
||||||
var critical model.ConsumptionUnit
|
var critical model.ConsumptionUnit
|
||||||
|
@ -401,7 +406,6 @@ func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
||||||
}
|
}
|
||||||
|
|
||||||
var CriticalProportion decimal.Decimal
|
var CriticalProportion decimal.Decimal
|
||||||
fmt.Println(summary.Critical.Amount == decimal.Zero)
|
|
||||||
if summary.Critical.Amount.InexactFloat64() == decimal.Zero.InexactFloat64() {
|
if summary.Critical.Amount.InexactFloat64() == decimal.Zero.InexactFloat64() {
|
||||||
CriticalProportion = decimal.Zero
|
CriticalProportion = decimal.Zero
|
||||||
} else {
|
} else {
|
||||||
|
@ -429,28 +433,50 @@ func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
||||||
ValleyProportion = decimal.NewFromFloat(valley.Amount.InexactFloat64() / summary.Valley.Amount.InexactFloat64())
|
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{
|
tenementCharge := calculate.TenementCharge{
|
||||||
Tenement: tCode,
|
Tenement: tCode,
|
||||||
Overall: model.ConsumptionUnit{
|
Overall: model.ConsumptionUnit{
|
||||||
|
Amount: overall.Amount,
|
||||||
|
Fee: overall.Fee,
|
||||||
Price: summary.Overall.Price,
|
Price: summary.Overall.Price,
|
||||||
Proportion: OverallProportion,
|
Proportion: OverallProportion,
|
||||||
},
|
},
|
||||||
Critical: model.ConsumptionUnit{
|
Critical: model.ConsumptionUnit{
|
||||||
|
Amount: critical.Amount,
|
||||||
|
Fee: critical.Fee,
|
||||||
Price: summary.Critical.Price,
|
Price: summary.Critical.Price,
|
||||||
Proportion: CriticalProportion,
|
Proportion: CriticalProportion,
|
||||||
},
|
},
|
||||||
Peak: model.ConsumptionUnit{
|
Peak: model.ConsumptionUnit{
|
||||||
Price: summary.Overall.Price,
|
Amount: peak.Amount,
|
||||||
|
Fee: peak.Fee,
|
||||||
|
Price: summary.Peak.Price,
|
||||||
Proportion: PeakProportion,
|
Proportion: PeakProportion,
|
||||||
},
|
},
|
||||||
Flat: model.ConsumptionUnit{
|
Flat: model.ConsumptionUnit{
|
||||||
Price: summary.Overall.Price,
|
Amount: flat.Amount,
|
||||||
|
Fee: flat.Fee,
|
||||||
|
Price: summary.Flat.Price,
|
||||||
Proportion: FlatProportion,
|
Proportion: FlatProportion,
|
||||||
},
|
},
|
||||||
Valley: model.ConsumptionUnit{
|
Valley: model.ConsumptionUnit{
|
||||||
Price: summary.Overall.Price,
|
Amount: valley.Amount,
|
||||||
|
Fee: valley.Fee,
|
||||||
|
Price: summary.Valley.Price,
|
||||||
Proportion: ValleyProportion,
|
Proportion: ValleyProportion,
|
||||||
},
|
},
|
||||||
|
Loss: model.ConsumptionUnit{
|
||||||
|
Amount: lossAmount,
|
||||||
|
Fee: lossPooled,
|
||||||
|
Price: summary.AuthoizeLoss.Price,
|
||||||
|
Proportion: lossProportion,
|
||||||
|
},
|
||||||
BasicFee: basicPooled,
|
BasicFee: basicPooled,
|
||||||
AdjustFee: adjustPooled,
|
AdjustFee: adjustPooled,
|
||||||
LossPooled: lossPooled,
|
LossPooled: lossPooled,
|
||||||
|
@ -462,10 +488,10 @@ func TenementChargeCalculate(tenements []calculate.PrimaryTenementStatistics,
|
||||||
Submeters: nil,
|
Submeters: nil,
|
||||||
Poolings: nil,
|
Poolings: nil,
|
||||||
}
|
}
|
||||||
|
fmt.Println("=====", tenementCharge)
|
||||||
tc = append(tc, tenementCharge)
|
tc = append(tc, tenementCharge)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println(tc)
|
//fmt.Println(len(tc))
|
||||||
return tc
|
return tc
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user