Authored by wangxin

增加扩展新客接口

package com.yoho.message.sdk.common.constants;
/**
* Created by yoho on 2017/6/27.
*/
public final class PromotionScenes {
//推荐成单奖励待发放
public static final String INVITE_COUPON_WAIT = "INVITE_COUPON_WAIT";
//推荐成单奖励已发放
public static final String INVITE_COUPON_SEND = "INVITE_COUPON_SEND";
}
... ...
package com.yoho.message.sdk.service.promotion;
import com.yoho.message.sdk.common.model.SendMessageRspBo;
/**
* Created by yoho on 2017/6/27.
*/
public interface ISendPromotionMessage {
SendMessageRspBo inviteCouponWait(String uid, String orderCode, String reward);
SendMessageRspBo inviteCouponSend(String uid, String orderCode, String reward);
}
... ...
package com.yoho.message.sdk.service.promotion.impl;
import com.yoho.message.sdk.common.constants.PromotionScenes;
import com.yoho.message.sdk.common.handler.MessageCenterMqHandler;
import com.yoho.message.sdk.common.model.MessageCenterCommonEvent;
import com.yoho.message.sdk.common.model.SendMessageRspBo;
import com.yoho.message.sdk.service.AbstractSendMessage;
import com.yoho.message.sdk.service.promotion.ISendPromotionMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by yoho on 2017/6/27.
*/
@Service
public class SendPromotionMessageImpl extends AbstractSendMessage implements ISendPromotionMessage {
@Autowired
private MessageCenterMqHandler messageCenterMqHandler;
@Override
public SendMessageRspBo inviteCouponWait(String uid, String orderCode, String reward) {
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(PromotionScenes.INVITE_COUPON_WAIT, orderCode, uid);
messageCenterCommonEvent.putInParams("amount", reward);
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
return new SendMessageRspBo(200, "SUCCESS");
}
@Override
public SendMessageRspBo inviteCouponSend(String uid, String orderCode, String reward) {
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(PromotionScenes.INVITE_COUPON_SEND, orderCode, uid);
messageCenterCommonEvent.putInParams("amount", reward);
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
return new SendMessageRspBo(200, "SUCCESS");
}
}
... ...
package com.yoho.message.sdk.test;
import com.yoho.message.sdk.service.promotion.ISendPromotionMessage;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Created by yoho on 2017/6/27.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:META-INF/spring/test-message-sdk-*.xml" })
public class TestPromotionMessage {
@Autowired
private ISendPromotionMessage sendPromotionMessage;
@Test
public void testInviteCouponWait() {
sendPromotionMessage.inviteCouponWait("8041612", "1234567", "50元优惠券");
}
@Test
public void testInviteCouponSend() {
sendPromotionMessage.inviteCouponSend("8041612", "1234567", "50元优惠券");
}
}
... ...