Search in sources :

Example 6 with MobileAppserviceName

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

the class MobileAppserviceChargingController method update.

// 返回修改页面
@RequestMapping(value = "/update/{id}")
public String update(@PathVariable("id") Long id, Model uiModel, HttpServletRequest request) {
    ApplicationInfo applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByPrimaryKey", id);
    uiModel.addAttribute("applicationInfo", applicationInfo);
    List<MobileAppserviceCharging> appserviceChargings = new ArrayList<MobileAppserviceCharging>();
    appserviceChargings = appserviceChargingService.selectList(id);
    AppserviceChargingWrap appserviceChargingWrap = new AppserviceChargingWrap();
    List<AppserviceChargingList> appserviceChargingLists = new ArrayList<AppserviceChargingList>();
    for (int i = 0; i < appserviceChargings.size(); i++) {
        AppserviceChargingList appserviceChargingList = new AppserviceChargingList();
        List<MobileAppserviceName> appserviceNames = new ArrayList<MobileAppserviceName>();
        appserviceNames = appserviceNameService.selectListByAppserviceCharging(appserviceChargings.get(i));
        List<AppserviceNameList> appserviceNameLists = new ArrayList<AppserviceNameList>();
        for (int j = 0; j < appserviceNames.size(); j++) {
            List<MobileChargingPrice> chargingPrices = chargingPriceService.selectListByOneAppserviceName(appserviceNames.get(j));
            AppserviceNameList appserviceNameList = new AppserviceNameList();
            ChargingPriceList chargingPriceList = new ChargingPriceList();
            // 1
            chargingPriceList.setChargingPriceLists(chargingPrices);
            // 2
            appserviceNameList.setAppserviceName(appserviceNames.get(j));
            appserviceNameList.setChargingPriceList(chargingPriceList);
            appserviceNameLists.add(appserviceNameList);
        }
        appserviceChargingList.setAppserviceCharging(appserviceChargings.get(i));
        appserviceChargingList.setAppserviceNameLists(appserviceNameLists);
        appserviceChargingLists.add(appserviceChargingList);
    }
    appserviceChargingWrap.setAppserviceChargingLists(appserviceChargingLists);
    uiModel.addAttribute("acw", appserviceChargingWrap);
    // Map<Long, AppService> appServiceMap = sqlSession.selectMap(
    // "com.itrus.portal.db.AppServiceMapper.selectByExample", null,
    // "id");
    // uiModel.addAttribute("appServiceMap", appServiceMap);
    returnParam(request, uiModel);
    return "appservicecharging/update";
}
Also used : MobileAppserviceCharging(com.itrus.portal.db.MobileAppserviceCharging) AppserviceNameList(com.itrus.portal.mobile.entity.AppserviceNameList) MobileChargingPrice(com.itrus.portal.db.MobileChargingPrice) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) ArrayList(java.util.ArrayList) ChargingPriceList(com.itrus.portal.mobile.entity.ChargingPriceList) AppserviceChargingWrap(com.itrus.portal.mobile.entity.AppserviceChargingWrap) MobileAppserviceName(com.itrus.portal.db.MobileAppserviceName) AppserviceChargingList(com.itrus.portal.mobile.entity.AppserviceChargingList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with MobileAppserviceName

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

the class MobileAppserviceChargingController method createOrUpdate.

// 新建和修改处理
@RequestMapping(value = "/createOrUpdate", method = RequestMethod.POST, produces = "text/html")
@ResponseBody
public synchronized Map<String, Object> createOrUpdate(@RequestParam("appserviceChargingStr") String appserviceChargingStr) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("flag", false);
    DefaultTransactionDefinition dtd = new DefaultTransactionDefinition();
    // 事物的传播行为,使用同一个事物
    dtd.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(dtd);
    try {
        AppserviceChargingWrap acw = jsonTool.readValue(appserviceChargingStr, AppserviceChargingWrap.class);
        List<AppserviceChargingList> appserviceChargingLists = acw.getAppserviceChargingLists();
        for (int i = 0; i < appserviceChargingLists.size(); i++) {
            // 取出单个的服务名称主表对象和服务名封装list
            MobileAppserviceCharging appCharging = appserviceChargingLists.get(i).getAppserviceCharging();
            // if (null == appCharging.getChargingType()) {
            // cc.setChargingType(ComNames.CHARGING_TYPE_SMRZ_1);
            // }
            List<AppserviceNameList> appserviceNameLists = appserviceChargingLists.get(i).getAppserviceNameLists();
            Map<String, Object> mapAC = new HashMap<String, Object>();
            mapAC = appserviceChargingService.saveOrUpdateAppserviceCharging(appCharging);
            boolean retCodeAC = false;
            retCodeAC = (boolean) mapAC.get("flag");
            // 新增或修改MobileAppserviceCharging成功
            if (retCodeAC) {
                appCharging = (MobileAppserviceCharging) mapAC.get("appserviceCharging");
                MobileAppserviceCharging oldAC = (MobileAppserviceCharging) mapAC.get("oldAppserviceCharging");
                // 将MobileAppserviceCharging的id值赋值给serviceNameList中新增的服务
                appserviceNameLists = appserviceNameService.insertIdIntoAppserviceName(appCharging, appserviceNameLists);
                // 2.新增或修改ServiceName
                for (int j = 0; j < appserviceNameLists.size(); j++) {
                    MobileAppserviceName appserviceName = appserviceNameLists.get(j).getAppserviceName();
                    ChargingPriceList chargingPriceList = appserviceNameLists.get(j).getChargingPriceList();
                    boolean retCodeSN = false;
                    Map<String, Object> mapAppserviceName = new HashMap<String, Object>();
                    mapAppserviceName = appserviceNameService.saveOrUpdateServiceName(appserviceName, appCharging, oldAC);
                    retCodeSN = (boolean) mapAppserviceName.get("flag");
                    // 新增或修改ServiceName成功
                    if (retCodeSN) {
                        appserviceName = (MobileAppserviceName) mapAppserviceName.get("appserviceName");
                        MobileAppserviceName oldAppserviceName = (MobileAppserviceName) mapAppserviceName.get("oldAppserviceName");
                        List<MobileAppserviceName> oldAppserviceNames = (List<MobileAppserviceName>) mapAppserviceName.get("appserviceNames");
                        // 将serviceNameId,CertificationCharging的id值赋值给chargingPriceList中计费以及价格区间
                        chargingPriceList = chargingPriceService.insertIdIntoChargingPrice(appserviceName, chargingPriceList);
                        List<MobileChargingPrice> chargingPrices = chargingPriceList.getChargingPriceLists();
                        // 3.charprice新增或修改
                        for (int k = 0; k < chargingPrices.size(); k++) {
                            Map<String, Object> mapChargingPrice = new HashMap<String, Object>();
                            mapChargingPrice = chargingPriceService.saveOrUpdateChargingPrice(appCharging, appserviceName, chargingPrices.get(k), oldAC, oldAppserviceName, oldAppserviceNames);
                            boolean retCodeChargingPrice = false;
                            retCodeChargingPrice = (boolean) mapChargingPrice.get("flag");
                            // 新增或修改ChargingPrice失败
                            if (!retCodeChargingPrice) {
                                transactionManager.rollback(status);
                                retMap = mapChargingPrice;
                                return retMap;
                            }
                        }
                    } else {
                        // TODO 新增或修改ServiceName错误,返回异常信息
                        transactionManager.rollback(status);
                        retMap = mapAppserviceName;
                        return retMap;
                    }
                }
            } else {
                // TODO 新增或修改CertificationCharging错误,返回异常信息
                transactionManager.rollback(status);
                retMap = mapAC;
                return retMap;
            }
        }
        LogUtil.adminlog(sqlSession, "新增计费规则", "新增了计费规则");
        transactionManager.commit(status);
        retMap.put("flag", true);
        // 修改应用对应的服务:将应用和服务关联起来
        // Set<Long> set = appserviceChargingService.getAllAppId();
        // if (null != set && set.size() >0) {
        // for (Long long1 : set) {
        // Set<Long> AppserviceIDs = appserviceChargingService.getAppserviceIDsByAppId(long1);
        // applicationInfoService.addServiceByAppInfo(long1,AppserviceIDs);
        // }
        // }
        // 通知其他机器,加载缓存
        CertificationChargingHandler cch = new CertificationChargingHandler();
        QueueThread.buildCertificationTask(cch);
        // cacheCustomer.initChargeRule();
        return retMap;
    } catch (JsonParseException e) {
        transactionManager.rollback(status);
        e.printStackTrace();
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (JsonMappingException e) {
        transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        e.printStackTrace();
        return retMap;
    } catch (IOException e) {
        transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        e.printStackTrace();
        return retMap;
    } catch (Exception e) {
        transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        e.printStackTrace();
        return retMap;
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) AppserviceNameList(com.itrus.portal.mobile.entity.AppserviceNameList) MobileChargingPrice(com.itrus.portal.db.MobileChargingPrice) ChargingPriceList(com.itrus.portal.mobile.entity.ChargingPriceList) TransactionStatus(org.springframework.transaction.TransactionStatus) JsonParseException(org.codehaus.jackson.JsonParseException) MobileAppserviceName(com.itrus.portal.db.MobileAppserviceName) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) List(java.util.List) CertificationChargingList(com.itrus.portal.entity.CertificationChargingList) AppserviceNameList(com.itrus.portal.mobile.entity.AppserviceNameList) ArrayList(java.util.ArrayList) ChargingPriceList(com.itrus.portal.mobile.entity.ChargingPriceList) AppserviceChargingList(com.itrus.portal.mobile.entity.AppserviceChargingList) ServiceNameList(com.itrus.portal.entity.ServiceNameList) MobileAppserviceCharging(com.itrus.portal.db.MobileAppserviceCharging) IOException(java.io.IOException) AppserviceChargingWrap(com.itrus.portal.mobile.entity.AppserviceChargingWrap) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) CertificationChargingHandler(com.itrus.portal.service.CertificationChargingHandler) AppserviceChargingList(com.itrus.portal.mobile.entity.AppserviceChargingList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 8 with MobileAppserviceName

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

the class MobileAppserviceNameService method saveOrUpdateServiceName.

/**
 * 新增或修改移动端app服务计费服务类别表
 * @param serviceName
 * @param certificationCharging
 * @return
 * @throws ClassNotFoundException
 * @throws IllegalAccessException
 */
public Map<String, Object> saveOrUpdateServiceName(MobileAppserviceName appserviceName, MobileAppserviceCharging appserviceCharging, MobileAppserviceCharging oldAppserviceCharging) throws ClassNotFoundException, IllegalAccessException {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("flag", false);
    // 参数检查
    boolean check = (null != appserviceName.getServiceType());
    if (!check) {
        retMap.put("retMsg", "服务类别子表参数不合法,请检查修改后重新提交");
        return retMap;
    }
    MobileAppserviceName oldAppserviceName = new MobileAppserviceName();
    // 获取修改之前,获取该MobileAppServiceCharging下的services信息
    List<MobileAppserviceName> appserviceNames = new ArrayList<MobileAppserviceName>();
    // 新增
    if (null != appserviceName && null == appserviceName.getId()) {
        retMap = checkSave(appserviceName, appserviceCharging);
        boolean flag = (boolean) retMap.get("flag");
        if (flag) {
            appserviceName.setCreateTime(new Date());
            appserviceName.setModifyTime(new Date());
            appserviceName.setTotalNumber(0);
            appserviceName.setIsValidity(true);
            appserviceName = save(appserviceName);
        } else {
            return retMap;
        }
    } else {
        // 修改
        appserviceNames = getAppserviceNamesByAppserviceCharging(appserviceCharging.getId(), true);
        retMap = checkSave(appserviceName, appserviceCharging);
        boolean flag = (boolean) retMap.get("flag");
        if (flag) {
            oldAppserviceName = getMobileAppServiceNameById(appserviceName.getId());
            appserviceName = setOldValueInto(appserviceName, oldAppserviceName);
            List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
            list = CompareTwoObjectUtils.compareTwoClass(appserviceName, oldAppserviceName);
            if (list.size() > 0) {
                LogUtil.adminlog(sqlSession, "修改移动端app服务计费规则", "服务名称表中,id为:" + appserviceName.getId() + ",进行了修改,修改内容为:" + list.toString());
            }
            Date date = new Date();
            appserviceName.setModifyTime(date);
            oldAppserviceName.setModifyTime(date);
            appserviceName = update(appserviceName);
        } else {
            return retMap;
        }
    }
    retMap.put("flag", true);
    retMap.put("appserviceName", appserviceName);
    retMap.put("oldAppserviceName", oldAppserviceName);
    retMap.put("appserviceNames", appserviceNames);
    return retMap;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MobileAppserviceName(com.itrus.portal.db.MobileAppserviceName) ArrayList(java.util.ArrayList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date)

Example 9 with MobileAppserviceName

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

the class MobileAppserviceNameService method getAppserviceNamesByAppserviceCharging.

/**
 * 根据输入的条件,获取MobileAppserviceNameList
 *
 * @param appserviceChargingId
 * @return
 */
public List<MobileAppserviceName> getAppserviceNamesByAppserviceCharging(Long appserviceChargingId, boolean isValidity) {
    List<MobileAppserviceName> list = new ArrayList<MobileAppserviceName>();
    MobileAppserviceNameExample appserviceNameExample = new MobileAppserviceNameExample();
    MobileAppserviceNameExample.Criteria criteria = appserviceNameExample.or();
    if (null != appserviceChargingId) {
        criteria.andAppserviceChargingEqualTo(appserviceChargingId);
    }
    criteria.andIsValidityEqualTo(isValidity);
    list = sqlSession.selectList("com.itrus.portal.db.MobileAppserviceNameMapper.selectByExample", appserviceNameExample);
    return list;
}
Also used : MobileAppserviceName(com.itrus.portal.db.MobileAppserviceName) ArrayList(java.util.ArrayList) MobileAppserviceNameExample(com.itrus.portal.db.MobileAppserviceNameExample)

Example 10 with MobileAppserviceName

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

the class MobileAppserviceNameService method checkSave.

/**
 * 新增约束检测
 * @param serviceName
 * @param certificationCharging
 * @return
 */
private Map<String, Object> checkSave(MobileAppserviceName appserviceName, MobileAppserviceCharging appserviceCharging) {
    /*
		 * 
		 * 
		 * 实名认证计费,新增记录的需求和约束: 免费的类型,时间可以重叠. 计费和包年的,同一个应用同一个类型的同一个服务下,时间不能重叠(有效的)
		 * 同一个时间段内,只能有一个有效的正式类型(即:只能有一个计费有效或者一个套餐有效,不能两者并存)
		 * 
		 * 应用id相同,服务id相同,都有效,不能有重叠的有效时间区域: "4.需根据实际计费规则判断:能不能添加已经配置过的认证组合名称
		 * (1)认证组合名称已被添加过,若想再继续添加该组合,实际计费时间不能有重叠的时间区域,且状态不能均有效,否则不能继续添加同样的认证组合名称
		 * 
		 * 解析为:同样的认证组合(应用名称+服务类型+服务名称+计费类型),不能存在两个时间重叠的,且都有效的记录,即:
		 * 可以有多个同样的认证组合的计费或者套餐,但是时间不能重叠.
		 * 
		 * (2)一个包年计费规则内,认证组合名称不能重复"
		 * 
		 * 解析为:一个套餐内,一个类型的一个服务名称只能存在一个
		 * 
		 * 2.在新建“实名认证计费配置”,若选择的所属应用已经配置过,需展示该应用配置的信息 (转化为:不回传已经配置计费且有效的应用.或者是)
		 * 
		 * 新增约束1: 解析为:同样的认证组合(应用名称+服务类型+服务名称+计费类型(记次,套餐)),不能存在两个时间重叠的,且都有效的记录,即:
		 * 可以有多个同样的认证组合的计费或者套餐,但是时间不能重叠.
		 */
    // 从数据库中,获取实名认证计费表:该应用,该计费类型,有效的计费记录
    // 获取该应用,该计费类型下的有效信息
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("flag", false);
    List<MobileAppserviceCharging> listAC = appserviceChargingService.selectListByAppId(appserviceCharging.getApp(), null);
    // 如果该MobileAppserviceCharging下所有的MobileAppserviceName都已经无效了.那么就不校验改MobileAppserviceCharging
    listAC = checkValidAppserviceCharging(listAC);
    // 遍历该应用,该计费类型下的有效信息,看看同一个服务是否已经存在该时间段内的
    for (int i = 0; i < listAC.size(); i++) {
        List<MobileAppserviceName> appserviceNames = getAppserviceNamesByAppserviceCharging(listAC.get(i).getId(), true);
        // 判断时间是否有重叠:新增的起始时间,结束时间都不处于原有记录的时间范围内.
        if (null != appserviceNames && appserviceNames.size() != 0) {
            // 若是修改的,且MobileAppserviceCharging下的所有service都已经无效了,则不再进行时间检测
            boolean flag = appserviceChargingService.checkDateOverlap(appserviceCharging, listAC.get(i));
            // 加入:serviceName.getIsValidity() 修复:当出现两个同应用,同服务名称,起始时间和结束时间有重叠,一个有效,一个无效,引起的修改不能通过的bug
            if (!flag && appserviceName.getIsValidity()) {
                retMap.put("flag", false);
                retMap.put("retMsg", "同一个应用,同一个服务名称下,不允许有重叠的有效时间");
                return retMap;
            }
        }
        // (2)一个包年计费规则内,认证组合名称不能重复"
        if (listAC.get(i).getUserGe().equals(3L) && null != appserviceNames && appserviceNames.size() != 0) {
            // 若appserviceName是修改的,则与数据库中的appserviceName进行对比,如果id不相同,但是与数据库中该服务下的service中对应的服务相同,则是重复了
            if (null != appserviceName.getId()) {
                for (MobileAppserviceName appserviceName2 : appserviceNames) {
                    if (appserviceName.getIsValidity().equals(true) && !appserviceName2.getId().equals(appserviceName.getId()) && appserviceName2.getServiceType().equals(appserviceName.getServiceType())) {
                        retMap.put("flag", false);
                        retMap.put("retMsg", "同一个应用,同一个套餐计费类型,服务类别不允许有重复");
                        return retMap;
                    }
                }
            } else {
                retMap.put("flag", false);
                retMap.put("retMsg", "同一个应用,同一个套餐计费类型,服务类别不允许有重复");
                return retMap;
            }
        }
    }
    retMap.put("flag", true);
    return retMap;
}
Also used : MobileAppserviceCharging(com.itrus.portal.db.MobileAppserviceCharging) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MobileAppserviceName(com.itrus.portal.db.MobileAppserviceName)

Aggregations

MobileAppserviceName (com.itrus.portal.db.MobileAppserviceName)16 ArrayList (java.util.ArrayList)11 MobileAppserviceCharging (com.itrus.portal.db.MobileAppserviceCharging)10 MobileChargingPrice (com.itrus.portal.db.MobileChargingPrice)6 Date (java.util.Date)6 MobileAppserviceNameExample (com.itrus.portal.db.MobileAppserviceNameExample)5 AppserviceNameList (com.itrus.portal.mobile.entity.AppserviceNameList)4 HashMap (java.util.HashMap)4 List (java.util.List)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 MobileAppserviceChargingExample (com.itrus.portal.db.MobileAppserviceChargingExample)3 AppserviceChargingList (com.itrus.portal.mobile.entity.AppserviceChargingList)3 AppserviceChargingWrap (com.itrus.portal.mobile.entity.AppserviceChargingWrap)3 ChargingPriceList (com.itrus.portal.mobile.entity.ChargingPriceList)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)2 AppService (com.itrus.portal.db.AppService)1 MobileCharging (com.itrus.portal.db.MobileCharging)1 SysConfig (com.itrus.portal.db.SysConfig)1 CertificationChargingList (com.itrus.portal.entity.CertificationChargingList)1