Пример #1
0
  public List<Coupon> findActiveCoupons() {

    List<Coupon> result =
        query()
            .leftOuterJoinFetch("coupon.merchant merchant")
            .leftOuterJoinFetch("coupon.couponstoreList couponstore")
            .leftOuterJoinFetch("couponstore.store store")
            .where("coupon.couponStart <= ?", new Date())
            .where("coupon.couponEnd >= ?", new Date())
            .where("coupon.maxDailyBudget >= ?", TappLocalConstants.priceInDolars)
            .where("coupon.maxBudget >= ?", TappLocalConstants.priceInDolars)
            .list();

    for (int i = result.size() - 1; i >= 0; i--) {
      Coupon c = result.get(i);

      Couponreport cr =
          Next.getObject(CouponreportDAO.class)
              .findCouponReportByDateAndCoupon(c.getId(), DateUtils.now().substring(0, 8));

      // if there is a report showing that the balance was already hit, remove it from the list
      if ((cr != null) && (cr.getBalance() != null) && (cr.getBalance() >= c.getMaxDailyBudget()))
        result.remove(i);
    }

    return result;
  }
Пример #2
0
 public static String getApplicationName() {
   return Next.getApplicationContext().getApplicationName();
 }