UserBillingMapper.java 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package com.ruoyi.system.mapper;
  2. import java.util.List;
  3. import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4. import com.ruoyi.system.domain.UserBilling;
  5. import com.ruoyi.system.domain.vo.BillDTO;
  6. import com.ruoyi.system.domain.vo.ShBillingDto;
  7. import org.apache.ibatis.annotations.Param;
  8. import org.apache.ibatis.annotations.Select;
  9. /**
  10. * BillingMapper接口
  11. *
  12. * @author ruoyi
  13. * @date 2023-09-06
  14. */
  15. public interface UserBillingMapper extends BaseMapper<UserBilling>
  16. {
  17. //用户余额查询
  18. @Select("SELECT IFNULL(SUM(amount),0) FROM user_billing WHERE state=0 and type<>2 and user_id = #{userid}") //查询语句
  19. List<UserBilling> getamsum(@Param("userid") Long userid); //反回结果
  20. @Select("SELECT IFNULL(SUM(amount),0) FROM user_billing WHERE state=0 and type=#{type} and user_id=#{userid}") //查询语句
  21. int gettypesum(@Param("userid") Long userid,@Param("type") Long type); //反回结果
  22. @Select("SELECT * FROM user_billing WHERE type=1 and state=3 and TIMESTAMPDIFF(MINUTE,cretim,NOW()) >= #{minute}") //查询语句
  23. List<UserBilling> getbillingTim(@Param("minute") Integer minute); //反回结果
  24. //统计商户全部收入
  25. @Select("SELECT IFNULL(SUM(amount),0) FROM user_billing WHERE user_id=#{shid} and type=0 and state=0") //查询语句
  26. int getshAllIncomeSum(@Param("shid") Long shid); //反回结果
  27. //统计商户当天收入
  28. @Select("SELECT IFNULL(SUM(amount),0) FROM user_billing WHERE user_id=#{shid} and type=0 and state=0 and DATE_FORMAT(cretim, '%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')") //查询语句
  29. int getshDayIncomeSum(@Param("shid") Long shid); //反回结果
  30. //统计商户已提现
  31. @Select("SELECT IFNULL(SUM(amount),0) FROM user_billing WHERE user_id=#{shid} and type=2 and state=0") //查询语句
  32. int getshtxsum(@Param("shid") Long shid);
  33. //统计商户全部收入(qb)
  34. @Select("SELECT IFNULL(SUM(amount),0) FROM user_billing WHERE user_id=#{shid} and type=0 and state=0")
  35. int getshqbsum(@Param("shid") Long shid);
  36. //统计商户当天收入(dt)
  37. @Select("SELECT IFNULL(SUM(amount),0) FROM user_billing WHERE user_id=#{shid} and type=0 and state=0 and DATE_FORMAT(cretim, '%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')")
  38. int getshdtsum(@Param("shid") Long shid); //反回结果
  39. //商家月账单统计
  40. @Select("SELECT IFNULL(COUNT(1),0) AS sul,IFNULL(SUM(amount),0) AS shouru ,IFNULL(SUM(divvy),0) AS commission,IFNULL(SUM(tax),0) AS tax,IFNULL(SUM(behalf_amount),0) AS behalfAmount FROM user_billing WHERE type=0 and user_id=#{shid} and DATE_FORMAT(cretim, '%Y-%m') = #{riqi} and state=0") //查询语句
  41. BillDTO getmatsum(@Param("shid") Long shid, @Param("riqi") String riqi); //反回结果
  42. //商户查询周月账单商品总金额,商家优惠总金额
  43. @Select("SELECT IFNULL(SUM(o.food_amount),0) AS foodAmount,IFNULL(SUM(o.md_discount_amount),0)+IFNULL(SUM(o.md_sales_reduction),0) as shYh FROM user_billing b left join pos_order o on b.dd_id=o.dd_id WHERE b.type=0 and b.user_id=#{shid} and DATE_FORMAT(b.cretim, '%Y-%m') = #{riqi} and b.state=0") //查询语句
  44. ShBillingDto getshMonthsum(@Param("shid") Long shid, @Param("riqi") String riqi);
  45. //商家月账单明细
  46. @Select("SELECT * FROM user_billing WHERE type=0 and user_id=#{shid} and DATE_FORMAT(cretim, '%Y-%m') = #{riqi} ORDER BY id desc limit #{page},#{size}") //查询语句
  47. List<UserBilling> getmatlist(@Param("shid") Long shid, @Param("riqi") String riqi,@Param("page") Long page,@Param("size") Long size); //反回结果
  48. //商家周账单统计
  49. @Select("SELECT IFNULL(COUNT(1),0) AS sul,IFNULL(SUM(amount),0) AS shouru ,IFNULL(SUM(divvy),0) AS commission,IFNULL(SUM(tax),0) AS tax,IFNULL(SUM(behalf_amount),0) AS behalfAmount FROM user_billing WHERE type=0 and user_id=#{shid} and WEEK(cretim) = WEEK(#{riqi}) and YEAR(cretim) = YEAR(#{riqi}) and state=0") //查询语句
  50. BillDTO getmeeksum(@Param("shid") Long shid, @Param("riqi") String riqi); //反回结果
  51. //商户查询周账单商品总金额,商家优惠总金额
  52. @Select("SELECT IFNULL(SUM(o.food_amount),0) AS foodAmount,IFNULL(SUM(o.md_discount_amount),0)+IFNULL(SUM(o.md_sales_reduction),0) as shYh FROM user_billing b left join pos_order o on b.dd_id=o.dd_id WHERE b.type=0 and b.user_id=#{shid} and WEEK(b.cretim) = WEEK(#{riqi}) and YEAR(b.cretim) = YEAR(#{riqi}) and b.state=0") //查询语句
  53. ShBillingDto getShMeeksum(@Param("shid") Long shid, @Param("riqi") String riqi);
  54. //商家周账单明细
  55. @Select("SELECT * FROM user_billing WHERE type=0 and user_id=#{shid} and WEEK(cretim) = WEEK(#{riqi}) and YEAR(cretim) = YEAR(#{riqi}) ORDER BY id desc limit #{page},#{size}") //查询语句
  56. List<UserBilling> getmeeklist(@Param("shid") Long shid, @Param("riqi") String riqi,@Param("page") Long page,@Param("size") Long size); //反回结果
  57. //商家日账单统计
  58. @Select("SELECT IFNULL(COUNT(1),0) AS sul,IFNULL(SUM(amount),0) AS shouru,IFNULL(SUM(divvy),0) AS commission,IFNULL(SUM(tax),0) AS tax,IFNULL(SUM(behalf_amount),0) AS behalfAmount FROM user_billing WHERE type=0 and user_id=#{shid} and date_format (cretim,'%Y-%m-%d %H:%i:%s') >= date_format (CONCAT(#{riqi}, ' 00:00:00'),'%Y-%m-%d %H:%i:%s') and date_format (cretim,'%Y-%m-%d %H:%i:%s') <= date_format (CONCAT(#{riqi}, ' 23:59:59'),'%Y-%m-%d %H:%i:%s') and state=0") //查询语句
  59. BillDTO getdaysum(@Param("shid") Long shid, @Param("riqi") String riqi); //反回结果
  60. //商户查询日账单商品总金额,商家优惠总金额
  61. @Select("SELECT IFNULL(SUM(o.food_amount),0) AS foodAmount,IFNULL(SUM(o.md_discount_amount),0)+IFNULL(SUM(o.md_sales_reduction),0) as shYh FROM user_billing b left join pos_order o on b.dd_id=o.dd_id WHERE b.type=0 and b.user_id=#{shid} and date_format (b.cretim,'%Y-%m-%d %H:%i:%s') >= date_format (CONCAT(#{riqi}, ' 00:00:00'),'%Y-%m-%d %H:%i:%s') and date_format (b.cretim,'%Y-%m-%d %H:%i:%s') <= date_format (CONCAT(#{riqi}, ' 23:59:59'),'%Y-%m-%d %H:%i:%s') ")
  62. ShBillingDto getShDaysum(@Param("shid") Long shid, @Param("riqi") String riqi);
  63. //商家日账单明细
  64. @Select("SELECT * FROM user_billing WHERE type=0 and user_id=#{shid} and date_format (cretim,'%Y-%m-%d %H:%i:%s') >= date_format (CONCAT(#{riqi}, ' 00:00:00'),'%Y-%m-%d %H:%i:%s') and date_format (cretim,'%Y-%m-%d %H:%i:%s') <= date_format (CONCAT(#{riqi}, ' 23:59:59'),'%Y-%m-%d %H:%i:%s') ORDER BY id desc limit #{page},#{size}") //查询语句
  65. List<UserBilling> getdaylist(@Param("shid") Long shid, @Param("riqi") String riqi,@Param("page") Long page,@Param("size") Long size); //反回结果
  66. /**
  67. * 查询Billing
  68. *
  69. * @param id Billing主键
  70. * @return Billing
  71. */
  72. public UserBilling selectUserBillingById(Long id);
  73. /**
  74. * 查询Billing列表,不包含提现记录
  75. *
  76. * @param userBilling Billing
  77. * @return Billing集合
  78. */
  79. public List<UserBilling> selectUserBillingList(UserBilling userBilling);
  80. /**
  81. * 查询提现列表
  82. *
  83. * @param userBilling Billing
  84. * @return Billing集合
  85. */
  86. public List<UserBilling> selectUserWithdrawList(UserBilling userBilling);
  87. /**
  88. * 新增Billing
  89. *
  90. * @param userBilling Billing
  91. * @return 结果
  92. */
  93. public int insertUserBilling(UserBilling userBilling);
  94. /**
  95. * 修改Billing
  96. *
  97. * @param userBilling Billing
  98. * @return 结果
  99. */
  100. public int updateUserBilling(UserBilling userBilling);
  101. /**
  102. * 删除Billing
  103. *
  104. * @param id Billing主键
  105. * @return 结果
  106. */
  107. public int deleteUserBillingById(Long id);
  108. /**
  109. * 批量删除Billing
  110. *
  111. * @param ids 需要删除的数据主键集合
  112. * @return 结果
  113. */
  114. public int deleteUserBillingByIds(Long[] ids);
  115. /**
  116. * 获取用户收入
  117. * @param userid
  118. * @return
  119. */
  120. @Select("SELECT IFNULL(SUM(amount),0) FROM user_billing WHERE user_id=#{userid} and type=0 and state=0") //查询语句
  121. public double getUserIncomeSum(Long userid);
  122. /**
  123. * 获取用户提现金额(包括未处理完成)
  124. * @param userid
  125. * @return
  126. */
  127. @Select("SELECT IFNULL(SUM(amount),0) FROM user_billing WHERE user_id= #{userid} and type=2 and state>=0")
  128. public double getUserWithdrawSum(Long userid);
  129. }