InvoiceMapper.xml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.fdkankan.order.mapper.IInvoiceMapper">
  4. <resultMap id="resultMap" type="com.fdkankan.order.entity.Invoice">
  5. <id column="id" jdbcType="VARCHAR" property="id" />
  6. <result column="order_id" jdbcType="VARCHAR" property="orderId" />
  7. <result column="virtual_order_id" jdbcType="VARCHAR" property="virtualOrderId" />
  8. <result column="increment_order_id" jdbcType="VARCHAR" property="incrementOrderId" />
  9. <result column="user_id" jdbcType="VARCHAR" property="userId" />
  10. <result column="type" jdbcType="INTEGER" property="type" />
  11. <result column="title" jdbcType="VARCHAR" property="title" />
  12. <result column="code" jdbcType="VARCHAR" property="code" />
  13. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  14. <result column="organized_name" jdbcType="VARCHAR" property="organizedName" />
  15. <result column="organized_address" jdbcType="VARCHAR" property="organizedAddress" />
  16. <result column="register_phone" jdbcType="VARCHAR" property="registerPhone" />
  17. <result column="bank_name" jdbcType="VARCHAR" property="bankName" />
  18. <result column="bank_account" jdbcType="VARCHAR" property="bankAccount" />
  19. <result column="consume_type" jdbcType="INTEGER" property="consumeType" />
  20. <result column="money" jdbcType="DECIMAL" property="money" />
  21. <result column="camera_id" jdbcType="VARCHAR" property="cameraId" />
  22. <result column="finish" jdbcType="INTEGER" property="finish" />
  23. <result column="email_address" jdbcType="VARCHAR" property="emailAddress" />
  24. <result column="rec_status" jdbcType="VARCHAR" property="recStatus" />
  25. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  26. <result column="ship_address" jdbcType="VARCHAR" property="shipAddress" />
  27. <result column="ship_area" jdbcType="VARCHAR" property="shipArea" />
  28. <result column="ship_area_path" jdbcType="VARCHAR" property="shipAreaPath" />
  29. <result column="ship_mobile" jdbcType="VARCHAR" property="shipMobile" />
  30. <result column="ship_name" jdbcType="VARCHAR" property="shipName" />
  31. <result column="ship_phone" jdbcType="VARCHAR" property="shipPhone" />
  32. <result column="ship_zip_code" jdbcType="VARCHAR" property="shipZipCode" />
  33. <result column="send" jdbcType="INTEGER" property="send" />
  34. <result column="express_company" jdbcType="VARCHAR" property="expressCompany" />
  35. <result column="express_number" jdbcType="VARCHAR" property="expressNumber" />
  36. <result column="e_invoice" jdbcType="VARCHAR" property="eInvoice" />
  37. <result column="remarks" jdbcType="LONGVARCHAR" property="remarks" />
  38. <result column="download_order_id" jdbcType="VARCHAR" property="downloadOrderId" />
  39. <result column="tb_status" jdbcType="INTEGER" property="tbStatus" />
  40. </resultMap>
  41. <sql id="columnList">
  42. id,order_id,virtual_order_id,increment_order_id,user_id,type,title,code,create_time,organized_name,organized_address,register_phone,bank_name,bank_account,consume_type,money,camera_id,finish,email_address,rec_status,update_time,ship_address,ship_area,ship_area_path,ship_mobile,ship_name,ship_phone,ship_zip_code,send,express_company,express_number,e_invoice,remarks,download_order_id,tb_status </sql>
  43. <insert id="insert" useGeneratedKeys="true" keyProperty="entity.id">
  44. INSERT INTO ${tableName} (
  45. order_id, virtual_order_id, increment_order_id, user_id, type, title, code, organized_name, organized_address, register_phone, bank_name, bank_account, consume_type, money, camera_id, finish, email_address, rec_status, ship_address, ship_area, ship_area_path, ship_mobile, ship_name, ship_phone, ship_zip_code, send, express_company, express_number, e_invoice, remarks, download_order_id
  46. ) VALUES (
  47. #{entity.orderId}, #{entity.virtualOrderId}, #{entity.incrementOrderId}, #{entity.userId}, #{entity.type}, #{entity.title}, #{entity.code}, #{entity.organizedName}, #{entity.organizedAddress}, #{entity.registerPhone}, #{entity.bankName}, #{entity.bankAccount}, #{entity.consumeType}, #{entity.money}, #{entity.cameraId}, #{entity.finish}, #{entity.emailAddress}, #{entity.recStatus}, #{entity.shipAddress}, #{entity.shipArea}, #{entity.shipAreaPath}, #{entity.shipMobile}, #{entity.shipName}, #{entity.shipPhone}, #{entity.shipZipCode}, #{entity.send}, #{entity.expressCompany}, #{entity.expressNumber}, #{entity.eInvoice}, #{entity.remarks}, #{entity.downloadOrderId}
  48. ) </insert>
  49. <insert id="insertByBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id" >
  50. INSERT INTO ${tableName} (
  51. order_id, virtual_order_id, increment_order_id, user_id, type, title, code, organized_name, organized_address, register_phone, bank_name, bank_account, consume_type, money, camera_id, finish, email_address, rec_status, ship_address, ship_area, ship_area_path, ship_mobile, ship_name, ship_phone, ship_zip_code, send, express_company, express_number, e_invoice, remarks, download_order_id
  52. ) VALUES
  53. <foreach collection="list" item="entity" index="index" separator=",">
  54. (#{entity.orderId}, #{entity.virtualOrderId}, #{entity.incrementOrderId}, #{entity.userId}, #{entity.type}, #{entity.title}, #{entity.code}, #{entity.organizedName}, #{entity.organizedAddress}, #{entity.registerPhone}, #{entity.bankName}, #{entity.bankAccount}, #{entity.consumeType}, #{entity.money}, #{entity.cameraId}, #{entity.finish}, #{entity.emailAddress}, #{entity.recStatus}, #{entity.shipAddress}, #{entity.shipArea}, #{entity.shipAreaPath}, #{entity.shipMobile}, #{entity.shipName}, #{entity.shipPhone}, #{entity.shipZipCode}, #{entity.send}, #{entity.expressCompany}, #{entity.expressNumber}, #{entity.eInvoice}, #{entity.remarks}, #{entity.downloadOrderId})
  55. </foreach>
  56. </insert>
  57. <update id="update" parameterType="java.util.List" >
  58. <foreach collection="list" item="entity" index="index" separator=";">
  59. UPDATE ${tableName} SET
  60. order_id=#{entity.orderId}, virtual_order_id=#{entity.virtualOrderId}, increment_order_id=#{entity.incrementOrderId}, user_id=#{entity.userId}, type=#{entity.type}, title=#{entity.title}, code=#{entity.code}, organized_name=#{entity.organizedName}, organized_address=#{entity.organizedAddress}, register_phone=#{entity.registerPhone}, bank_name=#{entity.bankName}, bank_account=#{entity.bankAccount}, consume_type=#{entity.consumeType}, money=#{entity.money}, camera_id=#{entity.cameraId}, finish=#{entity.finish}, email_address=#{entity.emailAddress}, rec_status=#{entity.recStatus}, ship_address=#{entity.shipAddress}, ship_area=#{entity.shipArea}, ship_area_path=#{entity.shipAreaPath}, ship_mobile=#{entity.shipMobile}, ship_name=#{entity.shipName}, ship_phone=#{entity.shipPhone}, ship_zip_code=#{entity.shipZipCode}, send=#{entity.send}, express_company=#{entity.expressCompany}, express_number=#{entity.expressNumber}, e_invoice=#{entity.eInvoice}, remarks=#{entity.remarks}, download_order_id=#{entity.downloadOrderId}, tb_status=#{entity.tbStatus}
  61. WHERE
  62. id = #{entity.id}
  63. </foreach>
  64. </update>
  65. <update id="updateByBatch" >
  66. UPDATE ${tableName} SET
  67. ${field}
  68. <where>
  69. <foreach collection="condition" index="key" item="value">
  70. ${value} ${key}
  71. </foreach>
  72. </where>
  73. </update>
  74. <select id="getById" parameterType="java.lang.Integer" resultMap="resultMap">
  75. select
  76. <include refid="columnList" />
  77. from ${tableName}
  78. where id = #{id}
  79. </select>
  80. <select id="getOne" parameterType="java.util.Map" resultMap="resultMap">
  81. select
  82. <if test="field == null">
  83. <include refid="columnList" />
  84. </if>
  85. <if test="field != null">
  86. ${field}
  87. </if>
  88. from ${tableName}
  89. <where>
  90. <foreach collection="condition" index="key" item="value">
  91. ${value} ${key}
  92. </foreach>
  93. </where>
  94. limit 1;
  95. </select>
  96. <select id="getCount" parameterType="java.util.Map" resultType="java.lang.Integer">
  97. select
  98. count(id)
  99. from ${tableName}
  100. <where>
  101. <foreach collection="condition" index="key" item="value">
  102. ${value} ${key}
  103. </foreach>
  104. </where>
  105. </select>
  106. <!-- 这部分为根据传递参数,自动生成SQL -->
  107. <select id="getList" parameterType="java.util.Map" resultMap="resultMap">
  108. select
  109. <if test="field == null">
  110. <include refid="columnList" />
  111. </if>
  112. <if test="field != null">
  113. ${field}
  114. </if>
  115. from ${tableName}
  116. <where>
  117. <foreach collection="condition" index="key" item="value">
  118. ${value} ${key}
  119. </foreach>
  120. </where>
  121. <if test="order != null">
  122. order by ${order}
  123. </if>
  124. <if test="limit != 0">
  125. <if test="offset != 0">
  126. limit ${offset}, ${limit}
  127. </if>
  128. <if test="offset == 0">
  129. limit ${limit}
  130. </if>
  131. </if>
  132. </select>
  133. <!-- 判断表格是否存在,如果不存在可以配合createTable使用,用于动态创建表格 -->
  134. <select id="existTable" parameterType="String" resultType="java.lang.Integer">
  135. select count(table_name) from information_schema.TABLES WHERE table_name=#{tableName} ;
  136. </select>
  137. <update id="createTable" parameterType="String">
  138. <!-- 这里是创建表格的SQL,复制过来,表名作为参数传递 -->
  139. <!-- create table ${tableName} ( // 表名要这样写 -->
  140. </update>
  141. </mapper>