NewShouldPayMapper.xml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.caimei.modules.order.dao.NewShouldPayDao">
  4. <sql id="shouldPayColumns">
  5. co.orderID AS "orderId",
  6. co.orderNo AS "orderNo",
  7. co.orderTime AS "orderTime",
  8. co.status AS "status",
  9. co.userID AS "userId",
  10. co.clubID AS "clubId",
  11. co.orderSubmitType AS "orderTypeShow",
  12. co.orderType AS "orderTypeSys",
  13. co.payTotalFee AS "payTotalFee",
  14. (SELECT IFNULL(sum(shouldPayFee),0) FROM cm_order_product WHERE orderId=co.orderID) AS "shouldPayProduct",
  15. (SELECT IFNULL(sum(shouldPayFee),0) FROM cm_order_product WHERE orderId=co.orderID AND payStatus=2) AS "received",
  16. (SELECT IFNULL(count(1),0) FROM cm_order_product WHERE orderID=co.orderID) AS "productTypeNum" ,
  17. (SELECT IFNULL(count(1),0) FROM cm_new_finance_charge WHERE orderSequence like CONCAT(co.orderNo,'%') and status=2) AS "applyPayProductNum",
  18. bou.province AS "province",
  19. bou.city AS "city",
  20. bou.town AS "town",
  21. bou.name AS "clubName",
  22. bou.address AS "clubAddress",
  23. bou.mobile AS "clubMobile"
  24. </sql>
  25. <select id="get" resultType="newShouldPay">
  26. SELECT
  27. <include refid="shouldPayColumns"/>
  28. FROM cm_order co
  29. LEFT JOIN club c ON c.clubID = co.clubID
  30. LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
  31. WHERE co.orderID = #{orderId}
  32. </select>
  33. <select id="findList" resultType="newShouldPay">
  34. SELECT
  35. <include refid="shouldPayColumns"/>
  36. FROM cm_order co
  37. LEFT JOIN club c ON c.clubID = co.clubID
  38. LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
  39. <where>
  40. <if test="orderId != null and orderId != ''">
  41. AND co.orderID = #{orderId}
  42. </if>
  43. <if test="orderTypeSys != null and orderTypeSys != ''">
  44. AND co.orderType = #{orderTypeSys}
  45. </if>
  46. <if test="orderNo != null and orderNo != ''">
  47. AND co.orderNo LIKE concat('%',#{orderNo},'%')
  48. </if>
  49. <if test="clubName != null and clubName != ''">
  50. AND c.name LIKE concat('%',#{clubName},'%')
  51. </if>
  52. <if test="startTime != null and startTime != ''">
  53. AND co.orderTime <![CDATA[ >= ]]> #{startTime}
  54. </if>
  55. <if test="endTime != null and endTime != ''">
  56. AND co.orderTime <![CDATA[ <= ]]> #{endTime}
  57. </if>
  58. AND co.delFlag = 0
  59. AND co.status != 6
  60. AND (co.confirmFlag = 1 OR co.confirmFlag = 2)
  61. </where>
  62. <choose>
  63. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  64. ORDER BY ${page.orderBy}
  65. </when>
  66. <otherwise>
  67. ORDER BY co.orderID DESC,co.orderTime DESC
  68. </otherwise>
  69. </choose>
  70. </select>
  71. </mapper>