use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class CertificationChargingServiceImpl method checkStoreCharging.
/**
* 存证计费校验:获取基准大小和存证
* 先获取按次计费的.按次计费通过了,并且本次大小小于基准大小,则直接通过.
* 如果本次大小大于基准大小,并且存证按量计费(不存在则直接通过),并且按量计费剩余量大于超出值,则通过,否则不通过
* 再根据按次计费进行
* 根据输入的appid和appserviceId,查看是否有有效的计费规则,能计费则返回true,不能则返回false,请注意,要保证输入的参数都不能为null,且应用和服务存在
*
* @param applicationInfo
* ,应用appid对应的applicationInfo对象
* @param appService
* ,服务编码对应的appService对象
* @return
*/
public boolean checkStoreCharging(ApplicationInfo applicationInfo, AppService appService, Integer baseSize, Integer size) {
String key = applicationInfo.getId() + "," + appService.getId();
ConcurrentHashMap<String, List<ChargingPrice>> chargeRuleMap = CacheCustomer.getCHARGERULE_MAP();
List<ChargingPrice> chargingPrices = chargeRuleMap.get(key);
ConcurrentHashMap<Long, ServiceName> serviceNameMap = CacheCustomer.getSERVICENAMEMAP();
if (null != chargingPrices && !chargingPrices.isEmpty()) {
for (ChargingPrice chargingPrice : chargingPrices) {
// 校验计费规则对应的时间,是否处于当前时间内,如果不是,则进行下一个计费规则
CertificationCharging certificationCharging = CacheCustomer.getCERTIFICATIONCHARGINGMAP().get(chargingPrice.getCertificationCharging());
boolean dateFlag = compareDate(new Date(), certificationCharging.getStartTime(), certificationCharging.getEndTime());
if (dateFlag) {
continue;
}
ServiceName serviceName = serviceNameMap.get(chargingPrice.getServiceName());
if (null != serviceName && serviceName.getTotalNumber() < chargingPrice.getMaximumNumber()) {
return true;
}
}
}
return false;
}
use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class CertificationChargingServiceImpl method checkTransInfo.
/**
* 根据输入的appid和appserviceId,查看是否有有效的计费规则,能计费则返回true,不能则返回false,请注意,要保证输入的参数都不能为null,且应用和服务存在
*
* @param appId
* ,应用appid
* @param appServiceId
* ,服务编码
* @param applicationInfo
* ,应用appid对应的applicationInfo对象
* @param appService
* ,服务编码对应的appService对象
* @return
*/
public boolean checkTransInfo(String appId, String appServiceId, ApplicationInfo applicationInfo, AppService appService) {
String key = applicationInfo.getId() + "," + appService.getId();
ConcurrentHashMap<String, List<ChargingPrice>> chargeRuleMap = CacheCustomer.getCHARGERULE_MAP();
List<ChargingPrice> chargingPrices = chargeRuleMap.get(key);
ConcurrentHashMap<Long, ServiceName> serviceNameMap = CacheCustomer.getSERVICENAMEMAP();
if (null != chargingPrices && !chargingPrices.isEmpty()) {
for (ChargingPrice chargingPrice : chargingPrices) {
// 校验计费规则对应的时间,是否处于当前时间内,如果不是,则进行下一个计费规则
CertificationCharging certificationCharging = CacheCustomer.getCERTIFICATIONCHARGINGMAP().get(chargingPrice.getCertificationCharging());
boolean dateFlag = compareDate(new Date(), certificationCharging.getStartTime(), certificationCharging.getEndTime());
if (dateFlag) {
continue;
}
ServiceName serviceName = serviceNameMap.get(chargingPrice.getServiceName());
if (null != serviceName && serviceName.getTotalNumber() < chargingPrice.getMaximumNumber()) {
return true;
}
}
}
return false;
}
use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class CertificationChargingServiceImpl method initCertificationCharging.
/**
* 初始实名认证化计费规则 取出当前有效的计费规则.并存入系统缓存中
*/
public ConcurrentHashMap<String, List<ChargingPrice>> initCertificationCharging() {
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 = getHourLaterDate(nowDate);
criteria.andStartTimeLessThanOrEqualTo(laterDate);
criteria.andChargingTypeEqualTo(ComNames.CHARGING_TYPE_SMRZ_1);
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();
chargeRuleMap.put(key, chargingPrices);
}
}
}
return chargeRuleMap;
}
use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class CertificationChargingController 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<AppService> appServices = new ArrayList<AppService>();
AppServiceExample ase = new AppServiceExample();
AppServiceExample.Criteria criteria = ase.or();
// 筛选实名认证类型的服务
criteria.andTypeEqualTo(ComNames.SERVICE_TYPE_CERTIFICATION);
appServices = sqlSession.selectList("com.itrus.portal.db.AppServiceMapper.selectByExample", ase);
uiModel.addAttribute("appServices", appServices);
Map<String, Object> map = new HashMap<>();
map.put("serviceType", 1);
// 系统配置的实名认证服务集合-企业
List<AppService> appServices_e = new ArrayList<AppService>();
appServices_e = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectAppServiceByServiceType", map);
// 系统配置的实名认证服务集合-个人
map.put("serviceType", 2);
List<AppService> appServices_p = new ArrayList<AppService>();
appServices_p = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectAppServiceByServiceType", map);
uiModel.addAttribute("appServices_e", appServices_e);
uiModel.addAttribute("appServices_p", appServices_p);
List<CertificationCharging> certificationChargings = new ArrayList<CertificationCharging>();
certificationChargings = certificationChargingService.selectList(id, ComNames.CHARGING_TYPE_SMRZ_1);
CertificationChargingWrap certificationChargingWrap = new CertificationChargingWrap();
List<CertificationChargingList> certificationChargingLists = new ArrayList<CertificationChargingList>();
for (int i = 0; i < certificationChargings.size(); i++) {
CertificationChargingList certificationChargingList = new CertificationChargingList();
List<ServiceName> serviceNames = new ArrayList<ServiceName>();
serviceNames = serviceNameService.selectListByCertificationCharging(certificationChargings.get(i));
List<ServiceNameList> serviceNameLists = new ArrayList<ServiceNameList>();
for (int j = 0; j < serviceNames.size(); j++) {
List<ChargingPrice> chargingPrices = chargingPriceService.selectListByOneServiceName(serviceNames.get(j));
ServiceNameList serviceNameList = new ServiceNameList();
ChargingPriceList chargingPriceList = new ChargingPriceList();
// 1
chargingPriceList.setChargingPriceLists(chargingPrices);
// 2
serviceNameList.setServiceName(serviceNames.get(j));
serviceNameList.setChargingPriceList(chargingPriceList);
serviceNameLists.add(serviceNameList);
}
certificationChargingList.setCertificationCharging(certificationChargings.get(i));
certificationChargingList.setServiceNameLists(serviceNameLists);
certificationChargingLists.add(certificationChargingList);
}
certificationChargingWrap.setCertificationChargingLists(certificationChargingLists);
uiModel.addAttribute("ccw", certificationChargingWrap);
Map<Long, AppService> appServiceMap = sqlSession.selectMap("com.itrus.portal.db.AppServiceMapper.selectByExample", null, "id");
uiModel.addAttribute("appServiceMap", appServiceMap);
returnParam(request, uiModel);
return "certificationcharging/update";
}
use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class StoreServiceNameServiceImpl method selectListByCertificationChargings.
/**
* 取出所有属于该计费规则的服务名称
*
* @param certificationCharging
* @return
*/
public List<ServiceName> selectListByCertificationChargings(List<CertificationCharging> certificationChargings) {
List<Long> ccIdList = new ArrayList<Long>();
for (int i = 0; i < certificationChargings.size(); i++) {
ccIdList.add(certificationChargings.get(i).getId());
}
List<ServiceName> list = new ArrayList<ServiceName>();
ServiceNameExample serviceNameExample = new ServiceNameExample();
ServiceNameExample.Criteria criteria = serviceNameExample.or();
criteria.andCertificationChargingIn(ccIdList);
list = sqlSession.selectList("com.itrus.portal.db.ServiceNameMapper.selectByExample", serviceNameExample);
return list;
}
Aggregations