Showing
4 changed files
with
93 additions
and
0 deletions
1 | +package com.yoho.message.sdk.common.constants; | ||
2 | + | ||
3 | +/** | ||
4 | + * Created by yoho on 2017/6/27. | ||
5 | + */ | ||
6 | +public final class PromotionScenes { | ||
7 | + | ||
8 | + //推荐成单奖励待发放 | ||
9 | + public static final String INVITE_COUPON_WAIT = "INVITE_COUPON_WAIT"; | ||
10 | + | ||
11 | + //推荐成单奖励已发放 | ||
12 | + public static final String INVITE_COUPON_SEND = "INVITE_COUPON_SEND"; | ||
13 | +} |
1 | +package com.yoho.message.sdk.service.promotion; | ||
2 | + | ||
3 | +import com.yoho.message.sdk.common.model.SendMessageRspBo; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by yoho on 2017/6/27. | ||
7 | + */ | ||
8 | +public interface ISendPromotionMessage { | ||
9 | + | ||
10 | + SendMessageRspBo inviteCouponWait(String uid, String orderCode, String reward); | ||
11 | + | ||
12 | + SendMessageRspBo inviteCouponSend(String uid, String orderCode, String reward); | ||
13 | +} |
1 | +package com.yoho.message.sdk.service.promotion.impl; | ||
2 | + | ||
3 | +import com.yoho.message.sdk.common.constants.PromotionScenes; | ||
4 | +import com.yoho.message.sdk.common.handler.MessageCenterMqHandler; | ||
5 | +import com.yoho.message.sdk.common.model.MessageCenterCommonEvent; | ||
6 | +import com.yoho.message.sdk.common.model.SendMessageRspBo; | ||
7 | +import com.yoho.message.sdk.service.AbstractSendMessage; | ||
8 | +import com.yoho.message.sdk.service.promotion.ISendPromotionMessage; | ||
9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
10 | +import org.springframework.stereotype.Service; | ||
11 | + | ||
12 | +/** | ||
13 | + * Created by yoho on 2017/6/27. | ||
14 | + */ | ||
15 | +@Service | ||
16 | +public class SendPromotionMessageImpl extends AbstractSendMessage implements ISendPromotionMessage { | ||
17 | + | ||
18 | + @Autowired | ||
19 | + private MessageCenterMqHandler messageCenterMqHandler; | ||
20 | + | ||
21 | + @Override | ||
22 | + public SendMessageRspBo inviteCouponWait(String uid, String orderCode, String reward) { | ||
23 | + MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(PromotionScenes.INVITE_COUPON_WAIT, orderCode, uid); | ||
24 | + messageCenterCommonEvent.putInParams("amount", reward); | ||
25 | + | ||
26 | + messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent); | ||
27 | + return new SendMessageRspBo(200, "SUCCESS"); | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public SendMessageRspBo inviteCouponSend(String uid, String orderCode, String reward) { | ||
32 | + MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(PromotionScenes.INVITE_COUPON_SEND, orderCode, uid); | ||
33 | + messageCenterCommonEvent.putInParams("amount", reward); | ||
34 | + | ||
35 | + messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent); | ||
36 | + return new SendMessageRspBo(200, "SUCCESS"); | ||
37 | + } | ||
38 | +} |
1 | +package com.yoho.message.sdk.test; | ||
2 | + | ||
3 | +import com.yoho.message.sdk.service.promotion.ISendPromotionMessage; | ||
4 | +import org.junit.Test; | ||
5 | +import org.junit.runner.RunWith; | ||
6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
7 | +import org.springframework.test.context.ContextConfiguration; | ||
8 | +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
9 | + | ||
10 | +/** | ||
11 | + * Created by yoho on 2017/6/27. | ||
12 | + */ | ||
13 | +@RunWith(SpringJUnit4ClassRunner.class) | ||
14 | +@ContextConfiguration(locations = { "classpath*:META-INF/spring/test-message-sdk-*.xml" }) | ||
15 | +public class TestPromotionMessage { | ||
16 | + | ||
17 | + @Autowired | ||
18 | + private ISendPromotionMessage sendPromotionMessage; | ||
19 | + | ||
20 | + @Test | ||
21 | + public void testInviteCouponWait() { | ||
22 | + sendPromotionMessage.inviteCouponWait("8041612", "1234567", "50元优惠券"); | ||
23 | + } | ||
24 | + | ||
25 | + @Test | ||
26 | + public void testInviteCouponSend() { | ||
27 | + sendPromotionMessage.inviteCouponSend("8041612", "1234567", "50元优惠券"); | ||
28 | + } | ||
29 | +} |
-
Please register or login to post a comment