37 lines
2.0 KiB
XML
37 lines
2.0 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.quinn.mapper.AccBudgetMapper">
|
|
<select id="getBudget" resultType="com.quinn.common.wx.BudgetDTO">
|
|
select a.id "id",b.id "expendId",IFNULL(a.budget,0) "budget",b.user_id "userId",a.gmt_create "gmtCreate",
|
|
IFNULL(
|
|
(select sum(money) from qn_acc_bill c where c.money_type = a.expend_id and c.user_id = #{userId} and c.date <![CDATA[ >= ]]> #{startDate} and c.date <![CDATA[ <= ]]> #{endDate})
|
|
,0) "used",
|
|
b.icon "expendIcon",
|
|
b.name "expendName"
|
|
from qn_acc_budget a right join qn_acc_setting b on a.expend_id = b.id
|
|
where b.user_id = #{userId} and b.setting_type = 'EXPEND_SETTING'
|
|
union all
|
|
select id "id",expend_id "expendId",IFNULL(budget,0) "budget",user_id "userId",gmt_create "gmtCreate",
|
|
IFNULL(
|
|
(select sum(money) from qn_acc_bill c where c.bill_type = 'EXPEND' and c.user_id = #{userId} and c.date <![CDATA[ >= ]]> #{startDate} and c.date <![CDATA[ <= ]]> #{endDate})
|
|
,0) "used",
|
|
null,null from qn_acc_budget where user_id = #{userId} and expend_id = -1
|
|
</select>
|
|
|
|
<select id="getIndexBudget" resultType="com.quinn.common.wx.IndexDTO">
|
|
select
|
|
IFNULL(
|
|
(select sum(money) from qn_acc_bill c where c.bill_type = 'EXPEND' and c.user_id = #{userId} and c.date = #{todayDate})
|
|
,0) "sumToday",
|
|
IFNULL(
|
|
(select sum(balance) from qn_acc_setting where user_id = #{userId} and (setting_type = 'CASH_SETTING' or setting_type = 'OWE_SETTING'))
|
|
,0) "sumBalance",
|
|
IFNULL(
|
|
(select budget from qn_acc_budget where user_id = #{userId} and expend_id = -1)
|
|
,0) "sumBudget",
|
|
IFNULL(
|
|
(select sum(money) from qn_acc_bill c where c.bill_type = 'EXPEND' and c.user_id = #{userId} and c.date <![CDATA[ >= ]]> #{startDate} and c.date <![CDATA[ <= ]]> #{endDate})
|
|
,0) "sumUsed"
|
|
</select>
|
|
</mapper>
|