use of com.itrus.portal.db.ChargingFail in project portal by ixinportal.
the class ChargingFailTask method ChargingAgain.
/**
* 遍历所有计费失败的记录,重新计费
*
* @Scheduled(fixedRate = 1000 * 60 * 60 * 24) 设置为每天凌晨2点触发
* @Scheduled(cron = "0 0 2 * * ?")
*/
@Scheduled(cron = "0 0/45 * * * ?")
public void ChargingAgain() {
// 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------------处理双机互斥----------
List<ChargingFail> chargingFails = chargingFailService.geChargingFails();
if (null == chargingFails || chargingFails.size() == 0) {
return;
}
for (int i = 0; i < chargingFails.size(); i++) {
ChargingFail chargingFail = chargingFails.get(i);
Map<String, Object> retMap = new HashMap<String, Object>();
ApplicationInfo applicationInfo = certificationChargingService.getApplicationInfoByAppId(chargingFail.getAppId());
AppService appService = certificationChargingService.getAppServiceByAppServiceId(chargingFail.getAppServiceId());
retMap = certificationChargingService.charging(chargingFail.getAppId(), chargingFail.getAppServiceId(), chargingFail.getTransinfoName(), chargingFail.getTransinfoId(), applicationInfo, appService, chargingFail.getTransinfoPrimaryId(), chargingFail.getTransinfoTableName());
Integer flag = (Integer) retMap.get("retCode");
// 若插入成功
if (null != flag && flag == 1) {
chargingFail.setIsValidity(false);
chargingFail.setModifyTime(new Date());
Charging charging = (Charging) retMap.get("charging");
chargingFail.setChargingId(charging.getChargingId());
chargingFailService.update(chargingFail);
}
}
}
use of com.itrus.portal.db.ChargingFail in project portal by ixinportal.
the class ChargingFailServiceImpl method geChargingFails.
/**
* 返回所有未成功计费的实名认证计费记录
* @return
*/
public List<ChargingFail> geChargingFails() {
ChargingFailExample chargingFailExample = new ChargingFailExample();
ChargingFailExample.Criteria criteria = chargingFailExample.or();
criteria.andIsValidityEqualTo(true);
// 设置计费类型为实名认证计费
criteria.andTransInfoTypeEqualTo(1L);
List<ChargingFail> chargingFails = sqlSession.selectList("com.itrus.portal.db.ChargingFailMapper.selectByExample", chargingFailExample);
return chargingFails;
}
use of com.itrus.portal.db.ChargingFail in project portal by ixinportal.
the class ChargingFailServiceImpl method chargingFailHandle.
/**
* 当实名认证计费进行计费失败后,调用该接口进行失败记录,用于在定时任务中重新计费
* @param appId
* @param appServiceId
*/
public void chargingFailHandle(String appId, String appServiceId, String transinfoName, Long transinfoId, Long transinfoPrimaryId, String transinfoTableName) {
ChargingFail chargingFail = new ChargingFail();
Date date = new Date();
chargingFail.setAppId(appId);
chargingFail.setAppServiceId(appServiceId);
chargingFail.setCreateTime(date);
chargingFail.setIsValidity(true);
chargingFail.setModifyTime(date);
chargingFail.setTransInfoType(1L);
chargingFail.setTransinfoName(transinfoName);
chargingFail.setTransinfoId(transinfoId);
chargingFail = insertOne(chargingFail);
}
Aggregations