记得上下班打卡 | git大法好,push需谨慎

Commit 0497621e authored by 张国柄's avatar 张国柄

fix:入场人+限制[10,20];

parent eb1cb20c
...@@ -54,6 +54,10 @@ public class AdamRedisConst { ...@@ -54,6 +54,10 @@ public class AdamRedisConst {
public static final String INCR_MEMBER_NO = PREFIX.concat("incr:member_no"); public static final String INCR_MEMBER_NO = PREFIX.concat("incr:member_no");
public static final String INCR_MEMBER_LIMITATION = PREFIX.concat("incr:member_limitation"); public static final String INCR_MEMBER_LIMITATION = PREFIX.concat("incr:member_limitation");
/**
* 用户添加/编辑入场人计数(N次/天)
*/
public static final String INCR_USER_ENTERS = PREFIX.concat("serial_u_e:");
// public static final String SWITCH_BUY_MEMBER = PREFIX.concat("switch:buy:member"); // public static final String SWITCH_BUY_MEMBER = PREFIX.concat("switch:buy:member");
......
...@@ -14,7 +14,7 @@ import java.util.List; ...@@ -14,7 +14,7 @@ import java.util.List;
* @since 2021-04-28 * @since 2021-04-28
*/ */
public interface IAdamEntersService { public interface IAdamEntersService {
String add(AdamEntersParam parameter); String add(AdamEntersParam parameter, String uid, List<AdamEntersVo> vos);
void def(String uid, String entersId); void def(String uid, String entersId);
......
...@@ -25,6 +25,8 @@ liquidnet: ...@@ -25,6 +25,8 @@ liquidnet:
app-login: app-login:
mobile: 13724286255 mobile: 13724286255
user-info: false user-info: false
limit:
enters: 10
enters_opr: 20
#以下为spring各环境个性配置 #以下为spring各环境个性配置
...@@ -25,5 +25,8 @@ liquidnet: ...@@ -25,5 +25,8 @@ liquidnet:
app-login: app-login:
mobile: 13724286255 mobile: 13724286255
user-info: false user-info: false
limit:
enters: 10
enters_opr: 20
#以下为spring各环境个性配置 #以下为spring各环境个性配置
...@@ -17,6 +17,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -17,6 +17,7 @@ import io.swagger.annotations.ApiOperation;
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;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -47,6 +48,12 @@ public class AdamEntersController { ...@@ -47,6 +48,12 @@ public class AdamEntersController {
@Autowired @Autowired
IAdamEntersService adamEntersService; IAdamEntersService adamEntersService;
@Value("${liquidnet.reviewer.limit.enters:10}")
private int reviewLimitEnters;
@Value("${liquidnet.reviewer.limit.enters_opr:10}")
private int reviewLimitEntersOpr;
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "添加入场人") @ApiOperation(value = "添加入场人")
@PostMapping("add") @PostMapping("add")
...@@ -84,8 +91,9 @@ public class AdamEntersController { ...@@ -84,8 +91,9 @@ public class AdamEntersController {
} }
break; break;
} }
String currentUid = CurrentUtil.getCurrentUid();
List<AdamEntersVo> vos = adamRdmService.getEntersVoByUid(CurrentUtil.getCurrentUid()); List<AdamEntersVo> vos = adamRdmService.getEntersVoByUid(currentUid);
if (!CollectionUtils.isEmpty(vos)) { if (!CollectionUtils.isEmpty(vos)) {
Optional<AdamEntersVo> any = vos.stream().filter(r -> (r.getIdCard().equals(parameter.getIdCard())) && r.getType().equals(parameter.getType())).findAny(); Optional<AdamEntersVo> any = vos.stream().filter(r -> (r.getIdCard().equals(parameter.getIdCard())) && r.getType().equals(parameter.getType())).findAny();
...@@ -93,12 +101,23 @@ public class AdamEntersController { ...@@ -93,12 +101,23 @@ public class AdamEntersController {
return ResponseDto.failure(ErrorMapping.get("10019")); return ResponseDto.failure(ErrorMapping.get("10019"));
} }
if (vos.size() >= 10) { if (reviewLimitEnters > 0 && vos.size() >= reviewLimitEnters) {
return ResponseDto.failure(ErrorMapping.get("10025")); return ResponseDto.failure(ErrorMapping.get("10025"));
} }
} }
String entersId = adamEntersService.add(parameter); int userEntersOprNo = adamRdmService.getUserEntersOprNo();
if (reviewLimitEntersOpr > 0 && userEntersOprNo >= reviewLimitEntersOpr) {
return ResponseDto.failure(ErrorMapping.get("10026"));
}
String entersId = adamEntersService.add(parameter, currentUid, vos);
if (userEntersOprNo == -1) {
adamRdmService.setUserEntersOprNo(1);
} else {
adamRdmService.incrUserEntersOprNo();
}
return ResponseDto.success(entersId); return ResponseDto.success(entersId);
} }
...@@ -151,8 +170,18 @@ public class AdamEntersController { ...@@ -151,8 +170,18 @@ public class AdamEntersController {
return ResponseDto.failure(ErrorMapping.get("10105")); return ResponseDto.failure(ErrorMapping.get("10105"));
} }
int userEntersOprNo = adamRdmService.getUserEntersOprNo();
if (reviewLimitEntersOpr > 0 && userEntersOprNo >= reviewLimitEntersOpr) {
return ResponseDto.failure(ErrorMapping.get("10026"));
}
adamEntersService.edit(parameter); adamEntersService.edit(parameter);
if (userEntersOprNo == -1) {
adamRdmService.setUserEntersOprNo(1);
} else {
adamRdmService.incrUserEntersOprNo();
}
return ResponseDto.success(); return ResponseDto.success();
} }
...@@ -165,7 +194,7 @@ public class AdamEntersController { ...@@ -165,7 +194,7 @@ public class AdamEntersController {
AdamEntersVo enters = adamRdmService.getEntersVoByUidEntersId(currentUid, entersId); AdamEntersVo enters = adamRdmService.getEntersVoByUidEntersId(currentUid, entersId);
if (null == enters) return ResponseDto.failure(ErrorMapping.get("10105")); if (null == enters) return ResponseDto.failure(ErrorMapping.get("10105"));
// adamEntersService.remove(currentUid, entersId); adamEntersService.remove(currentUid, entersId);
return ResponseDto.success(); return ResponseDto.success();
} }
......
...@@ -915,6 +915,23 @@ public class AdamRdmService { ...@@ -915,6 +915,23 @@ public class AdamRdmService {
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | */
public boolean setUserEntersOprNo(int val) {
LocalDateTime now = LocalDateTime.now();
return redisUtil.set(AdamRedisConst.INCR_USER_ENTERS, val,
ChronoUnit.SECONDS.between(now, LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), 23, 59, 59)));
}
public long incrUserEntersOprNo() {
return redisUtil.incr(AdamRedisConst.INCR_USER_ENTERS, 1);
}
public int getUserEntersOprNo() {
Object o = redisUtil.get(AdamRedisConst.INCR_USER_ENTERS);
return null == o ? -1 : (int) o;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | */
/* ========================================================== | Other micro-service data inquiry */ /* ========================================================== | Other micro-service data inquiry */
......
...@@ -43,8 +43,8 @@ public class AdamEntersServiceImpl implements IAdamEntersService { ...@@ -43,8 +43,8 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
@Override @Override
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) // @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public String add(AdamEntersParam parameter) { public String add(AdamEntersParam parameter, String currentUid, List<AdamEntersVo> vos) {
String currentUid = CurrentUtil.getCurrentUid(); // String currentUid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
...@@ -58,7 +58,7 @@ public class AdamEntersServiceImpl implements IAdamEntersService { ...@@ -58,7 +58,7 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
} }
List<AdamEntersVo> vos = adamRdmService.getEntersVoByUid(currentUid); // List<AdamEntersVo> vos = adamRdmService.getEntersVoByUid(currentUid);
AdamEntersVo vo = AdamEntersVo.getNew(); AdamEntersVo vo = AdamEntersVo.getNew();
BeanUtils.copyProperties(parameter, vo); BeanUtils.copyProperties(parameter, vo);
...@@ -74,15 +74,9 @@ public class AdamEntersServiceImpl implements IAdamEntersService { ...@@ -74,15 +74,9 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis(); s = System.currentTimeMillis();
String msg = SqlMapping.get("adam_enters.add", queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UCENTER.getKey(),
vo.getEntersId(), currentUid, vo.getType(), vo.getName(), vo.getMobile(), vo.getIdCard(), vo.getIsDefault(), vo.getState(), now SqlMapping.get("adam_enters.add",
); vo.getEntersId(), currentUid, vo.getType(), vo.getName(), vo.getMobile(), vo.getIdCard(), vo.getIsDefault(), vo.getState(), now)
log.debug("#SQL.GET耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis();
queueUtils.sendMsgByRedis(
MQConst.AdamQueue.SQL_UCENTER.getKey(),
msg
); );
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s); log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
return vo.getEntersId(); return vo.getEntersId();
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
10023=背景图不合规 10023=背景图不合规
10024=该账号已被主动注销 10024=该账号已被主动注销
10025=入场人已达上限 10025=入场人已达上限
10026=入场人今日操作已达上限
10101=姓名或身份证件号无效 10101=姓名或身份证件号无效
......
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