123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?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.dayou.mapper.MarketStatMapper">
- <select id="marketStat" resultType="com.dayou.vo.MarketStatVO" parameterType="com.dayou.dto.MarketStatDTO">
- SELECT
- ifnull(( SELECT sum(ifnull(sale_target,0)) FROM user_target
- <where>
- <if test="dto!=null and dto.userIds!=null and dto.userIds.size!=0">and user_id in
- <foreach collection="dto.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if> </where> ),0) AS yearSaleTarget,
- ifnull(( SELECT sum(ifnull(payment_target,0)) FROM user_target
- <where>
- <if test="dto!=null and dto.userIds!=null and dto.userIds.size!=0">
- and user_id in
- <foreach collection="dto.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if> </where>),0) AS yearPaymentTarget,
- ( SELECT count(*) FROM business_opportunity WHERE state = '跟进中' AND deleted = 0
- <if test="dto!=null and dto.userIds!=null and dto.userIds.size!=0">
- and user_id in
- <foreach collection="dto.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- ) AS businessNum,
- ( SELECT
- ifnull(sum(amount ),0)
- FROM
- item
- WHERE
- deleted = 0
- AND upload_date is not null
- AND upload_date >= concat( YEAR ( now())- 1, '-12-23' )
- AND upload_date <= concat( YEAR ( now()), '-12-22' )
- <if test="dto!=null and dto.userIds!=null and dto.userIds.size!=0">
- and user_id in
- <foreach collection="dto.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- ) AS yearSaleDone,
- ( SELECT
- ifnull( sum( pc.amount ), 0 )
- FROM
- payment_collection pc
- LEFT JOIN item i ON i.id = pc.item_id
- WHERE
- pc.deleted = 0
- AND pc.payment_date >= concat(
- YEAR (
- now())-1,
- '-12-23'
- )
- AND pc.payment_date <= concat(
- YEAR (
- now()),
- '-12-22'
- )
- <if test="dto!=null and dto.userIds!=null and dto.userIds.size!=0">
- and i.user_id in
- <foreach collection="dto.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- ) AS yearPaymentDone,
- ( SELECT ifnull(sum( pc.amount ),0) FROM payment_collection pc left join item i on i.id = pc.item_id WHERE pc.deleted = 0 AND pc.payment_date >= #{lastMonth23}
- AND pc.payment_date <= concat( date_format( LAST_DAY( now()), '%Y-%m-' ), '22' )
- <if test="dto!=null and dto.userIds!=null and dto.userIds.size!=0">
- and i.user_id in
- <foreach collection="dto.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- ) AS monthPaymentDone,
- ifnull(( select sum(estimate_amount) from business_opportunity where deleted = 0 and state = '跟进中'
- <if test="dto!=null and dto.userIds!=null and dto.userIds.size!=0">
- and user_id in
- <foreach collection="dto.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- ),0) AS estimateAmount
- </select>
- <select id="currentMonthPayment" resultType="java.math.BigDecimal">
- SELECT ifnull(sum( pc.amount ),0) FROM payment_collection pc left join item i on i.id = pc.item_id WHERE pc.deleted = 0 AND pc.payment_date >= #{lastMonth23}
- AND pc.payment_date <= concat( date_format( LAST_DAY( now()), '%Y-%m-' ), '22' ) and i.user_id = #{userId}
- </select>
- <select id="currentYearPayment" resultType="java.math.BigDecimal">
- SELECT
- ifnull( sum( pc.amount ), 0 )
- FROM
- payment_collection pc
- LEFT JOIN item i ON i.id = pc.item_id
- WHERE
- pc.deleted = 0
- AND pc.payment_date >= concat(
- YEAR (
- now())-1,
- '-12-23'
- )
- AND pc.payment_date <= concat(
- YEAR (
- now()),
- '-12-22'
- )
- and i.user_id = #{userId}
- </select>
- <select id="currentYearTeamPayment" parameterType="java.util.Set" resultType="java.math.BigDecimal">
- SELECT
- ifnull( sum( pc.amount ), 0 )
- FROM
- payment_collection pc
- LEFT JOIN item i ON i.id = pc.item_id
- WHERE
- pc.deleted = 0
- AND pc.payment_date >= concat(
- YEAR (
- now())-1,
- '-12-23'
- )
- AND pc.payment_date <= concat(
- YEAR (
- now()),
- '-12-22'
- )
- and i.user_id in (
- <foreach collection="userIds" item="item" index="index" separator=",">
- #{item}
- </foreach>
- )
- </select>
- </mapper>
|