Search in sources :

Example 21 with Enterprise

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

the class MakeCertController method push.

/**
 * 手动推送
 *
 * @param id
 * @param uiModel
 * @return
 */
@RequestMapping(value = "/{id}/{type}", method = RequestMethod.GET, produces = "text/html")
@ResponseBody
public String push(@PathVariable("id") Long id, @PathVariable("type") Long type, Model uiModel) {
    SignatureConfig sc = null;
    JSONObject data = null;
    JSONObject org = null;
    JSONObject result = null;
    Bill bill = null;
    /*if(type==1){
			try {
				bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
				log.error("bill.getMcstatus()="+bill.getMcstatus()+"bill="+bill);
				if(null == bill) {
					//log.error(bill.getMcstatus()+"---------------------------------------------"+bill);
					//System.out.println(bill.getMcstatus()+"=******************************="+bill);
					return "该订单无法推送";
				}
				Product product = productService.getProductById(bill.getProduct());
				sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey",
						product.getSignature());
				Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
				BusinessLicense bl = businessService.getBusinessByBillId((id), null);
				if (org == null) {
					org = new JSONObject();
					
				}
				org.put("userType", 1);
				org.put("fullName", bl.getEnterpriseName());
				if (bl != null && bl.getBusinessType() == 1) {
					org.put("orgCode", bl.getLicenseNo());
				} else {
					TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
					org.put("orgCode", tc == null ? "" : tc.getCertNo());
				}
				org.put("papersType", "营业执照");
				UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey",
						bill.getUniqueId());
				org.put("businessNum", userInfo.getTelephone());
				// IdentityCard ic =
				// identityCardService.getIdentityCardByBillId(Long.parseLong(String.valueOf(map.get("id"))),
				// null);
				org.put("legalPersonName", bl == null ? "" : bl.getLegalPerson());
				Agent agent = agentService.getAgentByBillId((id), null);
				org.put("transactorName", agent == null ? enterprise.getEnterpriseName() : agent.getName());
				if (agent != null && agent.getCardType() == 1) {
					org.put("transactorIdCardNum", agent.getIdCode());
				}
				org.put("transactorMobile", userInfo.getmPhone());
				org.put("realInfoOrder", bill.getBillId());
				org.put("realInfoUid", bill.getUniqueId());
				if (data == null) {
					data = new JSONObject();
				}
				data.put("appId", sc.getAppId());
				data.put("timestamp", System.currentTimeMillis());
				data.put("user", org);
				data.put("autoCert", true);
				data.put("autoSeal", true);
				// String content =
				// "{\"autoCert\":true,\"timestamp\":1472105170418,\"apiId\":\"test\",\"autoSeal\":true,\"user\":{\"transactorIdCardNum\":\"120102198904025625\",\"transactorMobile\":\"15822452770\",\"orgCode\":\"120116328553325\",\"papersType\":\"营销执照\",\"businessNum\":\"022-88956296\",\"realInfoUid\":\"151\",\"fullName\":\"天津瑞普生物技术股份有限公司空港经济区分公司\",\"legalPersonName\":\"刘建\",\"transactorName\":\"李洋\",\"realInfoOrder\":\"TWCX20160824170928580820\",\"userType\":1}}";
				// bill =
				// sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey",
				// map.get("id"));
				if (bill.getMcstatus() != null && bill.getMcstatus() == 1) {
					// return "redirect:/makecert";
					return null;
				}
				log.error("打印data="+data.toString());
				
				log.error("----------接口地址**************"+sc.getAddress() + USER_URL+"***********服务密钥**********"+sc.getAddressKey());
				result = JSONObject
						.parseObject(RequestUtils.post(sc.getAddress() + USER_URL, data.toString(), sc.getAddressKey()));
				log.equals("MakeCert_push_result : " + result);
				if (result.getBoolean("isOK") && result.getIntValue("code") == 0) {
					LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
					bill.setMcstatus(1);
					bill.setBillStatus(8);
					sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
					sqlSession.flushStatements();
					// return "redirect:/makecert";
					return null;
				}
				LogUtil.syslog(sqlSession, "手动推送用户",
						bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
				// uiModel.addAttribute("error", "错误:" +
				// result.getString("message"));
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
				// uiModel.addAttribute("error", "错误:" + e);
				return "错误【" + e + "】";
			}
		}else */
    if (type == 1) {
        try {
            bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
            log.error("bill.getMcstatus()=" + bill.getMcstatus() + "bill=" + bill);
            if (null == bill) {
                // System.out.println(bill.getMcstatus()+"=******************************="+bill);
                return "该订单无法推送";
            }
            Product product = productService.getProductById(bill.getProduct());
            sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", product.getSignature());
            Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
            BusinessLicense bl = businessService.getBusinessByBillId((id), null);
            if (org == null) {
                org = new JSONObject();
            }
            org.put("userType", 1);
            org.put("fullName", bl.getEnterpriseName());
            if (bl != null && bl.getBusinessType() == 1) {
                org.put("orgCode", bl.getLicenseNo());
            } else {
                TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
                org.put("orgCode", tc == null ? "orgCode" : tc.getCertNo());
            }
            org.put("papersType", "营业执照");
            UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
            org.put("businessNum", userInfo.getTelephone() == null ? "businessNum" : userInfo.getTelephone());
            // null);
            if (bl != null) {
                org.put("legalPersonName", bl.getLegalPerson() == null ? "legalPersonName" : bl.getLegalPerson());
            } else {
                org.put("legalPersonName", "legalPersonName");
            }
            Agent agent = agentService.getAgentByBillId((id), null);
            org.put("transactorName", agent == null ? "transactorName" : agent.getName());
            if (agent != null && agent.getCardType() == 1) {
                org.put("transactorIdCardNum", agent.getIdCode());
            } else {
                org.put("transactorIdCardNum", "transactorIdCardNum");
            }
            org.put("transactorMobile", userInfo.getmPhone());
            org.put("realInfoOrder", bill.getBillId());
            org.put("realInfoUid", bill.getUniqueId());
            if (data == null) {
                data = getJSONRequest(sc.getAppId());
            }
            data.put("autoCert", true);
            data.put("autoSeal", true);
            // data.put("appId", sc.getAppId());
            // data.put("timestamp", System.currentTimeMillis());
            data.put("user", org);
            // String content =
            // "{\"autoCert\":true,\"timestamp\":1472105170418,\"apiId\":\"test\",\"autoSeal\":true,\"user\":{\"transactorIdCardNum\":\"120102198904025625\",\"transactorMobile\":\"15822452770\",\"orgCode\":\"120116328553325\",\"papersType\":\"营销执照\",\"businessNum\":\"022-88956296\",\"realInfoUid\":\"151\",\"fullName\":\"天津瑞普生物技术股份有限公司空港经济区分公司\",\"legalPersonName\":\"刘建\",\"transactorName\":\"李洋\",\"realInfoOrder\":\"TWCX20160824170928580820\",\"userType\":1}}";
            // bill =
            // sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey",
            // map.get("id"));
            /*if (bill.getMcstatus() != null && bill.getMcstatus() == 1) {
					// return "redirect:/makecert";
					return null;
				}*/
            log.error("打印data=" + data.toString());
            log.error("----------接口地址**************" + sc.getAddress() + USER_URL + "***********服务密钥**********" + sc.getAddressKey());
            result = JSONObject.parseObject(RequestUtils.post(sc.getAddress() + USER_URL, data.toString(), sc.getAddressKey()));
            log.equals("MakeCert_push_result : " + result);
            if (result.getBoolean("isOK") && result.getIntValue("code") == 0) {
                LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
                bill.setMcstatus(1);
                bill.setBillStatus(8);
                sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
                sqlSession.flushStatements();
                // return "redirect:/makecert";
                return null;
            }
            LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
        // uiModel.addAttribute("error", "错误:" +
        // result.getString("message"));
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            // uiModel.addAttribute("error", "错误:" + e);
            return "错误【" + e + "】";
        }
    } else {
        try {
            bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
            log.error("bill.getMcstatus()=" + bill.getMcstatus() + "bill=" + bill);
            if (null == bill) {
                // System.out.println(bill.getMcstatus()+"=******************************="+bill);
                return "该订单无法推送";
            }
            Product product = productService.getProductById(bill.getProduct());
            sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", product.getSignature());
            Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
            BusinessLicense bl = businessService.getBusinessByBillId((id), null);
            /*if (org == null) {
					org = new JSONObject();
				}
				org.put("userType", 1);
				org.put("fullName", bl.getEnterpriseName());
				if (bl != null && bl.getBusinessType() == 1) {
					org.put("orgCode", bl.getLicenseNo());
				} else {
					TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
					org.put("orgCode", tc == null ? "" : tc.getCertNo());
				}
				org.put("papersType", "营业执照");*/
            UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
            // org.put("businessNum", userInfo.getTelephone());
            // IdentityCard ic =
            // identityCardService.getIdentityCardByBillId(Long.parseLong(String.valueOf(map.get("id"))),
            // null);
            // org.put("legalPersonName", bl == null ? "" : bl.getLegalPerson());
            Agent agent = agentService.getAgentByBillId((id), null);
            /*org.put("transactorName", agent == null ? "" : agent.getName());
				if (agent != null && agent.getCardType() == 1) {
					org.put("transactorIdCardNum", agent.getIdCode());
				}
				org.put("transactorMobile", userInfo.getmPhone());
				org.put("realInfoOrder", bill.getBillId());
				org.put("realInfoUid", bill.getUniqueId());*/
            if (data == null) {
                data = new JSONObject();
            }
            Map<String, Object> treeMap = Maps.newTreeMap();
            treeMap.put("app_id", sc.getAppId());
            treeMap.put("order_number", bill.getBillId());
            treeMap.put("user_name", enterprise.getEnterpriseName());
            treeMap.put("user_email", userInfo.getEmail());
            treeMap.put("user_phone", userInfo.getmPhone());
            treeMap.put("user_type", "organization");
            /*String cardType = null;
				if(agent!=null && agent.getCardType()!=null){
					if(agent.getCardType()==1){
						cardType = "IdentityCard";
					}else if(agent.getCardType()==2){
						cardType = "NationalPassport";
					}else{
						cardType = "Other";
					}
					treeMap.put("identification_number",agent.getIdCode());
				}
				*/
            String cardType = null;
            String sn = null;
            BusinessLicense businessLicense = businessService.getBusinessByBillId(bill.getId(), null);
            if (businessLicense != null && businessLicense.getBusinessType() == 1) {
                sn = businessLicense.getLicenseNo();
                cardType = "UniformSocialCreditCode";
            }
            if (businessLicense == null || businessLicense.getBusinessType() != 1) {
                // 不是五证合一
                OrgCode oc = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
                if (oc != null) {
                    sn = oc.getOrgCode();
                    cardType = "OrganizationCode";
                }
            }
            treeMap.put("identification_number", sn);
            treeMap.put("identity_type", cardType);
            String jsondata = JSONObject.toJSONString(treeMap);
            String data1 = mapToQueryString(treeMap);
            log.error(data1);
            result = JSONObject.parseObject(RequestUtils.post1(sc.getAddress(), jsondata.toString(), data1, sc.getAddressKey(), "HMAC-SHA256"));
            log.equals("MakeCert_push_result : " + result);
            if (result.getString("code") != null && "SUCCESS".equals(result.getString("code").toString())) {
                LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
                bill.setMcstatus(1);
                bill.setBillStatus(8);
                sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
                sqlSession.flushStatements();
                // return "redirect:/makecert";
                return null;
            }
            LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
        // uiModel.addAttribute("error", "错误:" +
        // result.getString("message"));
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            // uiModel.addAttribute("error", "错误:" + e);
            return "错误【" + e + "】";
        }
    }
    return "错误【" + result.getString("message") + "】";
}
Also used : Agent(com.itrus.portal.db.Agent) SignatureConfig(com.itrus.portal.db.SignatureConfig) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) EncDecException(com.itrus.portal.exception.EncDecException) IOException(java.io.IOException) RaServiceUnavailable_Exception(cn.topca.tca.ra.service.RaServiceUnavailable_Exception) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) JSONObject(com.alibaba.fastjson.JSONObject) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) JSONObject(com.alibaba.fastjson.JSONObject) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 22 with Enterprise

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

