tangxiaobao
2021-08-13 8a6375edade9f1edc194a0381369fe94e56c13c7
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActMessageServiceImpl.java
@@ -2,9 +2,14 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.common.utlis.WxUtil;
import com.panzhihua.common.utlis.WxXCXTempSend;
import com.panzhihua.service_community.dao.ComActActSignDAO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@@ -35,6 +40,8 @@
   private ComActMessageDAO comActMessageDAO;
   @Resource
   private ComActMessageBackDAO comActMessageBackDAO;
   @Resource
   private ComActActSignDAO comActActSignDAO;
   @Override
   public R addMessage(ComActMessageVO comActMessageVO) {
@@ -154,6 +161,22 @@
            records.forEach(comActMessageVO1 -> {
                Long id = comActMessageVO1.getId();
                List<ComActMessageBackVO> list = comActMessageDAO.selectMsgBackList(id);
                if(list!=null&& list.size()>0) {
               list.forEach(vo -> {
                  Long type = comActMessageVO1.getType();
                  if (type == 1) {
                     ComPbServiceTeamVO team = comActMessageDAO.selectComPbServiceTeamById(comActMessageVO1.getSendtoUserId());
                     if (!ObjectUtils.isEmpty(team)) {
                        vo.setUserJob(team.getJob());
                     }
                  } else if (type == 2) {
                     PartyCommitteeVO party = comActMessageDAO.selectPartyCommitteeById(comActMessageVO1.getSendtoUserId());
                     if (!ObjectUtils.isEmpty(party)) {
                        vo.setUserJob(party.getPosition());
                     }
                  }
               });
            }
                comActMessageVO1.setBackList(list);
            });
            iPage.setRecords(records);
@@ -170,6 +193,19 @@
         ComActMessageDO selectById = comActMessageDAO.selectById(comActMessageBackDO.getMsgId());
         selectById.setStatus(2);
         comActMessageDAO.updateById(selectById);
         //回复成功给用户推送订阅消息
         Map<String,String> map = comActActSignDAO.getUserOpenId(selectById.getUserId());
         if(map != null){
            String openid = map.get("openid");
            WxXCXTempSend util = new WxXCXTempSend();
            try {
               WxUtil.sendSubscribeLYHF(openid,util.getAppAccessToken(),comActMessageBackVO.getUserName()
                     , DateUtils.format(new Date(),DateUtils.ymdhms_format),comActMessageBackVO.getMsgContent());
            }catch (Exception e){
               log.error("消息推送失败,失败原因:" + e.getMessage());
            }
         }
         return R.ok();
      }
      return R.fail();
@@ -194,6 +230,7 @@
            records.forEach(comActMessageVO1 -> {
                Long id = comActMessageVO1.getId();
                List<ComActMessageBackVO> list = comActMessageDAO.selectMsgBackList(id);
                comActMessageVO1.setBackList(list);
            });
            iPage.setRecords(records);