FsIntegralOrderMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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.his.mapper.FsIntegralOrderMapper">
  6. <resultMap type="FsIntegralOrder" id="FsIntegralOrderResult">
  7. <result property="orderId" column="order_id" />
  8. <result property="orderCode" column="order_code" />
  9. <result property="userId" column="user_id" />
  10. <result property="userName" column="user_name" />
  11. <result property="userPhone" column="user_phone" />
  12. <result property="userAddress" column="user_address" />
  13. <result property="itemJson" column="item_json" />
  14. <result property="integral" column="integral" />
  15. <result property="payMoney" column="pay_money" />
  16. <result property="isPay" column="is_pay" />
  17. <result property="payTime" column="pay_time" />
  18. <result property="payType" column="pay_type" />
  19. <result property="status" column="status" />
  20. <result property="deliveryCode" column="delivery_code" />
  21. <result property="deliveryName" column="delivery_name" />
  22. <result property="deliverySn" column="delivery_sn" />
  23. <result property="deliveryTime" column="delivery_time" />
  24. <result property="createTime" column="create_time" />
  25. <result property="remark" column="remark" />
  26. <result property="barCode" column="bar_code" />
  27. <result property="loginAccount" column="login_account" />
  28. </resultMap>
  29. <sql id="selectFsIntegralOrderVo">
  30. select order_id, order_code, user_id,bar_code, user_name, user_phone, user_address, item_json, integral,pay_money,is_pay,pay_time,pay_type, status, delivery_code, delivery_name, delivery_sn, delivery_time, create_time,qw_user_id,company_user_id,company_id,remark,login_account from fs_integral_order
  31. </sql>
  32. <select id="selectFsIntegralOrderList" parameterType="FsIntegralOrder" resultMap="FsIntegralOrderResult">
  33. <include refid="selectFsIntegralOrderVo"/>
  34. <where>
  35. <if test="orderCode != null and orderCode != ''"> and order_code = #{orderCode}</if>
  36. <if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
  37. <if test="userPhone != null and userPhone != ''"> and user_phone = #{userPhone}</if>
  38. <if test="integral != null and integral != ''"> and integral = #{integral}</if>
  39. <if test="payMoney != null and payMoney != ''"> and pay_money = #{payMoney}</if>
  40. <if test="isPay != null and isPay != ''"> and is_pay = #{isPay}</if>
  41. <if test="payTime != null and payTime != ''"> and pay_time = #{payTime}</if>
  42. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  43. <if test="status != null and status != ''"> and status = #{status}</if>
  44. <if test="deliverySn != null and deliverySn != ''"> and delivery_sn like concat('%', #{deliverySn}, '%')</if>
  45. <if test="qwUserId != null and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
  46. <if test="companyUserId != null and companyUserId != ''"> and company_user_id = #{companyUserId}</if>
  47. <if test="companyId != null and companyId != ''"> and company_id = #{companyId}</if>
  48. <if test="createTime != null "> and create_time = #{createTime}</if>
  49. </where>
  50. </select>
  51. <select id="selectFsIntegralOrderByOrderId" parameterType="Long" resultMap="FsIntegralOrderResult">
  52. <include refid="selectFsIntegralOrderVo"/>
  53. where order_id = #{orderId}
  54. </select>
  55. <select id="findOrderByIds" resultType="com.fs.his.domain.FsIntegralOrder">
  56. SELECT * FROM fs_integral_order
  57. WHERE order_id IN
  58. <foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
  59. #{orderId}
  60. </foreach>
  61. </select>
  62. <select id="selectFsIntegralOrderListJn" resultType="com.fs.his.vo.FsIntegralOrderListVO">
  63. SELECT
  64. fio.order_id,
  65. fio.order_code,
  66. fio.user_id,
  67. fio.user_name,
  68. fio.user_phone,
  69. fio.user_address,
  70. fio.item_json,
  71. fio.integral,
  72. fio.pay_money,
  73. fio.is_pay,
  74. fio.pay_time,
  75. fio.pay_type,
  76. fio.`STATUS`,
  77. fio.delivery_code,
  78. fio.delivery_name,
  79. fio.delivery_sn,
  80. fio.delivery_time,
  81. fio.create_time,
  82. fio.qw_user_id,
  83. fio.company_user_id,
  84. fio.company_id,
  85. fio.remark,
  86. fio.login_account,
  87. fiod.erp_phone
  88. FROM
  89. fs_integral_order fio
  90. LEFT JOIN fs_integral_order_df fiod
  91. ON fiod.order_id = fio.order_id
  92. WHERE
  93. 1 = 1
  94. <!-- 订单编码精确查询 -->
  95. <if test="orderCode != null and orderCode != ''"> AND fio.order_code = #{orderCode} </if>
  96. <!-- 用户名模糊查询 -->
  97. <if test="userName != null and userName != ''"> AND fio.user_name LIKE CONCAT('%', #{userName}, '%') </if>
  98. <!-- 用户手机号精确查询 -->
  99. <if test="userPhone != null and userPhone != ''"> AND fio.user_phone = #{userPhone} </if>
  100. <!-- 积分精确查询 -->
  101. <if test="integral != null and integral != ''"> AND fio.integral = #{integral} </if>
  102. <!-- 支付金额精确查询 -->
  103. <if test="payMoney != null and payMoney != ''"> AND fio.pay_money = #{payMoney} </if>
  104. <!-- 支付状态精确查询 -->
  105. <if test="isPay != null and isPay != ''"> AND fio.is_pay = #{isPay} </if>
  106. <!-- 支付时间精确查询 -->
  107. <if test="payTime != null and payTime != ''"> AND fio.pay_time = #{payTime} </if>
  108. <!-- 支付类型精确查询 -->
  109. <if test="payType != null and payType != ''"> AND fio.pay_type = #{payType} </if>
  110. <!-- 订单状态精确查询 -->
  111. <if test="status != null and status != ''"> AND fio.status = #{status} </if>
  112. <!-- 快递单号模糊查询 -->
  113. <if test="deliverySn != null and deliverySn != ''"> AND fio.delivery_sn LIKE CONCAT('%', #{deliverySn}, '%') </if>
  114. <!-- 企微用户ID精确查询 -->
  115. <if test="qwUserId != null and qwUserId != ''"> AND fio.qw_user_id = #{qwUserId} </if>
  116. <!-- 公司用户ID精确查询 -->
  117. <if test="companyUserId != null and companyUserId != ''"> AND fio.company_user_id = #{companyUserId} </if>
  118. <!-- 公司ID精确查询 -->
  119. <if test="companyId != null and companyId != ''"> AND fio.company_id = #{companyId} </if>
  120. <!-- 创建时间范围查询(开始时间) -->
  121. <if test="sTime != null"> AND DATE(fio.create_time) &gt;= DATE(#{sTime}) </if>
  122. <!-- 创建时间范围查询(结束时间) -->
  123. <if test="eTime != null"> AND DATE(fio.create_time) &lt;= DATE(#{eTime}) </if>
  124. <if test="loginAccount != null and loginAccount !=''"> AND fio.login_account = #{loginAccount} </if>
  125. <if test="isPush != null"> AND COALESCE(fiod.is_push, 0) = 0 </if>
  126. ORDER BY
  127. fio.order_id DESC
  128. </select>
  129. <insert id="insertFsIntegralOrder" parameterType="FsIntegralOrder" useGeneratedKeys="true" keyProperty="orderId">
  130. insert into fs_integral_order
  131. <trim prefix="(" suffix=")" suffixOverrides=",">
  132. <if test="orderCode != null">order_code,</if>
  133. <if test="userId != null">user_id,</if>
  134. <if test="userName != null">user_name,</if>
  135. <if test="userPhone != null">user_phone,</if>
  136. <if test="userAddress != null">user_address,</if>
  137. <if test="itemJson != null">item_json,</if>
  138. <if test="integral != null">integral,</if>
  139. <if test="payMoney != null">pay_money,</if>
  140. <if test="isPay != null">is_pay,</if>
  141. <if test="payTime != null">pay_time,</if>
  142. <if test="payType != null">pay_type,</if>
  143. <if test="status != null and status != ''">status,</if>
  144. <if test="deliveryCode != null">delivery_code,</if>
  145. <if test="deliveryName != null">delivery_name,</if>
  146. <if test="deliverySn != null">delivery_sn,</if>
  147. <if test="deliveryTime != null">delivery_time,</if>
  148. <if test="createTime != null">create_time,</if>
  149. <if test="remark != null">remark,</if>
  150. <if test="barCode != null">bar_code,</if>
  151. <if test="qwUserId != null">qw_user_id,</if>
  152. <if test="companyUserId != null">company_user_id,</if>
  153. <if test="companyId != null">company_id,</if>
  154. </trim>
  155. <trim prefix="values (" suffix=")" suffixOverrides=",">
  156. <if test="orderId != null">#{orderId},</if>
  157. <if test="orderCode != null">#{orderCode},</if>
  158. <if test="userId != null">#{userId},</if>
  159. <if test="userName != null">#{userName},</if>
  160. <if test="userPhone != null">#{userPhone},</if>
  161. <if test="userAddress != null">#{userAddress},</if>
  162. <if test="itemJson != null">#{itemJson},</if>
  163. <if test="integral != null">#{integral},</if>
  164. <if test="payMoney != null">#{payMoney},</if>
  165. <if test="isPay != null">#{isPay},</if>
  166. <if test="payTime != null">#{payTime},</if>
  167. <if test="payType != null">#{payType},</if>
  168. <if test="status != null and status != ''">#{status},</if>
  169. <if test="deliveryCode != null">#{deliveryCode},</if>
  170. <if test="deliveryName != null">#{deliveryName},</if>
  171. <if test="deliverySn != null">#{deliverySn},</if>
  172. <if test="deliveryTime != null">#{deliveryTime},</if>
  173. <if test="createTime != null">#{createTime},</if>
  174. <if test="remark != null">#{remark},</if>
  175. <if test="barCode != null">#{barCode},</if>
  176. <if test="qwUserId != null">#{qwUserId},</if>
  177. <if test="companyUserId != null">#{companyUserId},</if>
  178. <if test="companyId != null">#{companyId},</if>
  179. </trim>
  180. </insert>
  181. <update id="updateFsIntegralOrder" parameterType="FsIntegralOrder">
  182. update fs_integral_order
  183. <trim prefix="SET" suffixOverrides=",">
  184. <if test="orderCode != null">order_code = #{orderCode},</if>
  185. <if test="userId != null">user_id = #{userId},</if>
  186. <if test="userName != null">user_name = #{userName},</if>
  187. <if test="userPhone != null">user_phone = #{userPhone},</if>
  188. <if test="userAddress != null">user_address = #{userAddress},</if>
  189. <if test="itemJson != null">item_json = #{itemJson},</if>
  190. <if test="integral != null">integral = #{integral},</if>
  191. <if test="payMoney != null">pay_money = #{payMoney},</if>
  192. <if test="isPay != null">is_pay = #{isPay},</if>
  193. <if test="payTime != null">pay_time = #{payTime},</if>
  194. <if test="payType != null">pay_type = #{payType},</if>
  195. <if test="status != null and status != ''">status = #{status},</if>
  196. <if test="deliveryCode != null">delivery_code = #{deliveryCode},</if>
  197. <if test="deliveryName != null">delivery_name = #{deliveryName},</if>
  198. <if test="deliverySn != null">delivery_sn = #{deliverySn},</if>
  199. <if test="deliveryTime != null">delivery_time = #{deliveryTime},</if>
  200. <if test="createTime != null">create_time = #{createTime},</if>
  201. <if test="remark != null">remark = #{remark},</if>
  202. <if test="barCode != null">bar_code = #{barCode},</if>
  203. <if test="loginAccount != '' and loginAccount != null">login_account = #{loginAccount},</if>
  204. </trim>
  205. where order_id = #{orderId}
  206. </update>
  207. <delete id="deleteFsIntegralOrderByOrderId" parameterType="Long">
  208. delete from fs_integral_order where order_id = #{orderId}
  209. </delete>
  210. <delete id="deleteFsIntegralOrderByOrderIds" parameterType="String">
  211. delete from fs_integral_order where order_id in
  212. <foreach item="orderId" collection="array" open="(" separator="," close=")">
  213. #{orderId}
  214. </foreach>
  215. </delete>
  216. <update id="cancelOrder" parameterType="FsIntegralOrder">
  217. update fs_integral_order set status = -1
  218. where order_id = #{orderId}
  219. </update>
  220. <update id="finishOrder">
  221. UPDATE fs_integral_order
  222. SET status = 3
  223. WHERE order_id = #{orderId}
  224. AND status = #{oldStatus}
  225. </update>
  226. </mapper>