use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class StoreServiceNameServiceImpl method initServiceNameMap.
/**
* 初始化当前时间内有效的serviceName
* @return
*/
public ConcurrentHashMap<Long, ServiceName> initServiceNameMap() {
ConcurrentHashMap<Long, ServiceName> serviceNameMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String, List<ChargingPrice>> chargeRuleMap = new ConcurrentHashMap<String, List<ChargingPrice>>();
CertificationChargingExample cce = new CertificationChargingExample();
CertificationChargingExample.Criteria criteria = cce.or();
Date nowDate = new Date();
criteria.andEndTimeGreaterThan(nowDate);
cce.setOrderByClause("start_time asc");
// 将入以下条件之后,只会加载当前时间处于计费起始终止时间内的计费规则,起始时间比当前时间还晚的就不加载
// 加载一个小时以后也有效的计费规则,避免定时任务的空白期出现无可用计费的规则的情况
Date laterDate = storeChargingService.getHourLaterDate(nowDate);
criteria.andStartTimeLessThanOrEqualTo(laterDate);
List<CertificationCharging> certificationChargings = new ArrayList<CertificationCharging>();
certificationChargings = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectByExample", cce);
if (null == certificationChargings) {
return serviceNameMap;
}
for (int i = 0; i < certificationChargings.size(); i++) {
List<ServiceName> serviceNames = selectListByCertificationChargingId(certificationChargings.get(i).getId());
if (null != serviceNames && !serviceNames.isEmpty()) {
for (ServiceName serviceName : serviceNames) {
serviceNameMap.put(serviceName.getId(), serviceName);
}
}
}
return serviceNameMap;
}
use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class StoreServiceNameServiceImpl method selectListByCertificationChargingId.
public List<ServiceName> selectListByCertificationChargingId(Long CertificationChargingId) {
List<ServiceName> list = new ArrayList<ServiceName>();
ServiceNameExample serviceNameExample = new ServiceNameExample();
ServiceNameExample.Criteria criteria = serviceNameExample.or();
criteria.andCertificationChargingEqualTo(CertificationChargingId);
criteria.andIsValidityEqualTo(true);
list = sqlSession.selectList("com.itrus.portal.db.ServiceNameMapper.selectByExample", serviceNameExample);
return list;
}
use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class TakeServiceNameServiceImpl 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 = takeChargingService.selectListByAppId(certificationCharging.getApp(), null, ComNames.CHARGING_TYPE_TAKE_3);
// 如果该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 = takeChargingService.checkDateOverlap(certificationCharging, listCC.get(i));
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;
}
use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class TakeServiceNameServiceImpl method checkNumber.
/**
* 判断当前的计费规则是否适用(判断totalNumber是否处于最大值和最小值之间,处于返回true,不处于返回false).
*
* @param serviceName
* @param chargingPrice
* @return
*/
public boolean checkNumber(Long serviceNameId, ChargingPrice chargingPrice) {
boolean flag = false;
// 用数据库中的数据做对比
ServiceName oldsServiceName = getServiceNameById(serviceNameId);
flag = (chargingPrice.getMaximumNumber() > oldsServiceName.getTotalNumber()) && (chargingPrice.getMinimumNumber() <= oldsServiceName.getTotalNumber());
return flag;
}
use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class TakeServiceNameServiceImpl method saveOrUpdateServiceName.
/**
* 新增或修改实名认证计费服务名称和服务类型表
* @param serviceName
* @param certificationCharging
* @return
* @throws ClassNotFoundException
* @throws IllegalAccessException
*/
public Map<String, Object> saveOrUpdateServiceName(ServiceName serviceName, CertificationCharging certificationCharging, CertificationCharging oldCertificationCharging) throws ClassNotFoundException, IllegalAccessException {
Map<String, Object> retMap = new HashMap<String, Object>();
retMap.put("flag", false);
// 参数检查
boolean check = (null != serviceName.getCertificationServiceId());
if (!check) {
retMap.put("retMsg", "服务名称子表参数不合法,请检查修改后重新提交");
return retMap;
}
ServiceName oldServiceName = new ServiceName();
// 获取修改之前,获取该CertificationCharging下的services信息
List<ServiceName> serviceNames = new ArrayList<ServiceName>();
// 新增
if (null != serviceName && null == serviceName.getId()) {
retMap = checkSave(serviceName, certificationCharging);
boolean flag = (boolean) retMap.get("flag");
if (flag) {
serviceName.setCreateTime(new Date());
serviceName.setModifyTime(new Date());
serviceName.setTotalNumber(0);
serviceName.setIsValidity(true);
serviceName = save(serviceName);
} else {
return retMap;
}
} else {
// 修改
serviceNames = getServiceNamesByCertificationCharging(certificationCharging.getId(), null, true);
retMap = checkSave(serviceName, certificationCharging);
boolean flag = (boolean) retMap.get("flag");
if (flag) {
oldServiceName = getServiceNameById(serviceName.getId());
serviceName = setOldValueInto(serviceName, oldServiceName);
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list = CompareTwoObjectUtils.compareTwoClass(serviceName, oldServiceName);
if (list.size() > 0) {
LogUtil.adminlog(sqlSession, "修改实名认证计费规则", "服务名称表中,id为:" + serviceName.getId() + ",进行了修改,修改内容为:" + list.toString());
}
Date date = new Date();
serviceName.setModifyTime(date);
oldServiceName.setModifyTime(date);
serviceName = update(serviceName);
} else {
return retMap;
}
}
retMap.put("flag", true);
retMap.put("serviceName", serviceName);
retMap.put("oldServiceName", oldServiceName);
retMap.put("serviceNames", serviceNames);
return retMap;
}
Aggregations