|
@@ -2,23 +2,66 @@
|
|
|
<!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">
|
|
|
+ <select id="marketStat" resultType="com.dayou.vo.MarketStatVO" parameterType="com.dayou.dto.MarketStatDTO">
|
|
|
SELECT
|
|
|
- ( SELECT VALUE FROM global_config WHERE field = 'YEAR_SALE_TARGET' AND NAME = 'MARKET' AND deleted = 0 ) AS yearSaleTarget,
|
|
|
- ( SELECT VALUE FROM global_config WHERE field = 'YEAR_PAYMENT_TARGET' AND NAME = 'MARKET' AND deleted = 0 ) AS yearPaymentTarget,
|
|
|
- ( SELECT count(*) FROM business_opportunity WHERE state = '跟进中' AND deleted = 0 ) AS businessNum,
|
|
|
- (
|
|
|
- SELECT
|
|
|
- sum( amount )
|
|
|
+ ( 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' )) AS yearSaleDone, ( SELECT sum( amount ) FROM payment_collection WHERE deleted = 0 AND payment_date >= DATE_SUB( CURDATE(), INTERVAL dayofyear( now())- 1 DAY )
|
|
|
- AND payment_date <= concat( YEAR ( now()), '-12-31' )) AS yearPaymentDone, ( SELECT sum( amount ) FROM payment_collection WHERE deleted = 0 AND payment_date >= concat( date_format( LAST_DAY( now()), '%Y-%m-' ), '01' )
|
|
|
- AND payment_date <= LAST_DAY(
|
|
|
- now())) AS monthPaymentDone
|
|
|
+ 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 >= concat( date_format( LAST_DAY( now()), '%Y-%m-' ), '01' )
|
|
|
+ AND pc.payment_date <= LAST_DAY(
|
|
|
+ now())
|
|
|
+ <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>
|