Search in sources :

Example 1 with PersonInfo

use of com.itrus.portal.db.PersonInfo in project portal by ixinportal.

the class BankCertificationController method verifyCode.

/**
 * 验证动态码/银行卡认证处理
 *
 * @param mPhone
 * @param code
 * @param request
 * @return
 */
@RequestMapping(value = "/verifyCode")
@ResponseBody
public Map<String, Object> verifyCode(@RequestHeader("Content-Signature") String authHmac, @RequestParam(value = "personId", required = false) Long personId, @RequestParam(value = "productId", required = false) Long productId, @RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "code", required = true) String code, @RequestParam(value = "personName", required = true) String personName, @RequestParam(value = "personNo", required = true) String personNo, @RequestParam(value = "bankNo", required = true) String bankNo, HttpServletRequest request) {
    // 得到当前个人用户信息
    HttpSession session = request.getSession();
    PersonInfo personInfo = (PersonInfo) session.getAttribute("webuserInfo");
    // PersonInfo personInfo =personInfoService.getSelectById(personId);
    // 得到当前产品信息
    Product product = productService.getProductById(productId);
    // 判断是否已经存在订单
    List list = personalBillService.selectPersonalBillByPersonId(2, personId, productId, 8);
    PersonalBill personalBill = null;
    if (list.size() == 0) {
        // 产生新订单
        personalBill = personalBillService.saveBill(personId, personInfo.getmPhone(), productId, 2, product.getProject(), 1, product.getPrice(), personId, 3);
    } else {
        personalBill = (PersonalBill) list.get(0);
    }
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识处理失败,1标识成功
    retMap.put("retCode", 0);
    try {
        // 验证动态码,
        if (!dynamicCodeService.verifyCode(mPhone, code)) {
            // if(false){
            // 验证码不通过
            retMap.put("retMsg", "动态码验证失败");
            return retMap;
        } else {
            // 调用银行卡认证
            String str = pbankrealtestsms(authHmac, personName, personNo, bankNo, mPhone, "1");
            retMap.put("retCode", 1);
            JSONObject jasonObject = JSONObject.parseObject(str);
            Map map = (Map) jasonObject;
            String status = (String) map.get("status");
            PersonInfo personInfo1 = personInfoService.getSelectById(personInfo.getId());
            if ("200".equals(status)) {
                retMap.put("retCode", 1);
                // 添加银行卡信息
                BankcardInfo bank = bankcardInfoService.saveBankcardInfo(personName, mPhone, personNo, bankNo, personId, null);
                // 认证成功修改订单信息
                personalBill.setReservedPhone(mPhone);
                personalBill.setBankNo(bankNo);
                personalBill.setRealName(personName);
                personalBill.setIdCode(personNo);
                personalBill.setBillStatus(8);
                personalBill.setCheckTime(new Date());
                personalBillService.updateByPersonalBill(personalBill);
                // 修改个人用户信息
                personInfo1.setRealName(personName);
                personInfo1.setPersonName(personName);
                personInfo1.setIdCode(personNo);
                personInfoService.updateByPersonInfo(personInfo1);
                // 生成认证记录
                personalReviewLogService.saveReviewLog(1, null, 1, null, personalBill.getId(), personId, bank.getId());
                // 添加系统日志
                LogUtil.syslog(sqlSession, "银行卡认证送审成功", "产品ID" + personalBill.getProduct() + "订单ID:" + personalBill.getBillId());
            } else {
                if ("201".equals(status)) {
                    retMap.put("retMsg", map.get("message"));
                } else if ("205".equals(status)) {
                    retMap.put("retMsg", map.get("error"));
                }
                // 认证失败修改订单状态
                personalBill.setBillStatus(4);
                personalBillService.updateByPersonalBill(personalBill);
                // 生成认证记录
                personalReviewLogService.saveReviewLog(1, null, 2, map.get("error").toString(), personalBill.getId(), personId, null);
                // 添加系统日志
                LogUtil.syslog(sqlSession, "银行卡认证送审失败", "产品ID" + personalBill.getProduct() + "订单ID:" + personalBill.getBillId());
            }
        }
    } catch (Exception e) {
        retMap.put("retMsg", "出现未知异常,请联系管理员处理");
        String info = mPhone + "认证失败,原因:" + e.getMessage();
        LogUtil.syslog(sqlSession, "银行卡认证", info);
        return retMap;
    }
    return retMap;
}
Also used : BankcardInfo(com.itrus.portal.db.BankcardInfo) PersonInfo(com.itrus.portal.db.PersonInfo) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) Product(com.itrus.portal.db.Product) Date(java.util.Date) PersonalBill(com.itrus.portal.db.PersonalBill) JSONObject(com.alibaba.fastjson.JSONObject) ArrayList(java.util.ArrayList) List(java.util.List) JSONObject(com.alibaba.fastjson.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with PersonInfo

use of com.itrus.portal.db.PersonInfo in project portal by ixinportal.

the class IdCertificationController method loadImg.

/**
 * 得到个人用户的免冠照
 * @return
 */
@RequestMapping(value = "/img/{id}")
public String loadImg(@PathVariable("id") Long id, HttpServletResponse response) {
    String img = null;
    OutputStream os = null;
    FileInputStream fis = null;
    try {
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        PersonInfo personinfo = personInfoService.getSelectById(id);
        if (personinfo == null) {
            return "status403";
        }
        img = personinfo.getBareheadedImg();
        File file = null;
        file = filePathUtils.getEnterpriseFile("personaltestsms");
        if (!file.exists()) {
            file.mkdir();
        }
        File imgFile = new File(file, img);
        fis = new FileInputStream(imgFile);
        byte[] bb = IOUtils.toByteArray(fis);
        os = response.getOutputStream();
        os.write(bb);
        os.flush();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        // 关闭流!
        try {
            if (null != fis) {
                fis.close();
            }
            if (null != os) {
                os.close();
            }
        } catch (IOException e) {
        }
    }
    return null;
}
Also used : PersonInfo(com.itrus.portal.db.PersonInfo) OutputStream(java.io.OutputStream) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with PersonInfo

use of com.itrus.portal.db.PersonInfo in project portal by ixinportal.

the class IdCertificationController method personaltestsms.

// 测试人像识别接口
@RequestMapping(value = "/personaltestsms")
@ResponseBody
public Map<String, Object> personaltestsms(@RequestHeader("Content-Signature") String authHmac, @RequestParam(value = "personId", required = false) Long personId, @RequestParam(value = "productId", required = false) Long productId, @RequestParam(value = "personName", required = false) String personName, @RequestParam(value = "personNo", required = false) String personNo, @RequestParam(value = "frontPhoto", required = false) String frontPhoto, HttpServletRequest request, Model uiModel) throws Exception {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识发送验证码失败,1标识成功
    retMap.put("retCode", 0);
    // 得到当前个人用户信息
    HttpSession session = request.getSession();
    PersonInfo personInfo = (PersonInfo) session.getAttribute("webuserInfo");
    // PersonInfo personInfo =personInfoService.getSelectById(personId);
    // 得到当前产品信息
    Product product = productService.getProductById(productId);
    // 判断是否已经存在订单
    List list = personalBillService.selectPersonalBillByPersonId(1, personId, productId, 8);
    PersonalBill personalBill = null;
    if (list.size() == 0) {
        // 产生新订单
        personalBill = personalBillService.saveBill(personId, personInfo.getmPhone(), productId, 1, product.getProject(), 1, product.getPrice(), personId, 3);
    } else {
        personalBill = (PersonalBill) list.get(0);
    }
    // 保存图片
    // System.out.println(frontPhoto);
    File frontImg = personInfoService.saveBareheadedImg(frontPhoto);
    // 调用人像认证接口
    String appId = sysconfigService.getPersonAppid();
    String personUrl = sysconfigService.getPersonUrl();
    String str = personalService.personal(authHmac, appId, personName, personNo, frontPhoto, personUrl);
    JSONObject jasonObject = JSONObject.parseObject(str);
    Map map = (Map) jasonObject;
    String status = (String) map.get("status");
    PersonInfo personInfo1 = personInfoService.getSelectById(personInfo.getId());
    try {
        // 判断认证是否成功; 200:成功 ,201:失败 , 205:系统错误
        if ("200".equals(status)) {
            retMap.put("retCode", 1);
            retMap.put("retMsg", map.get("message"));
            // 修改个人用户信息
            if (frontImg != null && frontImg.isFile()) {
                personInfo1.setBareheadedImg(frontImg.getName());
                personInfo1.setBareheadedImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
            }
            personInfo1.setRealName(personName);
            personInfo1.setPersonName(personName);
            personInfo1.setIdCode(personNo);
            personInfoService.updateByPersonInfo(personInfo1);
            // 修改订单信息
            personalBill.setIdCode(personNo);
            personalBill.setRealName(personName);
            if (frontImg != null && frontImg.isFile()) {
                personalBill.setBareheadedImg(frontImg.getName());
                personalBill.setBareheadedImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
            }
            personalBill.setBillStatus(8);
            personalBill.setCheckTime(new Date());
            personalBillService.updateByPersonalBill(personalBill);
            // 生成认证记录
            personalReviewLogService.saveReviewLog(1, null, 1, null, personalBill.getId(), personId, null);
            // 添加系统日志
            LogUtil.syslog(sqlSession, "个人实名认证认证通过", "产品ID" + personalBill.getProduct() + "订单ID:" + personalBill.getBillId());
        } else {
            if ("201".equals(status)) {
                retMap.put("retMsg", map.get("message"));
                // 生成认证记录
                personalReviewLogService.saveReviewLog(1, null, 2, map.get("message").toString(), personalBill.getId(), personId, null);
            } else if ("205".equals(status)) {
                retMap.put("retMsg", map.get("error"));
                // 生成认证记录
                personalReviewLogService.saveReviewLog(1, null, 2, map.get("error").toString(), personalBill.getId(), personId, null);
            }
            // 认证失败修改订单状态
            personalBill.setBillStatus(4);
            personalBillService.updateByPersonalBill(personalBill);
            // 添加系统日志
            LogUtil.syslog(sqlSession, "个人实名认证认证失败", "产品ID" + personalBill.getProduct() + "订单ID:" + personalBill.getBillId());
        }
    } catch (Exception e) {
        // TODO: handle exception
        retMap.put("retMsg", "出现未知异常,请联系管理员处理");
        String info = personName + "认证失败,原因:" + e.getMessage();
        LogUtil.syslog(sqlSession, "个人实名认证", info);
        return retMap;
    }
    return retMap;
}
Also used : PersonInfo(com.itrus.portal.db.PersonInfo) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) Product(com.itrus.portal.db.Product) Date(java.util.Date) IOException(java.io.IOException) PersonalBill(com.itrus.portal.db.PersonalBill) JSONObject(com.alibaba.fastjson.JSONObject) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with PersonInfo

