Ejemplo n.º 1
0
 /**
  * @Title: selectReplyByCommentId @Description: TODO(根据评论id查询回复列表)
  *
  * @author <a href="*****@*****.**">赖彩妙</a>
  * @date 2015-5-20 下午2:31:00
  * @version 1.0.0
  * @param @param data
  * @param @return
  * @return Object 返回类型
  * @throws
  */
 public Object selectReplyByCommentId(Object data) {
   log.info("start[MemberCommentService.selectReplyByCommentId]");
   net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(data);
   Integer pageIndex = jsonObject.getInt("pageIndex");
   Integer pageSize = jsonObject.getInt("pageSize");
   Integer commentId = jsonObject.getInt("commentId");
   PageHelper.startPage(pageIndex, pageSize);
   ResultPage<OrderCommentDetailDTO> commentPage =
       new ResultPage(orderCommentMapper.selectReplyByCommentId(commentId));
   if (commentPage.getRows() != null && commentPage.getRows().size() >= 1) {
     SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     for (int i = 0; i < commentPage.getRows().size(); i++) {
       if (commentPage.getRows().get(i).getCreateTime() != null) {
         commentPage
             .getRows()
             .get(i)
             .setCommentDate(format.format(commentPage.getRows().get(i).getCreateTime()));
       }
     }
   }
   log.info("end[MemberCommentService.selectReplyByCommentId]");
   //	    	return new ResultObject(new HeadObject(ErrorCode.SUCCESS),
   // JSONObject.fromObject(commentPage));
   return new ResultObject(
       new HeadObject(ErrorCode.SUCCESS), com.alibaba.fastjson.JSONObject.toJSON(commentPage));
 }
Ejemplo n.º 2
0
 /** 附属账户 */
 @Override
 public String getSubAccountList(HttpSession session, SubAccount subAccount, PageUtil pageUtil) {
   String carrierId = (String) session.getAttribute(Constant.USER_ID);
   Map<String, Object> params = new HashMap<String, Object>();
   String hql = "from SubAccount t " + whereHql(subAccount, params);
   hql += " and t.hostAccountId=:hostAccountId ";
   params.put("hostAccountId", carrierId);
   List<SubAccount> subAccountList = subAccountDao.find(hql, params);
   JSONArray jsonArray = new JSONArray();
   for (SubAccount sub : subAccountList) {
     JSONObject jsonObject = (JSONObject) JSONObject.toJSON(sub);
     jsonArray.add(jsonObject);
   }
   return jsonArray.toString();
 }
Ejemplo n.º 3
0
  /** 下订单时获取用于的发货地址列表 */
  @Override
  public JSONArray getUserAddress(HttpSession session, Integer kind) {
    String userId = (String) session.getAttribute(Constant.USER_ID);
    String hql = "from Address t where t.clientId=:clientId and t.kind=:kind";
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("clientId", userId);
    params.put("kind", kind);
    List<Address> addressList = addressDao.find(hql, params);

    JSONArray jsonArray = new JSONArray();
    for (Address address : addressList) {
      JSONObject jsonObject = (JSONObject) JSONObject.toJSON(address);
      jsonArray.add(jsonObject);
    }
    return jsonArray;
  }
Ejemplo n.º 4
0
 /**
  * 查询订单评论
  *
  * @param data
  * @return
  */
 public Object findCommentByOrderId(Object data) {
   log.info("start[MemberCommentService.selectCommentCountByProductId]");
   Long orderId = (Long) data;
   OrderComment orderComment = new OrderComment();
   HeadObject head = new HeadObject();
   try {
     orderComment = orderCommentMapper.findCommentByOrderId(orderId);
     head.setRetCode(ErrorCode.SUCCESS);
   } catch (Exception e) {
     e.printStackTrace();
     head.setRetCode(ErrorCode.FAILURE);
     log.error(e.toString());
   }
   log.info("end[MemberCommentService.selectCommentCountByProductId]");
   ResultObject result =
       new ResultObject(new HeadObject(ErrorCode.SUCCESS), JSONObject.toJSON(orderComment));
   return result;
 }
