Search in sources :

Example 46 with Product

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

the class UnlockKeyBillController method submitUnlockBill.

/**
 * 提交解锁订单
 * @param productId,购买产品的id
 * @param certSn
 * @param keySn
 * @param einvoice
 * @param proxy
 * @param request
 * @return
 */
@RequestMapping("/submitUnlockBill")
@ResponseBody
public Map<String, Object> submitUnlockBill(@RequestParam("productId") Long productId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @RequestParam("keyType") String keyType, @RequestParam("enterpriseName") String enterpriseName, @RequestParam("reqCode") String reqCode, @ModelAttribute("einvoice") Einvoice einvoice, @ModelAttribute("userInfo") UserInfo userInfo, @ModelAttribute("enterprise") Enterprise enterprise, @ModelAttribute("proxy") Proxy proxy, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("retCode", 0);
    HttpSession session = request.getSession();
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (StringUtils.isBlank(keySn)) {
        retMap.put("retMsg", "key序列号不能为空");
        return retMap;
    }
    if (StringUtils.isBlank(reqCode)) {
        retMap.put("retMsg", "解锁请求码不能为空");
        return retMap;
    }
    if (null == userCert) {
        retMap.put("retMsg", "该证书未注册,请您先注册");
        return retMap;
    }
    if (StringUtils.isBlank(userCert.getKeySn()) || !keySn.equals(userCert.getKeySn())) {
        userCert.setKeySn(keySn);
        userCertService.updateByPrimaryKeySelective(userCert);
    }
    UserInfo webUserInfo = null;
    if (null == userInfo || StringUtils.isBlank(userInfo.getmPhone())) {
        retMap.put("retMsg", "用户信息不完整,请重新提交");
        return retMap;
    } else {
        webUserInfo = userInfoService.getUserInfoByMphone(userInfo.getmPhone());
    }
    if (null == webUserInfo) {
        retMap.put("retMsg", "手机号:" + userInfo.getmPhone() + ", 尚未注册或者校验通过,请检查您输入的手机号是否正确!");
        return retMap;
    }
    Enterprise enterpriseByName = enterpriseService.getEntByName(enterpriseName);
    if (null == enterpriseByName) {
        // 若新提交的企业信息为null或者信息不全,则提示
        if (null == enterprise || StringUtils.isBlank(enterprise.getEnterpriseName()) || null == enterprise.getEnterpriseNature() || StringUtils.isBlank(enterprise.getEnterpriseSn())) {
            retMap.put("retMsg", "企业信息不完整,请重新提交");
            return retMap;
        } else {
            // 保存新增的企业信息
            enterprise = enterpriseService.saveOrUpdateEnterprise(enterprise);
            // 添加企业-代理人关联关系
            UserinfoEnterprise userinfoEnterprise = userInfoEnterpriseServiceImpl.selectOne(enterprise.getId(), webUserInfo.getId());
            if (null == userinfoEnterprise) {
                userInfoEnterpriseServiceImpl.saveUserInfoEnterprise(webUserInfo.getId(), enterprise.getId());
            }
        }
    } else {
        enterprise = enterpriseByName;
    }
    Product product = productService.getProduct(productId);
    if (null == product) {
        retMap.put("retMsg", "您选择的产品不存在");
        return retMap;
    }
    if (null == product.getKeyUnlockType()) {
        retMap.put("retMsg", "您选择的产品不属于解锁产品,请重新选择");
        return retMap;
    }
    if (null == userCert.getUserinfo() && product.getKeyUnlockType().equals(ComNames.KEY_UNLOCK_TYPE_1)) {
        retMap.put("retMsg", "未绑定用户的证书,不能购买自助解锁产品");
        return retMap;
    }
    Bill billOld = billService.getBillWaitingForUnlock(userCert.getId());
    if (null != billOld) {
        retMap.put("retMsg", "当前证书尚有未解锁的订单,请先在原订单解锁,订单号:" + billOld.getBillId());
        return retMap;
    }
    Project project = projectService.selectByPrimaryKey(product.getProject());
    DefaultTransactionDefinition dtd = new DefaultTransactionDefinition();
    dtd.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(dtd);
    try {
        if (StringUtils.isNotBlank(userInfo.getEmail()) && StringUtils.isBlank(webUserInfo.getEmail())) {
            webUserInfo.setEmail(userInfo.getEmail());
            userInfoService.updateUserInfo(webUserInfo);
        }
        if (StringUtils.isNotBlank(einvoice.getName()) && null != einvoice.geteReiceipt()) {
            einvoice = EinvoiceService.saveEInvoice(webUserInfo.getId(), einvoice);
        }
        Bill bill = null;
        // 生成订单
        double billSum = product.getPrice();
        bill = billService.saveBill(webUserInfo.getId(), enterprise.getId(), product.getId(), null, null, null == einvoice.getId() ? null : einvoice.getId(), null, product.getProject(), 1, billSum, webUserInfo.getId(), ComNames.BILL_STATUS_1);
        bill.setBillId(UniqueIDUtils.genBilUID(bill));
        bill.setUnlockUserCert(userCert.getId());
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
        keyUnlockService.insert(bill.getId(), project.getId(), keySn, certSn, enterpriseName, keyType, "ENROLL", product.getKeyUnlockType() == 1 ? 1 : 2, reqCode);
        sqlSession.flushStatements();
        if (null != proxy && StringUtils.isNotBlank(proxy.getImgFile())) {
            // 保存授权书
            proxy = proxyService.saveProxy(enterprise.getId(), webUserInfo.getUniqueId(), bill.getId(), webUserInfo.getId(), proxy, project);
        }
        transactionManager.commit(status);
        retMap.put("billId", bill.getId());
        retMap.put("retCode", 1);
        // 将用户信息放入session中,避免支付出错
        session.setAttribute(ComNames.WEB_USER_INFO, webUserInfo);
        // 记录日志
        LogUtil.userlog(sqlSession, project.getId(), "购买解锁产品", webUserInfo.getmPhone() + "购买了" + product.getName(), "未知", "", null == webUserInfo.getUniqueId() ? null : webUserInfo.getUniqueId());
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        UserLog userlog = new UserLog();
        userlog.setProject(project.getId());
        userlog.setType("购买解锁产品");
        userlog.setInfo("url:submitUnlockBill,详细错误:" + 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) HttpSession(javax.servlet.http.HttpSession) Product(com.itrus.portal.db.Product) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Project(com.itrus.portal.db.Project) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) Bill(com.itrus.portal.db.Bill) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 47 with Product

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

the class UnlockKeyBillController method zhifuPage.

/**
 * 3进入支付页面
 *
 * @param billId
 * @param request
 * @param uiModel
 * @return
 */
@RequestMapping("/zhifu/{billId}")
public String zhifuPage(@PathVariable("billId") Long billId, @RequestParam(value = "certSn", required = false) String certSn, @RequestParam(value = "keySn", required = false) String keySn, @RequestParam(value = "enterpriseName", required = false) String enterpriseName, HttpServletRequest request, Model uiModel) {
    HttpSession session = request.getSession();
    String ip = request.getRemoteAddr();
    uiModel.addAttribute("ip", ip);
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    if (null == bill) {
        return "resourceNotFound";
    }
    // 产品
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    if (null == product) {
        // 产品不存在
        uiModel.addAttribute("errorMsg", "您购买的产品不存在");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    if (null == product.getOnpay() && StringUtils.isBlank(product.getPay()) && bill.getBillSum().equals(0.00)) {
        // 跳转到订单支付成功页面,并将订单状态设置为3已支付 待审核
        if (null != product.getKeyUnlockType()) {
            bill = unLockKeyBillService.updateBillStatusWhileHasPay(bill, product);
        } else {
            bill.setBillStatus(ComNames.BILL_STATUS_3);
        }
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
        session.setAttribute("webbill", bill);
        if (null != product.getKeyUnlockType()) {
            UserCert userCert = userCertService.selectByPrimaryKey(bill.getUnlockUserCert());
            Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
            return "redirect:/doUnlockKey/toUnlockKeyPage?" + "billId=" + billId + "&certSn=" + userCert.getCertSn() + "&keySn=" + userCert.getKeySn() + "&enterpriseName=" + enterprise.getEnterpriseName();
        } else {
            return "redirect:/billClient";
        }
    }
    // 获取产品对应的线上支付服务
    if (product.getOnpay() != null && product.getOnpay() != "") {
        List<Long> onlinepays = new ArrayList<Long>();
        String[] onpay = (product.getOnpay()).split(",");
        // 过滤掉不是服务型客户的在线支付
        onpay = onlinePayService.removeOnlinePayWithOutClientFw(onpay);
        Map<Integer, String> map = new HashMap<Integer, String>();
        for (int i = 0; i < onpay.length; i++) {
            OnlinePay op = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByPrimaryKey", onpay[i]);
            map.put(op.getSort(), onpay[i]);
        }
        Set<Integer> set = map.keySet();
        Object[] obj = set.toArray();
        Arrays.sort(obj);
        for (int i = (onpay.length - 1); i >= 0; i--) {
            String a = map.get(obj[i]);
            onlinepays.add(Long.parseLong(a));
        }
        Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
        uiModel.addAttribute("opMap", opMap);
        uiModel.addAttribute("onlinepays", onlinepays);
        Map<Long, PayConfig> pcMap = sqlSession.selectMap("com.itrus.portal.db.PayConfigMapper.selectByExample", "id");
        uiModel.addAttribute("pcMap", pcMap);
    }
    // 获取产品对应的银行汇款服务
    if (!StringUtils.isBlank(product.getPay())) {
        Transfer transfer = sqlSession.selectOne("com.itrus.portal.db.TransferMapper.selectByPrimaryKey", Long.parseLong(product.getPay()));
        uiModel.addAttribute("transfer", transfer);
    }
    if (null != product.getTransferNotes()) {
        product.setTransferNotes(product.getTransferNotes().replace("\r\n", "<br/><span ></span>"));
    }
    // 解锁订单,返回keysn,certsn,enterprisename
    if (null != product.getKeyUnlockType() && (StringUtils.isBlank(keySn) || StringUtils.isBlank(certSn) || StringUtils.isBlank(enterpriseName))) {
        Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
        enterpriseName = enterprise.getEnterpriseName();
        UserCert userCert = userCertService.selectByPrimaryKey(bill.getUnlockUserCert());
        if (null != userCert && StringUtils.isNotBlank(userCert.getKeySn())) {
            keySn = userCert.getKeySn();
        }
        if (null != userCert && StringUtils.isNotBlank(userCert.getCertSn())) {
            certSn = userCert.getCertSn();
        }
    }
    uiModel.addAttribute("product", product);
    uiModel.addAttribute("certSn", certSn);
    uiModel.addAttribute("keySn", keySn);
    uiModel.addAttribute("enterpriseName", enterpriseName);
    session.setAttribute("webbill", bill);
    if (null != product.getCert()) {
        // 产品关联的数字证书
        DigitalCert digitalCert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
        // 用于获取产品期限(数字证书的期限)
        uiModel.addAttribute("digitalCert", digitalCert);
    }
    return "clientFW/pay";
}
Also used : PayConfig(com.itrus.portal.db.PayConfig) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) ArrayList(java.util.ArrayList) Product(com.itrus.portal.db.Product) DigitalCert(com.itrus.portal.db.DigitalCert) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) Transfer(com.itrus.portal.db.Transfer) UserCert(com.itrus.portal.db.UserCert) OnlinePay(com.itrus.portal.db.OnlinePay) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 48 with Product

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

the class BankCertificationController method create.

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

Example 49 with Product

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

the class BankCertificationController method pbankrealtestsms.

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

Example 50 with Product

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

the class IdCertificationController method create.

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

Aggregations

Product (com.itrus.portal.db.Product)77 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)43 HashMap (java.util.HashMap)42 Bill (com.itrus.portal.db.Bill)39 Enterprise (com.itrus.portal.db.Enterprise)27 UserInfo (com.itrus.portal.db.UserInfo)27 DigitalCert (com.itrus.portal.db.DigitalCert)24 JSONObject (com.alibaba.fastjson.JSONObject)19 UserCert (com.itrus.portal.db.UserCert)19 ArrayList (java.util.ArrayList)19 IOException (java.io.IOException)18 Map (java.util.Map)17 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)17 ProductExample (com.itrus.portal.db.ProductExample)15 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)15 Date (java.util.Date)15 List (java.util.List)14 HttpSession (javax.servlet.http.HttpSession)14 BillExample (com.itrus.portal.db.BillExample)10 Project (com.itrus.portal.db.Project)10