两个独立缺陷,叠在一起导致全站实际不收运费(29 个历史订单运费全为 0)。 一、真实下单路径根本没走模板 order.go 把商品分成两组:绑了模板的走 CalculateShippingFee, 没绑的走 shipping_fee_first_weight / shipping_fee_per_gram 两个系统设置。 而这两个 key 在库里从未写入过,settingFloat 默认取 0, 站点 42 个商品 shipping_template_id 全是 NULL —— 于是全部落进 第二个分支,运费恒为 0。 改为:没绑模板的商品也走 CalculateShippingFee(nil, ...), 由模板统一决定。旧的系统设置分支删除。 二、商品绑一个地区模板时,其他省份的地区价永远轮不到 原逻辑:取商品绑定的模板 → 检查买家省份在不在它的 provinces 里 → 不在就回退默认模板。等于一个商品只能享用一个地区的价。 新增 pickShippingTemplate(),按优先级选模板: 1. 商品绑定的模板,且覆盖收货省份 2. 任意地区模板覆盖收货省份(按 sort_order,先到先得) 3. 默认模板 配套新增 provinceMatches():provinces 为空 / province 为空 / JSON 解析失败,一律视为覆盖,宁可收到运费也不因脏数据漏收。 实测(首重内 200g): 上海 10 / 北京 12 / 广东 12 / 四川 15 / 黑龙江 15 / 陕西 18 / 新疆 25 / 香港 35 / 无匹配省份 15 续重:900g 广东 = 12 + ceil(400/500)×6 = 18 包邮:广东满 450 → 0,满 449 → 18 空省份 → 回退默认 15 数据侧同步:删掉孤儿模板「中国区域」(provinces 空但非默认, 永远用不上,且无商品引用)。
71 lines
2.8 KiB
AMPL
71 lines
2.8 KiB
AMPL
module sale
|
|
|
|
go 1.25.0
|
|
|
|
require (
|
|
github.com/PuerkitoBio/goquery v1.9.2
|
|
github.com/andybalholm/cascadia v1.3.2 // indirect
|
|
github.com/gin-gonic/gin v1.9.1
|
|
github.com/glebarez/sqlite v1.11.0
|
|
github.com/golang-jwt/jwt/v5 v5.3.1
|
|
github.com/google/uuid v1.3.0
|
|
github.com/joho/godotenv v1.5.1
|
|
golang.org/x/crypto v0.53.0
|
|
gorm.io/driver/mysql v1.6.0
|
|
gorm.io/driver/postgres v1.6.0
|
|
gorm.io/gorm v1.31.1
|
|
)
|
|
|
|
require github.com/xuri/excelize/v2 v2.11.0
|
|
|
|
require (
|
|
filippo.io/edwards25519 v1.1.0 // indirect
|
|
github.com/bytedance/gopkg v0.1.3 // indirect
|
|
github.com/bytedance/sonic v1.15.0 // indirect
|
|
github.com/bytedance/sonic/loader v0.5.0 // indirect
|
|
github.com/cloudwego/base64x v0.1.6 // indirect
|
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
|
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
|
github.com/glebarez/go-sqlite v1.21.2 // indirect
|
|
github.com/go-playground/locales v0.14.1 // indirect
|
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
|
github.com/go-playground/validator/v10 v10.14.0 // indirect
|
|
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
|
github.com/goccy/go-json v0.10.5 // indirect
|
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
|
github.com/jackc/pgx/v5 v5.6.0 // indirect
|
|
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
|
github.com/jinzhu/now v1.1.5 // indirect
|
|
github.com/json-iterator/go v1.1.12 // indirect
|
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
|
github.com/kr/text v0.2.0 // indirect
|
|
github.com/leodido/go-urn v1.4.0 // indirect
|
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
|
github.com/richardlehane/mscfb v1.0.7 // indirect
|
|
github.com/richardlehane/msoleps v1.0.6 // indirect
|
|
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
|
github.com/tiendc/go-deepcopy v1.7.2 // indirect
|
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
|
github.com/ugorji/go/codec v1.3.1 // indirect
|
|
github.com/xuri/efp v0.0.1 // indirect
|
|
github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 // indirect
|
|
golang.org/x/arch v0.17.0 // indirect
|
|
golang.org/x/net v0.56.0 // indirect
|
|
golang.org/x/sync v0.21.0 // indirect
|
|
golang.org/x/sys v0.46.0 // indirect
|
|
golang.org/x/text v0.38.0 // indirect
|
|
google.golang.org/protobuf v1.36.10 // indirect
|
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
modernc.org/libc v1.22.5 // indirect
|
|
modernc.org/mathutil v1.5.0 // indirect
|
|
modernc.org/memory v1.5.0 // indirect
|
|
modernc.org/sqlite v1.23.1 // indirect
|
|
)
|