Search in sources :

Example 1 with ExtraProductRelease

use of com.itrus.portal.db.ExtraProductRelease 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)

Example 2 with ExtraProductRelease

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

the class ClientWebController method getProductInfoFromClient.

/**
 * 接收新服务型客户端传递的项目信息,用户信息,企业信息
 * @param type,类型.web.app,客户端,目前是客户端,跟发布平台的值相同:{1:"web", 2:"客户端", 3:"app"}
 * @param keySn
 * @param certSn
 * @param enterpriseName
 * @param session
 * @param uiModel
 * @return
 */
@RequestMapping("/getProductInfoFromClient")
public String getProductInfoFromClient(@RequestParam(value = "type", required = true) String type, @RequestParam(value = "keySn", required = false) String keySn, @RequestParam(value = "certSn", required = false) String certSn, @RequestParam(value = "enterpriseName", required = false) String enterpriseName, HttpSession session, Model uiModel) {
    try {
        UserInfo userInfo = (UserInfo) session.getAttribute(ComNames.WEB_USER_INFO);
        Enterprise enterprise = (Enterprise) session.getAttribute(ComNames.WEB_ENTERPRISE);
        if (null == userInfo || null == enterprise) {
            return ComNames.DENG_LU_CLIENT;
        }
        UserCert userCert = null;
        if (StringUtils.isNotBlank(certSn)) {
            userCert = userCertService.getUserCertByCertSn(certSn);
        } else if (null != session.getAttribute(ComNames.WEB_USER_CERT_SN)) {
            String certSnInSession = (String) session.getAttribute(ComNames.WEB_USER_CERT_SN);
            userCert = userCertService.getUserCertByCertSn(certSnInSession);
        }
        if (null != userCert) {
            uiModel.addAttribute("userCert", userCert);
        }
        Project project = null;
        if (StringUtils.isNotBlank(keySn)) {
            ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
            project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
        } else {
            project = projectService.selectByPrimaryKey(userInfo.getProject());
        }
        if (null == project) {
            uiModel.addAttribute("errorMsg", "无法识别当前登录用户所属的项目,请重新登录!");
            return "client/errorpage";
        }
        // 返回增值产品信息
        List<ExtraProductRelease> extraProductReleases = extraProductReleaseService.getByprojectAndType(project.getId(), type);
        // 获取项目下所有的发布产品
        List<ExtraProduct> extraProducts = extraProductService.getproductByEPR(extraProductReleases);
        uiModel.addAttribute("webExtraProducts", extraProducts);
        // 增值产品的类型
        Set<Object> productTypeSet = new LinkedHashSet<>();
        for (ExtraProduct ep : extraProducts) {
            productTypeSet.add(ep.getAppType());
        }
        uiModel.addAttribute("webProductTypes", productTypeSet);
        session.setAttribute("isregister", 1);
    } catch (Exception e) {
        uiModel.addAttribute("errorMsg", "出现异常,异常信息:" + e.getMessage());
        return "client/errorpage";
    }
    return "client/yingyongzhanshi";
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) UserInfo(com.itrus.portal.db.UserInfo) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ExtraProductRelease

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

the class ExtraProductReleaseController method updatePage.

