Authored by tanling

小程序消息模板

... ... @@ -67,7 +67,24 @@ public class SendScenes {
public static final String REFUND_SUCCESS = "REFUND_SUCCESS";
// 小程序模板消息
public static final String MINIAPP_MSG = "MINIAPP_MSG";
// 确认收货
public static final String MINI_GOODS_RECEIPT = "MINI_GOODS_RECEIPT";
// 退款
public static final String MINI_GOODS_REFUND = "MINI_GOODS_REFUND";
// 订单取消
public static final String MINI_ORDER_CANCEL = "MINI_ORDER_CANCEL";
// 订单发货
public static final String MINI_ORDER_DELIVERY = "MINI_ORDER_DELIVERY";
// 支付成功
public static final String MINI_PAY_SUCCESS = "MINI_PAY_SUCCESS";
// 待支付
public static final String MINI_WAITING_PAY = "MINI_WAITING_PAY";
//上门换货审核通过
public static final String HOME_CHANGE_VERIFY_PASS = "HOME_CHANGE_VERIFY_PASS";
... ...
package com.yoho.message.sdk.service.order.impl;
import com.yoho.message.sdk.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -275,7 +276,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
MessageCenterCommonEvent messageCenterCommonEvent = null;
if (miniappFlg == 1){
messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid);
messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_ORDER_CANCEL, orderCode, uid);
}else{
messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.ORDER_CANCEL, orderCode, uid);
}
... ... @@ -286,9 +287,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
messageCenterCommonEvent.putInParams("address", address);
messageCenterCommonEvent.putInParams("cancelReason", cancelReason);
messageCenterCommonEvent.putInParams("cancelTime", cancelTime);
messageCenterCommonEvent.putInParams("miniappFlg", miniappFlg);
messageCenterCommonEvent.putInParams("msgCode", 1002); // 订单取消
messageCenterCommonEvent.putInParams("cancelTime", DateUtils.long2DateStr(cancelTime, DateUtils.fullDateTimeFormat));
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
... ... @@ -307,15 +306,12 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
*/
public SendMessageRspBo waitingPay(String uid, String orderCode, String orderAmount, String productName) {
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid);
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_WAITING_PAY, orderCode, uid);
messageCenterCommonEvent.putInParams("orderCode", orderCode);
messageCenterCommonEvent.putInParams("orderAmount", orderAmount);
messageCenterCommonEvent.putInParams("productName", productName);
messageCenterCommonEvent.putInParams("miniappFlg", 1);
messageCenterCommonEvent.putInParams("msgCode", 1001); // 待支付
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
return new SendMessageRspBo(200, "SUCCESS");
... ... @@ -332,14 +328,11 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
*/
public SendMessageRspBo confirmOrder(String uid, String orderCode, int goodReceiptTime, String productName) {
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid);
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_GOODS_RECEIPT, orderCode, uid);
messageCenterCommonEvent.putInParams("orderCode", orderCode);
messageCenterCommonEvent.putInParams("productName", productName);
messageCenterCommonEvent.putInParams("goodReceiptTime", goodReceiptTime);
messageCenterCommonEvent.putInParams("miniappFlg", 1);
messageCenterCommonEvent.putInParams("msgCode", 1004); // 确认收货
messageCenterCommonEvent.putInParams("goodReceiptTime", DateUtils.long2DateStr(goodReceiptTime, DateUtils.fullDateTimeFormat));
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
... ... @@ -357,17 +350,14 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
*/
public SendMessageRspBo paySucess(String uid, String orderCode, int payTime, String productName, String goodReceiptAddress, String orderAmount) {
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid);
MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_PAY_SUCCESS, orderCode, uid);
messageCenterCommonEvent.putInParams("orderCode", orderCode);
messageCenterCommonEvent.putInParams("productName", productName);
messageCenterCommonEvent.putInParams("payTime", payTime);
messageCenterCommonEvent.putInParams("payTime", DateUtils.long2DateStr(payTime, DateUtils.fullDateTimeFormat));
messageCenterCommonEvent.putInParams("orderAmount", orderAmount);
messageCenterCommonEvent.putInParams("goodReceiptAddress", goodReceiptAddress);
messageCenterCommonEvent.putInParams("miniappFlg", 1);
messageCenterCommonEvent.putInParams("msgCode", 1000); // 订单支付成功
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
return new SendMessageRspBo(200, "SUCCESS");
... ... @@ -390,7 +380,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
MessageCenterCommonEvent messageCenterCommonEvent = null;
if (miniappFlg == 1){
messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid);
messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_GOODS_REFUND, orderCode, uid);
}else{
messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.REFUND_SUCCESS, orderCode, uid);
}
... ... @@ -399,12 +389,9 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
messageCenterCommonEvent.putInParams("orderAmount", orderAmount);
messageCenterCommonEvent.putInParams("payType", payType);
messageCenterCommonEvent.putInParams("productName", productName);
messageCenterCommonEvent.putInParams("refundTime", refundTime); // 时间戳
messageCenterCommonEvent.putInParams("refundTime", DateUtils.long2DateStr(refundTime, DateUtils.fullDateTimeFormat)); // 时间戳
messageCenterCommonEvent.putInParams("refundId", refundId);
messageCenterCommonEvent.putInParams("msgCode", 1005); // 退货成功
messageCenterCommonEvent.putInParams("miniappFlg", miniappFlg);
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
return new SendMessageRspBo(200, "SUCCESS");
... ... @@ -441,7 +428,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
MessageCenterCommonEvent messageCenterCommonEvent = null;
if (miniappFlg == 1){
messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid);
messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_ORDER_DELIVERY, orderCode, uid);
}else{
messageCenterCommonEvent = genMessageCenterCommonEvent(sendScene, orderCode, uid);
}
... ... @@ -455,13 +442,10 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
messageCenterCommonEvent.putInParams("arriveDate", arriveDate);
messageCenterCommonEvent.putInParams("miniappFlg", miniappFlg);
messageCenterCommonEvent.putInParams("msgCode",1003); // 订单发货 参见MsgTemplateTypeEnum
messageCenterCommonEvent.putInParams("productName",productName);
messageCenterCommonEvent.putInParams("deliveryType", deliveryType);
// 发货时间
messageCenterCommonEvent.putInParams("deliveryTime", deliveryTime);
messageCenterCommonEvent.putInParams("deliveryTime", DateUtils.long2DateStr(deliveryTime, DateUtils.fullDateTimeFormat));
messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
... ...
package com.yoho.message.sdk.utils;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* Created by chenchao on 2017/1/13.
*/
public final class DateUtils {
public static final String dateConnSeperator="-",
dateFormat = "yyyy-MM-dd",
fullDateTimeFormat = "yyyy-MM-dd HH:mm:ss";
public static int getCurrentTimeSeconds() {
long longTime = System.currentTimeMillis();
return (int) (longTime / 1000);
}
public static long getCurrentDateMillis(){
StringBuffer dateStr = new StringBuffer();
Calendar now = Calendar.getInstance();
int year= now.get(Calendar.YEAR);
int month= now.get(Calendar.MONTH) + 1;
int day=now.get(Calendar.DAY_OF_MONTH);
dateStr.append(year).append(dateConnSeperator)
.append(month).append(dateConnSeperator)
.append(day);
DateFormat format = new SimpleDateFormat(dateFormat) ;
long dateTime=0L;
try {
Date nowDate = format.parse(dateStr.toString());
dateTime=nowDate.getTime();
} catch (ParseException e) {
e.printStackTrace();
}
return dateTime;
}
public static void main(String[] args) {
System.out.println("DateUtils.getCurrentTimeSeconds() is :" + DateUtils.getCurrentTimeSeconds());
System.out.println("DateUtils.getCurrentDateMillis() is :" + DateUtils.getCurrentDateMillis());
long currentTimeMillis = System.currentTimeMillis();
System.out.println("System.currentTimeMillis() is :" + currentTimeMillis);
boolean flag = currentTimeMillis-DateUtils.getCurrentDateMillis()>0;
System.out.println("flag is : " + flag);
int subtime = 1484551195;
System.out.println("subtime 1484551195 is :" + subtime*1000L);
}
public static String long2DateStr(long time, String format) {
Date date = new Date(time);
SimpleDateFormat sdf = new SimpleDateFormat(format);
String dateStr = sdf.format(date);
return dateStr;
}
}
... ...