Search in sources :

Example 11 with UserLog

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

the class BillWebController method updateAuditBill.

/**
 * 修改审核中订单
 *
 * @param enterpriseName
 *            企业名称
 * @param enterpriseNature
 *            企业性质
 * @param billId
 *            订单id
 * @param businessLicense
 * @param orgCode
 * @param taxregisterCert
 * @param identityCard
 * @param agent
 * @param proxy
 * @param session
 * @return
 */
@RequestMapping("/updateAuditBill")
@ResponseBody
public Map<String, Object> updateAuditBill(@RequestParam(value = "enterpriseName", required = true) String enterpriseName, @RequestParam(value = "enterprise_nature", required = false) Integer enterpriseNature, @RequestParam(value = "billId", required = true) Long billId, @RequestParam(value = "uid", required = true) String uid, @RequestParam(value = "uid1", required = false) String uid1, @RequestParam(value = "uid2", required = false) String uid2, @RequestParam(value = "uid3", required = false) String uid3, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("identityCard") IdentityCard identityCard, @ModelAttribute("agent") Agent agent, @ModelAttribute("proxy") Proxy proxy, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识失败,1标识成功
    retMap.put("retCode", 0);
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        // 登录状态失效,跳转到注册页面
        // 2表示登录失效
        retMap.put("retCode", 2);
        retMap.put("retMsg", "登录已经失效,请重新登录");
        return retMap;
    }
    // 验证参数完整性
    if (null == enterpriseNature || 0 == enterpriseNature || null == billId) {
        retMap.put("retMsg", "提交参数信息不完整");
        return retMap;
    }
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    if (null == bill) {
        retMap.put("retMsg", "该订单不存在");
        return retMap;
    }
    if (!webuserInfo.getId().equals(bill.getUniqueId())) {
        retMap.put("retMsg", "您不能修改该订单");
        return retMap;
    }
    // 1、订单状态为:未支付、支付待确认、已支付待审核、送审中的状态,其余状态不能继续往下执行
    List<Integer> modifiedStatus = new ArrayList<Integer>();
    modifiedStatus.add(ComNames.BILL_STATUS_1);
    modifiedStatus.add(ComNames.BILL_STATUS_2);
    modifiedStatus.add(ComNames.BILL_STATUS_3);
    modifiedStatus.add(ComNames.BILL_STATUS_10);
    // 不在以上状态中
    if (modifiedStatus.indexOf(bill.getBillStatus()) == -1) {
        retMap.put("retMsg", "该订单不能修改");
        return retMap;
    }
    // 根据订单id获取产品需要认证项,
    List<String> certItems = sqlSession.selectList("com.itrus.portal.db.CertificationMapper.selectCertItemsByBillId", billId);
    if (null == certItems || certItems.isEmpty()) {
        retMap.put("retMsg", "服务端出现异常,请联系管理员");
        log.error("获取订单对应产品的认证项失败:订单Id=" + billId + ".");
        return retMap;
    }
    // 记录旧的企业唯一标识:
    String oldEnterpriseSn = webenterprise.getEnterpriseSn();
    // 设置企业唯一标识
    if (enterpriseNature.equals(1) || enterpriseNature.equals(2)) {
        // 类型为企业和个体工商户:当三证合一时,企业标识为统一社会信用代码;当非三证合一时,企业标识为营业执照注册号;
        webenterprise.setEnterpriseSn(businessLicense.getLicenseNo());
    }
    if (enterpriseNature.equals(3)) {
        // 类型为政府机关/事业单位:企业标识为组织机构代码
        webenterprise.setEnterpriseSn(orgCode.getOrgCode());
    }
    // 修改企业名称
    webenterprise.setEnterpriseName(enterpriseName.trim());
    // 修改企业性质
    webenterprise.setEnterpriseNature(enterpriseNature);
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 删除订单关联的旧认证项,新增订单对应的新认证项
        billWebService.saveBillAuthenticationItems(certItems.get(0), enterpriseNature, billId, businessLicense, orgCode, taxregisterCert, identityCard, agent, proxy, webenterprise, webuserInfo);
        // 3、判断该订单对应的企业的认证项是否为通过,若是通过,则重新设置为不通过
        if (null != webenterprise.getAuthenticationLevel())
            webenterprise.setAuthenticationLevel(null);
        if (null != webenterprise.getHasBl())
            webenterprise.setHasBl(null);
        if (null != webenterprise.getHasOrgCode())
            webenterprise.setHasOrgCode(null);
        if (null != webenterprise.getHasTaxCert())
            webenterprise.setHasTaxCert(null);
        if (null != webenterprise.getHasIdCard())
            webenterprise.setHasIdCard(null);
        if (null != webenterprise.getHasAgent())
            webenterprise.setHasAgent(null);
        sqlSession.update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKey", webenterprise);
        // 修改发票
        if (bill.getInvoice() != null && bill.getIsInvoiced() == null) {
            Invoice invoice = sqlSession.selectOne("com.itrus.portal.db.InvoiceMapper.selectByPrimaryKey", bill.getInvoice());
            invoice.setName(webenterprise.getEnterpriseName());
            sqlSession.update("com.itrus.portal.db.InvoiceMapper.updateByPrimaryKey", invoice);
        }
        if (bill.geteInvoice() != null && bill.getIsInvoiced() == null) {
            Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
            einvoice.setName(webenterprise.getEnterpriseName());
            sqlSession.update("com.itrus.portal.db.EinvoiceMapper.updateByPrimaryKey", einvoice);
        }
        // 判断该订单状态是否为送审中,假如是,则设置为 3已支付,待审核(用于重新送审)
        if (bill.getBillStatus().equals(ComNames.BILL_STATUS_10)) {
            bill.setBillStatus(ComNames.BILL_STATUS_3);
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        }
        if (StringUtils.isNotEmpty(uid) && !uid.equals("{}")) {
            bill.setUid(uid);
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        } else {
            if (StringUtils.isNotEmpty(uid1) && !uid1.equals("{}")) {
                bill.setUid1(uid1);
            }
            if (StringUtils.isNotEmpty(uid2) && !uid2.equals("{}")) {
                bill.setUid2(uid2);
            }
            if (StringUtils.isNotEmpty(uid3) && !uid3.equals("{}")) {
                bill.setUid3(uid3);
            }
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        }
        transactionManager.commit(status);
        session.setAttribute("webenterprise", webenterprise);
        // 企业标识改变后,将旧目录中的图片复制到新目录中
        if (!oldEnterpriseSn.equals(webenterprise.getEnterpriseSn())) {
            CopyFile.copyFile(systemConfigService.getTrustDir().getPath() + File.separator + oldEnterpriseSn, systemConfigService.getTrustDir().getPath() + File.separator + webenterprise.getEnterpriseSn());
        }
        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);
        UserLog userlog = new UserLog();
        userlog.setType("修改订单");
        userlog.setInfo("url:updateAuditBill,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setProject(webuserInfo.getProject());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
        log.error(e.getMessage());
        return retMap;
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
    return retMap;
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) Invoice(com.itrus.portal.db.Invoice) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) EncDecException(com.itrus.portal.exception.EncDecException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Einvoice(com.itrus.portal.db.Einvoice) Enterprise(com.itrus.portal.db.Enterprise) EditBill(com.itrus.portal.db.EditBill) Bill(com.itrus.portal.db.Bill) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with UserLog

use of com.itrus.portal.db.UserLog 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 13 with UserLog

use of com.itrus.portal.db.UserLog 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 14 with UserLog

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

the class ClientWebController method submitOrder.

// TODO 用户提交订单:确认订单页面,点击去支付
@RequestMapping("/submitOrder")
@ResponseBody
public Map<String, Object> submitOrder(@RequestParam(value = "projectId", required = true) Long projectId, @RequestParam(value = "productId", required = true) Long productId, @RequestParam(value = "productNum", required = true) Integer productNum, @RequestParam(value = "productSpecId", required = true) Long productSpecId, @ModelAttribute("enterprise") Enterprise enterprise, @ModelAttribute("userInfo") UserInfo userInfo, @ModelAttribute("einvoice") Einvoice einvoice, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("agent") Agent agent, @ModelAttribute("openBankInfo") OpenBankInfo openBankInfo, @ModelAttribute("identityCard") IdentityCard identityCard, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识失败,1标识成功
    retMap.put("retCode", 0);
    HttpSession session = request.getSession();
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        retMap.put("retMsg", "用户登录信息已失效,请重新登录");
        return retMap;
    }
    ExtraProduct product = extraProductService.selectByPrimaryKey(productId);
    if (null == product) {
        retMap.put("retMsg", "产品信息不存在,请重新选择产品");
        return retMap;
    }
    ExtraProductSpec productSpec = extraProductSpecService.selectByPrimaryKey(productSpecId);
    if (null == productSpec || productSpec.getIsValid().equals(false)) {
        retMap.put("retMsg", "规格信息不存在或已经失效,请重新选择规格");
        return retMap;
    }
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 保存发票信息(填写了发票信息才保存,未填写则不保存)
        if (StringUtils.isNotBlank(einvoice.getName()) && StringUtils.isNotBlank(einvoice.getIdNumber()) && null != einvoice.geteReiceipt())
            einvoice = EinvoiceService.saveEInvoice(webuserInfo.getId(), einvoice);
        // 计算订单价格
        Double billSum = null;
        billSum = productNum * productSpec.getPrice();
        // 生成订单
        ExtraBill bill = extraBillService.saveExtraBill(projectId, webuserInfo.getId(), webenterprise.getId(), productId, productSpecId, null != einvoice.getId() ? einvoice.getId() : null, productNum, billSum, ComNames.EXTRA_BILL_STATUS_1);
        // ""字符串判断,改为Null,避免覆盖数据库中的信息
        if (null != enterprise && StringUtils.isBlank(enterprise.getProvince())) {
            enterprise.setProvince(null);
        }
        if (null != enterprise && StringUtils.isBlank(enterprise.getCity())) {
            enterprise.setCity(null);
        }
        if (null != enterprise && StringUtils.isBlank(enterprise.getShortName())) {
            enterprise.setShortName(null);
        }
        // 更新用户信息和企业信息
        if (null != enterprise && null == enterprise.getId()) {
            enterprise.setId(webenterprise.getId());
        }
        if (null != userInfo && null == userInfo.getId()) {
            userInfo.setId(webuserInfo.getId());
        }
        enterprise = enterpriseService.updateByPrimaryKeySelective(enterprise);
        userInfo = userInfoService.updateByPrimaryKeySelective(userInfo);
        // 获取产品需要的附加信息项
        ExtraMessage extraMessage = extraMessageService.selectByPrimaryKey(product.getExtraMessage());
        // 是否有营业执照信息,默认false没有
        boolean hasBl = false;
        if (null != extraMessage) {
            // //企业信息 认证项(1.企业名称,2.统一社会信用代码/营业执照,3.组织机构代码,4.税务登记号)
            if (StringUtils.isNotBlank(extraMessage.getEnterpriseItems())) {
                if (StringUtils.isNotBlank(extraMessage.getEnterpriseItems())) {
                    if (extraMessage.getEnterpriseItems().contains("1")) {
                    }
                    if (extraMessage.getEnterpriseItems().contains("2") && !webenterprise.getEnterpriseNature().equals(3)) {
                        // 事业单位不填写营业执照
                        hasBl = true;
                        // 需要统一社会信用代码/营业执照实名认证项,但是页面没有传递过来的时候,用老的
                        if (null == businessLicense || !StringUtils.isNotBlank(businessLicense.getImgFile())) {
                            List<BusinessLicense> businessLicenses = businessService.getBusinessLicensesNews(webenterprise.getId());
                            if (null != businessLicenses && !businessLicenses.isEmpty()) {
                                businessLicense = businessLicenses.get(0);
                                businessLicense.setImgFile(null);
                            }
                        }
                        businessLicense = businessService.saveBusinessExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), businessLicense, ComNames.ITEM_STATUS_2, null);
                    }
                    if (extraMessage.getEnterpriseItems().contains("3")) {
                        // 需要统一组织机构代码认证项,但是页面没有传递过来的时候,用老的
                        if (!(hasBl && businessLicense.getBusinessType().equals(// 五证合一企业不用提交组织机构代码、税务登记信息
                        1))) {
                            if (null == orgCode || !StringUtils.isNotBlank(orgCode.getImgFile())) {
                                List<OrgCode> orgCodes = orgCodeService.getOrgCodesNews(webenterprise.getId());
                                if (null != orgCodes && !orgCodes.isEmpty()) {
                                    orgCode = orgCodes.get(0);
                                    orgCode.setImgFile(null);
                                }
                            }
                            orgCode = orgCodeService.saveOrgCodeExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), orgCode, ComNames.ITEM_STATUS_2, null);
                        }
                    }
                    if (extraMessage.getEnterpriseItems().contains("4")) {
                        if (!(hasBl && businessLicense.getBusinessType().equals(// 五证合一企业不用提交组织机构代码、税务登记信息
                        1))) {
                            // 保存税务登记证
                            if (// 事业单位不填写税务登记信息
                            !webenterprise.getEnterpriseNature().equals(3)) {
                                // 需要税务登记实名认证项,但是页面没有传递过来的时候,用老的
                                if (null == taxregisterCert || !StringUtils.isNotBlank(taxregisterCert.getImgFile())) {
                                    List<TaxRegisterCert> taxRegisterCerts = taxCertService.getTaxRegisterCertsNews(webenterprise.getId());
                                    if (null != taxRegisterCerts && !taxRegisterCerts.isEmpty()) {
                                        taxregisterCert = taxRegisterCerts.get(0);
                                        taxregisterCert.setImgFile(null);
                                    }
                                }
                                taxregisterCert = taxCertService.saveTaxCertExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), taxregisterCert, ComNames.ITEM_STATUS_2, null);
                            }
                        }
                    }
                }
            }
            // field string --fieldName agentItems
            if (StringUtils.isNotBlank(extraMessage.getAgentItems())) {
                if (null == agent || StringUtils.isBlank(agent.getFrontImg())) {
                    List<Agent> agents = agentService.getAgentsNews(webenterprise.getId());
                    if (null != agents && !agents.isEmpty()) {
                        agent = agents.get(0);
                        agent.setFrontImg(null);
                        agent.setBackImg(null);
                    }
                }
                agent = agentService.saveAgentExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), agent, ComNames.ITEM_STATUS_2, null);
            }
            // field string --fieldName bankItems
            if (StringUtils.isNotBlank(extraMessage.getBankItems())) {
                if (null == openBankInfo || StringUtils.isBlank(openBankInfo.getBankNumber())) {
                    List<OpenBankInfo> openBankInfos = openBankInfoService.getOpenBankInfosNews(webenterprise.getId());
                    if (null != openBankInfos && !openBankInfos.isEmpty()) {
                        openBankInfo = openBankInfos.get(0);
                    }
                }
                openBankInfo = openBankInfoService.saveOpenBankInfoExtraBill(webenterprise.getId(), bill.getId(), webuserInfo.getId(), openBankInfo, ComNames.ITEM_STATUS_2, null);
            }
            // field string  --fieldName identityCardItems
            if (StringUtils.isNotBlank(extraMessage.getIdentityCardItems())) {
                if (null == identityCard || StringUtils.isBlank(identityCard.getFrontImg())) {
                    List<IdentityCard> identityCards = identityCardService.getIdentityCardsNews(webenterprise.getId());
                    if (null != identityCards && !identityCards.isEmpty()) {
                        identityCard = identityCards.get(0);
                        identityCard.setFrontImg(null);
                        identityCard.setBackImg(null);
                    }
                }
                identityCard = identityCardService.saveIdentityCardExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), identityCard, ComNames.ITEM_STATUS_2, null);
            }
        }
        transactionManager.commit(status);
        retMap.put("retCode", 1);
        retMap.put("billId", bill.getId());
        // 更新session用户和企业信息
        webenterprise = enterpriseService.getEnterpriseById(webenterprise.getId());
        webuserInfo = userInfoService.getUserInfoById(webuserInfo.getId());
        session.setAttribute("webenterprise", webenterprise);
        session.setAttribute("webuserInfo", webuserInfo);
        // 记录日志
        UserLog userlog = new UserLog();
        userlog.setProject(projectId);
        userlog.setType("购买增值产品");
        userlog.setInfo(webuserInfo.getmPhone() + "购买了" + product.getAppName());
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        return retMap;
    } 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);
        }
        UserLog userlog = new UserLog();
        userlog.setProject(projectId);
        userlog.setType("购买增值产品");
        userlog.setInfo("url:submitOrder,详细错误:" + e.getMessage());
        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) ExtraBill(com.itrus.portal.db.ExtraBill) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) IdentityCard(com.itrus.portal.db.IdentityCard) Agent(com.itrus.portal.db.Agent) HttpSession(javax.servlet.http.HttpSession) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) UserLog(com.itrus.portal.db.UserLog) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) ExtraProduct(com.itrus.portal.db.ExtraProduct) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) ExtraMessage(com.itrus.portal.db.ExtraMessage) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 15 with UserLog

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

