Search in sources :

Example 36 with Project

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

the class ClientWebController method checkInvoceByPDF.

/**
 * retCode:0为失败,1为成功
 * PDF发票校验接口
 * @param invoicePDF:PDF发票文件
 */
@RequestMapping("/fpjyByPDF")
@ResponseBody
public Map<String, Object> checkInvoceByPDF(@RequestParam(value = "invoicePDF", required = true) MultipartFile invoicePDF, @RequestParam(value = "productId", required = true) Long productId, HttpServletRequest request) {
    HttpSession session = request.getSession();
    Map<String, Object> retMap = new HashMap<>();
    retMap.put("retCode", 0);
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        retMap.put("retMsg", "用户登录信息已失效,请重新登录");
        return retMap;
    }
    // 
    Project project = (Project) session.getAttribute("webproject");
    if (null == project) {
        retMap.put("retMsg", "项目信息不存在");
        return retMap;
    }
    // 获取发票校验的应用
    ExtraProduct product = extraProductService.selectByPrimaryKey(productId);
    if (null == product) {
        retMap.put("retMsg", "产品信息不存在");
        return retMap;
    }
    if (invoicePDF.getContentType().equals("pdf")) {
        retMap.put("retMsg", "请上传PDF类型的文件");
        return retMap;
    }
    try {
        File file = baiWangService.getInvoiceImageFilePath();
        String imageFileName = getImageFileName();
        // 将pdf转为图片,存储到制定路径
        PDFToImageUtils.pdf2Pic(invoicePDF.getInputStream(), file, imageFileName);
        File PDFImageFile = new File(file, imageFileName);
        // 0位发票代码,1为发票号码,2为发票校验码
        String[] invoiceInfo = parseQRCodeTool.parseQRCode(PDFImageFile);
        if (null == invoiceInfo || invoiceInfo.length != 3) {
            retMap.put("retMsg", "无法识别发票中的信息,请重新上传或者用其他方式校验发票");
            return retMap;
        }
        // 删除临时文件
        PDFImageFile.deleteOnExit();
        Map<String, String> invoiceMap = baiWangService.verifyInvoice(invoiceInfo[0], invoiceInfo[1], invoiceInfo[2]);
        retMap.putAll(invoiceMap);
        if (null != retMap.get("REPLYCODE") && retMap.get("REPLYCODE").equals("0000")) {
            retMap.put("retCode", 1);
            String info = invoiceMap.toString().replaceAll(" ", "");
            checkInvoiceLogService.insertCheckInvoiceLog(product.getAppName(), webenterprise.getEnterpriseName(), info, project.getId(), webuserInfo.getRealName());
            return retMap;
        } else {
            String REPLYMSG = (String) retMap.get("REPLYMSG");
            retMap.put("retMsg", REPLYMSG);
            return retMap;
        }
    } catch (Exception e) {
        UserLog userlog = new UserLog();
        userlog.setProject(webuserInfo.getProject());
        userlog.setType("校验发票");
        userlog.setInfo("url:fpjyByPDF,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "PDF发票校验出错,请确认您上传的PDF电子发票是否正确或者更换其他查验方式,您还可以请联系管理员,错误代码:fpjyByPDF001");
    }
    return retMap;
}
Also used : HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 37 with Project

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

the class ClientWebController method checkInvoceByPhone.

/**
 * retCode:0为失败,1为成功
 * 手机发票校验接口
 */
