Authored by Lixiaodi

Merge branch 'test6.8.7' of http://git.yoho.cn/ufo/yohoufo-fore into test6.8.7

... ... @@ -18,6 +18,29 @@ public class UserInfoHiddenHelper {
private static final String PRIVACY_CHARS = "****";
/**
* 提取11位数字
*/
public static List<String> fetchPhone(String str){
List<String> ls = new ArrayList<>();
if (str == null)
return ls;
String regEx = "(\\d{11})";
//String regEx2 = "^[0-9_]+$";//纯数字
Pattern pattern = Pattern.compile(regEx);
// 创建匹配给定输入与此模式的匹配器。
Matcher matcher = pattern.matcher(str);
//查找字符串中是否有符合的子字符串
while(matcher.find()){
ls.add(matcher.group());
//查找到符合的即输出
//System.out.println("查询到一个符合的手机号码:"+);
}
return ls;
}
/**
* 11位数字
*/
public static boolean isPhone(String phoneNo){
... ... @@ -102,15 +125,7 @@ public class UserInfoHiddenHelper {
}
}
public static void main(String[] args) throws IOException {
List<String> lines = new ArrayList<>();
for (String str : lines){
System.out.println(str.trim()+"============"+getHiddenAddress(str));
}
}
}
... ...
... ... @@ -11,6 +11,8 @@ public interface OrderOverTimeMapper {
int insertShamSendTime(OrderOverTime record);
int insertMiniFaultConfirmTime(OrderOverTime record);
List<OrderOverTime> selectByOrderCodes(@Param(value = "orderCodeList") List<Long> orderCodeList);
OrderOverTime selectByOrderCode(@Param(value = "orderCode")Long orderCode);
... ...
... ... @@ -13,6 +13,8 @@ public class OrderOverTime {
private Integer shamSendTime;
private Integer miniFaultConfirmMinutes;
public OrderOverTime() {
}
... ... @@ -27,6 +29,14 @@ public class OrderOverTime {
this.orderCode = orderCode;
}
public Integer getMiniFaultConfirmMinutes() {
return miniFaultConfirmMinutes;
}
public void setMiniFaultConfirmMinutes(Integer miniFaultConfirmMinutes) {
this.miniFaultConfirmMinutes = miniFaultConfirmMinutes;
}
public Integer getDeliveryMinutes() {
return deliveryMinutes;
}
... ...
... ... @@ -7,6 +7,7 @@
<result column="delivery_time" property="deliveryTime" jdbcType="INTEGER" />
<result column="delivery_minutes" property="deliveryMinutes" jdbcType="INTEGER" />
<result column="sham_send_time" property="shamSendTime" jdbcType="INTEGER" />
<result column="mini_fault_confirm_minutes" property="miniFaultConfirmMinutes" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, order_code, delivery_time, delivery_minutes, sham_send_time
... ... @@ -21,6 +22,11 @@
values (#{orderCode,jdbcType=BIGINT}, #{shamSendTime,jdbcType=INTEGER})
ON DUPLICATE KEY UPDATE sham_send_time = #{shamSendTime,jdbcType=INTEGER}
</insert>
<insert id="insertMiniFaultConfirmTime" parameterType="com.yohoufo.dal.order.model.OrderOverTime" >
insert into order_over_time (order_code, mini_fault_confirm_minutes)
values (#{orderCode,jdbcType=BIGINT}, #{miniFaultConfirmMinutes,jdbcType=INTEGER})
ON DUPLICATE KEY UPDATE mini_fault_confirm_minutes = #{miniFaultConfirmMinutes,jdbcType=INTEGER}
</insert>
<select id="selectByOrderCodes" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
... ...
... ... @@ -144,7 +144,7 @@ public class AppraiseController {
@RequestMapping(value="/deliveryGoodsToBuyer")
@IgnoreSession
@IgnoreSignature
public ApiResponse deliveryGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo){
public ApiResponse deliveryGoodsToBuyer(@RequestBody AppraiseExpressInfoBo appraiseExpressInfoBo){
logger.info("in deliveryGoodsToBuyer, appraiseExpressInfoBo {}", appraiseExpressInfoBo);
appraiseService.deliveryGoodsToBuyer(appraiseExpressInfoBo);
return new ApiResponse();
... ...
... ... @@ -19,7 +19,8 @@ public interface DelayTime {
int SELLER_ORDER_WAITING_PAY = 15;
//瑕疵等待用户确认的超时时间,24小时
int MINI_FAULT_CONFIRM_OUTER_TIME_MINUTE=24*60;
//修改为48小时 2019-03-01 craig.qin
int MINI_FAULT_CONFIRM_OUTER_TIME_MINUTE=48*60;
//卖家发货后,系统判定虚假发货的超时时间,96小时
int CANCEL_SHAM_DELIVERY_TIME_MINUTE=96*60;
... ...
... ... @@ -2,10 +2,12 @@ package com.yohoufo.order.service.handler;
import com.google.common.eventbus.Subscribe;
import com.yohoufo.common.alarm.IEventHandler;
import com.yohoufo.dal.order.model.OrderOverTime;
import com.yohoufo.order.event.BuyerMiniFaultOuterTimeEvent;
import com.yohoufo.order.mq.DelayTime;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.mq.producer.TradeMqSender;
import com.yohoufo.order.service.impl.OrderOverTimeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -22,11 +24,21 @@ public class BuyerMiniFaultOuterTimeHandler implements IEventHandler<BuyerMiniFa
@Autowired
private TradeMqSender tradeMqSender;
@Autowired
private OrderOverTimeService orderOverTimeService;
@Override
@Subscribe
public void handle(BuyerMiniFaultOuterTimeEvent event) {
logger.info("Subscribe Buyer mini fault delay msg, event {}", event);
int minutes = DelayTime.MINI_FAULT_CONFIRM_OUTER_TIME_MINUTE;
logger.info("Subscribe Buyer mini fault delay msg, event {},minutes {}", event,minutes);
tradeMqSender.send(TopicConstants.BUYER_ORDER_MINI_FAULT_AUTO_REJECT, event,minutes );
tradeMqSender.send(TopicConstants.BUYER_ORDER_MINI_FAULT_AUTO_REJECT, event, DelayTime.MINI_FAULT_CONFIRM_OUTER_TIME_MINUTE);
//更新订单的瑕疵确认时间
OrderOverTime orderOverTime=new OrderOverTime();
orderOverTime.setOrderCode(event.getOrderCode());
orderOverTime.setMiniFaultConfirmMinutes(minutes);
orderOverTimeService.insertMiniFaultConfirmTime(orderOverTime);
}
}
... ...
... ... @@ -12,6 +12,8 @@ import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.dal.product.ProductMapper;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.common.RefundCase;
import com.yohoufo.order.common.TransferCase;
... ... @@ -48,6 +50,7 @@ import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
... ... @@ -119,6 +122,9 @@ public class AppraiseService {
@Autowired
private MerchantOrderPaymentService merchantOrderPaymentService;
@Autowired
private ProductMapper productMapper;
/**
* 瑕疵确认不通过的情况,卖家的保证金扣掉一部分给平台,暂定0元
*/
... ... @@ -209,10 +215,10 @@ public class AppraiseService {
//记录订单的状态变更信息
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetOrderStatus.getCode());
//TODO 平台已发货给买家
//清缓存
cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
Product product =Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.noticeBuyerWhenDeliveryGoodsToBuyer(buyerUid, orderCode, sellerOrderGoods,product);
}else{
LOGGER.warn("in deliveryGoodsToBuyer update status number zero, buyer Order orderCode {} pstatus {}, expect Order Status {}",
orderCode, buyerOrder.getStatus(), expectOrderStatus);
... ... @@ -435,7 +441,9 @@ public class AppraiseService {
//记录操作记录
orderOperateRecordService.addRecord(orderCode,"买家操作",OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_PASS);
//TODO 发消息
//TODO 发消息 瑕疵接收,只给卖家发消息
Product product =Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods,product);
}else{
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); // 更新失败,可能是因为订单状态已经被并发修改
}
... ... @@ -1176,8 +1184,9 @@ public class AppraiseService {
LOGGER.info("in judgeCenterPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetOrderStatus.getCode());
//TODO 鉴定通过,等待发货,消息
//inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods);
//TODO 鉴定通过,
Product product =Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods,product);
}catch (Exception ex){
LOGGER.warn("in judgeCenterPass,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
String content = "后台鉴定通过商品,订单"+ orderCode + "退还保证金失败";
... ... @@ -1289,6 +1298,7 @@ public class AppraiseService {
//更新卖家订单状态
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
skup, orderCode, buyerUid);
//退款给卖家(仅退一次)
PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid,orderCode,skup,sellerOrder,targetSoStatus);
... ... @@ -1338,7 +1348,9 @@ public class AppraiseService {
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetOrderStatus.getCode());
//平台已发货给买家
inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods);
Product product =Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeBuyer(buyerUid, orderCode, sellerOrderGoods,product);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods,product);
}catch (Exception ex){
LOGGER.warn("in appraiseSuccess,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
String content = "鉴定通过时,订单"+ orderCode + "退还保证金失败";
... ...
... ... @@ -18,6 +18,8 @@ import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.QualityCheckMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.dal.product.ProductMapper;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.order.common.ActionStatusHold;
import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.common.Payment;
... ... @@ -49,10 +51,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@Service
... ... @@ -108,6 +107,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Autowired
private BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler;
@Autowired
private ProductMapper productMapper;
/**
* 提交订单
... ... @@ -777,9 +779,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
//消息
inBoxFacade.buyerMiniFaultCreate(uid,orderCode,sellerOrderGoods.getProductName());
inBoxFacade.buyerMiniFaultCreate(uid,orderCode,sellerOrderGoods,product);
}
}
... ...
... ... @@ -16,6 +16,7 @@ import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.constant.ExpressInfoConstant;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.common.utils.UserInfoHiddenHelper;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.ExpressForMqSend;
... ... @@ -42,6 +43,7 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
... ... @@ -96,6 +98,9 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
@Autowired
private QualityCheckMapper qualityCheckMapper;
@Autowired
private OrderOverTimeService orderOverTimeService;
private static String EXPRESS_MQ_SEND = "third.logistics.logistics_data";
//物流文案设置
... ... @@ -366,6 +371,9 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
}
ExpressInfoRespBo expressInfoRespBo = new ExpressInfoRespBo();
expressInfoRespBo.setExpressInfoDetailTitle("");
expressInfoRespBo.setJudgeExpressInfoDetailTitle("平台鉴定");
expressInfoRespBo.setSupplementExpressInfoDetailTitle("卖家发往平台");
expressInfoRespBo.setExpressInfoDetailList(Lists.newArrayList());
expressInfoRespBo.setJudgeExpressInfoDetailList(Lists.newArrayList());
expressInfoRespBo.setSupplementExpressInfoDetailList(Lists.newArrayList());
... ... @@ -391,6 +399,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
//设定最近一个阶段的物流
List<ExpressInfo> expressInfoList = getExpressInfoListByStage(actor, orderCode, expressTypeList.get(0));
constructExpressInfo(actor,expressInfoList, expressInfoRespBo.getExpressInfoDetailList());
expressInfoRespBo.setExpressInfoDetailTitle("卖家发往平台");
}else if(expressTypeList.size()==2){
if(EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode().intValue()==expressTypeList.get(0)){
//设定鉴定的物流调拨信息
... ... @@ -403,6 +412,12 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
//设定最近一个阶段的物流
List<ExpressInfo> expressInfoList = getExpressInfoListByStage(actor, orderCode, expressTypeList.get(0));
constructExpressInfo(actor,expressInfoList, expressInfoRespBo.getExpressInfoDetailList());
if(EnumExpressType.EXPRESS_TYPE_2.getCode().equals(expressTypeList.get(0))){
expressInfoRespBo.setExpressInfoDetailTitle("平台发往买家");
}else{
expressInfoRespBo.setExpressInfoDetailTitle("平台发往卖家");
}
//获取上一阶段的辅助物流信息
constructSupplementExpress( actor,orderCode,expressTypeList.get(0),expressInfoRespBo);
... ... @@ -411,6 +426,11 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
//设定最近一个阶段的物流
List<ExpressInfo> expressInfoList = getExpressInfoListByStage(actor, orderCode, expressTypeList.get(0));
constructExpressInfo(actor,expressInfoList, expressInfoRespBo.getExpressInfoDetailList());
if(EnumExpressType.EXPRESS_TYPE_2.getCode().equals(expressTypeList.get(0))){
expressInfoRespBo.setExpressInfoDetailTitle("平台发往买家");
}else{
expressInfoRespBo.setExpressInfoDetailTitle("平台发往卖家");
}
//设定鉴定的物流调拨信息
List<ExpressInfo> judgeExpressInfoList=getExpressInfoListByStage(actor, orderCode, EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode());
... ... @@ -441,10 +461,17 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
expressInfoRespBo.setStage(1);
if(OrderStatus.PLATFORM_RECEIVE.getCode()==status
||OrderStatus.PLATFORM_CHECKING.getCode()==status
||OrderStatus.MINI_FAULT_WAITING.getCode()==status
||OrderStatus.MINI_FAULT_ACCEPT.getCode()==status
||OrderStatus.JUDGE_PASS.getCode()==status){
||OrderStatus.MINI_FAULT_WAITING.getCode()==status){
expressInfoRespBo.setStage(2);
}else if(OrderStatus.MINI_FAULT_ACCEPT.getCode()==status
||OrderStatus.JUDGE_PASS.getCode()==status){
if(TabType.BUY==actor){
//买家
expressInfoRespBo.setStage(2);
}else{
//卖家
expressInfoRespBo.setStage(3);
}
}else if(OrderStatus.WAITING_RECEIVE.getCode()==status){
if(TabType.BUY==actor){
//买家
... ... @@ -639,19 +666,34 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
list = list.stream().filter(info -> StringUtils.equals(waybillCode,info.getWaybillCode())).collect(Collectors.toList());
}
if(CollectionUtils.isNotEmpty(list)){
LOGGER.info("getExpressInfoListByStage success have data in express info ,orderCode = {} ,expressType = {} ",orderCode,expressType);
return list;
//如果获取为空,尝试另外一个方式,通过物流单号查
if(CollectionUtils.isEmpty(list)){
LOGGER.info("getExpressInfoListByStage try again by waybillCode, orderCode = {} ,expressType = {}, expressRecord = {} ",orderCode,expressType,expressRecord);
list = expressInfoMapper.selectExpressInfoListByWaybillCodeAndLogisticsType(waybillCode,logisticsType);
//如果存在多笔订单的情况,选择一个最近的订单
if(CollectionUtils.isNotEmpty(list)){
long latestOrder=list.get(0).getOrderCode();
list = list.stream().filter(info -> (latestOrder==info.getOrderCode())).collect(Collectors.toList());
}
}
LOGGER.info("getExpressInfoListByStage begin , orderCode = {} ,expressType = {}, expressRecord = {} ",orderCode,expressType,expressRecord);
List<ExpressInfo> expressInfoList = expressInfoMapper.selectExpressInfoListByWaybillCodeAndLogisticsType(waybillCode,logisticsType);
//如果存在多笔订单的情况,选择一个最近的订单
if(CollectionUtils.isNotEmpty(expressInfoList)){
long latestOrder=expressInfoList.get(0).getOrderCode();
expressInfoList = expressInfoList.stream().filter(info -> (latestOrder==info.getOrderCode())).collect(Collectors.toList());
//第一阶段的物流:买家不允许查看卖家给平台订单的顺丰联系人的手机号,手机号脱敏
if(EnumExpressType.EXPRESS_TYPE_1.getCode().equals(expressType)&&TabType.BUY==actor&&CollectionUtils.isNotEmpty(list)){
for(ExpressInfo expressInfo:list){
String info = StringUtils.defaultString(expressInfo.getAcceptRemark(),"");
boolean hasSendKeyword = info.contains("派送")||info.contains("派件");
if(info.contains("电话")&&hasSendKeyword){
List<String> phoneList = UserInfoHiddenHelper.fetchPhone(info);
LOGGER.info("getExpressInfoListByStage hide phone number , orderCode = {} ,expressType = {}, actor = {} ,remark {}",orderCode,expressType, actor,info);
for(String ph:phoneList){
info = info.replaceFirst(ph,UserInfoHiddenHelper.hidePhoneNo(ph));
}
expressInfo.setAcceptRemark(info);
LOGGER.info("getExpressInfoListByStage hide phone number , orderCode = {} ,expressType = {}, actor = {} ,new replace remark {}",orderCode,expressType, actor,info);
}
}
}
return expressInfoList;
return list;
}
private List<ExpressInfoDetail> queryLastExpressDetailInfo(TabType actor,Long orderCode, int expressType) {
... ... @@ -755,7 +797,11 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
boolean showBtn=false;
int leftTime = 0;
//倒计时
int mini_fault_mark_outer_time_second= DelayTime.MINI_FAULT_CONFIRM_OUTER_TIME_MINUTE * 60;
OrderOverTime orderOverTime = Optional.ofNullable(qualityCheck.getOrderCode()).map(orderOverTimeService::selectByOrderCode).orElse(null);
// 对于老订单来说,超时表记录无数据,则默认24小时 ,即1440分钟
Integer miniFaultConfirmMinutes = Optional.ofNullable(orderOverTime).map(OrderOverTime::getMiniFaultConfirmMinutes).orElse(1440);
int mini_fault_mark_outer_time_second= miniFaultConfirmMinutes * 60;
//int mini_fault_mark_outer_time_second= DelayTime.MINI_FAULT_CONFIRM_OUTER_TIME_MINUTE * 60;
int expireTime = qualityCheck.getCreateTime() + mini_fault_mark_outer_time_second;
int nowTs = DateUtil.getCurrentTimeSecond();
if(expireTime> nowTs){
... ...
... ... @@ -19,6 +19,10 @@ public class OrderOverTimeService {
return orderOverTimeMapper.insertDeliveryTime(record);
}
public int insertMiniFaultConfirmTime(OrderOverTime record) {
return orderOverTimeMapper.insertMiniFaultConfirmTime(record);
}
public int insertShamSendTime(OrderOverTime record) {
return orderOverTimeMapper.insertShamSendTime(record);
}
... ...
... ... @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.inboxclient.model.InBoxResponse;
import com.yohoufo.inboxclient.model.InboxReqVO;
import com.yohoufo.inboxclient.sdk.InBoxSDK;
... ... @@ -18,6 +19,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
... ... @@ -129,18 +131,68 @@ public class InBoxFacade {
});
}
/**
* 平台发货给买家
*
* @return
*/
public void noticeBuyerWhenDeliveryGoodsToBuyer(int buyerUid, long orderCode, SellerOrderGoods psog,Product product) {
executorService.execute(()->{
try {
logger.info("record noticeBuyerWhenDeliveryGoodsToBuyer inbox msg, buyerUid {}, orderCode {}, psog {},SellerOrderGoods {} product {}",
buyerUid, orderCode, psog, JSON.toJSONString(psog), JSON.toJSONString(product));
String prdName = psog.getProductName();
String sizeName = psog.getSizeName();
String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.PURCHASE_SENDED;
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record noticeBuyerWhenDeliveryGoodsToBuyer inbox msg, buyerUid {}, orderCode {}, prdName {},SellerOrderGoods {} resp {}",
buyerUid, orderCode, prdName, JSON.toJSONString(psog), resp);
//seller notice
//短信
String phone = userProxyService.getMobile(buyerUid);
if (StringUtils.isBlank(phone)){
logger.warn("in noticeBuyerWhenDeliveryGoodsToBuyer notice buyer sms fail, buyerUid {} orderCode {} prdName {} ", buyerUid, orderCode,prdName);
}else{
List<String> mobileList = Arrays.asList(phone);
String content = getReplacedContent(InboxBusinessTypeEnum.SMS_SEND.getContent(),prdName,sizeName,productCode,orderCode);
sendSmsService.smsSendByMobile(content,mobileList);
logger.info("record noticeBuyerWhenDeliveryGoodsToBuyer notice buyer sms msg, buyerUid {}, orderCode {}, prdName {} phone {}",
buyerUid, orderCode,prdName, phone);
}
} catch (Exception e) {
logger.warn("InBoxFacade noticeBuyerWhenDeliveryGoodsToBuyer error inbox msg, buyerUid {}, orderCode {} ,psog {}",
buyerUid, orderCode, psog, e);
}
});
}
/**
* 平台已发货给买家
*
* @return
*/
public void appraisePassNotice(int buyerUid, long orderCode, SellerOrderGoods psog) {
public void appraisePassNoticeBuyer(int buyerUid, long orderCode, SellerOrderGoods psog,Product product) {
executorService.execute(()->{
try {
logger.info("record appraisePassNotice inbox msg, buyerUid {}, orderCode {}, psog {},SellerOrderGoods {} product {}",
buyerUid, orderCode, psog, JSON.toJSONString(psog), JSON.toJSONString(product));
String prdName = psog.getProductName();
String sizeName = psog.getSizeName();
String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.PURCHASE_SENDED;
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
... ... @@ -149,34 +201,13 @@ public class InBoxFacade {
logger.info("record appraisePassNotice inbox msg, buyerUid {}, orderCode {}, prdName {},SellerOrderGoods {} resp {}",
buyerUid, orderCode, prdName, JSON.toJSONString(psog), resp);
//seller notice
String sizeName = psog.getSizeName();
Integer sellerUid = psog.getUid();
InboxBusinessTypeEnum ibtOfSeller = InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_APPRAISE_PASS;
String paramsOfSeller = buildParams(prdName, sizeName);
InboxReqVO reqOfSeller = buildInboxReqVO(sellerUid, paramsOfSeller, ibtOfSeller);
InBoxResponse respOfSeller = inBoxSDK.addInbox(reqOfSeller);
logger.info("record appraisePassNotice inbox msg, buyerUid {}, orderCode {}, prdName {} ,sizeName {} ,resp {}",
buyerUid, orderCode, prdName,sizeName, respOfSeller);
String phoneOfSeller = userProxyService.getMobile(sellerUid);
if (StringUtils.isBlank(phoneOfSeller)){
logger.warn("in appraisePassNotice sms fail, buyerUid {} orderCode {} prdName {} ", buyerUid, orderCode,prdName);
}else{
List<String> mobileList = Arrays.asList(phoneOfSeller);
String contentOfSeller = getReplacedContent(InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_APPRAISE_PASS.getContent(), orderCode);
sendSmsService.smsSendByMobile(contentOfSeller, mobileList);
logger.info("record appraisePassNotice sms msg notice seller, sellerUid {}, orderCode {}, prdName {} sizeName {} phone {}",
sellerUid, orderCode, prdName, sizeName, phoneOfSeller);
}
//短信
String phone = userProxyService.getMobile(buyerUid);
if (StringUtils.isBlank(phone)){
logger.warn("in appraisePassNotice notice buyer sms fail, buyerUid {} orderCode {} prdName {} ", buyerUid, orderCode,prdName);
}else{
List<String> mobileList = Arrays.asList(phone);
String content = getReplacedContent(InboxBusinessTypeEnum.SMS_SEND.getContent(),prdName,orderCode);
String content = getReplacedContent(InboxBusinessTypeEnum.SMS_SEND.getContent(),prdName,sizeName,productCode,orderCode);
sendSmsService.smsSendByMobile(content,mobileList);
logger.info("record appraisePassNotice notice buyer sms msg, buyerUid {}, orderCode {}, prdName {} phone {}",
buyerUid, orderCode,prdName, phone);
... ... @@ -188,6 +219,45 @@ public class InBoxFacade {
});
}
public void appraisePassNoticeSeller(int buyerUid, long orderCode, SellerOrderGoods psog,Product product) {
executorService.execute(()->{
try {
logger.info("record appraisePassNoticeSeller inbox msg, buyerUid {}, orderCode {}, psog {},SellerOrderGoods {} product {}",
buyerUid, orderCode, psog, JSON.toJSONString(psog), JSON.toJSONString(product));
String prdName = psog.getProductName();
String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
//seller notice
String sizeName = psog.getSizeName();
Integer sellerUid = psog.getUid();
InboxBusinessTypeEnum ibtOfSeller = InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_APPRAISE_PASS;
String paramsOfSeller = buildParams(prdName, sizeName);
InboxReqVO reqOfSeller = buildInboxReqVO(sellerUid, paramsOfSeller, ibtOfSeller);
InBoxResponse respOfSeller = inBoxSDK.addInbox(reqOfSeller);
logger.info("record appraisePassNoticeSeller inbox msg, buyerUid {}, orderCode {}, prdName {} ,sizeName {} ,resp {}",
buyerUid, orderCode, prdName,sizeName, respOfSeller);
String phoneOfSeller = userProxyService.getMobile(sellerUid);
if (StringUtils.isBlank(phoneOfSeller)){
logger.warn("in appraisePassNoticeSeller sms fail, buyerUid {} orderCode {} prdName {} ", buyerUid, orderCode,prdName);
}else{
List<String> mobileList = Arrays.asList(phoneOfSeller);
String contentOfSeller = getReplacedContent(InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_APPRAISE_PASS.getContent(), orderCode);
sendSmsService.smsSendByMobile(contentOfSeller, mobileList);
logger.info("record appraisePassNoticeSeller sms msg notice seller, sellerUid {}, orderCode {}, prdName {} sizeName {} phone {}",
sellerUid, orderCode, prdName, sizeName, phoneOfSeller);
}
} catch (Exception e) {
logger.warn("InBoxFacade appraisePassNoticeSeller error inbox msg, buyerUid {}, orderCode {} ,psog {}",
buyerUid, orderCode, psog, e);
}
});
}
private String replaceSMSContent(InboxBusinessTypeEnum ibte, Object... params){
return getReplacedContent(ibte.getContent(), params);
}
... ... @@ -349,33 +419,39 @@ public class InBoxFacade {
/**
* 瑕疵提醒,给买家消息
*/
public void buyerMiniFaultCreate(int buyerUid, long orderCode,String prdName) {
public void buyerMiniFaultCreate(int buyerUid, long orderCode,SellerOrderGoods psog,Product product) {
try {
executorService.execute(() -> {
logger.info("record buyerMiniFaultCreate inbox enter, buyerUid {} ,orderCode {} ,psog {},product {}",
buyerUid, orderCode ,psog, JSON.toJSONString(product));
String prdName = psog.getProductName();
String sizeName = psog.getSizeName();
String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_PROBLEM_ORDER;
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record buyerMiniFaultCreate inbox msg, buyerUid {} ,orderCode {} ,prdName {},resp {}",
buyerUid, orderCode ,prdName,resp);
logger.info("record buyerMiniFaultCreate inbox msg, buyerUid {} ,orderCode {} ,psog {},product {},resp {}",
buyerUid, orderCode ,psog,JSON.toJSONString(product),resp);
//短信
String phone = userProxyService.getMobile(buyerUid);
if (StringUtils.isBlank(phone)){
logger.warn("buyerMiniFaultCreate sms send fail,buyerUid {} ,orderCode {},prdName {}", buyerUid, orderCode,prdName);
logger.warn("buyerMiniFaultCreate sms send fail,buyerUid {} ,orderCode {},psog {},product {}", buyerUid, orderCode,psog,JSON.toJSONString(product));
return;
}
List<String> mobileList = Arrays.asList(phone);
String content = getReplacedContent(InboxBusinessTypeEnum.SMS_CHECK_ORDER_PROBLEM.getContent(),prdName,orderCode);
String content = getReplacedContent(InboxBusinessTypeEnum.SMS_CHECK_ORDER_PROBLEM.getContent(),prdName,sizeName,productCode,orderCode);
sendSmsService.smsSendByMobile(content, mobileList);
logger.info("record buyerMiniFaultCreate inbox sms msg,buyerUid {}, orderCode {},prdName {}",
buyerUid ,orderCode,prdName);
});
} catch (Exception e) {
logger.warn("InBoxFacade buyerMiniFaultCreate error inbox msg, buyerUid {},orderCode {},prdName {} ",
buyerUid, orderCode,prdName , e);
logger.warn("InBoxFacade buyerMiniFaultCreate error inbox msg, buyerUid {},orderCode {},psog {},product {} ",
buyerUid, orderCode,psog ,JSON.toJSONString(product), e);
}
}
/**
... ... @@ -404,6 +480,9 @@ public class InBoxFacade {
}
List<String> mobileList = Arrays.asList(phone);
InboxBusinessTypeEnum sms = InboxBusinessTypeEnum.SMS_NOTICE_BUYER_WHEN_MINI_FAULT_UN_ACCEPT;
if(outTimeFlag){
sms = InboxBusinessTypeEnum.SMS_NOTICE_BUYER_WHEN_MINI_FAULT_UN_ACCEPT_OUT_TIME;
}
String content = getReplacedContent(sms.getContent(),prdName,orderCode);
sendSmsService.smsSendByMobile(content, mobileList);
logger.info("record buyerQualityCheckNotPass inbox sms msg,buyerUid {}, prdName {},orderCode {}",
... ...
... ... @@ -86,6 +86,28 @@ public class ProductIdentifyController {
}
}
@ApiOperation(name = "ufo.product.queryIdentifyInfoForPlatform", desc="UFO商品物权转移查询接口")
@ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class)
@ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class)
@ApiParam(name="uid",required = true,desc="有货uid",type=Integer.class)
@ApiRespCode(code=200,desc="查询成功")
@ApiRespCode(code=402,desc="查询失败")
@IgnoreSignature
@RequestMapping(params = "method=ufo.product.queryIdentifyInfoForPlatform")
public ApiResponse queryIdentifyInfoForPlatform(@RequestParam(value = "tagId", required = true) String tagId,
@RequestParam(value = "nfcUid",required = false) String nfcUid) throws GatewayException {
try{
ProductIdentifyResp info = identifyService.queryIdentifyInfoForPlatform(tagId, nfcUid);
return new ApiResponse.ApiResponseBuilder().code(200).data(info).build();
}catch (Exception e){
logger.warn("queryIdentifyInfoForPlatform error! tagId={}, nfcUid={}, e is {}", tagId, nfcUid, e);
if( e instanceof GatewayException){
throw e;
}
return new ApiResponse.ApiResponseBuilder().code(402).message("查询失败,请稍后重试").build();
}
}
@ApiOperation(name = "ufo.product.applyToBeOwner", desc="申请成为物权所有人")
@ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class)
@ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class)
... ...
... ... @@ -21,4 +21,6 @@ public interface ProductIdentifyService {
IdentifyRecord queryIdentifyRecord(String tagId, String nfcUid);
ProductIdentifyResp queryIdentifyInfoForPlatform(String tagId, String nfcUid) throws GatewayException;
}
... ...
... ... @@ -328,7 +328,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
public ProductIdentifyResp queryNewIdentifyInfo(String tagId, String nfcUid, Integer uid) throws GatewayException {
logger.info("enter queryNewIdentifyInfo, tagId = {}, nfcUid={}, uid={}", tagId, nfcUid, uid);
//返回结果可能在缓存中
ProductIdentifyResp result = getIdentifyFromCache(tagId, nfcUid);
ProductIdentifyResp result = getNewIdentifyFromCache(tagId, nfcUid);
if(result != null ){
rebuildResult(result, tagId, nfcUid, uid);
logger.info("queryNewIdentifyInfo get result from cache success! tagId = {}, nfcUid={},uid={}, result={} ", tagId, nfcUid, uid, result );
... ... @@ -363,7 +363,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
result.setAllowPop(identifyRecord.getAllowPop());
//设置缓存--可能会有延时,不影响的
setIdentifyCache(tagId, nfcUid, result);
setNewIdentifyCache(tagId, nfcUid, result);
//添加申请物权转移人信息
rebuildResult(result, tagId, nfcUid, uid);
... ... @@ -373,8 +373,48 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
}
@Override
public synchronized int applyToBeOwner(String tagId, String nfcUid, Integer uid) throws GatewayException {
IdentifyRecord identifyRecord = identifyRecordsMapper.selectByTagAndNfcId(tagId, nfcUid);//防止缓存更新失败
public ProductIdentifyResp queryIdentifyInfoForPlatform(String tagId, String nfcUid) throws GatewayException {
logger.info("enter queryNewIdentifyInfo, tagId = {}, nfcUid={}", tagId, nfcUid);
//返回结果可能在缓存中
// ProductIdentifyResp result = getNewIdentifyFromCache(tagId, nfcUid);
// if(result != null ){
// logger.info("queryIdentifyInfoForPlatform get result from cache success! tagId = {}, nfcUid={}, result={} ", tagId, nfcUid, result);
// return result;
// }
//1)鉴定 记录--先从缓存去取
IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid);
if(identifyRecord == null){
throw new GatewayException(402, "鉴定信息不存在");
}
//根据鉴定记录 获取订单号
Long orderCode = identifyRecord.getOrderCode();
//2)订单号 获取订单详细信息
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if(buyerOrder == null){
throw new GatewayException(403, "订单不存在");
}
//3)商品详细信息
ProductIdentifyResp result = getOrderDetail(buyerOrder, identifyRecord, tagId);
//4)物权转移轨迹
List<IdentifyTrackResp> trackList = getTrackList(identifyRecord, result.getIdentifyPlat());
result.setTrackList(trackList);
//5)设置当前物权所有人
result.setCurrentOwner(trackList.get(trackList.size()-1).getContent());
//设置缓存--可能会有延时,不影响的
// setNewIdentifyCache(tagId, nfcUid, result);
logger.info("queryIdentifyInfoForPlatform success!, tagId = {}, nfcUid={}, result ={}", tagId, nfcUid, result );
return result;
}
public int applyToBeOwner(String tagId, String nfcUid, Integer uid) throws GatewayException {
IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid);
if(identifyRecord == null){
throw new GatewayException(402, "鉴定信息不存在");
}
... ... @@ -826,6 +866,12 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
clientCache.setEx(kb, result,5 * 60 );
}
private void setNewIdentifyCache(String tagId, String nfcUid, ProductIdentifyResp result) {
RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:newIdentifyResultInfo:").
appendVar(tagId).appendVar(":").appendVar(nfcUid);
clientCache.setEx(kb, result,5 * 60 );
}
private void clearIdentifyCache(String tagId, String nfcUid) {
RedisKeyBuilder infoKb = new RedisKeyBuilder().appendFixed("ufo:product:identifyResultInfo:").
appendVar(tagId).appendVar(":").appendVar(nfcUid);
... ... @@ -833,6 +879,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyRecord:").
appendVar(tagId).appendVar(":").appendVar(nfcUid);
clientCache.delete(kb.toString());
RedisKeyBuilder kb_new = new RedisKeyBuilder().appendFixed("ufo:product:newIdentifyResultInfo:").
appendVar(tagId).appendVar(":").appendVar(nfcUid);
clientCache.delete(kb_new.toString());
}
private ProductIdentifyResp getIdentifyFromCache(String tagId, String nfcUid) {
... ... @@ -842,6 +891,13 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
return identifyResp;
}
private ProductIdentifyResp getNewIdentifyFromCache(String tagId, String nfcUid) {
RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:newIdentifyResultInfo:").
appendVar(tagId).appendVar(":").appendVar(nfcUid);
ProductIdentifyResp identifyResp = clientCache.get(kb, ProductIdentifyResp.class);
return identifyResp;
}
/**
* 查询用户基本信息--头像信息(不要取此接口的手机号)
* @return
... ...
... ... @@ -18,10 +18,11 @@ consumer:
delay:
interval: 10080
#瑕疵确认时间为48小时
- class: com.yohoufo.order.mq.consumer.BuyerOrderMiniFaultOuterTimeDelayMsgConsumer
topic: buyerOrder.miniFaultAutoReject
delay:
interval: 1440
interval: 2880
#- class: com.yohoufo.order.mq.consumer.BuyerOrderCancelShamDeliveryMsgConsumer
# topic: buyerOrder.cancelShamDeliver
... ...