Search in sources :

Example 1 with Enterprise

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

the class BillWebController method showTwo.

/**
 * 订单详情
 *
 * @param id
 * @param uiModel
 * @param autoShowPfxMessage 从订单信息页面 点击下载证书跳转到下载证书页面,若为 1 自动弹出短信输入框,
 * @return
 */
@RequestMapping(value = "/bill/{id}.html", produces = "text/html")
public String showTwo(@PathVariable("id") Long id, Model uiModel, @RequestParam(value = "typenum", required = false) String typenum, @RequestParam(value = "num", required = false) Long num, @RequestParam(value = "updateAuditBill", required = false) String updateAuditBill, @RequestParam(value = "autoShowPfxMessage", required = false) String autoShowPfxMessage, HttpServletRequest request) {
    HttpSession session = request.getSession();
    Boolean verifyCodeStatus = (Boolean) session.getAttribute("webverifyCodeStatus");
    Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
    UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
    List<Map> billAll = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectDingdanByBill", id);
    if (billAll.size() == 0) {
        return "redirect:/userInfoWeb/denglu.html";
    }
    // 解析订单中uid信息{"ADDTIONAL_FIELD1_1":"","ADDTIONAL_FIELD3_1":"","ADDTIONAL_FIELD4_1":"G2016071301","inputName":"inputValue"}\
    Bill bill = billService.getBill(id);
    if (null != bill.getUid()) {
        uiModel.addAttribute("uid", bill.getUid().toString());
    }
    if (null != bill.getUid1()) {
        uiModel.addAttribute("uid1", bill.getUid1().toString());
    }
    if (null != bill.getUid2()) {
        uiModel.addAttribute("uid2", bill.getUid2().toString());
    }
    if (null != bill.getUid3()) {
        uiModel.addAttribute("uid3", bill.getUid3().toString());
    }
    /*if(!bill.getUid().equals("{}")){
			List<String> listStr = new ArrayList<String>();
			JSONObject uid = JSONObject.parseObject(bill.getUid().toString());
			for(int i= 0; i< (int)bill.getProductNum();i++){
				//uiModel.addAttribute("uid"+ (i+1), uid.get(("ADDTIONAL_FIELD"+ (i+ 1)) + "_1"));
				listStr.add(uid.get(("ADDTIONAL_FIELD1_"+ (i+ 1))).toString());
			}
			uiModel.addAttribute("listStr", listStr);
		}*/
    // 得到证书信息项
    Product pdt = productService.getProductById(bill.getProduct());
    uiModel.addAttribute("pdt", pdt);
    if (pdt.getCertinfo() != null) {
        uiModel.addAttribute("certinfoStr", escapeTool.javascript(pdt.getCertinfo()));
    } else {
        uiModel.addAttribute("certinfoStr", "[]");
    }
    PayInfoExample payInfoex = new PayInfoExample();
    Map<Long, PayInfo> payinfoMap = sqlSession.selectMap("com.itrus.portal.db.PayInfoMapper.selectByExample", payInfoex, "id");
    uiModel.addAttribute("payinfomap", payinfoMap);
    String descript = billAll.get(0).get("descript").toString().replace("\r\n", "<br/>");
    uiModel.addAttribute("descript", descript);
    // 如配置了产品规格,则将产品规格返回:产品期限、产品描述
    if (billAll.get(0).containsKey("product_spec") && !"0".equals(billAll.get(0).get("product_spec"))) {
        ProductSpec productSpec = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec"));
        descript = "产品期限:" + productSpec.getProductValid() + "年<br/>" + "产品描述:" + productSpec.getDescript().replace("\r\n", "<br/>");
        uiModel.addAttribute("descript", descript);
    }
    // 组合产品以及产品规格以及证书信息项
    String descript1 = "";
    String descript2 = "";
    String descript3 = "";
    if (billAll.get(0).containsKey("product_spec1") && !"0".equals(billAll.get(0).get("product_spec1"))) {
        ProductSpec productSpec1 = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec1"));
        descript1 = "产品期限:" + productSpec1.getProductValid() + "年<br/>" + "产品描述:" + productSpec1.getDescript().replace("\r\n", "<br/>");
        uiModel.addAttribute("descript1", descript1);
    }
    if (billAll.get(0).containsKey("product_spec2") && !"0".equals(billAll.get(0).get("product_spec2"))) {
        ProductSpec productSpec2 = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec2"));
        descript2 = "产品期限:" + productSpec2.getProductValid() + "年<br/>" + "产品描述:" + productSpec2.getDescript().replace("\r\n", "<br/>");
        uiModel.addAttribute("descript2", descript2);
    }
    if (billAll.get(0).containsKey("product_spec3") && !"0".equals(billAll.get(0).get("product_spec3"))) {
        ProductSpec productSpec3 = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec3"));
        descript3 = "产品期限:" + productSpec3.getProductValid() + "年<br/>" + "产品描述:" + productSpec3.getDescript().replace("\r\n", "<br/>");
        uiModel.addAttribute("descript3", descript3);
    }
    if (null != bill.getProduct1()) {
        Product product1 = productService.getProductById(bill.getProduct1());
        uiModel.addAttribute("product1", product1);
        if (product1.getCertinfo() != null) {
            uiModel.addAttribute("certinfoStr1", escapeTool.javascript(product1.getCertinfo()));
        } else {
            uiModel.addAttribute("certinfoStr1", "[]");
        }
    }
    if (null != bill.getProduct2()) {
        Product product2 = productService.getProductById(bill.getProduct2());
        uiModel.addAttribute("product2", product2);
        if (product2.getCertinfo() != null) {
            uiModel.addAttribute("certinfoStr2", escapeTool.javascript(product2.getCertinfo()));
        } else {
            uiModel.addAttribute("certinfoStr2", "[]");
        }
    }
    if (null != bill.getProduct3()) {
        Product product3 = productService.getProductById(bill.getProduct3());
        uiModel.addAttribute("product3", product3);
        if (product3.getCertinfo() != null) {
            uiModel.addAttribute("certinfoStr3", escapeTool.javascript(product3.getCertinfo()));
        } else {
            uiModel.addAttribute("certinfoStr3", "[]");
        }
    }
    if (null == verifyCodeStatus || !verifyCodeStatus || null == userInfo || !(billAll.get(0).get("enterprise").equals(enterprise.getId()))) {
        // 登录状态失效,跳转到登录页面
        return "redirect:/userInfoWeb/denglu.html";
    }
    // 获取订单在线支付方式
    if (billAll.get(0).get("on_pay_info") != null) {
        Map<Long, OnPayInfo> opiMap = sqlSession.selectMap("com.itrus.portal.db.OnPayInfoMapper.selectByExample", "id");
        uiModel.addAttribute("opiMap", opiMap);
        Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
        uiModel.addAttribute("opMap", opMap);
    }
    // 获取产品的认证等级需要认证的项
    Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", billAll.get(0).get("authentication"));
    List<Map> courierinfos = new ArrayList<Map>();
    if (billAll.get(0).get("delivery") != null) {
        courierinfos = sqlSession.selectList("com.itrus.portal.db.CourierInfoMapper.selectItemsByCourierInfo", billAll.get(0).get("id"));
        uiModel.addAttribute("courierinfos", courierinfos);
    }
    Map<Long, Receipt> receiptmap = sqlSession.selectMap("com.itrus.portal.db.ReceiptMapper.selectByExample", null, "id");
    Map<Long, Ereceipt> ereceiptmap = sqlSession.selectMap("com.itrus.portal.db.EreceiptMapper.selectByExample", null, "id");
    Map<Long, DigitalCert> certmap = sqlSession.selectMap("com.itrus.portal.db.DigitalCertMapper.selectByExample", null, "id");
    // 判断订单对应的产品是否配置有数字证书
    Product product = productService.getProductById((Long) billAll.get(0).get("product"));
    if (null == product.getCert()) {
        uiModel.addAttribute("billhasnotcert", 1);
        // 判断无数字证书的订单是否需要配送
        if (null != billAll.get(0).get("delivery")) {
            uiModel.addAttribute("billneedtodelivery", 1);
        } else {
            uiModel.addAttribute("billneedtodelivery", 0);
        }
    } else {
        uiModel.addAttribute("billhasnotcert", 0);
    }
    // 根据省市区code值获取省市区最新名称
    String regionCodes = billAll.get(0).get("d_codes") == null ? "" : billAll.get(0).get("d_codes").toString();
    String detailAdds = billAll.get(0).get("d_adds") == null ? "" : billAll.get(0).get("d_adds").toString();
    if (StringUtils.isNotBlank(regionCodes) && regionCodes.indexOf("@") >= 0) {
        String[] codes = regionCodes.split("@");
        String regionName = sysRegionService.getAllName(codes[1], codes[2], codes[3]);
        detailAdds = regionName + detailAdds;
    }
    uiModel.addAttribute("detailAdd", detailAdds);
    if (null != billAll.get(0).get("u_adds")) {
        String regionCodes1 = billAll.get(0).get("u_codes").toString();
        String detailAdds1 = billAll.get(0).get("u_adds").toString();
        if (StringUtils.isNotBlank(regionCodes1) && regionCodes1.indexOf("@") >= 0) {
            String[] codes1 = regionCodes1.split("@");
            String regionName1 = sysRegionService.getAllName(codes1[1], codes1[2], codes1[3]);
            detailAdds1 = regionName1 + detailAdds1;
        }
        uiModel.addAttribute("detailAdd1", detailAdds1);
    }
    int num1 = 0;
    if (num != null) {
        num1 = Integer.parseInt(num.toString());
    }
    // 该订单是否有价格优惠记录
    PreferentialRecord pr = preferentialRecordService.selectPreferentialRecordSByBillId(id);
    if (null != pr) {
        // 原价
        Double originalCost = pr.getOriginalPrice();
        // 优惠价
        Double preCost = pr.getPreferentialPrice();
        uiModel.addAttribute("originalCost", originalCost);
        uiModel.addAttribute("preCost", preCost);
    }
    uiModel.addAttribute("num", num1);
    uiModel.addAttribute("billAll", billAll);
    uiModel.addAttribute("receiptmap", receiptmap);
    uiModel.addAttribute("ereceiptmap", ereceiptmap);
    uiModel.addAttribute("certmap", certmap);
    uiModel.addAttribute("certification", certification);
    uiModel.addAttribute("product", product);
    // 根据订单id返回签章模版
    try {
        makeSeal((Long) billAll.get(0).get("id"), uiModel);
    } catch (EncDecException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    if (typenum == null)
        typenum = "0";
    // 判断是否是审核中进入的订单修改页面
    if (StringUtils.isNotBlank(updateAuditBill) && updateAuditBill.equals("1")) {
        // 判断订单状态是否1,2,3,10
        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(billAll.get(0).get("bill_status")) == -1) {
            // 重定向
            return "redirect:/billWeb/bill/" + id + ".html";
        }
        return "ixinweb/dingdanxiangqing_shenhezhong_chongxintijiao";
    }
    // 审核记录
    ReviewLog reviewLog = reviewLogService.getReviewLog(id);
    if (reviewLog != null) {
        uiModel.addAttribute("reviewLog", reviewLog);
    }
    // 支付待确认时间
    if (billAll.get(0).get("pay_info") != null) {
        List<PayInfo> pays = sqlSession.selectList("com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey", billAll.get(0).get("pay_info"));
        PayInfo dp = pays.get(0);
        uiModel.addAttribute("pay_time", dp.getCreateTime());
        uiModel.addAttribute("pay_confirm_time", dp.getPayConfirmTime());
    }
    // 判断订单状态
    if (billAll.get(0).get("bill_status").equals(1) || billAll.get(0).get("bill_status").equals(2)) {
        // 更新证书前 ,显示旧证书
        if (billAll.get(0).get("old_user_cert") != null) {
            UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
            Object[] info = getCertInfo(oldUserCert);
            uiModel.addAttribute("remainingDays", info[0]);
            uiModel.addAttribute("owner", info[1]);
            uiModel.addAttribute("oldUserCert", oldUserCert);
            // 根据订单id返回签章模版
            try {
                makeSeal(oldUserCert.getBill(), uiModel);
            } catch (EncDecException e1) {
                e1.printStackTrace();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
        return "ixinweb/dingdanxiangqing_daizhifu";
    } else if (billAll.get(0).get("bill_status").equals(3) || billAll.get(0).get("bill_status").equals(4) || billAll.get(0).get("bill_status").equals(11) || billAll.get(0).get("bill_status").equals(10)) {
        // 更新证书前 ,显示旧证书
        if (billAll.get(0).get("old_user_cert") != null) {
            UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
            Object[] info = getCertInfo(oldUserCert);
            uiModel.addAttribute("remainingDays", info[0]);
            uiModel.addAttribute("owner", info[1]);
            uiModel.addAttribute("oldUserCert", oldUserCert);
            // 根据订单id返回签章模版
            try {
                makeSeal(oldUserCert.getBill(), uiModel);
            } catch (EncDecException e1) {
                e1.printStackTrace();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
        if (billAll.get(0).get("bill_status").equals(11)) {
            PayInfo payinfo = sqlSession.selectOne("com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey", billAll.get(0).get("pay_info"));
            uiModel.addAttribute("payinfo", payinfo);
        }
        if (Integer.parseInt(typenum) == 1) {
            if (null != product && product.getProject() != null) {
                EnterpriseQqExample enterpriseE = new EnterpriseQqExample();
                EnterpriseQqExample.Criteria qqEx = enterpriseE.createCriteria();
                qqEx.andProjectIdEqualTo(product.getProject());
                EnterpriseQq enterpriseqq = sqlSession.selectOne("com.itrus.portal.db.EnterpriseQqMapper.selectByExample", enterpriseE);
                if (enterpriseqq != null && enterpriseqq.getEnterpriseQqLinks() != null) {
                    uiModel.addAttribute("enterpriseqq", enterpriseqq.getEnterpriseQqLinks());
                    session.setAttribute("enterpriseqqE", enterpriseqq.getEnterpriseQqLinks());
                }
            }
            return "ixinweb/dingdanxiangqing_chongxintijiao";
        } else {
            return "ixinweb/dingdanxiangqing_dengdaishenhe";
        }
    } else if (billAll.get(0).get("bill_status").equals(12)) {
        // 待更新
        List<UserCert> userCerts = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
        if (userCerts.size() > 0) {
            UserCert userCert = userCerts.get(0);
            Object[] info = getCertInfo(userCert);
            uiModel.addAttribute("remainingDays", info[0]);
            uiModel.addAttribute("owner", info[1]);
            uiModel.addAttribute("userCert", userCerts.get(0));
            // 根据订单id返回签章模版
            try {
                makeSeal(userCert.getBill(), uiModel);
            } catch (EncDecException e1) {
                e1.printStackTrace();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
        return "ixinweb/dingdanxiangqing_gengxinshenhetongguo";
    } else if (billAll.get(0).get("bill_status").equals(5) || billAll.get(0).get("bill_status").equals(6) || billAll.get(0).get("bill_status").equals(7)) {
        // 初购产品 已制证 在订单详情显示 证书信息
        if ((Integer) billAll.get(0).get("bill_status") >= 6) {
            List<String> certStatus = new ArrayList<String>();
            List<UserCert> certs = userCertService.getUserCertByBill(id, certStatus);
            if (certs != null && certs.size() > 0) {
                certStatus.add(ComNames.CERT_STATUS_1);
                certStatus.add(ComNames.CERT_STATUS_2);
                UserCert userCert = certs.get(0);
                Object[] info = getCertInfo(userCert);
                uiModel.addAttribute("remainingDays", info[0]);
                uiModel.addAttribute("owner", info[1]);
                uiModel.addAttribute("userCert", userCert);
            }
        }
        // 返回老证书序列号
        if (billAll.get(0).get("old_user_cert") != null) {
            UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
            uiModel.addAttribute("oldCertSn", oldUserCert.getCertSn());
            try {
                List<String> allIssUerDn = new ArrayList<String>();
                allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
                uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
                makeSeal(oldUserCert.getBill(), uiModel);
            } catch (JsonGenerationException e) {
                e.printStackTrace();
            } catch (JsonMappingException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (EncDecException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (courierinfos.size() > 0) {
            uiModel.addAttribute("couriercount", courierinfos.size());
            return "ixinweb/dingdanxiangqing_yifahuo";
        } else {
            return "ixinweb/dingdanxiangqing_dengdaifahuo";
        }
    } else if (billAll.get(0).get("bill_status").equals(8)) {
        List<String> certStatus = new ArrayList<String>();
        List<UserCert> certs = userCertService.getUserCertByBill(id, certStatus);
        if (certs != null && certs.size() > 0) {
            certStatus.add(ComNames.CERT_STATUS_1);
            certStatus.add(ComNames.CERT_STATUS_2);
            UserCert userCert = certs.get(0);
            Object[] info = getCertInfo(userCert);
            uiModel.addAttribute("remainingDays", info[0]);
            uiModel.addAttribute("owner", info[1]);
            uiModel.addAttribute("userCert", userCert);
        }
        // 返回老证书序列号
        if (billAll.get(0).get("old_user_cert") != null) {
            UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", billAll.get(0).get("old_user_cert"));
            uiModel.addAttribute("oldCertSn", oldUserCert.getCertSn());
            try {
                List<String> allIssUerDn = new ArrayList<String>();
                allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
                uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
            } catch (JsonGenerationException e) {
                e.printStackTrace();
            } catch (JsonMappingException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return "ixinweb/dingdanxiangqing_yifahuo";
    // 下载证书
    } else if (billAll.get(0).get("bill_status").equals(13)) {
        uiModel.addAttribute("autoShowPfxMessage", autoShowPfxMessage);
        return "ixinweb/dingdanxiangqing_xiazaizhengshu";
    } else {
        return "ixinweb/dingdanxiangqing_yichuihui";
    }
}
Also used : ArrayList(java.util.ArrayList) Product(com.itrus.portal.db.Product) PreferentialRecord(com.itrus.portal.db.PreferentialRecord) DigitalCert(com.itrus.portal.db.DigitalCert) PayInfo(com.itrus.portal.db.PayInfo) OnPayInfo(com.itrus.portal.db.OnPayInfo) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) EnterpriseQqExample(com.itrus.portal.db.EnterpriseQqExample) ArrayList(java.util.ArrayList) List(java.util.List) Receipt(com.itrus.portal.db.Receipt) ProductSpec(com.itrus.portal.db.ProductSpec) Certification(com.itrus.portal.db.Certification) EditBill(com.itrus.portal.db.EditBill) Bill(com.itrus.portal.db.Bill) Map(java.util.Map) HashMap(java.util.HashMap) PayInfoExample(com.itrus.portal.db.PayInfoExample) UserInfo(com.itrus.portal.db.UserInfo) OnPayInfo(com.itrus.portal.db.OnPayInfo) OnlinePay(com.itrus.portal.db.OnlinePay) UserCert(com.itrus.portal.db.UserCert) Ereceipt(com.itrus.portal.db.Ereceipt) HttpSession(javax.servlet.http.HttpSession) EncDecException(com.itrus.portal.exception.EncDecException) IOException(java.io.IOException) 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) EnterpriseQq(com.itrus.portal.db.EnterpriseQq) Enterprise(com.itrus.portal.db.Enterprise) ReviewLog(com.itrus.portal.db.ReviewLog) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Enterprise

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

the class BindCertWebController method loginCertSendCode.

/**
 * 证书登陆绑定手机,发送验证码 szy 2016年8月18日 下午3:54:40
 *
 * @param mPhone
 *            手机号
 * @param projectId
 *            项目id
 * @param productId
 *            产品id
 * @param code
 *            短信验证码
 * @param certBase64
 *            证书信息
 * @return Map<String,Object> retCode -1失败,0成功,1该证书已经绑定过用户 hasUserInfo -1
 *         没有用户, 0 有用户
 */
@RequestMapping("/loginCertSendCode")
@ResponseBody
public Map<String, Object> loginCertSendCode(@RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "productId", required = false) Long productId, @RequestParam(value = "projectId", required = false) Long projectId, @RequestParam(value = "certBase64", required = true) String certBase64, @RequestParam(value = "enterpriseName", required = true) String enterpriseName, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 默认发送失败
    retMap.put("retCode", -1);
    // 查询使用手机号mPhone注册的用户
    UserInfo userInfo = userInfoService.getUserInfoByMphone(mPhone);
    // -1表示没有用户
    retMap.put("hasUserInfo", -1);
    try {
        if (null != userInfo) {
            // 0表示有用户
            retMap.put("hasUserInfo", 0);
            // false 是未关联, true已经关联
            if (userCertService.isBindCert(userInfo.getId(), certBase64)) {
                retMap.put("retCode", 1);
                retMap.put("retMsg", "该证书已绑定过用户");
                return retMap;
            }
        }
        if (null != projectId && null != productId) {
            session.setAttribute("webnoProduct", false);
        } else {
            Product product = getProjectByCertBase64(certBase64);
            projectId = product.getProject();
            productId = product.getId();
            session.setAttribute("webnoProduct", true);
        }
        // 发送验证码
        // ZSBD表示短信模版类型为‘绑定证书’。
        dynamicCodeService.sendCode(mPhone, projectId, "ZSBD");
        // 发送成功
        retMap.put("retCode", 0);
        // 返回企業信息
        Enterprise et = enterpriseService.getEntByName(enterpriseName);
        retMap.put("enterprise", et);
        // 将productId, projectId放入session
        session.setAttribute("webproductId", productId);
        session.setAttribute("webprojectId", projectId);
        // session.setAttribute("certBase64", certBase64);
        retMap.put("productId", productId);
        retMap.put("projectId", projectId);
    } catch (CertificateException e) {
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (SigningServerException e) {
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (UserInfoServiceException e) {
        retMap.put("retMsg", e.getMessage());
        return retMap;
    }
    return retMap;
}
Also used : HashMap(java.util.HashMap) Enterprise(com.itrus.portal.db.Enterprise) Product(com.itrus.portal.db.Product) SigningServerException(com.itrus.cryptorole.SigningServerException) UserInfo(com.itrus.portal.db.UserInfo) CertificateException(java.security.cert.CertificateException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with Enterprise

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

the class ClientWebController method bugExtraProduct.

// TODO
// 用户选择了产品中的某个规格,确认进行购买,对应于确认订单:根据产品是否需要附加信息,来决定用户提交的资料,判断后台是否有这个用户对应的这些附加信息,如果有就返回给页面
@RequestMapping("/buyExtraProduct")
public String bugExtraProduct(@RequestParam(value = "productId", required = true) Long productId, @RequestParam(value = "productSpecId", required = true) Long productSpecId, @RequestParam(value = "buyNumber", required = true) Long buyNumber, HttpServletRequest request, Model uiModel) {
    HttpSession session = request.getSession();
    // 判断用户和企业信息是否存在了,不存在不能购买
    Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
    UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
    if (null == enterprise || null == userInfo) {
        uiModel.addAttribute("errorMsg", "登录已经失效,请重新登录");
        return "client/errorpage";
    }
    try {
        ExtraProduct product = extraProductService.selectByPrimaryKey(productId);
        if (null == product) {
            uiModel.addAttribute("errorMsg", "增值产品不存在");
            return "client/errorpage";
        }
        uiModel.addAttribute("extraproduct", product);
        // 选择的规格信息
        ExtraProductSpec extraProductSpec = extraProductSpecService.selectByPrimaryKey(productSpecId);
        if (null == extraProductSpec) {
            uiModel.addAttribute("errorMsg", "增值产品规格不存在");
            return "client/errorpage";
        }
        uiModel.addAttribute("extraProductSpec", extraProductSpec);
        // 用户购买的数量:选择应该默认都是1
        uiModel.addAttribute("buyNumber", buyNumber);
        // 产品对应的服务商信息
        Long serviceProviderId = product.getServiceProvider();
        ServiceProvider serviceProvider = serviceProviderService.selectByPrimaryKey(serviceProviderId);
        uiModel.addAttribute("serviceProvider", serviceProvider);
        // 电子发票信息,看后台配置该产品是否能开票
        String eInvoceStr = product.getEinvoice();
        if (StringUtils.isNotBlank(eInvoceStr)) {
            // 电子开票服务
            Long[] ereceiptIds = StringTools.getLong(product.getEinvoice());
            Map<Long, Ereceipt> ereceiptMap = ereceiptService.getEreceiptMap(ereceiptIds);
            uiModel.addAttribute("ereceiptMap", ereceiptMap);
        }
        // 附加信息
        if (null != product.getExtraMessage()) {
            ExtraMessage extraMessage = extraMessageService.selectByPrimaryKey(product.getExtraMessage());
            // 用附加信息项的有无来判断是否需要用户填写附加信息,如果需要,则取附加信息项进行分割处理
            uiModel.addAttribute("extraMessage", 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")) {
                        List<BusinessLicense> businessLicenses = businessService.getBusinessLicensesNews(enterprise.getId());
                        if (null != businessLicenses && !businessLicenses.isEmpty()) {
                            session.setAttribute("webbusinessLicense", businessLicenses.get(0));
                        }
                    }
                    if (extraMessage.getEnterpriseItems().contains("3")) {
                        List<OrgCode> orgCodes = orgCodeService.getOrgCodesNews(enterprise.getId());
                        if (null != orgCodes && !orgCodes.isEmpty()) {
                            session.setAttribute("weborgCode", orgCodes.get(0));
                        }
                    }
                    if (extraMessage.getEnterpriseItems().contains("4")) {
                        List<TaxRegisterCert> taxRegisterCerts = taxCertService.getTaxRegisterCertsNews(enterprise.getId());
                        if (null != taxRegisterCerts && !taxRegisterCerts.isEmpty()) {
                            session.setAttribute("webtaxRegisterCert", taxRegisterCerts.get(0));
                        }
                    }
                }
            }
            // field string --fieldName agentItems
            if (StringUtils.isNotBlank(extraMessage.getAgentItems())) {
                List<Agent> agents = agentService.getAgentsNews(enterprise.getId());
                if (null != agents && !agents.isEmpty()) {
                    session.setAttribute("webagent", agents.get(0));
                }
            }
            // field string --fieldName bankItems
            if (StringUtils.isNotBlank(extraMessage.getBankItems())) {
                List<OpenBankInfo> openBankInfos = openBankInfoService.getOpenBankInfosNews(enterprise.getId());
                if (null != openBankInfos && !openBankInfos.isEmpty()) {
                    session.setAttribute("webopenBankInfo", openBankInfos.get(0));
                }
            }
            // 法人认证项
            if (StringUtils.isNotBlank(extraMessage.getIdentityCardItems())) {
                List<IdentityCard> identityCards = identityCardService.getIdentityCardsNews(enterprise.getId());
                if (null != identityCards && !identityCards.isEmpty()) {
                    session.setAttribute("webidentityCard", identityCards.get(0));
                }
            }
        }
    // logo和应用介绍信息,通过类似后台的回显方式进行加载
    } catch (Exception e) {
    // TODO: handle exception
    }
    return "client/querendingdan";
}
Also used : UserInfo(com.itrus.portal.db.UserInfo) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) IdentityCard(com.itrus.portal.db.IdentityCard) Ereceipt(com.itrus.portal.db.Ereceipt) Agent(com.itrus.portal.db.Agent) HttpSession(javax.servlet.http.HttpSession) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) 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) ServiceProvider(com.itrus.portal.db.ServiceProvider) 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)

Example 4 with Enterprise

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

the class ClientWebController method reSubmitOrder.

/**
 * 审核拒绝,重新提交信息接口
 * @param enterprise
 * @param userInfo
 * @param einvoice
 * @param businessLicense
 * @param orgCode
 * @param taxregisterCert
 * @param agent
 * @param openBankInfo
 * @param identityCard
 * @param request
 * @return
 */
@RequestMapping("/reSubmitOrder")
@ResponseBody
public Map<String, Object> reSubmitOrder(@RequestParam(value = "extraBillId", required = true) Long id, @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;
    }
    ExtraBill bill = extraBillService.selectByPrimaryKey(id);
    if (null == bill) {
        retMap.put("retMsg", "订单不存在");
        return retMap;
    }
    if (!bill.getUniqueId().equals(webuserInfo.getId())) {
        retMap.put("retMsg", "您无权操作该订单");
        return retMap;
    }
    ExtraProduct product = extraProductService.selectByPrimaryKey(bill.getExtraProduct());
    ExtraProductSpec productSpec = extraProductSpecService.selectByPrimaryKey(bill.getExtraProductSpec());
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 更新用户信息和企业信息
        enterprise.setId(webenterprise.getId());
        // ""字符串判断,改为Null,避免覆盖数据库中的信息
        if (null != enterprise) {
            if (StringUtils.isBlank(enterprise.getProvince())) {
                enterprise.setProvince(null);
            }
            if (StringUtils.isBlank(enterprise.getCity())) {
                enterprise.setCity(null);
            }
            if (StringUtils.isBlank(enterprise.getShortName())) {
                enterprise.setShortName(null);
            }
            if (StringUtils.isBlank(enterprise.getNsrsbh())) {
                enterprise.setNsrsbh(null);
            }
        }
        enterprise = enterpriseService.updateByPrimaryKeySelective(enterprise);
        userInfo.setId(webuserInfo.getId());
        userInfo = userInfoService.updateByPrimaryKeySelective(userInfo);
        // 根据订单id,获取该订单的旧认证项:
        BusinessLicense oldBl = businessService.getBusinessByExtraBillId(id, null);
        OrgCode oldOc = orgCodeService.getOrgCodeByExtraBillId(id, null);
        TaxRegisterCert oldTc = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
        IdentityCard oldIc = identityCardService.getIdentityCardByBillId(id, null);
        Agent oldAgent = agentService.getAgentByExtraBillId(id, null);
        OpenBankInfo oldBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
        // 新认证项id置null,便于执行新增或者修改处理
        businessLicense.setId(null);
        orgCode.setId(null);
        taxregisterCert.setId(null);
        identityCard.setId(null);
        agent.setId(null);
        openBankInfo.setId(null);
        // 获取产品需要的附加信息项
        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("2") && !webenterprise.getEnterpriseNature().equals(3)) {
                        // 事业单位不填写营业执照
                        hasBl = true;
                        businessLicense = businessService.saveBusinessExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), businessLicense, ComNames.ITEM_STATUS_2, oldBl);
                    }
                    if (extraMessage.getEnterpriseItems().contains("3")) {
                        // 需要统一组织机构代码认证项,但是页面没有传递过来的时候,用老的
                        if (!(hasBl && businessLicense.getBusinessType().equals(// 五证合一企业不用提交组织机构代码、税务登记信息
                        1))) {
                            orgCode = orgCodeService.saveOrgCodeExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), orgCode, ComNames.ITEM_STATUS_2, oldOc);
                        }
                    }
                    if (extraMessage.getEnterpriseItems().contains("4")) {
                        if (!(hasBl && businessLicense.getBusinessType().equals(// 五证合一企业不用提交组织机构代码、税务登记信息
                        1))) {
                            // 保存税务登记证
                            if (// 事业单位不填写税务登记信息
                            !webenterprise.getEnterpriseNature().equals(3)) {
                                taxregisterCert = taxCertService.saveTaxCertExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), taxregisterCert, ComNames.ITEM_STATUS_2, oldTc);
                            }
                        }
                    }
                }
            }
            // field string --fieldName agentItems
            if (StringUtils.isNotBlank(extraMessage.getAgentItems())) {
                agent = agentService.saveAgentExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), agent, ComNames.ITEM_STATUS_2, oldAgent);
            }
            // field string --fieldName bankItems
            if (StringUtils.isNotBlank(extraMessage.getBankItems())) {
                openBankInfo = openBankInfoService.saveOpenBankInfoExtraBill(webenterprise.getId(), bill.getId(), webuserInfo.getId(), openBankInfo, ComNames.ITEM_STATUS_2, oldBankInfo);
            }
            // field string  --fieldName identityCardItems
            if (StringUtils.isNotBlank(extraMessage.getIdentityCardItems())) {
                identityCard = identityCardService.saveIdentityCardExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), identityCard, ComNames.ITEM_STATUS_2, oldIc);
            }
        }
        retMap.put("retCode", 1);
        retMap.put("billId", bill.getId());
        bill.setBillStatus(ComNames.EXTRA_BILL_STATUS_3);
        extraBillService.updateByPrimaryKeySelective(bill);
        transactionManager.commit(status);
        // 更新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(bill.getProject());
        userlog.setType("审核拒绝重新提交");
        userlog.setInfo("提交成功,订单id:" + bill.getBillId());
        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(bill.getProject());
        userlog.setType("审核拒绝重新提交");
        userlog.setInfo("url:reSubmitOrder,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
        return retMap;
    }
}
Also used : Agent(com.itrus.portal.db.Agent) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) ExtraBill(com.itrus.portal.db.ExtraBill) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) 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) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) ExtraMessage(com.itrus.portal.db.ExtraMessage) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with Enterprise

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

