新增查询最近12个月消费总额接口
在SysUserController中新增`getMonthsSummary`接口,用于查询最近12个月的消费总额。此接口调用userService中的`getMonthsSummary`方法,该方法汇总并返回指定时间范围内的消费记录。 在SysUserMapper中添加`selectMonthSummary`方法的映射,并在SysUserMapper.xml中定义相应的SQL查询,以从数据库中获取月度消费数据。 在SysUserService接口中添加`getMonthsSummary`方法的定义,并在SysUserServiceImpl中实现该方法,通过调用mapper的方法来获取数据。 ConnectorLog实体类中添加`month`和`totalAmount`字段,用于存储月度消费记录的查询结果。master
parent
0566362e70
commit
24b4f9cd22
|
@ -56,6 +56,14 @@ public class SysUserController extends BaseController {
|
|||
@Autowired
|
||||
private SysConfigService configService;
|
||||
|
||||
|
||||
//查询12个月的消费记录
|
||||
@GetMapping("/months")
|
||||
public List<ConnectorLog>getMonthsSummary(ConnectorLog connectorLog){
|
||||
return userService.getMonthsSummary(connectorLog);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
|
|
|
@ -29,4 +29,8 @@ public class ConnectorLog {
|
|||
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private String createTime;
|
||||
|
||||
private String month;
|
||||
|
||||
private Double totalAmount;
|
||||
|
||||
}
|
||||
|
|
|
@ -165,4 +165,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
int updateUserPhonenumber(@Param("username") String username, @Param("phonenumber") String phonenumber);
|
||||
|
||||
List<ConnectorLog> selectRecordList(ConnectorLog connectorLog);
|
||||
|
||||
List<ConnectorLog> selectMonthSummary(ConnectorLog connectorLog);
|
||||
}
|
||||
|
|
|
@ -250,4 +250,6 @@ public interface SysUserService extends IService<SysUser> {
|
|||
int updateUserPhonenumber(String username, String phonenumber);
|
||||
|
||||
List<ConnectorLog> selectRecordList(ConnectorLog connectorLog);
|
||||
|
||||
List<ConnectorLog> getMonthsSummary(ConnectorLog connectorLog);
|
||||
}
|
||||
|
|
|
@ -597,5 +597,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
return userMapper.selectRecordList(connectorLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConnectorLog> getMonthsSummary(ConnectorLog connectorLog) {
|
||||
return userMapper.selectMonthSummary(connectorLog);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -207,6 +207,20 @@
|
|||
select id,data_name,amount ,create_time from connect_log
|
||||
</select>
|
||||
|
||||
<select id="selectMonthSummary" resultType="com.muyu.system.domain.ConnectorLog">
|
||||
SELECT
|
||||
DATE_FORMAT(create_time, '%Y-%m') as month,
|
||||
SUM(amount) as totalAmount
|
||||
FROM
|
||||
connect_log
|
||||
WHERE
|
||||
create_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH)
|
||||
GROUP BY
|
||||
DATE_FORMAT(create_time, '%Y-%m')
|
||||
ORDER BY
|
||||
DATE_FORMAT(create_time, '%Y-%m');
|
||||
</select>
|
||||
|
||||
|
||||
<update id="addUserMoney">
|
||||
update sys_user set user_balance = user_balance + #{userBalance} where user_id = #{userId}
|
||||
|
|
Loading…
Reference in New Issue