247 lines
10 KiB
XML
247 lines
10 KiB
XML
<?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.intc.invest.mapper.PosMachineMapper">
|
|
|
|
<resultMap type="PosMachineVo" id="PosMachineResult">
|
|
<result property="id" column="id" />
|
|
<result property="name" column="name" />
|
|
<result property="type" column="type" />
|
|
<result property="manufacture" column="manufacture" />
|
|
<result property="payCompany" column="pay_company" />
|
|
<result property="merchantName" column="merchant_name" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="delFlag" column="del_flag" />
|
|
<result property="remark" column="remark" />
|
|
<result property="code" column="code" />
|
|
<result property="rate" column="rate" />
|
|
<result property="debitCard" column="debit_card" />
|
|
<result property="merchantType" column="merchant_type" />
|
|
<result property="merchantCode" column="merchant_code" />
|
|
<result property="activationDate" column="activation_date" />
|
|
<result property="ratePlus" column="rate_plus" />
|
|
<result property="bankName" column="bank_name" />
|
|
<result property="bankCode" column="bank_code" />
|
|
<result property="status" column="status" />
|
|
<result property="roundingMode" column="rounding_mode" />
|
|
</resultMap>
|
|
|
|
<sql id="selectPosMachineVo">
|
|
select
|
|
a.id,
|
|
a.name,
|
|
a.type,
|
|
a.manufacture,
|
|
a.pay_company,
|
|
a.merchant_name,
|
|
a.create_by,
|
|
a.create_time,
|
|
a.update_by,
|
|
a.update_time,
|
|
a.del_flag,
|
|
a.remark,
|
|
a.code,
|
|
a.rate,
|
|
a.rate_plus,
|
|
a.debit_card,
|
|
a.merchant_type,
|
|
a.merchant_code,
|
|
a.activation_date,
|
|
a.status,
|
|
a.rounding_mode,
|
|
bc."name" as bank_name,
|
|
bc.code as bank_code
|
|
from
|
|
pos_machine a
|
|
left join bank_card_lend bc on bc.id =a.debit_card
|
|
</sql>
|
|
|
|
<select id="selectPosMachineList" parameterType="PosMachineDto" resultMap="PosMachineResult">
|
|
<include refid="selectPosMachineVo"/>
|
|
<where>
|
|
a.del_flag='0'
|
|
<if test="name != null and name != ''"> and a.name like '%'|| #{name}||'%'</if>
|
|
<if test="type != null and type != ''"> and a.type = #{type}</if>
|
|
<if test="status != null and status != ''"> and a.status = #{status}</if>
|
|
<if test="merchantName != null and merchantName != ''"> and a.merchant_name like '%'|| #{merchantName}||'%'</if>
|
|
</where>
|
|
<!-- 数据范围过滤 -->
|
|
${params.dataScope}
|
|
order by a.create_time desc
|
|
</select>
|
|
|
|
<select id="selectPosMachineById" parameterType="Long" resultMap="PosMachineResult">
|
|
<include refid="selectPosMachineVo"/>
|
|
where a.id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertPosMachine" parameterType="PosMachine">
|
|
insert into pos_machine
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">id,</if>
|
|
<if test="name != null">name,</if>
|
|
<if test="type != null">type,</if>
|
|
<if test="manufacture != null">manufacture,</if>
|
|
<if test="payCompany != null">pay_company,</if>
|
|
<if test="merchantName != null">merchant_name,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="delFlag != null">del_flag,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="code != null">code,</if>
|
|
<if test="rate != null">rate,</if>
|
|
<if test="ratePlus != null">rate_plus,</if>
|
|
<if test="debitCard != null">debit_card,</if>
|
|
<if test="merchantType != null">merchant_type,</if>
|
|
<if test="merchantCode != null">merchant_code,</if>
|
|
<if test="activationDate != null">activation_date,</if>
|
|
<if test="status != null">status,</if>
|
|
<if test="roundingMode != null">rounding_mode,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">#{id},</if>
|
|
<if test="name != null">#{name},</if>
|
|
<if test="type != null">#{type},</if>
|
|
<if test="manufacture != null">#{manufacture},</if>
|
|
<if test="payCompany != null">#{payCompany},</if>
|
|
<if test="merchantName != null">#{merchantName},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="delFlag != null">#{delFlag},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="code != null">#{code},</if>
|
|
<if test="rate != null">#{rate},</if>
|
|
<if test="ratePlus != null">#{ratePlus},</if>
|
|
<if test="debitCard != null">#{debitCard},</if>
|
|
<if test="merchantType != null">#{merchantType},</if>
|
|
<if test="merchantCode != null">#{merchantCode},</if>
|
|
<if test="activationDate != null">#{activationDate},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="roundingMode != null">#{roundingMode},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updatePosMachine" parameterType="PosMachine">
|
|
update pos_machine
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="name != null">name = #{name},</if>
|
|
<if test="type != null">type = #{type},</if>
|
|
<if test="manufacture != null">manufacture = #{manufacture},</if>
|
|
<if test="payCompany != null">pay_company = #{payCompany},</if>
|
|
<if test="merchantName != null">merchant_name = #{merchantName},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<if test="code != null">code = #{code},</if>
|
|
<if test="rate != null">rate = #{rate},</if>
|
|
<if test="ratePlus != null">rate_plus = #{ratePlus},</if>
|
|
<if test="debitCard != null">debit_card = #{debitCard},</if>
|
|
<if test="merchantType != null">merchant_type = #{merchantType},</if>
|
|
<if test="merchantCode != null">merchant_code = #{merchantCode},</if>
|
|
<if test="activationDate != null">activation_date = #{activationDate},</if>
|
|
<if test="status != null">status = #{status},</if>
|
|
<if test="roundingMode != null">rounding_mode = #{roundingMode},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deletePosMachineById" parameterType="Long">
|
|
delete from pos_machine where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deletePosMachineByIds" parameterType="String">
|
|
delete from pos_machine where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
<update id="removePosMachineById" parameterType="Long">
|
|
update pos_machine set del_flag='1' where id = #{id}
|
|
</update>
|
|
|
|
<update id="removePosMachineByIds" parameterType="String">
|
|
update pos_machine set del_flag='1' where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</update>
|
|
|
|
<select id="selectCreditPosList" parameterType="AccountsDto" resultType="AccountsVo">
|
|
select
|
|
a."name",
|
|
a.code,
|
|
a.available_limit as availableLimit,
|
|
bcl.bill_date || '日' as billDateName,
|
|
(
|
|
select
|
|
STRING_AGG(to_char(atr.create_time,
|
|
'yyyy-MM-dd')|| '-' || pm.name || '(' || pm.merchant_name || ')'|| '-' ||bcl.name ::text,
|
|
'、'
|
|
order by
|
|
atr.create_time) as posNames
|
|
from
|
|
accounts_transfer_record atr
|
|
left join pos_machine pm on
|
|
pm.id = atr.pos_id
|
|
left join bank_card_lend bcl on
|
|
bcl.id = pm.debit_card
|
|
where
|
|
atr.out_account_id = a.id
|
|
and atr.create_time >= CURRENT_DATE - interval '1 months'
|
|
and atr.del_flag = '0'
|
|
|
|
) as remark,
|
|
(
|
|
select
|
|
STRING_AGG(pm.name || '(' || pm.merchant_name || ')'|| '-' ||bcl.name ::text,
|
|
'、'
|
|
)
|
|
from
|
|
pos_machine pm
|
|
left join bank_card_lend bcl on
|
|
bcl.id = pm.debit_card
|
|
where
|
|
pm.status = '1'
|
|
and bcl.name not like '%' || a.name || '%'
|
|
and pm.del_flag = '0'
|
|
and pm.id not in
|
|
(
|
|
select
|
|
atr.pos_id
|
|
from
|
|
accounts_transfer_record atr
|
|
left join pos_machine pm on
|
|
pm.id = atr.pos_id
|
|
where
|
|
atr.out_account_id = a.id
|
|
and atr.create_time >= CURRENT_DATE - interval '1 months'
|
|
and atr.del_flag = '0'
|
|
) ) as advicePosNames
|
|
from
|
|
accounts a
|
|
left join bank_card_lend bcl on
|
|
bcl.id = a.id
|
|
where
|
|
a."type" = '2'
|
|
and a.status = '1'
|
|
and a.del_flag = '0'
|
|
<if test="name != null and name != ''"> and a.name like '%'|| #{name}||'%'</if>
|
|
<if test="code != null and code != ''"> and a.code like '%'|| #{code}||'%'</if>
|
|
<!-- 数据范围过滤 -->
|
|
${params.dataScope}
|
|
order by
|
|
bcl.bill_date
|
|
</select>
|
|
</mapper>
|