mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 05:09:19 +08:00
feat: 快递报价改为分区×重量带以对齐承运商矩阵计价
This commit is contained in:
@@ -1,14 +1,16 @@
|
|||||||
-- ========================================
|
-- ========================================
|
||||||
-- 电商-仓库发货与快递报价(无进销存)
|
-- 电商-仓库发货与快递报价(无进销存)
|
||||||
-- ec_warehouse / ec_express_quote(+version/region/tier)
|
-- ec_warehouse / ec_express_quote(+version/region/band)
|
||||||
-- ec_warehouse_express_bind / ec_express_carrier_alias
|
-- ec_warehouse_express_bind / ec_express_carrier_alias
|
||||||
-- SKU 默认仓、体积尺寸见 ec_product_design.sql(warehouse_id / length_mm…)
|
-- SKU 默认仓、体积尺寸见 ec_product_design.sql(warehouse_id / length_mm…)
|
||||||
|
-- REGION_WEIGHT:目的分区 × 多重量带(元/票 或 首重+续重/kg),对齐承运商矩阵报价单
|
||||||
-- ========================================
|
-- ========================================
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- 仓库主数据(无库存)
|
-- 仓库主数据(无库存)
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP TABLE IF EXISTS `ec_warehouse_express_bind`;
|
DROP TABLE IF EXISTS `ec_warehouse_express_bind`;
|
||||||
|
DROP TABLE IF EXISTS `ec_express_quote_band`;
|
||||||
DROP TABLE IF EXISTS `ec_express_quote_tier`;
|
DROP TABLE IF EXISTS `ec_express_quote_tier`;
|
||||||
DROP TABLE IF EXISTS `ec_express_quote_region`;
|
DROP TABLE IF EXISTS `ec_express_quote_region`;
|
||||||
DROP TABLE IF EXISTS `ec_express_quote_version`;
|
DROP TABLE IF EXISTS `ec_express_quote_version`;
|
||||||
@@ -78,8 +80,9 @@ CREATE TABLE `ec_express_quote_version` (
|
|||||||
`unit_scope` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'FLAT:ORDER|PIECE',
|
`unit_scope` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'FLAT:ORDER|PIECE',
|
||||||
`price_per_kg` decimal(10, 4) NULL DEFAULT NULL COMMENT 'PER_KG 单价',
|
`price_per_kg` decimal(10, 4) NULL DEFAULT NULL COMMENT 'PER_KG 单价',
|
||||||
`min_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT 'PER_KG 最低消费',
|
`min_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT 'PER_KG 最低消费',
|
||||||
`volume_divisor` int UNSIGNED NULL DEFAULT 6000 COMMENT '体积重除数(长*宽*高mm / divisor = g 量级需再换算;约定:mm³/divisor→kg*1000=g)',
|
`volume_divisor` int UNSIGNED NULL DEFAULT 6000 COMMENT '计泡除数(cm 公式):体积重克=ceil(长*宽*高mm / divisor),如 6000/8000',
|
||||||
`use_volumetric` tinyint NOT NULL DEFAULT 0 COMMENT '是否启用体积重:0否 1是(计费重=max实重,体积重)',
|
`use_volumetric` tinyint NOT NULL DEFAULT 0 COMMENT '是否启用体积重:0否 1是(计费重=max实重,体积重)',
|
||||||
|
`weight_round` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'NONE' COMMENT '计费重取整:NONE/CEIL_KG',
|
||||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '调价说明',
|
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '调价说明',
|
||||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
@@ -98,9 +101,10 @@ CREATE TABLE `ec_express_quote_region` (
|
|||||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '分区ID',
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '分区ID',
|
||||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||||
`version_id` bigint UNSIGNED NOT NULL COMMENT '报价版本ID',
|
`version_id` bigint UNSIGNED NOT NULL COMMENT '报价版本ID',
|
||||||
`region_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '分区名(如江浙沪)',
|
`region_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '分区名(如二类/江浙沪)',
|
||||||
`provinces_json` json NOT NULL COMMENT '省份全称列表 JSON,与 BiRegionNormalizer 对齐',
|
`zone_label` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '价区标签:一类/二类…(展示用)',
|
||||||
`is_default` tinyint NOT NULL DEFAULT 0 COMMENT '是否默认分区(未命中省时回落)',
|
`provinces_json` json NOT NULL COMMENT '目的地列表 JSON(省全称或市名,如深圳市)',
|
||||||
|
`is_default` tinyint NOT NULL DEFAULT 0 COMMENT '是否默认分区(未命中时回落)',
|
||||||
`sort_order` int NOT NULL DEFAULT 0 COMMENT '排序',
|
`sort_order` int NOT NULL DEFAULT 0 COMMENT '排序',
|
||||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
@@ -108,26 +112,31 @@ CREATE TABLE `ec_express_quote_region` (
|
|||||||
INDEX `idx_ec_express_quote_region_version`(`version_id` ASC) USING BTREE,
|
INDEX `idx_ec_express_quote_region_version`(`version_id` ASC) USING BTREE,
|
||||||
CONSTRAINT `fk_ec_express_quote_region_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
CONSTRAINT `fk_ec_express_quote_region_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
CONSTRAINT `fk_ec_express_quote_region_version` FOREIGN KEY (`version_id`) REFERENCES `ec_express_quote_version` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
CONSTRAINT `fk_ec_express_quote_region_version` FOREIGN KEY (`version_id`) REFERENCES `ec_express_quote_version` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-快递报价分区';
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-快递报价目的分区';
|
||||||
|
|
||||||
CREATE TABLE `ec_express_quote_tier` (
|
-- 重量带:一分区多行;FLAT_TICKET=元/票;FIRST_PLUS_KG=首重价+续重元/kg(续重按 kg 向上取整段)
|
||||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '阶梯ID',
|
CREATE TABLE `ec_express_quote_band` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '重量带ID',
|
||||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||||
`version_id` bigint UNSIGNED NOT NULL COMMENT '报价版本ID',
|
`version_id` bigint UNSIGNED NOT NULL COMMENT '报价版本ID',
|
||||||
`region_id` bigint UNSIGNED NOT NULL COMMENT '分区ID',
|
`region_id` bigint UNSIGNED NOT NULL COMMENT '分区ID',
|
||||||
`first_weight_g` int UNSIGNED NOT NULL DEFAULT 1000 COMMENT '首重(克)',
|
`weight_from_g` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '计费重下限(克,含)',
|
||||||
`first_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '首重价格',
|
`weight_to_g` int UNSIGNED NULL DEFAULT NULL COMMENT '计费重上限(克,含);NULL=无上限',
|
||||||
`additional_weight_g` int UNSIGNED NOT NULL DEFAULT 1000 COMMENT '续重步进(克)',
|
`price_mode` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'FLAT_TICKET/FIRST_PLUS_KG',
|
||||||
`additional_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '续重价格',
|
`flat_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT 'FLAT_TICKET 元/票',
|
||||||
|
`first_weight_g` int UNSIGNED NULL DEFAULT NULL COMMENT 'FIRST_PLUS_KG 首重克数(可为0)',
|
||||||
|
`first_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT 'FIRST_PLUS_KG 首重价',
|
||||||
|
`continue_per_kg` decimal(10, 4) NULL DEFAULT NULL COMMENT 'FIRST_PLUS_KG 续重元/kg',
|
||||||
|
`sort_order` int NOT NULL DEFAULT 0 COMMENT '同区分带排序',
|
||||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
UNIQUE INDEX `uk_ec_express_quote_tier_region`(`region_id` ASC) USING BTREE,
|
INDEX `idx_ec_express_quote_band_region`(`region_id` ASC, `weight_from_g` ASC) USING BTREE,
|
||||||
INDEX `idx_ec_express_quote_tier_version`(`version_id` ASC) USING BTREE,
|
INDEX `idx_ec_express_quote_band_version`(`version_id` ASC) USING BTREE,
|
||||||
CONSTRAINT `fk_ec_express_quote_tier_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
CONSTRAINT `fk_ec_express_quote_band_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
CONSTRAINT `fk_ec_express_quote_tier_version` FOREIGN KEY (`version_id`) REFERENCES `ec_express_quote_version` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
CONSTRAINT `fk_ec_express_quote_band_version` FOREIGN KEY (`version_id`) REFERENCES `ec_express_quote_version` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
CONSTRAINT `fk_ec_express_quote_tier_region` FOREIGN KEY (`region_id`) REFERENCES `ec_express_quote_region` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
CONSTRAINT `fk_ec_express_quote_band_region` FOREIGN KEY (`region_id`) REFERENCES `ec_express_quote_region` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-快递报价首重续重';
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-快递报价重量带';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- 仓 ↔ 报价多对多绑定
|
-- 仓 ↔ 报价多对多绑定
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
-- 报价:单区单条首重续重 → 目的分区 × 多重量带(对齐承运商矩阵报价单)
|
||||||
|
|
||||||
|
-- 1) version 增加计费重取整
|
||||||
|
ALTER TABLE `ec_express_quote_version`
|
||||||
|
ADD COLUMN `weight_round` varchar(16) NOT NULL DEFAULT 'NONE' COMMENT '计费重取整:NONE/CEIL_KG'
|
||||||
|
AFTER `use_volumetric`;
|
||||||
|
|
||||||
|
-- 2) region 增加价区标签
|
||||||
|
ALTER TABLE `ec_express_quote_region`
|
||||||
|
ADD COLUMN `zone_label` varchar(32) NULL DEFAULT NULL COMMENT '价区标签:一类/二类…'
|
||||||
|
AFTER `region_name`;
|
||||||
|
|
||||||
|
ALTER TABLE `ec_express_quote_region`
|
||||||
|
MODIFY COLUMN `provinces_json` json NOT NULL COMMENT '目的地列表 JSON(省全称或市名)';
|
||||||
|
|
||||||
|
-- 3) 新建重量带表
|
||||||
|
CREATE TABLE IF NOT EXISTS `ec_express_quote_band` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '重量带ID',
|
||||||
|
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||||
|
`version_id` bigint UNSIGNED NOT NULL COMMENT '报价版本ID',
|
||||||
|
`region_id` bigint UNSIGNED NOT NULL COMMENT '分区ID',
|
||||||
|
`weight_from_g` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '计费重下限(克,含)',
|
||||||
|
`weight_to_g` int UNSIGNED NULL DEFAULT NULL COMMENT '计费重上限(克,含);NULL=无上限',
|
||||||
|
`price_mode` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'FLAT_TICKET/FIRST_PLUS_KG',
|
||||||
|
`flat_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT 'FLAT_TICKET 元/票',
|
||||||
|
`first_weight_g` int UNSIGNED NULL DEFAULT NULL COMMENT 'FIRST_PLUS_KG 首重克数',
|
||||||
|
`first_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT 'FIRST_PLUS_KG 首重价',
|
||||||
|
`continue_per_kg` decimal(10, 4) NULL DEFAULT NULL COMMENT 'FIRST_PLUS_KG 续重元/kg',
|
||||||
|
`sort_order` int NOT NULL DEFAULT 0 COMMENT '同区分带排序',
|
||||||
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
INDEX `idx_ec_express_quote_band_region`(`region_id` ASC, `weight_from_g` ASC) USING BTREE,
|
||||||
|
INDEX `idx_ec_express_quote_band_version`(`version_id` ASC) USING BTREE,
|
||||||
|
CONSTRAINT `fk_ec_express_quote_band_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_ec_express_quote_band_version` FOREIGN KEY (`version_id`) REFERENCES `ec_express_quote_version` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_ec_express_quote_band_region` FOREIGN KEY (`region_id`) REFERENCES `ec_express_quote_region` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-快递报价重量带';
|
||||||
|
|
||||||
|
-- 4) 迁移旧 tier → 一条开区间 FIRST_PLUS_KG band
|
||||||
|
INSERT INTO `ec_express_quote_band` (
|
||||||
|
`company_id`, `version_id`, `region_id`,
|
||||||
|
`weight_from_g`, `weight_to_g`, `price_mode`,
|
||||||
|
`first_weight_g`, `first_amount`, `continue_per_kg`, `sort_order`
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
t.`company_id`, t.`version_id`, t.`region_id`,
|
||||||
|
0, NULL, 'FIRST_PLUS_KG',
|
||||||
|
IFNULL(t.`first_weight_g`, 1000),
|
||||||
|
IFNULL(t.`first_amount`, 0),
|
||||||
|
CASE
|
||||||
|
WHEN IFNULL(t.`additional_weight_g`, 0) > 0
|
||||||
|
THEN ROUND(IFNULL(t.`additional_amount`, 0) * 1000 / t.`additional_weight_g`, 4)
|
||||||
|
ELSE IFNULL(t.`additional_amount`, 0)
|
||||||
|
END,
|
||||||
|
0
|
||||||
|
FROM `ec_express_quote_tier` t
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM `ec_express_quote_band` b WHERE b.`region_id` = t.`region_id`
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 5) 删除旧 tier
|
||||||
|
DROP TABLE IF EXISTS `ec_express_quote_tier`;
|
||||||
+2
-1
@@ -119,7 +119,8 @@ public class FreightCostCalculator {
|
|||||||
}
|
}
|
||||||
int chargeG = FreightQuoteResolver.chargeableWeightG(actualG, volumetricG, useVolumetric);
|
int chargeG = FreightQuoteResolver.chargeableWeightG(actualG, volumetricG, useVolumetric);
|
||||||
Optional<BigDecimal> packageFreight = quoteResolver.resolveAmount(
|
Optional<BigDecimal> packageFreight = quoteResolver.resolveAmount(
|
||||||
warehouseId, onDate, order.getProvince(), chargeG, pieceCount, preferredCarrier);
|
warehouseId, onDate, order.getProvince(), order.getCity(),
|
||||||
|
chargeG, pieceCount, preferredCarrier);
|
||||||
|
|
||||||
if (packageFreight.isPresent() && chargeG > 0) {
|
if (packageFreight.isPresent() && chargeG > 0) {
|
||||||
allocateByWeight(result, group, lineWeight, packageFreight.get(), costMap, onDate);
|
allocateByWeight(result, group, lineWeight, packageFreight.get(), costMap, onDate);
|
||||||
|
|||||||
+110
-47
@@ -6,14 +6,14 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.support.BiRegionNormalizer;
|
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.support.BiRegionNormalizer;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteBandMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteRegionMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteRegionMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteTierMapper;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteVersionMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteVersionMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.WarehouseExpressBindMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.WarehouseExpressBindMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteBandPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuotePO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuotePO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteRegionPO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteRegionPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteTierPO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteVersionPO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteVersionPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.WarehouseExpressBindPO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.WarehouseExpressBindPO;
|
||||||
|
|
||||||
@@ -27,8 +27,9 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按仓 + 日期 + 省 + 计费重 + 可选承运商选价。
|
* 按仓 + 日期 + 目的地 + 计费重 + 可选承运商选价。
|
||||||
* 策略:PRIORITY;有 carrier 时将该 carrier 的 bind 提到最前。
|
* 策略:PRIORITY;有 carrier 时将该 carrier 的 bind 提到最前。
|
||||||
|
* REGION_WEIGHT:目的地优先市名精确匹配,再省全称,再默认分区;命中后按重量带计价。
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class FreightQuoteResolver {
|
public class FreightQuoteResolver {
|
||||||
@@ -37,20 +38,20 @@ public class FreightQuoteResolver {
|
|||||||
private final ExpressQuoteMapper quoteMapper;
|
private final ExpressQuoteMapper quoteMapper;
|
||||||
private final ExpressQuoteVersionMapper versionMapper;
|
private final ExpressQuoteVersionMapper versionMapper;
|
||||||
private final ExpressQuoteRegionMapper regionMapper;
|
private final ExpressQuoteRegionMapper regionMapper;
|
||||||
private final ExpressQuoteTierMapper tierMapper;
|
private final ExpressQuoteBandMapper bandMapper;
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
public FreightQuoteResolver(WarehouseExpressBindMapper bindMapper,
|
public FreightQuoteResolver(WarehouseExpressBindMapper bindMapper,
|
||||||
ExpressQuoteMapper quoteMapper,
|
ExpressQuoteMapper quoteMapper,
|
||||||
ExpressQuoteVersionMapper versionMapper,
|
ExpressQuoteVersionMapper versionMapper,
|
||||||
ExpressQuoteRegionMapper regionMapper,
|
ExpressQuoteRegionMapper regionMapper,
|
||||||
ExpressQuoteTierMapper tierMapper,
|
ExpressQuoteBandMapper bandMapper,
|
||||||
ObjectMapper objectMapper) {
|
ObjectMapper objectMapper) {
|
||||||
this.bindMapper = bindMapper;
|
this.bindMapper = bindMapper;
|
||||||
this.quoteMapper = quoteMapper;
|
this.quoteMapper = quoteMapper;
|
||||||
this.versionMapper = versionMapper;
|
this.versionMapper = versionMapper;
|
||||||
this.regionMapper = regionMapper;
|
this.regionMapper = regionMapper;
|
||||||
this.tierMapper = tierMapper;
|
this.bandMapper = bandMapper;
|
||||||
this.objectMapper = objectMapper;
|
this.objectMapper = objectMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,8 +60,10 @@ public class FreightQuoteResolver {
|
|||||||
* @param pieceCount 件数(FLAT/PIECE 用)
|
* @param pieceCount 件数(FLAT/PIECE 用)
|
||||||
* @return 运费金额;无法计价返回 empty
|
* @return 运费金额;无法计价返回 empty
|
||||||
*/
|
*/
|
||||||
public Optional<BigDecimal> resolveAmount(Long warehouseId, LocalDate onDate, String province,
|
public Optional<BigDecimal> resolveAmount(Long warehouseId, LocalDate onDate,
|
||||||
int chargeableWeightG, int pieceCount, String preferredCarrier) {
|
String province, String city,
|
||||||
|
int chargeableWeightG, int pieceCount,
|
||||||
|
String preferredCarrier) {
|
||||||
if (warehouseId == null || onDate == null || chargeableWeightG <= 0) {
|
if (warehouseId == null || onDate == null || chargeableWeightG <= 0) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
@@ -94,6 +97,7 @@ public class FreightQuoteResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String provinceFull = BiRegionNormalizer.normalize(province);
|
String provinceFull = BiRegionNormalizer.normalize(province);
|
||||||
|
String cityRaw = StringUtils.hasText(city) ? city.trim() : null;
|
||||||
for (WarehouseExpressBindPO bind : ordered) {
|
for (WarehouseExpressBindPO bind : ordered) {
|
||||||
ExpressQuotePO quote = quoteMapper.selectById(bind.getQuoteId());
|
ExpressQuotePO quote = quoteMapper.selectById(bind.getQuoteId());
|
||||||
if (quote == null || quote.getStatus() == null || quote.getStatus() != 1) {
|
if (quote == null || quote.getStatus() == null || quote.getStatus() != 1) {
|
||||||
@@ -107,7 +111,8 @@ public class FreightQuoteResolver {
|
|||||||
if (version == null) {
|
if (version == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Optional<BigDecimal> amount = price(quote, version, provinceFull, chargeableWeightG, pieceCount);
|
int weightG = applyWeightRound(chargeableWeightG, version.getWeightRound());
|
||||||
|
Optional<BigDecimal> amount = price(quote, version, provinceFull, cityRaw, weightG, pieceCount);
|
||||||
if (amount.isPresent()) {
|
if (amount.isPresent()) {
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
@@ -116,7 +121,7 @@ public class FreightQuoteResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Optional<BigDecimal> price(ExpressQuotePO quote, ExpressQuoteVersionPO version,
|
private Optional<BigDecimal> price(ExpressQuotePO quote, ExpressQuoteVersionPO version,
|
||||||
String provinceFull, int weightG, int pieceCount) {
|
String provinceFull, String cityRaw, int weightG, int pieceCount) {
|
||||||
String mode = quote.getBillingMode();
|
String mode = quote.getBillingMode();
|
||||||
if (ExpressQuotePO.MODE_FLAT.equals(mode)) {
|
if (ExpressQuotePO.MODE_FLAT.equals(mode)) {
|
||||||
if (version.getFlatAmount() == null) {
|
if (version.getFlatAmount() == null) {
|
||||||
@@ -143,62 +148,120 @@ public class FreightQuoteResolver {
|
|||||||
return Optional.of(amount);
|
return Optional.of(amount);
|
||||||
}
|
}
|
||||||
if (ExpressQuotePO.MODE_REGION_WEIGHT.equals(mode)) {
|
if (ExpressQuotePO.MODE_REGION_WEIGHT.equals(mode)) {
|
||||||
return priceRegionWeight(version, provinceFull, weightG);
|
return priceRegionWeight(version, provinceFull, cityRaw, weightG);
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<BigDecimal> priceRegionWeight(ExpressQuoteVersionPO version, String provinceFull, int weightG) {
|
private Optional<BigDecimal> priceRegionWeight(ExpressQuoteVersionPO version,
|
||||||
|
String provinceFull, String cityRaw, int weightG) {
|
||||||
List<ExpressQuoteRegionPO> regions = regionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
List<ExpressQuoteRegionPO> regions = regionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
||||||
.eq(ExpressQuoteRegionPO::getVersionId, version.getId())
|
.eq(ExpressQuoteRegionPO::getVersionId, version.getId())
|
||||||
.orderByAsc(ExpressQuoteRegionPO::getSortOrder));
|
.orderByAsc(ExpressQuoteRegionPO::getSortOrder));
|
||||||
ExpressQuoteRegionPO hit = null;
|
ExpressQuoteRegionPO hit = matchRegion(regions, provinceFull, cityRaw);
|
||||||
|
if (hit == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
List<ExpressQuoteBandPO> bands = bandMapper.selectList(new LambdaQueryWrapper<ExpressQuoteBandPO>()
|
||||||
|
.eq(ExpressQuoteBandPO::getRegionId, hit.getId())
|
||||||
|
.orderByAsc(ExpressQuoteBandPO::getSortOrder)
|
||||||
|
.orderByAsc(ExpressQuoteBandPO::getWeightFromG));
|
||||||
|
ExpressQuoteBandPO band = matchBand(bands, weightG);
|
||||||
|
if (band == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return priceBand(band, weightG);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 市名精确优先,再省全称,再默认分区。 */
|
||||||
|
private ExpressQuoteRegionPO matchRegion(List<ExpressQuoteRegionPO> regions,
|
||||||
|
String provinceFull, String cityRaw) {
|
||||||
ExpressQuoteRegionPO defaultRegion = null;
|
ExpressQuoteRegionPO defaultRegion = null;
|
||||||
|
ExpressQuoteRegionPO provinceHit = null;
|
||||||
for (ExpressQuoteRegionPO r : regions) {
|
for (ExpressQuoteRegionPO r : regions) {
|
||||||
if (r.getIsDefault() != null && r.getIsDefault() == 1) {
|
if (r.getIsDefault() != null && r.getIsDefault() == 1) {
|
||||||
defaultRegion = r;
|
defaultRegion = r;
|
||||||
}
|
}
|
||||||
if (provinceContains(r.getProvincesJson(), provinceFull)) {
|
List<String> dests = parseDestinations(r.getProvincesJson());
|
||||||
hit = r;
|
if (cityRaw != null && dests.stream().anyMatch(d -> destinationEquals(d, cityRaw))) {
|
||||||
break;
|
return r;
|
||||||
|
}
|
||||||
|
if (provinceHit == null && !BiRegionNormalizer.isUnknown(provinceFull)
|
||||||
|
&& dests.stream().anyMatch(d -> destinationEquals(d, provinceFull))) {
|
||||||
|
provinceHit = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hit == null) {
|
return provinceHit != null ? provinceHit : defaultRegion;
|
||||||
hit = defaultRegion;
|
|
||||||
}
|
|
||||||
if (hit == null) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
ExpressQuoteTierPO tier = tierMapper.selectOne(new LambdaQueryWrapper<ExpressQuoteTierPO>()
|
|
||||||
.eq(ExpressQuoteTierPO::getRegionId, hit.getId())
|
|
||||||
.last("LIMIT 1"));
|
|
||||||
if (tier == null) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
int firstG = tier.getFirstWeightG() != null && tier.getFirstWeightG() > 0 ? tier.getFirstWeightG() : 1000;
|
|
||||||
int addG = tier.getAdditionalWeightG() != null && tier.getAdditionalWeightG() > 0
|
|
||||||
? tier.getAdditionalWeightG() : 1000;
|
|
||||||
BigDecimal firstAmt = nz(tier.getFirstAmount());
|
|
||||||
BigDecimal addAmt = nz(tier.getAdditionalAmount());
|
|
||||||
if (weightG <= firstG) {
|
|
||||||
return Optional.of(firstAmt);
|
|
||||||
}
|
|
||||||
int remain = weightG - firstG;
|
|
||||||
int steps = (remain + addG - 1) / addG;
|
|
||||||
return Optional.of(firstAmt.add(addAmt.multiply(BigDecimal.valueOf(steps))).setScale(2, RoundingMode.HALF_UP));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean provinceContains(String provincesJson, String provinceFull) {
|
private static ExpressQuoteBandPO matchBand(List<ExpressQuoteBandPO> bands, int weightG) {
|
||||||
if (!StringUtils.hasText(provincesJson) || BiRegionNormalizer.isUnknown(provinceFull)) {
|
for (ExpressQuoteBandPO b : bands) {
|
||||||
return false;
|
int from = b.getWeightFromG() != null ? b.getWeightFromG() : 0;
|
||||||
|
Integer to = b.getWeightToG();
|
||||||
|
if (weightG >= from && (to == null || weightG <= to)) {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Optional<BigDecimal> priceBand(ExpressQuoteBandPO band, int weightG) {
|
||||||
|
if (ExpressQuoteBandPO.MODE_FLAT_TICKET.equals(band.getPriceMode())) {
|
||||||
|
if (band.getFlatAmount() == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return Optional.of(band.getFlatAmount().setScale(2, RoundingMode.HALF_UP));
|
||||||
|
}
|
||||||
|
if (ExpressQuoteBandPO.MODE_FIRST_PLUS_KG.equals(band.getPriceMode())) {
|
||||||
|
int firstG = band.getFirstWeightG() != null ? Math.max(band.getFirstWeightG(), 0) : 0;
|
||||||
|
BigDecimal firstAmt = nz(band.getFirstAmount());
|
||||||
|
BigDecimal continuePerKg = nz(band.getContinuePerKg());
|
||||||
|
if (weightG <= firstG) {
|
||||||
|
return Optional.of(firstAmt.setScale(2, RoundingMode.HALF_UP));
|
||||||
|
}
|
||||||
|
int remainG = weightG - firstG;
|
||||||
|
int continueKg = (remainG + 999) / 1000;
|
||||||
|
return Optional.of(firstAmt.add(continuePerKg.multiply(BigDecimal.valueOf(continueKg)))
|
||||||
|
.setScale(2, RoundingMode.HALF_UP));
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 计费重取整:CEIL_KG 向上取整到整千克(克)。 */
|
||||||
|
static int applyWeightRound(int weightG, String round) {
|
||||||
|
if (weightG <= 0) {
|
||||||
|
return weightG;
|
||||||
|
}
|
||||||
|
if ("CEIL_KG".equalsIgnoreCase(round)) {
|
||||||
|
return ((weightG + 999) / 1000) * 1000;
|
||||||
|
}
|
||||||
|
return weightG;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> parseDestinations(String provincesJson) {
|
||||||
|
if (!StringUtils.hasText(provincesJson)) {
|
||||||
|
return List.of();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
List<String> list = objectMapper.readValue(provincesJson, new TypeReference<>() {
|
return objectMapper.readValue(provincesJson, new TypeReference<>() {
|
||||||
});
|
});
|
||||||
return list.stream().anyMatch(p -> Objects.equals(p, provinceFull));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean destinationEquals(String configured, String actual) {
|
||||||
|
if (!StringUtils.hasText(configured) || !StringUtils.hasText(actual)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
String a = configured.trim();
|
||||||
|
String b = actual.trim();
|
||||||
|
if (Objects.equals(a, b)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
String na = BiRegionNormalizer.normalize(a);
|
||||||
|
String nb = BiRegionNormalizer.normalize(b);
|
||||||
|
return !BiRegionNormalizer.isUnknown(na) && Objects.equals(na, nb);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BigDecimal nz(BigDecimal v) {
|
private static BigDecimal nz(BigDecimal v) {
|
||||||
@@ -206,7 +269,8 @@ public class FreightQuoteResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 体积重(克):长宽高 mm,divisor 默认 6000 → kg = L*W*H/divisor,再 ×1000。
|
* 体积重(克):长宽高 mm,divisor 默认 6000(cm 公式)。
|
||||||
|
* 克 = ceil(Lmm * Wmm * Hmm / divisor)。
|
||||||
*/
|
*/
|
||||||
public static int volumetricWeightG(Integer lengthMm, Integer widthMm, Integer heightMm, Integer divisor) {
|
public static int volumetricWeightG(Integer lengthMm, Integer widthMm, Integer heightMm, Integer divisor) {
|
||||||
if (lengthMm == null || widthMm == null || heightMm == null
|
if (lengthMm == null || widthMm == null || heightMm == null
|
||||||
@@ -215,8 +279,7 @@ public class FreightQuoteResolver {
|
|||||||
}
|
}
|
||||||
int d = divisor != null && divisor > 0 ? divisor : 6000;
|
int d = divisor != null && divisor > 0 ? divisor : 6000;
|
||||||
long volume = (long) lengthMm * widthMm * heightMm;
|
long volume = (long) lengthMm * widthMm * heightMm;
|
||||||
// kg = volume / d;g = kg * 1000 = volume * 1000 / d
|
return (int) Math.ceil(volume * 1.0 / d);
|
||||||
return (int) Math.ceil(volume * 1000.0 / d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int chargeableWeightG(int actualG, int volumetricG, boolean useVolumetric) {
|
public static int chargeableWeightG(int actualG, int volumetricG, boolean useVolumetric) {
|
||||||
|
|||||||
+3
-3
@@ -2,9 +2,9 @@ package top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteTierPO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteBandPO;
|
||||||
|
|
||||||
/** ExpressQuoteTier Mapper */
|
/** 快递报价重量带 Mapper */
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ExpressQuoteTierMapper extends BaseMapper<ExpressQuoteTierPO> {
|
public interface ExpressQuoteBandMapper extends BaseMapper<ExpressQuoteBandPO> {
|
||||||
}
|
}
|
||||||
+22
-4
@@ -27,7 +27,6 @@ public final class ExpressQuoteDtos {
|
|||||||
private String billingMode;
|
private String billingMode;
|
||||||
private Integer status;
|
private Integer status;
|
||||||
private String remark;
|
private String remark;
|
||||||
/** 创建时可顺带写入首个版本 */
|
|
||||||
@Valid
|
@Valid
|
||||||
private VersionUpsert initialVersion;
|
private VersionUpsert initialVersion;
|
||||||
}
|
}
|
||||||
@@ -60,6 +59,8 @@ public final class ExpressQuoteDtos {
|
|||||||
private BigDecimal minAmount;
|
private BigDecimal minAmount;
|
||||||
private Integer volumeDivisor;
|
private Integer volumeDivisor;
|
||||||
private Integer useVolumetric;
|
private Integer useVolumetric;
|
||||||
|
/** NONE / CEIL_KG */
|
||||||
|
private String weightRound;
|
||||||
private String remark;
|
private String remark;
|
||||||
@Valid
|
@Valid
|
||||||
private List<RegionUpsert> regions;
|
private List<RegionUpsert> regions;
|
||||||
@@ -69,13 +70,30 @@ public final class ExpressQuoteDtos {
|
|||||||
public static class RegionUpsert {
|
public static class RegionUpsert {
|
||||||
@NotBlank(message = "分区名不能为空")
|
@NotBlank(message = "分区名不能为空")
|
||||||
private String regionName;
|
private String regionName;
|
||||||
/** 省份全称列表 */
|
/** 一类/二类… */
|
||||||
|
private String zoneLabel;
|
||||||
|
/** 目的地:省全称或市名 */
|
||||||
private List<String> provinces;
|
private List<String> provinces;
|
||||||
private Integer isDefault;
|
private Integer isDefault;
|
||||||
private Integer sortOrder;
|
private Integer sortOrder;
|
||||||
|
/** 重量带(REGION_WEIGHT 必填) */
|
||||||
|
@Valid
|
||||||
|
private List<BandUpsert> bands;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class BandUpsert {
|
||||||
|
/** 下限克(含),默认 0 */
|
||||||
|
private Integer weightFromG;
|
||||||
|
/** 上限克(含);空=无上限 */
|
||||||
|
private Integer weightToG;
|
||||||
|
/** FLAT_TICKET / FIRST_PLUS_KG */
|
||||||
|
@NotBlank(message = "计价方式不能为空")
|
||||||
|
private String priceMode;
|
||||||
|
private BigDecimal flatAmount;
|
||||||
private Integer firstWeightG;
|
private Integer firstWeightG;
|
||||||
private BigDecimal firstAmount;
|
private BigDecimal firstAmount;
|
||||||
private Integer additionalWeightG;
|
private BigDecimal continuePerKg;
|
||||||
private BigDecimal additionalAmount;
|
private Integer sortOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-7
@@ -6,10 +6,13 @@ import lombok.Data;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/** 分区首重/续重。 */
|
/** 报价重量带(一分区多行)。 */
|
||||||
@Data
|
@Data
|
||||||
@TableName("ec_express_quote_tier")
|
@TableName("ec_express_quote_band")
|
||||||
public class ExpressQuoteTierPO {
|
public class ExpressQuoteBandPO {
|
||||||
|
|
||||||
|
public static final String MODE_FLAT_TICKET = "FLAT_TICKET";
|
||||||
|
public static final String MODE_FIRST_PLUS_KG = "FIRST_PLUS_KG";
|
||||||
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -23,17 +26,30 @@ public class ExpressQuoteTierPO {
|
|||||||
@TableField("region_id")
|
@TableField("region_id")
|
||||||
private Long regionId;
|
private Long regionId;
|
||||||
|
|
||||||
|
@TableField("weight_from_g")
|
||||||
|
private Integer weightFromG;
|
||||||
|
|
||||||
|
/** NULL=无上限 */
|
||||||
|
@TableField("weight_to_g")
|
||||||
|
private Integer weightToG;
|
||||||
|
|
||||||
|
@TableField("price_mode")
|
||||||
|
private String priceMode;
|
||||||
|
|
||||||
|
@TableField("flat_amount")
|
||||||
|
private BigDecimal flatAmount;
|
||||||
|
|
||||||
@TableField("first_weight_g")
|
@TableField("first_weight_g")
|
||||||
private Integer firstWeightG;
|
private Integer firstWeightG;
|
||||||
|
|
||||||
@TableField("first_amount")
|
@TableField("first_amount")
|
||||||
private BigDecimal firstAmount;
|
private BigDecimal firstAmount;
|
||||||
|
|
||||||
@TableField("additional_weight_g")
|
@TableField("continue_per_kg")
|
||||||
private Integer additionalWeightG;
|
private BigDecimal continuePerKg;
|
||||||
|
|
||||||
@TableField("additional_amount")
|
@TableField("sort_order")
|
||||||
private BigDecimal additionalAmount;
|
private Integer sortOrder;
|
||||||
|
|
||||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
+5
-1
@@ -22,7 +22,11 @@ public class ExpressQuoteRegionPO {
|
|||||||
@TableField("region_name")
|
@TableField("region_name")
|
||||||
private String regionName;
|
private String regionName;
|
||||||
|
|
||||||
/** JSON 数组字符串 */
|
/** 一类/二类等展示标签 */
|
||||||
|
@TableField("zone_label")
|
||||||
|
private String zoneLabel;
|
||||||
|
|
||||||
|
/** 目的地 JSON(省全称或市名) */
|
||||||
@TableField("provinces_json")
|
@TableField("provinces_json")
|
||||||
private String provincesJson;
|
private String provincesJson;
|
||||||
|
|
||||||
|
|||||||
+4
@@ -46,6 +46,10 @@ public class ExpressQuoteVersionPO {
|
|||||||
@TableField("use_volumetric")
|
@TableField("use_volumetric")
|
||||||
private Integer useVolumetric;
|
private Integer useVolumetric;
|
||||||
|
|
||||||
|
/** NONE / CEIL_KG */
|
||||||
|
@TableField("weight_round")
|
||||||
|
private String weightRound;
|
||||||
|
|
||||||
@TableField("remark")
|
@TableField("remark")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
|||||||
+14
-3
@@ -21,7 +21,6 @@ public class ExpressQuoteVO {
|
|||||||
private String remark;
|
private String remark;
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
/** 当前生效版本(最大 effective_from)摘要 */
|
|
||||||
private VersionVO currentVersion;
|
private VersionVO currentVersion;
|
||||||
private List<VersionVO> versions;
|
private List<VersionVO> versions;
|
||||||
|
|
||||||
@@ -36,6 +35,7 @@ public class ExpressQuoteVO {
|
|||||||
private BigDecimal minAmount;
|
private BigDecimal minAmount;
|
||||||
private Integer volumeDivisor;
|
private Integer volumeDivisor;
|
||||||
private Integer useVolumetric;
|
private Integer useVolumetric;
|
||||||
|
private String weightRound;
|
||||||
private String remark;
|
private String remark;
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
private List<RegionVO> regions;
|
private List<RegionVO> regions;
|
||||||
@@ -45,12 +45,23 @@ public class ExpressQuoteVO {
|
|||||||
public static class RegionVO {
|
public static class RegionVO {
|
||||||
private Long id;
|
private Long id;
|
||||||
private String regionName;
|
private String regionName;
|
||||||
|
private String zoneLabel;
|
||||||
private List<String> provinces;
|
private List<String> provinces;
|
||||||
private Integer isDefault;
|
private Integer isDefault;
|
||||||
private Integer sortOrder;
|
private Integer sortOrder;
|
||||||
|
private List<BandVO> bands;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class BandVO {
|
||||||
|
private Long id;
|
||||||
|
private Integer weightFromG;
|
||||||
|
private Integer weightToG;
|
||||||
|
private String priceMode;
|
||||||
|
private BigDecimal flatAmount;
|
||||||
private Integer firstWeightG;
|
private Integer firstWeightG;
|
||||||
private BigDecimal firstAmount;
|
private BigDecimal firstAmount;
|
||||||
private Integer additionalWeightG;
|
private BigDecimal continuePerKg;
|
||||||
private BigDecimal additionalAmount;
|
private Integer sortOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+91
-48
@@ -17,15 +17,15 @@ import top.xyquan.ecomdmbbackend.modules.bi.orderstat.support.BiRegionNormalizer
|
|||||||
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.mapper.ProductSkuMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.mapper.ProductSkuMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.model.po.ProductSkuPO;
|
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.model.po.ProductSkuPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.freight.ExpressCarrierCodes;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.freight.ExpressCarrierCodes;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteBandMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteRegionMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteRegionMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteTierMapper;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteVersionMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteVersionMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.WarehouseExpressBindMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.WarehouseExpressBindMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.dto.ExpressQuoteDtos;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.dto.ExpressQuoteDtos;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteBandPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuotePO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuotePO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteRegionPO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteRegionPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteTierPO;
|
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteVersionPO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.ExpressQuoteVersionPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.WarehouseExpressBindPO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.WarehouseExpressBindPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.vo.ExpressQuoteVO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.vo.ExpressQuoteVO;
|
||||||
@@ -48,7 +48,7 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
private final CurrentUserContext currentUserContext;
|
private final CurrentUserContext currentUserContext;
|
||||||
private final ExpressQuoteVersionMapper versionMapper;
|
private final ExpressQuoteVersionMapper versionMapper;
|
||||||
private final ExpressQuoteRegionMapper regionMapper;
|
private final ExpressQuoteRegionMapper regionMapper;
|
||||||
private final ExpressQuoteTierMapper tierMapper;
|
private final ExpressQuoteBandMapper bandMapper;
|
||||||
private final WarehouseExpressBindMapper bindMapper;
|
private final WarehouseExpressBindMapper bindMapper;
|
||||||
private final ProductSkuMapper productSkuMapper;
|
private final ProductSkuMapper productSkuMapper;
|
||||||
private final BiOrderStatDirtyDayService dirtyDayService;
|
private final BiOrderStatDirtyDayService dirtyDayService;
|
||||||
@@ -57,7 +57,7 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
public ExpressQuoteServiceImpl(CurrentUserContext currentUserContext,
|
public ExpressQuoteServiceImpl(CurrentUserContext currentUserContext,
|
||||||
ExpressQuoteVersionMapper versionMapper,
|
ExpressQuoteVersionMapper versionMapper,
|
||||||
ExpressQuoteRegionMapper regionMapper,
|
ExpressQuoteRegionMapper regionMapper,
|
||||||
ExpressQuoteTierMapper tierMapper,
|
ExpressQuoteBandMapper bandMapper,
|
||||||
WarehouseExpressBindMapper bindMapper,
|
WarehouseExpressBindMapper bindMapper,
|
||||||
ProductSkuMapper productSkuMapper,
|
ProductSkuMapper productSkuMapper,
|
||||||
BiOrderStatDirtyDayService dirtyDayService,
|
BiOrderStatDirtyDayService dirtyDayService,
|
||||||
@@ -65,7 +65,7 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
this.currentUserContext = currentUserContext;
|
this.currentUserContext = currentUserContext;
|
||||||
this.versionMapper = versionMapper;
|
this.versionMapper = versionMapper;
|
||||||
this.regionMapper = regionMapper;
|
this.regionMapper = regionMapper;
|
||||||
this.tierMapper = tierMapper;
|
this.bandMapper = bandMapper;
|
||||||
this.bindMapper = bindMapper;
|
this.bindMapper = bindMapper;
|
||||||
this.productSkuMapper = productSkuMapper;
|
this.productSkuMapper = productSkuMapper;
|
||||||
this.dirtyDayService = dirtyDayService;
|
this.dirtyDayService = dirtyDayService;
|
||||||
@@ -235,15 +235,7 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
applyVersionFields(version, dto);
|
applyVersionFields(version, dto);
|
||||||
version.setUpdateBy(currentUserContext.getCurrentUserId());
|
version.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||||
versionMapper.updateById(version);
|
versionMapper.updateById(version);
|
||||||
// 重建分区
|
clearRegionsAndBands(version.getId());
|
||||||
List<ExpressQuoteRegionPO> oldRegions = regionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
|
||||||
.eq(ExpressQuoteRegionPO::getVersionId, version.getId()));
|
|
||||||
for (ExpressQuoteRegionPO r : oldRegions) {
|
|
||||||
tierMapper.delete(new LambdaQueryWrapper<ExpressQuoteTierPO>()
|
|
||||||
.eq(ExpressQuoteTierPO::getRegionId, r.getId()));
|
|
||||||
}
|
|
||||||
regionMapper.delete(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
|
||||||
.eq(ExpressQuoteRegionPO::getVersionId, version.getId()));
|
|
||||||
} else {
|
} else {
|
||||||
version = new ExpressQuoteVersionPO();
|
version = new ExpressQuoteVersionPO();
|
||||||
version.setCompanyId(quote.getCompanyId());
|
version.setCompanyId(quote.getCompanyId());
|
||||||
@@ -266,6 +258,11 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
version.setMinAmount(dto.getMinAmount());
|
version.setMinAmount(dto.getMinAmount());
|
||||||
version.setVolumeDivisor(dto.getVolumeDivisor() != null ? dto.getVolumeDivisor() : 6000);
|
version.setVolumeDivisor(dto.getVolumeDivisor() != null ? dto.getVolumeDivisor() : 6000);
|
||||||
version.setUseVolumetric(dto.getUseVolumetric() != null ? dto.getUseVolumetric() : 0);
|
version.setUseVolumetric(dto.getUseVolumetric() != null ? dto.getUseVolumetric() : 0);
|
||||||
|
String round = dto.getWeightRound() != null ? dto.getWeightRound().trim().toUpperCase() : "NONE";
|
||||||
|
if (!"CEIL_KG".equals(round)) {
|
||||||
|
round = "NONE";
|
||||||
|
}
|
||||||
|
version.setWeightRound(round);
|
||||||
version.setRemark(dto.getRemark());
|
version.setRemark(dto.getRemark());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,44 +272,78 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ExpressQuoteDtos.RegionUpsert r : regions) {
|
for (ExpressQuoteDtos.RegionUpsert r : regions) {
|
||||||
|
if (r.getBands() == null || r.getBands().isEmpty()) {
|
||||||
|
throw new BusinessException("分区「" + r.getRegionName() + "」至少配置一条重量带");
|
||||||
|
}
|
||||||
ExpressQuoteRegionPO region = new ExpressQuoteRegionPO();
|
ExpressQuoteRegionPO region = new ExpressQuoteRegionPO();
|
||||||
region.setCompanyId(companyId);
|
region.setCompanyId(companyId);
|
||||||
region.setVersionId(versionId);
|
region.setVersionId(versionId);
|
||||||
region.setRegionName(r.getRegionName().trim());
|
region.setRegionName(r.getRegionName().trim());
|
||||||
region.setProvincesJson(toProvincesJson(r.getProvinces()));
|
region.setZoneLabel(StringUtils.hasText(r.getZoneLabel()) ? r.getZoneLabel().trim() : null);
|
||||||
|
region.setProvincesJson(toDestinationsJson(r.getProvinces()));
|
||||||
region.setIsDefault(r.getIsDefault() != null ? r.getIsDefault() : 0);
|
region.setIsDefault(r.getIsDefault() != null ? r.getIsDefault() : 0);
|
||||||
region.setSortOrder(r.getSortOrder() != null ? r.getSortOrder() : i++);
|
region.setSortOrder(r.getSortOrder() != null ? r.getSortOrder() : i++);
|
||||||
regionMapper.insert(region);
|
regionMapper.insert(region);
|
||||||
|
int bi = 0;
|
||||||
ExpressQuoteTierPO tier = new ExpressQuoteTierPO();
|
for (ExpressQuoteDtos.BandUpsert b : r.getBands()) {
|
||||||
tier.setCompanyId(companyId);
|
saveBand(companyId, versionId, region.getId(), b, bi++);
|
||||||
tier.setVersionId(versionId);
|
}
|
||||||
tier.setRegionId(region.getId());
|
|
||||||
tier.setFirstWeightG(r.getFirstWeightG() != null ? r.getFirstWeightG() : 1000);
|
|
||||||
tier.setFirstAmount(r.getFirstAmount() != null ? r.getFirstAmount() : java.math.BigDecimal.ZERO);
|
|
||||||
tier.setAdditionalWeightG(r.getAdditionalWeightG() != null ? r.getAdditionalWeightG() : 1000);
|
|
||||||
tier.setAdditionalAmount(r.getAdditionalAmount() != null ? r.getAdditionalAmount() : java.math.BigDecimal.ZERO);
|
|
||||||
tierMapper.insert(tier);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toProvincesJson(List<String> provinces) {
|
private void saveBand(Long companyId, Long versionId, Long regionId,
|
||||||
|
ExpressQuoteDtos.BandUpsert b, int defaultOrder) {
|
||||||
|
String mode = b.getPriceMode().trim().toUpperCase();
|
||||||
|
if (!ExpressQuoteBandPO.MODE_FLAT_TICKET.equals(mode)
|
||||||
|
&& !ExpressQuoteBandPO.MODE_FIRST_PLUS_KG.equals(mode)) {
|
||||||
|
throw new BusinessException("不支持的重量带计价方式: " + b.getPriceMode());
|
||||||
|
}
|
||||||
|
int from = b.getWeightFromG() != null ? b.getWeightFromG() : 0;
|
||||||
|
Integer to = b.getWeightToG();
|
||||||
|
if (from < 0 || (to != null && to < from)) {
|
||||||
|
throw new BusinessException("重量带区间无效");
|
||||||
|
}
|
||||||
|
ExpressQuoteBandPO band = new ExpressQuoteBandPO();
|
||||||
|
band.setCompanyId(companyId);
|
||||||
|
band.setVersionId(versionId);
|
||||||
|
band.setRegionId(regionId);
|
||||||
|
band.setWeightFromG(from);
|
||||||
|
band.setWeightToG(to);
|
||||||
|
band.setPriceMode(mode);
|
||||||
|
band.setSortOrder(b.getSortOrder() != null ? b.getSortOrder() : defaultOrder);
|
||||||
|
if (ExpressQuoteBandPO.MODE_FLAT_TICKET.equals(mode)) {
|
||||||
|
if (b.getFlatAmount() == null) {
|
||||||
|
throw new BusinessException("元/票金额不能为空");
|
||||||
|
}
|
||||||
|
band.setFlatAmount(b.getFlatAmount());
|
||||||
|
} else {
|
||||||
|
if (b.getFirstAmount() == null || b.getContinuePerKg() == null) {
|
||||||
|
throw new BusinessException("首重价与续重元/kg 不能为空");
|
||||||
|
}
|
||||||
|
band.setFirstWeightG(b.getFirstWeightG() != null ? b.getFirstWeightG() : 0);
|
||||||
|
band.setFirstAmount(b.getFirstAmount());
|
||||||
|
band.setContinuePerKg(b.getContinuePerKg());
|
||||||
|
}
|
||||||
|
bandMapper.insert(band);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 目的地:能归一为省全称则用全称,否则保留原名(如深圳市)。 */
|
||||||
|
private String toDestinationsJson(List<String> destinations) {
|
||||||
try {
|
try {
|
||||||
Set<String> normalized = new HashSet<>();
|
Set<String> normalized = new HashSet<>();
|
||||||
if (provinces != null) {
|
if (destinations != null) {
|
||||||
for (String p : provinces) {
|
for (String p : destinations) {
|
||||||
if (!StringUtils.hasText(p)) {
|
if (!StringUtils.hasText(p)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String n = BiRegionNormalizer.normalize(p);
|
String raw = p.trim();
|
||||||
if (!BiRegionNormalizer.isUnknown(n)) {
|
String n = BiRegionNormalizer.normalize(raw);
|
||||||
normalized.add(n);
|
normalized.add(BiRegionNormalizer.isUnknown(n) ? raw : n);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return objectMapper.writeValueAsString(normalized.stream().sorted().toList());
|
return objectMapper.writeValueAsString(normalized.stream().sorted().toList());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BusinessException("省份列表序列化失败");
|
throw new BusinessException("目的地列表序列化失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,20 +387,29 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
}
|
}
|
||||||
} else if (ExpressQuotePO.MODE_REGION_WEIGHT.equals(billingMode)) {
|
} else if (ExpressQuotePO.MODE_REGION_WEIGHT.equals(billingMode)) {
|
||||||
if (dto.getRegions() == null || dto.getRegions().isEmpty()) {
|
if (dto.getRegions() == null || dto.getRegions().isEmpty()) {
|
||||||
throw new BusinessException("请配置分区与首重续重");
|
throw new BusinessException("请配置目的分区与重量带");
|
||||||
|
}
|
||||||
|
for (ExpressQuoteDtos.RegionUpsert r : dto.getRegions()) {
|
||||||
|
if (r.getBands() == null || r.getBands().isEmpty()) {
|
||||||
|
throw new BusinessException("分区「" + r.getRegionName() + "」至少一条重量带");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteVersionCascade(Long versionId) {
|
private void clearRegionsAndBands(Long versionId) {
|
||||||
List<ExpressQuoteRegionPO> regions = regionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
List<ExpressQuoteRegionPO> oldRegions = regionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
||||||
.eq(ExpressQuoteRegionPO::getVersionId, versionId));
|
.eq(ExpressQuoteRegionPO::getVersionId, versionId));
|
||||||
for (ExpressQuoteRegionPO r : regions) {
|
for (ExpressQuoteRegionPO r : oldRegions) {
|
||||||
tierMapper.delete(new LambdaQueryWrapper<ExpressQuoteTierPO>()
|
bandMapper.delete(new LambdaQueryWrapper<ExpressQuoteBandPO>()
|
||||||
.eq(ExpressQuoteTierPO::getRegionId, r.getId()));
|
.eq(ExpressQuoteBandPO::getRegionId, r.getId()));
|
||||||
}
|
}
|
||||||
regionMapper.delete(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
regionMapper.delete(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
||||||
.eq(ExpressQuoteRegionPO::getVersionId, versionId));
|
.eq(ExpressQuoteRegionPO::getVersionId, versionId));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteVersionCascade(Long versionId) {
|
||||||
|
clearRegionsAndBands(versionId);
|
||||||
versionMapper.deleteById(versionId);
|
versionMapper.deleteById(versionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,24 +467,27 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
List<ExpressQuoteRegionPO> regions = regionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
List<ExpressQuoteRegionPO> regions = regionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
||||||
.eq(ExpressQuoteRegionPO::getVersionId, v.getId())
|
.eq(ExpressQuoteRegionPO::getVersionId, v.getId())
|
||||||
.orderByAsc(ExpressQuoteRegionPO::getSortOrder));
|
.orderByAsc(ExpressQuoteRegionPO::getSortOrder));
|
||||||
List<ExpressQuoteTierPO> tiers = tierMapper.selectList(new LambdaQueryWrapper<ExpressQuoteTierPO>()
|
List<ExpressQuoteBandPO> bands = bandMapper.selectList(new LambdaQueryWrapper<ExpressQuoteBandPO>()
|
||||||
.eq(ExpressQuoteTierPO::getVersionId, v.getId()));
|
.eq(ExpressQuoteBandPO::getVersionId, v.getId())
|
||||||
var tierByRegion = tiers.stream().collect(Collectors.toMap(ExpressQuoteTierPO::getRegionId, t -> t, (a, b) -> a));
|
.orderByAsc(ExpressQuoteBandPO::getSortOrder)
|
||||||
|
.orderByAsc(ExpressQuoteBandPO::getWeightFromG));
|
||||||
|
var bandsByRegion = bands.stream().collect(Collectors.groupingBy(ExpressQuoteBandPO::getRegionId));
|
||||||
List<ExpressQuoteVO.RegionVO> regionVos = new ArrayList<>();
|
List<ExpressQuoteVO.RegionVO> regionVos = new ArrayList<>();
|
||||||
for (ExpressQuoteRegionPO r : regions) {
|
for (ExpressQuoteRegionPO r : regions) {
|
||||||
ExpressQuoteVO.RegionVO rv = new ExpressQuoteVO.RegionVO();
|
ExpressQuoteVO.RegionVO rv = new ExpressQuoteVO.RegionVO();
|
||||||
rv.setId(r.getId());
|
rv.setId(r.getId());
|
||||||
rv.setRegionName(r.getRegionName());
|
rv.setRegionName(r.getRegionName());
|
||||||
|
rv.setZoneLabel(r.getZoneLabel());
|
||||||
rv.setProvinces(parseProvinces(r.getProvincesJson()));
|
rv.setProvinces(parseProvinces(r.getProvincesJson()));
|
||||||
rv.setIsDefault(r.getIsDefault());
|
rv.setIsDefault(r.getIsDefault());
|
||||||
rv.setSortOrder(r.getSortOrder());
|
rv.setSortOrder(r.getSortOrder());
|
||||||
ExpressQuoteTierPO tier = tierByRegion.get(r.getId());
|
List<ExpressQuoteVO.BandVO> bandVos = new ArrayList<>();
|
||||||
if (tier != null) {
|
for (ExpressQuoteBandPO b : bandsByRegion.getOrDefault(r.getId(), List.of())) {
|
||||||
rv.setFirstWeightG(tier.getFirstWeightG());
|
ExpressQuoteVO.BandVO bv = new ExpressQuoteVO.BandVO();
|
||||||
rv.setFirstAmount(tier.getFirstAmount());
|
BeanCopyUtils.copyProperties(b, bv);
|
||||||
rv.setAdditionalWeightG(tier.getAdditionalWeightG());
|
bandVos.add(bv);
|
||||||
rv.setAdditionalAmount(tier.getAdditionalAmount());
|
|
||||||
}
|
}
|
||||||
|
rv.setBands(bandVos);
|
||||||
regionVos.add(rv);
|
regionVos.add(rv);
|
||||||
}
|
}
|
||||||
regionVos.sort(Comparator.comparing(r -> r.getSortOrder() != null ? r.getSortOrder() : 0));
|
regionVos.sort(Comparator.comparing(r -> r.getSortOrder() != null ? r.getSortOrder() : 0));
|
||||||
|
|||||||
@@ -31,18 +31,31 @@ export namespace ExpressQuoteDTO {
|
|||||||
minAmount?: number;
|
minAmount?: number;
|
||||||
volumeDivisor?: number;
|
volumeDivisor?: number;
|
||||||
useVolumetric?: number;
|
useVolumetric?: number;
|
||||||
|
/** NONE / CEIL_KG */
|
||||||
|
weightRound?: string;
|
||||||
remark?: string;
|
remark?: string;
|
||||||
regions?: RegionUpsert[];
|
regions?: RegionUpsert[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RegionUpsert {
|
export interface RegionUpsert {
|
||||||
regionName: string;
|
regionName: string;
|
||||||
|
zoneLabel?: string;
|
||||||
|
/** 目的地:省全称或市名 */
|
||||||
provinces?: string[];
|
provinces?: string[];
|
||||||
isDefault?: number;
|
isDefault?: number;
|
||||||
sortOrder?: number;
|
sortOrder?: number;
|
||||||
|
bands?: BandUpsert[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BandUpsert {
|
||||||
|
weightFromG?: number;
|
||||||
|
weightToG?: number | null;
|
||||||
|
/** FLAT_TICKET / FIRST_PLUS_KG */
|
||||||
|
priceMode: string;
|
||||||
|
flatAmount?: number;
|
||||||
firstWeightG?: number;
|
firstWeightG?: number;
|
||||||
firstAmount?: number;
|
firstAmount?: number;
|
||||||
additionalWeightG?: number;
|
continuePerKg?: number;
|
||||||
additionalAmount?: number;
|
sortOrder?: number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ export namespace ExpressQuoteVO {
|
|||||||
minAmount?: number;
|
minAmount?: number;
|
||||||
volumeDivisor?: number;
|
volumeDivisor?: number;
|
||||||
useVolumetric?: number;
|
useVolumetric?: number;
|
||||||
|
/** NONE / CEIL_KG */
|
||||||
|
weightRound?: string;
|
||||||
remark?: string;
|
remark?: string;
|
||||||
regions?: Region[];
|
regions?: Region[];
|
||||||
}
|
}
|
||||||
@@ -30,13 +32,24 @@ export namespace ExpressQuoteVO {
|
|||||||
export interface Region {
|
export interface Region {
|
||||||
id?: number;
|
id?: number;
|
||||||
regionName: string;
|
regionName: string;
|
||||||
|
zoneLabel?: string;
|
||||||
provinces?: string[];
|
provinces?: string[];
|
||||||
isDefault?: number;
|
isDefault?: number;
|
||||||
sortOrder?: number;
|
sortOrder?: number;
|
||||||
|
bands?: Band[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Band {
|
||||||
|
id?: number;
|
||||||
|
weightFromG: number;
|
||||||
|
weightToG?: number | null;
|
||||||
|
/** FLAT_TICKET / FIRST_PLUS_KG */
|
||||||
|
priceMode: string;
|
||||||
|
flatAmount?: number;
|
||||||
firstWeightG?: number;
|
firstWeightG?: number;
|
||||||
firstAmount?: number;
|
firstAmount?: number;
|
||||||
additionalWeightG?: number;
|
continuePerKg?: number;
|
||||||
additionalAmount?: number;
|
sortOrder?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CarrierOption {
|
export interface CarrierOption {
|
||||||
|
|||||||
+248
-65
@@ -6,6 +6,7 @@ import { computed, reactive, ref } from 'vue';
|
|||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Button,
|
||||||
Form,
|
Form,
|
||||||
FormItem,
|
FormItem,
|
||||||
Input,
|
Input,
|
||||||
@@ -14,23 +15,62 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
Switch,
|
Switch,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createExpressQuoteApi,
|
createExpressQuoteApi,
|
||||||
getExpressCarriersApi,
|
getExpressCarriersApi,
|
||||||
getExpressProvincesApi,
|
getExpressProvincesApi,
|
||||||
|
getExpressQuoteDetailApi,
|
||||||
updateExpressQuoteApi,
|
updateExpressQuoteApi,
|
||||||
upsertExpressQuoteVersionApi,
|
upsertExpressQuoteVersionApi,
|
||||||
} from '#/api/ec/express-quote';
|
} from '#/api/ec/express-quote';
|
||||||
|
|
||||||
const emit = defineEmits<{ success: [] }>();
|
const emit = defineEmits<{ success: [] }>();
|
||||||
|
|
||||||
|
interface BandRow {
|
||||||
|
weightFromG: number;
|
||||||
|
weightToG: number | null;
|
||||||
|
priceMode: string;
|
||||||
|
flatAmount: number;
|
||||||
|
firstWeightG: number;
|
||||||
|
firstAmount: number;
|
||||||
|
continuePerKg: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RegionRow {
|
||||||
|
regionName: string;
|
||||||
|
zoneLabel: string;
|
||||||
|
provinces: string[];
|
||||||
|
isDefault: boolean;
|
||||||
|
bands: BandRow[];
|
||||||
|
}
|
||||||
|
|
||||||
|
function emptyBand(fromG = 0): BandRow {
|
||||||
|
return {
|
||||||
|
weightFromG: fromG,
|
||||||
|
weightToG: null,
|
||||||
|
priceMode: 'FLAT_TICKET',
|
||||||
|
flatAmount: 0,
|
||||||
|
firstWeightG: 0,
|
||||||
|
firstAmount: 0,
|
||||||
|
continuePerKg: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function emptyRegion(): RegionRow {
|
||||||
|
return {
|
||||||
|
regionName: '默认区',
|
||||||
|
zoneLabel: '',
|
||||||
|
provinces: [],
|
||||||
|
isDefault: true,
|
||||||
|
bands: [emptyBand(0)],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const isEdit = ref(false);
|
const isEdit = ref(false);
|
||||||
const editingId = ref<number>();
|
const editingId = ref<number>();
|
||||||
const carriers = ref<ExpressQuoteVO.CarrierOption[]>([]);
|
const carriers = ref<ExpressQuoteVO.CarrierOption[]>([]);
|
||||||
const provinces = ref<ExpressQuoteVO.ProvinceOption[]>([]);
|
const provinces = ref<ExpressQuoteVO.ProvinceOption[]>([]);
|
||||||
const mode = ref('FLAT');
|
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
code: '',
|
code: '',
|
||||||
@@ -39,25 +79,25 @@ const form = reactive({
|
|||||||
billingMode: 'FLAT',
|
billingMode: 'FLAT',
|
||||||
status: 1,
|
status: 1,
|
||||||
remark: '',
|
remark: '',
|
||||||
effectiveFrom: dayjs().format('YYYY-MM-DD'),
|
effectiveFrom: new Date().toISOString().slice(0, 10),
|
||||||
flatAmount: 0,
|
flatAmount: 0,
|
||||||
unitScope: 'ORDER',
|
unitScope: 'ORDER',
|
||||||
pricePerKg: 0,
|
pricePerKg: 0,
|
||||||
minAmount: undefined as number | undefined,
|
minAmount: undefined as number | undefined,
|
||||||
volumeDivisor: 6000,
|
volumeDivisor: 6000,
|
||||||
useVolumetric: false,
|
useVolumetric: false,
|
||||||
regionName: '默认区',
|
weightRound: 'NONE',
|
||||||
regionProvinces: [] as string[],
|
regions: [emptyRegion()] as RegionRow[],
|
||||||
firstWeightG: 1000,
|
|
||||||
firstAmount: 0,
|
|
||||||
additionalWeightG: 1000,
|
|
||||||
additionalAmount: 0,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const isRegion = computed(() => form.billingMode === 'REGION_WEIGHT');
|
const isRegion = computed(() => form.billingMode === 'REGION_WEIGHT');
|
||||||
const isFlat = computed(() => form.billingMode === 'FLAT');
|
const isFlat = computed(() => form.billingMode === 'FLAT');
|
||||||
const isPerKg = computed(() => form.billingMode === 'PER_KG');
|
const isPerKg = computed(() => form.billingMode === 'PER_KG');
|
||||||
|
|
||||||
|
const provinceOptions = computed(() =>
|
||||||
|
provinces.value.map((p) => ({ value: p.code, label: p.name })),
|
||||||
|
);
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
onConfirm: handleSubmit,
|
onConfirm: handleSubmit,
|
||||||
onOpenChange: (open) => {
|
onOpenChange: (open) => {
|
||||||
@@ -73,20 +113,16 @@ function reset() {
|
|||||||
billingMode: 'FLAT',
|
billingMode: 'FLAT',
|
||||||
status: 1,
|
status: 1,
|
||||||
remark: '',
|
remark: '',
|
||||||
effectiveFrom: dayjs().format('YYYY-MM-DD'),
|
effectiveFrom: new Date().toISOString().slice(0, 10),
|
||||||
flatAmount: 0,
|
flatAmount: 0,
|
||||||
unitScope: 'ORDER',
|
unitScope: 'ORDER',
|
||||||
pricePerKg: 0,
|
pricePerKg: 0,
|
||||||
minAmount: undefined,
|
minAmount: undefined,
|
||||||
volumeDivisor: 6000,
|
volumeDivisor: 6000,
|
||||||
useVolumetric: false,
|
useVolumetric: false,
|
||||||
regionName: '默认区',
|
weightRound: 'NONE',
|
||||||
regionProvinces: [],
|
|
||||||
firstWeightG: 1000,
|
|
||||||
firstAmount: 0,
|
|
||||||
additionalWeightG: 1000,
|
|
||||||
additionalAmount: 0,
|
|
||||||
});
|
});
|
||||||
|
form.regions = [emptyRegion()];
|
||||||
isEdit.value = false;
|
isEdit.value = false;
|
||||||
editingId.value = undefined;
|
editingId.value = undefined;
|
||||||
}
|
}
|
||||||
@@ -100,33 +136,100 @@ async function ensureMeta() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fillFromVersion(v?: ExpressQuoteVO.Version) {
|
||||||
|
if (!v) return;
|
||||||
|
form.effectiveFrom = v.effectiveFrom;
|
||||||
|
form.flatAmount = v.flatAmount ?? 0;
|
||||||
|
form.unitScope = v.unitScope || 'ORDER';
|
||||||
|
form.pricePerKg = v.pricePerKg ?? 0;
|
||||||
|
form.minAmount = v.minAmount;
|
||||||
|
form.volumeDivisor = v.volumeDivisor ?? 6000;
|
||||||
|
form.useVolumetric = v.useVolumetric === 1;
|
||||||
|
form.weightRound = v.weightRound || 'NONE';
|
||||||
|
if (v.regions?.length) {
|
||||||
|
form.regions = v.regions.map((r) => ({
|
||||||
|
regionName: r.regionName,
|
||||||
|
zoneLabel: r.zoneLabel || '',
|
||||||
|
provinces: r.provinces ? [...r.provinces] : [],
|
||||||
|
isDefault: r.isDefault === 1,
|
||||||
|
bands:
|
||||||
|
r.bands?.length ?
|
||||||
|
r.bands.map((b) => ({
|
||||||
|
weightFromG: b.weightFromG ?? 0,
|
||||||
|
weightToG: b.weightToG ?? null,
|
||||||
|
priceMode: b.priceMode || 'FLAT_TICKET',
|
||||||
|
flatAmount: b.flatAmount ?? 0,
|
||||||
|
firstWeightG: b.firstWeightG ?? 0,
|
||||||
|
firstAmount: b.firstAmount ?? 0,
|
||||||
|
continuePerKg: b.continuePerKg ?? 0,
|
||||||
|
}))
|
||||||
|
: [emptyBand(0)],
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function open(edit: boolean, row?: ExpressQuoteVO.Info) {
|
async function open(edit: boolean, row?: ExpressQuoteVO.Info) {
|
||||||
await ensureMeta();
|
await ensureMeta();
|
||||||
isEdit.value = edit;
|
isEdit.value = edit;
|
||||||
if (edit && row) {
|
if (edit && row) {
|
||||||
editingId.value = row.id;
|
editingId.value = row.id;
|
||||||
form.code = row.code;
|
const detail = await getExpressQuoteDetailApi(row.id);
|
||||||
form.name = row.name;
|
form.code = detail.code;
|
||||||
form.carrierCode = row.carrierCode;
|
form.name = detail.name;
|
||||||
form.billingMode = row.billingMode;
|
form.carrierCode = detail.carrierCode;
|
||||||
form.status = row.status;
|
form.billingMode = detail.billingMode;
|
||||||
form.remark = row.remark || '';
|
form.status = detail.status;
|
||||||
mode.value = row.billingMode;
|
form.remark = detail.remark || '';
|
||||||
|
fillFromVersion(detail.currentVersion);
|
||||||
} else {
|
} else {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
modalApi.setState({
|
modalApi.setState({
|
||||||
title: edit ? '编辑报价单' : '新建报价单',
|
title: edit ? '编辑报价单' : '新建报价单',
|
||||||
class: 'w-[640px]',
|
class: form.billingMode === 'REGION_WEIGHT' ? 'w-[920px]' : 'w-[640px]',
|
||||||
});
|
});
|
||||||
modalApi.open();
|
modalApi.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addRegion() {
|
||||||
|
form.regions.push({
|
||||||
|
regionName: `分区${form.regions.length + 1}`,
|
||||||
|
zoneLabel: '',
|
||||||
|
provinces: [],
|
||||||
|
isDefault: false,
|
||||||
|
bands: [emptyBand(0)],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeRegion(idx: number) {
|
||||||
|
if (form.regions.length <= 1) {
|
||||||
|
message.warning('至少保留一个分区');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
form.regions.splice(idx, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addBand(region: RegionRow) {
|
||||||
|
const last = region.bands[region.bands.length - 1];
|
||||||
|
const nextFrom =
|
||||||
|
last?.weightToG != null ? last.weightToG + 1 : (last?.weightFromG ?? 0) + 1000;
|
||||||
|
region.bands.push(emptyBand(nextFrom));
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeBand(region: RegionRow, idx: number) {
|
||||||
|
if (region.bands.length <= 1) {
|
||||||
|
message.warning('每分区至少一条重量带');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
region.bands.splice(idx, 1);
|
||||||
|
}
|
||||||
|
|
||||||
function buildVersion(): ExpressQuoteDTO.VersionUpsert {
|
function buildVersion(): ExpressQuoteDTO.VersionUpsert {
|
||||||
const version: ExpressQuoteDTO.VersionUpsert = {
|
const version: ExpressQuoteDTO.VersionUpsert = {
|
||||||
effectiveFrom: form.effectiveFrom,
|
effectiveFrom: form.effectiveFrom,
|
||||||
volumeDivisor: form.volumeDivisor,
|
volumeDivisor: form.volumeDivisor,
|
||||||
useVolumetric: form.useVolumetric ? 1 : 0,
|
useVolumetric: form.useVolumetric ? 1 : 0,
|
||||||
|
weightRound: form.weightRound,
|
||||||
};
|
};
|
||||||
if (form.billingMode === 'FLAT') {
|
if (form.billingMode === 'FLAT') {
|
||||||
version.flatAmount = form.flatAmount;
|
version.flatAmount = form.flatAmount;
|
||||||
@@ -135,17 +238,23 @@ function buildVersion(): ExpressQuoteDTO.VersionUpsert {
|
|||||||
version.pricePerKg = form.pricePerKg;
|
version.pricePerKg = form.pricePerKg;
|
||||||
version.minAmount = form.minAmount;
|
version.minAmount = form.minAmount;
|
||||||
} else {
|
} else {
|
||||||
version.regions = [
|
version.regions = form.regions.map((r, i) => ({
|
||||||
{
|
regionName: r.regionName.trim() || `分区${i + 1}`,
|
||||||
regionName: form.regionName || '默认区',
|
zoneLabel: r.zoneLabel.trim() || undefined,
|
||||||
provinces: form.regionProvinces,
|
provinces: r.provinces,
|
||||||
isDefault: 1,
|
isDefault: r.isDefault ? 1 : 0,
|
||||||
firstWeightG: form.firstWeightG,
|
sortOrder: i,
|
||||||
firstAmount: form.firstAmount,
|
bands: r.bands.map((b, bi) => ({
|
||||||
additionalWeightG: form.additionalWeightG,
|
weightFromG: b.weightFromG ?? 0,
|
||||||
additionalAmount: form.additionalAmount,
|
weightToG: b.weightToG,
|
||||||
},
|
priceMode: b.priceMode,
|
||||||
];
|
flatAmount: b.priceMode === 'FLAT_TICKET' ? b.flatAmount : undefined,
|
||||||
|
firstWeightG: b.priceMode === 'FIRST_PLUS_KG' ? b.firstWeightG : undefined,
|
||||||
|
firstAmount: b.priceMode === 'FIRST_PLUS_KG' ? b.firstAmount : undefined,
|
||||||
|
continuePerKg: b.priceMode === 'FIRST_PLUS_KG' ? b.continuePerKg : undefined,
|
||||||
|
sortOrder: bi,
|
||||||
|
})),
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
@@ -155,6 +264,14 @@ async function handleSubmit() {
|
|||||||
message.warning('请填写编码与名称');
|
message.warning('请填写编码与名称');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isRegion.value) {
|
||||||
|
for (const r of form.regions) {
|
||||||
|
if (!r.bands.length) {
|
||||||
|
message.warning(`分区「${r.regionName}」至少一条重量带`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
modalApi.setState({ confirming: true });
|
modalApi.setState({ confirming: true });
|
||||||
try {
|
try {
|
||||||
if (isEdit.value && editingId.value) {
|
if (isEdit.value && editingId.value) {
|
||||||
@@ -164,7 +281,6 @@ async function handleSubmit() {
|
|||||||
status: form.status,
|
status: form.status,
|
||||||
remark: form.remark || undefined,
|
remark: form.remark || undefined,
|
||||||
});
|
});
|
||||||
// 编辑时可追加版本
|
|
||||||
if (form.effectiveFrom) {
|
if (form.effectiveFrom) {
|
||||||
await upsertExpressQuoteVersionApi(editingId.value, buildVersion());
|
await upsertExpressQuoteVersionApi(editingId.value, buildVersion());
|
||||||
}
|
}
|
||||||
@@ -193,7 +309,7 @@ defineExpose({ open });
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal>
|
<Modal>
|
||||||
<Form layout="vertical" class="max-h-[70vh] overflow-y-auto px-1">
|
<Form layout="vertical" class="max-h-[75vh] overflow-y-auto px-1">
|
||||||
<FormItem v-if="!isEdit" label="报价编码" required>
|
<FormItem v-if="!isEdit" label="报价编码" required>
|
||||||
<Input v-model:value="form.code" />
|
<Input v-model:value="form.code" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -214,7 +330,7 @@ defineExpose({ open });
|
|||||||
:options="[
|
:options="[
|
||||||
{ value: 'FLAT', label: '一口价 FLAT' },
|
{ value: 'FLAT', label: '一口价 FLAT' },
|
||||||
{ value: 'PER_KG', label: '按千克 PER_KG' },
|
{ value: 'PER_KG', label: '按千克 PER_KG' },
|
||||||
{ value: 'REGION_WEIGHT', label: '分区首重续重' },
|
{ value: 'REGION_WEIGHT', label: '分区×重量带' },
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -258,42 +374,109 @@ defineExpose({ open });
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="isRegion">
|
<template v-if="isRegion">
|
||||||
<FormItem label="分区名">
|
<div class="mb-2 flex items-center justify-between">
|
||||||
<Input v-model:value="form.regionName" />
|
<span class="text-sm text-muted-foreground">目的分区 × 重量带(对齐承运商报价矩阵)</span>
|
||||||
</FormItem>
|
<Button size="small" type="dashed" @click="addRegion">添加分区</Button>
|
||||||
<FormItem label="覆盖省份">
|
</div>
|
||||||
<Select
|
<div
|
||||||
v-model:value="form.regionProvinces"
|
v-for="(region, ri) in form.regions"
|
||||||
mode="multiple"
|
:key="ri"
|
||||||
allow-clear
|
class="mb-3 rounded border border-border p-3"
|
||||||
show-search
|
>
|
||||||
option-filter-prop="label"
|
<div class="mb-2 flex items-start justify-between gap-2">
|
||||||
:options="provinces.map((p) => ({ value: p.code, label: p.name }))"
|
<div class="grid flex-1 grid-cols-3 gap-2">
|
||||||
placeholder="可多选;设为默认分区"
|
<FormItem label="分区名" class="mb-0">
|
||||||
/>
|
<Input v-model:value="region.regionName" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<div class="grid grid-cols-2 gap-3">
|
<FormItem label="价区标签" class="mb-0">
|
||||||
<FormItem label="首重(克)">
|
<Input v-model:value="region.zoneLabel" placeholder="一类/二类…" />
|
||||||
<InputNumber v-model:value="form.firstWeightG" :min="1" class="w-full" />
|
</FormItem>
|
||||||
</FormItem>
|
<FormItem label="默认分区" class="mb-0">
|
||||||
<FormItem label="首重价">
|
<Switch v-model:checked="region.isDefault" />
|
||||||
<InputNumber v-model:value="form.firstAmount" :min="0" class="w-full" />
|
</FormItem>
|
||||||
</FormItem>
|
</div>
|
||||||
<FormItem label="续重步进(克)">
|
<Button size="small" danger type="link" @click="removeRegion(ri)">删除</Button>
|
||||||
<InputNumber v-model:value="form.additionalWeightG" :min="1" class="w-full" />
|
</div>
|
||||||
</FormItem>
|
<FormItem label="目的地(省或市)" class="mb-2">
|
||||||
<FormItem label="续重价">
|
<Select
|
||||||
<InputNumber v-model:value="form.additionalAmount" :min="0" class="w-full" />
|
v-model:value="region.provinces"
|
||||||
|
mode="tags"
|
||||||
|
allow-clear
|
||||||
|
show-search
|
||||||
|
option-filter-prop="label"
|
||||||
|
:options="provinceOptions"
|
||||||
|
placeholder="选省或输入市名如深圳市"
|
||||||
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
<div class="mb-1 flex items-center justify-between">
|
||||||
|
<span class="text-xs text-muted-foreground">重量带</span>
|
||||||
|
<Button size="small" type="link" @click="addBand(region)">加带</Button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-for="(band, bi) in region.bands"
|
||||||
|
:key="bi"
|
||||||
|
class="mb-2 grid grid-cols-12 items-end gap-2 rounded bg-muted/40 p-2"
|
||||||
|
>
|
||||||
|
<FormItem label="从(克)" class="col-span-2 mb-0">
|
||||||
|
<InputNumber v-model:value="band.weightFromG" :min="0" class="w-full" />
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="到(克)" class="col-span-2 mb-0">
|
||||||
|
<InputNumber
|
||||||
|
v-model:value="band.weightToG"
|
||||||
|
:min="0"
|
||||||
|
class="w-full"
|
||||||
|
placeholder="空=无上限"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="方式" class="col-span-3 mb-0">
|
||||||
|
<Select
|
||||||
|
v-model:value="band.priceMode"
|
||||||
|
:options="[
|
||||||
|
{ value: 'FLAT_TICKET', label: '元/票' },
|
||||||
|
{ value: 'FIRST_PLUS_KG', label: '首重+续重/kg' },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
<template v-if="band.priceMode === 'FLAT_TICKET'">
|
||||||
|
<FormItem label="元/票" class="col-span-3 mb-0">
|
||||||
|
<InputNumber v-model:value="band.flatAmount" :min="0" class="w-full" />
|
||||||
|
</FormItem>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<FormItem label="首重克" class="col-span-1 mb-0">
|
||||||
|
<InputNumber v-model:value="band.firstWeightG" :min="0" class="w-full" />
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="首重价" class="col-span-2 mb-0">
|
||||||
|
<InputNumber v-model:value="band.firstAmount" :min="0" class="w-full" />
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="续重元/kg" class="col-span-2 mb-0">
|
||||||
|
<InputNumber v-model:value="band.continuePerKg" :min="0" class="w-full" />
|
||||||
|
</FormItem>
|
||||||
|
</template>
|
||||||
|
<div class="col-span-2 flex justify-end pb-1">
|
||||||
|
<Button size="small" type="link" danger @click="removeBand(region, bi)">
|
||||||
|
删带
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div class="grid grid-cols-2 gap-3">
|
<div class="grid grid-cols-3 gap-3">
|
||||||
<FormItem label="启用体积重">
|
<FormItem label="启用体积重">
|
||||||
<Switch v-model:checked="form.useVolumetric" />
|
<Switch v-model:checked="form.useVolumetric" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="体积重除数">
|
<FormItem label="体积重除数">
|
||||||
<InputNumber v-model:value="form.volumeDivisor" :min="1" class="w-full" />
|
<InputNumber v-model:value="form.volumeDivisor" :min="1" class="w-full" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
<FormItem label="计费重取整">
|
||||||
|
<Select
|
||||||
|
v-model:value="form.weightRound"
|
||||||
|
:options="[
|
||||||
|
{ value: 'NONE', label: '不取整' },
|
||||||
|
{ value: 'CEIL_KG', label: '向上整千克' },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
</div>
|
</div>
|
||||||
<FormItem label="备注">
|
<FormItem label="备注">
|
||||||
<Input.TextArea v-model:value="form.remark" :rows="2" />
|
<Input.TextArea v-model:value="form.remark" :rows="2" />
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ async function handleDelete(row: ExpressQuoteVO.Info) {
|
|||||||
<Page title="快递报价" auto-content-height>
|
<Page title="快递报价" auto-content-height>
|
||||||
<template #description>
|
<template #description>
|
||||||
<div class="text-foreground/80 mt-2">
|
<div class="text-foreground/80 mt-2">
|
||||||
公司级报价单(可多仓共用);支持一口价 / 按 kg / 分区首重续重;版本按生效日 as-of
|
公司级报价单(可多仓共用);支持一口价 / 按 kg / 分区×重量带;版本按生效日 as-of
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<Grid :loading="loading">
|
<Grid :loading="loading">
|
||||||
|
|||||||
Reference in New Issue
Block a user