<?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.matrix.system.hive.dao.MoneyCardUseFlowDao">
|
<!-- 定义MoneyCardUseFlow 的复杂关联map -->
|
<resultMap type="com.matrix.system.hive.bean.MoneyCardUseFlow" id="MoneyCardUseFlowMap">
|
<id property="id" column="id" />
|
<result property="orderNo" column="order_no" />
|
<result property="payNo" column="pay_no" />
|
<result property="operationId" column="operation_id" />
|
<result property="content" column="content" />
|
<result property="createTime" column="create_time" />
|
<result property="vipId" column="vip_id" />
|
<result property="carUseId" column="car_use_id" />
|
<result property="operVipId" column="oper_vip_id" />
|
<result property="type" column="type" />
|
<result property="total" column="total" />
|
<result property="times" column="times" />
|
<result property="giftMoney" column="gift_money" />
|
<result property="balance" column="balance" />
|
|
<!-- 扩展属性 -->
|
<result property="operVipName" column="operVipName" />
|
<result property="vipName" column="vipName" />
|
<result property="staffName" column="staffName" />
|
<result property="cardName" column="cardName" />
|
</resultMap>
|
|
|
<!-- 定义MoneyCardUseFlow 的简单map ,本map不添加其他的关联属性 -->
|
<resultMap type="com.matrix.system.hive.bean.MoneyCardUseFlow" id="MoneyCardUseFlowSimpleMap">
|
<id property="id" column="id" />
|
<result property="orderNo" column="order_no" />
|
<result property="payNo" column="pay_no" />
|
<result property="operationId" column="operation_id" />
|
<result property="content" column="content" />
|
<result property="createTime" column="create_time" />
|
<result property="vipId" column="vip_id" />
|
<result property="carUseId" column="car_use_id" />
|
<result property="operVipId" column="oper_vip_id" />
|
<result property="type" column="type" />
|
<result property="total" column="total" />
|
<result property="times" column="times" />
|
<result property="giftMoney" column="gift_money" />
|
<result property="cardName" column="cardName" />
|
<result property="balance" column="balance" />
|
</resultMap>
|
|
<!-- 插入方法 -->
|
<insert id="insert" parameterType="com.matrix.system.hive.bean.MoneyCardUseFlow"
|
useGeneratedKeys="true" keyProperty="id">
|
INSERT INTO money_card_use_flow (
|
id,
|
order_no,
|
pay_no,
|
operation_id,
|
content,
|
create_time,
|
vip_id,
|
car_use_id,
|
oper_vip_id,
|
type,
|
total,
|
times,
|
gift_money,
|
balance
|
)
|
VALUES (
|
#{id},
|
#{orderNo},
|
#{payNo},
|
#{operationId},
|
#{content},
|
#{createTime},
|
#{vipId},
|
#{carUseId},
|
#{operVipId},
|
#{type},
|
#{total},
|
#{times},
|
#{giftMoney},
|
#{balance}
|
)
|
</insert>
|
|
|
<!-- 根据id更新 部分更新 -->
|
<update id="update" parameterType="Long">
|
UPDATE money_card_use_flow
|
<set>
|
<if test="orderNo != null and orderNo !='' ">
|
order_no = #{orderNo},
|
</if>
|
<if test="operationId != null and operationId !='' ">
|
operation_id = #{operationId},
|
</if>
|
<if test="content != null and content !='' ">
|
content = #{content},
|
</if>
|
<if test="createTime != null ">
|
create_time = #{createTime},
|
</if>
|
<if test="vipId != null and vipId !='' ">
|
vip_id = #{vipId},
|
</if>
|
<if test="carUseId != null and carUseId !='' ">
|
car_use_id = #{carUseId},
|
</if>
|
<if test="operVipId != null and operVipId !='' ">
|
oper_vip_id = #{operVipId},
|
</if>
|
<if test="type != null and type !='' ">
|
type = #{type},
|
</if>
|
<if test="total != null and total !='' ">
|
total = #{total},
|
</if>
|
<if test="times != null and times !='' ">
|
times = #{times},
|
</if>
|
<if test="giftMoney != null and giftMoney !='' ">
|
gift_money = #{giftMoney},
|
</if>
|
<if test="balance != null and balance !='' ">
|
balance = #{balance},
|
</if>
|
</set>
|
WHERE id=#{id}
|
</update>
|
|
|
<!-- 批量删除 -->
|
<delete id="deleteByIds" parameterType="java.util.List">
|
delete from money_card_use_flow where id in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<!-- 根据id删除 -->
|
<delete id="deleteById" parameterType="Long">
|
DELETE FROM
|
money_card_use_flow
|
where id=#{id}
|
</delete>
|
|
|
|
<!-- 分页查询 -->
|
<select id="selectInPage" resultMap="MoneyCardUseFlowMap">
|
select
|
id,
|
order_no,
|
pay_no,
|
operation_id,
|
content,
|
create_time,
|
vip_id,
|
car_use_id,
|
oper_vip_id,
|
type,
|
total,
|
times,
|
gift_money,
|
balance,
|
(SELECT su_name from sys_users a WHERE operation_id=a.su_id) staffName,
|
(SELECT VIP_NAME FROM sys_vip_info b WHERE vip_id=b.ID) vipName,
|
(SELECT card_NAME FROM money_card_use c WHERE car_use_id=c.ID) cardName
|
from money_card_use_flow
|
where 1=1
|
<if test="record!=null">
|
<if test="record.id != null and record.id !='' ">
|
and id = #{record.id}
|
</if>
|
<if test="record.orderNo != null and record.orderNo !='' ">
|
and order_no = #{record.orderNo}
|
</if>
|
<if test="record.payNo != null and record.payNo !='' ">
|
and pay_no = #{record.payNo}
|
</if>
|
<if test="record.operationId != null and record.operationId !='' ">
|
and operation_id = #{record.operationId}
|
</if>
|
<if test="record.content != null and record.content !='' ">
|
and content like CONCAT('%',#{record.content},'%')
|
</if>
|
<if test="record.createTime != null and record.createTime !='' ">
|
and create_time = #{record.createTime}
|
</if>
|
<if test="record.vipId != null and record.vipId !='' ">
|
and vip_id = #{record.vipId}
|
</if>
|
<if test="record.carUseId != null and record.carUseId !='' ">
|
and car_use_id = #{record.carUseId}
|
</if>
|
<if test="record.operVipId != null and record.operVipId!='' ">
|
and oper_vip_id = #{record.operVipId}
|
</if>
|
<if test="record.type != null and record.type !='' ">
|
and type = #{record.type}
|
</if>
|
</if>
|
ORDER BY create_time desc
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<!-- 查询总条数 -->
|
<select id="selectTotalRecord" parameterType="long" resultType="java.lang.Integer">
|
select count(*)
|
from money_card_use_flow
|
where 1=1
|
<if test="record!=null">
|
<if test="record.id != null and record.id !='' ">
|
and id = #{record.id}
|
</if>
|
<if test="record.orderNo != null and record.orderNo !='' ">
|
and order_no = #{record.orderNo}
|
</if>
|
<if test="record.payNo != null and record.payNo !='' ">
|
and pay_no = #{record.payNo}
|
</if>
|
<if test="record.operationId != null and record.operationId !='' ">
|
and operation_id = #{record.operationId}
|
</if>
|
<if test="record.content != null and record.content !='' ">
|
and content like CONCAT('%',#{record.content},'%')
|
</if>
|
<if test="record.createTime != null and record.createTime !='' ">
|
and create_time = #{record.createTime}
|
</if>
|
<if test="record.vipId != null and record.vipId !='' ">
|
and vip_id = #{record.vipId}
|
</if>
|
<if test="record.carUseId != null and record.carUseId !='' ">
|
and car_use_id = #{record.carUseId}
|
</if>
|
|
<if test="record.operVipId != null and record.operVipId!='' ">
|
and oper_vip_id = #{record.operVipId}
|
</if>
|
<if test="record.type != null and record.type !='' ">
|
and type = #{record.type}
|
</if>
|
</if>
|
</select>
|
|
<!-- 根据id查询 -->
|
<select id="selectById" resultMap="MoneyCardUseFlowMap">
|
select
|
id,
|
order_no,
|
pay_no,
|
operation_id,
|
content,
|
create_time,
|
vip_id,
|
car_use_id,
|
oper_vip_id,
|
type,
|
balance,
|
total,
|
times,
|
gift_money,
|
(SELECT STAFF_NAME from sys_shopstaff_info a WHERE operation_id=a.id) staffName,
|
(SELECT VIP_NAME FROM sys_vip_info a WHERE vip_id=a.ID) vipName,
|
(SELECT VIP_NAME FROM sys_vip_info a WHERE oper_vip_id=a.ID) operVipName
|
from money_card_use_flow
|
where id=#{id}
|
</select>
|
|
|
<!-- 根据对象查询 -->
|
<select id="selectByModel" resultMap="MoneyCardUseFlowMap">
|
select
|
id,
|
order_no,
|
pay_no,
|
operation_id,
|
content,
|
create_time,
|
vip_id,
|
car_use_id,
|
balance,
|
oper_vip_id,
|
type,
|
total,
|
times,
|
gift_money,
|
(SELECT STAFF_NAME from sys_shopstaff_info a WHERE operation_id=a.id) staffName,
|
(SELECT VIP_NAME FROM sys_vip_info a WHERE vip_id=a.ID) vipName,
|
(SELECT VIP_NAME FROM sys_vip_info a WHERE oper_vip_id=a.ID) operVipName
|
from money_card_use_flow
|
where 1=1
|
<if test="record!=null">
|
<if test="record.id != null and record.id !='' ">
|
and id = #{record.id}
|
</if>
|
<if test="record.orderNo != null and record.orderNo !='' ">
|
and order_no = #{record.orderNo}
|
</if>
|
<if test="record.payNo != null and record.payNo !='' ">
|
and pay_no = #{record.payNo}
|
</if>
|
<if test="record.operationId != null and record.operationId !='' ">
|
and operation_id = #{record.operationId}
|
</if>
|
<if test="record.content != null and record.content !='' ">
|
and content like CONCAT('%',#{record.content},'%')
|
</if>
|
<if test="record.createTime != null and record.createTime !='' ">
|
and create_time = #{record.createTime}
|
</if>
|
<if test="record.vipId != null and record.vipId !='' ">
|
and vip_id = #{record.vipId}
|
</if>
|
<if test="record.carUseId != null and record.carUseId !='' ">
|
and car_use_id = #{record.carUseId}
|
</if>
|
<if test="record.operVipId != null and record.operVipId!='' ">
|
and oper_vip_id = #{record.operVipId}
|
</if>
|
<if test="record.type != null and record.type !='' ">
|
and type = #{record.type}
|
</if>
|
</if>
|
</select>
|
|
<select id="selectForWxInPage" resultMap="MoneyCardUseFlowMap">
|
select
|
id,
|
order_no,
|
pay_no,
|
content,
|
create_time,
|
type,
|
total,
|
times,
|
gift_money,
|
balance,
|
(SELECT su_name from sys_users a WHERE operation_id=a.su_id) staffName
|
from money_card_use_flow
|
<where>
|
and car_use_id=#{record.carUseId}
|
<if test="record.queryTime!=null and record.queryTime!=''">
|
and DATE_FORMAT(create_time,'%Y-%m')=#{record.queryTime}
|
</if>
|
<if test="record.revenueType==1">
|
and total>0
|
</if>
|
<if test="record.revenueType==2">
|
<![CDATA[ and total<0 ]]>
|
</if>
|
</where>
|
order by create_time desc
|
</select>
|
|
<update id="updateVipCardId">
|
update money_card_use_flow
|
set car_use_id=#{cardId}
|
where vip_id=#{vipId} and type='会员充值'
|
</update>
|
|
<select id="selectCardUseAmount" resultType="java.lang.Double">
|
select IFNULL(ABS(sum(IFNULL(total, 0))), 0)
|
from money_card_use_flow
|
where car_use_id=#{cardId} and type='消费扣款'
|
</select>
|
</mapper>
|
|
|