Search in sources :

Example 36 with CertificationCharging

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

the class StoreChargingServiceImpl method getAllAppId.

/**
 * 获取计费下所有的应用id
 * @return
 */
public Set<Long> getAllAppId() {
    Set<Long> set = new TreeSet<Long>();
    List<Long> list = new ArrayList<Long>();
    List<CertificationCharging> ccList = selectByExample(null);
    if (null != ccList && ccList.size() > 0) {
        for (CertificationCharging certificationCharging : ccList) {
            set.add(certificationCharging.getApp());
        }
    }
    return set;
}
Also used : CertificationCharging(com.itrus.portal.db.CertificationCharging) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList)

Example 37 with CertificationCharging

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

the class StoreChargingServiceImpl method initAllStoreCharging.

/**
 * 初始化所有的存证计费
 */
public ConcurrentHashMap<String, List<ChargingPrice>> initAllStoreCharging() {
    ConcurrentHashMap<String, List<ChargingPrice>> chargeRuleMap = new ConcurrentHashMap<String, List<ChargingPrice>>();
    CertificationChargingExample cce = new CertificationChargingExample();
    CertificationChargingExample.Criteria criteria = cce.or();
    Date nowDate = new Date();
    cce.setOrderByClause("start_time asc");
    criteria.andChargingTypeEqualTo(ComNames.CHARGING_TYPE_STORE_2);
    List<CertificationCharging> certificationChargings = new ArrayList<CertificationCharging>();
    certificationChargings = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectByExample", cce);
    if (null == certificationChargings) {
        return chargeRuleMap;
    }
    for (int i = 0; i < certificationChargings.size(); i++) {
        List<ServiceName> serviceNames = serviceNameService.selectListByCertificationChargingId(certificationChargings.get(i).getId());
        if (null != serviceNames && serviceNames.size() > 0) {
            for (int j = 0; j < serviceNames.size(); j++) {
                List<ChargingPrice> chargingPrices = new ArrayList<ChargingPrice>();
                chargingPrices = chargingPriceService.selectListByServiceName(serviceNames.get(j));
                String key = certificationChargings.get(i).getApp() + "," + serviceNames.get(j).getCertificationServiceId() + "," + certificationChargings.get(i).getAccountingStrategy();
                chargeRuleMap.put(key, chargingPrices);
            }
        }
    }
    return chargeRuleMap;
}
Also used : CertificationChargingExample(com.itrus.portal.db.CertificationChargingExample) CertificationCharging(com.itrus.portal.db.CertificationCharging) ArrayList(java.util.ArrayList) Date(java.util.Date) ServiceName(com.itrus.portal.db.ServiceName) ArrayList(java.util.ArrayList) List(java.util.List) ChargingPrice(com.itrus.portal.db.ChargingPrice) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 38 with CertificationCharging

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

the class StoreChargingServiceImpl method initCertificationChargingMap.

/**
 * 初始化CertificationChargingMap
 */
