fixbug 收入支出调整

This commit is contained in:
2023-02-09 23:51:52 +08:00
parent e9d5f9abc1
commit b107754627
3 changed files with 18 additions and 3 deletions

View File

@@ -115,11 +115,16 @@ public class WxSettingsController extends BaseWxController{
*/
@PostMapping("user/settings/expend")
public ResponseDTO getBillExpend(HttpServletRequest request){
double sumYearAmnt = 0;
List<YearAmnt> billByType = accSettingService.getBillByType(getLoginUserId(request), AccSettingType.EXPEND_SETTING);
Map<Integer,Double> result = new HashMap<>();
if (!CollectionUtils.isEmpty(billByType)){
for (YearAmnt yearAmnt : billByType) {
sumYearAmnt = sumYearAmnt + yearAmnt.getMoney();
}
result = billByType.stream().collect(Collectors.toMap(YearAmnt::getSettingId, YearAmnt::getMoney, (k1, k2) -> k1));
}
result.put(-1,sumYearAmnt);
return ResponseDTO.ok().setData(result);
}
@@ -130,11 +135,16 @@ public class WxSettingsController extends BaseWxController{
*/
@PostMapping("user/settings/income")
public ResponseDTO getBillIncome(HttpServletRequest request){
double sumYearAmnt = 0;
List<YearAmnt> billByType = accSettingService.getBillByType(getLoginUserId(request), AccSettingType.INCOME_SETTING);
Map<Integer,Double> result = new HashMap<>();
if (!CollectionUtils.isEmpty(billByType)){
for (YearAmnt yearAmnt : billByType) {
sumYearAmnt = sumYearAmnt + yearAmnt.getMoney();
}
result = billByType.stream().collect(Collectors.toMap(YearAmnt::getSettingId, YearAmnt::getMoney, (k1, k2) -> k1));
}
result.put(-1,sumYearAmnt);
return ResponseDTO.ok().setData(result);
}

View File

@@ -3,9 +3,10 @@
<mapper namespace="com.quinn.mapper.AccSettingMapper">
<select id="getBillByType" resultType="com.quinn.common.wx.YearAmnt">
select a.bill_type "settingId",sum(a.money) "money" from qn_acc_bill a,qn_acc_setting b
where a.bill_type = b.id and a.user_id = #{userId} and b.setting_type = #{settingType}
group by a.bill_type
select a.money_type "settingId",sum(a.money) "money" from qn_acc_bill a,qn_acc_setting b
where a.money_type = b.id and a.user_id = #{userId} and b.setting_type = #{settingType}
and YEAR(a.date) = YEAR(NOW())
group by a.money_type
</select>
<update id="updateBalance">

View File

@@ -37,3 +37,7 @@ CREATE TABLE `qn_acc_budget` (
`gmt_create` datetime NOT NULL COMMENT '收藏创建时间',
PRIMARY KEY (`id`)
);
INSERT INTO `qn_acc_setting`(`id`, `name`, `setting_type`, `icon`, `balance`, `user_id`, `gmt_create`) VALUES (-1, '还款', 'OTHER', '/image/bill/repayment.png', 0.00, NULL, '2023-02-09 23:44:20');
INSERT INTO `qn_acc_setting`(`id`, `name`, `setting_type`, `icon`, `balance`, `user_id`, `gmt_create`) VALUES (-2, '转账', 'OTHER', '/image/bill/transfer.png', 0.00, NULL, '2023-02-09 23:44:20');