the class MakeCertController method downloadPfxCert.

/**
 * 后台管理员下载pfx证书的接口
 *
 * @param id,订单id
 * @param request
 * @param response
 * @return
 */
@RequestMapping("/pfx/{id}")
public String downloadPfxCert(@PathVariable(value = "id") Long id, HttpServletRequest request, HttpServletResponse response) {
    Bill bill = billService.getBill(id);
    if (null == bill) {
        return null;
    }
    Integer uidIdx = 1;
    UserInfo webuserInfo = userInfoService.getUserInfoByBillId(id);
    Enterprise webenterprise = enterpriseService.getEnterpriseByBillId(id);
    boolean billFlag = webuserInfo.getId().equals(bill.getUniqueId()) && webenterprise.getId().equals(bill.getEnterprise());
    if (!billFlag) {
        return null;
    }
    // 用户已经下载过了,再次下载
    boolean downLoadFlag = bill.getBillStatus().equals(ComNames.BILL_STATUS_6) || bill.getBillStatus().equals(ComNames.BILL_STATUS_7) || bill.getBillStatus().equals(ComNames.BILL_STATUS_8);
    if (downLoadFlag) {
        // 根据订单号,找到订单对应的证书信息
        CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectPfxCertByBillId", bill.getId());
        Date date = new Date();
        // 获取证书第一次下载时间和当前时间比较,如果超过了十五天,则不允许下载
        int day = DateUtils.daysOfTwo(date, certBuf.getCreateTime());
        if (day > 16) {
            return null;
        }
        // 从数据库中取出数据,返回给客户端.
        // 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
        response.reset();
        String filename = webenterprise.getEnterpriseName() + "功能证书.pfx";
        filename = encodeFilename(filename, request);
        response.setHeader("Content-disposition", "attachment;filename=" + filename);
        response.setCharacterEncoding("utf-8");
        // 由于导出格式是pfx的文件,设置导出文件的响应头部信息
        response.setContentType("application/x-pkcs12");
        OutputStream os = null;
        try {
            os = response.getOutputStream();
            // 清理刷新缓冲区,将缓存中的数据将数据导出excel
            byte[] byteCert = Base64.decode(certBuf.getPfxCert());
            os.write(byteCert);
            os.flush();
            // 关闭os
            if (os != null) {
                os.close();
            }
            certBuf.setLastDownloadTime(new Date());
            certBuf.setCertDownloadNumber(certBuf.getCertDownloadNumber() + 1);
            downLoadCertService.updatePfxCert(certBuf);
            // 记录日志
            LogUtil.adminlog(sqlSession, "下载pfx证书", "企业名称:" + webenterprise.getEnterpriseName());
            return null;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            LogUtil.adminlog(sqlSession, "下载pfx证书", "下载失败,错误信息:" + e.getMessage());
        }
    } else {
        // 用户未下载过,第一次下载
        if (bill.getBillStatus().equals(ComNames.BILL_STATUS_13)) {
            // 查询项目产品
            Product product = productService.getProduct(bill.getProduct());
            // 企业
            Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
            // 获取产品、RA配置
            RaAccount ra = raAccountService.getRaAccount(product.getRa());
            // 证书配置
            DigitalCert digitalcert = digitalCertService.getDigitalCert(product.getCert());
            // 下载证书
            String autoidType = "";
            Integer autoidValue = 0;
            String pfxCert = "";
            // 用户ID,用来最终匹配公钥证书和密钥对,一个用户id,只能使用一次,所以考虑使用订单号来作为用户id,避免一个用户只能下载一个证书.
            String userid = bill.getBillId() + (Math.random() * 1000 + 9000);
            // TODO
            String certPass = product.getPassword();
            // 20170410pfx私钥证书保护密码:需要根据产品配置的密码或获取
            // 产生CSR证书请求
            String certReqBuf = "";
            // 算法
            String algorithm = digitalCertService.getAlgorithm(digitalcert);
            // 下载证书
            CertInfo racertinfo = null;
            try {
                certReqBuf = GenUtil.GenP10(userid, "", algorithm);
                racertinfo = downLoadCertService.downLoadCert(product, ra, bill, digitalcert, uidIdx, certReqBuf, autoidType, autoidValue);
                pfxCert = GenUtil.GenPFX(userid, certPass, racertinfo.getCertSignBuf(), false, enterprise.getEnterpriseName());
                // 保存证书
                downLoadCertService.savePfxCertInfo(racertinfo, bill, ra.getId(), uidIdx, "", autoidType, autoidValue, pfxCert);
                // 从数据库中取出数据,返回给客户端.
                // 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
                response.reset();
                String filename = webenterprise.getEnterpriseName() + "通讯证书.pfx";
                filename = encodeFilename(filename, request);
                response.setHeader("Content-disposition", "attachment;filename=" + filename);
                response.setCharacterEncoding("utf-8");
                // 由于导出格式是pfx的文件,设置导出文件的响应头部信息
                response.setContentType("application/x-pkcs12");
                OutputStream os = null;
                os = response.getOutputStream();
                // 清理刷新缓冲区,将缓存中的数据将数据导出excel
                byte[] byteCert = Base64.decode(pfxCert);
                os.write(byteCert);
                os.flush();
                // 关闭os
                if (os != null) {
                    os.close();
                }
                // 记录日志
                LogUtil.adminlog(sqlSession, "下载pfx证书", "下载成功,企业名称:" + webenterprise.getEnterpriseName());
                return null;
            } catch (Exception e) {
                // TODO: handle exception
                LogUtil.adminlog(sqlSession, "下载pfx证书", "下载失败,错误信息:" + e.getMessage());
            }
        }
    }
    return null;
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) OutputStream(java.io.OutputStream) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) IOException(java.io.IOException) Date(java.util.Date) EncDecException(com.itrus.portal.exception.EncDecException) IOException(java.io.IOException) RaServiceUnavailable_Exception(cn.topca.tca.ra.service.RaServiceUnavailable_Exception) BigInteger(java.math.BigInteger) DigitalCert(com.itrus.portal.db.DigitalCert) RaAccount(com.itrus.portal.db.RaAccount) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) CertBuf(com.itrus.portal.db.CertBuf) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 23 with Enterprise

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

