Search in sources :

Example 1 with ChargingFail

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);
        }
    }
}
Also used : SysConfig(com.itrus.portal.db.SysConfig) AppService(com.itrus.portal.db.AppService) Charging(com.itrus.portal.db.Charging) UnknownHostException(java.net.UnknownHostException) HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) Date(java.util.Date) ChargingFail(com.itrus.portal.db.ChargingFail) InetAddress(java.net.InetAddress) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 2 with 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;
}
Also used : ChargingFail(com.itrus.portal.db.ChargingFail) ChargingFailExample(com.itrus.portal.db.ChargingFailExample)

Example 3 with ChargingFail

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);
}
Also used : ChargingFail(com.itrus.portal.db.ChargingFail) Date(java.util.Date)

Aggregations

ChargingFail (com.itrus.portal.db.ChargingFail)3 Date (java.util.Date)2 AppService (com.itrus.portal.db.AppService)1 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)1 Charging (com.itrus.portal.db.Charging)1 ChargingFailExample (com.itrus.portal.db.ChargingFailExample)1 SysConfig (com.itrus.portal.db.SysConfig)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 HashMap (java.util.HashMap)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1