use of com.itrus.portal.db.MobileAppserviceCharging in project portal by ixinportal.
the class MobileChargingRuleTask method setChargingRuleToInvalid.
/**
* 定时任务,将过期的计费规则置为无效
*
* @Scheduled(fixedRate = 1000 * 60 * 60 * 24)
* @Scheduled(cron = "0 0 2 * * ?")设置为每天凌晨2点触发
*/
@Scheduled(cron = "0 0/35 * * * ?")
public void setChargingRuleToInvalid() {
// start------------处理双机互斥----------
// 系统是否配置同步任务的主机名
SysConfig sysConfigHost = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoHost");
if (null == sysConfigHost) {
// 没有配置,直接返回
return;
}
String host = sysConfigHost.getConfig();
host = host.replaceAll(" ", "");
String[] hosts = host.split(",");
// 获取本机主机名称
InetAddress ia = null;
try {
ia = ia.getLocalHost();
} catch (UnknownHostException e1) {
e1.printStackTrace();
return;
}
String hostName = ia.getHostName();
boolean flag_check = false;
for (String str : hosts) {
if (hostName.equals(str.replaceAll(" ", ""))) {
flag_check = true;
}
}
// 判断本地主机名称是否与系统配置的同步主机名称一致,不一致则返回
if (!flag_check) {
return;
}
// end------------处理双机互斥----------
MobileAppserviceChargingExample cce = new MobileAppserviceChargingExample();
MobileAppserviceChargingExample.Criteria criteria = cce.or();
Date now = new Date();
criteria.andEndTimeLessThan(now);
List<MobileAppserviceCharging> list = appSeviceChargingService.selectByExample(cce);
if (null != list && list.size() > 0) {
List<MobileAppserviceName> serviceNames = appServiceNameService.selectListByCertificationChargings(list);
if (null != serviceNames && serviceNames.size() > 0) {
for (MobileAppserviceName serviceName : serviceNames) {
if (serviceName.getIsValidity() == true) {
serviceName.setIsValidity(false);
appServiceNameService.update(serviceName);
LogUtil.syslog(sqlSession, "将计费规则置为无效", "计费规则id为:" + serviceName.getAppserviceCharging() + ", 服务表id为:" + serviceName.getId());
}
}
}
}
}
use of com.itrus.portal.db.MobileAppserviceCharging in project portal by ixinportal.
the class MobileAppserviceNameService method checkValidAppserviceCharging.
/**
* 如果该MobileAppserviceCharging下所有的MobileAppserviceName都已经无效了.那么就不校验改MobileAppserviceCharging
* 校验该MobileAppserviceCharging
* @param ccList
* @return
*/
private List<MobileAppserviceCharging> checkValidAppserviceCharging(List<MobileAppserviceCharging> acList) {
if (null == acList || acList.size() == 0) {
return acList;
}
Iterator<MobileAppserviceCharging> iterator = acList.iterator();
while (iterator.hasNext()) {
MobileAppserviceCharging appserviceCharging = iterator.next();
MobileAppserviceNameExample appserviceNameExample = new MobileAppserviceNameExample();
MobileAppserviceNameExample.Criteria criteria = appserviceNameExample.or();
criteria.andAppserviceChargingEqualTo(appserviceCharging.getId());
criteria.andIsValidityEqualTo(true);
List<MobileAppserviceName> appserviceNames = selectListByExample(appserviceNameExample);
if (null == appserviceNames || appserviceNames.size() == 0) {
iterator.remove();
}
}
return acList;
}
use of com.itrus.portal.db.MobileAppserviceCharging in project portal by ixinportal.
the class MobileChargingServiceImpl method insertOneIntoCharging.
/**
* 向移动端计费表中插入一条计费记录
*
* @param applicationInfoId
* @param appServiceId
* @param chargingPrice,计费以及价格区间
* @return
*/
public Map<String, Object> insertOneIntoCharging(Long applicationInfoId, /*Long appServiceId,*/
MobileChargingPrice chargingPrice, /*Long transinfoPrimaryId,*/
String transinfoTableName, Long chargingFlow) {
Map<String, Object> retMap = new HashMap<String, Object>();
retMap.put("flag", false);
MobileAppserviceName serviceName = appServiceNameService.getMobileAppServiceNameById(chargingPrice.getAppserviceName());
MobileAppserviceCharging cc = appserviceChargingService.getCertificationChargingById(chargingPrice.getAppserviceCharging());
Date date = new Date();
MobileCharging charging = new MobileCharging();
charging.setApplicationInfo(applicationInfoId);
// charging.setAppService(appServiceId);
charging.setCertificationCharging(chargingPrice.getAppserviceCharging());
charging.setCreateTime(date);
charging.setChargingPrice(chargingPrice.getId());
charging.setIsValidity(true);
charging.setModifyTime(date);
charging.setServiceName(chargingPrice.getAppserviceName());
charging.setServieType(Long.parseLong(String.valueOf(serviceName.getServiceType())));
charging.setUnitPrice(chargingPrice.getUnitPrice());
charging.setUserGe(cc.getUserGe());
charging = getYearMonthQuarter(date, charging);
// charging.setTransinfoName(transinfoName);
// charging.setTransinfoId(transinfoId);
charging.setChargingType(ComNames.SERVICE_TYPE_FOUR);
// charging.setTransinfoPrimaryId(transinfoPrimaryId);
charging.setTransinfoTableName(transinfoTableName);
charging.setChargingId(UniqueIDUtils.genCertificationTransInfoUID(sqlSession));
charging.setChargingFlow(chargingFlow);
// 认证组合名称:组合字段的值是:应用id+','+服务id+','+服务类别+','+年份+','+计费策略
String combinationName = applicationInfoId + /*+ "," + appServiceId*/
"," + serviceName.getServiceType() + "," + charging.getYear1() + "," + cc.getUserGe();
charging.setCombinationName(combinationName);
try {
charging = insertOne(charging);
serviceName.setTotalNumber(serviceName.getTotalNumber() + 1);
appServiceNameService.updateTotalNum(serviceName);
} catch (Exception e) {
// TODO: handle exception
retMap.put("retMsg", e.getMessage());
retMap.put("flag", false);
return retMap;
}
retMap.put("flag", true);
retMap.put("charging", charging);
return retMap;
}
use of com.itrus.portal.db.MobileAppserviceCharging in project portal by ixinportal.
the class MobileAppserviceChargingController method show.
// 根据应用id,查询应用下的所有计费规则信息
@RequestMapping(value = "/show/{id}")
public String show(@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 appServiceExample = new AppServiceExample();
// AppServiceExample.Criteria criteria = appServiceExample.or();
// criteria.andTypeEqualTo(ComNames.SERVICE_TYPE_CERTIFICATION);
// appServices = sqlSession.selectList(
// "com.itrus.portal.db.AppServiceMapper.selectByExample", appServiceExample);
// uiModel.addAttribute("appServices", appServices);
List<MobileAppserviceCharging> appserviceChargings = new ArrayList<MobileAppserviceCharging>();
appserviceChargings = appserviceChargingService.selectList(id);
AppserviceChargingWrap appserviceChargingWrap = new AppserviceChargingWrap();
List<AppserviceChargingList> appserviceChargingLists = new ArrayList<AppserviceChargingList>();
for (int i = 0; i < appserviceChargings.size(); i++) {
AppserviceChargingList appserviceChargingList = new AppserviceChargingList();
List<MobileAppserviceName> serviceNames = new ArrayList<MobileAppserviceName>();
serviceNames = appserviceNameService.selectListByAppserviceCharging(appserviceChargings.get(i));
List<AppserviceNameList> serviceNameLists = new ArrayList<AppserviceNameList>();
for (int j = 0; j < serviceNames.size(); j++) {
List<MobileChargingPrice> chargingPrices = chargingPriceService.selectListByOneAppserviceName(serviceNames.get(j));
AppserviceNameList appserviceNameList = new AppserviceNameList();
ChargingPriceList chargingPriceList = new ChargingPriceList();
// 1
chargingPriceList.setChargingPriceLists(chargingPrices);
// 2
appserviceNameList.setAppserviceName(serviceNames.get(j));
appserviceNameList.setChargingPriceList(chargingPriceList);
serviceNameLists.add(appserviceNameList);
}
appserviceChargingList.setAppserviceCharging(appserviceChargings.get(i));
appserviceChargingList.setAppserviceNameLists(serviceNameLists);
appserviceChargingLists.add(appserviceChargingList);
}
appserviceChargingWrap.setAppserviceChargingLists(appserviceChargingLists);
System.out.println(appserviceChargingWrap);
uiModel.addAttribute("acw", appserviceChargingWrap);
Map<Long, AppService> appServiceMap = sqlSession.selectMap("com.itrus.portal.db.AppServiceMapper.selectByExample", null, "id");
uiModel.addAttribute("appServiceMap", appServiceMap);
// 返回页面上的表单数据
returnParam(request, uiModel);
return "appservicecharging/show";
}
use of com.itrus.portal.db.MobileAppserviceCharging in project portal by ixinportal.
the class MobileAppserviceChargingController method createForm.
// 新建处理页面
@RequestMapping(params = "form", produces = "text/html")
public String createForm(Model uiModel) {
// 系统配置的移动端应用集合
List<ApplicationInfo> mobileApplies = new ArrayList<ApplicationInfo>();
mobileApplies = sqlSession.selectList("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", null);
uiModel.addAttribute("mobileApplies", mobileApplies);
// 移除已经存在了的应用集合
Iterator<ApplicationInfo> iterator = mobileApplies.iterator();
while (iterator.hasNext()) {
ApplicationInfo mobileApply = iterator.next();
List<MobileAppserviceCharging> appserviceChargings = appserviceChargingService.selectListByAppId(mobileApply.getId(), null);
if (null != appserviceChargings && appserviceChargings.size() > 0) {
iterator.remove();
}
}
uiModel.addAttribute("mobileApplies", mobileApplies);
return "appservicecharging/create";
}
Aggregations