<?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.nuvole.four.mapper.ActivityShopRecordMapper" >
|
<select id="selectList" parameterType="com.nuvole.four.domain.query.ActivityShopRecordQuery" resultType="com.nuvole.four.domain.ActivityShopRecord">
|
select <include refid="Base_Column_List"></include>
|
from activity_shop_record
|
<where>
|
deleted = 0
|
<if test="activityId!=null">
|
and activity_id =#{activityId}
|
</if>
|
<if test="merchantShopId!=null">
|
and merchant_shop_id =#{merchantShopId}
|
</if>
|
<if test="channelId!=null">
|
and channel_id =#{channelId}
|
</if>
|
<if test="channelName!=null and channelName!=''">
|
and channel_name like concat('%',#{channelName},'%')
|
</if>
|
<if test="totalFee!=null">
|
and total_fee =#{totalFee}
|
</if>
|
<if test="thirdShopNo!=null and thirdShopNo!=''">
|
and third_shop_no like concat('%',#{thirdShopNo},'%')
|
</if>
|
<if test="useFee!=null">
|
and use_fee =#{useFee}
|
</if>
|
<if test="surplusFee!=null">
|
and surplus_fee =#{surplusFee}
|
</if>
|
<if test="status!=null">
|
and status =#{status}
|
</if>
|
<if test="deleted!=null">
|
and deleted =#{deleted}
|
</if>
|
<if test="createBy!=null">
|
and create_by =#{createBy}
|
</if>
|
<if test="createTime!=null">
|
and create_time =#{createTime}
|
</if>
|
<if test="updateBy!=null">
|
and update_by =#{updateBy}
|
</if>
|
<if test="updateTime!=null">
|
and update_time =#{updateTime}
|
</if>
|
</where>
|
</select>
|
|
<select id="getActRateByShopId" resultType="map">
|
SELECT
|
feeAct.online_mer_wx_rate onlineMerWxRate,
|
feeAct.online_mer_zfb_rate onlineMerZfbRate,
|
feeAct.online_mer_unionpay_rate onlineMerUnionpayRate ,
|
feeAct.offline_mer_wx_rate offlineMerWxRate,
|
feeAct.offline_mer_zfb_rate offlineMerZfbRate,
|
feeAct.offline_mer_unionpay_rate offlineMerUnionpayRate,
|
shopRec.surplus_fee surplusFee,
|
shopRec.activity_id activityId,
|
shopRec.merchant_shop_id merchantShopId,
|
shopRec.channel_id channelId
|
FROM
|
activity_shop_record shopRec
|
LEFT JOIN activity_fee feeAct ON feeAct.id = shopRec.activity_id
|
<where>
|
NOW() BETWEEN feeAct.begin_time
|
AND feeAct.end_time
|
AND feeAct.`status` = 1
|
AND feeAct.deleted = 0
|
AND shopRec.deleted = 0
|
AND shopRec.`status` = 1
|
<if test="shopId != null">
|
AND shopRec.merchant_shop_id = #{shopId}
|
</if>
|
<if test="channelId != null">
|
AND shopRec.channel_id = #{channelId}
|
</if>
|
</where>
|
</select>
|
<select id="getAlreadyMerchantList" resultType="com.nuvole.four.domain.dto.ActivityShopRecordDto">
|
select * from activity_shop_record
|
<where>
|
deleted = 0 and activity_id = #{activityId}
|
<if test="merchantId != null">
|
and merchant_shop_id =#{merchantId}
|
</if>
|
<if test="channelId != null">
|
and channel_id = #{channelId}
|
</if>
|
</where>
|
</select>
|
<select id="selectByCondition" resultType="com.nuvole.four.domain.ActivityShopRecord">
|
select * from activity_shop_record
|
<where>
|
and deleted = 0 and activity_id = #{activityId}
|
<if test="ids != null">
|
and merchant_shop_id in
|
<foreach collection="ids" item="item" index="index"
|
open="(" close=")" separator=",">
|
#{item}
|
</foreach>
|
</if>
|
</where>
|
</select>
|
|
<update id="updShopSurplusFee">
|
UPDATE activity_shop_record
|
SET use_fee = IFNULL(use_fee,0) + #{useFee},
|
surplus_fee = IFNULL(surplus_fee,total_fee) - #{useFee}
|
WHERE
|
activity_id = #{activityId}
|
AND merchant_shop_id = #{merchantShopId}
|
AND channel_id =#{channelId}
|
</update>
|
|
<insert id="batchInsert" parameterType="list">
|
insert into activity_shop_record
|
(id,
|
activity_id,
|
merchant_shop_id,
|
channel_id,
|
channel_name,
|
total_fee,
|
third_shop_no,
|
use_fee,
|
surplus_fee,
|
status,
|
deleted,
|
create_by,
|
create_time)
|
values
|
<foreach collection="list" item="i" separator=",">
|
(
|
#{i.id},
|
#{i.activityId},
|
#{i.merchantShopId},
|
#{i.channelId},
|
#{i.channelName},
|
#{i.totalFee},
|
#{i.thirdShopNo},
|
#{i.useFee},
|
#{i.surplusFee},
|
#{i.status},
|
#{i.deleted},
|
#{i.createBy},
|
#{i.createTime}
|
)
|
</foreach>
|
ON duplicate KEY UPDATE
|
update_by = values(update_by),
|
update_time = values(update_time)
|
</insert>
|
|
<insert id="batchUpdate" parameterType="list">
|
insert into activity_shop_record
|
(id,
|
total_fee,
|
use_fee,
|
surplus_fee,
|
update_by,
|
update_time)
|
values
|
<foreach collection="list" item="i" separator=",">
|
(
|
#{i.id},
|
#{i.totalFee},
|
#{i.useFee},
|
#{i.surplusFee},
|
#{i.updateBy},
|
#{i.updateTime}
|
)
|
</foreach>
|
ON duplicate KEY UPDATE
|
total_fee = values(total_fee),
|
use_fee = values(use_fee),
|
surplus_fee = values(surplus_fee),
|
update_by = values(update_by),
|
update_time = values(update_time)
|
</insert>
|
</mapper>
|