Esempio n. 1
0
  @SuppressWarnings("unchecked")
  private void balanceAllSiteWithEndDate() {
    try {
      Global.getServerLog().info("统计网站广告收入---------Start");

      String hql =
          "FROM AdsPublish as ad WHERE ad.balanceState = ? "
              + "AND ad.publishState =? "
              + "AND ad.endDate <= ?";

      final List list =
          this.findObjectByHQL(
              DB_POOL_COMMON,
              hql,
              new Object[] {!AD_PUBLISH_STATE_ISBALANCE, AD_PUBLISH_STATE_ENABLED, new Date()});
      final List<AdsWebsite> sList = this.findObjectByExample(DB_POOL_COMMON, new AdsWebsite());

      for (int i = 0; i < list.size(); i++) {
        AdsPublish ad = (AdsPublish) list.get(i);
        for (int j = 0; j < sList.size(); j++) {
          AdsWebsite site = (AdsWebsite) sList.get(j);
          if (site.getId().intValue() == ad.getSiteId().intValue()) {
            site.setWebBalance(site.getWebBalance() + ad.getAdsPrice());
            ad.setBalanceDate(new Date());
            ad.setBalanceState(AD_PUBLISH_STATE_ISBALANCE);
            list.set(i, ad);
            sList.set(j, site);
            break;
          }
        }
      }

      this.getIDBDao()
          .transactionFunction(
              new IDBFunction() {
                public void doTransactionFunction() throws Exception {
                  HibernateTemplate dbTemplate = getDBPool(DB_POOL_COMMON).getHibernateTemplate();
                  dbTemplate.saveOrUpdateAll(list);
                  dbTemplate.saveOrUpdateAll(sList);
                }
              });
      Global.getServerLog().info("统计网站广告收入---------End");
    } catch (Exception e) {
      Global.getServerLog().error("统计网站广告收入发生错误。");
    }
  }
Esempio n. 2
0
  public List<AdsPublish> getMySiteApprove(HttpServletRequest request) throws AjClientException {
    ServerUserEx user = (ServerUserEx) new AjAccount().validateUserState(request, null);
    try {
      AdsPublish ad = new AdsPublish();
      ad.setSiteCmId(user.getMember().getId());
      ad.setPublishState(AD_PUBLISH_STATE_APPROVE);

      List list = this.findObjectByExample(DB_POOL_COMMON, ad);
      List<AdsPublish> dataList = new ArrayList<AdsPublish>();
      for (int i = 0; i < list.size(); i++) {
        ad = (AdsPublish) list.get(i);
        dataList.add(ad);
      }

      return dataList;
    } catch (Exception e) {
      throw new AjClientException(AJ_ERROR_CODE_SERVER_ISBUSY);
    }
  }