OrderFundMapper.xml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.dayou.mapper.OrderFundMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.OrderFund">
  6. <result column="id" property="id" />
  7. <result column="deleted" property="deleted" />
  8. <result column="created" property="created" />
  9. <result column="modified" property="modified" />
  10. <result column="business_type" property="businessType" />
  11. <result column="business_id" property="businessId" />
  12. <result column="should_amount" property="shouldAmount" />
  13. <result column="real_amount" property="realAmount" />
  14. <result column="remark" property="remark" />
  15. </resultMap>
  16. <!-- 通用查询结果列 -->
  17. <sql id="Base_Column_List">
  18. id,
  19. deleted,
  20. created,
  21. modified,
  22. business_type, business_id, should_amount, real_amount, remark
  23. </sql>
  24. <update id="updateRealAmount">
  25. update order_fund set real_amount = (ifnull(real_amount,0) + #{thisTimeAmount}) where id = #{id}
  26. </update>
  27. <update id="updateRealAmountByOrderId">
  28. update order_fund set real_amount = (ifnull(real_amount,0) + #{thisTimeAmount}) where order_id = #{orderId} and deleted = 0
  29. </update>
  30. <select id="residueNotAllotAmount" parameterType="java.lang.Long" resultType="java.math.BigDecimal">
  31. SELECT (`of`.real_amount - (SELECT IFNULL(SUM(real_amount), 0) AS ca
  32. FROM production_fund
  33. WHERE deleted = 0 AND order_fund_id = #{orderFundId})
  34. ) AS notClaimAmount
  35. FROM order_fund `of`
  36. WHERE `of`.id = #{orderFundId}
  37. AND `of`.deleted = 0
  38. </select>
  39. <!--更新折扣比例-->
  40. <update id="updateDiscountByOrderIdAfter">
  41. UPDATE order_fund
  42. SET discount = order_fund.real_amount / order_fund.should_amount
  43. WHERE id = #{orderFundId}
  44. </update>
  45. <select id="getAllOrderFund" resultType="com.dayou.entity.OrderFund">
  46. SELECT
  47. off.*,
  48. mp.report_no,
  49. mp.production,
  50. mp.standard_amount
  51. FROM
  52. order_fund off
  53. LEFT JOIN ( SELECT * FROM major_production WHERE deleted = 0 AND production = 'REPORT' ) mp ON mp.major_id = off.business_id
  54. WHERE
  55. off.business_type = 'MAJOR_BUSINESS'
  56. AND off.real_amount IS NOT NULL
  57. AND mp.report_no IS NOT NULL
  58. </select>
  59. </mapper>