记得上下班打卡 | git大法好,push需谨慎

Commit 50901977 authored by jiangxiulong's avatar jiangxiulong

订阅create增加type xxjob支持传参数

parent 881b9ce1
...@@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/ */
public interface ISweetAppletSubMsgService extends IService<SweetAppletSubMsg> { public interface ISweetAppletSubMsgService extends IService<SweetAppletSubMsg> {
ResponseDto sendMsg(); ResponseDto sendMsg(Integer type, String targetId);
ResponseDto<Boolean> create(String openId, String templateId, String targetId, String appletType); ResponseDto<Boolean> create(String openId, String templateId, String targetId, Integer appletType, Integer activityType);
} }
...@@ -49,6 +49,11 @@ public class SweetAppletSubMsg implements Serializable { ...@@ -49,6 +49,11 @@ public class SweetAppletSubMsg implements Serializable {
*/ */
private Integer appletType; private Integer appletType;
/**
* 活动类型
*/
private Integer activityType;
/** /**
* 是否推送 1未推送 2已推送 * 是否推送 1未推送 2已推送
*/ */
......
...@@ -5,6 +5,7 @@ import feign.hystrix.FallbackFactory; ...@@ -5,6 +5,7 @@ import feign.hystrix.FallbackFactory;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Component @Component
@FeignClient(name = "liquidnet-service-sweet", @FeignClient(name = "liquidnet-service-sweet",
...@@ -17,6 +18,6 @@ public interface FeignSweetWechatClient { ...@@ -17,6 +18,6 @@ public interface FeignSweetWechatClient {
ResponseDto send(); ResponseDto send();
@GetMapping("sweet/appletSubMsg/send") @GetMapping("sweet/appletSubMsg/send")
ResponseDto sendSubMsg(); ResponseDto sendSubMsg(@RequestParam("type") Integer type, @RequestParam("type") String targetId);
} }
...@@ -2,6 +2,7 @@ package com.liquidnet.service.executor.main.handler; ...@@ -2,6 +2,7 @@ package com.liquidnet.service.executor.main.handler;
import com.liquidnet.service.feign.sweet.task.FeignSweetWechatClient; import com.liquidnet.service.feign.sweet.task.FeignSweetWechatClient;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -37,10 +38,21 @@ public class SweetWechatTaskHandler { ...@@ -37,10 +38,21 @@ public class SweetWechatTaskHandler {
@XxlJob(value = "sev-sweet:sendSubMsg") @XxlJob(value = "sev-sweet:sendSubMsg")
public ReturnT<String> sendSubMsgHandler() { public ReturnT<String> sendSubMsgHandler() {
try { try {
Object data = feignSweetWechatClient.sendSubMsg().getData(); String jobParam = XxlJobHelper.getJobParam();//执行参数
log.info("sendSubMsgHandler:结果:{}", data); log.info("jobParam = " + jobParam);
String[] paramArray = jobParam.split(":");
ReturnT<String> success = ReturnT.SUCCESS; ReturnT<String> success = ReturnT.SUCCESS;
for (String typeAndTargetId : paramArray) {
String[] typeAndTargetIdArray = typeAndTargetId.split(",");
Integer type = Integer.parseInt(typeAndTargetIdArray[0]);
String targetId = typeAndTargetIdArray[1];
Object data = feignSweetWechatClient.sendSubMsg(type, targetId).getData();
log.info("sendSubMsgHandler:结果:{}", data);
success.setMsg(String.valueOf(data)); success.setMsg(String.valueOf(data));
}
return success; return success;
} catch (Exception e) { } catch (Exception e) {
log.error("exception of handler:{}", e.getMessage(), e); log.error("exception of handler:{}", e.getMessage(), e);
......
...@@ -8,6 +8,7 @@ CREATE TABLE `sweet_applet_sub_msg` ...@@ -8,6 +8,7 @@ CREATE TABLE `sweet_applet_sub_msg`
`template_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'template_id', `template_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'template_id',
`target_id` varchar(255) NOT NULL DEFAULT '' COMMENT '目标id 显示是演出id', `target_id` varchar(255) NOT NULL DEFAULT '' COMMENT '目标id 显示是演出id',
`applet_type` tinyint NOT NULL DEFAULT 0 COMMENT '1草莓 2五百里 3mdsk 4正在', `applet_type` tinyint NOT NULL DEFAULT 0 COMMENT '1草莓 2五百里 3mdsk 4正在',
`activity_type` tinyint NOT NULL DEFAULT 0 COMMENT '活动类型',
`is_push` tinyint NOT NULL DEFAULT 1 COMMENT '是否推送 1未推送 2已推送', `is_push` tinyint NOT NULL DEFAULT 1 COMMENT '是否推送 1未推送 2已推送',
`created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', `updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
......
...@@ -32,8 +32,11 @@ public class SweetAppletSubMsgController { ...@@ -32,8 +32,11 @@ public class SweetAppletSubMsgController {
@GetMapping("send") @GetMapping("send")
@ApiOperation("发送模版消息") @ApiOperation("发送模版消息")
public ResponseDto send() { public ResponseDto send(
return subMsgService.sendMsg(); @RequestParam Integer type,
@RequestParam String targetId
) {
return subMsgService.sendMsg(type, targetId);
} }
@PostMapping("create") @PostMapping("create")
...@@ -43,14 +46,16 @@ public class SweetAppletSubMsgController { ...@@ -43,14 +46,16 @@ public class SweetAppletSubMsgController {
@ApiImplicitParam(type = "form", dataType = "String", name = "templateId", value = "templateId 多个用英文逗号分割", required = true), @ApiImplicitParam(type = "form", dataType = "String", name = "templateId", value = "templateId 多个用英文逗号分割", required = true),
@ApiImplicitParam(type = "form", dataType = "String", name = "targetId", value = "演出id", required = true), @ApiImplicitParam(type = "form", dataType = "String", name = "targetId", value = "演出id", required = true),
@ApiImplicitParam(type = "form", dataType = "String", name = "appletType", value = "1草莓 2五百里 3mdsk 4正在", required = true), @ApiImplicitParam(type = "form", dataType = "String", name = "appletType", value = "1草莓 2五百里 3mdsk 4正在", required = true),
@ApiImplicitParam(type = "form", dataType = "String", name = "activityType", value = "活动类型", required = true),
}) })
public ResponseDto<Boolean> create( public ResponseDto<Boolean> create(
@RequestParam() String openId, @RequestParam() String openId,
@RequestParam() String templateId, @RequestParam() String templateId,
@RequestParam() String targetId, @RequestParam() String targetId,
@RequestParam() String appletType @RequestParam() Integer appletType,
@RequestParam() Integer activityType
) { ) {
return subMsgService.create(openId, templateId, targetId, appletType); return subMsgService.create(openId, templateId, targetId, appletType, activityType);
} }
......
...@@ -55,17 +55,18 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM ...@@ -55,17 +55,18 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
private QueueUtils queueUtils; private QueueUtils queueUtils;
@Override @Override
public ResponseDto sendMsg() { public ResponseDto sendMsg(Integer type, String targetId) {
List<SweetAppletSubMsg> msgList = subMsgMapper.selectList( List<SweetAppletSubMsg> msgList = subMsgMapper.selectList(
Wrappers.lambdaQuery(SweetAppletSubMsg.class) Wrappers.lambdaQuery(SweetAppletSubMsg.class)
.eq(SweetAppletSubMsg::getIsPush, 1) .eq(SweetAppletSubMsg::getIsPush, 1)
.eq(SweetAppletSubMsg::getActivityType, type)
); );
ArrayList<String> msgIdList = CollectionUtil.arrayListString(); ArrayList<String> msgIdList = CollectionUtil.arrayListString();
if (!CollectionUtils.isEmpty(msgList)) { if (!CollectionUtils.isEmpty(msgList)) {
for (SweetAppletSubMsg info : msgList) { for (SweetAppletSubMsg info : msgList) {
try { try {
String msgId = info.getMsgId(); String msgId = info.getMsgId();
ResponseDto<KylinPerformanceVo> kylinPerformanceVo = feignKylinPerformancesClient.detail(info.getTargetId(), 0, 0, ""); ResponseDto<KylinPerformanceVo> kylinPerformanceVo = feignKylinPerformancesClient.detail(targetId, 0, 0, "");
KylinPerformanceVo performanceVoData = kylinPerformanceVo.getData(); KylinPerformanceVo performanceVoData = kylinPerformanceVo.getData();
if (null == performanceVoData || ObjectUtils.isEmpty(performanceVoData)) { if (null == performanceVoData || ObjectUtils.isEmpty(performanceVoData)) {
log.info("无演出数据:[getPerformancesId=[{}]", info.getTargetId()); log.info("无演出数据:[getPerformancesId=[{}]", info.getTargetId());
...@@ -104,6 +105,7 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM ...@@ -104,6 +105,7 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
if (!CollectionUtils.isEmpty(msgIdList)) { if (!CollectionUtils.isEmpty(msgIdList)) {
SweetAppletSubMsg update = new SweetAppletSubMsg(); SweetAppletSubMsg update = new SweetAppletSubMsg();
update.setIsPush(2); update.setIsPush(2);
update.setTargetId(targetId);
update.setUpdatedAt(LocalDateTime.now()); update.setUpdatedAt(LocalDateTime.now());
subMsgMapper.update( subMsgMapper.update(
update, update,
...@@ -116,7 +118,7 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM ...@@ -116,7 +118,7 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
} }
@Override @Override
public ResponseDto<Boolean> create(String openId, String templateId, String targetId, String appletType) { public ResponseDto<Boolean> create(String openId, String templateId, String targetId, Integer appletType, Integer activityType) {
String[] templateIdArray = templateId.split(","); String[] templateIdArray = templateId.split(",");
LinkedList<String> sqls = CollectionUtil.linkedListString(); LinkedList<String> sqls = CollectionUtil.linkedListString();
...@@ -124,7 +126,7 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM ...@@ -124,7 +126,7 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
sqls.add(SqlMapping.get("sweet_applet_sub_msg.insert")); sqls.add(SqlMapping.get("sweet_applet_sub_msg.insert"));
for (String id : templateIdArray) { for (String id : templateIdArray) {
sqlsDataA.add(new Object[]{ sqlsDataA.add(new Object[]{
IDGenerator.nextSnowId(), openId, id, targetId, appletType IDGenerator.nextSnowId(), openId, id, targetId, appletType, activityType
}); });
} }
queueUtils.sendMsgByRedis(MQConst.SweetQueue.SWEET_REMIND_INSERT.getKey(), queueUtils.sendMsgByRedis(MQConst.SweetQueue.SWEET_REMIND_INSERT.getKey(),
......
...@@ -37,7 +37,7 @@ sweet_luck_draw.insert=INSERT INTO sweet_luck_draw (mobile,union_id,luck_draw_nu ...@@ -37,7 +37,7 @@ sweet_luck_draw.insert=INSERT INTO sweet_luck_draw (mobile,union_id,luck_draw_nu
sweet_answer.insert=INSERT INTO sweet_answer (answer_id,phone,answer_json,img_url) VALUES (?,?,?,?) sweet_answer.insert=INSERT INTO sweet_answer (answer_id,phone,answer_json,img_url) VALUES (?,?,?,?)
# --------------------------提醒记录-------------------------- # --------------------------提醒记录--------------------------
sweet_remind.insert=INSERT INTO sweet_remind (remind_id,openId,unionId,performancesId) VALUES (?,?,?,?) sweet_remind.insert=INSERT INTO sweet_remind (remind_id,openId,unionId,performancesId) VALUES (?,?,?,?)
sweet_applet_sub_msg.insert=INSERT INTO sweet_applet_sub_msg (msg_id,open_id,template_id,target_id,applet_type) VALUES (?,?,?,?,?) sweet_applet_sub_msg.insert=INSERT INTO sweet_applet_sub_msg (msg_id,open_id,template_id,target_id,applet_type,activity_type) VALUES (?,?,?,?,?,?)
# --------------------------用户投票记录-------------------------- # --------------------------用户投票记录--------------------------
sweet_city_vote.insert=INSERT INTO sweet_city_vote (vote_id,phone,openId,unionId,type,city_code,city_name,day_time) VALUES (?,?,?,?,?,?,?,?) sweet_city_vote.insert=INSERT INTO sweet_city_vote (vote_id,phone,openId,unionId,type,city_code,city_name,day_time) VALUES (?,?,?,?,?,?,?,?)
sweet_city_vote_stat.insert=INSERT INTO sweet_city_vote_stat (stat_id,city_code,city_name,vote_num,type) VALUES (?,?,?,?,?) sweet_city_vote_stat.insert=INSERT INTO sweet_city_vote_stat (stat_id,city_code,city_name,vote_num,type) VALUES (?,?,?,?,?)
......
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