<?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.nova.sankuai.infra.mapper.DeductionRecordMapper">
|
|
<select id="pageModel" resultType="com.nova.sankuai.domain.vo.DeductionRecordVo">
|
select
|
dr.id as id,
|
su.user_phone as phone,
|
dr.mechanism_id as mechanismId,
|
dr.deduction_amount as deductionAmount,
|
dr.creation_date as creationDate,
|
su.company_name as mechanismName,
|
dr.status as status,
|
dr.memo as memo
|
from deduction_record dr
|
inner join sys_user su on dr.mechanism_id = su.id
|
<where>
|
su.delete_flag = 0
|
<if test="pageDto.mechanismId != null">
|
and dr.mechanism_id = #{pageDto.mechanismId}
|
</if>
|
<if test="pageDto.mechanismName != null and pageDto.mechanismName !=''">
|
and su.company_name like concat('%',#{pageDto.mechanismName},'%')
|
</if>
|
<if test="pageDto.phone != null and pageDto.phone !=''">
|
and su.user_phone like concat('%',#{pageDto.phone},'%')
|
</if>
|
<if test="pageDto.startDate != null">
|
and dr.creation_date >= #{pageDto.startDate}
|
</if>
|
<if test="pageDto.endDate != null">
|
and dr.creation_date <= #{pageDto.endDate}
|
</if>
|
<if test="pageDto.status != null">
|
and dr.status = #{pageDto.status}
|
</if>
|
</where>
|
order by dr.creation_date desc
|
</select>
|
|
|
<select id="welcomePageList" resultType="com.nova.sankuai.domain.vo.WelcomePageHistory">
|
select date,sum(expendAmount) as expendAmount,sum(customerCount) as customerCount
|
from (
|
select date_format(creation_date,'%Y/%m/%d') as date ,deduction_amount as expendAmount, 0 as customerCount
|
from deduction_record
|
<where>
|
mechanism_id = #{id}
|
<if test="pageDto.startDate != null">
|
and creation_date >= #{pageDto.startDate}
|
</if>
|
<if test="pageDto.endDate != null">
|
and creation_date <= #{pageDto.endDate}
|
</if>
|
</where>
|
union all
|
select date_format(apply_date,'%Y/%m/%d') as date, 0 as expendAmount, 1 as customerCount
|
from customer
|
<where>
|
mechanism_id = #{id}
|
<if test="pageDto.startDate != null">
|
and apply_date >= #{pageDto.startDate}
|
</if>
|
<if test="pageDto.endDate != null">
|
and apply_date <= #{pageDto.endDate}
|
</if>
|
</where>
|
) t group by date
|
</select>
|
|
<select id="getAllExpendAmount" resultType="java.lang.Double">
|
select ifnull( sum( deduction_amount ), 0 )
|
from deduction_record where mechanism_id = #{id} and status = 0
|
</select>
|
</mapper>
|