123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?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
- ( 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>) AS yearSaleTarget,
- ( 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>) 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 sign_date >= DATE_SUB( CURDATE(), INTERVAL dayofyear( now())- 1 DAY )
- AND sign_date <= concat( YEAR ( now()), '-12-31' )
- <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 >= DATE_SUB( CURDATE(), INTERVAL dayofyear( now())- 1 DAY )
- AND pc.payment_date <= concat( YEAR ( now()), '-12-31' )
- <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
- </select>
- </mapper>
|