应付账单初始化
This commit is contained in:
@@ -85,6 +85,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectServiceChannelByName" parameterType="String" resultMap="ServiceChannelResult">
|
||||
<include refid="selectChannelVo"/>
|
||||
where channel_name = #{channelName}
|
||||
limit 2
|
||||
</select>
|
||||
|
||||
<select id="countProductChannelByCode" parameterType="String" resultType="int">
|
||||
select count(1) from srv_product_channel where channel_code = #{channelCode}
|
||||
</select>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.ChannelProductMapMapper">
|
||||
|
||||
<select id="selectByChannelAndType" resultType="com.bms.price.domain.ChannelProductMap">
|
||||
select id, channel_id as channelId, product_id as productId, price_set_id as priceSetId,
|
||||
pay_type as payType, create_by as createBy, create_time as createTime,
|
||||
update_by as updateBy, update_time as updateTime
|
||||
from srv_channel_product_map
|
||||
where channel_id = #{channelId} and pay_type = #{payType}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="upsert">
|
||||
insert into srv_channel_product_map (
|
||||
channel_id, product_id, price_set_id, pay_type, create_by, create_time, update_by, update_time
|
||||
) values (
|
||||
#{channelId}, #{productId}, #{priceSetId}, #{payType}, #{createBy}, sysdate(), #{updateBy}, sysdate()
|
||||
)
|
||||
on duplicate key update
|
||||
product_id = values(product_id),
|
||||
price_set_id = values(price_set_id),
|
||||
update_by = values(update_by),
|
||||
update_time = sysdate()
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByChannelAndType">
|
||||
delete from srv_channel_product_map
|
||||
where channel_id = #{channelId} and pay_type = #{payType}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByProductId">
|
||||
delete from srv_channel_product_map where product_id = #{productId}
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.PayBillMapper">
|
||||
|
||||
<select id="selectPayBillList" resultType="com.bms.price.domain.PayBill">
|
||||
select bill_id as billId, bill_no as billNo, supplier_id as supplierId, supplier_name as supplierName,
|
||||
currency, source_type as sourceType, period_start as periodStart, period_end as periodEnd,
|
||||
order_count as orderCount, total_amount as totalAmount, status, void_reason as voidReason,
|
||||
void_by as voidBy, void_time as voidTime, create_by as createBy, create_time as createTime, remark
|
||||
from pay_bill
|
||||
<where>
|
||||
<if test="billNo != null and billNo != ''">and bill_no like concat('%', #{billNo}, '%')</if>
|
||||
<if test="supplierName != null and supplierName != ''">and supplier_name like concat('%', #{supplierName}, '%')</if>
|
||||
<if test="status != null and status != ''">and status = #{status}</if>
|
||||
<if test="currency != null and currency != ''">and currency = #{currency}</if>
|
||||
</where>
|
||||
order by bill_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectPayBillById" resultType="com.bms.price.domain.PayBill">
|
||||
select bill_id as billId, bill_no as billNo, supplier_id as supplierId, supplier_name as supplierName,
|
||||
currency, source_type as sourceType, period_start as periodStart, period_end as periodEnd,
|
||||
order_count as orderCount, total_amount as totalAmount, status, void_reason as voidReason,
|
||||
void_by as voidBy, void_time as voidTime, create_by as createBy, create_time as createTime, remark
|
||||
from pay_bill where bill_id = #{billId}
|
||||
</select>
|
||||
|
||||
<select id="selectLines" resultType="com.bms.price.domain.PayBillLine">
|
||||
select line_id as lineId, bill_id as billId, order_bill_id as orderBillId, order_no as orderNo,
|
||||
lading_no as ladingNo, lading_fee_id as ladingFeeId, fee_name as feeName, amount, currency,
|
||||
price_date as priceDate, version_no as versionNo, remote_flag as remoteFlag,
|
||||
density_level as densityLevel, line_source as lineSource
|
||||
from pay_bill_line where bill_id = #{billId} order by line_id
|
||||
</select>
|
||||
|
||||
<select id="selectLogs" resultType="com.bms.price.domain.PayBillLog">
|
||||
select log_id as logId, bill_id as billId, operation_type as operationType, from_status as fromStatus,
|
||||
to_status as toStatus, operation_desc as operationDesc, operator_name as operatorName, create_time as createTime
|
||||
from pay_bill_log where bill_id = #{billId} order by log_id
|
||||
</select>
|
||||
|
||||
<select id="selectCandidateOrders" resultType="com.bms.price.domain.PayBillOrder">
|
||||
select o.bill_id as billId, o.order_no as orderNo, o.tracking_no as trackingNo, o.biz_date as bizDate,
|
||||
o.pay_total as payTotal, o.currency as currency, o.pieces as pieces, o.charge_weight as chargeWeight,
|
||||
o.product_name as productName, o.country_code as countryCode, o.country_name as countryName,
|
||||
o.dest_postcode as destPostcode, e.air_no_old as ladingNo, e.product_floor as channelName,
|
||||
e.supplier_name as supplierName,
|
||||
(select group_concat(concat(ifnull(nullif(trim(f.fee_name), ''), ifnull(f.fee_type, '费用')), ' ', format(f.amount, 2))
|
||||
order by field(f.fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE', 'REFUND'), f.fee_id separator ';')
|
||||
from prc_pay_bill_fee f where f.bill_id = o.bill_id) as feeText,
|
||||
(select b.bill_no from pay_bill_line l
|
||||
inner join pay_bill b on b.bill_id = l.bill_id
|
||||
where l.order_bill_id = o.bill_id and b.status <> 'VOID'
|
||||
limit 1) as occupiedBillNo
|
||||
from prc_order_bill o
|
||||
left join prc_order_bill_ext e on e.bill_id = o.bill_id
|
||||
<where>
|
||||
<if test="orderNos != null and orderNos.size() > 0">
|
||||
and o.order_no in
|
||||
<foreach collection="orderNos" item="no" open="(" separator="," close=")">#{no}</foreach>
|
||||
</if>
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
and o.biz_date >= #{beginDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and o.biz_date < date_add(#{endDate}, interval 1 day)
|
||||
</if>
|
||||
<if test="ladingNos != null and ladingNos.size() > 0">
|
||||
and (
|
||||
e.air_no_old in
|
||||
<foreach collection="ladingNos" item="no" open="(" separator="," close=")">#{no}</foreach>
|
||||
or e.lading_id in (
|
||||
select lading_id from pay_lading where lading_no in
|
||||
<foreach collection="ladingNos" item="no" open="(" separator="," close=")">#{no}</foreach>
|
||||
)
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
order by o.biz_date, o.order_no
|
||||
limit 2000
|
||||
</select>
|
||||
|
||||
<select id="selectOrderFees" resultType="com.bms.price.domain.PrcPayBillFee">
|
||||
select fee_id as feeId, bill_id as billId, fee_name as feeName, amount, currency, fee_source as feeSource
|
||||
from prc_pay_bill_fee
|
||||
where bill_id in
|
||||
<foreach collection="billIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
order by bill_id, fee_id
|
||||
</select>
|
||||
|
||||
<insert id="insertPayBill" useGeneratedKeys="true" keyProperty="billId">
|
||||
insert into pay_bill (
|
||||
bill_no, supplier_id, supplier_name, currency, source_type, period_start, period_end,
|
||||
order_count, total_amount, status, create_by, create_time, remark
|
||||
) values (
|
||||
#{billNo}, #{supplierId}, #{supplierName}, #{currency}, #{sourceType}, #{periodStart}, #{periodEnd},
|
||||
#{orderCount}, #{totalAmount}, 'DRAFT', #{createBy}, sysdate(), #{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updatePayBillStatus">
|
||||
update pay_bill
|
||||
set status = #{status},
|
||||
void_reason = #{voidReason},
|
||||
void_by = #{voidBy},
|
||||
void_time = #{voidTime},
|
||||
update_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where bill_id = #{billId}
|
||||
</update>
|
||||
|
||||
<insert id="insertLines">
|
||||
insert into pay_bill_line (
|
||||
bill_id, order_bill_id, order_no, lading_no, lading_fee_id, fee_name, amount, currency,
|
||||
price_date, version_no, remote_flag, density_level, line_source
|
||||
) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.billId}, #{item.orderBillId}, #{item.orderNo}, #{item.ladingNo}, #{item.ladingFeeId},
|
||||
#{item.feeName}, #{item.amount}, #{item.currency}, #{item.priceDate}, #{item.versionNo},
|
||||
#{item.remoteFlag}, #{item.densityLevel}, #{item.lineSource})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertLog">
|
||||
insert into pay_bill_log (bill_id, operation_type, from_status, to_status, operation_desc, operator_name, create_time)
|
||||
values (#{billId}, #{operationType}, #{fromStatus}, #{toStatus}, #{operationDesc}, #{operatorName}, sysdate())
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.PayPostcodeMapper">
|
||||
|
||||
<select id="selectGroupList" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select group_id as groupId, source_file as sourceFile, file_md5 as fileMd5, sheet_name as sheetName,
|
||||
block_title as blockTitle, config_kind as configKind, coverage, channel_name as channelName,
|
||||
country_name as countryName, country_code as countryCode,
|
||||
service_type as serviceType, catalog_country as catalogCountry, product_name as productName, quote_sheet as quoteSheet,
|
||||
fee_name as feeName, fee_text as feeText, line_count as lineCount, create_by as createBy, create_time as createTime, remark
|
||||
from pay_postcode_group
|
||||
<where>
|
||||
<if test="sourceFile != null and sourceFile != ''">and source_file like concat('%', #{sourceFile}, '%')</if>
|
||||
<if test="sheetName != null and sheetName != ''">and sheet_name like concat('%', #{sheetName}, '%')</if>
|
||||
<if test="countryName != null and countryName != ''">and (country_name like concat('%', #{countryName}, '%') or country_code like concat('%', #{countryName}, '%') or catalog_country like concat('%', #{countryName}, '%'))</if>
|
||||
<if test="serviceType != null and serviceType != ''">and service_type like concat('%', #{serviceType}, '%')</if>
|
||||
<if test="productName != null and productName != ''">and product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="quoteSheet != null and quoteSheet != ''">and quote_sheet like concat('%', #{quoteSheet}, '%')</if>
|
||||
<if test="configKind != null and configKind != ''">and config_kind = #{configKind}</if>
|
||||
<if test="coverage != null and coverage != ''">and coverage = #{coverage}</if>
|
||||
<if test="channelName != null and channelName != ''">and channel_name like concat('%', #{channelName}, '%')</if>
|
||||
<if test="feeName != null and feeName != ''">and fee_name like concat('%', #{feeName}, '%')</if>
|
||||
<if test="postcode != null and postcode != ''">
|
||||
and exists (
|
||||
select 1 from pay_postcode_line l
|
||||
where l.group_id = pay_postcode_group.group_id and l.postcode like concat('%', #{postcode}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
order by group_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectLineList" parameterType="com.bms.price.domain.PayPostcodeLine" resultType="com.bms.price.domain.PayPostcodeLine">
|
||||
select line_id as lineId, group_id as groupId, country_name as countryName, country_code as countryCode,
|
||||
region_name as regionName, region_name_cn as regionNameCn, city_name as cityName, region_code as regionCode,
|
||||
zone_name as zoneName, postcode, postcode_raw as postcodeRaw, postcode_end as postcodeEnd,
|
||||
extra_text as extraText, sort_no as sortNo
|
||||
from pay_postcode_line
|
||||
<where>
|
||||
<if test="groupId != null">and group_id = #{groupId}</if>
|
||||
<if test="postcode != null and postcode != ''">and postcode like concat('%', #{postcode}, '%')</if>
|
||||
<if test="regionName != null and regionName != ''">and (region_name like concat('%', #{regionName}, '%') or region_name_cn like concat('%', #{regionName}, '%') or zone_name like concat('%', #{regionName}, '%'))</if>
|
||||
</where>
|
||||
order by sort_no asc, line_id asc
|
||||
</select>
|
||||
|
||||
<insert id="insertGroup" parameterType="com.bms.price.domain.PayPostcodeGroup" useGeneratedKeys="true" keyProperty="groupId">
|
||||
insert into pay_postcode_group (
|
||||
source_file, file_md5, sheet_name, block_title, config_kind, coverage, channel_name, country_name, country_code,
|
||||
service_type, catalog_country, product_name, quote_sheet,
|
||||
fee_name, fee_text, line_count, create_by, create_time, remark
|
||||
) values (
|
||||
#{sourceFile}, #{fileMd5}, #{sheetName}, #{blockTitle}, #{configKind}, #{coverage}, #{channelName}, #{countryName}, #{countryCode},
|
||||
#{serviceType}, #{catalogCountry}, #{productName}, #{quoteSheet},
|
||||
#{feeName}, #{feeText}, #{lineCount}, #{createBy}, sysdate(), #{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertLines">
|
||||
insert into pay_postcode_line (
|
||||
group_id, country_name, country_code, region_name, region_name_cn, city_name, region_code,
|
||||
zone_name, postcode, postcode_raw, postcode_end, extra_text, sort_no
|
||||
) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.groupId}, #{item.countryName}, #{item.countryCode}, #{item.regionName}, #{item.regionNameCn},
|
||||
#{item.cityName}, #{item.regionCode}, #{item.zoneName}, #{item.postcode}, #{item.postcodeRaw},
|
||||
#{item.postcodeEnd}, #{item.extraText}, #{item.sortNo})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectGroupById" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select group_id as groupId, source_file as sourceFile, file_md5 as fileMd5, sheet_name as sheetName,
|
||||
block_title as blockTitle, config_kind as configKind, coverage, channel_name as channelName,
|
||||
country_name as countryName, country_code as countryCode,
|
||||
service_type as serviceType, catalog_country as catalogCountry, product_name as productName, quote_sheet as quoteSheet,
|
||||
fee_name as feeName, fee_text as feeText, line_count as lineCount, create_by as createBy, create_time as createTime, remark
|
||||
from pay_postcode_group
|
||||
where group_id = #{groupId}
|
||||
</select>
|
||||
|
||||
<update id="updateGroup" parameterType="com.bms.price.domain.PayPostcodeGroup">
|
||||
update pay_postcode_group
|
||||
set coverage = #{coverage},
|
||||
channel_name = #{channelName},
|
||||
country_name = #{countryName},
|
||||
country_code = #{countryCode},
|
||||
service_type = #{serviceType},
|
||||
catalog_country = #{catalogCountry},
|
||||
product_name = #{productName},
|
||||
quote_sheet = #{quoteSheet},
|
||||
config_kind = #{configKind},
|
||||
fee_name = #{feeName},
|
||||
fee_text = #{feeText},
|
||||
block_title = #{blockTitle},
|
||||
remark = #{remark}
|
||||
where group_id = #{groupId}
|
||||
</update>
|
||||
|
||||
<select id="selectGroupIds" resultType="long">
|
||||
select group_id from pay_postcode_group where file_md5 = #{fileMd5} and sheet_name = #{sheetName}
|
||||
</select>
|
||||
|
||||
<select id="selectGroupsByTokens" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select group_id as groupId, block_title as blockTitle, channel_name as channelName,
|
||||
product_name as productName, quote_sheet as quoteSheet, sheet_name as sheetName,
|
||||
config_kind as configKind, fee_name as feeName, country_name as countryName, country_code as countryCode
|
||||
from pay_postcode_group
|
||||
where
|
||||
<foreach collection="tokens" item="token" separator=" or ">
|
||||
lower(concat_ws(' ', ifnull(channel_name, ''), ifnull(block_title, ''), ifnull(product_name, ''),
|
||||
ifnull(quote_sheet, ''), ifnull(sheet_name, ''))) like concat('%', #{token}, '%')
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectRegionKeys" resultType="com.bms.price.domain.PayPostcodeLine">
|
||||
select group_id as groupId, region_name as regionName, zone_name as zoneName
|
||||
from pay_postcode_line
|
||||
where group_id in
|
||||
<foreach collection="groupIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
group by group_id, region_name, zone_name
|
||||
</select>
|
||||
|
||||
<select id="selectLinesByGroups" resultType="com.bms.price.domain.PayPostcodeLine">
|
||||
select line_id as lineId, group_id as groupId, region_name as regionName, zone_name as zoneName,
|
||||
postcode, postcode_end as postcodeEnd
|
||||
from pay_postcode_line
|
||||
where group_id in
|
||||
<foreach collection="groupIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</select>
|
||||
|
||||
<delete id="deleteLines">
|
||||
delete from pay_postcode_line where group_id in
|
||||
<foreach collection="groupIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteGroups">
|
||||
delete from pay_postcode_group where group_id in
|
||||
<foreach collection="groupIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,355 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.PayProductMapper">
|
||||
|
||||
<resultMap type="com.bms.price.domain.PayProduct" id="PayProductResult">
|
||||
<id property="productId" column="product_id"/>
|
||||
<result property="productName" column="product_name"/>
|
||||
<result property="productType" column="product_type"/>
|
||||
<result property="dictValue" column="dict_value"/>
|
||||
<result property="originId" column="origin_id"/>
|
||||
<result property="channelId" column="channel_id"/>
|
||||
<result property="versionNo" column="version_no"/>
|
||||
<result property="countryScope" column="country_scope"/>
|
||||
<result property="chargeType" column="charge_type"/>
|
||||
<result property="extraPerKg" column="extra_per_kg"/>
|
||||
<result property="serviceType" column="service_type"/>
|
||||
<result property="classification" column="classification"/>
|
||||
<result property="catalogRemark" column="catalog_remark"/>
|
||||
<result property="updateContent" column="update_content"/>
|
||||
<result property="weightLimit" column="weight_limit"/>
|
||||
<result property="sheetName" column="sheet_name"/>
|
||||
<result property="relatedSheet" column="related_sheet"/>
|
||||
<result property="sourceFile" column="source_file"/>
|
||||
<result property="fileMd5" column="file_md5"/>
|
||||
<result property="supplierName" column="supplier_name"/>
|
||||
<result property="effectiveDate" column="effective_date"/>
|
||||
<result property="currency" column="currency"/>
|
||||
<result property="serviceNote" column="service_note"/>
|
||||
<result property="parseStatus" column="parse_status"/>
|
||||
<result property="weightCount" column="weight_count"/>
|
||||
<result property="surchargeCount" column="surcharge_count"/>
|
||||
<result property="extraCount" column="extra_count"/>
|
||||
<result property="versionProductId" column="version_product_id"/>
|
||||
<result property="termId" column="term_id"/>
|
||||
<result property="termStatus" column="term_status"/>
|
||||
<result property="termStart" column="term_start"/>
|
||||
<result property="termEnd" column="term_end"/>
|
||||
<result property="createBy" column="created_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="updated_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="payProductWhere">
|
||||
<where>
|
||||
<if test="templateOnly != null and templateOnly">
|
||||
and (pay_product.channel_id is null or pay_product.channel_id = '')
|
||||
</if>
|
||||
<if test="currentOnly != null and currentOnly">
|
||||
and pay_product.origin_id is null
|
||||
</if>
|
||||
<if test="productName != null and productName != ''">
|
||||
and pay_product.product_name like concat('%', #{productName}, '%')
|
||||
</if>
|
||||
<if test="countryScope != null and countryScope != ''">
|
||||
and pay_product.country_scope like concat('%', #{countryScope}, '%')
|
||||
</if>
|
||||
<if test="sheetName != null and sheetName != ''">
|
||||
and pay_product.sheet_name like concat('%', #{sheetName}, '%')
|
||||
</if>
|
||||
<if test="sourceFile != null and sourceFile != ''">
|
||||
and pay_product.source_file like concat('%', #{sourceFile}, '%')
|
||||
</if>
|
||||
<if test="supplierName != null and supplierName != ''">
|
||||
and pay_product.supplier_name like concat('%', #{supplierName}, '%')
|
||||
</if>
|
||||
<if test="serviceType != null and serviceType != ''">
|
||||
and pay_product.service_type like concat('%', #{serviceType}, '%')
|
||||
</if>
|
||||
<if test="parseStatus != null and parseStatus != ''">
|
||||
and pay_product.parse_status = #{parseStatus}
|
||||
</if>
|
||||
<if test="effectiveBegin != null and effectiveBegin != ''">
|
||||
and ifnull(t.effective_start, pay_product.effective_date) >= #{effectiveBegin}
|
||||
</if>
|
||||
<if test="effectiveEnd != null and effectiveEnd != ''">
|
||||
and ifnull(t.effective_start, pay_product.effective_date) <= #{effectiveEnd}
|
||||
</if>
|
||||
<if test="surchargeName != null and surchargeName != ''">
|
||||
and exists (
|
||||
select 1 from pay_surcharge s
|
||||
where s.product_id = pay_product.product_id
|
||||
and (s.fee_name like concat('%', #{surchargeName}, '%')
|
||||
or s.charge_text like concat('%', #{surchargeName}, '%')
|
||||
or s.fee_desc like concat('%', #{surchargeName}, '%')
|
||||
or s.period_text like concat('%', #{surchargeName}, '%'))
|
||||
)
|
||||
</if>
|
||||
<if test="weightKeyword != null and weightKeyword != ''">
|
||||
and exists (
|
||||
select 1 from pay_weight_band b
|
||||
where b.product_id = pay_product.product_id
|
||||
and (b.weight_label like concat('%', #{weightKeyword}, '%')
|
||||
or b.charge_name like concat('%', #{weightKeyword}, '%')
|
||||
or b.zone_name like concat('%', #{weightKeyword}, '%')
|
||||
or b.country_name like concat('%', #{weightKeyword}, '%')
|
||||
or b.section_name like concat('%', #{weightKeyword}, '%')
|
||||
or b.volume_text like concat('%', #{weightKeyword}, '%'))
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="selectPayProductList" parameterType="com.bms.price.domain.PayProduct" resultMap="PayProductResult">
|
||||
select pay_product.product_id, pay_product.product_name,
|
||||
ifnull(cur.product_type, pay_product.product_type) as product_type, pay_product.dict_value, pay_product.origin_id,
|
||||
pay_product.channel_id, ifnull(cur.version_no, pay_product.version_no) as version_no,
|
||||
pay_product.country_scope, ifnull(cur.charge_type, pay_product.charge_type) as charge_type,
|
||||
ifnull(cur.extra_per_kg, pay_product.extra_per_kg) as extra_per_kg, pay_product.service_type,
|
||||
pay_product.classification, pay_product.catalog_remark, pay_product.update_content, pay_product.weight_limit,
|
||||
pay_product.sheet_name, pay_product.related_sheet, ifnull(cur.source_file, pay_product.source_file) as source_file,
|
||||
pay_product.file_md5,
|
||||
pay_product.supplier_name, pay_product.effective_date, ifnull(cur.currency, pay_product.currency) as currency,
|
||||
pay_product.service_note,
|
||||
pay_product.parse_status, ifnull(cur.weight_count, pay_product.weight_count) as weight_count,
|
||||
ifnull(cur.surcharge_count, pay_product.surcharge_count) as surcharge_count, pay_product.extra_count,
|
||||
pay_product.created_by, pay_product.create_time, pay_product.updated_by, pay_product.update_time, pay_product.remark,
|
||||
t.product_id as version_product_id,
|
||||
t.term_id, t.status as term_status, t.effective_start as term_start, t.effective_end as term_end
|
||||
from pay_product
|
||||
left join pay_product_term t on t.term_id = (
|
||||
select t2.term_id
|
||||
from pay_product_term t2
|
||||
inner join pay_product v on v.product_id = t2.product_id
|
||||
where (v.channel_id is null or v.channel_id = '')
|
||||
and (v.product_id = pay_product.product_id or v.origin_id = pay_product.product_id)
|
||||
order by case when t2.status = '0' then 0 else 1 end, ifnull(v.version_no, 1) desc, t2.term_id desc
|
||||
limit 1
|
||||
)
|
||||
left join pay_product cur on cur.product_id = t.product_id
|
||||
<include refid="payProductWhere"/>
|
||||
order by ifnull(t.effective_start, pay_product.effective_date) desc, pay_product.product_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectPayProductById" parameterType="long" resultMap="PayProductResult">
|
||||
select product_id, product_name, product_type, dict_value, origin_id, channel_id, version_no, country_scope, charge_type, extra_per_kg, service_type,
|
||||
classification, catalog_remark, update_content, weight_limit, sheet_name, related_sheet, source_file,
|
||||
file_md5, supplier_name, effective_date, currency, service_note, parse_status, weight_count,
|
||||
surcharge_count, extra_count, created_by, create_time, updated_by, update_time, remark
|
||||
from pay_product
|
||||
where product_id = #{productId}
|
||||
</select>
|
||||
|
||||
<select id="selectExistingId" resultType="long">
|
||||
select product_id from pay_product
|
||||
where file_md5 = #{fileMd5} and sheet_name = #{sheetName} and product_name = #{productName}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertPayProduct" parameterType="com.bms.price.domain.PayProduct" useGeneratedKeys="true" keyProperty="productId">
|
||||
insert into pay_product (
|
||||
product_name, product_type, dict_value, origin_id, channel_id, version_no, country_scope, charge_type, extra_per_kg, service_type, classification,
|
||||
catalog_remark, update_content, weight_limit, sheet_name, related_sheet, source_file, file_md5,
|
||||
supplier_name, effective_date, currency, service_note, parse_status, weight_count, surcharge_count,
|
||||
extra_count, created_by, create_time, remark
|
||||
) values (
|
||||
#{productName}, #{productType}, #{dictValue}, #{originId}, #{channelId}, ifnull(#{versionNo}, 1), #{countryScope}, #{chargeType}, #{extraPerKg},
|
||||
#{serviceType}, #{classification}, #{catalogRemark}, #{updateContent}, #{weightLimit}, #{sheetName},
|
||||
#{relatedSheet}, #{sourceFile}, #{fileMd5}, #{supplierName}, #{effectiveDate}, #{currency},
|
||||
#{serviceNote}, #{parseStatus}, #{weightCount}, #{surchargeCount}, #{extraCount}, #{createBy}, sysdate(),
|
||||
#{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updatePayProduct" parameterType="com.bms.price.domain.PayProduct">
|
||||
update pay_product
|
||||
set product_name = #{productName},
|
||||
product_type = #{productType},
|
||||
dict_value = #{dictValue},
|
||||
origin_id = #{originId},
|
||||
channel_id = #{channelId},
|
||||
version_no = ifnull(#{versionNo}, version_no),
|
||||
country_scope = #{countryScope},
|
||||
charge_type = #{chargeType},
|
||||
extra_per_kg = #{extraPerKg},
|
||||
service_type = #{serviceType},
|
||||
classification = #{classification},
|
||||
catalog_remark = #{catalogRemark},
|
||||
update_content = #{updateContent},
|
||||
weight_limit = #{weightLimit},
|
||||
sheet_name = #{sheetName},
|
||||
related_sheet = #{relatedSheet},
|
||||
source_file = #{sourceFile},
|
||||
file_md5 = #{fileMd5},
|
||||
supplier_name = #{supplierName},
|
||||
effective_date = #{effectiveDate},
|
||||
currency = #{currency},
|
||||
service_note = #{serviceNote},
|
||||
parse_status = #{parseStatus},
|
||||
weight_count = #{weightCount},
|
||||
surcharge_count = #{surchargeCount},
|
||||
extra_count = #{extraCount},
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate(),
|
||||
remark = #{remark}
|
||||
where product_id = #{productId}
|
||||
</update>
|
||||
|
||||
<select id="selectTemplateId" resultType="long">
|
||||
select product_id from pay_product
|
||||
where dict_value = #{dictValue}
|
||||
and (channel_id is null or channel_id = '')
|
||||
and origin_id is null
|
||||
order by product_id
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectTemplateOptions" resultMap="PayProductResult">
|
||||
select p.product_id, p.product_name, p.dict_value, p.sheet_name, p.supplier_name, p.effective_date,
|
||||
p.currency, ifnull(cur.version_no, p.version_no) as version_no
|
||||
from pay_product p
|
||||
left join pay_product_term t on t.term_id = (
|
||||
select t2.term_id
|
||||
from pay_product_term t2
|
||||
inner join pay_product v on v.product_id = t2.product_id
|
||||
where (v.channel_id is null or v.channel_id = '')
|
||||
and (v.product_id = p.product_id or v.origin_id = p.product_id)
|
||||
order by case when t2.status = '0' then 0 else 1 end, ifnull(v.version_no, 1) desc, t2.term_id desc
|
||||
limit 1
|
||||
)
|
||||
left join pay_product cur on cur.product_id = t.product_id
|
||||
where (p.channel_id is null or p.channel_id = '')
|
||||
and p.origin_id is null
|
||||
order by p.product_name
|
||||
</select>
|
||||
|
||||
<select id="selectMaxVersion" resultType="int">
|
||||
select ifnull(max(version_no), 1) from pay_product
|
||||
where product_id = #{originId} or origin_id = #{originId}
|
||||
</select>
|
||||
|
||||
<insert id="insertWeightBands">
|
||||
insert into pay_weight_band (
|
||||
product_id, version_no, section_name, country_name, country_code, zone_name, weight_label, weight_min, weight_max,
|
||||
volume_text, charge_name, price, price_unit, sort_no
|
||||
) values
|
||||
<foreach collection="list" item="row" separator=",">
|
||||
(#{row.productId}, ifnull(#{row.versionNo}, 1), #{row.sectionName}, #{row.countryName}, #{row.countryCode}, #{row.zoneName},
|
||||
#{row.weightLabel}, #{row.weightMin}, #{row.weightMax}, #{row.volumeText}, #{row.chargeName}, #{row.price},
|
||||
#{row.priceUnit}, #{row.sortNo})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertSurcharges">
|
||||
insert into pay_surcharge (
|
||||
product_id, version_no, section_name, fee_name, zone_name, charge_text, amount, currency, fee_desc, period_text,
|
||||
effective_start, effective_end, charge_timing, calc_rule, calc_param, sort_no
|
||||
) values
|
||||
<foreach collection="list" item="row" separator=",">
|
||||
(#{row.productId}, ifnull(#{row.versionNo}, 1), #{row.sectionName}, #{row.feeName}, #{row.zoneName}, #{row.chargeText}, #{row.amount},
|
||||
#{row.currency}, #{row.feeDesc}, #{row.periodText}, #{row.effectiveStart}, #{row.effectiveEnd},
|
||||
#{row.chargeTiming}, ifnull(#{row.calcRule}, 'MANUAL'), #{row.calcParam}, #{row.sortNo})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertExtraLines">
|
||||
insert into pay_extra_line (product_id, line_type, line_text, sort_no) values
|
||||
<foreach collection="list" item="row" separator=",">
|
||||
(#{row.productId}, #{row.lineType}, #{row.lineText}, #{row.sortNo})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectWeightBands" resultType="com.bms.price.domain.PayWeightBand">
|
||||
select band_id as bandId, product_id as productId, version_no as versionNo, section_name as sectionName, country_name as countryName,
|
||||
country_code as countryCode, zone_name as zoneName, weight_label as weightLabel, weight_min as weightMin,
|
||||
weight_max as weightMax, volume_text as volumeText, charge_name as chargeName, price, price_unit as priceUnit, sort_no as sortNo
|
||||
from pay_weight_band
|
||||
where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
order by product_id, sort_no, band_id
|
||||
</select>
|
||||
|
||||
<select id="selectSurcharges" resultType="com.bms.price.domain.PaySurcharge">
|
||||
select surcharge_id as surchargeId, product_id as productId, version_no as versionNo, section_name as sectionName, fee_name as feeName,
|
||||
zone_name as zoneName, charge_text as chargeText, amount, currency, fee_desc as feeDesc,
|
||||
period_text as periodText, effective_start as effectiveStart, effective_end as effectiveEnd,
|
||||
charge_timing as chargeTiming, calc_rule as calcRule, calc_param as calcParam, sort_no as sortNo
|
||||
from pay_surcharge
|
||||
where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
order by product_id, sort_no, surcharge_id
|
||||
</select>
|
||||
|
||||
<select id="selectExtraLines" resultType="com.bms.price.domain.PayExtraLine">
|
||||
select line_id as lineId, product_id as productId, line_type as lineType, line_text as lineText, sort_no as sortNo
|
||||
from pay_extra_line
|
||||
where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
order by product_id, sort_no, line_id
|
||||
</select>
|
||||
|
||||
<delete id="deleteWeightBands">
|
||||
delete from pay_weight_band where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSurcharges">
|
||||
delete from pay_surcharge where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteExtraLines">
|
||||
delete from pay_extra_line where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deletePayProducts">
|
||||
delete from pay_product where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectFamilyIds" resultType="long">
|
||||
select product_id from pay_product
|
||||
where product_id = #{rootId} or origin_id = #{rootId}
|
||||
</select>
|
||||
|
||||
<select id="selectEffectiveVersionId" resultType="long">
|
||||
select v.product_id
|
||||
from pay_product v
|
||||
inner join pay_product_term t on t.product_id = v.product_id
|
||||
where (v.channel_id is null or v.channel_id = '')
|
||||
and (v.product_id = #{stableId} or v.origin_id = #{stableId})
|
||||
and t.status = '0'
|
||||
and (t.effective_start is null or t.effective_start <= date(#{bizDate}))
|
||||
and (t.effective_end is null or t.effective_end >= date(#{bizDate}))
|
||||
order by ifnull(v.version_no, 1) desc, v.product_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectInactiveCovering" resultMap="PayProductResult">
|
||||
select v.product_id, v.product_name, t.version_no
|
||||
from pay_product v
|
||||
inner join pay_product_term t on t.product_id = v.product_id
|
||||
where (v.channel_id is null or v.channel_id = '')
|
||||
and (v.product_id = #{stableId} or v.origin_id = #{stableId})
|
||||
and ifnull(t.status, '1') <> '0'
|
||||
and (t.effective_start is null or t.effective_start <= date(#{bizDate}))
|
||||
and (t.effective_end is null or t.effective_end >= date(#{bizDate}))
|
||||
order by ifnull(t.version_no, 1) desc, v.product_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectLatestVersionId" resultType="long">
|
||||
select v.product_id
|
||||
from pay_product v
|
||||
where (v.channel_id is null or v.channel_id = '')
|
||||
and (v.product_id = #{stableId} or v.origin_id = #{stableId})
|
||||
order by ifnull(v.version_no, 1) desc, v.product_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.PayProductTermMapper">
|
||||
|
||||
<select id="selectByDict" resultType="com.bms.price.domain.PayProductTerm">
|
||||
select t.term_id as termId, t.dict_value as dictValue, t.product_id as productId, t.version_no as versionNo,
|
||||
t.effective_start as effectiveStart, t.effective_end as effectiveEnd, t.status,
|
||||
t.created_by as createBy, t.create_time as createTime, t.remark,
|
||||
p.product_name as productName, p.source_file as sourceFile, p.weight_count as weightCount,
|
||||
p.surcharge_count as surchargeCount, p.currency
|
||||
from pay_product_term t
|
||||
join pay_product p on p.product_id = t.product_id
|
||||
where t.dict_value = #{dictValue}
|
||||
and (p.channel_id is null or p.channel_id = '')
|
||||
order by t.version_no desc, t.term_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultType="com.bms.price.domain.PayProductTerm">
|
||||
select term_id as termId, dict_value as dictValue, product_id as productId, version_no as versionNo,
|
||||
effective_start as effectiveStart, effective_end as effectiveEnd, status
|
||||
from pay_product_term
|
||||
where term_id = #{termId}
|
||||
</select>
|
||||
|
||||
<select id="selectByProductId" resultType="com.bms.price.domain.PayProductTerm">
|
||||
select term_id as termId, dict_value as dictValue, product_id as productId, version_no as versionNo,
|
||||
effective_start as effectiveStart, effective_end as effectiveEnd, status
|
||||
from pay_product_term
|
||||
where product_id = #{productId}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertTerm" parameterType="com.bms.price.domain.PayProductTerm" useGeneratedKeys="true" keyProperty="termId">
|
||||
insert into pay_product_term (
|
||||
dict_value, product_id, version_no, effective_start, effective_end, status, created_by, create_time, remark
|
||||
) values (
|
||||
#{dictValue}, #{productId}, ifnull(#{versionNo}, 1), #{effectiveStart}, #{effectiveEnd},
|
||||
ifnull(#{status}, '0'), #{createBy}, sysdate(), #{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updatePeriod">
|
||||
update pay_product_term
|
||||
set effective_start = #{effectiveStart},
|
||||
effective_end = #{effectiveEnd},
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where term_id = #{termId}
|
||||
</update>
|
||||
|
||||
<update id="updateStatus">
|
||||
update pay_product_term
|
||||
set status = #{status},
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where term_id = #{termId}
|
||||
</update>
|
||||
|
||||
<update id="closeOpenTerms">
|
||||
update pay_product_term
|
||||
set status = '1',
|
||||
effective_end = case
|
||||
when effective_end is not null and effective_end < #{endDate} then effective_end
|
||||
when effective_start is not null and effective_start > #{endDate} then effective_start
|
||||
else #{endDate}
|
||||
end,
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where dict_value = #{dictValue}
|
||||
and status = '0'
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductIds">
|
||||
delete from pay_product_term where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="updateProductEffectiveDate">
|
||||
update pay_product
|
||||
set effective_date = #{effectiveDate},
|
||||
update_time = sysdate()
|
||||
where product_id = #{productId}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -942,6 +942,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where bill_id = #{billId}
|
||||
</update>
|
||||
|
||||
<update id="updatePayTotal">
|
||||
update prc_order_bill
|
||||
set pay_total = #{payTotal},
|
||||
update_time = sysdate()
|
||||
where bill_id = #{billId}
|
||||
</update>
|
||||
|
||||
<update id="updateOrderBillAmounts">
|
||||
update prc_order_bill
|
||||
set surcharge_amount = #{surchargeAmount},
|
||||
|
||||
@@ -44,6 +44,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="String">
|
||||
delete from prc_pay_bill_fee where bill_id = #{billId}
|
||||
delete from prc_pay_bill_fee
|
||||
where bill_id = #{billId}
|
||||
and (fee_source is null or fee_source = '' or fee_source = 'CALC')
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user