TbBusinessMapper.xml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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.pj.project.tb_business.TbBusinessMapper">
  4. <update id="unBindCar">
  5. update tb_business set card_no='',china_car_no='',business_car_id=null where id=#{id}
  6. </update>
  7. <!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
  8. <select id="getList" resultType="com.pj.project.tb_business.TbBusiness">
  9. select * from tb_business
  10. <where>
  11. <if test=' this.has("id") '>and id = #{id}</if>
  12. <if test=' this.has("customerId") '>and customer_id = #{customerId}</if>
  13. <if test=' this.has("customerName") '>and customer_name like concat('%', #{customerName} ,'%')</if>
  14. <if test=' this.has("owner") '>and owner like concat('%', #{owner} ,'%')</if>
  15. <if test=' this.has("no") '>and no like concat('%', #{no},'%')</if>
  16. <if test=' this.has("cardNo") '>and card_no like concat('%', #{cardNo} ,'%')</if>
  17. <if test=' this.has("cardSize") '>and card_size = #{cardSize}</if>
  18. <if test=' this.has("netWeight") '>and net_weight = #{netWeight}</if>
  19. <if test=' this.has("goodsId") '>and goods_id = #{goodsId}</if>
  20. <if test=' this.has("goodsName") '>and goods_name = #{goodsName}</if>
  21. <if test=' this.has("goodsCode") '>and goods_code = #{goodsCode}</if>
  22. <if test=' this.has("driverName") '>and driver_name like concat('%', #{driverName} ,'%')</if>
  23. <if test=' this.has("driverId") '>and driver_id = #{driverId}</if>
  24. <if test=' this.has("driverPhone") '>and driver_phone = #{driverPhone}</if>
  25. <if test=' this.has("driverIdCard") '>and driver_id_card like concat('%', #{driverIdCard} ,'%')</if>
  26. <if test=' this.has("expectInDay") '>and expect_in_day = #{expectInDay}</if>
  27. <if test=' this.has("realInDay") '>and real_in_day = #{realInDay}</if>
  28. <if test=' this.has("realInTime") '>and real_in_time = #{realInTime}</if>
  29. <if test=' this.has("payStatus") '>and pay_status = #{payStatus}</if>
  30. <if test=' this.has("payTime") '>and pay_time = #{payTime}</if>
  31. <if test=' this.has("payType") '>and pay_type = #{payType}</if>
  32. <if test=' this.has("outDayTime") '>and out_day_time = #{outDayTime}</if>
  33. <if test=' this.has("partMoney") '>and part_money = #{partMoney}</if>
  34. <if test=' this.has("supplement") '>and supplement = #{supplement}</if>
  35. <if test=' this.has("error") '>and pay_time is null</if>
  36. <if test=' this.has("partTime") '>and part_time = #{partTime}</if>
  37. <if test=' this.has("createTime") '>and date_format(create_time,'%Y-%m-%d') = #{createTime}</if>
  38. <if test=' this.has("businessType") '>and business_type = #{businessType}</if>
  39. <if test=' this.has("businessCarId") '>and business_car_id = #{businessCarId}</if>
  40. <if test=' this.has("createByCustomerId") '>and create_by_customer_id = #{createByCustomerId}</if>
  41. <if test=' this.has("carNo") '>and (card_no like concat('%', #{carNo},'%') or china_car_no like concat('%', #{carNo},'%'))</if>
  42. <if test='adminConfirmInput !=null and adminConfirmInput>-1'>and admin_confirm_input = #{adminConfirmInput}</if>
  43. <if test='isCar==0'>
  44. and declare_no is not null
  45. </if>
  46. <if test='isCar==1'>
  47. and (declare_no is null or declare_no='')
  48. </if>
  49. <if test=' this.has("current") '>
  50. <if test=' current == 3 '>and real_in_time is not null and out_day_time is not null</if>
  51. <if test=' current == 2 '>and real_in_time is not null and out_day_time is null</if>
  52. <if test=' current == 1 '>and real_in_time is null and out_day_time is null</if>
  53. </if>
  54. </where>
  55. order by
  56. <choose>
  57. <when test='sortType == 1'>id desc</when>
  58. <when test='sortType == 2'>customer_id desc</when>
  59. <when test='sortType == 3'>customer_name desc</when>
  60. <when test='sortType == 4'>no desc</when>
  61. <when test='sortType == 5'>card_no desc</when>
  62. <when test='sortType == 6'>card_size desc</when>
  63. <when test='sortType == 7'>net_weight desc</when>
  64. <when test='sortType == 8'>goods_name desc</when>
  65. <when test='sortType == 9'>goods_code desc</when>
  66. <when test='sortType == 10'>driver_name desc</when>
  67. <when test='sortType == 11'>driver_id desc</when>
  68. <when test='sortType == 12'>driver_phone desc</when>
  69. <when test='sortType == 13'>driver_id_card desc</when>
  70. <when test='sortType == 14'>expect_in_day desc</when>
  71. <when test='sortType == 15'>real_in_day desc</when>
  72. <when test='sortType == 16'>real_in_time desc</when>
  73. <when test='sortType == 17'>pay_status desc</when>
  74. <when test='sortType == 18'>pay_time desc</when>
  75. <when test='sortType == 19'>pay_type desc</when>
  76. <when test='sortType == 20'>out_day_time desc</when>
  77. <when test='sortType == 21'>part_money desc</when>
  78. <when test='sortType == 22'>part_time desc</when>
  79. <when test='sortType == 23'>supplement_time desc</when>
  80. <otherwise>id desc</otherwise>
  81. </choose>
  82. </select>
  83. <select id="getCarDisincleList" resultType="com.pj.project.tb_business.CarDisincle">
  84. SELECT
  85. a.id,
  86. b.id as businessCarId,
  87. a.`no`,a.operate_time,
  88. a.item_price,a.goods_name,a.admin_confirm_input,b.car_no,
  89. b.base_part_money,a.total_money,a.pay_money,a.create_time,
  90. b.real_in_time,b.real_out_time,b.car_no ,a.net_weight,a.card_size,a.pay_status,a.item_type_name
  91. from tb_business a,tb_business_car b
  92. WHERE a.business_car_id=b.id and (a.declare_no='' or a.declare_no is null)
  93. <if test="cardNo !='' and cardNo !=null">
  94. and b.car_no like concat('%',#{cardNo},'%')
  95. </if>
  96. <if test="no !='' and no !=null">
  97. and a.no like concat('%',#{no},'%')
  98. </if>
  99. <if test="adminConfirmInput !='-1'">
  100. and a.admin_confirm_input=#{adminConfirmInput}
  101. </if>
  102. <if test="customerId !=null and customerId !=''">
  103. and a.customer_id=#{customerId}
  104. </if>
  105. <if test="businessCarId !=null and businessCarId !=''">
  106. and a.business_car_id=#{businessCarId}
  107. </if>
  108. <if test="carNo !=null and carNo !=''">
  109. and b.car_no like concat ('%',#{carNo},'%')
  110. </if>
  111. ORDER BY a.create_time desc
  112. </select>
  113. <select id="checkCarBusinessType" resultType="java.lang.Integer">
  114. SELECT
  115. count(a.id)
  116. FROM
  117. tb_business_car a,
  118. relation_business_car b,
  119. tb_business c,
  120. tb_business_item d
  121. WHERE
  122. a.id = b.business_car_id
  123. and b.business_id=c.id
  124. and c.id=d.business_id
  125. AND a.car_no =#{carNo}
  126. and d.item_type_id=#{typeId}
  127. <if test="before==1">
  128. AND DATE_FORMAT( c.operate_time, '%Y-%m-%d %H:%i:%s' ) &lt; #{operateTime}
  129. </if>
  130. <if test="before==0">
  131. AND DATE_FORMAT( c.operate_time, '%Y-%m-%d %H:%i:%s' ) &gt; #{operateTime}
  132. </if>
  133. </select>
  134. <select id="checkCarBusinessTypeByTime" resultType="java.lang.Integer">
  135. SELECT
  136. count(b.id)
  137. FROM
  138. tb_business_car a,
  139. relation_business_car b,
  140. tb_business c,
  141. tb_business_item d
  142. WHERE
  143. a.id = b.business_car_id
  144. and b.business_id=c.id
  145. and c.id=d.business_id
  146. AND a.car_no =#{carNo}
  147. and d.item_type_id=#{typeId}
  148. AND DATE_FORMAT( c.operate_time, '%Y-%m-%d %H:%i:%s' ) &gt; #{timeStart}
  149. and DATE_FORMAT( c.operate_time, '%Y-%m-%d %H:%i:%s' ) &lt; #{timeEnd}
  150. <if test="businessId!=null and businessId !=''">
  151. and c.id !=#{businessId}
  152. </if>
  153. </select>
  154. <resultMap id="otherBusinessMap" type="com.pj.project.tb_business.TbBusiness">
  155. <result property="id" column="id"/>
  156. <result property="cardNo" column="card_no"/>
  157. <result property="chinaCarNo" column="china_car_no"/>
  158. <result property="no" column="no"/>
  159. <result property="createTime" column="create_time"/>
  160. <result property="customerName" column="customer_name"/>
  161. <result property="goodsName" column="goods_name"/>
  162. <result property="adminConfirmInput" column="admin_confirm_input"/>
  163. <result property="itemPrice" column="item_price"/>
  164. <result property="payMoney" column="pay_money"/>
  165. <result property="operateTime" column="operate_time"/>
  166. <collection property="items" ofType="com.pj.project.tb_item.TbItem" select="getItems" column="id"/>
  167. </resultMap>
  168. <select id="getOtherBusiness" resultType="com.pj.project.tb_business.TbBusiness">
  169. select * from tb_business
  170. <trim prefix="where" prefixOverrides="and||or">
  171. <if test="customerId !=null and customerId !=''">
  172. and customer_id=#{customerId}
  173. </if>
  174. <if test="carNo !=null and carNo !=''">
  175. and (card_no like concat('%',#{carNo},'%') or china_car_no like concat('%',#{carNo},'%'))
  176. </if>
  177. </trim>
  178. order by create_time desc
  179. </select>
  180. <select id="getItems" resultType="com.pj.project.tb_item.TbItem">
  181. select * from tb_item where business_id=#{id}
  182. </select>
  183. <select id="findOtherBusinessByCarId" resultType="com.pj.project.tb_business.TbBusiness">
  184. select distinct a.*
  185. from tb_business a,relation_business_car b
  186. where a.id=b.business_id
  187. and b.business_car_id=#{businessCarId}
  188. </select>
  189. </mapper>