admin
2019-01-08 c84d8ecd97d111b01db9cfd807300d0491a95bc8
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoMapper.xml
@@ -266,6 +266,7 @@
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
      yeshi_ec_hongbao where id = #{id,jdbcType=BIGINT}
   </delete>
@@ -555,14 +556,14 @@
   <select id="selectCountByTypeAndStateAndCreateTime" resultType="java.lang.Long">
      SELECT COUNT(h.`id`) FROM yeshi_ec_hongbao h WHERE uid=#{uid}
      <foreach  collection="type" item="itemType" open="and (" separator=" or "
         close=")">
      <foreach collection="type" item="itemType" open="and ("
         separator=" or " close=")">
         h.`type`=#{itemType}
      </foreach>
      <foreach collection="state" item="itemState" open="and (" separator=" or "
         close=")">
      <foreach collection="state" item="itemState" open="and ("
         separator=" or " close=")">
         h.`state`=#{itemState}
      </foreach>
@@ -573,87 +574,92 @@
      ]]>
      #{maxTime};
   </select>
   <select id="count24HOderByChannel" resultType="java.util.HashMap">
      SELECT  COALESCE(SUM(b.money*2),0) AS 'commision',  COALESCE(COUNT(b.id),0) AS'countOrder',
          COALESCE(SUM(b.payMoney),0) AS 'payMoney',
          <if test="type == 1">
             FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'createDate'
         </if>
         <if test="type == 2">
             FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'createDate'
         </if>
         <if test="type == 3">
             FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'createDate'
         </if>
      FROM
         (
         SELECT h.* FROM  yeshi_ec_hongbao h
         LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
              WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a
         ON a.uid=h.`uid` WHERE a.uid IS NOT NULL AND (h.`type`=1 OR h.`type`=20)
         ) b
      LEFT JOIN yeshi_ec_user u ON u.`id`=b.uid
      WHERE <![CDATA[b.createtime<u.`createtime`+1000*60*60*24 ]]>
         <if test="startTime != null and startTime != '' ">
             AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
         </if>
         <if test="endTime != null and endTime != '' ">
             AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
         </if>
         <if test="years != null and years != '' ">
             AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}'
         </if>
      SELECT COALESCE(SUM(b.money*2),0) AS 'commision',
      COALESCE(COUNT(b.id),0) AS'countOrder',
      COALESCE(SUM(b.payMoney),0) AS 'payMoney',
      <if test="type == 1">
         GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
         FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'createDate'
      </if>
      <if test="type == 2">
          GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m')
         FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'createDate'
      </if>
      <if test="type == 3">
          GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y')
      </if>
         FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'createDate'
      </if>
      FROM
      (
      SELECT h.* FROM yeshi_ec_hongbao h
      LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a
      WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a
      ON a.uid=h.`uid` WHERE a.uid IS NOT NULL AND (h.`type`=1 OR h.`type`=20)
      ) b
      LEFT JOIN yeshi_ec_user u ON u.`id`=b.uid
      WHERE <![CDATA[b.createtime<u.`createtime`+1000*60*60*24 ]]>
      <if test="startTime != null and startTime != '' ">
         AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
      </if>
      <if test="endTime != null and endTime != '' ">
         AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]>
         '${endTime}'
      </if>
      <if test="years != null and years != '' ">
         AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}'
      </if>
      <if test="type == 1">
         GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
      </if>
      <if test="type == 2">
         GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m')
      </if>
      <if test="type == 3">
         GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y')
      </if>
      ORDER BY u.`createtime`
   </select>
   <select id="countHistoryOderByChannel" resultType="java.util.HashMap">
      SELECT  COALESCE(SUM(h.`money`)*2,0) AS 'commision', COALESCE(COUNT(h.id),0) AS 'countOrder',
          COALESCE(SUM(h.payMoney),0) AS 'payMoney',
            <if test="type == 1">
                FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') AS 'createDate'
            </if>
            <if test="type == 2">
                FROM_UNIXTIME(h.`createtime`/1000,'%m') AS 'createDate'
            </if>
            <if test="type == 3">
                FROM_UNIXTIME(h.`createtime`/1000,'%Y') AS 'createDate'
            </if>
      FROM yeshi_ec_hongbao h
      LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
         WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON h.`uid`=a.uid
      WHERE  (h.`type`=1 OR h.`type`=20)  AND  a.uid IS NOT NULL
            <if test="startTime != null and startTime != '' ">
             AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
            <if test="endTime != null and endTime != '' ">
                AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
            </if>
            <if test="years != null and years != '' ">
                AND FROM_UNIXTIME(h.`createtime`/1000,'%Y') = '${years}'
            </if>
      SELECT COALESCE(SUM(h.`money`)*2,0) AS 'commision',
      COALESCE(COUNT(h.id),0) AS 'countOrder',
      COALESCE(SUM(h.payMoney),0) AS 'payMoney',
      <if test="type == 1">
         GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')
         FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') AS 'createDate'
      </if>
      <if test="type == 2">
          GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m')
         FROM_UNIXTIME(h.`createtime`/1000,'%m') AS 'createDate'
      </if>
      <if test="type == 3">
          GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y')
      </if>
         FROM_UNIXTIME(h.`createtime`/1000,'%Y') AS 'createDate'
      </if>
      FROM yeshi_ec_hongbao h
      LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a
      WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON
      h.`uid`=a.uid
      WHERE (h.`type`=1 OR h.`type`=20) AND a.uid IS NOT NULL
      <if test="startTime != null and startTime != '' ">
         AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
      </if>
      <if test="endTime != null and endTime != '' ">
         AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]>
         '${endTime}'
      </if>
      <if test="years != null and years != '' ">
         AND FROM_UNIXTIME(h.`createtime`/1000,'%Y') = '${years}'
      </if>
      <if test="type == 1">
         GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')
      </if>
      <if test="type == 2">
         GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m')
      </if>
      <if test="type == 3">
         GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y')
      </if>
      ORDER BY h.`createtime`
   </select>
</mapper>