<?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.app.ydl.marketing.dao.LandingChannelWxmpAccessRecordDao">

  <select id="selectJoinWxcorpList" resultType="map">
    SELECT o.id, o.`from`, o.uid, o.phone, o.`status`, p.update_time AS pay_time, r.if_join_wxcorp,r.join_wxcorp_userid FROM `ydl`.`course_order` o
    LEFT JOIN `ydl`.`pay` p ON p.relation_id = o.id
    LEFT JOIN `ydl_marketing`.`landing_channel_wxmp_access_record` r ON r.uid = o.uid
    WHERE o.`status` = '2'
    <if test="ffromList != null and ffromList.size > 0">
      AND o.`from` IN
      <foreach close=")" collection="ffromList" item="listItem" open="(" separator=",">
        #{listItem}
      </foreach>
    </if>
    AND o.create_time &gt;= #{startTime,jdbcType=VARCHAR} AND o.create_time &lt;= #{endTime,jdbcType=VARCHAR}
    AND r.if_join_wxcorp = 1
    ORDER BY `uid` DESC
  </select>

  <select id="selectUnJoinWxcorpList" resultType="map">
    SELECT o.id, o.`from`, o.uid, o.phone, o.`status`, p.update_time AS pay_time, r.if_join_wxcorp, r.wxmp_access_record_id FROM `ydl`.`course_order` o
    LEFT JOIN `ydl`.`pay` p ON p.relation_id = o.id
    LEFT JOIN `ydl_marketing`.`landing_channel_wxmp_access_record` r ON r.uid = o.uid
    WHERE o.`status` = '2'
    <if test="ffromList != null and ffromList.size > 0">
      AND o.`from` IN
      <foreach close=")" collection="ffromList" item="listItem" open="(" separator=",">
        #{listItem}
      </foreach>
    </if>
    AND o.create_time &gt;= #{startTime,jdbcType=VARCHAR} AND o.create_time &lt;= #{endTime,jdbcType=VARCHAR}
    AND r.if_join_wxcorp = 0
    ORDER BY `uid` DESC
  </select>
</mapper>