Commit d34ca97e by 阮思源

1002031无资源服务时反馈给编辑

parent fc4c46b8
...@@ -126,6 +126,11 @@ public class BookGroupDTO implements Serializable { ...@@ -126,6 +126,11 @@ public class BookGroupDTO implements Serializable {
*/ */
private Integer joinGroupType; private Integer joinGroupType;
/**
* 二维码id
*/
private Long sceneId;
public String getUrl() { public String getUrl() {
return url; return url;
} }
...@@ -312,6 +317,14 @@ public class BookGroupDTO implements Serializable { ...@@ -312,6 +317,14 @@ public class BookGroupDTO implements Serializable {
this.joinGroupType = joinGroupType; this.joinGroupType = joinGroupType;
} }
public Long getSceneId() {
return sceneId;
}
public void setSceneId(Long sceneId) {
this.sceneId = sceneId;
}
@Override @Override
public String toString() { public String toString() {
return "BookGroupDTO{" + return "BookGroupDTO{" +
...@@ -337,6 +350,7 @@ public class BookGroupDTO implements Serializable { ...@@ -337,6 +350,7 @@ public class BookGroupDTO implements Serializable {
", bookInfo=" + bookInfo + ", bookInfo=" + bookInfo +
", url='" + url + '\'' + ", url='" + url + '\'' +
", joinGroupType=" + joinGroupType + ", joinGroupType=" + joinGroupType +
", sceneId=" + sceneId +
'}'; '}';
} }
} }
\ No newline at end of file
...@@ -230,4 +230,14 @@ public class BookApplication { ...@@ -230,4 +230,14 @@ public class BookApplication {
public Binding wxLiveBroadcastReminderBindBind(){ public Binding wxLiveBroadcastReminderBindBind(){
return RabbitMQFactory.bindingExchange(wxLiveBroadcastReminderBindQueue(), MQTopicProducer.WX_LIVE_BROADCAST_REMINDER); return RabbitMQFactory.bindingExchange(wxLiveBroadcastReminderBindQueue(), MQTopicProducer.WX_LIVE_BROADCAST_REMINDER);
} }
@Bean
public Queue someUserScanBookGroupQueue(){
return RabbitMQFactory.queueBuilder(MQTopicConumer.CONSUMER_SOME_USER_SCAN_BOOK_GROUP);
}
@Bean
public Binding someUserScanBookGroupBind(){
return RabbitMQFactory.bindingExchange(someUserScanBookGroupQueue(), MQTopicProducer.SOME_USER_SCAN_BOOK_GROUP);
}
} }
...@@ -20,4 +20,6 @@ public interface BookGroupServeDao extends BaseDao<BookGroupServe> { ...@@ -20,4 +20,6 @@ public interface BookGroupServeDao extends BaseDao<BookGroupServe> {
List<BookGroupServe> getProductServeList(); List<BookGroupServe> getProductServeList();
List<BookGroupApp> getAllAppServe(); List<BookGroupApp> getAllAppServe();
Integer getCountByBookGroupId(Long bookGroupId);
} }
...@@ -54,4 +54,11 @@ public class BookGroupServeDaoImpl extends BaseDaoImpl<BookGroupServe> implement ...@@ -54,4 +54,11 @@ public class BookGroupServeDaoImpl extends BaseDaoImpl<BookGroupServe> implement
public List<BookGroupApp> getAllAppServe() { public List<BookGroupApp> getAllAppServe() {
return super.getSqlSession().selectList(getStatement("getAllAppServe")); return super.getSqlSession().selectList(getStatement("getAllAppServe"));
} }
@Override
public Integer getCountByBookGroupId(Long bookGroupId) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
return super.getSqlSession().selectOne(getStatement("getCountByBookGroupId"), map);
}
} }
...@@ -85,4 +85,9 @@ public class MQTopicConumer { ...@@ -85,4 +85,9 @@ public class MQTopicConumer {
*/ */
public static final String WX_LIVE_BROADCAST_REMINDER = PREFIX + MQTopicProducer.WX_LIVE_BROADCAST_REMINDER; public static final String WX_LIVE_BROADCAST_REMINDER = PREFIX + MQTopicProducer.WX_LIVE_BROADCAST_REMINDER;
/**
* 社群码扫码人数达到一定数量
*/
public static final String CONSUMER_SOME_USER_SCAN_BOOK_GROUP = PREFIX + MQTopicProducer.SOME_USER_SCAN_BOOK_GROUP;
} }
package com.pcloud.book.mq.topic;
import com.pcloud.book.consumer.message.TemplateConsr;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dao.BookGroupServeDao;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.keywords.dao.BookKeywordDao;
import com.pcloud.book.mq.config.MQTopicConumer;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.SceneCode;
import com.pcloud.common.core.constant.SendType;
import com.pcloud.common.core.constant.SystemCode;
import com.pcloud.common.exceptions.BizException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @Description社群码扫码人数达到一定数量
* @Author ruansiyuan
* @Date 2019/12/5 16:34
**/
@Component("someUserScanBookGroupListener")
@RabbitListener(queues = MQTopicConumer.CONSUMER_SOME_USER_SCAN_BOOK_GROUP)
public class SomeUserScanBookGroupListener {
private static final Logger LOGGER = LoggerFactory.getLogger(SomeUserScanBookGroupListener.class);
@Autowired
private BookGroupDao bookGroupDao;
@Autowired
private BookKeywordDao bookKeywordDao;
@Autowired
private BookGroupServeDao bookGroupServeDao;
@Autowired
private TemplateConsr templateConsr;
@ParamLog("接收社群码扫码人数达到一定数量topic")
@RabbitHandler
public void onMessage(Long bookGroupId) throws BizException {
if (bookGroupId == null) {
return;
}
BookGroupDTO dto = bookGroupDao.getDTOById(bookGroupId);
if (dto == null) {
LOGGER.error("没有找到该社群码" + bookGroupId);
return;
}
Integer joinGroupType = dto.getJoinGroupType();
Boolean isSend = false;
if (JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(joinGroupType)) {
//普通群查询有没有配置关键词
Integer keywordCount = bookKeywordDao.getKeywordCount(bookGroupId, null);
if (keywordCount <= 0) {
isSend = true;
}
}
if (JoinGroupTypeEnum.ROBOT.getCode().equals(joinGroupType)) {
//1v1查询有没有配置资源服务
Integer count = bookGroupServeDao.getCountByBookGroupId(bookGroupId);
if (count <= 0) {
isSend = true;
}
}
if (isSend) {
//发送模板消息
sendTemplate(dto);
}
}
@ParamLog("发送模板消息")
private void sendTemplate(BookGroupDTO dto) {
try {
Map<String, String> temParam = new HashMap<>();
String word="已有读者扫码!您的二维码“" + dto.getGroupQrcodeName() + "”还未配置任何资源服务。请及时完善该二维码资源服务。";
temParam.put("first", word);
temParam.put("keyword1", "【提醒】您的二维码还未配置资源服务");
temParam.put("keyword2", "待查看");
temParam.put("remark", "请及时处理");
templateConsr.sendManage(SceneCode.PROJECT_TASK_SCENE.value, dto.getAgentId(), dto.getCreateUser(),
SystemCode.adviser.code, "", temParam, SendType.SEND_BY_PARTY_ID.value, false);
LOGGER.info("资源未配置发送模板消息temParam="+temParam.toString()+"dto="+dto.toString());
} catch (Exception e) {
LOGGER.error("编辑管理--删除副编辑,发送模板消息失败<ERROR>" + e.getMessage());
}
}
}
...@@ -120,4 +120,11 @@ ...@@ -120,4 +120,11 @@
t.serve_id, t.serve_id,
t.serve_type t.serve_type
</select> </select>
<!--根据社群码id查询资源服务数量-->
<select id="getCountByBookGroupId" parameterType="map" resultType="integer">
select count(1)
from book_group_serve
where book_group_id=#{bookGroupId}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment