Search in sources :

Example 6 with ExtraProduct

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

the class ClientWebController method choiceExtraProduct.

/**
 * 用户点击购要购买某个产品,返回这个产品对应的信息.购买信息.对应于:应用详情页面
 *
 * @param productId
 *            ,增值产品id
 * @param old_billId
 * @param request
 * @param uiModel
 * @return
 */
@RequestMapping("/choiceExtraProduct")
public String choiceExtraProduct(@RequestParam(value = "productId", required = true) Long productId, // enterpriseId,
@RequestParam(value = "old_billId", required = false) Long old_billId, 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) {
        return "";
    }
    ExtraProduct product = null;
    try {
        product = extraProductService.selectByPrimaryKey(productId);
        if (null == product) {
            uiModel.addAttribute("errorMsg", "产品不存在");
            return "client/errorpage";
        }
        uiModel.addAttribute("webExtraproduct", product);
        // 产品对应的服务商信息
        Long serviceProviderId = product.getServiceProvider();
        ServiceProvider serviceProvider = serviceProviderService.selectByPrimaryKey(serviceProviderId);
        uiModel.addAttribute("webServiceProvider", serviceProvider);
        // 服务商对应的网点信息
        List<ServiceHall> serviceHalls = new ArrayList<>();
        serviceHalls = serviceHallService.getServiceHalls(serviceProviderId);
        uiModel.addAttribute("webServiceHalls", serviceHalls);
        // 产品对应的规格信息
        List<ExtraProductSpec> extraProductSpecs = extraProductSpecService.getSpecByProductIdValid(product.getId());
        uiModel.addAttribute("extraProductSpecs", extraProductSpecs);
        Set<String> periodSet = new LinkedHashSet<>();
        Set<String> specSet = new LinkedHashSet<>();
        Map<String, Map<String, Object>> specPeriodMap = new HashMap<>();
        for (ExtraProductSpec eps : extraProductSpecs) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", eps.getId());
            map.put("price", eps.getPrice());
            specPeriodMap.put(eps.getSpec() + "||" + eps.getCycle1() + ";" + eps.getCycleUnit(), map);
            String spec = eps.getSpec();
            specSet.add(spec);
            periodSet.add(eps.getCycle1() + ";" + eps.getCycleUnit());
        }
        ObjectMapper objectMapper = new ObjectMapper();
        uiModel.addAttribute("specSet", specSet);
        uiModel.addAttribute("periodSet", periodSet);
        uiModel.addAttribute("specPeriodMapJson", objectMapper.writeValueAsString(specPeriodMap));
    } catch (Exception e) {
    // TODO: handle exception
    }
    // 仅用户授权产品.发票校验产品,直接跳转发票校验
    if (null != product.getProductOpenType() && product.getProductOpenType().equals(ComNames.PRODUCT_OPEN_TYPE_1)) {
        // 查询用户是否曾经买过了该产品对于的订单,如果买了,则提示只能购买一次
        List<ExtraBill> bills = extraBillService.getHasByExtraBill(userInfo.getId(), enterprise.getId(), productId);
        if (null != bills && bills.size() > 0) {
            uiModel.addAttribute("ifHasOpen", 1);
        }
        return "client/yingyongxiangqing_jyhsq";
    }
    return "client/yingyongxiangqing";
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) ExtraBill(com.itrus.portal.db.ExtraBill) ArrayList(java.util.ArrayList) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) UserInfo(com.itrus.portal.db.UserInfo) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) ExtraProduct(com.itrus.portal.db.ExtraProduct) ServiceProvider(com.itrus.portal.db.ServiceProvider) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) ServiceHall(com.itrus.portal.db.ServiceHall) Map(java.util.Map) HashMap(java.util.HashMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with ExtraProduct

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

the class AppClientController method loadImg.

/**
 * 根据主键id和类型返回相对应的图片信息
 * @param type 1 代表应用管理 2 代表增值应用
 * @param id
 * @param response
 * @return
 */
@RequestMapping(value = "/getImage/{id}/{type}")
public String loadImg(@PathVariable("type") Long type, @PathVariable("id") Long id, HttpServletResponse response, Model uiModel) {
    String img = null;
    Long n = 1l;
    OutputStream os = null;
    FileInputStream fis = null;
    try {
        if (n.equals(type)) {
            App app = sqlSession.selectOne("com.itrus.portal.db.AppMapper.selectByPrimaryKey", id);
            if (null == app) {
                return "status403";
            }
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expires", 0);
            img = app.getAppIcon();
            if (img == null) {
                return "status403";
            }
            File filePath = appService.getFilePathById(app.getId());
            if (!filePath.exists()) {
                filePath.mkdir();
            }
            File file = new File(filePath, img);
            fis = new FileInputStream(file);
        } else {
            ExtraProduct extraProduct = extraProductService.selectByPrimaryKey(id);
            if (null == extraProduct) {
                uiModel.addAttribute("errorMsg", "增值产品不存在");
                return ComNames.CLIENTFW_ERRORPAGE;
            }
            img = extraProduct.getAppLogo();
            if (img == null) {
                uiModel.addAttribute("errorMsg", "图片不存");
                return null;
            }
            File filePath = extraProductService.getFilePathById(id);
            if (!filePath.exists()) {
                filePath.mkdir();
            }
            File file = new File(filePath, img);
            fis = new FileInputStream(file);
        }
        byte[] bb = IOUtils.toByteArray(fis);
        os = response.getOutputStream();
        os.write(bb);
        os.flush();
    } catch (IOException e) {
        // 未找到
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        // 关闭流!
        try {
            if (null != fis) {
                fis.close();
            }
            if (null != os) {
                os.close();
            }
        } catch (IOException e) {
        }
    }
    return null;
}
Also used : App(com.itrus.portal.db.App) ExtraProduct(com.itrus.portal.db.ExtraProduct) OutputStream(java.io.OutputStream) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with ExtraProduct

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

the class ExtraBillWebController method showDetail.

/**
 * 增值订单详细接口
 *
 * @param id
 * @param processProgress 服务提供商
 *     1默认进度,2为内嵌页面
 * @param uiModel
 * @param request
 * @return
 */
@RequestMapping(value = "/bill/{id}.html", produces = "text/html")
public String showDetail(@PathVariable("id") Long id, @RequestParam(value = "processProgress", required = false) Long processProgress, Model uiModel, HttpServletRequest request) {
    HttpSession session = request.getSession();
    Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
    UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
    ExtraBill bill = extraBillService.selectByPrimaryKey(id);
    if (null == bill) {
        uiModel.addAttribute("errorMsg", "订单不存在");
        return "client/errorpage";
    }
    uiModel.addAttribute("bill", bill);
    if (!bill.getUniqueId().equals(userInfo.getId())) {
        uiModel.addAttribute("errorMsg", "您无权操作该订单");
        return "client/errorpage";
    }
    // 订单对应的产品信息
    ExtraProduct product = extraProductService.selectByPrimaryKey(bill.getExtraProduct());
    uiModel.addAttribute("product", product);
    // 订单对应的规格信息
    ExtraProductSpec productSpec = extraProductSpecService.selectByPrimaryKey(bill.getExtraProductSpec());
    uiModel.addAttribute("productSpec", productSpec);
    // 银行卡支付记录信息
    PayInfoExample payInfoex = new PayInfoExample();
    Map<Long, PayInfo> payinfoMap = sqlSession.selectMap("com.itrus.portal.db.PayInfoMapper.selectByExample", payInfoex, "id");
    uiModel.addAttribute("payinfomap", payinfoMap);
    // 获取订单在线支付方式
    if (null != bill.getOnPayInfo()) {
        // 第三方在线支付记录信息
        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);
    }
    // 电子发票信息
    if (null != bill.geteInvoice()) {
        Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
        uiModel.addAttribute("einvoice", einvoice);
    }
    // 纸票模版
    Map<Long, Receipt> receiptmap = sqlSession.selectMap("com.itrus.portal.db.ReceiptMapper.selectByExample", null, "id");
    uiModel.addAttribute("receiptmap", receiptmap);
    // 电票开票模版
    Map<Long, Ereceipt> ereceiptmap = sqlSession.selectMap("com.itrus.portal.db.EreceiptMapper.selectByExample", null, "id");
    uiModel.addAttribute("ereceiptmap", ereceiptmap);
    // 企业
    Enterprise billEnterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    if (StringUtils.isNotBlank(billEnterprise.getProvince())) {
        String province = sysRegionService.getProvince(billEnterprise.getProvince());
        billEnterprise.setProvince(province);
    }
    if (StringUtils.isNotBlank(billEnterprise.getCity())) {
        String city = sysRegionService.getCity(billEnterprise.getCity());
        billEnterprise.setCity(city);
    }
    uiModel.addAttribute("enterprise", billEnterprise);
    // 开户行信息
    OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
    uiModel.addAttribute("openBankInfo", openBankInfo);
    // 根据订单所处状态,返回不同的页面,或者先统一用一个页面.
    if (processProgress != null && processProgress.intValue() == 2) {
        return "client/banlijindu_neiqian";
    }
    return "client/banlijindu_moren";
}
Also used : Ereceipt(com.itrus.portal.db.Ereceipt) PayInfoExample(com.itrus.portal.db.PayInfoExample) Receipt(com.itrus.portal.db.Receipt) HttpSession(javax.servlet.http.HttpSession) ExtraBill(com.itrus.portal.db.ExtraBill) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) UserInfo(com.itrus.portal.db.UserInfo) Einvoice(com.itrus.portal.db.Einvoice) ExtraProduct(com.itrus.portal.db.ExtraProduct) OnPayInfo(com.itrus.portal.db.OnPayInfo) PayInfo(com.itrus.portal.db.PayInfo) OnPayInfo(com.itrus.portal.db.OnPayInfo) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) Enterprise(com.itrus.portal.db.Enterprise) OnlinePay(com.itrus.portal.db.OnlinePay) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with ExtraProduct

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