the class ClientWebController method submitOrderJYHSQ.

/**
 * 仅用户授权产品订单提交接口
 * @param projectId
 * @param productId
 * @param productNum
 * @param request
 * @return
 */
@RequestMapping("/submitOrder/jyhsq")
@ResponseBody
public Map<String, Object> submitOrderJYHSQ(@RequestParam(value = "projectId", required = true) Long projectId, @RequestParam(value = "productId", required = true) Long productId, @RequestParam(value = "productNum", required = true) Integer productNum, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识失败,1标识成功
    retMap.put("retCode", 0);
    HttpSession session = request.getSession();
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        retMap.put("retMsg", "用户登录信息已失效,请重新登录");
        return retMap;
    }
    ExtraProduct product = extraProductService.selectByPrimaryKey(productId);
    if (null == product) {
        retMap.put("retMsg", "产品信息不存在,请重新选择产品");
        return retMap;
    }
    // 查询用户是否曾经买过了该产品对于的订单,如果买了,则提示只能购买一次
    List<ExtraBill> bills = extraBillService.getHasByExtraBill(webuserInfo.getId(), webenterprise.getId(), productId);
    if (null != bills && bills.size() > 0) {
        retMap.put("retMsg", "该产品每个用户仅需开通一次即可");
        retMap.put("retCode", 2);
        return retMap;
    }
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 计算订单价格
        Double billSum = null;
        billSum = 0d;
        // 生成订单
        ExtraBill bill = extraBillService.saveExtraBill(projectId, webuserInfo.getId(), webenterprise.getId(), productId, null, null, productNum, billSum, ComNames.EXTRA_BILL_STATUS_7);
        retMap.put("retCode", 1);
        retMap.put("billId", bill.getId());
        // 记录日志
        UserLog userlog = new UserLog();
        userlog.setProject(projectId);
        userlog.setType("购买增值产品");
        userlog.setInfo(webuserInfo.getmPhone() + "购买了" + product.getAppName());
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        transactionManager.commit(status);
        return retMap;
    } catch (UserInfoServiceException e) {
        // TODO: handle exception
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        UserLog userlog = new UserLog();
        userlog.setProject(projectId);
        userlog.setType("购买增值产品");
        userlog.setInfo("url:submitOrder,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
        return retMap;
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) ExtraBill(com.itrus.portal.db.ExtraBill) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) ExtraProduct(com.itrus.portal.db.ExtraProduct) 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)

Aggregations

UserLog (com.itrus.portal.db.UserLog)23 UserInfo (com.itrus.portal.db.UserInfo)20 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)18 IOException (java.io.IOException)17 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)17 Enterprise (com.itrus.portal.db.Enterprise)15 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)15 HashMap (java.util.HashMap)15 HttpSession (javax.servlet.http.HttpSession)12 Bill (com.itrus.portal.db.Bill)9 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)9 TransactionStatus (org.springframework.transaction.TransactionStatus)8 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)8 ExtraProduct (com.itrus.portal.db.ExtraProduct)7 Product (com.itrus.portal.db.Product)7 BusinessLicense (com.itrus.portal.db.BusinessLicense)6 ExtraBill (com.itrus.portal.db.ExtraBill)6 IdentityCard (com.itrus.portal.db.IdentityCard)6 OrgCode (com.itrus.portal.db.OrgCode)6 Project (com.itrus.portal.db.Project)6