ContractMapper.xml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.fjhx.sale.mapper.contract.ContractMapper">
  4. <select id="getPage" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
  5. select
  6. *
  7. from contract
  8. ${ew.customSqlSegment}
  9. </select>
  10. <select id="getNoPackContractByCustomerId" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
  11. SELECT
  12. *
  13. FROM
  14. (
  15. SELECT
  16. t1.*,
  17. t2.quantity AS cpQuantity,
  18. ( SELECT IFNULL( SUM( quantity ), 0 ) FROM pack_detail_product WHERE contract_product_id = t2.id ) AS sumPackQuantity
  19. FROM
  20. contract t1
  21. LEFT JOIN contract_product t2 ON t1.id = t2.contract_id
  22. <where>
  23. <if test="customerId neq null and customerId neq '' ">
  24. buy_corporation_id = #{customerId}
  25. </if>
  26. </where>
  27. ) t1
  28. WHERE t1.sumPackQuantity &lt; t1.cpQuantity
  29. AND t1.`status` &gt;=30
  30. AND t1.`status` &lt;999
  31. GROUP BY t1.id
  32. </select>
  33. <select id="getNoPackContractProductById" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
  34. SELECT
  35. *
  36. FROM
  37. (
  38. SELECT
  39. t1.*,
  40. t2.quantity AS cpQuantity,
  41. t2.id AS contractProductId,
  42. ( SELECT IFNULL( SUM( quantity ), 0 ) FROM pack_detail_product WHERE contract_product_id = t2.id ) AS sumPackQuantity
  43. FROM
  44. contract t1
  45. LEFT JOIN contract_product t2 ON t1.id = t2.contract_id
  46. <where>
  47. <if test="customerId neq null and customerId neq '' ">
  48. buy_corporation_id = #{customerId}
  49. </if>
  50. </where>
  51. ) t1
  52. WHERE t1.sumPackQuantity &lt; t1.cpQuantity
  53. AND t1.id = #{contractId}
  54. </select>
  55. </mapper>