the class ExtraQueryBillController method updateExtraBillStatusPage.

/**
 * 修改增值订单状态的页面
 * @param id
 * @param request
 * @param uiModel
 * @return
 */
@RequestMapping("/update_extrabill_status_page/{id}")
public String updateExtraBillStatusPage(@PathVariable(value = "id", required = true) Long id, HttpServletRequest request, Model uiModel) {
    ExtraBill bill = extraBillService.selectByPrimaryKey(id);
    if (null == bill) {
        return "status403";
    }
    uiModel.addAttribute("bill", bill);
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    uiModel.addAttribute("enterprise", enterprise);
    // return "review/update";
    return "extrabill/update2";
}
Also used : ExtraBill(com.itrus.portal.db.ExtraBill) Enterprise(com.itrus.portal.db.Enterprise) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 24 with Enterprise

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

the class ExtraQueryBillController method show.

// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
    // 管理员项目权限
    Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
    List<Long> projectsOfAdminList = Arrays.asList(projectsOfAdmin);
    ExtraBillExample billExample = new ExtraBillExample();
    ExtraBillExample.Criteria criteria = billExample.or();
    criteria.andIdEqualTo(id);
    criteria.andProjectIn(projectsOfAdminList);
    ExtraBill bill = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.selectByExample", billExample);
    if (null == bill) {
        uiModel.addAttribute("errorMsg", "未找到该订单");
        return "status403";
    }
    uiModel.addAttribute("bill", bill);
    // 项目
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
    uiModel.addAttribute("project", project);
    // 企业
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    if (StringUtils.isNotBlank(enterprise.getProvince())) {
        String province = sysRegionService.getProvince(enterprise.getProvince());
        enterprise.setProvince(province);
    }
    if (StringUtils.isNotBlank(enterprise.getCity())) {
        String city = sysRegionService.getCity(enterprise.getCity());
        enterprise.setCity(city);
    }
    uiModel.addAttribute("enterprise", enterprise);
    // 产品
    ExtraProduct product = sqlSession.selectOne("com.itrus.portal.db.ExtraProductMapper.selectByPrimaryKey", bill.getExtraProduct());
    uiModel.addAttribute("product", product);
    // 规格
    ExtraProductSpec productSpec = sqlSession.selectOne("com.itrus.portal.db.ExtraProductSpecMapper.selectByPrimaryKey", bill.getExtraProductSpec());
    uiModel.addAttribute("productSpec", productSpec);
    // 服务商
    ServiceProvider serviceProvider = serviceProviderService.selectByPrimaryKey(product.getServiceProvider());
    uiModel.addAttribute("serviceProvider", serviceProvider);
    // 用户
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
    uiModel.addAttribute("userInfo", userInfo);
    // 第三方支付信息
    OnPayInfo onPayInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
    uiModel.addAttribute("onPayInfo", onPayInfo);
    if (onPayInfo != null) {
        // 在线支付信息
        OnlinePay onlinePay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByPrimaryKey", onPayInfo.getOnlinePay());
        uiModel.addAttribute("onlinePay", onlinePay);
    }
    // 电子发票
    Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
    uiModel.addAttribute("einvoice", einvoice);
    // 电子发票类型
    if (einvoice != null && einvoice.geteReiceipt() != null) {
        Ereceipt ereceipt = sqlSession.selectOne("com.itrus.portal.db.EreceiptMapper.selectByPrimaryKey", einvoice.geteReiceipt());
        uiModel.addAttribute("ereceipt", ereceipt);
    }
    // 其他附加信息
    // 营业执照
    BusinessLicense businessLicense = businessService.getBusinessByExtraBillId(id, null);
    uiModel.addAttribute("bl", businessLicense);
    // 税务登记
    TaxRegisterCert taxRegisterCert = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
    uiModel.addAttribute("trc", taxRegisterCert);
    // 组织机构代码
    OrgCode orgCode = orgCodeService.getOrgCodeByExtraBillId(id, null);
    uiModel.addAttribute("oc", orgCode);
    // 代理人
    Agent agent = agentService.getAgentByExtraBillId(id, null);
    uiModel.addAttribute("agent", agent);
    // 开户行信息
    OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
    uiModel.addAttribute("obi", openBankInfo);
    // 法人信息
    IdentityCard identityCard = identityCardService.getIdentityCardByExtraBillId(id, null);
    uiModel.addAttribute("ic", identityCard);
    // TODO 还需要补充订单对应的附加信息和第三方回调信息
    return "extrabill/show";
}
Also used : Ereceipt(com.itrus.portal.db.Ereceipt) Agent(com.itrus.portal.db.Agent) ExtraBill(com.itrus.portal.db.ExtraBill) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) UserInfo(com.itrus.portal.db.UserInfo) Einvoice(com.itrus.portal.db.Einvoice) ExtraBillExample(com.itrus.portal.db.ExtraBillExample) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) OnPayInfo(com.itrus.portal.db.OnPayInfo) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) ServiceProvider(com.itrus.portal.db.ServiceProvider) Enterprise(com.itrus.portal.db.Enterprise) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) OnlinePay(com.itrus.portal.db.OnlinePay) IdentityCard(com.itrus.portal.db.IdentityCard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 25 with Enterprise

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

the class EnterpriseController method updateEnterprise.

/**
 * 修改企业
 *
 * @param id
 * @return
 */
@RequestMapping(value = "/updateEnterprise/{eid}", method = RequestMethod.POST)
public String updateEnterprise(@PathVariable(value = "eid") Long id, Enterprise enterprise) {
    Enterprise old_enterprise = enterpriseService.getEnterpriseById(id);
    if (null == enterprise) {
        return "uncaughtException";
    }
    String oldEnterpriseSn = old_enterprise.getEnterpriseSn();
    // 修改企业信息
    try {
        enterpriseService.updateEnterprise(enterprise);
        // 修改该企业关联的营业执照信息中的企业名称
        List<BusinessLicense> bus = businessService.getBusinessLicenses(id);
        businessService.updateBus(bus, enterprise);
        // 记录管理员日志
        LogUtil.adminlog(sqlSession, "修改企业", "企业名称由" + old_enterprise.getEnterpriseName() + "修改为" + enterprise.getEnterpriseName() + ",企业唯一标识由" + old_enterprise.getEnterpriseSn() + "修改为" + enterprise.getEnterpriseSn());
    } catch (Exception e) {
        e.printStackTrace();
        return "uncaughtException";
    }
    // 复制修改前的图片到新的文件夹中(旧目录为空不会复制)
    if (!oldEnterpriseSn.equals(enterprise.getEnterpriseSn())) {
        try {
            CopyFile.copyFile(systemConfigService.getTrustDir().getPath() + File.separator + oldEnterpriseSn, systemConfigService.getTrustDir().getPath() + File.separator + enterprise.getEnterpriseSn());
        } catch (Exception e) {
            e.printStackTrace();
            return "uncaughtException";
        }
    }
    return "redirect:/enterpriseinfo/updateEnterpriseUI/" + id;
}
Also used : BusinessLicense(com.itrus.portal.db.BusinessLicense) Enterprise(com.itrus.portal.db.Enterprise) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Enterprise (com.itrus.portal.db.Enterprise)94 UserInfo (com.itrus.portal.db.UserInfo)68 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)58 HashMap (java.util.HashMap)47 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)37 IOException (java.io.IOException)32 Product (com.itrus.portal.db.Product)27 HttpSession (javax.servlet.http.HttpSession)27 Bill (com.itrus.portal.db.Bill)26 BusinessLicense (com.itrus.portal.db.BusinessLicense)26 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)25 ExtraProduct (com.itrus.portal.db.ExtraProduct)24 OrgCode (com.itrus.portal.db.OrgCode)23 IdentityCard (com.itrus.portal.db.IdentityCard)22 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)22 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)22 ExtraBill (com.itrus.portal.db.ExtraBill)21 Project (com.itrus.portal.db.Project)20 UserCert (com.itrus.portal.db.UserCert)19 Agent (com.itrus.portal.db.Agent)18