...
|
...
|
@@ -13,6 +13,7 @@ import com.yohobuy.ufo.model.promotion.request.CouponSendMqBean; |
|
|
import com.yohobuy.ufo.model.promotion.request.CouponSendType;
|
|
|
import com.yohoufo.common.ApiResponse;
|
|
|
import com.yohoufo.common.alarm.EventBusPublisher;
|
|
|
import com.yohoufo.common.constant.EnumPlatformDeliveryStatus;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
...
|
...
|
@@ -68,7 +69,7 @@ public class AppraiseService { |
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(AppraiseService.class);
|
|
|
|
|
|
private ExecutorService executorService = new ThreadPoolExecutor(3, 5, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(100), new PubThreadFactory("appraise-processor"));
|
|
|
private ExecutorService executorService = new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1000), new PubThreadFactory("appraise-processor"));
|
|
|
|
|
|
@Autowired
|
|
|
private IExpressInfoService expressInfoService;
|
...
|
...
|
@@ -214,10 +215,15 @@ public class AppraiseService { |
|
|
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
|
|
|
EventBusPublisher.publishEvent(buyerConfirmEvent);
|
|
|
|
|
|
//记录物流信息
|
|
|
//发物流
|
|
|
expressInfoService.deliverGoods(buyerUid, appraiseExpressInfoBo.getExpressCompanyId(), orderCode, appraiseExpressInfoBo.getWayBillCode(), appraiseExpressInfoBo.getDepotNum(), appraiseExpressInfoBo.getMobile());
|
|
|
executorService.execute(() -> {
|
|
|
//记录物流信息
|
|
|
//发物流
|
|
|
expressInfoService.deliverGoods(buyerUid, appraiseExpressInfoBo.getExpressCompanyId(), orderCode, appraiseExpressInfoBo.getWayBillCode(), appraiseExpressInfoBo.getDepotNum(), appraiseExpressInfoBo.getMobile());
|
|
|
|
|
|
//更新平台物流状态为已发货
|
|
|
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
|
|
|
EnumPlatformDeliveryStatus.delivery_to_buyer.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
});
|
|
|
//记录订单的状态变更信息
|
|
|
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
|
|
|
|
...
|
...
|
@@ -291,11 +297,16 @@ public class AppraiseService { |
|
|
LOGGER.info("returnBackOrderCauseOfJudgeFailure check status ok expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
|
|
buyerOrder.getStatus(), orderCode);
|
|
|
|
|
|
executorService.execute(() -> {
|
|
|
//更新物流信息
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
|
|
|
|
|
|
//更新物流信息
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
|
|
|
//更新平台物流状态为已发货
|
|
|
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
|
|
|
EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
|
|
|
});
|
|
|
//清缓存
|
|
|
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
|
|
|
|
...
|
...
|
@@ -342,10 +353,15 @@ public class AppraiseService { |
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
|
|
|
//记录物流信息
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, false);
|
|
|
executorService.execute(() -> {
|
|
|
//记录物流信息
|
|
|
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, false);
|
|
|
|
|
|
//更新平台物流状态为已发货
|
|
|
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
|
|
|
EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
});
|
|
|
//发送消息
|
|
|
inBoxFacade.sendCancelledProductToSellerByCenter(sellerUid, wayBillCode);
|
|
|
|
...
|
...
|
@@ -384,8 +400,14 @@ public class AppraiseService { |
|
|
|
|
|
//记录物流信息
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, true);
|
|
|
executorService.execute(() -> {
|
|
|
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, true);
|
|
|
|
|
|
//更新平台物流状态为已发货
|
|
|
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
|
|
|
EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
});
|
|
|
|
|
|
//发送消息
|
|
|
//清缓存
|
|
|
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
|
...
|
...
|
@@ -403,9 +425,6 @@ public class AppraiseService { |
|
|
LOGGER.info("Buyer Order miniFaultAccept (OrderRequest) {}", orderRequest);
|
|
|
//订单状态变更为鉴定中 ,记录调拨的物流信息 ,发消息 ,
|
|
|
OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING;
|
|
|
//拆分状态,版本升级之后存在的特殊订单
|
|
|
//OrderStatus expectStatusAnother = OrderStatus.PLATFORM_RECEIVE;
|
|
|
//List<Integer> expectStatusList= Lists.newArrayList(expectStatus.getCode(),expectStatusAnother.getCode());
|
|
|
OrderStatus targetStatus = OrderStatus.MINI_FAULT_ACCEPT;
|
|
|
|
|
|
// 参数检查
|
...
|
...
|
@@ -426,8 +445,6 @@ public class AppraiseService { |
|
|
buyerOrder.getStatus(), buyerOrder.getOrderCode());
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
//checkStatusWithMoreExpectStatus(buyerOrder,orderRequest, expectStatusList);
|
|
|
|
|
|
int buyerUid = orderRequest.getUid();
|
|
|
long orderCode = orderRequest.getOrderCode();
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
...
|
...
|
@@ -497,9 +514,7 @@ public class AppraiseService { |
|
|
LOGGER.info("Buyer Order miniFaultNotAccept (OrderRequest) {}", orderRequest);
|
|
|
//订单状态变更为 鉴定不通过 ,记录调拨的物流信息 ,发消息 ,
|
|
|
OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING;
|
|
|
//拆分状态,版本升级之后存在的特殊订单
|
|
|
//OrderStatus expectStatusAnother = OrderStatus.PLATFORM_RECEIVE;
|
|
|
//List<Integer> expectStatusList= Lists.newArrayList(expectStatusNew.getCode(),expectStatusAnother.getCode());
|
|
|
|
|
|
OrderStatus targetStatus = OrderStatus.MINI_FAULT_REJECT;
|
|
|
// 参数检查
|
|
|
if (orderRequest.getUid() < 0
|
...
|
...
|
@@ -521,8 +536,6 @@ public class AppraiseService { |
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
|
|
|
//checkStatusWithMoreExpectStatus(buyerOrder,orderRequest, expectStatusList);
|
|
|
|
|
|
long orderCode = orderRequest.getOrderCode();
|
|
|
ApiResponse result = this.miniFaultReject(orderCode, targetStatus, false);
|
|
|
|
...
|
...
|
@@ -536,21 +549,6 @@ public class AppraiseService { |
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 该方法再6.8.6.5版本中使用,拆分订单的时候,存在多种情况expectStatus
|
|
|
* 瑕疵接受
|
|
|
* 瑕疵不接受 这两种情形使用
|
|
|
@Deprecated
|
|
|
private void checkStatusWithMoreExpectStatus(BuyerOrder buyerOrder, OrderRequest orderRequest, List<Integer> expectStatusList ) {
|
|
|
// 检查 订单状态
|
|
|
int status = buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus().intValue();
|
|
|
OrderStatus orderStatus = OrderStatus.getOrderStatus(status);
|
|
|
if (orderStatus == null || !expectStatusList.contains(orderStatus.getCode())){
|
|
|
LOGGER.warn("check status invalidate, uid is {}, orderCode is {}, status is {}",
|
|
|
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrder.getStatus());
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
/**
|
|
|
* 瑕疵不通过: 买家不接受或者超时确认
|
...
|
...
|
@@ -561,9 +559,6 @@ public class AppraiseService { |
|
|
public ApiResponse miniFaultReject(Long orderCode, OrderStatus targetStatus, boolean outTimeFlag) {
|
|
|
LOGGER.info("miniFaultReject enter , orderCode {} ,targetStatus {},outTimeFlag {}", orderCode, targetStatus, outTimeFlag);
|
|
|
OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING;
|
|
|
//拆分状态,版本升级之后存在的特殊订单
|
|
|
//OrderStatus expectStatusAnother = OrderStatus.PLATFORM_RECEIVE;
|
|
|
//List<Integer> expectStatusList= Lists.newArrayList(expectStatusNew.getCode(),expectStatusAnother.getCode());
|
|
|
ApiResponse apiResponse = new ApiResponse();
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
|
...
|
...
|
@@ -741,70 +736,6 @@ public class AppraiseService { |
|
|
DateUtil.getCurrentTimeSecond());
|
|
|
|
|
|
if (rows > 0) {
|
|
|
/*
|
|
|
//refund coupons of buyer
|
|
|
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)
|
|
|
.uid(buyerUid).orderCode(orderCode).build();
|
|
|
EventBusPublisher.publishEvent(brce);
|
|
|
//
|
|
|
|
|
|
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
|
|
|
int skup = bog.getSkup();
|
|
|
|
|
|
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
|
|
|
long sellerOrderCode = sellerOrder.getOrderCode();
|
|
|
|
|
|
final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;
|
|
|
final SellerOrderStatus targetSoStatus = SellerOrderStatus.APPRAISAL_FAIL_COMPENSATE;
|
|
|
|
|
|
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
|
|
|
skup, orderCode, buyerUid);
|
|
|
|
|
|
//将卖家的保证金分账给平台和买家
|
|
|
PenaltyResult penaltyResult = SellerEarnestMoney2BuyerPenaltyCalculator.from(sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee"))
|
|
|
.calculate()
|
|
|
.orElse(null);
|
|
|
if(Objects.nonNull(penaltyResult)){
|
|
|
TransferCase transferCase = TransferCase.EARNEST_MONEY_TO_BUYER;
|
|
|
TranseferCellNode transeferCellNode = new TranseferCellNode();
|
|
|
transeferCellNode.setUid(buyerUid);
|
|
|
transeferCellNode.setAmount(penaltyResult.getPenaltyAmountWithoutYhServiceAmount());
|
|
|
TransferMoneyRequest tmReq = TransferMoneyRequest.builder()
|
|
|
.sellerUid(sellerUid)
|
|
|
.buyerOrderCode(orderCode)
|
|
|
.type(transferCase.getCode())
|
|
|
.transferCase(transferCase)
|
|
|
.transeferCellNode(transeferCellNode)
|
|
|
.swdType(SellerWalletDetail.Type.APPRAISE_FAIL)
|
|
|
.alarmConfig(AlarmConfig.APPRAISE_FAIL)
|
|
|
.build();
|
|
|
|
|
|
//先校验,提前把错误抛出
|
|
|
paymentService.transferMonCheck(tmReq);
|
|
|
//再分账
|
|
|
|
|
|
//改成异步的分账,不关心分账执行结果
|
|
|
executorService.execute(()->{
|
|
|
LOGGER.info("in appraiseFail,begin transfer async");
|
|
|
transferService.transfer(tmReq);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
//退钱给买家
|
|
|
BigDecimal goodsAmount = buyerOrder.getAmount();
|
|
|
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
|
|
|
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)
|
|
|
.payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
|
|
|
.amount(goodsAmount)
|
|
|
.skup(skup);
|
|
|
boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler().loadPaymentRequest(buyerUid,orderCode,goodsAmount)
|
|
|
.loadBillLogEventBuilder(bleb)
|
|
|
.loadTargetOrderStatus(targetStatus)
|
|
|
.loadRefundAction(payRefundService::refund)
|
|
|
.loadLogger(LOGGER)
|
|
|
.refund();
|
|
|
*/
|
|
|
RefundMoneyResultModel refundMoneyResultModel = operateMoneyWhenCheckFail(buyerOrder, orderCode, targetStatus);
|
|
|
boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
|
|
|
SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
|
...
|
...
|
@@ -838,6 +769,10 @@ public class AppraiseService { |
|
|
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
|
|
|
|
|
|
//更新平台物流状态为已发货
|
|
|
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
|
|
|
EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
|
|
|
//发货物流(平台已发货)
|
|
|
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
|
|
|
|
...
|
...
|
@@ -1331,59 +1266,21 @@ public class AppraiseService { |
|
|
* 退款给卖家(仅退一次)
|
|
|
*
|
|
|
*/
|
|
|
/*
|
|
|
SellerOrder tso = new SellerOrder();
|
|
|
tso.setUid(sellerUid);
|
|
|
tso.setOrderCode(sellerOrderCode);
|
|
|
tso.setStatus(targetSoStatus.getCode());
|
|
|
tso.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
tso.setExceptStatus(expectSOStatus.getCode());
|
|
|
int soCnt = sellerOrderMapper.updateByOrderCode(tso);
|
|
|
*/
|
|
|
//更新卖家订单状态
|
|
|
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid, sellerOrderCode, expectSOStatus, targetSoStatus,
|
|
|
skup, orderCode, buyerUid);
|
|
|
|
|
|
//退款给卖家(仅退一次)
|
|
|
PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid, orderCode, skup, sellerOrder, targetSoStatus);
|
|
|
|
|
|
|
|
|
/*
|
|
|
BigDecimal saleIncome = getSaleIncome(sellerUid, skup);
|
|
|
|
|
|
TransferCase transferCase = TransferCase.ALL_GOODS_MONEY_TO_SELLER;
|
|
|
TranseferCellNode transeferCellNode = new TranseferCellNode();
|
|
|
transeferCellNode.setUid(sellerUid);
|
|
|
transeferCellNode.setAmount(saleIncome);
|
|
|
TransferMoneyRequest tmReq = TransferMoneyRequest.builder()
|
|
|
.buyerOrderCode(orderCode)
|
|
|
.type(transferCase.getCode())
|
|
|
.transferCase(transferCase)
|
|
|
.transeferCellNode(transeferCellNode)
|
|
|
.alarmConfig(AlarmConfig.APPRAISE_SUCCESS)
|
|
|
.build();
|
|
|
|
|
|
//先校验,提前把错误抛出
|
|
|
paymentService.transferMonCheck(tmReq);
|
|
|
|
|
|
//改成异步的分账,不关心分账执行结果
|
|
|
executorService.execute(()->{
|
|
|
LOGGER.info("in appraiseSuccess,begin transfer async");
|
|
|
transferService.transfer(tmReq);
|
|
|
});
|
|
|
|
|
|
//退保证金给卖家
|
|
|
//refund earnestMoney
|
|
|
BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
|
|
|
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.APPRAISE_OK,orderCode,sellerUid ,sellerOrder,skup,buyerUid,targetSoStatus,earnestMoney.doubleValue());
|
|
|
LOGGER.info("in appraiseSuccess,refund ok, refundReqOfSeller {}", refundReqOfSeller);
|
|
|
|
|
|
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
*/
|
|
|
try {
|
|
|
//鉴定通过后自动发货,这个时候产生:买家确认收货的mq
|
|
|
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
|
|
|
EventBusPublisher.publishEvent(buyerConfirmEvent);
|
|
|
|
|
|
//更新平台物流状态为已发货
|
|
|
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
|
|
|
EnumPlatformDeliveryStatus.delivery_to_buyer.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
|
|
|
//记录物流信息
|
|
|
//发物流
|
|
|
expressInfoService.deliverGoods(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
|
...
|
...
|
@@ -1409,18 +1306,6 @@ public class AppraiseService { |
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
|
|
|
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
|
|
|
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
|
|
|
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
|
|
|
CacheKeyBuilder.orderDetailKey(buyerUid,TabType.BUY.getValue(), orderCode),
|
|
|
CacheKeyBuilder.buyerOrderNums(buyerUid)));
|
|
|
|
|
|
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid);
|
|
|
EventBusPublisher.publishEvent(event);
|
|
|
*/
|
|
|
|
|
|
LOGGER.info("in appraiseSuccess, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
|
|
|
sellerUid, sellerOrderCode, skup, sellerOrder.getEarnestMoney());
|
|
|
|
...
|
...
|
|