Merge branch '0.2' of https://git.archgrid.xyz/free-lancers/electricity_bill_calc_service into 0.2
This commit is contained in:
commit
361b302407
@ -7,7 +7,6 @@ import (
|
||||
"electricity_bill_calc/repository"
|
||||
"electricity_bill_calc/vo"
|
||||
"fmt"
|
||||
|
||||
"github.com/samber/lo"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@ -82,7 +81,7 @@ func (ts _TenementService) BindMeter(pid, tid, meterCode string, reading *vo.Met
|
||||
tx.Rollback(ctx)
|
||||
return fmt.Errorf("未能获取表计详细信息,%w", err)
|
||||
}
|
||||
err = repository.TenementRepository.BindMeter(tx, ctx, pid, tid, meterCode,reading)
|
||||
err = repository.TenementRepository.BindMeter(tx, ctx, pid, tid, meterCode, reading)
|
||||
if err != nil {
|
||||
ts.log.Error("向商户绑定一个新表计失败,未能绑定表计", zap.Error(err))
|
||||
tx.Rollback(ctx)
|
||||
@ -201,7 +200,7 @@ func (ts _TenementService) MoveOutTenement(pid, tid string, reading []*vo.MeterR
|
||||
tx.Rollback(ctx)
|
||||
return fmt.Errorf("找不到指定表计[%s]的抄表信息,%w", meterCode, err)
|
||||
}
|
||||
if reading.Validate() {
|
||||
if !reading.Validate() {
|
||||
ts.log.Error("迁出指定商户失败,表计读数不能正确配平,尖锋电量、峰电量、谷电量之和超过总电量。", zap.String("Meter", meterCode))
|
||||
tx.Rollback(ctx)
|
||||
return fmt.Errorf("表计[%s]读数不能正确配平,尖锋电量、峰电量、谷电量之和超过总电量。", meterCode)
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"electricity_bill_calc/model"
|
||||
"electricity_bill_calc/types"
|
||||
"fmt"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
@ -19,7 +18,8 @@ type MeterReadingForm struct {
|
||||
|
||||
func (r MeterReadingForm) Validate() bool {
|
||||
flat := r.Overall.Sub(r.Critical).Sub(r.Peak).Sub(r.Valley)
|
||||
return flat.GreaterThanOrEqual(decimal.Zero)
|
||||
b := flat.GreaterThanOrEqual(decimal.Zero)
|
||||
return b
|
||||
}
|
||||
|
||||
type MeterReadingFormWithCode struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user