提交设置套餐
This commit is contained in:
@@ -25,6 +25,8 @@ public class PrcPriceSetDetail implements Serializable
|
||||
private Long zdId;
|
||||
private Long wsdId;
|
||||
private String weightLabel;
|
||||
/** 关联 bms_product_country.detail_id */
|
||||
private Long productCountryId;
|
||||
private BigDecimal fvValue;
|
||||
private BigDecimal fvRegistrationFee;
|
||||
private BigDecimal discountValue;
|
||||
@@ -52,6 +54,8 @@ public class PrcPriceSetDetail implements Serializable
|
||||
public void setWsdId(Long wsdId) { this.wsdId = wsdId; }
|
||||
public String getWeightLabel() { return weightLabel; }
|
||||
public void setWeightLabel(String weightLabel) { this.weightLabel = weightLabel; }
|
||||
public Long getProductCountryId() { return productCountryId; }
|
||||
public void setProductCountryId(Long productCountryId) { this.productCountryId = productCountryId; }
|
||||
public BigDecimal getFvValue() { return fvValue; }
|
||||
public void setFvValue(BigDecimal fvValue) { this.fvValue = fvValue; }
|
||||
public BigDecimal getFvRegistrationFee() { return fvRegistrationFee; }
|
||||
@@ -74,6 +78,7 @@ public class PrcPriceSetDetail implements Serializable
|
||||
.append("productCode", getProductCode())
|
||||
.append("countryCode", getCountryCode())
|
||||
.append("wsdId", getWsdId())
|
||||
.append("productCountryId", getProductCountryId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+69
@@ -12,10 +12,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.price.domain.BmsProductCountry;
|
||||
import com.ruoyi.price.domain.PrcCustomerPriceSet;
|
||||
import com.ruoyi.price.domain.PrcPriceSet;
|
||||
import com.ruoyi.price.domain.PrcPriceSetCheckItem;
|
||||
import com.ruoyi.price.domain.PrcPriceSetDetail;
|
||||
import com.ruoyi.price.mapper.BmsProductCountryMapper;
|
||||
import com.ruoyi.price.mapper.PrcCustomerPriceSetMapper;
|
||||
import com.ruoyi.price.mapper.PrcPriceSetDetailMapper;
|
||||
import com.ruoyi.price.mapper.PrcPriceSetMapper;
|
||||
@@ -46,6 +48,9 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
@Autowired
|
||||
private PrcCustomerPriceSetMapper customerMapper;
|
||||
|
||||
@Autowired
|
||||
private BmsProductCountryMapper productCountryMapper;
|
||||
|
||||
@Override
|
||||
public PrcPriceSet selectPrcPriceSetById(Long priceSetId)
|
||||
{
|
||||
@@ -621,6 +626,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
throw new ServiceException("固定价明细必须填写挂号费");
|
||||
}
|
||||
fillProductCountryId(detail);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(detail.getCountryCode()))
|
||||
{
|
||||
@@ -628,6 +634,69 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve / verify product_country_id from bms_product_country when missing.
|
||||
*/
|
||||
private void fillProductCountryId(PrcPriceSetDetail detail)
|
||||
{
|
||||
if (detail.getProductCountryId() != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isEmpty(detail.getProductCode()) || StringUtils.isEmpty(detail.getWeightLabel()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
BmsProductCountry query = new BmsProductCountry();
|
||||
query.setProductCode(detail.getProductCode());
|
||||
List<BmsProductCountry> rows = productCountryMapper.selectBmsProductCountryList(query);
|
||||
if (rows == null || rows.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (BmsProductCountry row : rows)
|
||||
{
|
||||
if (!matchDetailCountry(detail, row))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String label = formatWeightLabel(row.getWeightMin(), row.getWeightMax());
|
||||
if (detail.getWeightLabel().equals(label)
|
||||
|| (StringUtils.isNotEmpty(detail.getWeightLabel())
|
||||
&& row.getWeightMin() != null && row.getWeightMax() != null
|
||||
&& detail.getWeightLabel().contains(stripTrailingZeros(row.getWeightMin()))
|
||||
&& detail.getWeightLabel().contains(stripTrailingZeros(row.getWeightMax()))))
|
||||
{
|
||||
detail.setProductCountryId(row.getDetailId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean matchDetailCountry(PrcPriceSetDetail detail, BmsProductCountry row)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(detail.getCountryCode()) && StringUtils.isNotEmpty(row.getCountryCode()))
|
||||
{
|
||||
return detail.getCountryCode().equalsIgnoreCase(row.getCountryCode());
|
||||
}
|
||||
return StringUtils.isNotEmpty(detail.getCountryName())
|
||||
&& detail.getCountryName().equals(row.getCountryName());
|
||||
}
|
||||
|
||||
private static String formatWeightLabel(BigDecimal min, BigDecimal max)
|
||||
{
|
||||
return stripTrailingZeros(min) + "\u2264W\u2264" + stripTrailingZeros(max);
|
||||
}
|
||||
|
||||
private static String stripTrailingZeros(BigDecimal v)
|
||||
{
|
||||
if (v == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return v.stripTrailingZeros().toPlainString();
|
||||
}
|
||||
|
||||
private void validateCustomer(PrcCustomerPriceSet customer, PrcPriceSet set)
|
||||
{
|
||||
if (customer.getCustomerId() == null || customer.getCustomerId().longValue() <= 0)
|
||||
|
||||
@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="zdId" column="zd_id" />
|
||||
<result property="wsdId" column="wsd_id" />
|
||||
<result property="weightLabel" column="weight_label" />
|
||||
<result property="productCountryId" column="product_country_id" />
|
||||
<result property="fvValue" column="fv_value" />
|
||||
<result property="fvRegistrationFee" column="fv_registration_fee" />
|
||||
<result property="discountValue" column="discount_value" />
|
||||
@@ -24,8 +25,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<sql id="selectPrcPriceSetDetailVo">
|
||||
select psd_id, price_set_id, product_code, product_name, country_code, country_name,
|
||||
zd_id, wsd_id, weight_label, fv_value, fv_registration_fee, discount_value,
|
||||
pr_id, created_at, updated_at
|
||||
zd_id, wsd_id, weight_label, product_country_id, fv_value, fv_registration_fee,
|
||||
discount_value, pr_id, created_at, updated_at
|
||||
from prc_price_set_detail
|
||||
</sql>
|
||||
|
||||
@@ -68,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="zdId != null">zd_id,</if>
|
||||
<if test="wsdId != null">wsd_id,</if>
|
||||
<if test="weightLabel != null">weight_label,</if>
|
||||
<if test="productCountryId != null">product_country_id,</if>
|
||||
<if test="fvValue != null">fv_value,</if>
|
||||
<if test="fvRegistrationFee != null">fv_registration_fee,</if>
|
||||
<if test="discountValue != null">discount_value,</if>
|
||||
@@ -82,6 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="zdId != null">#{zdId},</if>
|
||||
<if test="wsdId != null">#{wsdId},</if>
|
||||
<if test="weightLabel != null">#{weightLabel},</if>
|
||||
<if test="productCountryId != null">#{productCountryId},</if>
|
||||
<if test="fvValue != null">#{fvValue},</if>
|
||||
<if test="fvRegistrationFee != null">#{fvRegistrationFee},</if>
|
||||
<if test="discountValue != null">#{discountValue},</if>
|
||||
@@ -100,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
zd_id = #{zdId},
|
||||
wsd_id = #{wsdId},
|
||||
weight_label = #{weightLabel},
|
||||
product_country_id = #{productCountryId},
|
||||
fv_value = #{fvValue},
|
||||
fv_registration_fee = #{fvRegistrationFee},
|
||||
discount_value = #{discountValue},
|
||||
|
||||
@@ -43,6 +43,7 @@ CREATE TABLE IF NOT EXISTS prc_price_set_detail (
|
||||
zd_id BIGINT(20) DEFAULT NULL COMMENT '收费区划id',
|
||||
wsd_id BIGINT(20) DEFAULT NULL COMMENT '重量段明细id',
|
||||
weight_label VARCHAR(50) DEFAULT NULL COMMENT '重量段展示',
|
||||
product_country_id BIGINT(20) DEFAULT NULL COMMENT '关联 bms_product_country.detail_id',
|
||||
fv_value DECIMAL(10,4) DEFAULT NULL COMMENT '运费单价 RMB/KG',
|
||||
fv_registration_fee DECIMAL(10,2) DEFAULT NULL COMMENT '挂号费 RMB/票',
|
||||
discount_value DECIMAL(5,2) DEFAULT NULL COMMENT '明细折扣百分数,DISCOUNT 可覆盖默认',
|
||||
@@ -52,6 +53,7 @@ CREATE TABLE IF NOT EXISTS prc_price_set_detail (
|
||||
PRIMARY KEY (psd_id),
|
||||
INDEX idx_psd_set (price_set_id),
|
||||
INDEX idx_psd_product (price_set_id, product_code, country_code),
|
||||
INDEX idx_psd_product_country (product_country_id),
|
||||
CONSTRAINT fk_psd_set FOREIGN KEY (price_set_id) REFERENCES prc_price_set (price_set_id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='价格套餐明细-固定价/折扣范围';
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
-- 价格套餐明细关联 bms_product_country.detail_id
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
ALTER TABLE prc_price_set_detail
|
||||
ADD COLUMN product_country_id bigint DEFAULT NULL COMMENT 'bms_product_country.detail_id' AFTER weight_label,
|
||||
ADD KEY idx_psd_product_country (product_country_id);
|
||||
@@ -347,6 +347,7 @@ function weightOptionsOf(row) {
|
||||
map.set(value, {
|
||||
value,
|
||||
label: value,
|
||||
detailId: item.detailId,
|
||||
freightPrice: item.freightPrice,
|
||||
registrationFee: item.registrationFee
|
||||
})
|
||||
@@ -362,6 +363,7 @@ function emptyDetail() {
|
||||
countryName: undefined,
|
||||
_countryKey: undefined,
|
||||
weightLabel: undefined,
|
||||
productCountryId: undefined,
|
||||
fvValue: undefined,
|
||||
fvRegistrationFee: undefined,
|
||||
discountValue: undefined
|
||||
@@ -391,6 +393,7 @@ function clearCascadeAfterProduct(row) {
|
||||
row.countryName = undefined
|
||||
row._countryKey = undefined
|
||||
row.weightLabel = undefined
|
||||
row.productCountryId = undefined
|
||||
row.fvValue = undefined
|
||||
row.fvRegistrationFee = undefined
|
||||
}
|
||||
@@ -408,13 +411,18 @@ function onCountryChange(row) {
|
||||
row.countryCode = opt ? opt.code : undefined
|
||||
row.countryName = opt ? opt.name : undefined
|
||||
row.weightLabel = undefined
|
||||
row.productCountryId = undefined
|
||||
row.fvValue = undefined
|
||||
row.fvRegistrationFee = undefined
|
||||
}
|
||||
|
||||
function onWeightChange(row) {
|
||||
const opt = weightOptionsOf(row).find(w => w.value === row.weightLabel)
|
||||
if (!opt) return
|
||||
if (!opt) {
|
||||
row.productCountryId = undefined
|
||||
return
|
||||
}
|
||||
row.productCountryId = opt.detailId
|
||||
if (opt.freightPrice != null) row.fvValue = Number(opt.freightPrice)
|
||||
if (opt.registrationFee != null) row.fvRegistrationFee = Number(opt.registrationFee)
|
||||
}
|
||||
@@ -436,6 +444,7 @@ function hydrateDetailRow(d) {
|
||||
if (hit) {
|
||||
row.weightLabel = formatWeightLabel(hit.weightMin, hit.weightMax)
|
||||
row._countryKey = countryKeyOf(hit)
|
||||
row.productCountryId = hit.detailId
|
||||
if (!row.countryCode) row.countryCode = hit.countryCode
|
||||
if (!row.countryName) row.countryName = hit.countryName
|
||||
}
|
||||
@@ -451,6 +460,7 @@ function buildPayload(submitFlag) {
|
||||
countryCode: d.countryCode || undefined,
|
||||
countryName: d.countryName || undefined,
|
||||
weightLabel: d.weightLabel || undefined,
|
||||
productCountryId: d.productCountryId || undefined,
|
||||
fvValue: d.fvValue,
|
||||
fvRegistrationFee: d.fvRegistrationFee,
|
||||
discountValue: d.discountValue
|
||||
|
||||
@@ -76,9 +76,9 @@
|
||||
<el-table-column v-if="set.setType === 'DISCOUNT'" label="产品折扣" min-width="110">
|
||||
<template #default="{ row }">{{ row.discountValue != null ? row.discountValue + '%' : '默认折扣' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="关联 pr_id" prop="prId" width="110">
|
||||
<!-- <el-table-column label="关联 pr_id" prop="prId" width="110">
|
||||
<template #default="{ row }">{{ row.prId || '-' }}</template>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
<el-table-column v-if="childEditable" label="操作" width="140" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openDetailDialog(row)" v-hasPermi="['price:set:edit']">编辑</el-button>
|
||||
@@ -175,9 +175,9 @@
|
||||
<el-form-item v-else label="产品折扣%" prop="discountValue">
|
||||
<el-input-number v-model="detailForm.discountValue" :min="1" :max="99" controls-position="right" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="关联 pr_id" prop="prId">
|
||||
<!-- <el-form-item label="关联 pr_id" prop="prId">
|
||||
<el-input v-model="detailForm.prId" placeholder="可选" />
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="submitDetail">确 定</el-button>
|
||||
@@ -304,6 +304,7 @@ const detailWeightOptions = computed(() => {
|
||||
map.set(value, {
|
||||
value,
|
||||
label: value,
|
||||
detailId: item.detailId,
|
||||
freightPrice: item.freightPrice,
|
||||
registrationFee: item.registrationFee
|
||||
})
|
||||
@@ -328,6 +329,7 @@ function onDetailProductChange() {
|
||||
detailForm.value.countryName = undefined
|
||||
detailForm.value._countryKey = undefined
|
||||
detailForm.value.weightLabel = undefined
|
||||
detailForm.value.productCountryId = undefined
|
||||
detailForm.value.fvValue = undefined
|
||||
detailForm.value.fvRegistrationFee = undefined
|
||||
if (detailForm.value.productCode && set.value.setType === 'FIXED') {
|
||||
@@ -340,13 +342,18 @@ function onDetailCountryChange() {
|
||||
detailForm.value.countryCode = opt ? opt.code : undefined
|
||||
detailForm.value.countryName = opt ? opt.name : undefined
|
||||
detailForm.value.weightLabel = undefined
|
||||
detailForm.value.productCountryId = undefined
|
||||
detailForm.value.fvValue = undefined
|
||||
detailForm.value.fvRegistrationFee = undefined
|
||||
}
|
||||
|
||||
function onDetailWeightChange() {
|
||||
const opt = detailWeightOptions.value.find(w => w.value === detailForm.value.weightLabel)
|
||||
if (!opt) return
|
||||
if (!opt) {
|
||||
detailForm.value.productCountryId = undefined
|
||||
return
|
||||
}
|
||||
detailForm.value.productCountryId = opt.detailId
|
||||
if (opt.freightPrice != null) detailForm.value.fvValue = Number(opt.freightPrice)
|
||||
if (opt.registrationFee != null) detailForm.value.fvRegistrationFee = Number(opt.registrationFee)
|
||||
}
|
||||
@@ -440,6 +447,7 @@ function openDetailDialog(row) {
|
||||
countryName: undefined,
|
||||
_countryKey: undefined,
|
||||
weightLabel: undefined,
|
||||
productCountryId: undefined,
|
||||
fvValue: undefined,
|
||||
fvRegistrationFee: undefined,
|
||||
discountValue: undefined
|
||||
|
||||
Reference in New Issue
Block a user