| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- <?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.ydtech.modules.admin.dao.SysUserAccountHistoryMapper">
- <resultMap id="BaseResultMap" type="com.ydtech.modules.admin.model.po.SysUserAccountHistory">
- <id property="id" column="id" jdbcType="BIGINT"/>
- <result property="amount" column="amount" jdbcType="DECIMAL"/>
- <result property="surplusAmount" column="surplus_amount" jdbcType="DECIMAL"/>
- <result property="documentary" column="documentary" jdbcType="TINYINT"/>
- <result property="property" column="property" jdbcType="TINYINT"/>
- <result property="suborder" column="suborder" jdbcType="VARCHAR"/>
- <result property="fromBankCard" column="from_bank_card" jdbcType="VARCHAR"/>
- <result property="toBankCard" column="to_bank_card" jdbcType="VARCHAR"/>
- <result property="userId" column="user_id" jdbcType="VARCHAR"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="businessSegmentsType" column="business_eegments_type" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="Base_Column_List">
- id,amount,surplus_amount,
- documentary,property,suborder,
- from_bank_card,to_bank_card,user_id,
- create_time,business_eegments_type
- </sql>
- <select id="revenueReportYear" resultType="com.ydtech.modules.admin.model.dto.RevenueReportDto">
- SELECT
- a.reportDate AS reportDate,
- MAX( CASE WHEN a.property = 1 THEN a.amount ELSE 0 END ) AS haldingAmount,
- MAX( CASE WHEN a.property = 2 THEN a.amount ELSE 0 END ) AS documentaryAmount,
- MAX( CASE WHEN a.property = 3 THEN a.amount ELSE 0 END ) AS promotionAmount
- FROM
- (
- SELECT
- CONCAT(YEAR(create_time),'-',LPAD(MONTH(create_time), 2, '0')) reportDate,
- property as property,
- sum(amount) as amount
- FROM
- sys_user_account_history
- WHERE
- documentary=2
- and create_time >= #{beginTime} and create_time <= #{endTime}
- and user_id=#{userId}
- GROUP BY
- CONCAT(YEAR(create_time),'-',LPAD(MONTH(create_time), 2, '0')),
- property
- ) a
- GROUP BY
- a.reportDate
- </select>
- <select id="revenueReportMonth" resultType="com.ydtech.modules.admin.model.dto.RevenueReportDto">
- SELECT
- a.reportDate AS reportDate,
- MAX( CASE WHEN a.property = 1 THEN a.amount ELSE 0 END ) AS haldingAmount,
- MAX( CASE WHEN a.property = 2 THEN a.amount ELSE 0 END ) AS documentaryAmount,
- MAX( CASE WHEN a.property = 3 THEN a.amount ELSE 0 END ) AS promotionAmount
- FROM
- (
- SELECT
- CONCAT(YEAR(create_time),'-',LPAD(MONTH(create_time), 2, '0'),'-',LPAD(Day(create_time), 2, '0')) reportDate,
- property as property,
- sum(amount) as amount
- FROM
- sys_user_account_history
- WHERE
- documentary=2
- and create_time >= #{beginTime} and create_time <= #{endTime}
- and user_id=#{userId}
- GROUP BY
- CONCAT(YEAR(create_time),'-',LPAD(MONTH(create_time), 2, '0'),'-',LPAD(Day(create_time), 2, '0')),
- property
- ) a
- GROUP BY
- a.reportDate
- </select>
- <select id="revenueReportDay" resultType="com.ydtech.modules.admin.model.dto.RevenueReportDto">
- SELECT
- a.reportDate AS reportDate,
- MAX( CASE WHEN a.property = 1 THEN a.amount ELSE 0 END ) AS haldingAmount,
- MAX( CASE WHEN a.property = 2 THEN a.amount ELSE 0 END ) AS documentaryAmount,
- MAX( CASE WHEN a.property = 3 THEN a.amount ELSE 0 END ) AS promotionAmount
- FROM
- (
- SELECT
- CONCAT(YEAR ( create_time ),'-',LPAD( MONTH ( create_time ), 2, '0' ),'-',LPAD( DAY ( create_time ), 2, '0' ),' ',LPAD( HOUR ( create_time ), 2, '0' )) reportDate,
- property as property,
- sum( amount ) as amount
- FROM
- sys_user_account_history
- WHERE
- documentary=2
- and create_time >= #{beginTime} and create_time <= #{endTime}
- and user_id=#{userId}
- GROUP BY
- CONCAT(YEAR ( create_time ),'-',LPAD( MONTH ( create_time ), 2, '0' ),'-',LPAD( DAY ( create_time ), 2, '0' ),' ',LPAD( HOUR ( create_time ), 2, '0' )),
- property
- ) a
- GROUP BY
- a.reportDate
- </select>
- <select id="findMyIncomeAndExpensesAmountByUserId"
- resultType="com.ydtech.modules.admin.model.dto.MyCollectInAdvanceDto">
- SELECT
- his.id as id,
- ins.id as "subOrderNo",
- ins.signing_time as "signingTime",
- o.licenseno as "licenseno",
- his.amount as "amount",
- his.business_eegments_type as "businessSegmentsType",
- his.documentary as "incomeAndExpensesType",
- his.property as "transactionType",
- his.create_time as "createTime",
- his.auditiing_id as "auditiingId",
- CASE saa.auditing_status
- WHEN '2' THEN '提现中'
- WHEN '3' THEN '已提现'
- WHEN '4' THEN '驳回'
- ELSE ''
- END AS "auditingStatus",
- CASE ifa.audituser WHEN '自动审核' THEN '1'
- ELSE '2' END as "checkStatus"
- FROM
- sys_user_account_history his
- LEFT JOIN ins_area_company ins ON his.suborder = ins.id
- LEFT JOIN ins_orders o ON o.orderno = ins.orderno
- left join sys_amount_auditing saa on saa.id =his.auditiing_id
- left join ins_fee_audit ifa on ifa.ins_order_no = ins.id
- WHERE
- his.property !=1 and his.property !=2
- <if test="myIncomeAndExpensesQueryDto.incomeAndExpensesType !=null and myIncomeAndExpensesQueryDto.incomeAndExpensesType != '' and myIncomeAndExpensesQueryDto.incomeAndExpensesType != '0' ">
- AND his.documentary=#{ myIncomeAndExpensesQueryDto.incomeAndExpensesType}
- </if>
- and his.user_id = #{myIncomeAndExpensesQueryDto.userId}
- <if test="myIncomeAndExpensesQueryDto.startDate !=null and myIncomeAndExpensesQueryDto.startDate != '' and myIncomeAndExpensesQueryDto.endDate !=null and myIncomeAndExpensesQueryDto.endDate != '' ">
- AND his.create_time BETWEEN #{myIncomeAndExpensesQueryDto.startDate} AND #{myIncomeAndExpensesQueryDto.endDate}
- </if>
- <if test="myIncomeAndExpensesQueryDto.transactionType !=null and myIncomeAndExpensesQueryDto.transactionType != '' and myIncomeAndExpensesQueryDto.transactionType != '0'">
- and his.property = #{myIncomeAndExpensesQueryDto.transactionType}
- </if>
- <if test="myIncomeAndExpensesQueryDto.businessSegmentsType !=null and myIncomeAndExpensesQueryDto.businessSegmentsType != '' and myIncomeAndExpensesQueryDto.businessSegmentsType != '0'">
- and his.business_eegments_type =#{myIncomeAndExpensesQueryDto.businessSegmentsType}
- </if>
- order by his.create_time desc
- </select>
- <select id="findMyIncomeAndExpensesAmountByUserIdCount" resultType="java.lang.Long">
- SELECT
- count(0)
- FROM
- sys_user_account_history his
- WHERE
- his.property !=1 and his.property !=2
- <if test="myIncomeAndExpensesQueryDto.incomeAndExpensesType !=null and myIncomeAndExpensesQueryDto.incomeAndExpensesType != '' and myIncomeAndExpensesQueryDto.incomeAndExpensesType != '0'">
- AND his.documentary=#{ myIncomeAndExpensesQueryDto.incomeAndExpensesType}
- </if>
- and his.user_id = #{myIncomeAndExpensesQueryDto.userId}
- <if test="myIncomeAndExpensesQueryDto.startDate !=null and myIncomeAndExpensesQueryDto.startDate != '' and myIncomeAndExpensesQueryDto.endDate !=null and myIncomeAndExpensesQueryDto.endDate != '' ">
- AND his.create_time BETWEEN #{myIncomeAndExpensesQueryDto.startDate} AND #{myIncomeAndExpensesQueryDto.endDate}
- </if>
- <if test="myIncomeAndExpensesQueryDto.transactionType !=null and myIncomeAndExpensesQueryDto.transactionType != '' and myIncomeAndExpensesQueryDto.transactionType != '0'">
- and his.property = #{myIncomeAndExpensesQueryDto.transactionType}
- </if>
- <if test="myIncomeAndExpensesQueryDto.businessSegmentsType !=null and myIncomeAndExpensesQueryDto.businessSegmentsType != '' and myIncomeAndExpensesQueryDto.businessSegmentsType != '0' ">
- and his.business_eegments_type =#{myIncomeAndExpensesQueryDto.businessSegmentsType}
- </if>
- </select>
- <select id="findSumAmount" resultType="java.math.BigDecimal">
- SELECT
- sum(his.amount) as "sumAmount"
- FROM
- sys_user_account_history his
- WHERE
- his.property !=1 and his.property !=2
- <if test="myIncomeAndExpensesQueryDto.incomeAndExpensesType !=null and myIncomeAndExpensesQueryDto.incomeAndExpensesType != '' and myIncomeAndExpensesQueryDto.incomeAndExpensesType != '0' ">
- AND his.documentary=#{ myIncomeAndExpensesQueryDto.incomeAndExpensesType}
- </if>
- and his.user_id = #{myIncomeAndExpensesQueryDto.userId}
- <if test="myIncomeAndExpensesQueryDto.startDate !=null and myIncomeAndExpensesQueryDto.startDate != '' and myIncomeAndExpensesQueryDto.endDate !=null and myIncomeAndExpensesQueryDto.endDate != '' ">
- AND his.create_time BETWEEN #{myIncomeAndExpensesQueryDto.startDate} AND #{myIncomeAndExpensesQueryDto.endDate}
- </if>
- <if test="myIncomeAndExpensesQueryDto.transactionType !=null and myIncomeAndExpensesQueryDto.transactionType != '' and myIncomeAndExpensesQueryDto.transactionType != '0'">
- and his.property = #{myIncomeAndExpensesQueryDto.transactionType}
- </if>
- <if test="myIncomeAndExpensesQueryDto.businessSegmentsType !=null and myIncomeAndExpensesQueryDto.businessSegmentsType != '' and myIncomeAndExpensesQueryDto.businessSegmentsType != '0' ">
- and his.business_eegments_type =#{myIncomeAndExpensesQueryDto.businessSegmentsType}
- </if>
- </select>
- <select id="findSumAmountByUserId" resultType="java.math.BigDecimal">
- SELECT
- sum(his.amount) as "sumAmount"
- FROM
- sys_user_account_history his
- WHERE
- his.documentary =#{types}
- and his.property !=1 and his.property !=2
- and his.user_id = #{userId}
- </select>
- <select id="findMyIncomeAndExpensesAmountNewByUserId"
- resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsSZDto">
- <include refid="common_List_sql"/>
- </select>
- <select id="exportMyIncomeAndExpensesAmountNewByUserId"
- resultType="com.ydtech.modules.admin.model.dto.ExportExpenditureTypeDetalsSZDto">
- <include refid="common_List_sql"/>
- </select>
- <sql id="common_List_sql">
- SELECT
- his.id as id,
- ins.id as "subOrderNo",
- ins.signing_time as "signingTime",
- o.licenseno as "licenseno",
- his.amount as "amount",
- his.business_eegments_type as "businessSegmentsType",
- his.documentary as "incomeAndExpensesType",
- his.property as "transactionType",
- his.create_time as "createTime",
- his.auditiing_id as "auditiingId",
- CASE saa.auditing_status
- WHEN '2' THEN '提现中'
- WHEN '3' THEN '已提现'
- WHEN '4' THEN '已驳回'
- ELSE ''
- END AS "auditingStatus"
- FROM
- sys_user_account_history his
- LEFT JOIN ins_area_company ins ON his.suborder = ins.id
- LEFT JOIN ins_orders o ON o.orderno = ins.orderno
- left join sys_amount_auditing saa on saa.id =his.auditiing_id
- WHERE
- his.property !=1 and his.property !=2
- <if test="vo.incomeAndExpensesType !=null and vo.incomeAndExpensesType != '' and vo.incomeAndExpensesType != '0' ">
- AND his.documentary=#{ vo.incomeAndExpensesType}
- </if>
- and his.user_id = #{vo.userId}
- <if test="vo.startDate !=null and vo.startDate != '' and vo.endDate !=null and vo.endDate != '' ">
- AND his.create_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- <if test="vo.transactionType !=null and vo.transactionType != '' and vo.transactionType != '0'">
- and his.property = #{vo.transactionType}
- </if>
- <if test="vo.businessSegmentsType !=null and vo.businessSegmentsType != '' and vo.businessSegmentsType != '0'">
- and his.business_eegments_type =#{vo.businessSegmentsType}
- </if>
- <if test="vo.licenseNo !=null and vo.licenseNo != ''">
- and o.licenseno =#{vo.licenseNo}
- </if>
- order by his.create_time desc
- </sql>
- <select id="queryRevenueAndExpenditureDataPage"
- resultType="com.ydtech.modules.admin.model.report.financeData.RevenueAndExpenditureDataDto">
- SELECT
- his.id as id,
- his.amount as "amount",
- DATE_FORMAT(his.create_time, '%Y-%m-%d %H:%i:%s') as "createTime",
- his.auditiing_id as "auditiingId",
- CASE saa.auditing_status
- WHEN '2' THEN '提现中'
- WHEN '3' THEN '已提现'
- WHEN '4' THEN '已驳回'
- ELSE ''
- END AS "auditingStatus",
- su.id as userId,
- su.name as userName,
- DATE_FORMAT(saa.auditing_time, '%Y-%m-%d %H:%i:%s') as auditingTime,
- CASE
- dept.management_source
- WHEN '1' THEN
- '渠道'
- WHEN '2' THEN
- '代理人' ELSE ''
- END deptType
- FROM
- sys_user_account_history his
- LEFT JOIN ins_area_company ins ON his.suborder = ins.id
- LEFT JOIN sys_user su ON su.id = his.user_id
- LEFT JOIN sys_amount_auditing saa ON saa.id = his.auditiing_id
- LEFT JOIN sys_dept dept ON dept.id = su.dept_id
- WHERE
- his.property !=1 and his.property !=2
- AND (
- dept.management_source = 1
- OR dept.management_source = 2)
- and his.documentary =1
- <if test="vo.userId !=null and vo.userId != '' ">
- and his.user_id = #{vo.userId}
- </if>
- <if test="vo.startDate !=null and vo.startDate != '' and vo.endDate !=null and vo.endDate != '' ">
- AND his.create_time BETWEEN #{vo.startDate} AND #{vo.endDate}
- </if>
- <if test="vo.auditstatus !=null and vo.auditstatus != '' ">
- AND saa.auditing_status = #{auditstatus}
- </if>
- order by his.create_time desc
- </select>
- </mapper>
|