public ConcurrentHashMap<Long, CertificationCharging> initCertificationChargingMap() {
    ConcurrentHashMap<Long, CertificationCharging> certificationChargingMap = new ConcurrentHashMap<Long, CertificationCharging>();
    CertificationChargingExample cce = new CertificationChargingExample();
    CertificationChargingExample.Criteria criteria = cce.or();
    Date nowDate = new Date();
    criteria.andEndTimeGreaterThan(nowDate);
    cce.setOrderByClause("start_time asc");
    // 将入以下条件之后,只会加载当前时间处于计费起始终止时间内的计费规则,起始时间比当前时间还晚的就不加载
    // 加载一个小时以后也有效的计费规则,避免定时任务的空白期出现无可用计费的规则的情况
    Date laterDate = getHourLaterDate(nowDate);
    criteria.andStartTimeLessThanOrEqualTo(laterDate);
    List<CertificationCharging> certificationChargings = new ArrayList<CertificationCharging>();
    certificationChargings = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectByExample", cce);
    if (null != certificationChargings && !certificationChargings.isEmpty()) {
        for (CertificationCharging certificationCharging : certificationChargings) {
            certificationChargingMap.put(certificationCharging.getId(), certificationCharging);
        }
    }
    return certificationChargingMap;
}
Also used : CertificationChargingExample(com.itrus.portal.db.CertificationChargingExample) CertificationCharging(com.itrus.portal.db.CertificationCharging) ArrayList(java.util.ArrayList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Date(java.util.Date)

Example 39 with CertificationCharging

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

the class StoreServiceNameServiceImpl method checkSave.

/**
 * 新增约束检测
 * @param serviceName
 * @param certificationCharging
 * @return
 */
private Map<String, Object> checkSave(ServiceName serviceName, CertificationCharging certificationCharging) {
    // 从数据库中,获取实名认证计费表:该应用,该计费类型,有效的计费记录
    // 获取该应用,该计费类型下的有效信息
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("flag", false);
    // 获取该应用该计费的类型的
    List<CertificationCharging> listCC = storeChargingService.selectListByAppId(certificationCharging.getApp(), null, ComNames.CHARGING_TYPE_STORE_2);
    // 如果该CertificationCharging下所有的ServiceName都已经无效了.那么就不校验改CertificationCharging
    listCC = checkValidCertificationCharging(listCC);
    // 遍历该应用,该计费类型下的有效信息,看看同一个服务是否已经存在该时间段内的
    for (int i = 0; i < listCC.size(); i++) {
        CertificationCharging thiscc = listCC.get(i);
        List<ServiceName> serviceNames = getServiceNamesByCertificationCharging(listCC.get(i).getId(), serviceName.getCertificationServiceId(), true);
        if (null != serviceNames && serviceNames.size() != 0) {
            // 判断该计费类型和本次循环的类型是否相同,根据是否相同,做不同的处理
            if (thiscc.getUserGe().equals(certificationCharging.getUserGe())) {
                // 同一个应用,同一个服务名称下,同一个用途,同一个计费策略,不允许有重叠的有效时间
                if (thiscc.getAccountingStrategy().equals(certificationCharging.getAccountingStrategy())) {
                    boolean flag = storeChargingService.checkDateOverlap(certificationCharging, listCC.get(i));
                    if (!flag && serviceName.getIsValidity()) {
                        retMap.put("flag", false);
                        retMap.put("retMsg", "同一个应用,同一个服务名称下,同一个用途,同一个计费策略,不允许有重叠的有效时间");
                        return retMap;
                    }
                }
            } else {
                // 使用用途不同
                // 同一个应用,同一个服务名称下,使用用途不同,不允许有重叠的有效时间
                boolean flag = storeChargingService.checkDateOverlap(certificationCharging, listCC.get(i));
                if (!flag) {
                    retMap.put("flag", false);
                    retMap.put("retMsg", "同一个应用,同一个服务名称下,使用用途不同,不允许有重叠的有效时间");
                    return retMap;
                }
            }
        // 如果该应用,该计费类型,该服务名称下,已经存在对应有效的计费规则,判断规则时间是否有重叠,有重叠则返回错误
        // 判断时间是否有重叠:新增的起始时间,结束时间都不处于原有记录的时间范围内.
        // 若是修改的,且certificationCharging下的所有service都已经无效了,则不再进行时间检测
        }
    }
    retMap.put("flag", true);
    return retMap;
}
Also used : CertificationCharging(com.itrus.portal.db.CertificationCharging) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ServiceName(com.itrus.portal.db.ServiceName)

Example 40 with CertificationCharging

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

the class ServiceNameServiceImpl method checkSave.

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

Aggregations

CertificationCharging (com.itrus.portal.db.CertificationCharging)43 ArrayList (java.util.ArrayList)34 ServiceName (com.itrus.portal.db.ServiceName)25 Date (java.util.Date)23 ChargingPrice (com.itrus.portal.db.ChargingPrice)21 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)19 CertificationChargingExample (com.itrus.portal.db.CertificationChargingExample)16 List (java.util.List)15 HashMap (java.util.HashMap)13 ServiceNameList (com.itrus.portal.entity.ServiceNameList)9 CertificationChargingList (com.itrus.portal.entity.CertificationChargingList)6 CertificationChargingWrap (com.itrus.portal.entity.CertificationChargingWrap)6 ChargingPriceList (com.itrus.portal.entity.ChargingPriceList)6 IOException (java.io.IOException)4 Map (java.util.Map)4 Test (org.junit.Test)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 AppService (com.itrus.portal.db.AppService)3 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)3 Charging (com.itrus.portal.db.Charging)3