Search in sources :

Example 1 with ServiceHall

use of com.itrus.portal.db.ServiceHall 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 2 with ServiceHall

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

the class ServiceHallServiceImpl method selectByExample.

public List<ServiceHall> selectByExample(ServiceHallExample example) throws Exception {
    ServiceHallMapper mapper = sqlSession.getMapper(ServiceHallMapper.class);
    List<ServiceHall> list = mapper.selectByExample(example);
    return list;
}
Also used : ServiceHall(com.itrus.portal.db.ServiceHall) ServiceHallMapper(com.itrus.portal.db.ServiceHallMapper)

Example 3 with ServiceHall

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

the class ServiceProviderController method show.

// 显示详情页面
@RequestMapping(value = "/show/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) throws Exception {
    ServiceProvider serviceProvider = ServiceProviderService.selectByPrimaryKey(id);
    uiModel.addAttribute("serviceProvider", serviceProvider);
    List<ServiceHall> serviceHalls = serviceHallService.getServiceHalls(serviceProvider.getId());
    uiModel.addAttribute("serviceHalls", serviceHalls);
    List<ExtraProduct> products = extraProductService.getProductsByServiceProviderId(serviceProvider.getId());
    uiModel.addAttribute("products", products);
    return "serviceprovider/show";
}
Also used : ExtraProduct(com.itrus.portal.db.ExtraProduct) ServiceProvider(com.itrus.portal.db.ServiceProvider) ServiceHall(com.itrus.portal.db.ServiceHall) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with ServiceHall

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

the class ServiceProviderController method update.

// 修改页面
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String update(@PathVariable("id") Long id, Model uiModel) throws Exception {
    ServiceProvider serviceProvider = ServiceProviderService.selectByPrimaryKey(id);
    uiModel.addAttribute("serviceProvider", serviceProvider);
    List<ServiceHall> serviceHalls = serviceHallService.getServiceHalls(serviceProvider.getId());
    uiModel.addAttribute("serviceHalls", serviceHalls);
    return "serviceprovider/update";
}
Also used : ServiceProvider(com.itrus.portal.db.ServiceProvider) ServiceHall(com.itrus.portal.db.ServiceHall) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with ServiceHall

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

the class ServiceProviderController method delete.

// 删除服务商
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
@ResponseBody
public String delete(@PathVariable("id") Long id) {
    ServiceProvider serviceProvider = ServiceProviderService.selectByPrimaryKey(id);
    if (null == serviceProvider) {
        return "未找到要删除的服务商";
    } else {
        try {
            ServiceProviderService.deleteByPrimaryKey(id);
            List<ServiceHall> serviceHalls = serviceHallService.getServiceHalls(id);
            if (null != serviceHalls && !serviceHalls.isEmpty()) {
                List<Long> list = new ArrayList<>();
                for (ServiceHall serviceHall : serviceHalls) {
                    list.add(serviceHall.getId());
                }
                ServiceHallExample example = new ServiceHallExample();
                ServiceHallExample.Criteria criteria = example.or();
                criteria.andServiceProviderIn(list);
                serviceHallService.deleteByExample(example);
            }
        } catch (Exception e) {
            return "要删除的服务商:" + serviceProvider.getName() + "存在关联,无法删除";
        }
    }
    return null;
}
Also used : ServiceProvider(com.itrus.portal.db.ServiceProvider) ArrayList(java.util.ArrayList) ServiceHall(com.itrus.portal.db.ServiceHall) ServiceHallExample(com.itrus.portal.db.ServiceHallExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ServiceHall (com.itrus.portal.db.ServiceHall)8 ServiceProvider (com.itrus.portal.db.ServiceProvider)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ArrayList (java.util.ArrayList)3 ExtraProduct (com.itrus.portal.db.ExtraProduct)2 ServiceHallExample (com.itrus.portal.db.ServiceHallExample)2 ServiceHallMapper (com.itrus.portal.db.ServiceHallMapper)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Enterprise (com.itrus.portal.db.Enterprise)1 ExtraBill (com.itrus.portal.db.ExtraBill)1 ExtraProductSpec (com.itrus.portal.db.ExtraProductSpec)1 UserInfo (com.itrus.portal.db.UserInfo)1 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)1 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)1 IOException (java.io.IOException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 HttpSession (javax.servlet.http.HttpSession)1