use of com.itrus.portal.db.ChargingPrice in project portal by ixinportal.
the class TakeChargingPriceServiceImpl method saveOrUpdateChargingPrice.
/**
* 新增或修改实名认证计费价格以及区间
*
* @param certificationCharging
* @param serviceName
* @param chargingPrice
* @return
* @throws ClassNotFoundException
* @throws IllegalAccessException
*/
public Map<String, Object> saveOrUpdateChargingPrice(CertificationCharging certificationCharging, ServiceName serviceName, ChargingPrice chargingPrice, CertificationCharging oldCertificationCharging, ServiceName oldServiceName, List<ServiceName> oldServiceNames) throws ClassNotFoundException, IllegalAccessException {
Map<String, Object> retMap = new HashMap<String, Object>();
retMap.put("flag", false);
// 参数检查
boolean check = (null != chargingPrice.getUnitPrice() && null != chargingPrice.getMinimumNumber() && null != chargingPrice.getMaximumNumber() && (chargingPrice.getMaximumNumber() > chargingPrice.getMinimumNumber()));
if (!check) {
retMap.put("retMsg", "计费以及价格区间子表参数不合法,请检查修改后重新提交");
return retMap;
}
// 情况3.插入的是中间的阶梯
if (null != chargingPrice && null == chargingPrice.getId()) {
retMap = checkSave(serviceName, chargingPrice);
boolean flag = (boolean) retMap.get("flag");
if (flag) {
chargingPrice.setCreateTime(new Date());
chargingPrice.setModifyTime(new Date());
chargingPrice = save(chargingPrice);
} else {
return retMap;
}
} else {
// 修改
ChargingPrice oldChargingPrice = getChargingPriceById(chargingPrice.getId());
chargingPrice = setOldValueInto(chargingPrice, oldChargingPrice);
retMap = checkUpdate(certificationCharging, serviceName, chargingPrice, oldCertificationCharging, oldServiceName);
boolean flag = (boolean) retMap.get("flag");
if (flag) {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list = CompareTwoObjectUtils.compareTwoClass(chargingPrice, oldChargingPrice);
if (list.size() > 0) {
LogUtil.adminlog(sqlSession, "修改实名认证计费以及价格区间", "计费以及价格区间表中,id为:" + chargingPrice.getId() + ",进行了修改,修改内容为:" + list.toString());
}
chargingPrice.setModifyTime(new Date());
chargingPrice = update(chargingPrice);
// 当原本是有效的,现在改成了无效的.将有效时间改成当前时间
boolean checkVal = (false == serviceName.getIsValidity() && true == oldServiceName.getIsValidity());
if (checkVal && oldCertificationCharging.getUserGe() != 3) {
certificationCharging.setInvalidTime(new Date());
takeChargingService.update(certificationCharging);
} else if (checkVal && oldCertificationCharging.getUserGe() == 3) {
// 当套餐只有一条有效的时候,则修改它的结束时间为当前时间
if (null != oldServiceNames && oldServiceNames.size() == 1) {
certificationCharging.setInvalidTime(new Date());
certificationCharging = takeChargingService.update(certificationCharging);
}
}
} else {
return retMap;
}
}
retMap.put("flag", true);
retMap.put("chargingPrice", chargingPrice);
return retMap;
}
use of com.itrus.portal.db.ChargingPrice in project portal by ixinportal.
the class TakeChargingServiceImpl method initTakeCharging.
/**
* 初始化出证计费规则 取出当前有效的计费规则.并存入系统缓存中
*/
public ConcurrentHashMap<String, List<ChargingPrice>> initTakeCharging() {
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_TAKE_3);
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.ChargingPrice in project portal by ixinportal.
the class TakeChargingServiceImpl method checkTakeCharing.
/**
* 根据输入的appid和appserviceId,查看是否有有效的计费规则,能计费则返回true,不能则返回false,请注意,要保证输入的参数都不能为null,且应用和服务存在
*
* @param applicationInfo
* ,应用appid对应的applicationInfo对象
* @param appService
* ,服务编码对应的appService对象
* @param number,证据份数
* @return
*/
public boolean checkTakeCharing(ApplicationInfo applicationInfo, AppService appService, Integer number) {
String key = applicationInfo.getId() + "," + appService.getId();
ConcurrentHashMap<String, List<ChargingPrice>> chargeRuleMap = CacheCustomer.TAKE_CHARGERULE_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 && (chargingPrice.getMinimumNumber() < number && number <= chargingPrice.getMaximumNumber())) {
return true;
}
}
}
return false;
}
use of com.itrus.portal.db.ChargingPrice in project portal by ixinportal.
the class TakeServiceNameServiceImpl 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 = takeChargingService.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.ChargingPrice in project portal by ixinportal.
the class StoreChargingPriceServiceImpl method selectListByServiceNames.
/**
* 根据serviceName,获取对应的计费以及价格区间
*
* @param serviceNames
* @return
*/
public List<ChargingPrice> selectListByServiceNames(List<ServiceName> serviceNames) {
List<Long> serviceNamesId = new ArrayList<Long>();
for (int i = 0; i < serviceNames.size(); i++) {
serviceNamesId.add(serviceNames.get(i).getId());
}
List<ChargingPrice> list = new ArrayList<ChargingPrice>();
ChargingPriceExample chargingPriceExample = new ChargingPriceExample();
ChargingPriceExample.Criteria criteria = chargingPriceExample.or();
criteria.andServiceNameIn(serviceNamesId);
list = sqlSession.selectList("com.itrus.portal.db.ChargingPriceMapper.selectByExample", chargingPriceExample);
return list;
}
Aggregations