Authored by sailing-PC\sailing

Merge branch 'dev'

  1 +package com.yohoufo.order.event;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Data;
  5 +import lombok.NoArgsConstructor;
  6 +import lombok.experimental.Builder;
  7 +
  8 +/**
  9 + * Created by chenchao on 2018/10/10.
  10 + */
  11 +@Data
  12 +@Builder
  13 +@NoArgsConstructor
  14 +@AllArgsConstructor
  15 +public class BuyerCancelEvent extends Event{
  16 +
  17 + private int uid;
  18 +
  19 + private long orderCode;
  20 +}
@@ -8,10 +8,10 @@ public interface TopicConstants { @@ -8,10 +8,10 @@ public interface TopicConstants {
8 /** 8 /**
9 * 取消订单 9 * 取消订单
10 */ 10 */
11 - String SELLER_ORDER_AUTO_CANCEL = "seller_order_autoCancel"; 11 + String SELLER_ORDER_AUTO_CANCEL = "sellerOrder.autoCancel";
12 12
13 13
14 - String BUYER_ORDER_AUTO_CANCEL = "buyer_order_autoCancel"; 14 + String BUYER_ORDER_AUTO_CANCEL = "buyerOrder.autoCancel";
15 /** 15 /**
16 * 买家订单自动确认 16 * 买家订单自动确认
17 * 7天自动确认 17 * 7天自动确认
@@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
14 public class BuyerOrderAutoCancelDelayMsgConsumer extends AbsOrderAutoCancelDelayMsgConsumer { 14 public class BuyerOrderAutoCancelDelayMsgConsumer extends AbsOrderAutoCancelDelayMsgConsumer {
15 15
16 @Autowired 16 @Autowired
17 - private IBuyerOrderService sellerOrderCancelService; 17 + private IBuyerOrderService buyerOrderService;
18 18
19 @Override 19 @Override
20 public String getTopic() { 20 public String getTopic() {
@@ -26,7 +26,7 @@ public class BuyerOrderAutoCancelDelayMsgConsumer extends AbsOrderAutoCancelDela @@ -26,7 +26,7 @@ public class BuyerOrderAutoCancelDelayMsgConsumer extends AbsOrderAutoCancelDela
26 int uid = orderCancelEvent.getUid(); 26 int uid = orderCancelEvent.getUid();
27 long orderCode = orderCancelEvent.getOrderCode(); 27 long orderCode = orderCancelEvent.getOrderCode();
28 OrderRequest req = OrderRequest.builder().uid(uid).orderCode(orderCode).build(); 28 OrderRequest req = OrderRequest.builder().uid(uid).orderCode(orderCode).build();
29 - sellerOrderCancelService.cancelByAuto(req); 29 + buyerOrderService.cancelByAuto(req);
30 } 30 }
31 31
32 @Override 32 @Override
  1 +package com.yohoufo.order.service.handler;
  2 +
  3 +import com.google.common.eventbus.Subscribe;
  4 +import com.yohoufo.order.event.BuyerCancelEvent;
  5 +import com.yohoufo.order.event.IEventHandler;
  6 +import com.yohoufo.order.mq.TopicConstants;
  7 +import com.yohoufo.order.mq.producer.TradeMqSender;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Component;
  12 +
  13 +/**
  14 + * Created by chenchao on 2018/10/10.
  15 + */
  16 +@Component
  17 +public class BuyerOrderCancelAsyncHandler implements IEventHandler<BuyerCancelEvent> {
  18 +
  19 + final Logger logger = LoggerFactory.getLogger(getClass());
  20 +
  21 + public static final int DELAY_MINUTES_15_MIN = 15 ;
  22 +
  23 + @Autowired
  24 + private TradeMqSender tradeMqSender;
  25 +
  26 +
  27 + @Override
  28 + @Subscribe
  29 + public void handle(BuyerCancelEvent event) {
  30 + logger.info("Subscribe Buyer timeout cancel delay msg, event {}", event);
  31 +
  32 + tradeMqSender.send(TopicConstants.BUYER_ORDER_AUTO_CANCEL, event, DELAY_MINUTES_15_MIN);
  33 + }
  34 +}
@@ -200,8 +200,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -200,8 +200,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
200 } 200 }
201 201
202 private void pushAutoCancelEvent(SellerOrderContext context){ 202 private void pushAutoCancelEvent(SellerOrderContext context){
203 - OrderCancelEvent orderCancelEvent = OrderCancelEvent.builder().uid(context.getUid())  
204 - .orderCode(context.getOrderCode()).payExpire(15) 203 + int uid = context.getUid();
  204 + long orderCode = context.getOrderCode();
  205 + log.info("seller order pushAutoCancelEvent, uid {}, orderCode {}", uid, orderCode);
  206 + OrderCancelEvent orderCancelEvent = OrderCancelEvent.builder().uid(uid)
  207 + .orderCode(orderCode).payExpire(15)
205 .actorType(TabType.SELL).cancelType(CancelType.TIME_OUT).build(); 208 .actorType(TabType.SELL).cancelType(CancelType.TIME_OUT).build();
206 eventHandlerContainer.fireAsyncCancelEvent(orderCancelEvent); 209 eventHandlerContainer.fireAsyncCancelEvent(orderCancelEvent);
207 } 210 }
@@ -8,6 +8,8 @@ import com.yohoufo.order.event.Event; @@ -8,6 +8,8 @@ import com.yohoufo.order.event.Event;
8 import com.yohoufo.order.event.IEventHandler; 8 import com.yohoufo.order.event.IEventHandler;
9 import com.yohoufo.order.event.OrderCancelEvent; 9 import com.yohoufo.order.event.OrderCancelEvent;
10 import com.yohoufo.order.service.impl.SellerOrderCancelService; 10 import com.yohoufo.order.service.impl.SellerOrderCancelService;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
11 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 14 import org.springframework.stereotype.Service;
13 15
@@ -19,6 +21,7 @@ import java.util.Objects; @@ -19,6 +21,7 @@ import java.util.Objects;
19 @Service 21 @Service
20 public class SellerOrderCancelHandler implements IEventHandler<Event> { 22 public class SellerOrderCancelHandler implements IEventHandler<Event> {
21 23
  24 + private final Logger logger = LoggerFactory.getLogger(getClass());
22 @Autowired 25 @Autowired
23 private SellerOrderCancelService sellerOrderCancelService; 26 private SellerOrderCancelService sellerOrderCancelService;
24 27
@@ -26,6 +29,7 @@ public class SellerOrderCancelHandler implements IEventHandler<Event> { @@ -26,6 +29,7 @@ public class SellerOrderCancelHandler implements IEventHandler<Event> {
26 @Override 29 @Override
27 @Subscribe 30 @Subscribe
28 public void handle(Event event) { 31 public void handle(Event event) {
  32 + logger.info("in SellerOrderCancelHandler.handle, event {}", event);
29 if (Objects.isNull(event)){ 33 if (Objects.isNull(event)){
30 return; 34 return;
31 } 35 }
  1 +package com.yohoufo.user.helper;
  2 +
  3 +import org.apache.commons.lang3.StringUtils;
  4 +
  5 +import java.util.regex.Matcher;
  6 +import java.util.regex.Pattern;
  7 +
  8 +public class HideDataUtil {
  9 +
  10 + /**
  11 + * 11位数字
  12 + */
  13 + public static boolean isPhone(String phoneNo){
  14 + if (phoneNo == null)
  15 + return false;
  16 +
  17 + String regEx = "^(\\d{11})$";
  18 + //String regEx2 = "^[0-9_]+$";//纯数字
  19 + Pattern pattern = Pattern.compile(regEx);
  20 + Matcher matcher = pattern.matcher(phoneNo);
  21 +
  22 + return matcher.matches();
  23 + }
  24 +
  25 + /**
  26 + *
  27 + * 方法描述 隐藏手机号中间位置字符,显示前三后三个字符
  28 + *
  29 + */
  30 + public static String hidePhoneNo(String phoneNo) {
  31 + if(StringUtils.isBlank(phoneNo)) {
  32 + return phoneNo;
  33 + }
  34 +
  35 + phoneNo = phoneNo.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
  36 +
  37 + return phoneNo;
  38 + }
  39 +
  40 +
  41 + public static boolean isEmail(String string) {
  42 + if (string == null)
  43 + return false;
  44 + String regEx1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
  45 + Pattern p;
  46 + Matcher m;
  47 + p = Pattern.compile(regEx1);
  48 + m = p.matcher(string);
  49 + if (m.matches())
  50 + return true;
  51 + else
  52 + return false;
  53 + }
  54 +
  55 +
  56 + /**
  57 + * 只显示@前面的首位和末位
  58 + */
  59 + public static String hideEmail(String email) {
  60 + if(StringUtils.isBlank(email)) {
  61 + return email;
  62 + }
  63 + //email = email.replaceAll("(\\w?)(\\w+)(\\w)(@\\w+\\.[a-z]+(\\.[a-z]+)?)", "$1****$3$4");
  64 + email = email.replaceAll("([\\S\\s]{3}?)([\\S\\s]+)(@\\w+\\.[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)?)", "$1****$3");
  65 + return email;
  66 + }
  67 +
  68 + public static void main(String args[]){
  69 + String str="f f.f.wwwr3@163.COM.COM";
  70 + System.out.println(hideEmail(str));
  71 + str = "123";
  72 + System.out.println(isPhone(str));
  73 + System.out.println(hidePhoneNo(str));
  74 +
  75 + System.out.println(str.substring(0,1)+"****"+str.substring(str.length()-1));
  76 + }
  77 +
  78 +}
@@ -3,6 +3,7 @@ package com.yohoufo.user.service.impl; @@ -3,6 +3,7 @@ package com.yohoufo.user.service.impl;
3 import com.yohoufo.dal.user.IUserAuthorizeInfoDao; 3 import com.yohoufo.dal.user.IUserAuthorizeInfoDao;
4 import com.yohoufo.dal.user.model.UserAuthorizeInfo; 4 import com.yohoufo.dal.user.model.UserAuthorizeInfo;
5 import com.yohoufo.user.cache.CacheService; 5 import com.yohoufo.user.cache.CacheService;
  6 +import com.yohoufo.user.helper.HideDataUtil;
6 import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO; 7 import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO;
7 import com.yohoufo.user.service.IRealNameAuthorizeService; 8 import com.yohoufo.user.service.IRealNameAuthorizeService;
8 import org.slf4j.Logger; 9 import org.slf4j.Logger;
@@ -60,12 +61,28 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { @@ -60,12 +61,28 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
60 authorizeInfo= userAuthorizeInfoDao.selectValidAuthorizeInfoByUid(uid); 61 authorizeInfo= userAuthorizeInfoDao.selectValidAuthorizeInfoByUid(uid);
61 logger.info("RealNameAuthorizeServiceImpl getValidAuthorizeInfo uid is {} ,database info is {} ",uid,authorizeInfo); 62 logger.info("RealNameAuthorizeServiceImpl getValidAuthorizeInfo uid is {} ,database info is {} ",uid,authorizeInfo);
62 if(authorizeInfo!=null){ 63 if(authorizeInfo!=null){
  64 + //把账号部分信息隐藏
  65 + if(HideDataUtil.isEmail(authorizeInfo.getAlipayAccount())){
  66 + authorizeInfo.setAlipayAccount(HideDataUtil.hideEmail(authorizeInfo.getAlipayAccount()));
  67 + }else if(HideDataUtil.isPhone(authorizeInfo.getAlipayAccount())){
  68 + authorizeInfo.setAlipayAccount(HideDataUtil.hidePhoneNo(authorizeInfo.getAlipayAccount()));
  69 + }else{
  70 + //即不是手机,又不是邮箱,只显示首末位
  71 + if(authorizeInfo.getAlipayAccount().length()>2){
  72 + authorizeInfo.setAlipayAccount(authorizeInfo.getAlipayAccount().substring(0,1)
  73 + +"****"
  74 + +authorizeInfo.getAlipayAccount().substring(authorizeInfo.getAlipayAccount().length()-1));
  75 + }
  76 + }
  77 +
63 //保存到redis 78 //保存到redis
64 cacheService.setUserAuthorizeInfo( authorizeInfo); 79 cacheService.setUserAuthorizeInfo( authorizeInfo);
65 } 80 }
66 return authorizeInfo; 81 return authorizeInfo;
67 } 82 }
68 83
  84 +
  85 +
69 public void saveAuthorizeInfo(RealNameAuthorizeReqVO reqVO){ 86 public void saveAuthorizeInfo(RealNameAuthorizeReqVO reqVO){
70 logger.info("real name saveAuthorizeInfo reqVO {}", reqVO); 87 logger.info("real name saveAuthorizeInfo reqVO {}", reqVO);
71 int uid=reqVO.getUid(); 88 int uid=reqVO.getUid();