Authored by sailing-PC\sailing

Merge branch 'dev'

package com.yohoufo.order.event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
/**
* Created by chenchao on 2018/10/10.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BuyerCancelEvent extends Event{
private int uid;
private long orderCode;
}
... ...
... ... @@ -8,10 +8,10 @@ public interface TopicConstants {
/**
* 取消订单
*/
String SELLER_ORDER_AUTO_CANCEL = "seller_order_autoCancel";
String SELLER_ORDER_AUTO_CANCEL = "sellerOrder.autoCancel";
String BUYER_ORDER_AUTO_CANCEL = "buyer_order_autoCancel";
String BUYER_ORDER_AUTO_CANCEL = "buyerOrder.autoCancel";
/**
* 买家订单自动确认
* 7天自动确认
... ...
... ... @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
public class BuyerOrderAutoCancelDelayMsgConsumer extends AbsOrderAutoCancelDelayMsgConsumer {
@Autowired
private IBuyerOrderService sellerOrderCancelService;
private IBuyerOrderService buyerOrderService;
@Override
public String getTopic() {
... ... @@ -26,7 +26,7 @@ public class BuyerOrderAutoCancelDelayMsgConsumer extends AbsOrderAutoCancelDela
int uid = orderCancelEvent.getUid();
long orderCode = orderCancelEvent.getOrderCode();
OrderRequest req = OrderRequest.builder().uid(uid).orderCode(orderCode).build();
sellerOrderCancelService.cancelByAuto(req);
buyerOrderService.cancelByAuto(req);
}
@Override
... ...
package com.yohoufo.order.service.handler;
import com.google.common.eventbus.Subscribe;
import com.yohoufo.order.event.BuyerCancelEvent;
import com.yohoufo.order.event.IEventHandler;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.mq.producer.TradeMqSender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created by chenchao on 2018/10/10.
*/
@Component
public class BuyerOrderCancelAsyncHandler implements IEventHandler<BuyerCancelEvent> {
final Logger logger = LoggerFactory.getLogger(getClass());
public static final int DELAY_MINUTES_15_MIN = 15 ;
@Autowired
private TradeMqSender tradeMqSender;
@Override
@Subscribe
public void handle(BuyerCancelEvent event) {
logger.info("Subscribe Buyer timeout cancel delay msg, event {}", event);
tradeMqSender.send(TopicConstants.BUYER_ORDER_AUTO_CANCEL, event, DELAY_MINUTES_15_MIN);
}
}
... ...
... ... @@ -200,8 +200,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}
private void pushAutoCancelEvent(SellerOrderContext context){
OrderCancelEvent orderCancelEvent = OrderCancelEvent.builder().uid(context.getUid())
.orderCode(context.getOrderCode()).payExpire(15)
int uid = context.getUid();
long orderCode = context.getOrderCode();
log.info("seller order pushAutoCancelEvent, uid {}, orderCode {}", uid, orderCode);
OrderCancelEvent orderCancelEvent = OrderCancelEvent.builder().uid(uid)
.orderCode(orderCode).payExpire(15)
.actorType(TabType.SELL).cancelType(CancelType.TIME_OUT).build();
eventHandlerContainer.fireAsyncCancelEvent(orderCancelEvent);
}
... ...
... ... @@ -8,6 +8,8 @@ import com.yohoufo.order.event.Event;
import com.yohoufo.order.event.IEventHandler;
import com.yohoufo.order.event.OrderCancelEvent;
import com.yohoufo.order.service.impl.SellerOrderCancelService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -19,6 +21,7 @@ import java.util.Objects;
@Service
public class SellerOrderCancelHandler implements IEventHandler<Event> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private SellerOrderCancelService sellerOrderCancelService;
... ... @@ -26,6 +29,7 @@ public class SellerOrderCancelHandler implements IEventHandler<Event> {
@Override
@Subscribe
public void handle(Event event) {
logger.info("in SellerOrderCancelHandler.handle, event {}", event);
if (Objects.isNull(event)){
return;
}
... ...
package com.yohoufo.user.helper;
import org.apache.commons.lang3.StringUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class HideDataUtil {
/**
* 11位数字
*/
public static boolean isPhone(String phoneNo){
if (phoneNo == null)
return false;
String regEx = "^(\\d{11})$";
//String regEx2 = "^[0-9_]+$";//纯数字
Pattern pattern = Pattern.compile(regEx);
Matcher matcher = pattern.matcher(phoneNo);
return matcher.matches();
}
/**
*
* 方法描述 隐藏手机号中间位置字符,显示前三后三个字符
*
*/
public static String hidePhoneNo(String phoneNo) {
if(StringUtils.isBlank(phoneNo)) {
return phoneNo;
}
phoneNo = phoneNo.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
return phoneNo;
}
public static boolean isEmail(String string) {
if (string == null)
return false;
String regEx1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
Pattern p;
Matcher m;
p = Pattern.compile(regEx1);
m = p.matcher(string);
if (m.matches())
return true;
else
return false;
}
/**
* 只显示@前面的首位和末位
*/
public static String hideEmail(String email) {
if(StringUtils.isBlank(email)) {
return email;
}
//email = email.replaceAll("(\\w?)(\\w+)(\\w)(@\\w+\\.[a-z]+(\\.[a-z]+)?)", "$1****$3$4");
email = email.replaceAll("([\\S\\s]{3}?)([\\S\\s]+)(@\\w+\\.[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)?)", "$1****$3");
return email;
}
public static void main(String args[]){
String str="f f.f.wwwr3@163.COM.COM";
System.out.println(hideEmail(str));
str = "123";
System.out.println(isPhone(str));
System.out.println(hidePhoneNo(str));
System.out.println(str.substring(0,1)+"****"+str.substring(str.length()-1));
}
}
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.user.service.impl;
import com.yohoufo.dal.user.IUserAuthorizeInfoDao;
import com.yohoufo.dal.user.model.UserAuthorizeInfo;
import com.yohoufo.user.cache.CacheService;
import com.yohoufo.user.helper.HideDataUtil;
import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO;
import com.yohoufo.user.service.IRealNameAuthorizeService;
import org.slf4j.Logger;
... ... @@ -60,12 +61,28 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
authorizeInfo= userAuthorizeInfoDao.selectValidAuthorizeInfoByUid(uid);
logger.info("RealNameAuthorizeServiceImpl getValidAuthorizeInfo uid is {} ,database info is {} ",uid,authorizeInfo);
if(authorizeInfo!=null){
//把账号部分信息隐藏
if(HideDataUtil.isEmail(authorizeInfo.getAlipayAccount())){
authorizeInfo.setAlipayAccount(HideDataUtil.hideEmail(authorizeInfo.getAlipayAccount()));
}else if(HideDataUtil.isPhone(authorizeInfo.getAlipayAccount())){
authorizeInfo.setAlipayAccount(HideDataUtil.hidePhoneNo(authorizeInfo.getAlipayAccount()));
}else{
//即不是手机,又不是邮箱,只显示首末位
if(authorizeInfo.getAlipayAccount().length()>2){
authorizeInfo.setAlipayAccount(authorizeInfo.getAlipayAccount().substring(0,1)
+"****"
+authorizeInfo.getAlipayAccount().substring(authorizeInfo.getAlipayAccount().length()-1));
}
}
//保存到redis
cacheService.setUserAuthorizeInfo( authorizeInfo);
}
return authorizeInfo;
}
public void saveAuthorizeInfo(RealNameAuthorizeReqVO reqVO){
logger.info("real name saveAuthorizeInfo reqVO {}", reqVO);
int uid=reqVO.getUid();
... ...