Authored by mlge

Merge branch 'test6.8.9' of http://git.yoho.cn/platform/platform-cms into test6.8.9

@@ -7,12 +7,16 @@ import com.yoho.service.model.social.request.UicUserReqBO; @@ -7,12 +7,16 @@ import com.yoho.service.model.social.request.UicUserReqBO;
7 import com.yoho.service.model.social.response.UserInfoRspBO; 7 import com.yoho.service.model.social.response.UserInfoRspBO;
8 import com.yohobuy.platform.dal.common.BeanConvertUtil; 8 import com.yohobuy.platform.dal.common.BeanConvertUtil;
9 import com.yohobuy.platform.dal.grass.IGrassArticleCommentDao; 9 import com.yohobuy.platform.dal.grass.IGrassArticleCommentDao;
  10 +import com.yohobuy.platform.dal.grass.IGrassArticleDao;
  11 +import com.yohobuy.platform.dal.grass.model.GrassArticle;
  12 +import com.yohobuy.platform.dal.grass.model.GrassArticleComment;
10 import com.yohobuy.platform.dal.grass.model.GrassArticleCommentQueryDo; 13 import com.yohobuy.platform.dal.grass.model.GrassArticleCommentQueryDo;
11 import com.yohobuy.platform.grass.service.IGrassArticleCommentService; 14 import com.yohobuy.platform.grass.service.IGrassArticleCommentService;
12 import com.yohobuy.platform.model.common.PageResponseVO; 15 import com.yohobuy.platform.model.common.PageResponseVO;
13 import com.yohobuy.platform.model.grass.ChildCommentTotalBo; 16 import com.yohobuy.platform.model.grass.ChildCommentTotalBo;
14 import com.yohobuy.platform.model.grass.request.ArticleCommentModifyStatusReq; 17 import com.yohobuy.platform.model.grass.request.ArticleCommentModifyStatusReq;
15 import com.yohobuy.platform.model.grass.request.ArticleCommentQueryReq; 18 import com.yohobuy.platform.model.grass.request.ArticleCommentQueryReq;
  19 +import com.yohobuy.platform.model.grass.request.GrassInBoxAddReq;
16 import com.yohobuy.platform.model.grass.response.ArticleCommentQueryRsp; 20 import com.yohobuy.platform.model.grass.response.ArticleCommentQueryRsp;
17 import org.apache.commons.collections.CollectionUtils; 21 import org.apache.commons.collections.CollectionUtils;
18 import org.apache.commons.lang3.StringEscapeUtils; 22 import org.apache.commons.lang3.StringEscapeUtils;
@@ -35,6 +39,8 @@ public class GrassArticleCommentServiceImpl implements IGrassArticleCommentServi @@ -35,6 +39,8 @@ public class GrassArticleCommentServiceImpl implements IGrassArticleCommentServi
35 @Autowired 39 @Autowired
36 private IGrassArticleCommentDao grassArticleCommentDao; 40 private IGrassArticleCommentDao grassArticleCommentDao;
37 @Autowired 41 @Autowired
  42 + private IGrassArticleDao grassArticleDao;
  43 + @Autowired
38 private ServiceCaller serviceCaller; 44 private ServiceCaller serviceCaller;
39 @Value("${uic.service.url:http://uic.yohoops.org/uic}") 45 @Value("${uic.service.url:http://uic.yohoops.org/uic}")
40 private String uicUrl; 46 private String uicUrl;
@@ -128,5 +134,50 @@ public class GrassArticleCommentServiceImpl implements IGrassArticleCommentServi @@ -128,5 +134,50 @@ public class GrassArticleCommentServiceImpl implements IGrassArticleCommentServi
128 @Override 134 @Override
129 public void modifyStatus(ArticleCommentModifyStatusReq req) { 135 public void modifyStatus(ArticleCommentModifyStatusReq req) {
130 grassArticleCommentDao.updateStatus(req.getIds(),req.getStatus(),req.getReviewer(), DateUtil.currentTimeSeconds()); 136 grassArticleCommentDao.updateStatus(req.getIds(),req.getStatus(),req.getReviewer(), DateUtil.currentTimeSeconds());
  137 + if(req.getStatus() == GrassArticleComment.Status.SUCCESS.getValue()){
  138 + sendInBoxMessage(req.getIds());
  139 + }
  140 + }
  141 +
  142 + private void sendInBoxMessage(List<Integer> commentIds){
  143 + logger.info("enter sendInBoxMessage.commentIds is {}",commentIds);
  144 + List<GrassArticleComment> commentList = grassArticleCommentDao.selectByIds(commentIds);
  145 + //只推送文章消息
  146 + commentList = commentList.stream().filter(com->com.getDestId()!=null && com.getColumnType() == GrassArticleComment.ColumnType.ARTICLE.getValue()).collect(Collectors.toList());
  147 + if(commentList.isEmpty()){
  148 + return;
  149 + }
  150 + List<Integer> parentIds = commentList.stream().filter(com->com.getParentId()!=null).map(GrassArticleComment::getParentId).collect(Collectors.toList());
  151 + Map<Integer,GrassArticleComment> parentCommentMap = CollectionUtils.isEmpty(parentIds)?new HashMap<>():grassArticleCommentDao.selectMapByIds(parentIds);
  152 + List<Integer> articleIds = commentList.stream().map(GrassArticleComment::getDestId).collect(Collectors.toList());
  153 + Map<Integer,GrassArticle> articleMap = CollectionUtils.isEmpty(articleIds)?new HashMap<>():grassArticleDao.selectMapByIds(articleIds);
  154 + List<GrassInBoxAddReq> addReqList = new ArrayList<>();
  155 + for(GrassArticleComment comment : commentList){
  156 + GrassArticle article = articleMap.get(comment.getDestId());
  157 + GrassInBoxAddReq addReq = new GrassInBoxAddReq();
  158 + addReq.setAttachValue(comment.getId().toString());
  159 + addReq.setOptUid(comment.getUid());
  160 + if(comment.getRootId() == null){
  161 + if(article.getAuthorType() == GrassArticle.AUTHORTYPE_EDITOR){
  162 + continue;//小编用户不发消息
  163 + }
  164 + addReq.setBusinessType(1002);
  165 + addReq.setUid(article.getAuthorUid());
  166 + }else{
  167 + GrassArticleComment parent = parentCommentMap.get(comment.getParentId());
  168 + addReq.setBusinessType(1003);
  169 + addReq.setUid(parent.getUid());
  170 + }
  171 + addReqList.add(addReq);
  172 + }
  173 + if(CollectionUtils.isEmpty(addReqList)){
  174 + return;
  175 + }
  176 + try{
  177 + logger.info("before sns.addBatchInBox.addReqList size is {}",addReqList.size());
  178 + serviceCaller.call("sns.addBatchInBox", addReqList, String.class);
  179 + }catch (Exception e){
  180 + logger.info("failed addBatchInBox, commentIds are {}, error is {}",commentIds, e);
  181 + }
131 } 182 }
132 } 183 }