示例#1
0
  /**
   * 是否已经存在存在主推商品
   *
   * @see com.sohu.suc.gift.service.GiftService#hasRecommendGift(com.sohu.suc.gift.model.SucGift)
   */
  public boolean hasRecommendGift(SucExchangeGift gift) {

    try {
      if (gift.getIsRecommend() == null || gift.getIsRecommend().intValue() == EnumUtils.NO) {
        return false;
      }

      StringBuilder queryString =
          new StringBuilder(
              "select count(id) from SucExchangeGift where regionId = 1 and isRecommend = ? ");
      List<Object> params = new ArrayList<Object>();
      params.add(EnumUtils.YES);

      if (gift.getId() != null && gift.getIsRecommend().intValue() == EnumUtils.YES) {
        queryString.append(" and id != ?");
        params.add(gift.getId());
      }
      List<SucExchangeGift> results =
          exchangeGiftDao.getListByParams(queryString.toString(), params.toArray());

      if (results != null && results.size() > 0) {
        return true;
      }
      return false;

    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      return false;
    }
  }
示例#2
0
 public SucExchangeGift getExchangeGift(Long id) {
   SucExchangeGift exchangeGift = null;
   try {
     exchangeGift = exchangeGiftDao.get(id);
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
   return exchangeGift;
 }
示例#3
0
  /**
   * 保存编辑后的礼品对象
   *
   * @see com.sohu.suc.gift.service.GiftService#updateExchangeGift(com.sohu.suc.gift.model.SucGift)
   */
  public void updateExchangeGift(SucExchangeGift gift) throws SucGiftException {
    try {

      exchangeGiftDao.saveOrUpdate(gift);
      updateGiftActivity(); // 更新礼品活动
      // RsyncCmd.rsycCmd(); //TODO 需要明白是做什么的

    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      throw new SucGiftException(e);
    }
  }
示例#4
0
  public void createGift(SucExchangeGift gift) throws SucGiftException {

    try {
      exchangeGiftDao.saveOrUpdate(gift);

      // 更新礼品活动
      updateGiftActivity();

    } catch (Exception e) {
      logger.error("createGift", e);
      throw new SucGiftException(e);
    }
  }
示例#5
0
 /**
  * 前台 兑换
  *
  * @param regionId 域id 默认为1
  * @param pagination
  * @return
  */
 public List<SucExchangeGift> exchange_recommend(Long regionId, Pagination pagination) {
   List<SucExchangeGift> result = null;
   try {
     // 过滤掉待重新上架状态
     String queryString =
         "from SucExchangeGift where regionId = ? and isShelf =? and priority>=80 and priority<90 ORDER BY compositorId asc, operateTime DESC ";
     Object[] params = {regionId, GiftEnumUtils.SHELFED};
     result = exchangeGiftDao.getObjectList(queryString, pagination, params);
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
   return result;
 }
示例#6
0
 /**
  * 兑换商品 兑换数
  *
  * @param productid
  * @return
  */
 public String exchange_num(Long productid) {
   String ret = "";
   List details = null;
   try {
     String queryString = "SELECT count(*) FROM suc_gift_detail d WHERE d.gift_Id = " + productid;
     details = exchangeGiftDao.executeList(queryString);
     for (Object obj : details) {
       ret = obj.toString();
     }
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
   return ret;
 }
示例#7
0
 public List<SucExchangeGift> getExchangeGiftList(
     String querySql, Object[] params, Pagination pagination) {
   return exchangeGiftDao.getObjectList(querySql, pagination, params);
 }