@RequestMapping("/fpjyByPhone")
@ResponseBody
public Map<String, Object> checkInvoceByPhone(@RequestParam(value = "invoiceQRImage", required = true) MultipartFile invoiceQRImage, @RequestParam(value = "projectId", required = true) Long projectId, @RequestParam(value = "productId", required = true) Long productId, @RequestParam(value = "userInfoId", required = true) Long userInfoId, @RequestParam(value = "enterpriseId", required = true) Long enterpriseId, @RequestParam(value = "currentTimeMillis", required = true) Long currentTimeMillis, HttpServletRequest request) {
    HttpSession session = request.getSession();
    Map<String, Object> retMap = new HashMap<>();
    retMap.put("retCode", 0);
    UserInfo webuserInfo = userInfoService.getUserInfoById(userInfoId);
    Enterprise webenterprise = enterpriseService.getEnterpriseById(enterpriseId);
    // 时间戳校验
    long time = System.currentTimeMillis();
    if ((time - currentTimeMillis) > (60 * 60 * 1000)) {
        retMap.put("retMsg", "二维码已经失效,请重新扫描");
        return retMap;
    }
    if (null == webuserInfo || null == webenterprise) {
        retMap.put("retMsg", "用户登录信息已失效,请重新登录");
        return retMap;
    }
    // 获取发票校验的应用
    ExtraProduct product = extraProductService.selectByPrimaryKey(productId);
    if (null == product) {
        retMap.put("retMsg", "产品信息不存在");
        return retMap;
    }
    // 
    Project project = projectService.selectByPrimaryKey(projectId);
    if (null == project) {
        retMap.put("retMsg", "项目信息不存在");
        return retMap;
    }
    // 校验文件信息
    if (invoiceQRImage.isEmpty()) {
        retMap.put("retMsg", "上传的图片信息不能为空");
        return retMap;
    }
    try {
        // 0位发票代码,1为发票号码,2为发票校验码
        String[] invoiceInfo = parseQRCodeTool.parseQRCode(invoiceQRImage.getInputStream());
        if (null == invoiceInfo || invoiceInfo.length != 3) {
            retMap.put("retMsg", "无法识别发票中的信息,请重新上传或者用其他方式校验发票");
            return retMap;
        }
        Map<String, String> invoiceMap = baiWangService.verifyInvoice(invoiceInfo[0], invoiceInfo[1], invoiceInfo[2]);
        retMap.putAll(invoiceMap);
        if (null != retMap.get("REPLYCODE") && retMap.get("REPLYCODE").equals("0000")) {
            retMap.put("retCode", 1);
            String info = invoiceMap.toString().replaceAll(" ", "");
            checkInvoiceLogService.insertCheckInvoiceLog(product.getAppName(), webenterprise.getEnterpriseName(), info, project.getId(), webuserInfo.getRealName());
            return retMap;
        } else {
            String REPLYMSG = (String) retMap.get("REPLYMSG");
            retMap.put("retMsg", REPLYMSG);
            return retMap;
        }
    } catch (Exception e) {
        UserLog userlog = new UserLog();
        userlog.setProject(webuserInfo.getProject());
        userlog.setType("校验发票");
        userlog.setInfo("url:fpjyByPhone,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "手机端发票校验出错,请联系管理员,错误信息:" + e.getMessage());
    }
    return retMap;
}
Also used : HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) ExtraProduct(com.itrus.portal.db.ExtraProduct) Project(com.itrus.portal.db.Project) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 38 with Project

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

the class ClientWebController method checkInvoce.

/**
 * retCode:0为失败,1为成功
 * 发票校验接口
 * @param FP_DM:发票代码
 * @param FP_HM:发票号码
 * @param JYM:发票校验码
 */
