Commit faec7e69 authored by hanfeng's avatar hanfeng

增加实名认证之后获取积分

parent e1ccc6e6
......@@ -5,6 +5,7 @@ import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.universal.biz.MQServiceBiZ;
......@@ -96,16 +97,16 @@ public class CertificationController {
log.info("----type========="+type);
try {
if (type!=null&&type==0){
ObjectRestResponse certificate = certificationService.certificate(idInformation);
if (certificate.getRel()) {
ObjectRestResponse<Integer> result = certificationService.certificate(idInformation);
if (result.getRel()) {
executor.execute(new Runnable() {
@Override
public void run() {
setIntegral(appUserDTO.getUserid());
setIntegral(appUserDTO.getUserid(),result.getData());
}
});
}
return certificate ;
return result ;
}
} catch (Exception e) {
e.printStackTrace();
......@@ -115,8 +116,12 @@ public class CertificationController {
}
private void setIntegral(Integer userid){
private void setIntegral(Integer userid, Integer iId){
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId", userid);
jsonObject.put("integralRuleCode", "CRETIFICATION");
jsonObject.put("channelId", iId);
mqServiceBiZ.sendMessage(RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY, jsonObject.toJSONString());
}
}
......@@ -4,24 +4,25 @@ package com.xxfc.platform.universal.service;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.universal.biz.IdInformationBiz;
import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.mapper.IdInformationMapper;
import com.xxfc.platform.universal.utils.CertifHttpUtils;
import com.xxfc.platform.universal.utils.Validation;
import javafx.application.Application;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.util.EntityUtils;
import org.apache.poi.ss.usermodel.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.text.ParseException;
......@@ -133,88 +134,13 @@ public class CertificationService {
@Autowired
private UserFeign userFeign;
// //身份证号+姓名认证
//
// public ObjectRestResponse stringCertificate(IdInformation idInformation) {
// HashedMap hashMap = new HashedMap();
// // 认证状态:true是认证过
//
//
// Integer certificateType = idInformation.getCertificateType();
// if (certificateType == 0) {
//
// if (!Validation.isIdCard(idInformation.getIdNumber())) {
// return ObjectRestResponse.createFailedResult(ResultCode.WRONG_FORMAT_OF_ID_CARD, "身份证格式错误");
// }
// }
//
//
// if (idInformation == null) {
//
//
// return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "未填写");
//
//
// }
//
// if (idInformation.getExpirationDate() == null) {
//
// return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "请填写证件到期时间");
// }
//
//
// //判断是否有填写身份证号
// if (StringUtils.isBlank(idInformation.getIdNumber())) {
// return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "请填写身份证号");
//
//
// }
//
// //判断是有否填写名字
// if (StringUtils.isBlank(idInformation.getName())) {
//
// return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "请填写姓名");
//
// }
//
// //获取查询参数
// Map<String, String> querys = new HashMap<String, String>();
// querys.put(idCardName, idInformation.getIdNumber());
//
// querys.put(cName, idInformation.getName());
//
// //认证
// String result = certificate(querys);
// System.out.println(result);
//
// //判断返回的值是否为空
// if (!StringUtils.isBlank(result)) {
//
// Map<String, String> resultMap = (Map<String, String>) JSONObject.parse(result);
//
// if (resultMap != null) {
// //认证成功
// if (certifResultCode.equals(resultMap.get(certifRet))) {
// Boolean aBoolean = addIdInformation(idInformation);
// if (aBoolean) {
//
// return ObjectRestResponse.succ();
// }
//
//
// }
// }
// }
// return ObjectRestResponse.createDefaultFail();
//
//
// }
@Autowired
private ApplicationContext applicationContext;
// 身份证图片进行实名认证
public ObjectRestResponse certificate(IdInformation idInformation) {
public ObjectRestResponse<Integer> certificate(IdInformation idInformation) {
//1.判断
//携带返回参数的map
HashedMap hashMap = new HashedMap();
......@@ -368,11 +294,11 @@ public class CertificationService {
}
}
idInformation.setExpirationDate(expirationDate);
Boolean aBoolean = addIdInformation(idInformation);
log.info("----请求admin=========" + aBoolean);
if (aBoolean) {
return ObjectRestResponse.succ();
CertificationService cs = applicationContext.getBean(this.getClass());
ObjectRestResponse objRR =cs.addIdInformation(idInformation);
log.info("----请求admin=========" + objRR);
if (objRR.getRel()) {
return ObjectRestResponse.succ(objRR.getData());
}
}
......@@ -469,18 +395,20 @@ public class CertificationService {
//认证通过保存到数据库当中
public Boolean addIdInformation(IdInformation idInformation) {
@Transactional(rollbackFor = Exception.class)
public ObjectRestResponse<Integer> addIdInformation(IdInformation idInformation) {
log.info("----idInformation=========" + idInformation);
//保存认证信息
try {
idInformationMapper.addIdInformation(idInformation);
idInformationMapper.insertSelective(idInformation);
//认证成功后修改用户,用户认证状态
ObjectRestResponse authentication = userFeign.authentication(idInformation.getUserLonginId(), idInformation.getName(), idInformation.getIdNumber(), 1);
return true;
return ObjectRestResponse.succ(idInformation.getId());
} catch (Exception e) {
e.printStackTrace();
return false;
TransactionAspectSupport.currentTransactionStatus();
return ObjectRestResponse.createDefaultFail();
}
......
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