the class ExtraProductController method show.

// 显示详情页面
@RequestMapping(value = "/show/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) throws Exception {
    ExtraProduct extraProduct = extraProductService.selectByPrimaryKey(id);
    uiModel.addAttribute("extraProduct", extraProduct);
    List<ExtraProductSpec> extraProductSpecs = extraProductSpecService.getSpecByProductId(id);
    uiModel.addAttribute("extraProductSpecs", extraProductSpecs);
    // 服务提供商组成的map
    Map<Long, ServiceProvider> serviceProviderMap = serviceProviderService.selectMapByExample(null);
    uiModel.addAttribute("serviceProviderMap", serviceProviderMap);
    // 在线支付的map:微信和支付宝
    List<OnlinePay> onlinepays = sqlSession.selectList("com.itrus.portal.db.OnlinePayMapper.selectByExample", null);
    uiModel.addAttribute("onlinepays", onlinepays);
    // 银行付款的List
    List<Transfer> bankPays = sqlSession.selectList("com.itrus.portal.db.TransferMapper.selectByExample", null);
    uiModel.addAttribute("bankPays", bankPays);
    // 电子发票的list
    List<Ereceipt> einvoices = sqlSession.selectList("com.itrus.portal.db.EreceiptMapper.selectByExample", null);
    uiModel.addAttribute("einvoices", einvoices);
    // 附加项的list
    List<ExtraMessage> extraMessages = extraMessageService.selectByExample(null);
    uiModel.addAttribute("extraMessages", extraMessages);
    return "extraproduct/show";
}
Also used : Ereceipt(com.itrus.portal.db.Ereceipt) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) ExtraProduct(com.itrus.portal.db.ExtraProduct) ServiceProvider(com.itrus.portal.db.ServiceProvider) Transfer(com.itrus.portal.db.Transfer) ExtraMessage(com.itrus.portal.db.ExtraMessage) OnlinePay(com.itrus.portal.db.OnlinePay) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with ExtraProduct

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