the class ClientWebController method getAllInfo.

/**
 * 接收客户端传递的项目,用户,企业信息,返回项目下面的的产品信息,如果传递了用户信息和企业信息,则查询是否存在了,不存在则注册.
 * @param projectName,项目名称
 * @param type,类型.web.app,客户端,目前是客户端,跟发布平台的值相同:{1:"web", 2:"客户端", 3:"app"}
 * @param isregister,是否已经注册或者需要更新附加信息的标识.0标识未注册或者需要更新信息,1标识已经注册且是最新信息.由ukey平台传递给客户端,客户端直接回传
 * @param keySn,key序列号
 * @param certSn,证书序列号
 * @param enterprise,企业信息
 * @param userInfo,用户信息
 * @param businessLicense,营业执照信息
 * @param orgCode,组织机构代码信息
 * @param taxregisterCert,税务登记信息
 * @param identityCard,法人信息
 * @param uiModel
 * @param request
 * @return
 */
@RequestMapping("/getProductInfo")
public String getAllInfo(@RequestParam(value = "projectName", required = true) String projectName, @RequestParam(value = "type", required = true) String type, @RequestParam(value = "isregister", required = true) Integer isregister, @RequestParam(value = "certSn", required = true) String certSn, @RequestParam(value = "keySn", required = false) String keySn, @ModelAttribute("enterprise") Enterprise enterprise, @ModelAttribute("userInfo") UserInfo userInfo, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("identityCard") IdentityCard identityCard, Model uiModel, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识处理失败,1标识成功
    retMap.put("retCode", 0);
    // projectName = "宁波CA";
    Project project = projectService.getProjectByName(projectName);
    HttpSession session = request.getSession();
    if (null == project) {
        uiModel.addAttribute("errorMsg", "项目名称:" + projectName + ", 在ixin运营服务平台中不存在,请联系系统管理员进行配置");
        return "client/errorpage";
    }
    session.setAttribute("webproject", project);
    session.setAttribute("isregister", isregister);
    try {
        List<ExtraProductRelease> extraProductReleases = extraProductReleaseService.getByprojectAndType(project.getId(), type);
        // 获取项目下所有的发布产品
        List<ExtraProduct> extraProducts = extraProductService.getproductByEPR(extraProductReleases);
        session.setAttribute("webExtraProducts", extraProducts);
        // 增值产品的类型
        Set<Object> productTypeSet = new LinkedHashSet<>();
        for (ExtraProduct ep : extraProducts) {
            productTypeSet.add(ep.getAppType());
        }
        session.setAttribute("webProductTypes", productTypeSet);
        // 若用户已经存在了,则标识用户
        UserInfo userInfo2 = null;
        if (null != userInfo && StringUtils.isNotBlank(userInfo.getmPhone())) {
            userInfo2 = userInfoService.getUserInfoByMphone(userInfo.getmPhone());
            if (null != userInfo2) {
                if (isNeedToUpdateUserInfo(userInfo, userInfo2)) {
                    userInfo.setId(userInfo2.getId());
                    userInfoService.updateByPrimaryKeySelective(userInfo);
                    userInfo2 = userInfoService.getUserInfoByMphone(userInfo.getmPhone());
                }
                userInfo = userInfo2;
                session.setAttribute("webuserInfo", userInfo2);
            } else {
                // 用户密码取手机号后六位
                String password = userInfo.getmPhone().substring(userInfo.getmPhone().length() - 6, userInfo.getmPhone().length());
                userInfo = userInfoService.registerUserInfoExtraProduct(userInfo, password, project.getId());
                session.setAttribute("webuserInfo", userInfo);
            }
        }
        // 企业信息
        Enterprise enterprise2 = null;
        if (null != enterprise && StringUtils.isNotBlank(enterprise.getEnterpriseName()) && StringUtils.isNotBlank(enterprise.getEnterpriseSn())) {
            enterprise2 = enterpriseService.getEntByName(enterprise.getEnterpriseName());
            if (null != enterprise2) {
                enterprise = enterprise2;
                if (StringUtils.isNotBlank(userInfo.getRegionCodes()) && (StringUtils.isBlank(enterprise.getProvince()) || StringUtils.isBlank(enterprise.getCity()))) {
                    // 组装企业信息中的企业省,市
                    String[] regegions = userInfo.getRegionCodes().split("@");
                    enterprise.setProvince(regegions[1]);
                    enterprise.setCity(regegions[2]);
                    enterpriseService.updateEnterprise(enterprise);
                }
            } else {
                if (StringUtils.isNotBlank(userInfo.getRegionCodes()) && (StringUtils.isBlank(enterprise.getProvince()) || StringUtils.isBlank(enterprise.getCity()))) {
                    // 组装企业信息中的企业省,市
                    String[] regegions = userInfo.getRegionCodes().split("@");
                    enterprise.setProvince(regegions[1]);
                    enterprise.setCity(regegions[2]);
                }
                enterpriseService.addEnterPrise(enterprise);
            }
            session.setAttribute("webenterprise", enterprise);
        }
        if (null != userInfo && null != userInfo.getId() && null != enterprise && null != enterprise.getId()) {
            // 若用户和企业之间没有关联关系,则关联起来
            UserinfoEnterprise userinfoEnterprise = UserInfoEnterpriseService.selectOne(enterprise.getId(), userInfo.getId());
            if (null == userinfoEnterprise) {
                UserInfoEnterpriseService.saveUserInfoEnterprise(userInfo.getId(), enterprise.getId());
            }
            // 保存营业执照.覆盖服务器中最新的信息..如果有则覆盖,没有则新增
            if (isregister != 1 && null != businessLicense && StringUtils.isNotBlank(businessLicense.getEnterpriseName()) && StringUtils.isNotBlank(businessLicense.getImgFile()) && StringUtils.isNotBlank(businessLicense.getLicenseNo())) {
                // 查询数据库中是否存在该用户,该企业,未关联订单和增值订单.并且认证通过的营业执照信息,如果有的话,就对营业执照进行更新
                BusinessLicense oldBl = businessService.getBusinessLicensesNews2(enterprise.getId(), userInfo.getId());
                // 判断是否三证合一
                if (null == businessLicense.getBusinessType()) {
                    Integer businessType = 0;
                    if (businessLicense.getLicenseNo().length() == 18) {
                        businessType = 1;
                        // 填充企业纳税人识别号
                        if (StringUtils.isBlank(enterprise.getNsrsbh())) {
                            enterprise.setNsrsbh(businessLicense.getLicenseNo());
                        }
                    }
                    businessLicense.setBusinessType(businessType);
                }
                businessLicense = businessService.saveBusinessExtraBill(enterprise.getId(), enterprise.getEnterpriseSn(), null, userInfo.getId(), businessLicense, ComNames.ITEM_STATUS_2, oldBl);
                // 设置企业和附加信息的认证关系
                if (null == enterprise.getHasBl()) {
                    enterprise.setHasBl(businessLicense.getId());
                }
            }
            if (isregister != 1 && null != orgCode && StringUtils.isNotBlank(orgCode.getEnterpriseName()) && StringUtils.isNotBlank(orgCode.getImgFile()) && StringUtils.isNotBlank(orgCode.getOrgCode())) {
                OrgCode oldoc = orgCodeService.getOrgCodesNews2(enterprise.getId(), userInfo.getId());
                orgCode = orgCodeService.saveOrgCodeExtraBill(enterprise.getId(), enterprise.getEnterpriseSn(), null, userInfo.getId(), orgCode, ComNames.ITEM_STATUS_2, oldoc);
                // 设置企业和附加信息的认证关系
                if (null == enterprise.getHasOrgCode()) {
                    enterprise.setHasOrgCode(orgCode.getId());
                }
            }
            if (isregister != 1 && null != taxregisterCert && StringUtils.isNotBlank(taxregisterCert.getEnterpriseName()) && StringUtils.isNotBlank(taxregisterCert.getImgFile()) && StringUtils.isNotBlank(taxregisterCert.getCertNo())) {
                TaxRegisterCert oldTaxRegisterCert = taxCertService.getTaxRegisterCertsNews2(enterprise.getId(), userInfo.getId());
                taxregisterCert = taxCertService.saveTaxCertExtraBill(enterprise.getId(), enterprise.getEnterpriseSn(), null, userInfo.getId(), taxregisterCert, ComNames.ITEM_STATUS_2, oldTaxRegisterCert);
                // 设置企业和附加信息的认证关系
                if (null == enterprise.getHasTaxCert()) {
                    enterprise.setHasTaxCert(taxregisterCert.getId());
                }
                // 填充企业纳税人识别号
                if (StringUtils.isBlank(enterprise.getNsrsbh())) {
                    enterprise.setNsrsbh(taxregisterCert.getCertNo());
                }
            }
            if (isregister != 1 && null != identityCard && StringUtils.isNotBlank(identityCard.getEnterpriseName()) && StringUtils.isNotBlank(identityCard.getName()) && StringUtils.isNotBlank(identityCard.getFrontImg())) {
                IdentityCard oldIdentityCard = identityCardService.getIdentityCardsNews2(enterprise.getId(), userInfo.getId());
                identityCard = identityCardService.saveIdentityCardExtraBillFromUkey(enterprise.getId(), enterprise.getEnterpriseSn(), null, userInfo.getId(), identityCard, ComNames.ITEM_STATUS_2, oldIdentityCard);
                // 设置企业和附加信息的认证关系
                if (null == enterprise.getHasIdCard()) {
                    enterprise.setHasIdCard(identityCard.getId());
                }
            }
            enterpriseService.updateEnterprise(enterprise);
        }
        // 如果用户是第一次来登录,并且用户没有通过认证,则不能认为用户认证通过了.(只有当本次输入是没有注册过,并且本次有通过认证的附加信息项,才能认为本次是注册成功了.)
        boolean hasOnePass = (null != businessLicense && null != businessLicense.getId()) || (null != orgCode && null != orgCode.getId()) || (null != taxregisterCert && null != taxregisterCert.getId()) || (null != identityCard && null != identityCard.getId());
        if (isregister != 1 && (null != userInfo.getId() && null != enterprise.getId()) && hasOnePass) {
            ixinUkeyRegrecordService.insertOrUpdate(keySn, certSn);
            // 判定用户是否已经在本平台注册成功.是否可以开始购买
            boolean isCanBuy = isCanBuy(enterprise, businessLicense, taxregisterCert, orgCode, identityCard);
            if (isCanBuy) {
                session.setAttribute("isregister", 1);
            }
        }
        UserLog userlog = new UserLog();
        userlog.setCreateTime(new Date());
        userlog.setHostId("未知");
        if (null == userInfo2) {
            userlog.setInfo("用户登录" + userInfo.getmPhone());
            userlog.setType("用户登录_增值产品");
        } else {
            userlog.setInfo("用户注册:" + userInfo.getmPhone());
            userlog.setType("用户注册_增值产品");
        }
        userlog.setProject(project.getId());
        userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
    } catch (Exception e) {
        UserLog userlog = new UserLog();
        userlog.setCreateTime(new Date());
        userlog.setHostId("未知");
        userlog.setInfo("增值订单用户注册出现异常,异常信息:" + e.getMessage());
        userlog.setProject(project.getId());
        userlog.setType("用户登录_增值产品");
        userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
    }
    return "client/yingyongzhanshi";
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) UserInfo(com.itrus.portal.db.UserInfo) IdentityCard(com.itrus.portal.db.IdentityCard) HttpSession(javax.servlet.http.HttpSession) UserLog(com.itrus.portal.db.UserLog) Date(java.util.Date) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) 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