Authored by tanling

线下店公众号

... ... @@ -3,9 +3,45 @@ package com.yoho.message.sdk.common.constants;
public class OfflineShopScenes {
/**
* 预约提醒
* 预约提醒-AB类
*/
public static String RESERVE_REMIND = "RESERVE_REMIND";
public static String RESERVE_REMIND_AB = "RESERVE_REMIND_AB";
/**
* 预约提醒-CD类
*/
public static String RESERVE_REMIND_CD = "RESERVE_REMIND_AB";
/**
* 实名登记提醒
*/
public static String REALNAME_REGISTER_REMIND = "REALNAME_REGISTER_REMIND";
/**
* 排队成功通知
*/
public static String LIMIT_QUEUE_SUCCESS = "LIMIT_QUEUE_SUCCESS";
/**
* 服务到期提醒
*/
public static String COUPON_SERVICE_DUE = "COUPON_SERVICE_DUE";
/**
* 入驻成功
*/
public static String ENTER_SUCCESS_SHOP = "ENTER_SUCCESS_SHOP";
/**
* 赴约提醒
*/
public static String APPOINTMENT_REMIND = "APPOINTMENT_REMIND";
}
... ...
package com.yoho.message.sdk.common.constants;
public interface PublicNumberConstants {
public class PublicNumberConstants {
// 值和 PublicNumberEnum 保持一致
/**
* 线下店
* 线下店公众号
*/
public static final int OFF_SHOP_SERVICE = 6;
/**
* 线下店小程序
*/
public static final int OFF_SHOP_MINIPROGRAM = 2;
/**
* 有货 订阅号
*/
public static final int YOHO_BUY = 1;
... ...
... ... @@ -27,13 +27,6 @@ public class MessageCenterCommonEvent implements Serializable{
// 区分公众号 默认值 有货服务号
private int publicNumberCode = 2;
public JSONObject getMiniprogram() {
return miniprogram;
}
public void setMiniprogram(JSONObject miniprogram) {
this.miniprogram = miniprogram;
}
public int getPublicNumberCode() {
return publicNumberCode;
... ... @@ -81,12 +74,7 @@ public class MessageCenterCommonEvent implements Serializable{
params.put(key, value);
}
public void putMiniprogram(String key,Object value){
if(miniprogram==null){
miniprogram = new JSONObject();
}
miniprogram.put(key, value);
}
public String getSendScene() {
return sendScene;
... ...
... ... @@ -30,6 +30,7 @@ public abstract class AbstractSendMessage {
}
public MessageCenterCommonEvent genMessageCenterCommonEvent(String sendScene, String sendSceneKey, int miniappType, String uid) {
List<String> uids = Arrays.asList(uid);
... ... @@ -43,4 +44,16 @@ public abstract class AbstractSendMessage {
}
public MessageCenterCommonEvent genMessageCenterCommonEvent(String sendScene, String sendSceneKey, int miniappType, List<String> uids) {
// 原来用 miniappFlg = 1 or 0 来标识是否是小程序
// 为了支持多小程序,miniappType (miniappFlg=1 实际上是 miniappType=0的小程序)
// 其他的 miniappFlg = miniappType
if (miniappType == 1){
miniappType = 0;
}
return new MessageCenterCommonEvent(sendScene, sendSceneKey, miniappType, uids);
}
}
... ...
... ... @@ -2,8 +2,89 @@ package com.yoho.message.sdk.service;
import com.yoho.message.sdk.common.model.SendMessageRspBo;
import java.util.List;
public interface IOfflineShopMessage {
public SendMessageRspBo reserveRemineForAllFans(String activityName, int startTime, int endTime, String address, String pagePath);
/**
* 预约成功
* @param activityName 活动名称
* @param startTime 限定活动开始时间
* @param endTime 限定活动结束时间
* @param isAB AB类为小程序限定发售详情页,CD类活动详情页
* @param miniPathParam 小程序页面路径的参数
*
* @return
*/
SendMessageRspBo reserveRemindForAllFans(String activityName, int startTime, int endTime, boolean isAB, String miniPatharam);
/**
* 实名登记提醒
* @param uids
* @param activityName
* @param startTime
* @param endTime
* @param activityId 用于小程序跳转
* @return
*/
SendMessageRspBo realNameRegisterRemind(List<String> uids, String activityName, int startTime, int endTime, String activityId);
/**
* 排队成功通知
* @param uids
* @param activityName 活动名称
* @param queueTimeStr 排队时间
* @param registerMobile 注册号码
* @param activityId 用于小程序跳转
* @return
*/
SendMessageRspBo queueSuccess(List<String> uids, String activityName, String queueTimeStr, String registerMobile, String activityId);
/**
* 服务到期提醒
* @param uid
* @param expireCouponNum 券数量
* @param brandName 体验券的销售渠道
* @param couponName 体验券名称
* @param expireTime 过期时间
* @return
*/
SendMessageRspBo serviceDue(String uid, String brandName, int expireCouponNum, String couponName, int expireTime);
/**
* 入驻成功通知
* @param desc 后台配置内容字段
* @param enterTimeStr 入驻时间
* @param remark 后台配置温馨提示
* @return
*/
SendMessageRspBo enterSuccess(String desc, String enterTimeStr, String remark);
/**
* 赴约通知
* @param desc 后台配置内容字段值
* @param activityName 活动名称
* @param activityAddress 活动地点
* @param activityTime 活动时间
* @param appointmentPerson 赴约的人
* @param remark 后台配置温馨提示字段值
* @return
*/
SendMessageRspBo appointmentRemind(String desc, String activityName, String activityAddress, int activityTime,
String appointmentPerson, String remark);
}
... ...
... ... @@ -2,6 +2,7 @@ package com.yoho.message.sdk.service.impl;
import com.yoho.message.sdk.common.constants.MiniAppTypeEnum;
import com.yoho.message.sdk.common.constants.OfflineShopScenes;
import com.yoho.message.sdk.common.constants.PromotionScenes;
import com.yoho.message.sdk.common.constants.PublicNumberConstants;
import com.yoho.message.sdk.common.handler.MessageCenterMqHandler;
import com.yoho.message.sdk.common.model.MessageCenterCommonEvent;
... ... @@ -12,6 +13,8 @@ import com.yoho.message.sdk.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import static com.yoho.message.sdk.common.constants.PublicNumberConstants.KEY_APP_ID;
@Service
... ... @@ -21,20 +24,150 @@ public class OfflineShopMessageImpl extends AbstractSendMessage implements IOffl
private MessageCenterMqHandler messageCenterMqHandler;
public SendMessageRspBo reserveRemineForAllFans(String activityName, int startTime, int endTime, String address, String pagePath) {
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEventPublicCode(OfflineShopScenes.RESERVE_REMIND,
String.valueOf(System.currentTimeMillis()), PublicNumberConstants.OFF_SHOP_SERVICE, PublicNumberConstants.ALL_FANS);
/**
* 预约提醒
* @param activityName 活动名称
* @param startTime 限定活动开始时间
* @param endTime 限定活动结束时间
* @param isAB 公众消息跳转的小程序路径
* @param miniPathParam 小程序页面参数
* @return
*/
public SendMessageRspBo reserveRemindForAllFans(String activityName, int startTime, int endTime, boolean isAB, String miniPathParam) {
messageCenterCommonEvent.putMiniprogram(PublicNumberConstants.KEY_APP_ID, MiniAppTypeEnum.OFFSHOP.getAppId());
messageCenterCommonEvent.putMiniprogram(PublicNumberConstants.KEY_PAGE_PATH, pagePath);
String scene = isAB ? OfflineShopScenes.RESERVE_REMIND_AB : OfflineShopScenes.RESERVE_REMIND_CD;
// 指定线下店公众号
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEventPublicCode(scene,
String.valueOf(System.currentTimeMillis()), PublicNumberConstants.OFF_SHOP_SERVICE, PublicNumberConstants.ALL_FANS);
messageCenterCommonEvent.putInParams("activityName",activityName);
messageCenterCommonEvent.putInParams("startTime", DateUtils.long2DateStr(startTime * 1000l, DateUtils.fullDateTimeFormat));
messageCenterCommonEvent.putInParams("endTime", DateUtils.long2DateStr(endTime * 1000l, DateUtils.fullDateTimeFormat));
messageCenterCommonEvent.putInParams("address",address);
messageCenterCommonEvent.putInParams("miniPathParam", miniPathParam);
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
return new SendMessageRspBo(200, "SUCCESS");
}
/**
* 实名登记提醒
* @param uids
* @param activityName
* @param startTime
* @param endTime
* @param activityId
* @return
*/
public SendMessageRspBo realNameRegisterRemind(List<String> uids, String activityName, int startTime, int endTime, String activityId) {
// 指定线下店小程序
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(OfflineShopScenes.REALNAME_REGISTER_REMIND,
String.valueOf(System.currentTimeMillis()), PublicNumberConstants.OFF_SHOP_MINIPROGRAM, uids);
messageCenterCommonEvent.putInParams("activityName", activityName);
messageCenterCommonEvent.putInParams("registerTime",
DateUtils.long2DateStr(startTime * 1000l, DateUtils.fullDateTimeFormat) +
"-"+ DateUtils.long2DateStr(endTime * 1000l, DateUtils.fullDateTimeFormat));
messageCenterCommonEvent.putInParams("activityId", activityId);
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
return new SendMessageRspBo(200, "SUCCESS");
}
/**
* 排队成功通知
* @param uids
* @param activityName
* @param queueTimeStr
* @param registerMobile
* @param activityId
* @return
*/
public SendMessageRspBo queueSuccess(List<String> uids, String activityName, String queueTimeStr, String registerMobile, String activityId) {
// 指定线下店小程序
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(OfflineShopScenes.LIMIT_QUEUE_SUCCESS,
String.valueOf(System.currentTimeMillis()), PublicNumberConstants.OFF_SHOP_MINIPROGRAM, uids);
messageCenterCommonEvent.putInParams("activityName", activityName);
messageCenterCommonEvent.putInParams("queueTimeStr", queueTimeStr);
messageCenterCommonEvent.putInParams("registerMobile", registerMobile);
messageCenterCommonEvent.putInParams("activityId", activityId);
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
return new SendMessageRspBo(200, "SUCCESS");
}
/**
* 服务到期提醒
* @param uids
* @param expireCouponNum 券数量
* @param couponName 体验券名称
* @param expireTime 过期时间
* @return
*/
@Override
public SendMessageRspBo serviceDue(String uids, String brandName, int expireCouponNum, String couponName, int expireTime) {
// 指定线下店公众号
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEventPublicCode(OfflineShopScenes.COUPON_SERVICE_DUE,
String.valueOf(System.currentTimeMillis()), PublicNumberConstants.OFF_SHOP_SERVICE, uids);
messageCenterCommonEvent.putInParams("expireCouponNum", expireCouponNum);
messageCenterCommonEvent.putInParams("brandName", brandName);
messageCenterCommonEvent.putInParams("couponName", couponName);
messageCenterCommonEvent.putInParams("expireTime", DateUtils.long2DateStr(expireTime * 1000l, DateUtils.dateFormat));
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
return new SendMessageRspBo(200, "SUCCESS");
}
/**
* 入驻成功
* @param desc 后台配置内容字段
* @param enterTimeStr 入驻时间
* @param remark 后台配置温馨提示
* @return
*/
@Override
public SendMessageRspBo enterSuccess(String desc, String enterTimeStr, String remark) {
// 指定线下店公众号
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEventPublicCode(OfflineShopScenes.ENTER_SUCCESS_SHOP,
String.valueOf(System.currentTimeMillis()), PublicNumberConstants.OFF_SHOP_SERVICE, PublicNumberConstants.ALL_FANS);
messageCenterCommonEvent.putInParams("desc", desc);
messageCenterCommonEvent.putInParams("enterTimeStr", enterTimeStr);
messageCenterCommonEvent.putInParams("remark", remark);
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
return new SendMessageRspBo(200, "SUCCESS");
}
/**
* 赴约通知
* @param desc 后台配置内容字段值
* @param activityName 活动名称
* @param activityAddress 活动地点
* @param activityTime 活动时间
* @param appointmentPerson 赴约的人
* @param remark 后台配置温馨提示字段值
* @return
*/
@Override
public SendMessageRspBo appointmentRemind(String desc, String activityName, String activityAddress, int activityTime,
String appointmentPerson, String remark) {
// 指定线下店公众号
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEventPublicCode(OfflineShopScenes.APPOINTMENT_REMIND,
String.valueOf(System.currentTimeMillis()), PublicNumberConstants.OFF_SHOP_SERVICE, PublicNumberConstants.ALL_FANS);
messageCenterCommonEvent.putInParams("desc", desc);
messageCenterCommonEvent.putInParams("activityName", activityName);
messageCenterCommonEvent.putInParams("activityAddress", activityAddress);
messageCenterCommonEvent.putInParams("activityTime", DateUtils.long2DateStr(activityTime * 1000l, DateUtils.fullDateTimeFormat));
messageCenterCommonEvent.putInParams("appointmentPerson", appointmentPerson);
messageCenterCommonEvent.putInParams("remark", remark);
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
return new SendMessageRspBo(200, "SUCCESS");
}
}
... ...
... ... @@ -20,12 +20,25 @@ public class TestUserMessage {
@Autowired
IOfflineShopMessage offlineShopMessage;
/**
* 测试注意
*/
@Test
public void reserveRemineForAllFans() {
offlineShopMessage.reserveRemineForAllFans("线下店王大锤测试活动", 1517905629, 1517905629, "有货", "pages/index/index");
// offlineShopMessage.reserveRemindForAllFans("线下店王大锤测试活动", 1517905629, 1517905629, "有货", "pages/index/index");
}
/**
* 无法测试 现在线下店的小程序还没有上报
*/
@Test
public void realNameRegisterRemind() {
// offlineShopMessage.realNameRegisterRemind("线下店王大锤测试活动", 1517905629, 1517905629, "有货", "pages/index/index");
}
}
... ...
... ... @@ -9,7 +9,7 @@
class="org.springframework.amqp.support.converter.SimpleMessageConverter" />
<rabbit:connection-factory id="message-rabbitmq-connectionFactory"
addresses="192.168.104.199:30005" username="yoho"
addresses="192.168.102.45:5672" username="yoho"
password="yoho" virtual-host="yoho" />
<rabbit:template id="messageAmqpTemplate"
... ...