LiveUserFirstEntryMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.live.mapper.LiveUserFirstEntryMapper">
  6. <resultMap type="LiveUserFirstEntry" id="LiveUserFirstEntryResult">
  7. <result property="id" column="id" />
  8. <result property="userId" column="user_id" />
  9. <result property="liveId" column="live_id" />
  10. <result property="entryDate" column="entry_date" />
  11. <result property="firstEntryTime" column="first_entry_time" />
  12. <result property="createTime" column="create_time" />
  13. <result property="updateTime" column="update_time" />
  14. <result property="companyId" column="company_id" />
  15. <result property="companyUserId" column="company_user_id" />
  16. <result property="qwUserId" column="qw_user_id" />
  17. <result property="externalContactId" column="external_contact_id" />
  18. </resultMap>
  19. <sql id="selectLiveUserFirstEntryVo">
  20. select id, user_id, live_id, entry_date, first_entry_time,company_id,company_user_id, create_time, update_time,qw_user_id,external_contact_id from live_user_first_entry
  21. </sql>
  22. <select id="selectLiveUserFirstEntryList" parameterType="LiveUserFirstEntry" resultMap="LiveUserFirstEntryResult">
  23. <include refid="selectLiveUserFirstEntryVo"/>
  24. <where>
  25. <if test="userId != null and userId != ''"> and user_id = #{userId}</if>
  26. <if test="liveId != null and liveId != ''"> and live_id = #{liveId}</if>
  27. <if test="entryDate != null "> and entry_date = #{entryDate}</if>
  28. <if test="firstEntryTime != null "> and first_entry_time = #{firstEntryTime}</if>
  29. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  30. <if test="companyId != null "> and company_id = #{companyId}</if>
  31. <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
  32. <if test="externalContactId != null "> and external_contact_id = #{externalContactId}</if>
  33. </where>
  34. </select>
  35. <select id="selectLiveUserFirstEntryById" parameterType="Long" resultMap="LiveUserFirstEntryResult">
  36. <include refid="selectLiveUserFirstEntryVo"/>
  37. where id = #{id}
  38. </select>
  39. <insert id="insertLiveUserFirstEntry" parameterType="LiveUserFirstEntry" useGeneratedKeys="true" keyProperty="id">
  40. insert into live_user_first_entry
  41. <trim prefix="(" suffix=")" suffixOverrides=",">
  42. <if test="userId != null and userId != ''">user_id,</if>
  43. <if test="liveId != null and liveId != ''">live_id,</if>
  44. <if test="entryDate != null">entry_date,</if>
  45. <if test="firstEntryTime != null">first_entry_time,</if>
  46. <if test="createTime != null">create_time,</if>
  47. <if test="updateTime != null">update_time,</if>
  48. <if test="companyUserId != null">company_user_id,</if>
  49. <if test="companyId != null">company_id,</if>
  50. <if test="qwUserId != null">qw_user_id,</if>
  51. <if test="externalContactId != null">external_contact_id,</if>
  52. </trim>
  53. <trim prefix="values (" suffix=")" suffixOverrides=",">
  54. <if test="userId != null and userId != ''">#{userId},</if>
  55. <if test="liveId != null and liveId != ''">#{liveId},</if>
  56. <if test="entryDate != null">#{entryDate},</if>
  57. <if test="firstEntryTime != null">#{firstEntryTime},</if>
  58. <if test="createTime != null">#{createTime},</if>
  59. <if test="updateTime != null">#{updateTime},</if>
  60. <if test="companyUserId != null">#{companyUserId},</if>
  61. <if test="companyId != null">#{companyId},</if>
  62. <if test="qwUserId != null">#{qwUserId},</if>
  63. <if test="externalContactId != null">#{externalContactId},</if>
  64. </trim>
  65. </insert>
  66. <update id="updateLiveUserFirstEntry" parameterType="LiveUserFirstEntry">
  67. update live_user_first_entry
  68. <trim prefix="SET" suffixOverrides=",">
  69. <if test="userId != null and userId != ''">user_id = #{userId},</if>
  70. <if test="liveId != null and liveId != ''">live_id = #{liveId},</if>
  71. <if test="entryDate != null">entry_date = #{entryDate},</if>
  72. <if test="firstEntryTime != null">first_entry_time = #{firstEntryTime},</if>
  73. <if test="createTime != null">create_time = #{createTime},</if>
  74. <if test="updateTime != null">update_time = #{updateTime},</if>
  75. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  76. <if test="companyId != null">company_id = #{companyId},</if>
  77. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  78. <if test="externalContactId != null">external_contact_id = #{externalContactId},</if>
  79. </trim>
  80. where id = #{id}
  81. </update>
  82. <delete id="deleteLiveUserFirstEntryById" parameterType="Long">
  83. delete from live_user_first_entry where id = #{id}
  84. </delete>
  85. <delete id="deleteLiveUserFirstEntryByIds" parameterType="String">
  86. delete from live_user_first_entry where id in
  87. <foreach item="id" collection="array" open="(" separator="," close=")">
  88. #{id}
  89. </foreach>
  90. </delete>
  91. <select id="selectLiveProfitList" resultType="com.fs.live.vo.LiveUserFirstProfit">
  92. SELECT
  93. lo.order_id,lo.order_code,lo.user_name,lo.user_phone,lo.total_price,lo.pay_price,lo.is_pay,lo.status,
  94. cu.user_id AS company_user_id,
  95. cu.nick_name AS company_user_name,
  96. c.company_name
  97. FROM
  98. live_order lo
  99. LEFT JOIN
  100. live_user_first_entry lufe
  101. ON lo.user_id = lufe.user_id
  102. AND DATE(lo.create_time) = lufe.entry_date
  103. LEFT JOIN
  104. company_user cu
  105. ON lufe.company_user_id = cu.user_id
  106. left join company c on cu.company_id = c.company_id
  107. ORDER BY
  108. lo.create_time DESC
  109. </select>
  110. </mapper>