Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-06-19 14:46:32 +03:00
parent 10f90cbaf3
commit 539ca4b587
5 changed files with 66 additions and 0 deletions

View File

@@ -384,6 +384,25 @@ WHERE is_active = TRUE
Dim3 sql.NullInt64
}
hasDim3Combo := func(dims []dimCombo) bool {
for _, d := range dims {
if d.Dim3.Valid && d.Dim3.Int64 > 0 {
return true
}
}
return false
}
filterDim3Combos := func(dims []dimCombo) []dimCombo {
out := make([]dimCombo, 0, len(dims))
for _, d := range dims {
if d.Dim3.Valid && d.Dim3.Int64 > 0 {
out = append(out, d)
}
}
return out
}
type sdprcWriteRow struct {
Currency string `json:"currency"`
SdprcGrpID int `json:"sdprcgrp_id"`
@@ -578,6 +597,9 @@ DO UPDATE SET dim_id = EXCLUDED.dim_id, updated_at = EXCLUDED.updated_at
d3 = sql.NullInt64{Int64: id, Valid: true}
resolvedDim3++
}
if strings.TrimSpace(dim3Code) != "" && !d3.Valid {
continue
}
key := fmt.Sprintf("%d|%d", d1, func() int64 {
if d3.Valid {
return d3.Int64
@@ -1071,6 +1093,9 @@ VALUES (
if d, err := loadDimsFromMssqlStock(code); err != nil {
logger.Error("save:pg:dims:mssql:error", "product_code", code, "err", err)
} else if len(d) > 0 {
if hasDim3Combo(d) {
dims = filterDim3Combos(dims)
}
seenDims := make(map[string]struct{}, len(dims)+len(d))
merged := make([]dimCombo, 0, len(dims)+len(d))
dim3Value := func(v sql.NullInt64) int64 {