UFOSendServiceImpl.java 3.15 KB
package com.yoho.message.sdk.service.ufo;

import com.yoho.message.sdk.common.constants.UFOScenes;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * Created by min.ling on 2019/1/29.
 */
@Service
public class UFOSendServiceImpl implements IUFOSendService{

    @Autowired
    private MessageCenterMqHandler messageCenterMqHandler;

    @Override
    public SendMessageRspBo sendAdjustPrice(String uid,int productCount) {
        MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(UFOScenes.UFO_PRICE_ADJUST,uid,0,uid);
        messageCenterCommonEvent.putInParams("productCount", productCount);
        messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);

        return new SendMessageRspBo(200, "SUCCESS");
    }

    public MessageCenterCommonEvent genMessageCenterCommonEvent(String sendScene, String sendSceneKey,int miniappType,String uid) {
        List<String> uids = Collections.singletonList(uid);
        return new MessageCenterCommonEvent(sendScene, sendSceneKey,miniappType, uids);
    }

    /**
     * 更低出售价提醒 商家已入驻
     * @param uid
     * @param productName 商品名称
     * @param size  尺寸
     * @param goodsNumber 货号
     * @param salePrice 提醒的更低售价
     * @param productSkn 商品skn
     * @return
     */
    public SendMessageRspBo sendLessPriceEnter(String uid,String productName,String size,String goodsNumber,String salePrice,String productSkn){
        MessageCenterCommonEvent commonEvent = genMessageCenterCommonEvent(UFOScenes.UFO_LESS_PRICE_ENTER,uid,0,uid);
        commonEvent.putInParams("productName",productName);
        commonEvent.putInParams("size",size);
        commonEvent.putInParams("goodsNumber",goodsNumber);
        commonEvent.putInParams("productSkn",productSkn);
        commonEvent.putInParams("salePrice",salePrice);
        messageCenterMqHandler.sendMessageToMq(commonEvent);
        return new SendMessageRspBo(200, "SUCCESS");
    }


    /**
     * 更低出售价提醒 商家未入驻
     * @param uid
     * @param productName 商品名称
     * @param size  尺寸
     * @param goodsNumber 货号
     *  @param salePrice 提醒的更低售价
     * @param orderCode 订单编号
     * @return
     */
    public SendMessageRspBo sendLessPrice(String uid,String productName,String size,String goodsNumber,String salePrice,String orderCode){
        MessageCenterCommonEvent commonEvent = genMessageCenterCommonEvent(UFOScenes.UFO_LESS_PRICE,uid,0,uid);
        commonEvent.putInParams("productName",productName);
        commonEvent.putInParams("size",size);
        commonEvent.putInParams("goodsNumber",goodsNumber);
        commonEvent.putInParams("orderCode",orderCode);
        commonEvent.putInParams("salePrice",salePrice);
        messageCenterMqHandler.sendMessageToMq(commonEvent);
        return new SendMessageRspBo(200, "SUCCESS");
    }
}