// 修改页面
@RequestMapping(value = "/update/{id}", produces = "text/html")
public String updatePage(@PathVariable("id") Long id, Model uiModel) throws Exception {
    Project project = projectService.selectByPrimaryKey(id);
    List<ExtraProductRelease> extraProductReleases = extraProductReleaseService.getByprojectId(id);
    // 所有的增值产品信息,以id为主键.以便页面显示信息
    Map<Long, ExtraProduct> extraProductMap = new HashMap<Long, ExtraProduct>();
    extraProductMap = extraProductService.selectMapByExample(null);
    List<ExtraProduct> allProducts = extraProductService.selectByExample(null);
    // 所有产品list
    uiModel.addAttribute("allProducts", allProducts);
    // 项目信息
    uiModel.addAttribute("project", project);
    // 产品与项目之间的关系
    uiModel.addAttribute("extraProductReleases", extraProductReleases);
    // 所有的产品
    uiModel.addAttribute("extraProductMap", extraProductMap);
    // 显示新建的增值产品,还未与项目产生关联
    ExtraProductExample epe = new ExtraProductExample();
    ExtraProductExample.Criteria epec = epe.createCriteria();
    List<Long> havedProductIds = new ArrayList<>();
    for (ExtraProductRelease epr : extraProductReleases) {
        havedProductIds.add(epr.getExtraProduct());
    }
    if (havedProductIds != null && havedProductIds.size() > 0) {
        epec.andIdNotIn(havedProductIds);
    }
    epe.setOrderByClause("id asc");
    // 没有与该项目产生关联关系的增值产品
    List<ExtraProduct> remainingProducts = extraProductService.selectByExample(epe);
    uiModel.addAttribute("remainingProducts", remainingProducts);
    return "extraproductrelease/update";
}
Also used : Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExtraProductExample(com.itrus.portal.db.ExtraProductExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with ExtraProductRelease

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

the class ExtraProductReleaseController method createForm.

// 新增页面
@RequestMapping(params = "form", produces = "text/html")
public String createForm(Model uimModel) throws Exception {
    List<Project> projects = new ArrayList<>();
    projects = projectService.getProjectByExample(null);
    // 移除已经有了关联关系的项目
    Iterator<Project> iterator = projects.iterator();
    while (iterator.hasNext()) {
        Project project = iterator.next();
        List<ExtraProductRelease> extraProductReleases = new ArrayList<>();
        extraProductReleases = extraProductReleaseService.getByprojectId(project.getId());
        if (null != extraProductReleases && !extraProductReleases.isEmpty()) {
            iterator.remove();
        }
    }
    uimModel.addAttribute("projects", projects);
    // 所有的增值产品信息,以id为主键.以便页面显示信息
    Map<Long, ExtraProduct> extraProductMap = new HashMap<Long, ExtraProduct>();
    extraProductMap = extraProductService.selectMapByExample(null);
    // 所有的产品
    uimModel.addAttribute("extraProductMap", extraProductMap);
    return "extraproductrelease/create";
}
Also used : Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with ExtraProductRelease

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

the class ExtraProductReleaseServiceImpl method selectByPrimaryKey.

public ExtraProductRelease selectByPrimaryKey(Long id) {
    ExtraProductReleaseMapper mapper = sqlSession.getMapper(ExtraProductReleaseMapper.class);
    ExtraProductRelease extraProductRelease = mapper.selectByPrimaryKey(id);
    return extraProductRelease;
}
Also used : ExtraProductReleaseMapper(com.itrus.portal.db.ExtraProductReleaseMapper) ExtraProductRelease(com.itrus.portal.db.ExtraProductRelease)

Aggregations

ExtraProductRelease (com.itrus.portal.db.ExtraProductRelease)14 ArrayList (java.util.ArrayList)9 ExtraProduct (com.itrus.portal.db.ExtraProduct)8 Project (com.itrus.portal.db.Project)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ExtraProductReleaseExample (com.itrus.portal.db.ExtraProductReleaseExample)5 HashMap (java.util.HashMap)5 Enterprise (com.itrus.portal.db.Enterprise)2 ExtraProductExample (com.itrus.portal.db.ExtraProductExample)2 ExtraProductReleaseMapper (com.itrus.portal.db.ExtraProductReleaseMapper)2 UserInfo (com.itrus.portal.db.UserInfo)2 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)2 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)2 IOException (java.io.IOException)2 Date (java.util.Date)2 LinkedHashSet (java.util.LinkedHashSet)2 App (com.itrus.portal.db.App)1 AppExample (com.itrus.portal.db.AppExample)1 BusinessLicense (com.itrus.portal.db.BusinessLicense)1 Criteria (com.itrus.portal.db.ExtraProductReleaseExample.Criteria)1