增加软删除
This commit is contained in:
@@ -112,6 +112,7 @@ price.zone.countryCode.empty=国家编码不能为空,请检查 region.country
|
||||
# 产品导入 BmsProduct
|
||||
price.product.codeDate.exists=同一产品代码与生效日期已存在,不能覆盖历史数据
|
||||
price.product.effectiveDate.empty=生效日期不能为空
|
||||
price.redline.delete.pendingOnly=仅待生效红线价可删除,以下不符合:{0}
|
||||
price.product.delete.pendingOnly=仅待生效产品可删除,以下不符合:{0}
|
||||
price.product.import.effEmpty=缺少生效日期,已跳过
|
||||
price.product.import.effRequired=请选择生效时间
|
||||
|
||||
@@ -31,7 +31,12 @@ public class BmsProduct extends BaseEntity
|
||||
public static final String STATUS_PENDING = "0";
|
||||
public static final String STATUS_ACTIVE = "1";
|
||||
public static final String STATUS_EXPIRED = "2";
|
||||
/** 0未删除 1已删除 */
|
||||
public static final String IS_DEL_NO = "0";
|
||||
public static final String IS_DEL_YES = "1";
|
||||
private String status;
|
||||
/** 0未删除 1已删除 */
|
||||
private String isDel;
|
||||
private String sourceSheet;
|
||||
/** FK prc_price_excel_file.pef_id */
|
||||
private Long pefId;
|
||||
|
||||
@@ -40,6 +40,10 @@ public class BmsProductCountry implements Serializable
|
||||
private Date expireDate;
|
||||
/** 0 pending, 1 active, 2 expired */
|
||||
private String status;
|
||||
/** 0未删除 1已删除 */
|
||||
public static final String IS_DEL_NO = "0";
|
||||
public static final String IS_DEL_YES = "1";
|
||||
private String isDel;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
||||
@@ -31,7 +31,12 @@ public class BmsRedlineProduct extends BaseEntity
|
||||
public static final String STATUS_PENDING = "0";
|
||||
public static final String STATUS_ACTIVE = "1";
|
||||
public static final String STATUS_EXPIRED = "2";
|
||||
/** 0未删除 1已删除 */
|
||||
public static final String IS_DEL_NO = "0";
|
||||
public static final String IS_DEL_YES = "1";
|
||||
private String status;
|
||||
/** 0未删除 1已删除 */
|
||||
private String isDel;
|
||||
private String sourceSheet;
|
||||
/** FK prc_price_excel_file.pef_id */
|
||||
private Long pefId;
|
||||
|
||||
@@ -38,6 +38,10 @@ public class BmsRedlineProductCountry implements Serializable
|
||||
private Date expireDate;
|
||||
/** 0 pending, 1 active, 2 expired */
|
||||
private String status;
|
||||
/** 0未删除 1已删除 */
|
||||
public static final String IS_DEL_NO = "0";
|
||||
public static final String IS_DEL_YES = "1";
|
||||
private String isDel;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
||||
@@ -24,6 +24,10 @@ public class PrcSurcharge extends BaseEntity
|
||||
private String roundMode;
|
||||
/** on / of */
|
||||
private String ssCode;
|
||||
/** 0未删除 1已删除 */
|
||||
public static final String IS_DEL_NO = "0";
|
||||
public static final String IS_DEL_YES = "1";
|
||||
private String isDel;
|
||||
private String countryCode;
|
||||
private String scNote;
|
||||
private Long tmsId;
|
||||
|
||||
@@ -37,6 +37,10 @@ public class PrcSurchargeRel extends BaseEntity
|
||||
private String priceType;
|
||||
/** 适用国家ISO2(空=全部),rel 表字段 */
|
||||
private String countryCode;
|
||||
/** 0未删除 1已删除 */
|
||||
public static final String IS_DEL_NO = "0";
|
||||
public static final String IS_DEL_YES = "1";
|
||||
private String isDel;
|
||||
|
||||
/** 附加费冗余展示字段 */
|
||||
private String scName;
|
||||
|
||||
@@ -23,10 +23,13 @@ public interface BmsProductCountryMapper
|
||||
/** Import overlay: update price/zone/attrs on matched country row */
|
||||
public int updateBmsProductCountryImport(BmsProductCountry country);
|
||||
|
||||
/** Soft delete by product_id */
|
||||
public int deleteByProductId(Long productId);
|
||||
|
||||
/** Soft delete by product_code */
|
||||
public int deleteByProductCode(String productCode);
|
||||
|
||||
/** Soft delete by product_code + effective_date */
|
||||
public int deleteByProductCodeAndEffectiveDate(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("effectiveDate") Date effectiveDate);
|
||||
|
||||
@@ -31,6 +31,7 @@ public interface BmsProductMapper
|
||||
|
||||
public int updateBmsProduct(BmsProduct product);
|
||||
|
||||
/** Soft delete: set del_flag = 2 */
|
||||
public int deleteBmsProductByIds(Long[] productIds);
|
||||
|
||||
/** Close previous open versions: expire_date = newEffectiveDate */
|
||||
|
||||
+5
@@ -39,6 +39,11 @@ public interface BmsRedlineProductCountryMapper
|
||||
@Param("productCode") String productCode,
|
||||
@Param("newEffectiveDate") Date newEffectiveDate);
|
||||
|
||||
/** After deleting a pending version: reopen rows closed at that effective date */
|
||||
public int reopenExpiredByProductCodeAndExpireDate(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("expireDate") Date expireDate);
|
||||
|
||||
/**
|
||||
* Close open rows for one product + country where effective_date < newEffectiveDate.
|
||||
* Match by country_code when present, otherwise country_name.
|
||||
|
||||
@@ -39,6 +39,11 @@ public interface BmsRedlineProductMapper
|
||||
@Param("newEffectiveDate") Date newEffectiveDate,
|
||||
@Param("excludeId") Long excludeId);
|
||||
|
||||
/** After deleting a pending version: reopen rows closed at that effective date */
|
||||
public int reopenExpiredByProductCodeAndExpireDate(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("expireDate") Date expireDate);
|
||||
|
||||
/** Recompute status from effective_date / expire_date vs today */
|
||||
public int refreshStatusByDates();
|
||||
}
|
||||
|
||||
+37
-2
@@ -174,6 +174,9 @@ public class BmsRedlineProductServiceImpl implements IBmsRedlineProductService
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
List<Long> deletableIds = new ArrayList<Long>();
|
||||
List<String> notPendingTips = new ArrayList<String>();
|
||||
List<BmsRedlineProduct> toReopen = new ArrayList<BmsRedlineProduct>();
|
||||
List<Long> relProductIds = new ArrayList<Long>();
|
||||
for (Long id : productIds)
|
||||
{
|
||||
@@ -182,19 +185,51 @@ public class BmsRedlineProductServiceImpl implements IBmsRedlineProductService
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String liveStatus = resolveStoredStatus(p.getEffectiveDate(), p.getExpireDate());
|
||||
if (!BmsRedlineProduct.STATUS_PENDING.equals(liveStatus))
|
||||
{
|
||||
String tip = p.getProductCode();
|
||||
if (p.getEffectiveDate() != null)
|
||||
{
|
||||
tip = tip + "(" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(p.getEffectiveDate()) + ")";
|
||||
}
|
||||
notPendingTips.add(tip);
|
||||
continue;
|
||||
}
|
||||
if (p.getProductId() != null)
|
||||
{
|
||||
countryMapper.deleteByProductId(p.getProductId());
|
||||
relProductIds.add(p.getProductId());
|
||||
}
|
||||
countryMapper.deleteByProductCodeAndEffectiveDate(p.getProductCode(), p.getEffectiveDate());
|
||||
deletableIds.add(p.getProductId());
|
||||
if (p.getEffectiveDate() != null)
|
||||
{
|
||||
toReopen.add(p);
|
||||
}
|
||||
}
|
||||
if (!notPendingTips.isEmpty())
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.redline.delete.pendingOnly",
|
||||
String.join("\u3001", notPendingTips)));
|
||||
}
|
||||
if (deletableIds.isEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!relProductIds.isEmpty())
|
||||
{
|
||||
// REDLINE rels bind redline_product.product_id (not shared with product catalog)
|
||||
surchargeRelMapper.deleteByProductIdsAndPriceType(relProductIds, PrcSurchargeRel.PRICE_TYPE_REDLINE);
|
||||
}
|
||||
return productMapper.deleteBmsRedlineProductByIds(productIds);
|
||||
int rows = productMapper.deleteBmsRedlineProductByIds(deletableIds.toArray(new Long[0]));
|
||||
for (BmsRedlineProduct p : toReopen)
|
||||
{
|
||||
productMapper.reopenExpiredByProductCodeAndExpireDate(p.getProductCode(), p.getEffectiveDate());
|
||||
countryMapper.reopenExpiredByProductCodeAndExpireDate(p.getProductCode(), p.getEffectiveDate());
|
||||
}
|
||||
productMapper.refreshStatusByDates();
|
||||
countryMapper.refreshStatusByDates();
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="effectiveDate" column="effective_date" />
|
||||
<result property="expireDate" column="expire_date" />
|
||||
<result property="status" column="status" />
|
||||
<result property="isDel" column="is_del" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="effectStatus" column="status" />
|
||||
@@ -33,13 +34,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
c.zone_id, c.zone_code, c.zone_name,
|
||||
c.weight_min, c.weight_max,
|
||||
c.freight_price, c.registration_fee, c.size_limit, c.last_mile, c.lead_time,
|
||||
c.effective_date, c.expire_date, c.status, c.create_time, c.update_time
|
||||
c.effective_date, c.expire_date, c.status, c.is_del, c.create_time, c.update_time
|
||||
from product_country c
|
||||
</sql>
|
||||
|
||||
<select id="selectBmsProductCountryList" parameterType="BmsProductCountry" resultMap="BmsProductCountryResult">
|
||||
<include refid="selectVo"/>
|
||||
<where>
|
||||
and ifnull(c.is_del, '0') = '0'
|
||||
<if test="productId != null">
|
||||
AND c.product_id = #{productId}
|
||||
</if>
|
||||
@@ -85,12 +87,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
product_id, product_code, country_name, country_code, zone_id, zone_code, zone_name,
|
||||
weight_min, weight_max,
|
||||
freight_price, registration_fee, size_limit, last_mile, lead_time,
|
||||
effective_date, expire_date, status, create_time
|
||||
effective_date, expire_date, status, is_del, create_time
|
||||
) values (
|
||||
#{productId}, #{productCode}, #{countryName}, #{countryCode}, #{zoneId}, #{zoneCode}, #{zoneName},
|
||||
#{weightMin}, #{weightMax},
|
||||
#{freightPrice}, #{registrationFee}, #{sizeLimit}, #{lastMile}, #{leadTime},
|
||||
#{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), sysdate()
|
||||
#{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), IFNULL(#{isDel}, '0'), sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -132,33 +134,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where detail_id = #{detailId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductId" parameterType="Long">
|
||||
delete from product_country where product_id = #{productId}
|
||||
</delete>
|
||||
<update id="deleteByProductId" parameterType="Long">
|
||||
update product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where product_id = #{productId}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductCode" parameterType="String">
|
||||
delete from product_country where product_code = #{productCode}
|
||||
</delete>
|
||||
<update id="deleteByProductCode" parameterType="String">
|
||||
update product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductCodes">
|
||||
delete from product_country where product_code in
|
||||
<update id="deleteByProductCodes">
|
||||
update product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where ifnull(is_del, '0') = '0'
|
||||
and product_code in
|
||||
<foreach item="code" collection="array" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductCodeAndEffectiveDate">
|
||||
delete from product_country
|
||||
<update id="deleteByProductCodeAndEffectiveDate">
|
||||
update product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and (
|
||||
(#{effectiveDate} is null and effective_date is null)
|
||||
or effective_date = #{effectiveDate}
|
||||
)
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<select id="selectMaxOpenEffectiveDate" resultType="java.util.Date">
|
||||
select max(effective_date) from product_country
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
</select>
|
||||
|
||||
@@ -167,6 +181,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
set expire_date = #{newEffectiveDate},
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{newEffectiveDate})
|
||||
</update>
|
||||
@@ -176,6 +191,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
set expire_date = null,
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date = #{expireDate}
|
||||
</update>
|
||||
|
||||
@@ -184,6 +200,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
set expire_date = #{newEffectiveDate},
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{newEffectiveDate})
|
||||
<choose>
|
||||
@@ -203,21 +220,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
when effective_date is null or effective_date > now() then '0'
|
||||
else '1'
|
||||
end
|
||||
where ifnull(is_del, '0') = '0'
|
||||
</update>
|
||||
|
||||
<delete id="deleteOpenByProductCodeAndEffectiveDate">
|
||||
delete from product_country
|
||||
<update id="deleteOpenByProductCodeAndEffectiveDate">
|
||||
update product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (
|
||||
(#{effectiveDate} is null and effective_date is null)
|
||||
or effective_date = #{effectiveDate}
|
||||
)
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<delete id="deleteOpenByProductCodeAndCountryOnDate">
|
||||
delete from product_country
|
||||
<update id="deleteOpenByProductCodeAndCountryOnDate">
|
||||
update product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (
|
||||
(#{effectiveDate} is null and effective_date is null)
|
||||
@@ -231,11 +253,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and country_name = #{countryName}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<select id="selectMatchByProductCountryWeight" resultMap="BmsProductCountryResult">
|
||||
<include refid="selectVo"/>
|
||||
where c.product_code = #{productCode}
|
||||
and ifnull(c.is_del, '0') = '0'
|
||||
and c.weight_min <= #{weight}
|
||||
and c.weight_max >= #{weight}
|
||||
<choose>
|
||||
@@ -272,6 +295,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select count(1)
|
||||
from product_country
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and zone_code is not null and zone_code <> ''
|
||||
<choose>
|
||||
<when test="countryCode != null and countryCode != ''">
|
||||
@@ -296,6 +320,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectOpenByProductCode" resultMap="BmsProductCountryResult">
|
||||
<include refid="selectVo"/>
|
||||
where c.product_code = #{productCode}
|
||||
and ifnull(c.is_del, '0') = '0'
|
||||
and c.expire_date is null
|
||||
order by c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc
|
||||
</select>
|
||||
@@ -304,14 +329,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into product_country (
|
||||
product_id, product_code, country_name, country_code, zone_id, zone_code, zone_name,
|
||||
weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time,
|
||||
effective_date, expire_date, status, create_time
|
||||
effective_date, expire_date, status, is_del, create_time
|
||||
)
|
||||
select
|
||||
#{productId}, product_code, country_name, country_code, zone_id, zone_code, zone_name,
|
||||
weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time,
|
||||
#{effectiveDate}, null, IFNULL(#{status}, '0'), sysdate()
|
||||
#{effectiveDate}, null, IFNULL(#{status}, '0'), '0', sysdate()
|
||||
from product_country
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{effectiveDate})
|
||||
order by detail_id asc
|
||||
|
||||
@@ -16,6 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="effectiveDate" column="effective_date" />
|
||||
<result property="expireDate" column="expire_date" />
|
||||
<result property="status" column="status" />
|
||||
<result property="isDel" column="is_del" />
|
||||
<result property="sourceSheet" column="source_sheet" />
|
||||
<result property="pefId" column="pef_id" />
|
||||
<result property="remark" column="remark" />
|
||||
@@ -30,28 +31,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<sql id="selectBmsProductVo">
|
||||
select p.product_id, p.product_code, p.product_name, p.service_level, p.cargo_attr,
|
||||
p.dest_region, p.update_note, p.tax_mode, p.effective_date, p.expire_date, p.status,
|
||||
p.dest_region, p.update_note, p.tax_mode, p.effective_date, p.expire_date, p.status, p.is_del,
|
||||
p.source_sheet, p.pef_id, p.remark, p.tms_id, p.created_by, p.create_time, p.updated_by, p.update_time,
|
||||
(select count(distinct c.country_name) from product_country c
|
||||
where c.product_id = p.product_id
|
||||
where ifnull(c.is_del, '0') = '0'
|
||||
and (c.product_id = p.product_id
|
||||
or (c.product_id is null and c.product_code = p.product_code
|
||||
and (
|
||||
(p.effective_date is null and c.effective_date is null)
|
||||
or c.effective_date = p.effective_date
|
||||
))
|
||||
)))
|
||||
) as country_count,
|
||||
(select count(*) from prc_surcharge_rel r where r.product_id = p.product_id and r.price_type = 'PRODUCT') as surcharge_count
|
||||
(select count(*) from prc_surcharge_rel r
|
||||
inner join prc_surcharge s on s.sc_id = r.sc_id and ifnull(s.is_del, '0') = '0'
|
||||
where ifnull(r.is_del, '0') = '0'
|
||||
and r.product_id = p.product_id and r.price_type = 'PRODUCT') as surcharge_count
|
||||
from product p
|
||||
</sql>
|
||||
|
||||
<select id="selectBmsProductById" parameterType="Long" resultMap="BmsProductResult">
|
||||
<include refid="selectBmsProductVo"/>
|
||||
where p.product_id = #{productId}
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectBmsProductByCode" parameterType="String" resultMap="BmsProductResult">
|
||||
<include refid="selectBmsProductVo"/>
|
||||
where p.product_code = #{productCode}
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
order by p.effective_date desc, p.product_id desc
|
||||
limit 1
|
||||
</select>
|
||||
@@ -59,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectBmsProductByCodeAndDate" resultMap="BmsProductResult">
|
||||
<include refid="selectBmsProductVo"/>
|
||||
where p.product_code = #{productCode}
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
<choose>
|
||||
<when test="effectiveDate != null">
|
||||
AND p.effective_date = #{effectiveDate}
|
||||
@@ -73,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectEffectiveBmsProductByCode" resultMap="BmsProductResult">
|
||||
<include refid="selectBmsProductVo"/>
|
||||
where p.product_code = #{productCode}
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
and (p.effective_date is null or #{bizDate} is null or p.effective_date <= #{bizDate})
|
||||
and (p.expire_date is null or #{bizDate} is null or p.expire_date > #{bizDate})
|
||||
order by p.effective_date desc, p.product_id desc
|
||||
@@ -82,6 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectBmsProductList" parameterType="BmsProduct" resultMap="BmsProductResult">
|
||||
<include refid="selectBmsProductVo"/>
|
||||
<where>
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
<if test="productCode != null and productCode != ''">
|
||||
AND p.product_code like concat('%', #{productCode}, '%')
|
||||
</if>
|
||||
@@ -139,6 +149,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="effectiveDate != null">effective_date,</if>
|
||||
<if test="expireDate != null">expire_date,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
is_del,
|
||||
<if test="sourceSheet != null">source_sheet,</if>
|
||||
<if test="pefId != null">pef_id,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
@@ -156,6 +167,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="effectiveDate != null">#{effectiveDate},</if>
|
||||
<if test="expireDate != null">#{expireDate},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
ifnull(#{isDel}, '0'),
|
||||
<if test="sourceSheet != null">#{sourceSheet},</if>
|
||||
<if test="pefId != null">#{pefId},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
@@ -188,18 +200,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where product_id = #{productId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteBmsProductByIds" parameterType="Long">
|
||||
delete from product where product_id in
|
||||
<update id="deleteBmsProductByIds" parameterType="Long">
|
||||
update product
|
||||
set is_del = '1',
|
||||
update_time = sysdate()
|
||||
where ifnull(is_del, '0') = '0'
|
||||
and product_id in
|
||||
<foreach item="productId" collection="array" open="(" separator="," close=")">
|
||||
#{productId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<update id="expireOpenByProductCode">
|
||||
update product
|
||||
set expire_date = #{newEffectiveDate},
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{newEffectiveDate})
|
||||
<if test="excludeId != null">
|
||||
@@ -212,6 +229,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
set expire_date = null,
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date = #{expireDate}
|
||||
</update>
|
||||
|
||||
@@ -222,6 +240,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
when effective_date is null or effective_date > now() then '0'
|
||||
else '1'
|
||||
end
|
||||
where ifnull(is_del, '0') = '0'
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
+57
-23
@@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="effectiveDate" column="effective_date" />
|
||||
<result property="expireDate" column="expire_date" />
|
||||
<result property="status" column="status" />
|
||||
<result property="isDel" column="is_del" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="effectStatus" column="status" />
|
||||
@@ -33,13 +34,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
c.zone_id, c.zone_code, c.zone_name,
|
||||
c.weight_min, c.weight_max,
|
||||
c.freight_price, c.registration_fee, c.size_limit, c.last_mile, c.lead_time,
|
||||
c.effective_date, c.expire_date, c.status, c.create_time, c.update_time
|
||||
c.effective_date, c.expire_date, c.status, c.is_del, c.create_time, c.update_time
|
||||
from redline_product_country c
|
||||
</sql>
|
||||
|
||||
<select id="selectBmsRedlineProductCountryList" parameterType="BmsRedlineProductCountry" resultMap="BmsRedlineProductCountryResult">
|
||||
<include refid="selectVo"/>
|
||||
<where>
|
||||
and ifnull(c.is_del, '0') = '0'
|
||||
<if test="productId != null">
|
||||
AND c.product_id = #{productId}
|
||||
</if>
|
||||
@@ -85,12 +87,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
product_id, product_code, country_name, country_code, zone_id, zone_code, zone_name,
|
||||
weight_min, weight_max,
|
||||
freight_price, registration_fee, size_limit, last_mile, lead_time,
|
||||
effective_date, expire_date, status, create_time
|
||||
effective_date, expire_date, status, is_del, create_time
|
||||
) values (
|
||||
#{productId}, #{productCode}, #{countryName}, #{countryCode}, #{zoneId}, #{zoneCode}, #{zoneName},
|
||||
#{weightMin}, #{weightMax},
|
||||
#{freightPrice}, #{registrationFee}, #{sizeLimit}, #{lastMile}, #{leadTime},
|
||||
#{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), sysdate()
|
||||
#{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), IFNULL(#{isDel}, '0'), sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -132,41 +134,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where detail_id = #{detailId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductId" parameterType="Long">
|
||||
delete from redline_product_country where product_id = #{productId}
|
||||
</delete>
|
||||
<update id="deleteByProductId" parameterType="Long">
|
||||
update redline_product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where product_id = #{productId}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductCode" parameterType="String">
|
||||
delete from redline_product_country where product_code = #{productCode}
|
||||
</delete>
|
||||
<update id="deleteByProductCode" parameterType="String">
|
||||
update redline_product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductCodes">
|
||||
delete from redline_product_country where product_code in
|
||||
<update id="deleteByProductCodes">
|
||||
update redline_product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where ifnull(is_del, '0') = '0'
|
||||
and product_code in
|
||||
<foreach item="code" collection="array" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductCodeAndEffectiveDate">
|
||||
delete from redline_product_country
|
||||
<update id="deleteByProductCodeAndEffectiveDate">
|
||||
update redline_product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and (
|
||||
(#{effectiveDate} is null and effective_date is null)
|
||||
or effective_date = #{effectiveDate}
|
||||
)
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<select id="selectMaxOpenEffectiveDate" resultType="java.util.Date">
|
||||
select max(effective_date) from redline_product_country
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
</select>
|
||||
|
||||
<update id="reopenExpiredByProductCodeAndExpireDate">
|
||||
update redline_product_country
|
||||
set expire_date = null,
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date = #{expireDate}
|
||||
</update>
|
||||
|
||||
<update id="expireOpenByProductCode">
|
||||
update redline_product_country
|
||||
set expire_date = #{newEffectiveDate},
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{newEffectiveDate})
|
||||
</update>
|
||||
@@ -176,6 +200,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
set expire_date = #{newEffectiveDate},
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{newEffectiveDate})
|
||||
<choose>
|
||||
@@ -195,21 +220,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
when effective_date is null or effective_date > now() then '0'
|
||||
else '1'
|
||||
end
|
||||
where ifnull(is_del, '0') = '0'
|
||||
</update>
|
||||
|
||||
<delete id="deleteOpenByProductCodeAndEffectiveDate">
|
||||
delete from redline_product_country
|
||||
<update id="deleteOpenByProductCodeAndEffectiveDate">
|
||||
update redline_product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (
|
||||
(#{effectiveDate} is null and effective_date is null)
|
||||
or effective_date = #{effectiveDate}
|
||||
)
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<delete id="deleteOpenByProductCodeAndCountryOnDate">
|
||||
delete from redline_product_country
|
||||
<update id="deleteOpenByProductCodeAndCountryOnDate">
|
||||
update redline_product_country
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (
|
||||
(#{effectiveDate} is null and effective_date is null)
|
||||
@@ -223,11 +253,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and country_name = #{countryName}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<select id="selectMatchByProductCountryWeight" resultMap="BmsRedlineProductCountryResult">
|
||||
<include refid="selectVo"/>
|
||||
where c.product_code = #{productCode}
|
||||
and ifnull(c.is_del, '0') = '0'
|
||||
and c.weight_min <= #{weight}
|
||||
and c.weight_max >= #{weight}
|
||||
<choose>
|
||||
@@ -264,6 +295,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select count(1)
|
||||
from redline_product_country
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and zone_code is not null and zone_code <> ''
|
||||
<choose>
|
||||
<when test="countryCode != null and countryCode != ''">
|
||||
@@ -288,6 +320,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectOpenByProductCode" resultMap="BmsRedlineProductCountryResult">
|
||||
<include refid="selectVo"/>
|
||||
where c.product_code = #{productCode}
|
||||
and ifnull(c.is_del, '0') = '0'
|
||||
and c.expire_date is null
|
||||
order by c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc
|
||||
</select>
|
||||
@@ -296,14 +329,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into redline_product_country (
|
||||
product_id, product_code, country_name, country_code, zone_id, zone_code, zone_name,
|
||||
weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time,
|
||||
effective_date, expire_date, status, create_time
|
||||
effective_date, expire_date, status, is_del, create_time
|
||||
)
|
||||
select
|
||||
#{productId}, product_code, country_name, country_code, zone_id, zone_code, zone_name,
|
||||
weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time,
|
||||
#{effectiveDate}, null, IFNULL(#{status}, '0'), sysdate()
|
||||
#{effectiveDate}, null, IFNULL(#{status}, '0'), '0', sysdate()
|
||||
from redline_product_country
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{effectiveDate})
|
||||
order by detail_id asc
|
||||
|
||||
@@ -16,6 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="effectiveDate" column="effective_date" />
|
||||
<result property="expireDate" column="expire_date" />
|
||||
<result property="status" column="status" />
|
||||
<result property="isDel" column="is_del" />
|
||||
<result property="sourceSheet" column="source_sheet" />
|
||||
<result property="pefId" column="pef_id" />
|
||||
<result property="remark" column="remark" />
|
||||
@@ -30,28 +31,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<sql id="selectBmsRedlineProductVo">
|
||||
select p.product_id, p.product_code, p.product_name, p.service_level, p.cargo_attr,
|
||||
p.dest_region, p.update_note, p.tax_mode, p.effective_date, p.expire_date, p.status,
|
||||
p.dest_region, p.update_note, p.tax_mode, p.effective_date, p.expire_date, p.status, p.is_del,
|
||||
p.source_sheet, p.pef_id, p.remark, p.tms_id, p.created_by, p.create_time, p.updated_by, p.update_time,
|
||||
(select count(distinct c.country_name) from redline_product_country c
|
||||
where c.product_id = p.product_id
|
||||
where ifnull(c.is_del, '0') = '0'
|
||||
and (c.product_id = p.product_id
|
||||
or (c.product_id is null and c.product_code = p.product_code
|
||||
and (
|
||||
(p.effective_date is null and c.effective_date is null)
|
||||
or c.effective_date = p.effective_date
|
||||
))
|
||||
)))
|
||||
) as country_count,
|
||||
(select count(*) from prc_surcharge_rel r where r.product_id = p.product_id and r.price_type = 'REDLINE') as surcharge_count
|
||||
(select count(*) from prc_surcharge_rel r
|
||||
inner join prc_surcharge s on s.sc_id = r.sc_id and ifnull(s.is_del, '0') = '0'
|
||||
where ifnull(r.is_del, '0') = '0'
|
||||
and r.product_id = p.product_id and r.price_type = 'REDLINE') as surcharge_count
|
||||
from redline_product p
|
||||
</sql>
|
||||
|
||||
<select id="selectBmsRedlineProductById" parameterType="Long" resultMap="BmsRedlineProductResult">
|
||||
<include refid="selectBmsRedlineProductVo"/>
|
||||
where p.product_id = #{productId}
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectBmsRedlineProductByCode" parameterType="String" resultMap="BmsRedlineProductResult">
|
||||
<include refid="selectBmsRedlineProductVo"/>
|
||||
where p.product_code = #{productCode}
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
order by p.effective_date desc, p.product_id desc
|
||||
limit 1
|
||||
</select>
|
||||
@@ -59,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectBmsRedlineProductByCodeAndDate" resultMap="BmsRedlineProductResult">
|
||||
<include refid="selectBmsRedlineProductVo"/>
|
||||
where p.product_code = #{productCode}
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
<choose>
|
||||
<when test="effectiveDate != null">
|
||||
AND p.effective_date = #{effectiveDate}
|
||||
@@ -73,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectEffectiveBmsRedlineProductByCode" resultMap="BmsRedlineProductResult">
|
||||
<include refid="selectBmsRedlineProductVo"/>
|
||||
where p.product_code = #{productCode}
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
and (p.effective_date is null or #{bizDate} is null or p.effective_date <= #{bizDate})
|
||||
and (p.expire_date is null or #{bizDate} is null or p.expire_date > #{bizDate})
|
||||
order by p.effective_date desc, p.product_id desc
|
||||
@@ -82,6 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectBmsRedlineProductList" parameterType="BmsRedlineProduct" resultMap="BmsRedlineProductResult">
|
||||
<include refid="selectBmsRedlineProductVo"/>
|
||||
<where>
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
<if test="productCode != null and productCode != ''">
|
||||
AND p.product_code like concat('%', #{productCode}, '%')
|
||||
</if>
|
||||
@@ -139,6 +149,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="effectiveDate != null">effective_date,</if>
|
||||
<if test="expireDate != null">expire_date,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
is_del,
|
||||
<if test="sourceSheet != null">source_sheet,</if>
|
||||
<if test="pefId != null">pef_id,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
@@ -156,6 +167,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="effectiveDate != null">#{effectiveDate},</if>
|
||||
<if test="expireDate != null">#{expireDate},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
ifnull(#{isDel}, '0'),
|
||||
<if test="sourceSheet != null">#{sourceSheet},</if>
|
||||
<if test="pefId != null">#{pefId},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
@@ -166,7 +178,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</insert>
|
||||
|
||||
<update id="updateBmsRedlineProduct" parameterType="BmsRedlineProduct">
|
||||
update product
|
||||
update redline_product
|
||||
<set>
|
||||
<if test="productCode != null and productCode != ''">product_code = #{productCode},</if>
|
||||
<if test="productName != null and productName != ''">product_name = #{productName},</if>
|
||||
@@ -188,18 +200,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where product_id = #{productId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteBmsRedlineProductByIds" parameterType="Long">
|
||||
delete from redline_product where product_id in
|
||||
<update id="deleteBmsRedlineProductByIds" parameterType="Long">
|
||||
update redline_product
|
||||
set is_del = '1',
|
||||
update_time = sysdate()
|
||||
where ifnull(is_del, '0') = '0'
|
||||
and product_id in
|
||||
<foreach item="productId" collection="array" open="(" separator="," close=")">
|
||||
#{productId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<update id="reopenExpiredByProductCodeAndExpireDate">
|
||||
update redline_product
|
||||
set expire_date = null,
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date = #{expireDate}
|
||||
</update>
|
||||
|
||||
<update id="expireOpenByProductCode">
|
||||
update product
|
||||
update redline_product
|
||||
set expire_date = #{newEffectiveDate},
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{newEffectiveDate})
|
||||
<if test="excludeId != null">
|
||||
@@ -208,12 +234,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</update>
|
||||
|
||||
<update id="refreshStatusByDates">
|
||||
update product
|
||||
update redline_product
|
||||
set status = case
|
||||
when expire_date is not null and expire_date <= now() then '2'
|
||||
when effective_date is null or effective_date > now() then '0'
|
||||
else '1'
|
||||
end
|
||||
where ifnull(is_del, '0') = '0'
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
f.content_type, f.file_extension, f.oss_id, f.sheet_names, f.remark,
|
||||
f.created_by, f.create_time, f.updated_by, f.update_time
|
||||
from prc_price_excel_file f
|
||||
inner join product p on p.pef_id = f.pef_id
|
||||
inner join product p on p.pef_id = f.pef_id and ifnull(p.is_del, '0') = '0'
|
||||
where p.product_code = #{productCode}
|
||||
and p.pef_id is not null
|
||||
order by f.effective_time desc, f.pef_id desc
|
||||
@@ -119,7 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
f.content_type, f.file_extension, f.oss_id, f.sheet_names, f.remark,
|
||||
f.created_by, f.create_time, f.updated_by, f.update_time
|
||||
from prc_price_excel_file f
|
||||
inner join redline_product p on p.pef_id = f.pef_id
|
||||
inner join redline_product p on p.pef_id = f.pef_id and ifnull(p.is_del, '0') = '0'
|
||||
where p.product_code = #{productCode}
|
||||
and p.pef_id is not null
|
||||
order by f.effective_time desc, f.pef_id desc
|
||||
|
||||
@@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
c.registration_fee as base_registration_fee,
|
||||
d.discount_value, d.round_mode, d.pr_id, d.effective_date, d.expire_date, d.create_time, d.update_time
|
||||
from prc_price_set_detail d
|
||||
left join product_country c on c.detail_id = d.product_country_id
|
||||
left join product_country c on c.detail_id = d.product_country_id and ifnull(c.is_del, '0') = '0'
|
||||
<where>
|
||||
<if test="priceSetId != null">
|
||||
AND d.price_set_id = #{priceSetId}
|
||||
@@ -166,9 +166,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
inner join product p on p.product_id = c.product_id
|
||||
<where>
|
||||
and p.status = '1'
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
and ifnull(c.is_del, '0') = '0'
|
||||
and p.product_id = (
|
||||
select max(p2.product_id) from product p2
|
||||
where p2.product_code = p.product_code and p2.status = '1'
|
||||
and ifnull(p2.is_del, '0') = '0'
|
||||
)
|
||||
and ifnull(c.status, '1') <> '2'
|
||||
<choose>
|
||||
@@ -226,9 +229,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
inner join product p on p.product_id = c.product_id
|
||||
<where>
|
||||
and p.status = '1'
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
and ifnull(c.is_del, '0') = '0'
|
||||
and p.product_id = (
|
||||
select max(p2.product_id) from product p2
|
||||
where p2.product_code = p.product_code and p2.status = '1'
|
||||
and ifnull(p2.is_del, '0') = '0'
|
||||
)
|
||||
and ifnull(c.status, '1') <> '2'
|
||||
<choose>
|
||||
@@ -259,9 +265,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from product p
|
||||
<where>
|
||||
and p.status = '1'
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
and p.product_id = (
|
||||
select max(p2.product_id) from product p2
|
||||
where p2.product_code = p.product_code and p2.status = '1'
|
||||
and ifnull(p2.is_del, '0') = '0'
|
||||
)
|
||||
</where>
|
||||
order by p.product_code asc
|
||||
|
||||
@@ -121,9 +121,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
sysdate()
|
||||
from product p
|
||||
where p.status = '1'
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
and p.product_id = (
|
||||
select max(p2.product_id) from product p2
|
||||
where p2.product_code = p.product_code and p2.status = '1'
|
||||
and ifnull(p2.is_del, '0') = '0'
|
||||
)
|
||||
order by p.product_code asc
|
||||
</insert>
|
||||
@@ -146,9 +148,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
null as update_time
|
||||
from product p
|
||||
where p.status = '1'
|
||||
and ifnull(p.is_del, '0') = '0'
|
||||
and p.product_id = (
|
||||
select max(p2.product_id) from product p2
|
||||
where p2.product_code = p.product_code and p2.status = '1'
|
||||
and ifnull(p2.is_del, '0') = '0'
|
||||
)
|
||||
order by p.product_code asc
|
||||
</select>
|
||||
|
||||
@@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="currency" column="currency" />
|
||||
<result property="roundMode" column="round_mode" />
|
||||
<result property="ssCode" column="ss_code" />
|
||||
<result property="isDel" column="is_del" />
|
||||
<result property="countryCode" column="country_code" />
|
||||
<result property="scNote" column="sc_note" />
|
||||
<result property="tmsId" column="tms_id" />
|
||||
@@ -23,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrcSurchargeVo">
|
||||
select sc_id, sc_name, fee_type, charge_type, charge_value, currency, round_mode, ss_code,
|
||||
select sc_id, sc_name, fee_type, charge_type, charge_value, currency, round_mode, ss_code, is_del,
|
||||
country_code, sc_note, tms_id, created_by, create_time, updated_by, update_time
|
||||
from prc_surcharge
|
||||
</sql>
|
||||
@@ -31,11 +32,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectPrcSurchargeById" parameterType="Long" resultMap="PrcSurchargeResult">
|
||||
<include refid="selectPrcSurchargeVo"/>
|
||||
where sc_id = #{scId}
|
||||
and ifnull(is_del, '0') = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectPrcSurchargeList" parameterType="PrcSurcharge" resultMap="PrcSurchargeResult">
|
||||
<include refid="selectPrcSurchargeVo"/>
|
||||
<where>
|
||||
and ifnull(is_del, '0') = '0'
|
||||
<if test="scName != null and scName != ''">
|
||||
AND sc_name like concat('%', #{scName}, '%')
|
||||
</if>
|
||||
@@ -76,6 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="currency != null and currency != ''">currency,</if>
|
||||
<if test="roundMode != null and roundMode != ''">round_mode,</if>
|
||||
<if test="ssCode != null and ssCode != ''">ss_code,</if>
|
||||
is_del,
|
||||
<if test="countryCode != null">country_code,</if>
|
||||
<if test="scNote != null">sc_note,</if>
|
||||
<if test="tmsId != null">tms_id,</if>
|
||||
@@ -89,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="currency != null and currency != ''">#{currency},</if>
|
||||
<if test="roundMode != null and roundMode != ''">#{roundMode},</if>
|
||||
<if test="ssCode != null and ssCode != ''">#{ssCode},</if>
|
||||
ifnull(#{isDel}, '0'),
|
||||
<if test="countryCode != null">#{countryCode},</if>
|
||||
<if test="scNote != null">#{scNote},</if>
|
||||
<if test="tmsId != null">#{tmsId},</if>
|
||||
@@ -101,7 +106,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updateSsCodeByIds">
|
||||
update prc_surcharge
|
||||
set ss_code = #{ssCode}, updated_by = #{operator}, update_time = sysdate()
|
||||
where sc_id in
|
||||
where ifnull(is_del, '0') = '0'
|
||||
and sc_id in
|
||||
<foreach item="scId" collection="scIds" open="(" separator="," close=")">
|
||||
#{scId}
|
||||
</foreach>
|
||||
|
||||
@@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="detailId" column="detail_id" />
|
||||
<result property="priceType" column="price_type" />
|
||||
<result property="countryCode" column="country_code" />
|
||||
<result property="isDel" column="is_del" />
|
||||
<result property="scName" column="sc_name" />
|
||||
<result property="feeType" column="fee_type" />
|
||||
<result property="chargeType" column="charge_type" />
|
||||
@@ -31,20 +32,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<sql id="selectPrcSurchargeRelVo">
|
||||
select r.rel_id, r.sc_id, r.product_id, r.product_code, r.detail_id,
|
||||
r.price_type, r.country_code,
|
||||
r.price_type, r.country_code, r.is_del,
|
||||
r.created_by, r.create_time, r.updated_by, r.update_time,
|
||||
s.sc_name, s.fee_type, s.charge_type, s.charge_value, s.currency,
|
||||
s.round_mode, s.ss_code, s.sc_note,
|
||||
ifnull(c.country_name, rc.country_name) as country_name, ifnull(c.weight_min, rc.weight_min) as weight_min, ifnull(c.weight_max, rc.weight_max) as weight_max
|
||||
from prc_surcharge_rel r
|
||||
join prc_surcharge s on s.sc_id = r.sc_id
|
||||
left join product_country c on c.detail_id = r.detail_id and r.price_type = 'PRODUCT'
|
||||
left join redline_product_country rc on rc.detail_id = r.detail_id and r.price_type = 'REDLINE'
|
||||
join prc_surcharge s on s.sc_id = r.sc_id and ifnull(s.is_del, '0') = '0'
|
||||
left join product_country c on c.detail_id = r.detail_id and r.price_type = 'PRODUCT' and ifnull(c.is_del, '0') = '0'
|
||||
left join redline_product_country rc on rc.detail_id = r.detail_id and r.price_type = 'REDLINE' and ifnull(rc.is_del, '0') = '0'
|
||||
</sql>
|
||||
|
||||
<select id="selectPrcSurchargeRelList" parameterType="PrcSurchargeRel" resultMap="PrcSurchargeRelResult">
|
||||
<include refid="selectPrcSurchargeRelVo"/>
|
||||
<where>
|
||||
and ifnull(r.is_del, '0') = '0'
|
||||
<if test="productId != null">
|
||||
AND r.product_id = #{productId}
|
||||
</if>
|
||||
@@ -69,7 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectByDetailIdsAndPriceType" resultMap="PrcSurchargeRelResult">
|
||||
<include refid="selectPrcSurchargeRelVo"/>
|
||||
where r.price_type = #{priceType}
|
||||
where ifnull(r.is_del, '0') = '0'
|
||||
and r.price_type = #{priceType}
|
||||
and r.detail_id in
|
||||
<foreach item="id" collection="detailIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
@@ -79,55 +82,66 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="insertPrcSurchargeRel" parameterType="PrcSurchargeRel" useGeneratedKeys="true" keyProperty="relId">
|
||||
insert into prc_surcharge_rel (
|
||||
sc_id, product_id, product_code, detail_id, price_type, country_code,
|
||||
sc_id, product_id, product_code, detail_id, price_type, country_code, is_del,
|
||||
<if test="createBy != null and createBy != ''">created_by,</if>
|
||||
create_time
|
||||
) values (
|
||||
#{scId}, #{productId}, #{productCode}, #{detailId},
|
||||
#{priceType}, #{countryCode},
|
||||
#{priceType}, #{countryCode}, ifnull(#{isDel}, '0'),
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deletePrcSurchargeRelByIds" parameterType="Long">
|
||||
delete from prc_surcharge_rel where rel_id in
|
||||
<update id="deletePrcSurchargeRelByIds" parameterType="Long">
|
||||
update prc_surcharge_rel
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where ifnull(is_del, '0') = '0'
|
||||
and rel_id in
|
||||
<foreach item="relId" collection="array" open="(" separator="," close=")">
|
||||
#{relId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<delete id="deleteRelByProductCodes">
|
||||
delete from prc_surcharge_rel where product_code in
|
||||
<update id="deleteRelByProductCodes">
|
||||
update prc_surcharge_rel
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where ifnull(is_del, '0') = '0'
|
||||
and price_type = 'PRODUCT'
|
||||
and product_code in
|
||||
<foreach item="code" collection="array" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
and price_type = 'PRODUCT'
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<delete id="deleteByDetailIdsAndPriceType">
|
||||
delete from prc_surcharge_rel
|
||||
where price_type = #{priceType}
|
||||
<update id="deleteByDetailIdsAndPriceType">
|
||||
update prc_surcharge_rel
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where ifnull(is_del, '0') = '0'
|
||||
and price_type = #{priceType}
|
||||
and detail_id in
|
||||
<foreach item="id" collection="detailIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductIdsAndPriceType">
|
||||
delete from prc_surcharge_rel
|
||||
where price_type = #{priceType}
|
||||
<update id="deleteByProductIdsAndPriceType">
|
||||
update prc_surcharge_rel
|
||||
set is_del = '1', update_time = sysdate()
|
||||
where ifnull(is_del, '0') = '0'
|
||||
and price_type = #{priceType}
|
||||
and product_id in
|
||||
<foreach item="id" collection="productIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<!-- 附加费版本化编辑后,产品关联重指向新记录 -->
|
||||
<update id="rebindRelScId">
|
||||
update prc_surcharge_rel
|
||||
set sc_id = #{newScId}, updated_by = #{operator}, update_time = sysdate()
|
||||
where sc_id = #{oldScId}
|
||||
where ifnull(is_del, '0') = '0'
|
||||
and sc_id = #{oldScId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -299,6 +299,7 @@ CREATE TABLE `product` (
|
||||
`effective_date` datetime DEFAULT NULL COMMENT '目录生效时间(到小时)',
|
||||
`expire_date` datetime DEFAULT NULL COMMENT '产品失效时间(空=长期;下一版生效时间=本版失效时间)',
|
||||
`status` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '0待生效 1已生效 2已失效',
|
||||
`is_del` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '是否删除 0未删除 1已删除',
|
||||
`source_sheet` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '来源Excel sheet名',
|
||||
`remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`tms_id` int(11) DEFAULT NULL COMMENT '多租户ID',
|
||||
@@ -307,7 +308,7 @@ CREATE TABLE `product` (
|
||||
`updated_by` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`product_id`) USING BTREE,
|
||||
UNIQUE KEY `uk_product_code_eff` (`product_code`,`effective_date`),
|
||||
UNIQUE KEY `uk_product_code_eff_is_del` (`product_code`,`effective_date`,`is_del`),
|
||||
KEY `idx_tax_status` (`tax_mode`,`status`) USING BTREE,
|
||||
KEY `idx_product_code` (`product_code`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='产品主表-来自产品目录';
|
||||
@@ -336,10 +337,11 @@ CREATE TABLE `product_country` (
|
||||
`effective_date` datetime DEFAULT NULL COMMENT '产品价表生效时间(到小时)',
|
||||
`expire_date` datetime DEFAULT NULL COMMENT '失效时间(空=开放;下一版导入生效时间=本版失效时间)',
|
||||
`status` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '0待生效 1已生效 2已失效',
|
||||
`is_del` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '是否删除 0未删除 1已删除',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`detail_id`) USING BTREE,
|
||||
UNIQUE KEY `uk_product_country_zone_weight_eff` (`product_code`,`country_name`,`zone_code`,`weight_min`,`weight_max`,`effective_date`),
|
||||
UNIQUE KEY `uk_product_country_zone_weight_eff_is_del` (`product_code`,`country_name`,`zone_code`,`weight_min`,`weight_max`,`effective_date`,`is_del`),
|
||||
KEY `idx_country_code` (`country_code`) USING BTREE,
|
||||
KEY `idx_weight_match` (`product_code`,`country_code`,`weight_min`,`weight_max`) USING BTREE,
|
||||
KEY `idx_product_eff` (`product_code`,`effective_date`,`expire_date`),
|
||||
@@ -364,6 +366,7 @@ CREATE TABLE IF NOT EXISTS `redline_product` (
|
||||
`effective_date` datetime DEFAULT NULL COMMENT '目录生效时间(到小时)',
|
||||
`expire_date` datetime DEFAULT NULL COMMENT '失效时间(空=长期)',
|
||||
`status` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '0待生效 1已生效 2已失效',
|
||||
`is_del` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '是否删除 0未删除 1已删除',
|
||||
`source_sheet` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '来源Excel sheet名',
|
||||
`pef_id` bigint(20) DEFAULT NULL COMMENT '关联导入价表Excel附件 prc_price_excel_file.pef_id',
|
||||
`remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
@@ -373,7 +376,7 @@ CREATE TABLE IF NOT EXISTS `redline_product` (
|
||||
`updated_by` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`product_id`) USING BTREE,
|
||||
UNIQUE KEY `uk_redline_product_code_eff` (`product_code`,`effective_date`),
|
||||
UNIQUE KEY `uk_redline_product_code_eff_is_del` (`product_code`,`effective_date`,`is_del`),
|
||||
KEY `idx_redline_tax_status` (`tax_mode`,`status`) USING BTREE,
|
||||
KEY `idx_redline_product_code` (`product_code`),
|
||||
KEY `idx_redline_product_pef_id` (`pef_id`)
|
||||
@@ -398,10 +401,11 @@ CREATE TABLE IF NOT EXISTS `redline_product_country` (
|
||||
`effective_date` datetime DEFAULT NULL COMMENT '生效时间(到小时)',
|
||||
`expire_date` datetime DEFAULT NULL COMMENT '失效时间(空=开放)',
|
||||
`status` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '0待生效 1已生效 2已失效',
|
||||
`is_del` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '是否删除 0未删除 1已删除',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`detail_id`) USING BTREE,
|
||||
UNIQUE KEY `uk_redline_country_zone_weight_eff` (`product_code`,`country_name`,`zone_code`,`weight_min`,`weight_max`,`effective_date`),
|
||||
UNIQUE KEY `uk_redline_country_zone_weight_eff_is_del` (`product_code`,`country_name`,`zone_code`,`weight_min`,`weight_max`,`effective_date`,`is_del`),
|
||||
KEY `idx_redline_country_code` (`country_code`) USING BTREE,
|
||||
KEY `idx_redline_weight_match` (`product_code`,`country_code`,`weight_min`,`weight_max`) USING BTREE,
|
||||
KEY `idx_redline_product_eff` (`product_code`,`effective_date`,`expire_date`),
|
||||
@@ -1505,6 +1509,7 @@ CREATE TABLE `prc_surcharge` (
|
||||
`currency` char(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'CNY' COMMENT '币种',
|
||||
`round_mode` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'HALF_UP' COMMENT '取值方式(字典bms_round_mode)',
|
||||
`ss_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'on' COMMENT '状态 on/of',
|
||||
`is_del` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '是否删除 0未删除 1已删除',
|
||||
`country_code` char(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '适用国家ISO2(空=全部)',
|
||||
`sc_note` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
|
||||
`tms_id` bigint(20) DEFAULT NULL COMMENT '租户ID',
|
||||
@@ -1529,12 +1534,13 @@ CREATE TABLE `prc_surcharge_rel` (
|
||||
`detail_id` bigint(20) DEFAULT NULL COMMENT '明细ID:PRODUCT/REDLINE=product_country.detail_id(空=产品全部);SALES=prc_price_set_detail.psd_id',
|
||||
`price_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'PRODUCT' COMMENT '价格类型 PRODUCT产品价/SALES销售价/REDLINE红线价',
|
||||
`country_code` char(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '适用国家ISO2(空=全部)',
|
||||
`is_del` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '是否删除 0未删除 1已删除',
|
||||
`created_by` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL,
|
||||
`updated_by` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`rel_id`),
|
||||
UNIQUE KEY `uk_rel_scope` (`sc_id`,`product_id`,`detail_id`,`price_type`,`country_code`),
|
||||
UNIQUE KEY `uk_rel_scope_is_del` (`sc_id`,`product_id`,`detail_id`,`price_type`,`country_code`,`is_del`),
|
||||
KEY `idx_rel_sc` (`sc_id`),
|
||||
KEY `idx_rel_product` (`product_id`),
|
||||
KEY `idx_rel_product_code` (`product_code`),
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
-- product / product_country / prc_surcharge: is_del (0 not deleted / 1 deleted)
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
SET @col := (
|
||||
SELECT COLUMN_NAME FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'product'
|
||||
AND COLUMN_NAME = 'is_del'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@col IS NULL,
|
||||
'ALTER TABLE product ADD COLUMN is_del char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''0'' COMMENT ''是否删除 0未删除 1已删除'' AFTER status',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx := (
|
||||
SELECT INDEX_NAME FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'product'
|
||||
AND INDEX_NAME = 'uk_product_code_eff'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@idx IS NULL, 'SELECT 1', 'ALTER TABLE product DROP INDEX uk_product_code_eff');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx := (
|
||||
SELECT INDEX_NAME FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'product'
|
||||
AND INDEX_NAME = 'uk_product_code_eff_is_del'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@idx IS NULL, 'ALTER TABLE product ADD UNIQUE KEY uk_product_code_eff_is_del (product_code, effective_date, is_del)', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @col := (
|
||||
SELECT COLUMN_NAME FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'product_country'
|
||||
AND COLUMN_NAME = 'is_del'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@col IS NULL,
|
||||
'ALTER TABLE product_country ADD COLUMN is_del char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''0'' COMMENT ''是否删除 0未删除 1已删除'' AFTER status',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx := (
|
||||
SELECT INDEX_NAME FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'product_country'
|
||||
AND INDEX_NAME = 'uk_product_country_zone_weight_eff'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@idx IS NULL, 'SELECT 1', 'ALTER TABLE product_country DROP INDEX uk_product_country_zone_weight_eff');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx := (
|
||||
SELECT INDEX_NAME FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'product_country'
|
||||
AND INDEX_NAME = 'uk_product_country_zone_weight_eff_is_del'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@idx IS NULL, 'ALTER TABLE product_country ADD UNIQUE KEY uk_product_country_zone_weight_eff_is_del (product_code, country_name, zone_code, weight_min, weight_max, effective_date, is_del)', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @col := (
|
||||
SELECT COLUMN_NAME FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'prc_surcharge'
|
||||
AND COLUMN_NAME = 'is_del'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@col IS NULL,
|
||||
'ALTER TABLE prc_surcharge ADD COLUMN is_del char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''0'' COMMENT ''是否删除 0未删除 1已删除'' AFTER ss_code',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
UPDATE product SET is_del = '0' WHERE is_del IS NULL;
|
||||
UPDATE product_country SET is_del = '0' WHERE is_del IS NULL;
|
||||
UPDATE prc_surcharge SET is_del = '0' WHERE is_del IS NULL;
|
||||
|
||||
-- redline_product / redline_product_country
|
||||
SET @col := (
|
||||
SELECT COLUMN_NAME FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'redline_product'
|
||||
AND COLUMN_NAME = 'is_del'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@col IS NULL,
|
||||
'ALTER TABLE redline_product ADD COLUMN is_del char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''0'' COMMENT ''是否删除 0未删除 1已删除'' AFTER status',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx := (
|
||||
SELECT INDEX_NAME FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'redline_product'
|
||||
AND INDEX_NAME = 'uk_redline_product_code_eff'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@idx IS NULL, 'SELECT 1', 'ALTER TABLE redline_product DROP INDEX uk_redline_product_code_eff');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx := (
|
||||
SELECT INDEX_NAME FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'redline_product'
|
||||
AND INDEX_NAME = 'uk_redline_product_code_eff_is_del'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@idx IS NULL, 'ALTER TABLE redline_product ADD UNIQUE KEY uk_redline_product_code_eff_is_del (product_code, effective_date, is_del)', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @col := (
|
||||
SELECT COLUMN_NAME FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'redline_product_country'
|
||||
AND COLUMN_NAME = 'is_del'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@col IS NULL,
|
||||
'ALTER TABLE redline_product_country ADD COLUMN is_del char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''0'' COMMENT ''是否删除 0未删除 1已删除'' AFTER status',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx := (
|
||||
SELECT INDEX_NAME FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'redline_product_country'
|
||||
AND INDEX_NAME = 'uk_redline_country_zone_weight_eff'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@idx IS NULL, 'SELECT 1', 'ALTER TABLE redline_product_country DROP INDEX uk_redline_country_zone_weight_eff');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx := (
|
||||
SELECT INDEX_NAME FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'redline_product_country'
|
||||
AND INDEX_NAME = 'uk_redline_country_zone_weight_eff_is_del'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@idx IS NULL, 'ALTER TABLE redline_product_country ADD UNIQUE KEY uk_redline_country_zone_weight_eff_is_del (product_code, country_name, zone_code, weight_min, weight_max, effective_date, is_del)', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
UPDATE redline_product SET is_del = '0' WHERE is_del IS NULL;
|
||||
UPDATE redline_product_country SET is_del = '0' WHERE is_del IS NULL;
|
||||
|
||||
-- prc_surcharge_rel
|
||||
SET @col := (
|
||||
SELECT COLUMN_NAME FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'prc_surcharge_rel'
|
||||
AND COLUMN_NAME = 'is_del'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@col IS NULL,
|
||||
'ALTER TABLE prc_surcharge_rel ADD COLUMN is_del char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''0'' COMMENT ''是否删除 0未删除 1已删除'' AFTER country_code',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx := (
|
||||
SELECT INDEX_NAME FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'prc_surcharge_rel'
|
||||
AND INDEX_NAME = 'uk_rel_scope'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@idx IS NULL, 'SELECT 1', 'ALTER TABLE prc_surcharge_rel DROP INDEX uk_rel_scope');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @idx := (
|
||||
SELECT INDEX_NAME FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'prc_surcharge_rel'
|
||||
AND INDEX_NAME = 'uk_rel_scope_is_del'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @sql := IF(@idx IS NULL, 'ALTER TABLE prc_surcharge_rel ADD UNIQUE KEY uk_rel_scope_is_del (sc_id, product_id, detail_id, price_type, country_code, is_del)', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
UPDATE prc_surcharge_rel SET is_del = '0' WHERE is_del IS NULL;
|
||||
@@ -13,6 +13,7 @@ CREATE TABLE IF NOT EXISTS `redline_product` (
|
||||
`effective_date` datetime DEFAULT NULL COMMENT '目录生效时间(到小时)',
|
||||
`expire_date` datetime DEFAULT NULL COMMENT '失效时间(空=长期)',
|
||||
`status` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '0待生效 1已生效 2已失效',
|
||||
`is_del` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '是否删除 0未删除 1已删除',
|
||||
`source_sheet` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '来源Excel sheet名',
|
||||
`pef_id` bigint(20) DEFAULT NULL COMMENT '关联导入价表Excel附件 prc_price_excel_file.pef_id',
|
||||
`remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
@@ -22,7 +23,7 @@ CREATE TABLE IF NOT EXISTS `redline_product` (
|
||||
`updated_by` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`product_id`) USING BTREE,
|
||||
UNIQUE KEY `uk_redline_product_code_eff` (`product_code`,`effective_date`),
|
||||
UNIQUE KEY `uk_redline_product_code_eff_is_del` (`product_code`,`effective_date`,`is_del`),
|
||||
KEY `idx_redline_tax_status` (`tax_mode`,`status`) USING BTREE,
|
||||
KEY `idx_redline_product_code` (`product_code`),
|
||||
KEY `idx_redline_product_pef_id` (`pef_id`)
|
||||
@@ -47,10 +48,11 @@ CREATE TABLE IF NOT EXISTS `redline_product_country` (
|
||||
`effective_date` datetime DEFAULT NULL COMMENT '生效时间(到小时)',
|
||||
`expire_date` datetime DEFAULT NULL COMMENT '失效时间(空=开放)',
|
||||
`status` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '0待生效 1已生效 2已失效',
|
||||
`is_del` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '是否删除 0未删除 1已删除',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`detail_id`) USING BTREE,
|
||||
UNIQUE KEY `uk_redline_country_zone_weight_eff` (`product_code`,`country_name`,`zone_code`,`weight_min`,`weight_max`,`effective_date`),
|
||||
UNIQUE KEY `uk_redline_country_zone_weight_eff_is_del` (`product_code`,`country_name`,`zone_code`,`weight_min`,`weight_max`,`effective_date`,`is_del`),
|
||||
KEY `idx_redline_country_code` (`country_code`) USING BTREE,
|
||||
KEY `idx_redline_weight_match` (`product_code`,`country_code`,`weight_min`,`weight_max`) USING BTREE,
|
||||
KEY `idx_redline_product_eff` (`product_code`,`effective_date`,`expire_date`),
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
:search-columns="searchColumns"
|
||||
:query="queryList"
|
||||
row-key="productId"
|
||||
:selection="true"
|
||||
>
|
||||
<template #toolbar="{ selection }">
|
||||
<el-col :span="1.5">
|
||||
@@ -33,6 +34,16 @@
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="!selection.length"
|
||||
@click="handleBatchDelete(selection)"
|
||||
v-hasPermi="['price:redline:remove']"
|
||||
>批量删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button plain icon="Clock" @click="expiredRef.open()" v-hasPermi="['price:redline:list']">失效价格</el-button>
|
||||
</el-col>
|
||||
@@ -152,9 +163,10 @@ import RedlineExcelFileDrawer from './components/RedlineExcelFileDrawer.vue'
|
||||
import RedlineCountryDrawer from './components/RedlineCountryDrawer.vue'
|
||||
import RedlineSurchargeDrawer from './components/RedlineSurchargeDrawer.vue'
|
||||
import RedlineExpiredDrawer from './components/RedlineExpiredDrawer.vue'
|
||||
import { listRedline, importRedlineExcelAsync, importRedlineCountryExcelAsync } from '@/api/price/redline'
|
||||
import { listRedline, delRedline, importRedlineExcelAsync, importRedlineCountryExcelAsync } from '@/api/price/redline'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_product_effect_status } = useDict('bms_product_effect_status')
|
||||
|
||||
const extraParams = { statusGroup: 'active' }
|
||||
@@ -240,6 +252,47 @@ function handleUpdate(row) {
|
||||
formRef.value.open(row)
|
||||
}
|
||||
|
||||
function isPendingProduct(row) {
|
||||
if (!row) return false
|
||||
if (String(row.status) === '0') return true
|
||||
if (!row.effectiveDate) return false
|
||||
const eff = new Date(String(row.effectiveDate).replace(/-/g, '/')).getTime()
|
||||
if (Number.isNaN(eff) || eff <= Date.now()) return false
|
||||
if (row.expireDate) {
|
||||
const exp = new Date(String(row.expireDate).replace(/-/g, '/')).getTime()
|
||||
if (!Number.isNaN(exp) && exp <= Date.now()) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function handleBatchDelete(selection) {
|
||||
const rows = (selection || []).filter(r => r && r.productId != null)
|
||||
if (!rows.length) {
|
||||
proxy.$modal.msgWarning('请先勾选红线价')
|
||||
return
|
||||
}
|
||||
const pending = rows.filter(isPendingProduct)
|
||||
const blocked = rows.filter(r => !isPendingProduct(r))
|
||||
if (!pending.length) {
|
||||
proxy.$modal.msgWarning('仅待生效红线价可删除,当前勾选无待生效记录')
|
||||
return
|
||||
}
|
||||
if (blocked.length) {
|
||||
const tip = blocked.map(r => r.productCode || r.productId).join('、')
|
||||
proxy.$modal.msgWarning('已跳过非待生效红线价:' + tip)
|
||||
}
|
||||
const codes = pending.map(r => r.productCode || r.productId).join('、')
|
||||
const ids = pending.map(r => r.productId)
|
||||
proxy.$modal.confirm(
|
||||
'确认删除已选待生效红线价(' + pending.length + '个):'
|
||||
+ codes
|
||||
+ '?删除后产品及国家/重量段明细将一并清除,且不可恢复。'
|
||||
).then(() => delRedline(ids)).then(() => {
|
||||
tableRef.value.refresh()
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function handleImportCommand(command) {
|
||||
if (command === 'country') {
|
||||
handleCountryImport()
|
||||
|
||||
Reference in New Issue
Block a user