Authored by tanling

小程序消息模板

@@ -67,7 +67,24 @@ public class SendScenes { @@ -67,7 +67,24 @@ public class SendScenes {
67 public static final String REFUND_SUCCESS = "REFUND_SUCCESS"; 67 public static final String REFUND_SUCCESS = "REFUND_SUCCESS";
68 68
69 // 小程序模板消息 69 // 小程序模板消息
70 - public static final String MINIAPP_MSG = "MINIAPP_MSG"; 70 + // 确认收货
  71 + public static final String MINI_GOODS_RECEIPT = "MINI_GOODS_RECEIPT";
  72 +
  73 + // 退款
  74 + public static final String MINI_GOODS_REFUND = "MINI_GOODS_REFUND";
  75 +
  76 + // 订单取消
  77 + public static final String MINI_ORDER_CANCEL = "MINI_ORDER_CANCEL";
  78 +
  79 + // 订单发货
  80 + public static final String MINI_ORDER_DELIVERY = "MINI_ORDER_DELIVERY";
  81 +
  82 + // 支付成功
  83 + public static final String MINI_PAY_SUCCESS = "MINI_PAY_SUCCESS";
  84 +
  85 + // 待支付
  86 + public static final String MINI_WAITING_PAY = "MINI_WAITING_PAY";
  87 +
71 88
72 //上门换货审核通过 89 //上门换货审核通过
73 public static final String HOME_CHANGE_VERIFY_PASS = "HOME_CHANGE_VERIFY_PASS"; 90 public static final String HOME_CHANGE_VERIFY_PASS = "HOME_CHANGE_VERIFY_PASS";
1 package com.yoho.message.sdk.service.order.impl; 1 package com.yoho.message.sdk.service.order.impl;
2 2
  3 +import com.yoho.message.sdk.utils.DateUtils;
3 import org.springframework.beans.factory.annotation.Autowired; 4 import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.stereotype.Service; 5 import org.springframework.stereotype.Service;
5 6
@@ -275,7 +276,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr @@ -275,7 +276,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
275 276
276 MessageCenterCommonEvent messageCenterCommonEvent = null; 277 MessageCenterCommonEvent messageCenterCommonEvent = null;
277 if (miniappFlg == 1){ 278 if (miniappFlg == 1){
278 - messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid); 279 + messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_ORDER_CANCEL, orderCode, uid);
279 }else{ 280 }else{
280 messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.ORDER_CANCEL, orderCode, uid); 281 messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.ORDER_CANCEL, orderCode, uid);
281 } 282 }
@@ -286,9 +287,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr @@ -286,9 +287,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
286 messageCenterCommonEvent.putInParams("address", address); 287 messageCenterCommonEvent.putInParams("address", address);
287 288
288 messageCenterCommonEvent.putInParams("cancelReason", cancelReason); 289 messageCenterCommonEvent.putInParams("cancelReason", cancelReason);
289 - messageCenterCommonEvent.putInParams("cancelTime", cancelTime);  
290 - messageCenterCommonEvent.putInParams("miniappFlg", miniappFlg);  
291 - messageCenterCommonEvent.putInParams("msgCode", 1002); // 订单取消 290 + messageCenterCommonEvent.putInParams("cancelTime", DateUtils.long2DateStr(cancelTime, DateUtils.fullDateTimeFormat));
292 291
293 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent); 292 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
294 293
@@ -307,15 +306,12 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr @@ -307,15 +306,12 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
307 */ 306 */
308 public SendMessageRspBo waitingPay(String uid, String orderCode, String orderAmount, String productName) { 307 public SendMessageRspBo waitingPay(String uid, String orderCode, String orderAmount, String productName) {
309 308
310 - MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid); 309 + MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_WAITING_PAY, orderCode, uid);
311 310
312 messageCenterCommonEvent.putInParams("orderCode", orderCode); 311 messageCenterCommonEvent.putInParams("orderCode", orderCode);
313 messageCenterCommonEvent.putInParams("orderAmount", orderAmount); 312 messageCenterCommonEvent.putInParams("orderAmount", orderAmount);
314 messageCenterCommonEvent.putInParams("productName", productName); 313 messageCenterCommonEvent.putInParams("productName", productName);
315 314
316 - messageCenterCommonEvent.putInParams("miniappFlg", 1);  
317 - messageCenterCommonEvent.putInParams("msgCode", 1001); // 待支付  
318 -  
319 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent); 315 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
320 316
321 return new SendMessageRspBo(200, "SUCCESS"); 317 return new SendMessageRspBo(200, "SUCCESS");
@@ -332,14 +328,11 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr @@ -332,14 +328,11 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
332 */ 328 */
333 public SendMessageRspBo confirmOrder(String uid, String orderCode, int goodReceiptTime, String productName) { 329 public SendMessageRspBo confirmOrder(String uid, String orderCode, int goodReceiptTime, String productName) {
334 330
335 - MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid); 331 + MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_GOODS_RECEIPT, orderCode, uid);
336 332
337 messageCenterCommonEvent.putInParams("orderCode", orderCode); 333 messageCenterCommonEvent.putInParams("orderCode", orderCode);
338 messageCenterCommonEvent.putInParams("productName", productName); 334 messageCenterCommonEvent.putInParams("productName", productName);
339 - messageCenterCommonEvent.putInParams("goodReceiptTime", goodReceiptTime);  
340 -  
341 - messageCenterCommonEvent.putInParams("miniappFlg", 1);  
342 - messageCenterCommonEvent.putInParams("msgCode", 1004); // 确认收货 335 + messageCenterCommonEvent.putInParams("goodReceiptTime", DateUtils.long2DateStr(goodReceiptTime, DateUtils.fullDateTimeFormat));
343 336
344 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent); 337 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
345 338
@@ -357,17 +350,14 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr @@ -357,17 +350,14 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
357 */ 350 */
358 public SendMessageRspBo paySucess(String uid, String orderCode, int payTime, String productName, String goodReceiptAddress, String orderAmount) { 351 public SendMessageRspBo paySucess(String uid, String orderCode, int payTime, String productName, String goodReceiptAddress, String orderAmount) {
359 352
360 - MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid); 353 + MessageCenterCommonEvent messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_PAY_SUCCESS, orderCode, uid);
361 354
362 messageCenterCommonEvent.putInParams("orderCode", orderCode); 355 messageCenterCommonEvent.putInParams("orderCode", orderCode);
363 messageCenterCommonEvent.putInParams("productName", productName); 356 messageCenterCommonEvent.putInParams("productName", productName);
364 - messageCenterCommonEvent.putInParams("payTime", payTime); 357 + messageCenterCommonEvent.putInParams("payTime", DateUtils.long2DateStr(payTime, DateUtils.fullDateTimeFormat));
365 messageCenterCommonEvent.putInParams("orderAmount", orderAmount); 358 messageCenterCommonEvent.putInParams("orderAmount", orderAmount);
366 messageCenterCommonEvent.putInParams("goodReceiptAddress", goodReceiptAddress); 359 messageCenterCommonEvent.putInParams("goodReceiptAddress", goodReceiptAddress);
367 360
368 - messageCenterCommonEvent.putInParams("miniappFlg", 1);  
369 - messageCenterCommonEvent.putInParams("msgCode", 1000); // 订单支付成功  
370 -  
371 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent); 361 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
372 362
373 return new SendMessageRspBo(200, "SUCCESS"); 363 return new SendMessageRspBo(200, "SUCCESS");
@@ -390,7 +380,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr @@ -390,7 +380,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
390 380
391 MessageCenterCommonEvent messageCenterCommonEvent = null; 381 MessageCenterCommonEvent messageCenterCommonEvent = null;
392 if (miniappFlg == 1){ 382 if (miniappFlg == 1){
393 - messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid); 383 + messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_GOODS_REFUND, orderCode, uid);
394 }else{ 384 }else{
395 messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.REFUND_SUCCESS, orderCode, uid); 385 messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.REFUND_SUCCESS, orderCode, uid);
396 } 386 }
@@ -399,12 +389,9 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr @@ -399,12 +389,9 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
399 messageCenterCommonEvent.putInParams("orderAmount", orderAmount); 389 messageCenterCommonEvent.putInParams("orderAmount", orderAmount);
400 messageCenterCommonEvent.putInParams("payType", payType); 390 messageCenterCommonEvent.putInParams("payType", payType);
401 messageCenterCommonEvent.putInParams("productName", productName); 391 messageCenterCommonEvent.putInParams("productName", productName);
402 - messageCenterCommonEvent.putInParams("refundTime", refundTime); // 时间戳 392 + messageCenterCommonEvent.putInParams("refundTime", DateUtils.long2DateStr(refundTime, DateUtils.fullDateTimeFormat)); // 时间戳
403 messageCenterCommonEvent.putInParams("refundId", refundId); 393 messageCenterCommonEvent.putInParams("refundId", refundId);
404 394
405 - messageCenterCommonEvent.putInParams("msgCode", 1005); // 退货成功  
406 - messageCenterCommonEvent.putInParams("miniappFlg", miniappFlg);  
407 -  
408 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent); 395 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
409 396
410 return new SendMessageRspBo(200, "SUCCESS"); 397 return new SendMessageRspBo(200, "SUCCESS");
@@ -441,7 +428,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr @@ -441,7 +428,7 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
441 428
442 MessageCenterCommonEvent messageCenterCommonEvent = null; 429 MessageCenterCommonEvent messageCenterCommonEvent = null;
443 if (miniappFlg == 1){ 430 if (miniappFlg == 1){
444 - messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINIAPP_MSG, orderCode, uid); 431 + messageCenterCommonEvent = genMessageCenterCommonEvent(SendScenes.MINI_ORDER_DELIVERY, orderCode, uid);
445 }else{ 432 }else{
446 messageCenterCommonEvent = genMessageCenterCommonEvent(sendScene, orderCode, uid); 433 messageCenterCommonEvent = genMessageCenterCommonEvent(sendScene, orderCode, uid);
447 } 434 }
@@ -455,13 +442,10 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr @@ -455,13 +442,10 @@ public class SendOrderMessageImpl extends AbstractSendMessage implements ISendOr
455 messageCenterCommonEvent.putInParams("arriveDate", arriveDate); 442 messageCenterCommonEvent.putInParams("arriveDate", arriveDate);
456 443
457 444
458 - messageCenterCommonEvent.putInParams("miniappFlg", miniappFlg);  
459 - messageCenterCommonEvent.putInParams("msgCode",1003); // 订单发货 参见MsgTemplateTypeEnum  
460 messageCenterCommonEvent.putInParams("productName",productName); 445 messageCenterCommonEvent.putInParams("productName",productName);
461 messageCenterCommonEvent.putInParams("deliveryType", deliveryType); 446 messageCenterCommonEvent.putInParams("deliveryType", deliveryType);
462 // 发货时间 447 // 发货时间
463 - messageCenterCommonEvent.putInParams("deliveryTime", deliveryTime);  
464 - 448 + messageCenterCommonEvent.putInParams("deliveryTime", DateUtils.long2DateStr(deliveryTime, DateUtils.fullDateTimeFormat));
465 449
466 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent); 450 messageCenterMqHandler.sendMessageToMq(messageCenterCommonEvent);
467 451
  1 +package com.yoho.message.sdk.utils;
  2 +
  3 +import java.text.DateFormat;
  4 +import java.text.ParseException;
  5 +import java.text.SimpleDateFormat;
  6 +import java.util.Calendar;
  7 +import java.util.Date;
  8 +
  9 +/**
  10 + * Created by chenchao on 2017/1/13.
  11 + */
  12 +public final class DateUtils {
  13 + public static final String dateConnSeperator="-",
  14 +
  15 + dateFormat = "yyyy-MM-dd",
  16 +
  17 + fullDateTimeFormat = "yyyy-MM-dd HH:mm:ss";
  18 +
  19 + public static int getCurrentTimeSeconds() {
  20 + long longTime = System.currentTimeMillis();
  21 + return (int) (longTime / 1000);
  22 + }
  23 +
  24 +
  25 +
  26 +
  27 + public static long getCurrentDateMillis(){
  28 + StringBuffer dateStr = new StringBuffer();
  29 + Calendar now = Calendar.getInstance();
  30 + int year= now.get(Calendar.YEAR);
  31 + int month= now.get(Calendar.MONTH) + 1;
  32 + int day=now.get(Calendar.DAY_OF_MONTH);
  33 + dateStr.append(year).append(dateConnSeperator)
  34 + .append(month).append(dateConnSeperator)
  35 + .append(day);
  36 + DateFormat format = new SimpleDateFormat(dateFormat) ;
  37 + long dateTime=0L;
  38 + try {
  39 + Date nowDate = format.parse(dateStr.toString());
  40 + dateTime=nowDate.getTime();
  41 + } catch (ParseException e) {
  42 + e.printStackTrace();
  43 + }
  44 + return dateTime;
  45 + }
  46 +
  47 + public static void main(String[] args) {
  48 + System.out.println("DateUtils.getCurrentTimeSeconds() is :" + DateUtils.getCurrentTimeSeconds());
  49 + System.out.println("DateUtils.getCurrentDateMillis() is :" + DateUtils.getCurrentDateMillis());
  50 + long currentTimeMillis = System.currentTimeMillis();
  51 + System.out.println("System.currentTimeMillis() is :" + currentTimeMillis);
  52 +
  53 + boolean flag = currentTimeMillis-DateUtils.getCurrentDateMillis()>0;
  54 + System.out.println("flag is : " + flag);
  55 +
  56 + int subtime = 1484551195;
  57 + System.out.println("subtime 1484551195 is :" + subtime*1000L);
  58 +
  59 +
  60 + }
  61 +
  62 + public static String long2DateStr(long time, String format) {
  63 + Date date = new Date(time);
  64 + SimpleDateFormat sdf = new SimpleDateFormat(format);
  65 + String dateStr = sdf.format(date);
  66 + return dateStr;
  67 + }
  68 +}