vip开通详情将已失效详情合并到有效详情里

This commit is contained in:
wuchunlei
2025-10-23 14:37:33 +08:00
parent b2d94d500a
commit 834759802e

View File

@@ -68,9 +68,13 @@ public class UserVipController {
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
List<MyUserEntity> users = page.getRecords();
for (MyUserEntity user : users) {
List<UserVip> userVips = userVipService.list(new LambdaQueryWrapper<UserVip>()
List<UserVip> userVips = userVipService.list(new MPJLambdaWrapper<UserVip>()
.rightJoin("(select max(end_time) endTime,type from user_vip where del_flag =0 and user_id = "+user.getId()+" group by type)" +
" t1 on t1.endTime = t.end_time and t1.type = t.type")
.selectAll(UserVip.class)
.eq(UserVip::getUserId, user.getId())
.eq(StringUtils.isNotEmpty(params.get("state").toString()),UserVip::getState, params.get("state").toString()));
.eq(StringUtils.isNotEmpty(params.get("state").toString()),UserVip::getState, params.get("state").toString())
.orderByAsc(UserVip::getEndTime,UserVip::getType));
user.setUserVips(userVips);
for(UserVip userVip : userVips){
userVip.setUserVipLogs(userVipLogService.list(new LambdaQueryWrapper<UserVipLog>()
@@ -169,12 +173,26 @@ public class UserVipController {
public R getUserVipInfoByUserId(@RequestBody Map<String, Object> params) {
List<UserVip> userVips = userVipService.list(new LambdaQueryWrapper<UserVip>()
.eq(UserVip::getUserId,params.get("userId").toString())
.eq("0".equals(params.get("state").toString()),UserVip::getState,params.get("state").toString()));
.eq("0".equals(params.get("state").toString()),UserVip::getState,params.get("state").toString())
.orderByDesc(UserVip::getEndTime));
Map<String,Object> map = new HashMap<>();
List<UserVip> resUserVips = new ArrayList<>();
//将失效详情添加到有效条目里
for (UserVip userVip : userVips) {
userVip.setUserVipLogs(userVipLogService.list(new LambdaQueryWrapper<UserVipLog>()
.eq(UserVipLog::getUserVipId,userVip.getId())));
if (!map.containsKey(userVip.getType()+"")){
userVip.setUserVipLogs(userVipLogService.list(new LambdaQueryWrapper<UserVipLog>()
.eq(UserVipLog::getUserVipId,userVip.getId())));
map.put(userVip.getType()+"",userVip);
resUserVips.add(userVip);
}else {
UserVip uv = (UserVip) map.get(userVip.getType()+"");
List<UserVipLog> list = uv.getUserVipLogs();
list.addAll(userVipLogService.list(new LambdaQueryWrapper<UserVipLog>()
.eq(UserVipLog::getUserVipId,userVip.getId())));
uv.setUserVipLogs(list);
}
}
return R.ok().put("userVips", userVips);
return R.ok().put("userVips", resUserVips);
}
@RequestMapping("/addUserVipLog")