the class ExtraProductController method update.

// 修改基础信息和产品规格信息
@RequestMapping(value = "/update", method = RequestMethod.POST, produces = "text/html")
public String update(@Valid ExtraProduct extraProduct, Model uiModel, @RequestParam(value = "extraProductSpecs") String extraProductSpecs, // 应用的LOGO图片
@RequestParam(value = "appLogoFile", required = false) MultipartFile appLogoFile, // 应用的附加协议
@RequestParam(value = "extraProtocolFile", required = false) MultipartFile extraProtocolFile, // 应用的介绍图片
@RequestParam(value = "appDescFile", required = false) MultipartFile appDescFile, // 操作指南,指向pdf存储的地址
@RequestParam(value = "instructionsFile", required = true) MultipartFile instructionsFile, BindingResult bindingResult) throws Exception {
    if (bindingResult.hasErrors()) {
        uiModel.addAttribute("extraProduct", extraProduct);
        uiModel.addAttribute("extraProductSpecs", extraProductSpecs);
        return "extraproduct/create";
    }
    // if (null == extraProtocolFile || extraProtocolFile.isEmpty()
    // || null == appLogoFile || appLogoFile.isEmpty()
    // || null == appDescFile || appDescFile.isEmpty()) {
    // return "status403";
    // }
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    ExtraProduct ep = extraProductService.selectByPrimaryKey(extraProduct.getId());
    ep.setAppName(extraProduct.getAppName());
    ep.setServiceProvider(extraProduct.getServiceProvider());
    ep.setAppType(extraProduct.getAppType());
    ep.setIsOpen(extraProduct.getIsOpen());
    ep.setAppSketch(extraProduct.getAppSketch());
    ep.setProductOpenType(extraProduct.getProductOpenType());
    try {
        if (null != appLogoFile && !appLogoFile.isEmpty()) {
            File logoFile = extraProductService.saveFile(appLogoFile, 0L, extraProduct.getId(), ITEM_TYPE_LOGO, FILE_TYPE_JPG);
            ep.setAppLogo(logoFile.getName());
        }
        if (null != extraProtocolFile && !extraProtocolFile.isEmpty()) {
            File protocolFile = extraProductService.saveFile(extraProtocolFile, 1L, extraProduct.getId(), ITEM_TYPE_PRO, FILE_TYPE_PDF);
            ep.setExtraProtocol(protocolFile.getName());
        }
        if (null != appDescFile && !appDescFile.isEmpty()) {
            File descFile = extraProductService.saveFile(appDescFile, 2L, extraProduct.getId(), ITEM_TYPE_DESC, FILE_TYPE_JPG);
            ep.setAppDesc(descFile.getName());
        }
        if (null != instructionsFile && !instructionsFile.isEmpty()) {
            File instructionsF = extraProductService.saveFile(instructionsFile, 3L, extraProduct.getId(), ITEM_TYPE_INS, FILE_TYPE_PDF);
            ep.setInstructions(instructionsF.getName());
        }
        extraProductService.updateByPrimaryKey(ep);
        extraProductSpecService.saveByJsons(extraProductSpecs, ep.getId());
        LogUtil.adminlog(sqlSession, "修改增值产品", "增值产品名称:" + extraProduct.getAppName());
        transactionManager.commit(status);
    } catch (Exception e) {
        // TODO: handle exception
        transactionManager.rollback(status);
    }
    return "redirect:/extraproduct/show/" + extraProduct.getId();
}
Also used : ExtraProduct(com.itrus.portal.db.ExtraProduct) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) TransactionStatus(org.springframework.transaction.TransactionStatus) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) IOException(java.io.IOException) 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