|
@@ -0,0 +1,374 @@
|
|
|
+package com.demo.wjj.controller;
|
|
|
+
|
|
|
+import com.demo.wjj.po.Agent;
|
|
|
+import com.demo.wjj.po.UserInfo;
|
|
|
+import com.demo.wjj.service.*;
|
|
|
+import com.demo.wjj.utils.ApiResult;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.List;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+@RequestMapping("/certification")
|
|
|
+@RestController
|
|
|
+public class CertificationController {
|
|
|
+ private final Logger LOG = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CertificationService certificationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AgentService agentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ QiNiuService qiNiuService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断是否实名认证
|
|
|
+ * @return apiResult
|
|
|
+ */
|
|
|
+ @GetMapping("/getUserInfo")
|
|
|
+ public ApiResult getUserInfo(String idCard,String status) {
|
|
|
+ LOG.info("调用获取用户信息(/certification/getUserInfo)接口");
|
|
|
+ try {
|
|
|
+ UserInfo userInfo = certificationService.getUserInfo(idCard,status);
|
|
|
+ if(userInfo!=null) {
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getIdcarddfrontpic())) {
|
|
|
+ String Idcarddfrontpic = qiNiuService.getUrl(userInfo.getIdcarddfrontpic());
|
|
|
+ userInfo.setIdcarddfrontpic(Idcarddfrontpic);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getIdcarddbackpic())) {
|
|
|
+ String Idcarddbackpic = qiNiuService.getUrl(userInfo.getIdcarddbackpic());
|
|
|
+ userInfo.setIdcarddbackpic(Idcarddbackpic);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getPic())) {
|
|
|
+ String pic = qiNiuService.getUrl(userInfo.getPic());
|
|
|
+ userInfo.setPic(pic);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getBankcardpic())) {
|
|
|
+ String bankcardpic = qiNiuService.getUrl(userInfo.getBankcardpic());
|
|
|
+ userInfo.setBankcardpic(bankcardpic);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LOG.info("userInfo="+userInfo);
|
|
|
+ ApiResult<UserInfo> apiResult = ApiResult.createSuccess(userInfo);
|
|
|
+ LOG.info("调用获取用户信息(/certification/getUserInfo)接口成功");
|
|
|
+ LOG.debug("调用获取用户信息(/certification/getUserInfo), apiResult:{}", apiResult);
|
|
|
+ return apiResult;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOG.error("调用获取用户信息(/certification/getUserInfo)接口异常", e);
|
|
|
+ return ApiResult.createFailure();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @GetMapping("/getUserInfoByAgent")
|
|
|
+ public ApiResult getUserInfoByAgent(String status,String angentId) {
|
|
|
+ LOG.info("调用获取用户信息(/certification/getUserInfo)接口");
|
|
|
+ try {
|
|
|
+ List<UserInfo> userInfos = certificationService.getUserInfoByAgent(status,angentId);
|
|
|
+ for(UserInfo userInfo:userInfos) {
|
|
|
+ if (userInfo != null) {
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getIdcarddfrontpic())) {
|
|
|
+ String Idcarddfrontpic = qiNiuService.getUrl(userInfo.getIdcarddfrontpic());
|
|
|
+ userInfo.setIdcarddfrontpic(Idcarddfrontpic);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getIdcarddbackpic())) {
|
|
|
+ String Idcarddbackpic = qiNiuService.getUrl(userInfo.getIdcarddbackpic());
|
|
|
+ userInfo.setIdcarddbackpic(Idcarddbackpic);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getPic())) {
|
|
|
+ String pic = qiNiuService.getUrl(userInfo.getPic());
|
|
|
+ userInfo.setPic(pic);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getBankcardpic())) {
|
|
|
+ String bankcardpic = qiNiuService.getUrl(userInfo.getBankcardpic());
|
|
|
+ userInfo.setBankcardpic(bankcardpic);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ApiResult<List<UserInfo>> apiResult = ApiResult.createSuccess(userInfos);
|
|
|
+ LOG.info("调用获取用户信息(/certification/getUserInfo)接口成功");
|
|
|
+ LOG.debug("调用获取用户信息(/certification/getUserInfo), apiResult:{}", apiResult);
|
|
|
+ return apiResult;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOG.error("调用获取用户信息(/certification/getUserInfo)接口异常", e);
|
|
|
+ return ApiResult.createFailure();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getUserInfoByAgentAndOpenId")
|
|
|
+ public ApiResult getUserInfoByAgentAndOpenId(String status,String angentId,String openId) {
|
|
|
+ LOG.info("调用获取用户信息(/certification/getUserInfo)接口");
|
|
|
+ try {
|
|
|
+ UserInfo userInfo = certificationService.getUserInfoByAgentAndOpenId(status,angentId,openId);
|
|
|
+
|
|
|
+ if (userInfo != null) {
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getIdcarddfrontpic())) {
|
|
|
+ String Idcarddfrontpic = qiNiuService.getUrl(userInfo.getIdcarddfrontpic());
|
|
|
+ userInfo.setIdcarddfrontpic(Idcarddfrontpic);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getIdcarddbackpic())) {
|
|
|
+ String Idcarddbackpic = qiNiuService.getUrl(userInfo.getIdcarddbackpic());
|
|
|
+ userInfo.setIdcarddbackpic(Idcarddbackpic);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getPic())) {
|
|
|
+ String pic = qiNiuService.getUrl(userInfo.getPic());
|
|
|
+ userInfo.setPic(pic);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(userInfo.getBankcardpic())) {
|
|
|
+ String bankcardpic = qiNiuService.getUrl(userInfo.getBankcardpic());
|
|
|
+ userInfo.setBankcardpic(bankcardpic);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ApiResult<UserInfo> apiResult = ApiResult.createSuccess(userInfo);
|
|
|
+ LOG.info("调用获取用户信息(/certification/getUserInfo)接口成功");
|
|
|
+ LOG.debug("调用获取用户信息(/certification/getUserInfo), apiResult:{}", apiResult);
|
|
|
+ return apiResult;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOG.error("调用获取用户信息(/certification/getUserInfo)接口异常", e);
|
|
|
+ return ApiResult.createFailure();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**,
|
|
|
+ * 四要素验证
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @PostMapping("/userVerification")
|
|
|
+ public ApiResult userVerification(String name,
|
|
|
+ String sex,
|
|
|
+ String idCard,
|
|
|
+ String birthday,
|
|
|
+ String province,
|
|
|
+ String city,
|
|
|
+ String prefecture,
|
|
|
+ String area,
|
|
|
+ String addrCode,
|
|
|
+ String accountNo,
|
|
|
+ String mobile,
|
|
|
+ String bank,
|
|
|
+ String cardName,
|
|
|
+ String cardType,
|
|
|
+ String openId,
|
|
|
+ String idCardDFrontPic,
|
|
|
+ String idCardDBackPic,
|
|
|
+ String cardValidity,
|
|
|
+ String bankCardPic,
|
|
|
+ String role,
|
|
|
+ String pic,
|
|
|
+ String agentId,
|
|
|
+ String url,
|
|
|
+ String verifyOpenId,
|
|
|
+ String appId){
|
|
|
+ UserInfo userInfo=new UserInfo();
|
|
|
+ userInfo.setUsername(name);
|
|
|
+ userInfo.setSex(sex);
|
|
|
+ userInfo.setIdcard(idCard);
|
|
|
+ userInfo.setBirthday(birthday);
|
|
|
+ userInfo.setProvince(province);
|
|
|
+ userInfo.setCity(city);
|
|
|
+ userInfo.setPrefecture(prefecture);
|
|
|
+ userInfo.setArea(area);
|
|
|
+ userInfo.setAddrcode(addrCode);
|
|
|
+ userInfo.setAccountno(accountNo);
|
|
|
+ userInfo.setMobile(mobile);
|
|
|
+ userInfo.setBank(bank);
|
|
|
+ userInfo.setCardname(cardName);
|
|
|
+ userInfo.setCardtype(cardType);
|
|
|
+ userInfo.setUseropenid(openId);
|
|
|
+ userInfo.setIdcarddfrontpic(idCardDFrontPic);
|
|
|
+ userInfo.setIdcarddbackpic(idCardDBackPic);
|
|
|
+ userInfo.setCardvalidity(cardValidity);
|
|
|
+ userInfo.setRole(role);
|
|
|
+ userInfo.setPic(pic);
|
|
|
+ userInfo.setBankcardpic(bankCardPic);
|
|
|
+ LOG.info("userInfo==="+userInfo);
|
|
|
+ final Agent agent = agentService.getAgent(agentId);
|
|
|
+ LOG.info("url==="+url);
|
|
|
+ if (agent == null) {
|
|
|
+ final ApiResult apiResult = ApiResult.createFailure();
|
|
|
+ apiResult.setMessage("未查询到商家信息");
|
|
|
+ return apiResult;
|
|
|
+ }
|
|
|
+ LOG.info("调用四要素验证(/userVerification/getUserVerification)接口");
|
|
|
+ LOG.info("url=="+url);
|
|
|
+ url=url+"?idCard="+userInfo.getIdcard()+"&agentId="+agentId+"&openId="+userInfo.getUseropenid();
|
|
|
+ try {
|
|
|
+ ApiResult res = certificationService.getUserVerifycation(
|
|
|
+ userInfo,
|
|
|
+ agent,
|
|
|
+ url,
|
|
|
+ verifyOpenId,
|
|
|
+ appId);
|
|
|
+
|
|
|
+ LOG.info("调用四要素验证(/userVerification/getUserVerification)接口成功");
|
|
|
+ LOG.debug("调用四要素验证(/userVerification/getUserVerification), apiResult:{}", res);
|
|
|
+ return res;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOG.error("调用四要素验证(/certification/getUserInfo)接口异常", e);
|
|
|
+ return ApiResult.createFailure();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 身份证识别
|
|
|
+ * FRONT:身份证含照片的一面;BACK:身份证带国徽的一面
|
|
|
+ */
|
|
|
+ @PostMapping("/idCardVerification")
|
|
|
+ public ApiResult idCardVerification(String url,String img){
|
|
|
+ LOG.info("调用身份证识别(/userVerification/idCardVerification)接口");
|
|
|
+ try {
|
|
|
+ //获取骑牛上传的url地址
|
|
|
+ String path=qiNiuService.getUrl(url);
|
|
|
+ ApiResult res = certificationService.checkIdCardVerification(path, img);
|
|
|
+ LOG.info("调用身份证识别(/userVerification/idCardVerification)接口成功");
|
|
|
+ LOG.debug("调用身份证识别(/certification/idCardVerification), apiResult:{}", res);
|
|
|
+ return res;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOG.error("调用身份证识别(/certification/idCardVerification)接口异常", e);
|
|
|
+ return ApiResult.createFailure();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 银行卡识别
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @PostMapping("/bankCardVerification")
|
|
|
+ public ApiResult bankCardVerification(String url){
|
|
|
+ LOG.info("调用银行卡识别(/userVerification/bankCardVerification)接口");
|
|
|
+ try {
|
|
|
+ //获取骑牛上传的url地址
|
|
|
+ String path=qiNiuService.getUrl(url);
|
|
|
+ ApiResult res = certificationService.bankCardVerification(path);
|
|
|
+ LOG.info("调用银行卡识别(/userVerification/bankCardVerification)接口成功");
|
|
|
+ LOG.debug("调用银行卡识别(/certification/bankCardVerification), apiResult:{}", res);
|
|
|
+ return res;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOG.error("调用银行卡识别(/certification/bankCardVerification)接口异常", e);
|
|
|
+ return ApiResult.createFailure();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 实名认证说明
|
|
|
+ * @return apiResult
|
|
|
+ */
|
|
|
+ @GetMapping("/getExplain")
|
|
|
+ public ApiResult getExplain(String idCard) {
|
|
|
+ LOG.info("调用实名认证说明(/certification/getExplain)接口");
|
|
|
+ try {
|
|
|
+ ApiResult info = certificationService.getExplainInfo();
|
|
|
+ LOG.info("调用实名认证说明(/certification/getExplain)接口成功");
|
|
|
+ LOG.debug("调用实名认证说明(/certification/getExplain), apiResult:{}", info);
|
|
|
+ return info;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOG.error("调用实名认证说明(/certification/getExplain)接口异常", e);
|
|
|
+ return ApiResult.createFailure();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存实名认证信息
|
|
|
+ * @return apiResult
|
|
|
+ */
|
|
|
+ @PostMapping("/saveUserInfo")
|
|
|
+ public ApiResult saveUserInfo(String userName,
|
|
|
+ String sex,
|
|
|
+ String idcard,
|
|
|
+ String birthday,
|
|
|
+ String province,
|
|
|
+ String city,
|
|
|
+ String prefecture,
|
|
|
+ String area,
|
|
|
+ String addrCode,
|
|
|
+ String account_no,
|
|
|
+ String phone_no,
|
|
|
+ String bank,
|
|
|
+ String cardName,
|
|
|
+ String cardType,
|
|
|
+ String status,
|
|
|
+ String openId,
|
|
|
+ String idCardDFrontPic,
|
|
|
+ String idCardDBackPic,
|
|
|
+ String cardValidity,
|
|
|
+ String role,
|
|
|
+ String pic) {
|
|
|
+ LOG.info("调用保存实名认证信息(/certification/saveUserInfo)接口");
|
|
|
+ UserInfo info=new UserInfo();
|
|
|
+ info.setUsername(userName);
|
|
|
+ info.setSex(sex);
|
|
|
+ info.setIdcard(idcard);
|
|
|
+ info.setBirthday(birthday);
|
|
|
+ info.setProvince(province);
|
|
|
+ info.setCity(city);
|
|
|
+ info.setPrefecture(prefecture);
|
|
|
+ info.setArea(area);
|
|
|
+ info.setAddrcode(addrCode);
|
|
|
+ info.setAccountno(account_no);
|
|
|
+ info.setMobile(phone_no);
|
|
|
+ info.setBank(bank);
|
|
|
+ info.setCardname(cardName);
|
|
|
+ info.setCardtype(cardType);
|
|
|
+ info.setStatus(status);
|
|
|
+ info.setUseropenid(openId);
|
|
|
+ info.setIdcarddfrontpic(idCardDFrontPic);
|
|
|
+ info.setIdcarddbackpic(idCardDBackPic);
|
|
|
+ info.setCardvalidity(cardValidity);
|
|
|
+ info.setRole(role);
|
|
|
+ info.setPic(pic);
|
|
|
+ try {
|
|
|
+ ApiResult apiResult = certificationService.saveUserInfo(info);
|
|
|
+ LOG.info("apiResult="+apiResult);
|
|
|
+ LOG.info("调用保存实名认证信息(/certification/saveUserInfo)接口成功");
|
|
|
+ LOG.debug("调用保存实名认证信息(/certification/saveUserInfo), apiResult:{}", apiResult);
|
|
|
+ return apiResult;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOG.error("调用保存实名认证信息(/certification/saveUserInfo)接口异常", e);
|
|
|
+ return ApiResult.createFailure();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询实名认证列表
|
|
|
+ * 1:待审核 2:实名认证通过
|
|
|
+ */
|
|
|
+ @GetMapping("/getUserVerificationList")
|
|
|
+ public ApiResult getUserVerificationList(String status){
|
|
|
+ ApiResult apiResult = certificationService.getUserVerificationList(status);
|
|
|
+ LOG.info("apiResult="+apiResult);
|
|
|
+ return apiResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核消息模板推送 status:1-通过 2-不通过
|
|
|
+ */
|
|
|
+ @GetMapping("/sendTempMsg")
|
|
|
+ public ApiResult sendTempMsg(String status,String reviewComments,String openId,String idCard,String agentId,String appId){
|
|
|
+ final Agent agent = agentService.getAgent(agentId);
|
|
|
+ LOG.info("agent==="+agent);
|
|
|
+ if (agent == null) {
|
|
|
+ final ApiResult apiResult = ApiResult.createFailure();
|
|
|
+ apiResult.setMessage("未查询到商家信息");
|
|
|
+ return apiResult;
|
|
|
+ }
|
|
|
+ String str = null;
|
|
|
+ LOG.info("reviewComments==="+reviewComments);
|
|
|
+ try {
|
|
|
+ str = new String (reviewComments.getBytes("ISO8859-1"),"utf-8");
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ LOG.info("reviewComments==="+str);
|
|
|
+ ApiResult apiResult = certificationService.sendUserVerification(openId,str, status, agent, idCard, appId);
|
|
|
+ LOG.info("apiResult="+apiResult);
|
|
|
+ return apiResult;
|
|
|
+ }
|
|
|
+}
|