收緊 PChome 單位價可比邊界
All checks were successful
CD Pipeline / deploy (push) Successful in 1m3s

This commit is contained in:
OoO
2026-05-19 23:49:23 +08:00
parent 23ddd3ede9
commit 108b05cc8b
5 changed files with 37 additions and 10 deletions

View File

@@ -483,12 +483,24 @@ def _spec_mention_count(identity: ProductIdentity) -> int:
def _has_overlapping_base_spec(left: ProductIdentity, right: ProductIdentity) -> bool:
for left_value in left.volumes_ml:
if any(_close_number(left_value, right_value) for right_value in right.volumes_ml):
return True
for left_value in left.weights_g:
if any(_close_number(left_value, right_value) for right_value in right.weights_g):
return True
left_volumes = tuple(sorted(set(left.volumes_ml)))
right_volumes = tuple(sorted(set(right.volumes_ml)))
if left_volumes or right_volumes:
if not left_volumes or not right_volumes:
return False
if len(left_volumes) > 1 or len(right_volumes) > 1:
return False
return _close_number(left_volumes[0], right_volumes[0])
left_weights = tuple(sorted(set(left.weights_g)))
right_weights = tuple(sorted(set(right.weights_g)))
if left_weights or right_weights:
if not left_weights or not right_weights:
return False
if len(left_weights) > 1 or len(right_weights) > 1:
return False
return _close_number(left_weights[0], right_weights[0])
return False