refactor logging and filters
This commit is contained in:
@ -12,6 +12,44 @@ type GoodsItemSize struct {
|
||||
Width Dimension
|
||||
Height Dimension
|
||||
Length Dimension
|
||||
|
||||
UnmatchedDepth Dimension
|
||||
}
|
||||
|
||||
func FixupSizes(s GoodsItemSize) (GoodsItemSize, bool) {
|
||||
// Nothing to substitute
|
||||
if s.UnmatchedDepth.IsZero() {
|
||||
return s, false
|
||||
}
|
||||
|
||||
var count int
|
||||
for _, d := range []Dimension{
|
||||
s.Width,
|
||||
s.Height,
|
||||
s.Length,
|
||||
} {
|
||||
if d.IsZero() {
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
||||
// Can only replace one dimension
|
||||
if count != 1 {
|
||||
return s, false
|
||||
}
|
||||
|
||||
switch {
|
||||
case s.Width.IsZero():
|
||||
s.Width = s.UnmatchedDepth
|
||||
case s.Height.IsZero():
|
||||
s.Height = s.UnmatchedDepth
|
||||
case s.Length.IsZero():
|
||||
s.Length = s.UnmatchedDepth
|
||||
}
|
||||
|
||||
s.UnmatchedDepth = Dimension{}
|
||||
|
||||
return s, true
|
||||
}
|
||||
|
||||
func (s GoodsItemSize) GetSum(kind DimensionKind) float64 {
|
||||
|
||||
Reference in New Issue
Block a user