123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- <?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.ygj.yuemum.dao.distributionchannel.DcIntroduceLogDao">
- <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
- <result column="id" property="id" jdbcType="INTEGER"/>
- <result column="xul_openid" property="xul_openid" jdbcType="VARCHAR"/>
- <result column="xul_phone" property="xul_phone" jdbcType="VARCHAR"/>
- <result column="xul_event" property="xul_event" jdbcType="INTEGER"/>
- <result column="xul_date" property="xul_date" jdbcType="DATE"/>
- <result column="xul_introducer_phone" property="xul_introducer_phone" jdbcType="VARCHAR"/>
- <result column="xul_pm_type" property="xul_pm_type" jdbcType="INTEGER"/>
- <result column="xul_orderno" property="xul_orderno" jdbcType="VARCHAR"/>
- <result column="xul_rebateamount" property="xul_rebateamount" jdbcType="INTEGER"/>
- </resultMap>
- <!--获取所有数据-->
- <select id="checkDcIntroducerLogs" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
- select
- count(1)
- from dc_introduce_log
- where xul_phone = #{xul_phone,jdbcType=VARCHAR}
- and xul_event = #{xul_event,jdbcType=INTEGER}
- and xul_openid = #{xul_openid,jdbcType=INTEGER}
- order by id desc
- </select>
- <select id="checkFirstDILogs" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
- select
- count(1)
- from dc_introduce_log
- where xul_openid = #{xul_openid,jdbcType=VARCHAR}
- and xul_event = 0
- and xul_introducer_phone = #{xul_introducer_phone,jdbcType=INTEGER}
- order by id desc
- </select>
- <select id="queryDcIntroduceLogs" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
- parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
- SELECT
- dc_introduce_log.id,
- xul_openid,
- xul_phone,
- xul_event,
- xul_date,
- xul_introducer_phone,
- xul_pm_type,
- xul_orderno,
- ys_order.od_order_amount od_order_amount,
- xul_rebateamount
- FROM
- dc_introduce_log LEFT JOIN ys_order ON dc_introduce_log.xul_orderno = ys_order.od_no
- where 1=1
- <if test="xul_openid != null and xul_openid != ''">
- and xul_openid = #{xul_openid,jdbcType=VARCHAR}
- </if>
- <if test="xul_phone != null and xul_phone != ''">
- and xul_phone = #{xul_phone,jdbcType=VARCHAR}
- </if>
- <if test="xul_event != null and xul_event != ''">
- and xul_event = #{xul_event,jdbcType=INTEGER}
- </if>
- <if test="xul_date != null and xul_date != ''">
- and xul_date = #{xul_date,jdbcType=DATE}
- </if>
- <if test="xul_introducer_phone != null and xul_introducer_phone != ''">
- and xul_introducer_phone = #{xul_introducer_phone,jdbcType=VARCHAR}
- </if>
- <if test="xul_pm_type != null and xul_pm_type != ''">
- and xul_pm_type = #{xul_pm_type,jdbcType=INTEGER}
- </if>
- <if test="xul_orderno != null and xul_orderno != ''">
- and xul_orderno = #{xul_orderno,jdbcType=VARCHAR}
- </if>
- order by xul_event desc, id desc , xul_pm_type asc
- </select>
- <select id="queryDcILbyrebate" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
- parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
- SELECT
- ta.id,
- xul_openid,
- xul_phone,
- xul_event,
- xul_date,
- xul_introducer_phone,
- xul_pm_type,
- xul_orderno,
- tb.od_order_amount,
- ifnull(tb.od_rebate_amount,0) od_rebate_amount
- FROM
- dc_introduce_log ta
- LEFT JOIN ys_order tb ON ta.xul_orderno = tb.od_no
- where 1=1
- <if test="xul_openid != null and xul_openid != ''">
- and xul_openid = #{xul_openid,jdbcType=VARCHAR}
- </if>
- <if test="xul_phone != null and xul_phone != ''">
- and xul_phone = #{xul_phone,jdbcType=VARCHAR}
- </if>
- <if test="xul_event != null and xul_event != ''">
- and xul_event = #{xul_event,jdbcType=INTEGER}
- </if>
- <if test="xul_date != null and xul_date != ''">
- and xul_date = #{xul_date,jdbcType=DATE}
- </if>
- <if test="xul_introducer_phone != null and xul_introducer_phone != ''">
- and xul_introducer_phone = #{xul_introducer_phone,jdbcType=VARCHAR}
- </if>
- <if test="xul_pm_type != null and xul_pm_type != ''">
- and xul_pm_type = #{xul_pm_type,jdbcType=INTEGER}
- </if>
- <if test="xul_orderno != null and xul_orderno != ''">
- and xul_orderno = #{xul_orderno,jdbcType=VARCHAR}
- </if>
- order by xul_event desc, id desc , xul_pm_type asc
- </select>
- <select id="getDcIntroduceLogs" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
- parameterType="java.lang.String">
- select xul_phone,max(xul_event) xul_event from dc_introduce_log
- where xul_introducer_phone = #{phone,jdbcType=VARCHAR}
- and xul_event >= 2
- group by xul_phone
- </select>
- <select id="getDcIntroduceLogFive" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
- parameterType="java.lang.String">
- SELECT
- xul_phone,
- DATE_FORMAT(min(xul_date), '%Y-%m-%d') xul_date,
- max(xul_event) xul_event,
- max(xul_pm_type) xul_pm_type,
- max(xul_rebateamount) xul_rebateamount
- FROM
- dc_introduce_log
- WHERE
- xul_phone = #{phone,jdbcType=VARCHAR}
- AND xul_event >= 5
- GROUP BY
- xul_orderno,xul_phone,xul_date
- </select>
- <select id="getDcIntroduceLogTwo" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
- parameterType="java.lang.String">
- SELECT
- xul_phone,
- DATE_FORMAT(xul_date, '%Y-%m-%d') xul_date,
- xul_event,
- xul_pm_type,
- xul_rebateamount
- FROM
- dc_introduce_log
- WHERE
- xul_phone = #{phone,jdbcType=VARCHAR}
- AND xul_event = 2
- GROUP BY
- xul_orderno,xul_phone,xul_date,xul_event,xul_pm_type,xul_rebateamount
- </select>
- <select id="getDcReport" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
- parameterType="com.ygj.yuemum.domain.distributionchannel.DcQueryReport">
- SELECT DISTINCT
- (ta.xul_phone) xul_phone,
- ta.xul_introducer_phone,
- ta.xul_date,
- ta.xul_orderno,
- ifnull(fgetorder_amount(ta.xul_orderno),0) od_order_amount,
- ifnull(ta.xul_rebateamount,0) od_rebate_amount,
- count(tb.xul_introducer_phone)
- FROM
- dc_introduce_log ta
- LEFT JOIN dc_introduce_log tb ON ta.xul_introducer_phone = tb.xul_introducer_phone
- WHERE
- ta.xul_introducer_phone != ''
- and ta.xul_event = #{xul_event,jdbcType=INTEGER}
- AND tb.xul_event = #{xul_event,jdbcType=INTEGER}
- <if test="start_date != null and start_date != ''">
- and ta.xul_date >= #{start_date,jdbcType=DATE}
- </if>
- <if test="xul_phone != null and xul_phone != ''">
- and ta.xul_phone like "%"#{xul_phone,jdbcType=VARCHAR}"%"
- </if>
- <if test="xul_introducer_phone != null and xul_introducer_phone != ''">
- and ta.xul_introducer_phone like "%"#{xul_introducer_phone,jdbcType=VARCHAR}"%"
- </if>
- <if test="end_date != null and end_date != ''">
- and ta.xul_date <= #{end_date,jdbcType=DATE}
- </if>
- GROUP BY
- ta.xul_phone,ta.xul_introducer_phone,ta.xul_date,ta.xul_orderno,ta.xul_rebateamount
- ORDER BY
- count(tb.xul_introducer_phone) DESC, ta.xul_introducer_phone asc
- </select>
- <insert id="insertDcIntroduceLog" parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
- insert into dc_introduce_log
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="xul_openid != null">
- xul_openid,
- </if>
- <if test="xul_phone != null">
- xul_phone,
- </if>
- <if test="xul_event != null">
- xul_event,
- </if>
- <if test="xul_date != null">
- xul_date,
- </if>
- <if test="xul_introducer_phone != null">
- xul_introducer_phone,
- </if>
- <if test="xul_pm_type != null">
- xul_pm_type,
- </if>
- <if test="xul_orderno != null">
- xul_orderno,
- </if>
- <if test="xul_rebateamount != null">
- xul_rebateamount
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="xul_openid != null">
- #{xul_openid,jdbcType=VARCHAR},
- </if>
- <if test="xul_phone != null">
- #{xul_phone,jdbcType=VARCHAR},
- </if>
- <if test="xul_event != null">
- #{xul_event,jdbcType=INTEGER},
- </if>
- <if test="xul_date != null">
- #{xul_date,jdbcType=DATE},
- </if>
- <if test="xul_introducer_phone != null">
- #{xul_introducer_phone,jdbcType=VARCHAR},
- </if>
- <if test="xul_pm_type != null">
- #{xul_pm_type,jdbcType=INTEGER},
- </if>
- <if test="xul_orderno != null">
- #{xul_orderno,jdbcType=VARCHAR},
- </if>
- <if test="xul_rebateamount != null">
- #{xul_rebateamount,jdbcType=INTEGER}
- </if>
- </trim>
- </insert>
- <update id="updateDcIntroduceLogByPhone" parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog" >
- update dc_introduce_log
- <set >
- <if test="xul_introducer_phone != null" >
- xul_introducer_phone = #{xul_introducer_phone,jdbcType=VARCHAR},
- </if>
- </set>
- where xul_introducer_phone = #{xul_introducer_phoneOld,jdbcType=VARCHAR}
- </update>
- </mapper>
|