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

Commit d23e8361 authored by jiangxiulong's avatar jiangxiulong

记录订阅增加redis标识,增加是否预约接口

parent 915d5143
...@@ -67,6 +67,8 @@ public class SweetConstant { ...@@ -67,6 +67,8 @@ public class SweetConstant {
// public final static String REDIS_KEY_SWEET_COLLECTION_RESERVATION_USER = "sweet:collectionReservation:unionId:"; // public final static String REDIS_KEY_SWEET_COLLECTION_RESERVATION_USER = "sweet:collectionReservation:unionId:";
// 活动结束时间 // 活动结束时间
public final static String REDIS_KEY_SWEET_ACTIVITY_END_TIME = "sweet:activity:endTime:type:"; public final static String REDIS_KEY_SWEET_ACTIVITY_END_TIME = "sweet:activity:endTime:type:";
// 演出预约
public final static String REDIS_KEY_SWEET_PERFORM_SUBSCRIBE = "sweet:performSubscribe:openId:";
// 微信服务号用户相关 // 微信服务号用户相关
public final static String REDIS_KEY_SWEET_WECHAT_USERS_UNIONID = "sweet:user:service:unionId:"; public final static String REDIS_KEY_SWEET_WECHAT_USERS_UNIONID = "sweet:user:service:unionId:";
......
...@@ -16,7 +16,9 @@ public interface ISweetAppletSubMsgService extends IService<SweetAppletSubMsg> { ...@@ -16,7 +16,9 @@ public interface ISweetAppletSubMsgService extends IService<SweetAppletSubMsg> {
ResponseDto sendMsg(Integer type, String targetId); ResponseDto sendMsg(Integer type, String targetId);
ResponseDto sendOfMid(Integer type, String midList, String targetId);
ResponseDto<Boolean> create(String openId, String templateId, String targetId, Integer appletType, Integer activityType); ResponseDto<Boolean> create(String openId, String templateId, String targetId, Integer appletType, Integer activityType);
ResponseDto sendOfMid(Integer type, String midList, String targetId); ResponseDto<Integer> isSubPerform(String openId, String targetId);
} }
...@@ -56,10 +56,10 @@ public class SweetAppletSubMsgController { ...@@ -56,10 +56,10 @@ public class SweetAppletSubMsgController {
@PostMapping("create") @PostMapping("create")
@ApiOperation("添加订阅记录") @ApiOperation("添加订阅记录")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(type = "form", dataType = "String", name = "openId", value = "openId", required = true), @ApiImplicitParam(type = "form", dataType = "String", name = "openId", value = "对应小程序的openId", required = true),
@ApiImplicitParam(type = "form", dataType = "String", name = "templateId", value = "templateId 多个用英文逗号分割", required = true), @ApiImplicitParam(type = "form", dataType = "String", name = "templateId", value = "模版消息ID,多个用英文逗号分割", 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正在 5跳飞船音乐节", required = true), @ApiImplicitParam(type = "form", dataType = "String", name = "appletType", value = "小程序类型 1草莓 2五百里 3mdsk 4正在 5跳飞船音乐节", required = true),
@ApiImplicitParam(type = "form", dataType = "String", name = "activityType", value = "活动类型", required = true), @ApiImplicitParam(type = "form", dataType = "String", name = "activityType", value = "活动类型", required = true),
}) })
public ResponseDto<Boolean> create( public ResponseDto<Boolean> create(
...@@ -72,5 +72,18 @@ public class SweetAppletSubMsgController { ...@@ -72,5 +72,18 @@ public class SweetAppletSubMsgController {
return subMsgService.create(openId, templateId, targetId, appletType, activityType); return subMsgService.create(openId, templateId, targetId, appletType, activityType);
} }
@PostMapping("isSubPerform")
@ApiOperation("是否预约演出")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", dataType = "String", name = "openId", value = "对应小程序的openId", required = true),
@ApiImplicitParam(type = "form", dataType = "String", name = "targetId", value = "演出id", required = true)
})
public ResponseDto<Integer> isSubPerform(
@RequestParam() String openId,
@RequestParam() String targetId
) {
return subMsgService.isSubPerform(openId, targetId);
}
} }
...@@ -18,6 +18,7 @@ import com.liquidnet.service.sweet.mapper.SweetAppletSubMsgMapper; ...@@ -18,6 +18,7 @@ import com.liquidnet.service.sweet.mapper.SweetAppletSubMsgMapper;
import com.liquidnet.service.sweet.service.ISweetAppletSubMsgService; import com.liquidnet.service.sweet.service.ISweetAppletSubMsgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.service.sweet.utils.QueueUtils; import com.liquidnet.service.sweet.utils.QueueUtils;
import com.liquidnet.service.sweet.utils.RedisActivityUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -54,6 +55,9 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM ...@@ -54,6 +55,9 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
@Autowired @Autowired
private QueueUtils queueUtils; private QueueUtils queueUtils;
@Autowired
private RedisActivityUtils redisActivityUtils;
@Override @Override
public ResponseDto sendMsg(Integer type, String targetId) { public ResponseDto sendMsg(Integer type, String targetId) {
List<SweetAppletSubMsg> msgList = subMsgMapper.selectList( List<SweetAppletSubMsg> msgList = subMsgMapper.selectList(
...@@ -194,9 +198,18 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM ...@@ -194,9 +198,18 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
} }
queueUtils.sendMsgByRedis(MQConst.SweetQueue.SWEET_REMIND_INSERT.getKey(), queueUtils.sendMsgByRedis(MQConst.SweetQueue.SWEET_REMIND_INSERT.getKey(),
SqlMapping.gets(sqls, sqlsDataA)); SqlMapping.gets(sqls, sqlsDataA));
redisActivityUtils.setSubscribe(openId, targetId);
return ResponseDto.success(); return ResponseDto.success();
} }
@Override
public ResponseDto<Integer> isSubPerform(String openId, String targetId) {
Integer subscribe = redisActivityUtils.getSubscribe(openId, targetId);
return ResponseDto.success(subscribe);
}
/** /**
* 微信小程序推送订阅消息 * 微信小程序推送订阅消息
*/ */
......
...@@ -47,4 +47,25 @@ public class RedisActivityUtils { ...@@ -47,4 +47,25 @@ public class RedisActivityUtils {
} }
} }
public void setSubscribe(String openId, String targetId) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_PERFORM_SUBSCRIBE
.concat(openId)
.concat(":")
.concat(targetId);
redisUtil.set(redisKey, 1);
}
public Integer getSubscribe(String openId, String targetId) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_PERFORM_SUBSCRIBE
.concat(openId)
.concat(":")
.concat(targetId);
Object obj = redisUtil.get(redisKey);
if (obj == null) {
return 0;
} else {
return (Integer) obj;
}
}
} }
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