sadjv3_java/src/main/resources/mapper/pay/CashDao.xml

212 lines
7.9 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.sqx.modules.pay.dao.CashOutDao">
<select id="selectCashOutLimit3" resultType="com.sqx.modules.pay.entity.CashOut">
select * from cash_out where state=1 order by out_at desc limit 3
</select>
<select id="selectCashOutSum" resultType="Double">
select sum(money) from cash_out where state in (0,1) and user_id=#{userId} and date_format(create_at,'%Y-%m-%d') between #{startTime} and #{endTime}
</select>
<select id="sumMoney" resultType="Double">
select ifnull(sum(money),0.00) from cash_out where
<if test="flag!=null and flag==1">
date_format(create_at,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
</if>
<if test="flag!=null and flag==2">
date_format(create_at,'%Y-%m')=date_format(#{time},'%Y-%m')
</if>
<if test="flag!=null and flag==3">
date_format(create_at,'%Y')=date_format(#{time},'%Y')
</if>
</select>
<select id="sumMoneyMonthByUserId" resultType="Double">
select ifnull(sum(money),0.00) from cash_out where user_id=#{userId} and `state` in (0,1)
and date_format(create_at,'%Y-%m')=date_format(#{time},'%Y-%m')
</select>
<select id="sumMoneyByUserId" resultType="BigDecimal">
select ifnull(sum(money),0.00) from cash_out where user_id=#{userId} and state in (0,1)
<if test="flag!=null and flag==1">
and date_format(create_at,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
</if>
<if test="flag!=null and flag==2">
and date_format(create_at,'%Y-%m')=date_format(#{time},'%Y-%m')
</if>
<if test="flag!=null and flag==3">
and date_format(create_at,'%Y')=date_format(#{time},'%Y')
</if>
</select>
<select id="countMoney" resultType="Integer">
select count(*) from cash_out where
<if test="flag!=null and flag==1">
date_format(create_at,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
</if>
<if test="flag!=null and flag==2">
date_format(create_at,'%Y-%m')=date_format(#{time},'%Y-%m')
</if>
<if test="flag!=null and flag==3">
date_format(create_at,'%Y')=date_format(#{time},'%Y')
</if>
</select>
<select id="stayCount" resultType="Integer">
select count(*) from cash_out where
<if test="flag!=null and flag==1">
date_format(create_at,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
</if>
<if test="flag!=null and flag==2">
date_format(create_at,'%Y-%m')=date_format(#{time},'%Y-%m')
</if>
<if test="flag!=null and flag==3">
date_format(create_at,'%Y')=date_format(#{time},'%Y')
</if>
and state=0
</select>
<select id="selectCashCountByClassify" resultType="Integer">
select count(*) from cash_out where
<if test="flag!=null and flag==1">
date_format(create_at,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
</if>
<if test="flag!=null and flag==2">
date_format(create_at,'%Y-%m')=date_format(#{time},'%Y-%m')
</if>
<if test="flag!=null and flag==3">
date_format(create_at,'%Y')=date_format(#{time},'%Y')
</if>
<if test="classify!=null">
and classify=#{classify}
</if>
<if test="state!=null">
and `state`=#{state}
</if>
</select>
<select id="selectCashMoneyByClassify" resultType="Double">
select ifnull(sum(money),0.00) from cash_out where
<if test="flag!=null and flag==1">
date_format(create_at,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
</if>
<if test="flag!=null and flag==2">
date_format(create_at,'%Y-%m')=date_format(#{time},'%Y-%m')
</if>
<if test="flag!=null and flag==3">
date_format(create_at,'%Y')=date_format(#{time},'%Y')
</if>
<if test="classify!=null">
and classify=#{classify}
</if>
<if test="state!=null">
and `state`=#{state}
</if>
</select>
<select id="stayMoney" resultType="Double">
select ifnull(sum(money),0.00) from cash_out where
<if test="flag!=null and flag==1">
date_format(create_at,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
</if>
<if test="flag!=null and flag==2">
date_format(create_at,'%Y-%m')=date_format(#{time},'%Y-%m')
</if>
<if test="flag!=null and flag==3">
date_format(create_at,'%Y')=date_format(#{time},'%Y')
</if>
and state=0
</select>
<select id="selectMayMoney" resultType="Double">
select money from user_money where user_id=#{userId}
</select>
<update id="updateMayMoney">
update user_money set
<if test="type==1">
money=money+#{money}
</if>
<if test="type==2">
money=money-#{money}
</if>
where user_id=#{userId}
</update>
<select id="selectCashOutPage" resultType="com.sqx.modules.pay.entity.CashOut">
select c.*,u.phone,a.artificer_name as artificerName,u.user_name as userName from cash_out c
left join tb_user u on u.user_id=c.user_id
left join artificer a on a.user_id=u.user_id
where 1=1
<if test="userName!=null and userName!=''">
and (u.user_name like concat('%',#{userName},'%') or a.artificer_name like concat('%',#{userName},'%') )
</if>
<if test="zhifubaoName!=null and zhifubaoName!=''">
and c.zhifubao_name like concat('%',#{zhifubaoName},'%')
</if>
<if test="zhifubao!=null and zhifubao!=''">
and c.zhifubao=#{zhifubao}
</if>
<if test="userId!=null">
and c.user_id=#{userId}
</if>
<if test="userType!=null and userType!=0">
and c.user_type=#{userType}
</if>
<if test="startTime!=null and startTime!=''">
and date_format(c.create_at,'%Y-%m-%d')>=date_format(#{startTime},'%Y-%m-%d')
</if>
<if test="endTime!=null and endTime!=''">
and date_format(c.create_at,'%Y-%m-%d')&lt;=date_format(#{endTime},'%Y-%m-%d')
</if>
<if test="state!=null">
and c.state=#{state}
</if>
<if test="phone!=null and phone!=''">
and u.phone=#{phone}
</if>
order by c.create_at desc
</select>
<select id="selectCashOutList" resultType="com.sqx.modules.pay.entity.CashOut">
select c.*,u.phone from cash_out c
left join tb_user u on u.user_id=c.user_id
where 1=1
<if test="userName!=null and userName!=''">
and (u.user_name like concat('%',#{userName},'%') or a.artificer_name like concat('%',#{userName},'%') )
</if>
<if test="zhifubaoName!=null and zhifubaoName!=''">
and c.zhifubao_name like concat('%',#{zhifubaoName},'%')
</if>
<if test="zhifubao!=null and zhifubao!=''">
and c.zhifubao=#{zhifubao}
</if>
<if test="userId!=null">
and c.user_id=#{userId}
</if>
<if test="userType!=null and userType!=0">
and c.user_type=#{userType}
</if>
<if test="startTime!=null and startTime!=''">
and date_format(c.create_at,'%Y-%m-%d')>=date_format(#{startTime},'%Y-%m-%d')
</if>
<if test="endTime!=null and endTime!=''">
and date_format(c.create_at,'%Y-%m-%d')&lt;=date_format(#{endTime},'%Y-%m-%d')
</if>
<if test="state!=null">
and c.state=#{state}
</if>
<if test="phone!=null and phone!=''">
and u.phone=#{phone}
</if>
order by c.create_at desc
</select>
</mapper>