Search in sources :

Example 36 with ExtraProduct

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

the class ClientWebController method loadInstrustionsPdf.

/**
 * 根据产品id,返回产品操作指南的pdf文件
 *
 * @param id
 * @param session
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
@RequestMapping("/loadInstrustionsPdf/{id}")
public String loadInstrustionsPdf(@PathVariable("id") Long id, HttpSession session, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ExtraProduct extraProduct = extraProductService.selectByPrimaryKey(id);
    if (null == extraProduct) {
        return "status403";
    }
    String pdf = extraProduct.getInstructions();
    if (null == pdf) {
        return "status403";
    }
    File filePath = extraProductService.getFilePathById(id);
    if (!filePath.exists()) {
        filePath.mkdir();
    }
    File file = new File(filePath, pdf);
    InputStream proxyIn = null;
    // 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
    try {
        proxyIn = new FileInputStream(file);
        response.reset();
        // String filename = "操作指南.pdf";
        String filename = "百望开票软件帮助手册.pdf";
        filename = encodeFilename(filename, request);
        // 设置输出文件为
        response.setHeader("Content-disposition", "attachment; filename=" + filename);
        response.setCharacterEncoding("utf-8");
        // 由于导出格式是excel的文件,设置导出文件的响应头部信息
        response.setContentType("application/pdf");
        // 用response对象获取输出流
        OutputStream os = response.getOutputStream();
        byte[] bos = new byte[proxyIn.available()];
        proxyIn.read(bos);
        os.write(bos);
        os.flush();
        // 关闭os
        if (os != null) {
            os.close();
        }
        if (null != proxyIn) {
            proxyIn.close();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : ExtraProduct(com.itrus.portal.db.ExtraProduct) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 37 with ExtraProduct

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

the class ClientWebController method zhifuPage.

/**
 * 进入增值订单支付页面,若未配置支付且订单价格为0,则不需要支付
 *
 * @param billId
 *            ,增值订单id
 * @param request
 * @param uiModel
 * @return
 */
@RequestMapping("/zhifu/{billId}")
public String zhifuPage(@PathVariable("billId") Long billId, HttpServletRequest request, Model uiModel) {
    HttpSession session = request.getSession();
    String ip = request.getRemoteAddr();
    UserInfo currentUserInfo = (UserInfo) session.getAttribute("webuserInfo");
    uiModel.addAttribute("ip", ip);
    // 增值订单
    ExtraBill bill = extraBillService.selectByPrimaryKey(billId);
    if (null == bill || !currentUserInfo.getId().equals(bill.getUniqueId())) {
        return "resourceNotFound";
    }
    // 增值产品
    ExtraProduct product = extraProductService.selectByPrimaryKey(bill.getExtraProduct());
    if (null == product) {
        // 产品不存在
        uiModel.addAttribute("errorMsg", "您购买的产品不存在");
        return "client/errorpage";
    }
    // 未配置支付方式,或者订单价格为0,则不用支付
    if (StringUtils.isBlank(product.getBankPay()) && StringUtils.isBlank(product.getOnlinePay()) && (null == bill.getBillSum() || bill.getBillSum().equals(0))) {
        // 跳转到订单支付成功页面,并将订单状态设置为3已支付 待审核
        bill.setBillStatus(ComNames.EXTRA_BILL_STATUS_3);
        // TODO 跳转到支付成功或者订单列表页面
        return "client/zhifuchenggong";
    }
    // 获取产品对应的线上支付服务
    if (product.getOnlinePay() != null && product.getOnlinePay() != "") {
        List<Long> onlinepays = new ArrayList<Long>();
        String[] onpay = (product.getOnlinePay()).split(",");
        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.getBankPay())) {
        Transfer transfer = sqlSession.selectOne("com.itrus.portal.db.TransferMapper.selectByPrimaryKey", Long.parseLong(product.getBankPay()));
        uiModel.addAttribute("transfer", transfer);
    }
    if (null != product.getBankRemarks()) {
        product.setBankRemarks(product.getBankRemarks().replace("\r\n", "<br/><span ></span>"));
    }
    uiModel.addAttribute("product", product);
    session.setAttribute("webbill", bill);
    if (null != bill.getExtraProductSpec()) {
        uiModel.addAttribute("productSpec", extraProductSpecService.selectByPrimaryKey(bill.getExtraProductSpec()));
    }
    if (currentUserInfo != null) {
        currentUserInfo = userInfoService.getUserInfoById(currentUserInfo.getId());
        EnterpriseQqExample enterpriseE = new EnterpriseQqExample();
        EnterpriseQqExample.Criteria qqEx = enterpriseE.createCriteria();
        qqEx.andProjectIdEqualTo(currentUserInfo.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());
        }
    }
    // TODO 跳转到支付页面
    return "client/zhifu";
}
Also used : PayConfig(com.itrus.portal.db.PayConfig) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) ExtraBill(com.itrus.portal.db.ExtraBill) ArrayList(java.util.ArrayList) UserInfo(com.itrus.portal.db.UserInfo) ExtraProduct(com.itrus.portal.db.ExtraProduct) EnterpriseQq(com.itrus.portal.db.EnterpriseQq) Transfer(com.itrus.portal.db.Transfer) EnterpriseQqExample(com.itrus.portal.db.EnterpriseQqExample) OnlinePay(com.itrus.portal.db.OnlinePay) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 38 with ExtraProduct

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

