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

Commit 9c190bc9 authored by 张国柄's avatar 张国柄

fix:编辑入场人+身份证实名校验;

parent 3d6743aa
......@@ -16,6 +16,7 @@ public class AdamRedisConst {
public static final String INFO_THIRD_PARTY = INFO.concat("third_party:");
public static final String INFO_ENTERS = INFO.concat("enters:");
public static final String INFO_ADDRESSES = INFO.concat("addresses:");
public static final String INFO_CERTIFICATION = INFO.concat("certification:");
public static final String INFO_MEMBER_SIMPLE = INFO.concat("member:simple");
public static final String INFO_MEMBER_CATEGORY = INFO.concat("member:category:");
......
......@@ -28,7 +28,9 @@ public interface IAdamRdmService {
AdamRealInfoVo getRealInfoVoByUid(String uid);
void delRealInfoVoByUid(String uid);
boolean setCertification(int idType, String idNo, String idName);
boolean isCertification(int idType, String idNo, String idName);
boolean setThirdPartVoListByUid(String uid, List<AdamThirdPartInfoVo> voList);
......
......@@ -11,6 +11,7 @@ import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.SqlMapping;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.ReturnDocument;
import com.mongodb.client.result.DeleteResult;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
......@@ -184,25 +185,21 @@ public class AdamAddressesServiceImpl implements IAdamAddressesService {
// removeVo.setDeletedAt(now);
long s = System.currentTimeMillis();
Document doc = mongoTemplate.getCollection(AdamAddressesVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("addressesId").is(addressesId)).getQueryObject(),
new Document("$set", new Document("state", 2).append("isDefault", false).append("updatedAt", now).append("deletedAt", now)),
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
DeleteResult deleteResult = mongoTemplate.remove(
Query.query(Criteria.where("addressesId").is(addressesId)), AdamAddressesVo.class.getSimpleName()
);
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
if (null != doc) {
List<AdamAddressesVo> vos = adamRdmService.getAddressesVoByUid(uid);
vos.removeIf(r -> r.getAddressesId().equals(addressesId));
s = System.currentTimeMillis();
adamRdmService.setAddressesVoByUid(uid, vos);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
List<AdamAddressesVo> vos = adamRdmService.getAddressesVoByUid(uid);
vos.removeIf(r -> r.getAddressesId().equals(addressesId));
s = System.currentTimeMillis();
adamRdmService.setAddressesVoByUid(uid, vos);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis();
rabbitTemplate.convertAndSend(MQConst.EX_LNS_SQL_UCENTER, MQConst.RK_SQL_UCENTER,
SqlMapping.get("adam_addresses.remove", now, now, addressesId)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
s = System.currentTimeMillis();
rabbitTemplate.convertAndSend(MQConst.EX_LNS_SQL_UCENTER, MQConst.RK_SQL_UCENTER,
SqlMapping.get("adam_addresses.remove", now, now, addressesId)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
@Override
......
......@@ -11,6 +11,7 @@ import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.SqlMapping;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.ReturnDocument;
import com.mongodb.client.result.DeleteResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.bson.Document;
......@@ -19,12 +20,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.MongoConverter;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
......@@ -65,26 +63,8 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
if (1 == parameter.getType()) {
LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("realName", parameter.getName());
paramsMap.add("cardNo", parameter.getIdCard());
String respStr = null;
try {
long s = System.currentTimeMillis();
respStr = HttpUtil.postToPhpApi(env.getProperty("liquidnet.url-service.url") + PHP_API_REAL_NAME, paramsMap);
log.debug("#PHP.API耗时:{}ms", System.currentTimeMillis() - s);
log.debug("###PHP.API[{}].RESP:{}", PHP_API_REAL_NAME, respStr);
Map respMap = JsonUtils.fromJson(respStr, Map.class);
if (CollectionUtils.isEmpty(respMap) || !StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"))) {
log.warn("PHP.API实名认证失败[uid:{},name:{},idCard:{},respStr:{}]", currentUid, parameter.getName(), parameter.getIdCard(), respStr);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
} catch (Exception e) {
log.error("PHP.API实名认证异常[uid:{},name:{},idCard:{},respStr:{}]", currentUid, parameter.getName(), parameter.getIdCard(), respStr, e);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
if (!adamRdmService.isCertification(1, parameter.getIdCard(), parameter.getName())) {
identityHandler(currentUid, parameter.getName(), parameter.getIdCard());
}
}
......@@ -105,6 +85,9 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
s = System.currentTimeMillis();
adamRdmService.delEntersVoByUid(currentUid);
if (1 == parameter.getType()) {
adamRdmService.setCertification(1, parameter.getIdCard(), parameter.getName());
}
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis();
......@@ -178,9 +161,18 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
}
@Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void edit(AdamEntersParam parameter) {
LocalDateTime now = LocalDateTime.now();
String currentUid = CurrentUtil.getCurrentUid();
if (1 == parameter.getType()) {
if (!adamRdmService.isCertification(1, parameter.getIdCard(), parameter.getName())) {
identityHandler(currentUid, parameter.getName(), parameter.getIdCard());
}
}
AdamEntersVo updateVo = AdamEntersVo.getNew();
BeanUtils.copyProperties(parameter, updateVo);
......@@ -194,10 +186,12 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
if (null != doc) {
updateVo = BsonUtil.toBean(doc, AdamEntersVo.class);
String currentUid = CurrentUtil.getCurrentUid();
List<AdamEntersVo> vos = adamRdmService.getEntersVoByUid(currentUid);
s = System.currentTimeMillis();
adamRdmService.setEntersVoByUid(currentUid, this.collectionProcess(vos, parameter.getEntersId(), updateVo));
if (1 == parameter.getType()) {
adamRdmService.setCertification(1, parameter.getIdCard(), parameter.getName());
}
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis();
......@@ -211,36 +205,25 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
}
@Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void remove(String uid, String entersId) {
LocalDateTime now = LocalDateTime.now();
// AdamEntersVo removeVo = AdamEntersVo.getNew();
// removeVo.setState(2);
// removeVo.setIsDefault(false);
// removeVo.setUpdatedAt(now);
// removeVo.setDeletedAt(now);
long s = System.currentTimeMillis();
Document doc = mongoTemplate.getCollection(AdamEntersVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("entersId").is(entersId)).getQueryObject(),
new Document("$set", new Document("state", 2).append("isDefault", false).append("updatedAt", now).append("deletedAt", now)),
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
DeleteResult deleteResult = mongoTemplate.remove(
Query.query(Criteria.where("entersId").is(entersId)), AdamEntersVo.class.getSimpleName()
);
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
if (null != doc) {
List<AdamEntersVo> vos = adamRdmService.getEntersVoByUid(uid);
vos.removeIf(r -> r.getEntersId().equals(entersId));
s = System.currentTimeMillis();
adamRdmService.setEntersVoByUid(uid, vos);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
List<AdamEntersVo> vos = adamRdmService.getEntersVoByUid(uid);
vos.removeIf(r -> r.getEntersId().equals(entersId));
s = System.currentTimeMillis();
adamRdmService.setEntersVoByUid(uid, vos);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis();
rabbitTemplate.convertAndSend(MQConst.EX_LNS_SQL_UCENTER, MQConst.RK_SQL_UCENTER,
SqlMapping.get("adam_enters.remove", now, now, entersId)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
s = System.currentTimeMillis();
rabbitTemplate.convertAndSend(MQConst.EX_LNS_SQL_UCENTER, MQConst.RK_SQL_UCENTER,
SqlMapping.get("adam_enters.remove", now, now, entersId)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
@Override
......@@ -286,4 +269,28 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
log.debug("#collect.process耗时:{}ms", System.currentTimeMillis() - s);
return vos;
}
private void identityHandler(String currentUid, String name, String idCard) {
String respStr = null;
try {
LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("realName", name);
paramsMap.add("cardNo", idCard);
long s = System.currentTimeMillis();
respStr = HttpUtil.postToPhpApi(env.getProperty("liquidnet.url-service.url") + PHP_API_REAL_NAME, paramsMap);
log.debug("#PHP.API耗时:{}ms", System.currentTimeMillis() - s);
log.debug("###PHP.API[{}].RESP:{}", PHP_API_REAL_NAME, respStr);
Map respMap = JsonUtils.fromJson(respStr, Map.class);
if (CollectionUtils.isEmpty(respMap) || !StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"))) {
log.warn("PHP.API实名认证失败[uid:{},name:{},idCard:{},respStr:{}]", currentUid, name, idCard, respStr);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
} catch (Exception e) {
log.error("PHP.API实名认证异常[uid:{},name:{},idCard:{},respStr:{}]", currentUid, name, idCard, respStr, e);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
}
}
......@@ -143,8 +143,14 @@ public class AdamRdmServiceImpl implements IAdamRdmService {
}
@Override
public void delRealInfoVoByUid(String uid) {
redisUtil.del(AdamRedisConst.INFO_REAL_NAME.concat(uid));
public boolean setCertification(int idType, String idNo, String idName) {
return redisUtil.set(AdamRedisConst.INFO_CERTIFICATION + idType + idNo, idName);
}
@Override
public boolean isCertification(int idType, String idNo, String idName) {
String o = (String) redisUtil.get(AdamRedisConst.INFO_CERTIFICATION + idType + idNo);
return !StringUtils.isEmpty(o) && o.equals(idName);
}
@Override
......
......@@ -366,26 +366,27 @@ public class AdamUserServiceImpl implements IAdamUserService {
if (RedisLockUtil.tryLock(AdamRedisConst.LOCK_KEY_UIDENTITY + uid, 1, 3)) {
vo = adamRdmService.getRealInfoVoByUid(uid);
if (null == vo) {
LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("realName", name);
paramsMap.add("cardNo", idCard);
String respStr = null;
try {
long s = System.currentTimeMillis();
respStr = HttpUtil.postToPhpApi(env.getProperty("liquidnet.url-service.url") + PHP_API_REAL_NAME, paramsMap);
log.debug("#PHP.API耗时:{}ms", System.currentTimeMillis() - s);
log.debug("###PHP.API[{}].RESP:{}", PHP_API_REAL_NAME, respStr);
Map respMap = JsonUtils.fromJson(respStr, Map.class);
if (CollectionUtils.isEmpty(respMap) || !StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"))) {
log.warn("PHP.API实名认证失败[uid:{},name:{},idCard:{},respStr:{}]", uid, name, idCard, respStr);
if (!adamRdmService.isCertification(1, idCard, name)) {
String respStr = null;
try {
LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("realName", name);
paramsMap.add("cardNo", idCard);
long s = System.currentTimeMillis();
respStr = HttpUtil.postToPhpApi(env.getProperty("liquidnet.url-service.url") + PHP_API_REAL_NAME, paramsMap);
log.debug("#PHP.API耗时:{}ms", System.currentTimeMillis() - s);
log.debug("###PHP.API[{}].RESP:{}", PHP_API_REAL_NAME, respStr);
Map respMap = JsonUtils.fromJson(respStr, Map.class);
if (CollectionUtils.isEmpty(respMap) || !StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"))) {
log.warn("PHP.API实名认证失败[uid:{},name:{},idCard:{},respStr:{}]", uid, name, idCard, respStr);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
} catch (Exception e) {
log.error("PHP.API实名认证异常[uid:{},name:{},idCard:{},respStr:{}]", uid, name, idCard, respStr, e);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
} catch (Exception e) {
log.error("PHP.API实名认证异常[uid:{},name:{},idCard:{},respStr:{}]", uid, name, idCard, respStr, e);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
AdamRealName realName = new AdamRealName();
......@@ -407,6 +408,7 @@ public class AdamUserServiceImpl implements IAdamUserService {
long s = System.currentTimeMillis();
adamRdmService.setRealInfoVoByUid(uid, vo);
adamRdmService.setCertification(1, idCard, name);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
}
RedisLockUtil.unlock(AdamRedisConst.LOCK_KEY_UIDENTITY + uid);
......
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