@RequestMapping("/fpjy")
@ResponseBody
public Map<String, Object> checkInvoce(@RequestParam(value = "FP_DM", required = true) String FP_DM, @RequestParam(value = "FP_HM", required = true) String FP_HM, @RequestParam(value = "JYM", required = true) String JYM, @RequestParam(value = "productId", required = true) Long productId, HttpServletRequest request) {
    HttpSession session = request.getSession();
    Map<String, Object> retMap = new HashMap<>();
    retMap.put("retCode", 0);
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        retMap.put("retMsg", "用户登录信息已失效,请重新登录");
        return retMap;
    }
    // 
    Project project = (Project) session.getAttribute("webproject");
    if (null == project) {
        retMap.put("retMsg", "项目信息不存在");
        return retMap;
    }
    // 获取发票校验的应用
    ExtraProduct product = extraProductService.selectByPrimaryKey(productId);
    if (null == product) {
        retMap.put("retMsg", "产品信息不存在");
        return retMap;
    }
    if (StringUtils.isBlank(FP_DM) || StringUtils.isBlank(FP_HM) || StringUtils.isBlank(JYM)) {
        retMap.put("retMsg", "发票代码,发票号码,发票校验码三者都不能为空");
        return retMap;
    }
    Map<String, String> invoiceMap = baiWangService.verifyInvoice(FP_DM, FP_HM, JYM);
    retMap.putAll(invoiceMap);
    if (null != retMap.get("REPLYCODE") && retMap.get("REPLYCODE").equals("0000")) {
        retMap.put("retCode", 1);
        String info = invoiceMap.toString().replaceAll(" ", "");
        checkInvoiceLogService.insertCheckInvoiceLog(product.getAppName(), webenterprise.getEnterpriseName(), info, project.getId(), webuserInfo.getRealName());
        return retMap;
    } else {
        String REPLYMSG = (String) retMap.get("REPLYMSG");
        retMap.put("retMsg", REPLYMSG);
        return retMap;
    }
}
Also used : Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) UserInfo(com.itrus.portal.db.UserInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 39 with Project

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

the class UnlockKeyBillController method reSubmitUnlockBill.

/**
 * 解锁订单重新提交授权书,注意授权书的id不能为null
 * @param billId
 * @param certSn
 * @param keySn
 * @param proxy
 * @param request
 * @return
 */
@RequestMapping("/reSubmitUnlockBill")
@ResponseBody
public Map<String, Object> reSubmitUnlockBill(@RequestParam("billId") Long billId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @ModelAttribute("proxy") Proxy proxy, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("retCode", 0);
    UserInfo webUserInfo = null;
    Project project = null;
    // 校验证书和证书所绑定的用户和企业
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert) {
        retMap.put("retMsg", "该证书未注册,请您先注册");
        return retMap;
    }
    // if(null == userCert.getUserinfo()){
    // retMap.put("retMsg", "该证书未绑定用户,请检查您插入的key是否正确");
    // return retMap;
    // }
    // 校验订单和证书所对应的用户与企业
    Bill bill = billService.getBill(billId);
    if (null == bill) {
        retMap.put("retMsg", "订单不存在");
        return retMap;
    }
    webUserInfo = userInfoService.selectByPrimaryKey(bill.getUniqueId());
    if (null == webUserInfo) {
        retMap.put("retMsg", "订单所对应的用户不存在,请检查");
        return retMap;
    }
    if (!(bill.getBillStatus().equals(ComNames.BILL_STATUS_1) || bill.getBillStatus().equals(ComNames.BILL_STATUS_2) || bill.getBillStatus().equals(ComNames.BILL_STATUS_15))) {
        retMap.put("errorMsg", "该订单不处于可以重新提交的状态");
        return retMap;
    }
    if (!bill.getUnlockUserCert().equals(userCert.getId())) {
        retMap.put("errorMsg", "您无权操作该订单");
        return retMap;
    }
    Product product = productService.getProduct(bill.getProduct());
    if (null == product.getKeyUnlockType()) {
        retMap.put("retMsg", "您选择的产品不属于解锁产品,请重新选择");
        return retMap;
    }
    project = projectService.selectByPrimaryKey(product.getProject());
    DefaultTransactionDefinition dtd = new DefaultTransactionDefinition();
    dtd.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(dtd);
    try {
        if (null != proxy && (StringUtils.isNotBlank(proxy.getImgFile()) || null != proxy.getId())) {
            // 保存授权书
            Proxy oldProxy = null;
            if (null != proxy.getId()) {
                oldProxy = new Proxy();
                oldProxy.setId(proxy.getId());
                proxy.setId(null);
            }
            proxy = proxyService.saveProxy1(bill.getEnterprise(), webUserInfo.getUniqueId(), bill.getId(), bill.getUniqueId(), proxy, oldProxy, project);
        }
        // 审核拒绝后的订单,重新提交,则修改订单状态和审核拒绝的短信发送
        if (bill.getBillStatus().equals(ComNames.BILL_STATUS_15)) {
            bill.setBillStatus(ComNames.BILL_STATUS_14);
            bill.setIsSms(false);
            billService.updateBill(bill);
        }
        transactionManager.commit(status);
        LogUtil.userlog(sqlSession, project.getId(), "重新提交解锁订单", webUserInfo.getmPhone() + "重新提交解锁订单:" + bill.getBillId(), "未知", "", null == webUserInfo.getUniqueId() ? null : webUserInfo.getUniqueId());
        retMap.put("retCode", 1);
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted()) {
            transactionManager.rollback(status);
        }
        UserLog userlog = new UserLog();
        userlog.setProject(project.getId());
        userlog.setType("重新提交解锁订单");
        userlog.setInfo("url:reSubmitUnlockBill,详细错误:" + e.getMessage() + ",订单号" + bill.getBillId());
        userlog.setHostId("未知");
        userlog.setSn(null == webUserInfo.getUniqueId() ? null : webUserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
        return retMap;
    } finally {
        if (!status.isCompleted()) {
            transactionManager.rollback(status);
        }
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) Product(com.itrus.portal.db.Product) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Project(com.itrus.portal.db.Project) Proxy(com.itrus.portal.db.Proxy) Bill(com.itrus.portal.db.Bill) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 40 with Project

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

the class UnlockKeyBillController method verifyAndRegister.

/**
 * 解锁订单提交,用户输入手机号时进行校验
 * @param has_userInfo
 * @param mPhone
 * @param code
 * @param password
 * @param keySn
 * @param enterprise
 * @param session
 * @return
 */
@RequestMapping("/verifyAndRegister")
@ResponseBody
public Map<String, Object> verifyAndRegister(@RequestParam(value = "has_userInfo", required = true) Integer has_userInfo, @RequestParam(value = "keySn", required = true) String keySn, @RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "code", required = true) String code, @RequestParam(value = "password", required = false) String password, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 错误
    retMap.put("retCode", 0);
    ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
    if (null == projectKeyInfo) {
        retMap.put("retMsg", "无法识别Key序列号:" + keySn + ",所属的项目,请联系系统管理员配置");
        return retMap;
    }
    Project project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
    // 验证动态码,
    if (!dynamicCodeService.verifyCode(mPhone, code)) {
        retMap.put("retMsg", "动态码验证失败");
        return retMap;
    }
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        UserInfo userInfo = userInfoService.getUserInfoByMphone(mPhone);
        if (null != has_userInfo && has_userInfo.equals(0)) {
            // 绑定用户和证书
            if (null == userInfo) {
                if (StringUtils.isBlank(password)) {
                    retMap.put("retMsg", "请先设置登录口令");
                    return retMap;
                }
                if (project != null) {
                    // 先自动创建用户
                    userInfo = userInfoService.registerUserInfo(mPhone, password, project.getId());
                    // 记录系统日志
                    String info = mPhone + "注册成功";
                    LogUtil.syslog(sqlSession, "注册用户", info);
                }
            }
        }
        // // 获取证书
        // UserCert userCert = userCertService.getUserCert(certBase64);
        // // key序列号
        // if (StringUtils.isNotBlank(keySn)){
        // userCert.setKeySn(keySn);
        // }
        transactionManager.commit(status);
        // 返回绑定成功
        retMap.put("retCode", 1);
    } catch (UserInfoServiceException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", "服务端出现未知异常,请联系管理员");
        String info = mPhone + "校验和注册用户失败,原因:" + e.getMessage();
        LogUtil.syslog(sqlSession, "解锁校验", info);
        return retMap;
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
    return retMap;
}
Also used : Project(com.itrus.portal.db.Project) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Project (com.itrus.portal.db.Project)77 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)59 HashMap (java.util.HashMap)32 UserInfo (com.itrus.portal.db.UserInfo)24 Enterprise (com.itrus.portal.db.Enterprise)20 ExtraProduct (com.itrus.portal.db.ExtraProduct)17 ProjectExample (com.itrus.portal.db.ProjectExample)16 ArrayList (java.util.ArrayList)15 ProjectKeyInfo (com.itrus.portal.db.ProjectKeyInfo)12 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)12 Product (com.itrus.portal.db.Product)10 Date (java.util.Date)10 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)9 BusinessLicense (com.itrus.portal.db.BusinessLicense)8 IdentityCard (com.itrus.portal.db.IdentityCard)8 OrgCode (com.itrus.portal.db.OrgCode)8 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)8 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)8 List (java.util.List)8 Map (java.util.Map)8