Ejemplo n.º 5
0
  /**
   * @Title: selectOrderCommentByGoodsId @Description: TODO(根据商品id查询评论列表)
   *
   * @author <a href="*****@*****.**">赖彩妙</a>
   * @date 2015-5-13 下午2:19:50
   * @version 1.0.0
   * @param @param data
   * @param @return
   * @return Object 返回类型
   * @throws
   */
  public Object selectOrderCommentByGoodsId(Object data) {
    log.info("start[OrderCommentService.selectOrderCommentByGoodsId]");
    net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(data);
    Integer pageIndex = jsonObject.getInt("pageIndex");
    Integer pageSize = jsonObject.getInt("pageSize");
    Integer goodsId = jsonObject.getInt("goodsId");
    PageHelper.startPage(pageIndex, pageSize);
    ResultPage<OrderCommentDetailDTO> commentPage =
        new ResultPage(orderCommentMapper.selectOrderCommentByGoodsId(goodsId));
    if (commentPage.getRows() != null && commentPage.getRows().size() >= 1) {
      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      CommentPraiseExample example = null;
      for (int i = 0; i < commentPage.getRows().size(); i++) {
        if (commentPage.getRows().get(i).getOrderCreateTime() != null) {
          commentPage
              .getRows()
              .get(i)
              .setOrderCreateDate(format.format(commentPage.getRows().get(i).getOrderCreateTime()));
        }
        // 查询点赞数量
        //					example = new CommentPraiseExample();
        //
        //	example.createCriteria().andCommentIdEqualTo(commentPage.getRows().get(i).getCommentId().intValue());
        //					commentPage.getRows().get(i).setPraise(commentPraiseMapper.countByExample(example));
        commentPage
            .getRows()
            .get(i)
            .setPraise(
                commentPraiseMapper.selectCountByCommentId(
                    commentPage.getRows().get(i).getCommentId().intValue()));

        // 查询回复数量
        commentPage
            .getRows()
            .get(i)
            .setReplyCount(
                orderCommentMapper.selectReplyCountByCommentId(
                    commentPage.getRows().get(i).getCommentId().intValue()));
      }
    }
    return new ResultObject(
        new HeadObject(ErrorCode.SUCCESS), com.alibaba.fastjson.JSONObject.toJSON(commentPage));
  }
Ejemplo n.º 6
0
  /** 获取发货地址 */
  @Override
  public String getAddress(HttpSession session, PageUtil pageUtil, Address address) {
    String userId = (String) session.getAttribute(Constant.USER_ID);
    String hql =
        "from Address t where t.clientId=:clientId and t.kind=:kind order by t.relDate desc "; // 1为发货地址,2为收货地址
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("clientId", userId);
    params.put("kind", address.getKind());

    int page = pageUtil.getCurrentPage() == 0 ? 1 : pageUtil.getCurrentPage();
    int display = pageUtil.getDisplay() == 0 ? 10 : pageUtil.getDisplay();
    List<Address> addressList = addressDao.find(hql, params, page, display);

    JSONArray jsonArray = new JSONArray();
    for (Address addr : addressList) {
      JSONObject jsonObject = (JSONObject) JSONObject.toJSON(addr);
      jsonArray.add(jsonObject);
    }

    return jsonArray.toString();
  }
Ejemplo n.º 7
0
 /**
  * @description <b>获取用户的评论信息</b>
  * @author 王鹏
  * @version 1.0.0
  * @data 2015-5-15
  * @param @param data
  * @param @return
  * @return Object
  */
 public Object findMemberComment(Object data) {
   HeadObject headObject = new HeadObject();
   ResultPage<Object> comments = null;
   try {
     MemberCommentQryDTO qryDTO = (MemberCommentQryDTO) data;
     qryDTO.buildOrderByField();
     PageHelper.startPage(qryDTO.getPage(), qryDTO.getRows());
     comments = new ResultPage<Object>(this.orderCommentMapper.selectMemberCommentCount(qryDTO));
     if (comments.getRows().size() > 0) {
       qryDTO.setCommentIds(comments.getRows());
       qryDTO.setCommentsType(CommentsType.COMMENT.getKey().toString());
       comments.setRows(orderCommentMapper.selectMemberComment(qryDTO));
     }
     headObject.setRetCode(ErrorCode.SUCCESS);
   } catch (Exception e) {
     headObject.setRetCode(ErrorCode.FAILURE);
     log.error("获取用户评论失败", e);
     e.printStackTrace();
   }
   return new ResultObject(headObject, JSONObject.toJSON(comments));
 }
Ejemplo n.º 8
0
 public String toJsonString() {
   return JSONObject.toJSON(this).toString();
 }