后台-撤回勋章
This commit is contained in:
@@ -13,7 +13,7 @@ public class MedalRecordAdminVo {
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
@ApiModelProperty("来源")
|
||||
private String source;
|
||||
private Integer source;
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
@ApiModelProperty("天数")
|
||||
|
@@ -43,8 +43,6 @@ public class MedalAdminService {
|
||||
private UserMedalService userMedalService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private MedalRecordService medalRecordService;
|
||||
|
||||
public List<Medal> listAll() {
|
||||
return medalService.lambdaQuery().eq(Medal::getEnable, Boolean.TRUE).list();
|
||||
@@ -110,46 +108,16 @@ public class MedalAdminService {
|
||||
return null;
|
||||
}
|
||||
return u;
|
||||
}).filter(Objects::isNull)
|
||||
}).filter(Objects::nonNull)
|
||||
.collect(Collectors.toMap(Users::getErbanNo, u->u, (a,b)->a));
|
||||
|
||||
if (erbanNoArray.length > usersMap.size()){
|
||||
throw new AdminServiceException("请输入正确的用户ID, 或确认用户的分区");
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
Date expireTime = DateTimeUtil.addDays(now, days);
|
||||
|
||||
UserMedal baseUserMedal = new UserMedal();
|
||||
baseUserMedal.setId(medalId);
|
||||
baseUserMedal.setCreateTime(now);
|
||||
baseUserMedal.setExpireTime(expireTime);
|
||||
baseUserMedal.setUpdateTime(now);
|
||||
|
||||
MedalRecord baseRecord = new MedalRecord();
|
||||
baseRecord.setCreateTime(now);
|
||||
baseRecord.setExpireTime(expireTime);
|
||||
baseRecord.setSource(1);
|
||||
baseRecord.setRemark(remark);
|
||||
baseRecord.setAdminId(adminId);
|
||||
|
||||
List<UserMedal> userMedalList = new ArrayList<>();
|
||||
List<MedalRecord> recordList = new ArrayList<>();
|
||||
|
||||
usersMap.values().forEach(u->{
|
||||
UserMedal um = new UserMedal();
|
||||
BeanUtils.copyProperties(baseUserMedal, um);
|
||||
um.setUid(u.getUid());
|
||||
userMedalList.add(um);
|
||||
|
||||
MedalRecord record = new MedalRecord();
|
||||
BeanUtils.copyProperties(baseRecord, record);
|
||||
record.setUid(u.getUid());
|
||||
recordList.add(record);
|
||||
usersMap.values().parallelStream().forEach(u->{
|
||||
userMedalService.sendMedal(u.getUid(), medalId, days, 1, remark, adminId);
|
||||
});
|
||||
|
||||
userMedalService.saveBatch(userMedalList);
|
||||
medalRecordService.saveBatch(recordList);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -5,9 +5,13 @@ import com.accompany.business.model.Medal;
|
||||
import com.accompany.business.model.MedalRecord;
|
||||
import com.accompany.business.service.medal.MedalRecordService;
|
||||
import com.accompany.business.service.medal.MedalService;
|
||||
import com.accompany.business.service.medal.UserMedalService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.base.SpringContextHolder;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.model.PartitionInfo;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.partition.PartitionInfoService;
|
||||
@@ -20,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -92,7 +97,9 @@ public class MedalRecordAdminService {
|
||||
vo.setPartitionName(partitionNameMap.get(user.getPartitionId()));
|
||||
}
|
||||
|
||||
if (medalRecord.getExpireTime().compareTo(now) >= 0){
|
||||
if (!medalRecord.getEnable()){
|
||||
vo.setStatus(Constant.StatusV2.delete);
|
||||
} else if (medalRecord.getExpireTime().compareTo(now) >= 0){
|
||||
vo.setStatus(Constant.StatusV2.valid);
|
||||
} else {
|
||||
vo.setStatus(Constant.StatusV2.invalid);
|
||||
@@ -107,7 +114,20 @@ public class MedalRecordAdminService {
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void rollback(Long recordId) {
|
||||
MedalRecord record = medalRecordService.getById(recordId);
|
||||
if (null == record){
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
|
||||
if (!record.getEnable()){
|
||||
return;
|
||||
}
|
||||
|
||||
SpringContextHolder.getBean(UserMedalService.class).rollback(record.getUid(), record.getMedalId(), record.getDays());
|
||||
|
||||
record.setEnable(Boolean.FALSE);
|
||||
medalRecordService.updateById(record);
|
||||
}
|
||||
}
|
||||
|
@@ -80,7 +80,7 @@ public class MedalAdminController extends BaseController {
|
||||
/**
|
||||
* 赠送
|
||||
* @param medalId
|
||||
* @param erBanNoStr
|
||||
* @param erbanNoStr
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("赠送")
|
||||
|
@@ -9,8 +9,8 @@ import java.util.Date;
|
||||
@Data
|
||||
public class MedalRecord {
|
||||
|
||||
@TableId(type = IdType.NONE)
|
||||
private Long id;
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private Integer medalId;
|
||||
private Long uid;
|
||||
private Date createTime;
|
||||
@@ -19,5 +19,6 @@ public class MedalRecord {
|
||||
private Integer source;
|
||||
private String remark;
|
||||
private Integer adminId;
|
||||
private Boolean enable;
|
||||
|
||||
}
|
||||
|
@@ -11,6 +11,6 @@ public class UserDetailMedalVo {
|
||||
//已获得勋章数
|
||||
private int medalCount = 0;
|
||||
//拥有的勋章对象集合
|
||||
private List<UserMedalVo> userMedalVos = new ArrayList<>();
|
||||
private List<UserMedalVo> userMedals = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
@@ -83,5 +83,5 @@ public class UserDetailsVo {
|
||||
private List<UserGamePartnerInfoVo> userGamePartner;
|
||||
|
||||
//勋章
|
||||
private UserDetailMedalVo userDetailMedalVo;
|
||||
private UserDetailMedalVo medals;
|
||||
}
|
||||
|
@@ -1,10 +1,27 @@
|
||||
package com.accompany.business.service.medal;
|
||||
|
||||
import com.accompany.business.model.MedalRecord;
|
||||
import com.accompany.business.model.UserMedal;
|
||||
import com.accompany.business.mybatismapper.MedalRecordMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MedalRecordService extends ServiceImpl<MedalRecordMapper, MedalRecord> {
|
||||
|
||||
public void saveRecord(UserMedal userMedal,
|
||||
Integer days, Integer source, String remark, Integer adminId) {
|
||||
MedalRecord record = new MedalRecord();
|
||||
record.setMedalId(userMedal.getMedalId());
|
||||
record.setUid(userMedal.getUid());
|
||||
record.setCreateTime(userMedal.getCreateTime());
|
||||
record.setDays(days);
|
||||
record.setExpireTime(userMedal.getExpireTime());
|
||||
record.setSource(source);
|
||||
record.setRemark(remark);
|
||||
record.setAdminId(adminId);
|
||||
record.setEnable(Boolean.TRUE);
|
||||
save(record);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -12,4 +12,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
public interface UserMedalService extends IService<UserMedal> {
|
||||
|
||||
UserDetailMedalVo getUserMedalWithDetail(Long uid);
|
||||
|
||||
void rollback(long uid, int medalId, int days);
|
||||
|
||||
void sendMedal(long uid, int medalId, int days,
|
||||
Integer source, String remark, Integer adminId);
|
||||
}
|
||||
|
@@ -3,17 +3,18 @@ package com.accompany.business.service.medal.impl;
|
||||
import com.accompany.business.model.Medal;
|
||||
import com.accompany.business.model.UserMedal;
|
||||
import com.accompany.business.mybatismapper.UserMedalMapper;
|
||||
import com.accompany.business.service.medal.MedalRecordService;
|
||||
import com.accompany.business.service.medal.MedalService;
|
||||
import com.accompany.business.service.medal.UserMedalService;
|
||||
import com.accompany.business.vo.medal.UserDetailMedalVo;
|
||||
import com.accompany.business.vo.medal.UserMedalVo;
|
||||
import com.accompany.core.base.BeanMapper;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
@@ -30,13 +31,70 @@ public class UserMedalServiceImpl extends ServiceImpl<UserMedalMapper, UserMedal
|
||||
|
||||
@Autowired
|
||||
private MedalService medalService;
|
||||
@Autowired
|
||||
private MedalRecordService medalRecordService;
|
||||
|
||||
public UserDetailMedalVo getUserMedalWithDetail(Long uid) {
|
||||
Date now = new Date();
|
||||
List<UserMedal> userMedals = list(Wrappers.<UserMedal>lambdaQuery()
|
||||
.eq(UserMedal::getUid, uid));
|
||||
.eq(UserMedal::getUid, uid)
|
||||
.le(UserMedal::getCreateTime, now)
|
||||
.ge(UserMedal::getExpireTime, now));
|
||||
return buildUserDetailMedalVoV2(uid, userMedals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback(long uid, int medalId, int days) {
|
||||
Date now = new Date();
|
||||
|
||||
UserMedal db = lambdaQuery()
|
||||
.eq(UserMedal::getUid, uid)
|
||||
.eq(UserMedal::getMedalId, medalId)
|
||||
.one();
|
||||
if (db == null || now.compareTo(db.getExpireTime()) >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.setExpireTime(DateTimeUtil.addDays(db.getExpireTime(), -days));
|
||||
db.setUpdateTime(now);
|
||||
updateById(db);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void sendMedal(long uid, int medalId, int days,
|
||||
Integer source, String remark, Integer adminId) {
|
||||
Date now = new Date();
|
||||
|
||||
UserMedal userMedal = new UserMedal();
|
||||
userMedal.setUid(uid);
|
||||
userMedal.setMedalId(medalId);
|
||||
userMedal.setCreateTime(now);
|
||||
userMedal.setExpireTime(DateTimeUtil.addDays(now, days));
|
||||
userMedal.setUpdateTime(now);
|
||||
|
||||
UserMedal db = lambdaQuery()
|
||||
.eq(UserMedal::getUid, uid)
|
||||
.eq(UserMedal::getMedalId, medalId)
|
||||
.one();
|
||||
if (null == db){
|
||||
save(userMedal);
|
||||
medalRecordService.saveRecord(userMedal, days, source, remark, adminId);
|
||||
return;
|
||||
}
|
||||
|
||||
userMedal.setId(db.getId());
|
||||
|
||||
if (now.compareTo(db.getExpireTime()) < 0){
|
||||
userMedal.setCreateTime(db.getCreateTime());
|
||||
userMedal.setExpireTime(DateTimeUtil.addDays(db.getExpireTime(), days));
|
||||
}
|
||||
|
||||
updateById(userMedal);
|
||||
medalRecordService.saveRecord(userMedal, source, days, remark, adminId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新版-用户勋章墙
|
||||
*
|
||||
@@ -48,7 +106,7 @@ public class UserMedalServiceImpl extends ServiceImpl<UserMedalMapper, UserMedal
|
||||
if (CollectionUtils.isEmpty(userMedals)) {
|
||||
UserDetailMedalVo userDetailMedalVo = new UserDetailMedalVo();
|
||||
userDetailMedalVo.setMedalCount(0);
|
||||
userDetailMedalVo.setUserMedalVos(Collections.emptyList());
|
||||
userDetailMedalVo.setUserMedals(Collections.emptyList());
|
||||
return userDetailMedalVo;
|
||||
}
|
||||
// 转换成vo
|
||||
@@ -83,7 +141,7 @@ public class UserMedalServiceImpl extends ServiceImpl<UserMedalMapper, UserMedal
|
||||
.collect(Collectors.toList());
|
||||
|
||||
userDetailMedalVo.setMedalCount(voList.size());
|
||||
userDetailMedalVo.setUserMedalVos(voList);
|
||||
userDetailMedalVo.setUserMedals(voList);
|
||||
return userDetailMedalVo;
|
||||
}
|
||||
|
||||
|
@@ -192,16 +192,17 @@ public class UserDetailsService extends BaseService {
|
||||
});
|
||||
|
||||
userDetailsVo.setBanAccount(accountBlockService.checkAccountBlock(userVo.getErbanNo(), userVo.getPhone()));
|
||||
//勋章
|
||||
userDetailsVo.setMedals(userMedalService.getUserMedalWithDetail(uid));
|
||||
userDetailsVo.setUserGamePartner(userGamePartnerInfoService.listUserGamePartnerInfo(uid));
|
||||
userDetailsVo.setIsRechargeUser(rechargeUserService.isRechargeUser(uid));
|
||||
|
||||
try {
|
||||
cdl.await(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("[异构UserDetailVo异常] await uid={},fromUid={}", uid, selfUid, e);
|
||||
}
|
||||
userDetailsVo.setIsRechargeUser(rechargeUserService.isRechargeUser(uid));
|
||||
//勋章
|
||||
userDetailsVo.setUserDetailMedalVo(userMedalService.getUserMedalWithDetail(uid));
|
||||
|
||||
return userDetailsVo;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user