the class ClientWebController method submitOrderJYHSQ.

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

Example 39 with ExtraProduct

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

the class ClientWebController method checkInvoce.

/**
 * retCode:0为失败,1为成功
 * 发票校验接口
 * @param FP_DM:发票代码
 * @param FP_HM:发票号码
 * @param JYM:发票校验码
 */
@RequestMapping("/fpjy")
@ResponseBody
public Map<String, Object> checkInvoce(@RequestParam(value = "FP_DM", required = true) String FP_DM, @RequestParam(value = "FP_HM", required = true) String FP_HM, @RequestParam(value = "JYM", required = true) String JYM, @RequestParam(value = "productId", required = true) Long productId, HttpServletRequest request) {
    HttpSession session = request.getSession();
    Map<String, Object> retMap = new HashMap<>();
    retMap.put("retCode", 0);
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        retMap.put("retMsg", "用户登录信息已失效,请重新登录");
        return retMap;
    }
    // 
    Project project = (Project) session.getAttribute("webproject");
    if (null == project) {
        retMap.put("retMsg", "项目信息不存在");
        return retMap;
    }
    // 获取发票校验的应用
    ExtraProduct product = extraProductService.selectByPrimaryKey(productId);
    if (null == product) {
        retMap.put("retMsg", "产品信息不存在");
        return retMap;
    }
    if (StringUtils.isBlank(FP_DM) || StringUtils.isBlank(FP_HM) || StringUtils.isBlank(JYM)) {
        retMap.put("retMsg", "发票代码,发票号码,发票校验码三者都不能为空");
        return retMap;
    }
    Map<String, String> invoiceMap = baiWangService.verifyInvoice(FP_DM, FP_HM, JYM);
    retMap.putAll(invoiceMap);
    if (null != retMap.get("REPLYCODE") && retMap.get("REPLYCODE").equals("0000")) {
        retMap.put("retCode", 1);
        String info = invoiceMap.toString().replaceAll(" ", "");
        checkInvoiceLogService.insertCheckInvoiceLog(product.getAppName(), webenterprise.getEnterpriseName(), info, project.getId(), webuserInfo.getRealName());
        return retMap;
    } else {
        String REPLYMSG = (String) retMap.get("REPLYMSG");
        retMap.put("retMsg", REPLYMSG);
        return retMap;
    }
}
Also used : Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) UserInfo(com.itrus.portal.db.UserInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 40 with ExtraProduct

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

the class ExtraBillWebController method billList.

/**
 * 订单列表
 *
 * @param billStatus
 *            0未完成订单,1已完成订单
 * @param request
 * @param uiModel
 * @return
 * @throws Exception
 */
@RequestMapping(produces = "text/html")
public String billList(@RequestParam(value = "billStatus", required = false) Integer billStatus, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, HttpServletRequest request, Model uiModel) throws Exception {
    HttpSession session = request.getSession();
    Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
    UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
    if (userInfo != null && enterprise == null) {
        // 登录未获取到企业信息,跳转到选择企业页面
        return "redirect:/userInfoWeb/choiceEnterprise";
    }
    uiModel.addAttribute("billStatus", billStatus);
    if (page == null || page < 1) {
        page = 1;
    }
    if (size == null || size < 1) {
        size = 5;
    }
    // 获取仅用户授权产品,不返回该类型产品的订单
    List<Long> productOpenTypes = extraProductService.getProductOpenType(ComNames.PRODUCT_OPEN_TYPE_1);
    ExtraBillExample billExampl0 = new ExtraBillExample();
    ExtraBillExample.Criteria criteria0 = billExampl0.or();
    // 查询当前用户当前企业的订单
    // 当前用户
    criteria0.andUniqueIdEqualTo(userInfo.getId());
    // 当前企业
    criteria0.andEnterpriseEqualTo(enterprise.getId());
    criteria0.andIsDeleteNotEqualTo(true);
    ExtraBillExample billExampl1 = new ExtraBillExample();
    ExtraBillExample.Criteria criteria1 = billExampl1.or();
    // 查询当前用户当前企业的订单
    // 当前用户
    criteria1.andUniqueIdEqualTo(userInfo.getId());
    // 当前企业
    criteria1.andEnterpriseEqualTo(enterprise.getId());
    criteria1.andIsDeleteNotEqualTo(true);
    if (null != productOpenTypes && !productOpenTypes.isEmpty()) {
        criteria0.andExtraProductNotIn(productOpenTypes);
        criteria1.andExtraProductNotIn(productOpenTypes);
    }
    // if (null == billStatus || 0 == billStatus) {
    // // 未完成订单:订单状态不为7
    // criteria.andBillStatusNotEqualTo(ComNames.EXTRA_BILL_STATUS_7);
    // criteria.andIsDeleteEqualTo(false);
    // } else if (1 == billStatus) {
    // criteria.andBillStatusEqualTo(ComNames.EXTRA_BILL_STATUS_7);// 订单状态为已完成
    // }
    // 未完成订单:订单状态不为7
    criteria0.andBillStatusNotEqualTo(ComNames.EXTRA_BILL_STATUS_7);
    criteria0.andIsDeleteEqualTo(false);
    // 订单状态为已完成
    criteria1.andBillStatusEqualTo(ComNames.EXTRA_BILL_STATUS_7);
    // Integer count = extraBillService.countByExample(billExampl);
    // if (page > 1 && size * (page - 1) >= count) {
    // page = (count + size - 1) / size;
    // }
    // uiModel.addAttribute("count", count);
    // uiModel.addAttribute("pages", (count + size - 1) / size);
    // uiModel.addAttribute("page", page);
    // uiModel.addAttribute("size", size);
    // Integer offset = size * (page - 1);
    // 
    // billExampl.setOffset(offset);
    // billExampl.setLimit(size);
    billExampl0.setOrderByClause("create_time desc");
    List<ExtraBill> billList0 = extraBillService.selectByExample(billExampl0);
    uiModel.addAttribute("billList0", billList0);
    // uiModel.addAttribute("itemcount", billList.size());
    // 获取订单对应的产品规格
    Map<Long, ExtraProductSpec> productSpecMap0 = extraProductSpecService.getProductSpec(billList0);
    uiModel.addAttribute("productSpecMap0", productSpecMap0);
    List<ExtraBill> billList1 = extraBillService.selectByExample(billExampl1);
    uiModel.addAttribute("billList1", billList1);
    // uiModel.addAttribute("itemcount", billList.size());
    // 获取订单对应的产品规格
    Map<Long, ExtraProductSpec> productSpecMap1 = extraProductSpecService.getProductSpec(billList1);
    uiModel.addAttribute("productSpecMap1", productSpecMap1);
    // 增值产品信息:
    Map<Long, ExtraProduct> productMap = sqlSession.selectMap("com.itrus.portal.db.ExtraProductMapper.selectByExample", "id");
    uiModel.addAttribute("productMap", productMap);
    // 返回订单列表
    return "client/dingdanliebiao";
}
Also used : HttpSession(javax.servlet.http.HttpSession) ExtraBill(com.itrus.portal.db.ExtraBill) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) UserInfo(com.itrus.portal.db.UserInfo) ExtraBillExample(com.itrus.portal.db.ExtraBillExample) ExtraProduct(com.itrus.portal.db.ExtraProduct) Enterprise(com.itrus.portal.db.Enterprise) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ExtraProduct (com.itrus.portal.db.ExtraProduct)62 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)44 HashMap (java.util.HashMap)28 ExtraBill (com.itrus.portal.db.ExtraBill)25 Enterprise (com.itrus.portal.db.Enterprise)24 UserInfo (com.itrus.portal.db.UserInfo)24 IOException (java.io.IOException)20 Project (com.itrus.portal.db.Project)17 ArrayList (java.util.ArrayList)16 ExtraProductSpec (com.itrus.portal.db.ExtraProductSpec)14 HttpSession (javax.servlet.http.HttpSession)14 File (java.io.File)13 BusinessLicense (com.itrus.portal.db.BusinessLicense)12 OpenBankInfo (com.itrus.portal.db.OpenBankInfo)12 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)12 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)12 IdentityCard (com.itrus.portal.db.IdentityCard)11 ServiceProvider (com.itrus.portal.db.ServiceProvider)11 OrgCode (com.itrus.portal.db.OrgCode)10 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)10