Authored by tanling

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

package com.yohoufo.order.event;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.function.Function;
@ToString(of = { "orderCode" })
public class SellerDepositOrderStatusConsistencyAsyncEvent
extends AsyncEvent{
@Getter@Setter
private Long orderCode;
public SellerDepositOrderStatusConsistencyAsyncEvent(Function<SellerDepositOrderStatusConsistencyAsyncEvent,Integer> function) {
super(function);
}
@Override
AsyncEvent getAsyncEvent() {
return this;
}
}
... ...
... ... @@ -3,6 +3,8 @@ package com.yohoufo.order.mq.consumer;
import com.yohoufo.order.event.SellerCancelDeliverEvent;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.service.impl.BuyerOrderCancelService;
import com.yohoufo.order.service.impl.ServiceOrderProcessor;
import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -14,8 +16,14 @@ import org.springframework.stereotype.Component;
public class SellerOrderCancelDeliverDelayMsgConsumer extends JsonObjectMessageConsumer<SellerCancelDeliverEvent> {
@Autowired
private ServiceOrderProcessor serviceOrderProcessor;
@Autowired
private BuyerOrderCancelService buyerOrderCancelService;
@Autowired
private SellerDepositOrderService sellerDepositOrderService;
@Override
public String getTopic() {
return TopicConstants.SELLER_ORDER_AUTO_CANCEL_DELIVER;
... ... @@ -23,6 +31,11 @@ public class SellerOrderCancelDeliverDelayMsgConsumer extends JsonObjectMessageC
@Override
public void handle(SellerCancelDeliverEvent event) {
buyerOrderCancelService.cancelForSellerSendOutTimeout(event.getUid(), event.getOrderCode(), event.getSkup(), event.getSellerOrderGoods());
long orderCode = event.getOrderCode();
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
int rows = sellerDepositOrderService.cancelForSendOutTimeout(orderCode);
return;
}
buyerOrderCancelService.cancelForSellerSendOutTimeout(event.getUid(), orderCode, event.getSkup(), event.getSellerOrderGoods());
}
}
... ...
... ... @@ -38,6 +38,7 @@ import com.yohoufo.order.utils.AddressHelper;
import com.yohoufo.order.utils.LoggerUtils;
import lombok.Builder;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -182,8 +183,12 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
throw new UfoServiceException(400, "商品ID错误");
}
final OrderAttributes orderAttributes = getOrderAttributes();
String addressIdstr=req.getAddressId();
if (StringUtils.isBlank(addressIdstr)){
throw new UfoServiceException(400, "请选择地址后提交");
}
int addressId = AddressUtil.getDecryptStr(req.getAddressId());
int addressId = AddressUtil.getDecryptStr(addressIdstr);
if (addressId < 0){
logger.warn("submit appraise order addressId invalidate, uid {}, productId {}, addressId {}",
uid, productId, req.getAddressId());
... ... @@ -424,16 +429,4 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
inBoxFacade.paidAppraiseOrderNotice(orderInfo.getUid(), orderInfo.getOrderCode(), targetStatus);
}
public int platformFinishReceiveGoods(long orderCode, long parentCode){
return 0;
}
public int detectAppraiseFinish(long orderCode){
return 0;
}
}
... ...
... ... @@ -523,7 +523,6 @@ public class DepositServiceImpl implements DepositService {
}
DepositDetailBo.DepositDetailBoBuilder depositDetailBoBuilder = DepositDetailBo.builder()
.orderCode(storageDeposit.getOrderCode())
.depositCode(storageDeposit.getDepositCode())
.skup(storageDeposit.getSkup())
.status(storageDeposit.getStatus())
... ... @@ -533,10 +532,12 @@ public class DepositServiceImpl implements DepositService {
Map<Long, List<String>> orderStatusStr = depositHelpService.queryAppraiseOrderStatusEx(storageDeposit.getOrderCode());
depositDetailBoBuilder.depositStatusName(CollectionUtils.isNotEmpty(orderStatusStr.get(storageDeposit.getOrderCode())) ? orderStatusStr.get(storageDeposit.getOrderCode()).get(0) : "")
.depositDescName(CollectionUtils.isNotEmpty(orderStatusStr.get(storageDeposit.getOrderCode())) ? orderStatusStr.get(storageDeposit.getOrderCode()).get(1) : "");
.depositDescName(CollectionUtils.isNotEmpty(orderStatusStr.get(storageDeposit.getOrderCode())) ? orderStatusStr.get(storageDeposit.getOrderCode()).get(1) : "")
.orderCode(storageDeposit.getParentOrderCode());
} else { // 正常的买家订单召回
depositDetailBoBuilder.depositStatusName(StorageDepositStatusEnum.getAppStatusNameByCode(storageDeposit.getStatus()))
.depositDescName(StorageDepositStatusEnum.getAppStatusDescByCode(storageDeposit.getStatus()));
.depositDescName(StorageDepositStatusEnum.getAppStatusDescByCode(storageDeposit.getStatus()))
.orderCode(storageDeposit.getOrderCode());
}
return depositDetailBoBuilder.build();
... ...
... ... @@ -1150,10 +1150,11 @@ public class InBoxFacade extends BaseNoticeFacade{
//
InboxBusinessTypeEnum inboxType = null;
InboxBusinessTypeEnum smsType = null;
Object[] inboxParams = null;
switch (targetStatus){
case HAS_PAYED:
inboxType = InboxBusinessTypeEnum.NOTICE_PAID_APPRAISE_ORDER_PAID;
inboxParams = new Object[]{orderCode};
break;
case PLATFORM_RECEIVE:
... ... @@ -1186,7 +1187,7 @@ public class InBoxFacade extends BaseNoticeFacade{
break;
}
boolean smsRequired = Objects.nonNull(smsType);
Object[] inboxParams = buildParams4PaidAppraiseOrder(orderCode);
inboxParams = Objects.nonNull(inboxParams) ? inboxParams : buildParams4PaidAppraiseOrder(orderCode);
Object[] smsParams = smsRequired ? inboxParams : null;
Notice notice = newNotice(uid).withLogPrefix("paid Appraise Order Notice 4 " + targetStatus.name());
... ...
... ... @@ -28,9 +28,7 @@ import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.ClientType;
import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.event.OrderCancelEvent;
import com.yohoufo.order.event.PayConfirmEvent;
import com.yohoufo.order.event.SellerDepositOrderCancelAsyncEvent;
import com.yohoufo.order.event.*;
import com.yohoufo.order.model.PayQueryBo;
import com.yohoufo.order.model.dto.PlatformFeeDto;
import com.yohoufo.order.model.dto.SellerDepositOrderContext;
... ... @@ -54,10 +52,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@Service
... ... @@ -343,6 +338,9 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
if (rows == 0){
return rows;
}
//
triggerStatusConsistencyCheck(orderCode);
Long paidCode = pao.getParentOrderCode();
inBoxFacade.sellerDepositOrderNotice(pao.getUid(), orderCode, targetStatus);
BigDecimal left = calLeftMoney(pao.getAmount(), orderCode);
... ... @@ -405,6 +403,10 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
if (rows == 0){
return rows;
}
//
Long orderCode = appraiseOrder.getOrderCode();
triggerStatusConsistencyCheck(orderCode);
//
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.CHECKING_FAKE;
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), targetOrderStatus);
depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
... ... @@ -421,6 +423,9 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
if (rows == 0){
return rows;
}
//
Long orderCode = appraiseOrder.getOrderCode();
triggerStatusConsistencyCheck(orderCode);
//refund amount
new GoodsServiceRefundHandler()
.loadLogger(logger)
... ... @@ -447,6 +452,10 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
if (rows == 0){
return rows;
}
//
Long orderCode = appraiseOrder.getOrderCode();
triggerStatusConsistencyCheck(orderCode);
//
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.SHAM_SEND_OUT;
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), targetOrderStatus);
//refund amount
... ... @@ -567,16 +576,18 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
if (rows == 0){
return rows;
}
Long orderCode = appraiseOrder.getOrderCode();
triggerStatusConsistencyCheck(orderCode);
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.QUALITY_CHECK_FAKE;
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), targetOrderStatus);
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), orderCode, targetOrderStatus);
new GoodsServiceRefundHandler()
.loadLogger(logger)
.loadUser(appraiseOrder.getUid())
.loadActionCase(SellerWalletDetail.Type.FLAW)
.loadRefundAction(payRefundService::refund)
.loadOrder(appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode(), appraiseOrder.getPayment(), appraiseOrder.getAmount())
.loadOrder(orderCode, appraiseOrder.getParentOrderCode(), appraiseOrder.getPayment(), appraiseOrder.getAmount())
.refund();
depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
depositService.insertFakeDeposit(appraiseOrder.getUid(), orderCode, appraiseOrder.getParentOrderCode());
return rows;
}
... ... @@ -595,14 +606,20 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
}
public void processAfterPay(OrderInfo orderInfo){
Long orderCode = orderInfo.getOrderCode();
Integer uid = orderInfo.getUid();
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.HAS_PAYED;
inBoxFacade.sellerDepositOrderNotice(orderInfo.getUid(), orderInfo.getOrderCode(), targetOrderStatus);
SellerDepositOrderCancelAsyncEvent event = new SellerDepositOrderCancelAsyncEvent(this::handleOrderCancelAsyncEvent);
event.setUid(orderInfo.getUid());
event.setOrderCode(orderInfo.getOrderCode());
event.setUid(uid);
event.setOrderCode(orderCode);
EventBusPublisher.publishEvent(event);
logger.info("processAfterPay seller deposit order , SellerDepositOrderCancelAsyncEvent send out, event {}", event);
SellerCancelDeliverEvent cancelDeliverEvent =
SellerCancelDeliverEvent.builder()
.uid(orderInfo.getUid())
.orderCode(orderCode).build();
EventBusPublisher.publishEvent(cancelDeliverEvent);
}
... ... @@ -621,12 +638,23 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
logger.warn("in getSubOrderStatistic selectByOrderCode null, orderCode {}", orderCode);
return new ArrayList<>(0);
}
long occ = appraiseOrder.getParentOrderCode()==null ? orderCode : appraiseOrder.getParentOrderCode();
long occ = findoutParentOrderCode(orderCode);
List<AppraiseOrder> paoList = appraiseOrderMapper.selectSubOrderStatistic(occ);
logger.info("getSubOrderStatistic orderCode {} ParentOrderCode {} AppraiseOrder list {}", orderCode, occ, paoList);
return paoList;
}
private Long findoutParentOrderCode(long orderCode){
AppraiseOrder appraiseOrder = appraiseOrderMapper.selectByOrderCode(orderCode);
if (Objects.isNull(appraiseOrder)){
logger.warn("in getSubOrderStatistic selectByOrderCode null, orderCode {}", orderCode);
return orderCode;
}
return appraiseOrder.getParentOrderCode()==null ? orderCode : appraiseOrder.getParentOrderCode();
}
public DepositOrderStatisticInfo getAppraiseProgress(int uid, long orderCode){
List<AppraiseOrder> paoList = buildSubOrderStatisticList(orderCode);
... ... @@ -681,4 +709,82 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
return dosi;
}
public int platformFinishReceiveGoods(long parentCode){
AppraiseOrderStatus targetStatus = AppraiseOrderStatus.FINISH,
expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE;
return triggerStatusChange(parentCode,targetStatus,expectedStatus);
}
public int detectAppraiseFinish(SellerDepositOrderStatusConsistencyAsyncEvent event ){
logger.info("detectAppraiseFinish event {}", event);
long orderCode = event.getOrderCode();
long parentOrderCode = findoutParentOrderCode(orderCode);
int cnt =appraiseOrderMapper.selectSubOrderCntIncludeStatus(parentOrderCode,Arrays.asList(AppraiseOrderStatus.PLATFORM_RECEIVE.getCode()));
logger.info("detectAppraiseFinish event {},parentOrderCode {} PLATFORM_RECEIVE count {}", event, parentOrderCode, cnt);
if (cnt == 0){
int prows = platformFinishReceiveGoods(parentOrderCode);
logger.info("detectAppraiseFinish platformFinishReceiveGoods, orderCode {},parentOrderCode {} parent count {}",
orderCode, parentOrderCode, prows);
return prows;
}
return 0;
}
public void triggerStatusConsistencyCheck(long orderCode){
SellerDepositOrderStatusConsistencyAsyncEvent asyncEvent
= new SellerDepositOrderStatusConsistencyAsyncEvent(this::detectAppraiseFinish);
asyncEvent.setOrderCode(orderCode);
EventBusPublisher.publishEvent(asyncEvent);
}
/**
* 发货超时取消
* @param orderCode
*/
public int cancelForSendOutTimeout(long orderCode){
logger.info("in cancel seller deposit order For Send Out Timeout orderCode {}", orderCode);
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.isAppraiseOrder(orderCode);
if (!existenceNode.isExisted()){
logger.warn("auto cancel AppraiseOrder not exist, orderCode {}", orderCode);
throw new UfoServiceException(400, "订单已迷路");
}
AppraiseOrder pao = existenceNode.getAppraiseOrder();
OrderAttributes oa = OrderAttributes.getOrderAttributes(pao.getAttributes());
if (!OrderAttributes.DEPOSITE.equals(oa)){
logger.warn("auto cancel AppraiseOrder not deposit Order, orderCode {}", orderCode);
throw new UfoServiceException(400, "订单已迷路");
}
int uid = pao.getUid();
AppraiseOrderStatus appraiseOrderStatus = AppraiseOrderStatus.getByCode(pao.getStatus());
int rows = 0;
AppraiseOrderStatus targetOrderStatus = null;
switch (appraiseOrderStatus){
case HAS_PAYED:
targetOrderStatus= AppraiseOrderStatus.SEND_OUT_TIMEOUT;
rows = super.triggerStatusChange(orderCode, targetOrderStatus, appraiseOrderStatus);
if (rows>0){
new GoodsServiceRefundHandler()
.loadLogger(logger)
.loadUser(uid)
.loadActionCase(SellerWalletDetail.Type.SELLER_OVER_TIME)
.loadRefundAction(payRefundService::refund)
.loadOrder(orderCode, orderCode, pao.getPayment(), pao.getAmount())
.refund();
//notice
inBoxFacade.sellerDepositOrderNotice(uid, orderCode, targetOrderStatus);
}
break;
default:
throw new UfoServiceException(400, "订单不支持取消");
}
return rows;
}
}
... ...
... ... @@ -44,9 +44,9 @@ public class CertificationController {
public ApiResponse alipayCertification(RealNameAuthorizeReqVO reqVO) throws GatewayException {
logger.info("CertificationController.alipayCertification: Enter alipayCertification param reqVO is {}", reqVO);
//若版本低于6.9.9, 提示升级版本
if(configReader.getBoolean("ufo.user.idCertUpdateVersionSwitch",false) && compareVersion(reqVO.getApp_version(), "6.9.10") < 0){
if(configReader.getBoolean("ufo.user.idCertUpdateVersionSwitch",false) && compareVersion(reqVO.getApp_version(), "6.9.9") < 0){
logger.info("CertificationController.alipayCertification: version need update, version is {}, uid is {}", reqVO.getApp_version(), reqVO.getUid());
throw new VersionNotSupportException();
throw new GatewayException(400, "支付宝实名认证服务已升级,请升级有货APP最新版本后重新申请");
}
//(1) 必要参数的校验
if(reqVO == null || reqVO.getUid() <= 0){
... ... @@ -76,9 +76,9 @@ public class CertificationController {
public ApiResponse alipayCertifyResultQuery(RealNameAuthorizeReqVO reqVO) throws GatewayException {
logger.info("CertificationController.alipayCertifyResultQuery: Enter. RealNameAuthorizeReqVO is {}", reqVO);
//若版本低于6.9.9提示升级版本
if(configReader.getBoolean("ufo.user.idCertUpdateVersionSwitch",false) && compareVersion(reqVO.getApp_version(), "6.9.10") < 0 ){
if(configReader.getBoolean("ufo.user.idCertUpdateVersionSwitch",false) && compareVersion(reqVO.getApp_version(), "6.9.9") < 0 ){
logger.info("CertificationController.alipayCertifyResultQuery: version need update, version is {}, uid is {}", reqVO.getApp_version(), reqVO.getUid());
throw new VersionNotSupportException();
throw new GatewayException(400, "支付宝实名认证服务已升级,请升级有货APP最新版本后重新申请");
}
//(1) 校验请求的参数
if (reqVO == null || StringUtils.isBlank(reqVO.getZhiMaBizNo())){
... ...
package com.yohoufo.user.controller.passport;
import com.yoho.core.config.ConfigReader;
import com.yoho.tools.common.beans.ApiResponse;
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
import com.yohoufo.common.exception.GatewayException;
... ... @@ -32,6 +33,9 @@ public class RealNameAuthorizeController {
private final String yohoCardUrlPre= "http://yhgidcard.static.yhbimg.com/yohocard";
@Autowired
private ConfigReader configReader;
/*@Autowired
GraphVerifyService graphVerifyService;*/
... ... @@ -166,6 +170,12 @@ public class RealNameAuthorizeController {
@RequestMapping(params = "method=ufo.user.zhiMaCertWithPhotoCheckInit")
public ApiResponse zhiMaCertWithPhotoCheckInit(RealNameAuthorizeReqVO reqVO) throws GatewayException {
logger.info("enter realNameAuthorize.zhiMaCertWithPhotoCheckInit param reqVO is {}", reqVO);
//若版本低于6.9.9提示升级版本
if(configReader.getBoolean("ufo.user.idCertUpdateVersionSwitch",false) && compareVersion(reqVO.getApp_version(), "6.9.9") < 0 ){
logger.info("realNameAuthorize.zhiMaCertWithPhotoCheckInit: version need update, version is {}, uid is {}", reqVO.getApp_version(), reqVO.getUid());
throw new GatewayException(400, "支付宝实名认证服务已升级,请升级有货APP最新版本后重新申请");
}
//(1) 优先校验请求的参数
if (reqVO == null || reqVO.getUid()<=0){
throw new GatewayException(400, "uid不能为空!");
... ... @@ -251,6 +261,12 @@ public class RealNameAuthorizeController {
public ApiResponse zhiMaCertResultQuery(RealNameAuthorizeReqVO reqVO) throws GatewayException {
logger.info("enter realNameAuthorize.zhiMaCertResultQuery param reqVO is {}", reqVO);
//若版本低于6.9.9提示升级版本
if(configReader.getBoolean("ufo.user.idCertUpdateVersionSwitch",false) && compareVersion(reqVO.getApp_version(), "6.9.9") < 0 ){
logger.info("realNameAuthorize.zhiMaCertResultQuery: version need update, version is {}, uid is {}", reqVO.getApp_version(), reqVO.getUid());
throw new GatewayException(400, "支付宝实名认证服务已升级,请升级有货APP最新版本后重新申请");
}
//(1) 优先校验请求的参数
if (reqVO == null || reqVO.getUid()<=0){
throw new GatewayException(400, "参数错误,uid不能为空!");
... ... @@ -266,4 +282,28 @@ public class RealNameAuthorizeController {
return result;
}
private int compareVersion(String curVersion,String sysVersion){
boolean isCurBlank = StringUtils.isBlank(curVersion);
boolean isSysBlank = StringUtils.isBlank(sysVersion);
if(isCurBlank && isSysBlank){
return 0;
}
if(isCurBlank){
return -1;
}
if(isSysBlank){
return 1;
}
String[] curArr = curVersion.split("\\.");
String[] sysArr = sysVersion.split("\\.");
for(int i=0;i<3;i++){
int cur = Integer.parseInt(curArr[i]);
int sys = Integer.parseInt(sysArr[i]);
if(cur != sys){
return cur-sys;
}
}
return 0;
}
}
... ...
... ... @@ -42,4 +42,4 @@ ufo.order.seller.noticeHKSellerEmailTo=chao.chen@yoho.cn,xiuchun.luo@yoho.cn
ufo.user.idCertSwitch=false
#实名认证提示版本升级开关
ufo.user.idCertUpdateVersionSwitch = true
\ No newline at end of file
ufo.user.idCertUpdateVersionSwitch = false
\ No newline at end of file
... ...