use of com.itrus.portal.db.PersonInfo in project portal by ixinportal.

the class PersonInfoController method loadImg.

/**
 * 得到个人用户的免冠照
 * @return
 */
@RequestMapping(value = "/img/{id}")
public String loadImg(@PathVariable("id") Long id, HttpServletResponse response) {
    String img = null;
    OutputStream os = null;
    FileInputStream fis = null;
    try {
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        PersonInfo personinfo = personInfoService.getSelectById(id);
        if (personinfo == null) {
            return "status403";
        }
        img = personinfo.getBareheadedImg();
        File file = null;
        file = filePathUtils.getEnterpriseFile("personaltestsms");
        if (!file.exists()) {
            file.mkdir();
        }
        File imgFile = new File(file, img);
        fis = new FileInputStream(imgFile);
        byte[] bb = IOUtils.toByteArray(fis);
        os = response.getOutputStream();
        os.write(bb);
        os.flush();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        // 关闭流!
        try {
            if (null != fis) {
                fis.close();
            }
            if (null != os) {
                os.close();
            }
        } catch (IOException e) {
        }
    }
    return null;
}
Also used : PersonInfo(com.itrus.portal.db.PersonInfo) OutputStream(java.io.OutputStream) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with PersonInfo

use of com.itrus.portal.db.PersonInfo in project portal by ixinportal.

