记得上下班打卡 | 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;
*/
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 {
*/
private Integer appletType;
/**
* 活动类型
*/
private Integer activityType;
/**
* 是否推送 1未推送 2已推送
*/
......
......@@ -5,6 +5,7 @@ import feign.hystrix.FallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Component
@FeignClient(name = "liquidnet-service-sweet",
......@@ -17,6 +18,6 @@ public interface FeignSweetWechatClient {
ResponseDto 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;
import com.liquidnet.service.feign.sweet.task.FeignSweetWechatClient;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -37,10 +38,21 @@ public class SweetWechatTaskHandler {
@XxlJob(value = "sev-sweet:sendSubMsg")
public ReturnT<String> sendSubMsgHandler() {
try {
Object data = feignSweetWechatClient.sendSubMsg().getData();
log.info("sendSubMsgHandler:结果:{}", data);
String jobParam = XxlJobHelper.getJobParam();//执行参数
log.info("jobParam = " + jobParam);
String[] paramArray = jobParam.split(":");
ReturnT<String> success = ReturnT.SUCCESS;
success.setMsg(String.valueOf(data));
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));
}
return success;
} catch (Exception e) {
log.error("exception of handler:{}", e.getMessage(), e);
......
......@@ -2,17 +2,18 @@
drop TABLE if exists `sweet_applet_sub_msg`;
CREATE TABLE `sweet_applet_sub_msg`
(
`mid` bigint unsigned NOT NULL AUTO_INCREMENT,
`msg_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'msg_id',
`open_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'open_id',
`template_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'template_id',
`target_id` varchar(255) NOT NULL DEFAULT '' COMMENT '目标id 显示是演出id',
`applet_type` tinyint NOT NULL DEFAULT 0 COMMENT '1草莓 2五百里 3mdsk 4正在',
`is_push` tinyint NOT NULL DEFAULT 1 COMMENT '是否推送 1未推送 2已推送',
`created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
`mid` bigint unsigned NOT NULL AUTO_INCREMENT,
`msg_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'msg_id',
`open_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'open_id',
`template_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'template_id',
`target_id` varchar(255) NOT NULL DEFAULT '' COMMENT '目标id 显示是演出id',
`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已推送',
`created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`mid`),
KEY `sweet_applet_sub_msg_id` (`msg_id`)
KEY `sweet_applet_sub_msg_id` (`msg_id`)
) ENGINE = InnoDB
DEFAULT CHARSET utf8mb4
COLLATE utf8mb4_unicode_ci
......
......@@ -32,8 +32,11 @@ public class SweetAppletSubMsgController {
@GetMapping("send")
@ApiOperation("发送模版消息")
public ResponseDto send() {
return subMsgService.sendMsg();
public ResponseDto send(
@RequestParam Integer type,
@RequestParam String targetId
) {
return subMsgService.sendMsg(type, targetId);
}
@PostMapping("create")
......@@ -43,14 +46,16 @@ public class SweetAppletSubMsgController {
@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 = "appletType", value = "1草莓 2五百里 3mdsk 4正在", required = true),
@ApiImplicitParam(type = "form", dataType = "String", name = "activityType", value = "活动类型", required = true),
})
public ResponseDto<Boolean> create(
@RequestParam() String openId,
@RequestParam() String templateId,
@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
private QueueUtils queueUtils;
@Override
public ResponseDto sendMsg() {
public ResponseDto sendMsg(Integer type, String targetId) {
List<SweetAppletSubMsg> msgList = subMsgMapper.selectList(
Wrappers.lambdaQuery(SweetAppletSubMsg.class)
.eq(SweetAppletSubMsg::getIsPush, 1)
.eq(SweetAppletSubMsg::getActivityType, type)
);
ArrayList<String> msgIdList = CollectionUtil.arrayListString();
if (!CollectionUtils.isEmpty(msgList)) {
for (SweetAppletSubMsg info : msgList) {
try {
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();
if (null == performanceVoData || ObjectUtils.isEmpty(performanceVoData)) {
log.info("无演出数据:[getPerformancesId=[{}]", info.getTargetId());
......@@ -104,6 +105,7 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
if (!CollectionUtils.isEmpty(msgIdList)) {
SweetAppletSubMsg update = new SweetAppletSubMsg();
update.setIsPush(2);
update.setTargetId(targetId);
update.setUpdatedAt(LocalDateTime.now());
subMsgMapper.update(
update,
......@@ -116,7 +118,7 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
}
@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(",");
LinkedList<String> sqls = CollectionUtil.linkedListString();
......@@ -124,7 +126,7 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
sqls.add(SqlMapping.get("sweet_applet_sub_msg.insert"));
for (String id : templateIdArray) {
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(),
......
......@@ -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_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_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