CompanyMoneyLogsMapper.xml 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.company.mapper.CompanyMoneyLogsMapper">
  6. <resultMap type="CompanyMoneyLogs" id="CompanyMoneyLogsResult">
  7. <result property="logsId" column="logs_id" />
  8. <result property="companyId" column="company_id" />
  9. <result property="money" column="money" />
  10. <result property="balance" column="balance" />
  11. <result property="remark" column="remark" />
  12. <result property="createTime" column="create_time" />
  13. <result property="logsType" column="logs_type" />
  14. <result property="businessId" column="business_id" />
  15. </resultMap>
  16. <sql id="selectCompanyMoneyLogsVo">
  17. select logs_id, company_id, money,balance, remark, create_time,logs_type,business_id from company_money_logs
  18. </sql>
  19. <select id="selectCompanyMoneyLogsList" parameterType="CompanyMoneyLogs" resultMap="CompanyMoneyLogsResult">
  20. <include refid="selectCompanyMoneyLogsVo"/>
  21. <where>
  22. <if test="companyId != null "> and company_id = #{companyId}</if>
  23. <if test="money != null "> and money = #{money}</if>
  24. </where>
  25. </select>
  26. <select id="selectCompanyMoneyLogsById" parameterType="Long" resultMap="CompanyMoneyLogsResult">
  27. <include refid="selectCompanyMoneyLogsVo"/>
  28. where logs_id = #{logsId}
  29. </select>
  30. <select id="selectCompanyRedPackageListVO" resultType="com.fs.company.domain.CompanyRedPackage">
  31. select sum(l.amount) as totalAmount,u.nick_name as nickName,c.company_name as companyName
  32. from fs_course_red_packet_log l
  33. LEFT JOIN company_user u on l.company_user_id =u.user_id
  34. left join company c on l.company_id = c.company_id
  35. where
  36. u.user_id is not null and l.status=1
  37. <if test="companyId != null">
  38. and l.company_id = #{companyId}
  39. </if>
  40. <if test="dateTime != null">
  41. and DATE_FORMAT(l.create_time,'%Y-%m-%d') like concat(#{dateTime}, '%')
  42. </if>
  43. GROUP BY l.company_user_id
  44. order by c.company_id,u.user_id
  45. </select>
  46. <insert id="insertCompanyMoneyLogs" parameterType="CompanyMoneyLogs" useGeneratedKeys="true" keyProperty="logsId">
  47. insert into company_money_logs
  48. <trim prefix="(" suffix=")" suffixOverrides=",">
  49. <if test="companyId != null">company_id,</if>
  50. <if test="money != null">money,</if>
  51. <if test="balance != null">balance,</if>
  52. <if test="remark != null">remark,</if>
  53. <if test="createTime != null">create_time,</if>
  54. <if test="logsType != null">logs_type,</if>
  55. <if test="businessId != null">business_id,</if>
  56. </trim>
  57. <trim prefix="values (" suffix=")" suffixOverrides=",">
  58. <if test="companyId != null">#{companyId},</if>
  59. <if test="money != null">#{money},</if>
  60. <if test="balance != null">#{balance},</if>
  61. <if test="remark != null">#{remark},</if>
  62. <if test="createTime != null">#{createTime},</if>
  63. <if test="logsType != null">#{logsType},</if>
  64. <if test="businessId != null">#{businessId},</if>
  65. </trim>
  66. </insert>
  67. <update id="updateCompanyMoneyLogs" parameterType="CompanyMoneyLogs">
  68. update company_money_logs
  69. <trim prefix="SET" suffixOverrides=",">
  70. <if test="companyId != null">company_id = #{companyId},</if>
  71. <if test="money != null">money = #{money},</if>
  72. <if test="balance != null">balance = #{balance},</if>
  73. <if test="remark != null">remark = #{remark},</if>
  74. <if test="createTime != null">create_time = #{createTime},</if>
  75. <if test="logsType != null">logs_type = #{logsType},</if>
  76. <if test="businessId != null">business_id = #{businessId},</if>
  77. </trim>
  78. where logs_id = #{logsId}
  79. </update>
  80. <delete id="deleteCompanyMoneyLogsById" parameterType="Long">
  81. delete from company_money_logs where logs_id = #{logsId}
  82. </delete>
  83. <delete id="deleteCompanyMoneyLogsByIds" parameterType="String">
  84. delete from company_money_logs where logs_id in
  85. <foreach item="logsId" collection="array" open="(" separator="," close=")">
  86. #{logsId}
  87. </foreach>
  88. </delete>
  89. </mapper>