ContractMapper.xml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. buy_corporation_id = #{customerId}
  24. ) t1
  25. WHERE t1.sumPackQuantity &lt; t1.cpQuantity
  26. AND t1.`status` &gt;=30 &lt;999
  27. GROUP BY t1.id
  28. </select>
  29. <select id="getNoPackContractProductById" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
  30. SELECT
  31. *
  32. FROM
  33. (
  34. SELECT
  35. t1.*,
  36. t2.quantity AS cpQuantity,
  37. t2.id AS contractProductId,
  38. ( SELECT IFNULL( SUM( quantity ), 0 ) FROM pack_detail_product WHERE contract_product_id = t2.id ) AS sumPackQuantity
  39. FROM
  40. contract t1
  41. LEFT JOIN contract_product t2 ON t1.id = t2.contract_id
  42. WHERE
  43. buy_corporation_id = #{customerId}
  44. ) t1
  45. WHERE t1.sumPackQuantity &lt; t1.cpQuantity
  46. AND t1.id = #{contractId}
  47. </select>
  48. </mapper>