the class BankCertificationController method create.

// 跳转yinhangkarenzheng页面
@RequestMapping("/create/{productId}")
public String create(@PathVariable("productId") Long productId, HttpServletRequest request, Model uiModel) {
    // 得到当前个人用户信息
    HttpSession session = request.getSession();
    PersonInfo personInfo = (PersonInfo) session.getAttribute("webuserInfo");
    // PersonInfo personInfo =personInfoService.getSelectById(personId);
    // 得到对应的产品
    Product product = productService.getProductById(productId);
    // 得到对应的认证项
    Certification certification = certificationService.getSelectById(product.getAuthentication());
    uiModel.addAttribute("product", product);
    uiModel.addAttribute("personInfo", personInfo);
    uiModel.addAttribute("certification", certification);
    return "gerenrenzheng/yinhangkarenzheng";
}
Also used : PersonInfo(com.itrus.portal.db.PersonInfo) HttpSession(javax.servlet.http.HttpSession) Product(com.itrus.portal.db.Product) Certification(com.itrus.portal.db.Certification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PersonInfo (com.itrus.portal.db.PersonInfo)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 Product (com.itrus.portal.db.Product)6 File (java.io.File)6 IOException (java.io.IOException)6 FileInputStream (java.io.FileInputStream)5 OutputStream (java.io.OutputStream)5 HttpSession (javax.servlet.http.HttpSession)5 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 JSONObject (com.alibaba.fastjson.JSONObject)3 PersonalBill (com.itrus.portal.db.PersonalBill)3 Date (java.util.Date)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 BankcardInfo (com.itrus.portal.db.BankcardInfo)2 Certification (com.itrus.portal.db.Certification)2 ArrayList (java.util.ArrayList)2 BankcardInfoExample (com.itrus.portal.db.BankcardInfoExample)1 PersonalBillExample (com.itrus.portal.db.PersonalBillExample)1