use of com.itrus.portal.db.CertificationCharging 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.CertificationCharging 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.CertificationCharging 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.CertificationCharging in project portal by ixinportal.
the class CertificationChargingController method createForm.
// 新建处理页面
@RequestMapping(params = "form", produces = "text/html")
public String createForm(Model uiModel) {
// 系统配置的应用集合
List<ApplicationInfo> applicationInfos = new ArrayList<ApplicationInfo>();
applicationInfos = sqlSession.selectList("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", null);
// 移除已经存在了的应用集合
Iterator<ApplicationInfo> iterator = applicationInfos.iterator();
while (iterator.hasNext()) {
ApplicationInfo applicationInfo = iterator.next();
List<CertificationCharging> certificationChargings = certificationChargingService.selectListByAppId(applicationInfo.getId(), null);
if (null != certificationChargings && certificationChargings.size() > 0) {
iterator.remove();
}
}
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("applicationInfos", applicationInfos);
uiModel.addAttribute("appServices_e", appServices_e);
uiModel.addAttribute("appServices_p", appServices_p);
return "certificationcharging/create";
}
use of com.itrus.portal.db.CertificationCharging 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";
}
Aggregations