Commit 87a9f54c authored by licc's avatar licc

fix 最近六个月收益sql

parent c1dcc266
...@@ -90,34 +90,22 @@ ...@@ -90,34 +90,22 @@
</where> </where>
</select> </select>
<select id="getByUserIdAndTime" resultType="cn.wisenergy.model.app.TradeRecord">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
trade_type !=1
<if test="userId">
and user_id=#{userId}
</if>
<if test="yearMonth != null">
AND(
YEAR(create_time) = YEAR(#{yearMonth})
AND MONTH(create_time) = MONTH(#{yearMonth}))
</if>
</where>
</select>
<select id="getSixMonthIncome" resultType="cn.wisenergy.model.vo.AccumulatedIncomeVo"> <select id="getSixMonthIncome" resultType="cn.wisenergy.model.vo.AccumulatedIncomeVo">
SELECT user_id as userId,sum(money) as income , select a.user_id as userId,a.money as income,date_format(a.create_time,'%Y-%m') as yearMonth
date_format(create_time,'%Y-%m') as yearMonth FROM trade_record as a right join (SELECT user_id ,trade_type,
date_format(create_time,'%Y-%m'),max(create_time) as time
FROM FROM
<include refid="table"/> <include refid="table"/>
WHERE date_format(create_time,'%Y-%m') &lt;= date_format(now(),'%Y-%m') WHERE date_format(create_time,'%Y-%m') &lt;= date_format(now(),'%Y-%m')
and date_format(create_time,'%Y-%m') >= date_format(now() - interval 5 month,'%Y-%m') and date_format(create_time,'%Y-%m') >= date_format(now() - interval 5 month,'%Y-%m')
and (status=1 or status=0) and (status=1 or status=0)
and user_id=#{userId} and user_id=#{userId}
group by user_id ,create_time; and trade_type in(2,4,5,7,8)
group by user_id ,trade_type,date_format(create_time,'%Y-%m')) as b on
a.user_id= b.user_id
and a.trade_type=b.trade_type
and a.create_time =b.time
ORDER BY b.time desc
</select> </select>
<select id="getWithdrawalRecord" resultType="cn.wisenergy.model.vo.WithdrawalRecordVo"> <select id="getWithdrawalRecord" resultType="cn.wisenergy.model.vo.WithdrawalRecordVo">
......
...@@ -11,7 +11,6 @@ import cn.wisenergy.model.app.TradeRecord; ...@@ -11,7 +11,6 @@ import cn.wisenergy.model.app.TradeRecord;
import cn.wisenergy.model.enums.TradeRecordEnum; import cn.wisenergy.model.enums.TradeRecordEnum;
import cn.wisenergy.model.vo.*; import cn.wisenergy.model.vo.*;
import cn.wisenergy.service.app.WalletService; import cn.wisenergy.service.app.WalletService;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -110,7 +109,7 @@ public class WalletServiceImpl implements WalletService { ...@@ -110,7 +109,7 @@ public class WalletServiceImpl implements WalletService {
return R.error("入参为空!"); return R.error("入参为空!");
} }
//获取包括本月在内的六个月的收益 //获取包括本月在内的六个月的收益
List<AccumulatedIncomeVo> list = tradeRecordMapper.getSixMonthIncome(userId); List<AccumulatedIncomeVo> list = tradeRecordMapper.getSixMonthIncome(userId);
return R.ok(list); return R.ok(list);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment