Authored by TANLING

Merge branch 'hotfix_0407_skupnotexist2' into test6.9.24

... ... @@ -2,8 +2,10 @@ package com.yohoufo.order.controller;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.annotation.IgnoreSession;
... ... @@ -18,6 +20,7 @@ import com.yohoufo.order.model.request.TransferMoneyRequest;
import com.yohoufo.order.model.response.PrepayResponse;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.IStoredSellerService;
import com.yohoufo.order.service.impl.AppraiseService;
import com.yohoufo.order.service.impl.TransferService;
import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
import lombok.Data;
... ... @@ -41,6 +44,10 @@ public class OrderHelpController {
@Autowired
private AlipayOuyinService alipayService;
@Autowired
private AppraiseService appraiseService;
@Data
public static class RefundEarnestMoneyRequest {
private Integer uid;
... ... @@ -68,6 +75,20 @@ public class OrderHelpController {
.build();
}
@IgnoreSignature
@IgnoreSession
@RequestMapping(value = "/miniFaultRejectedHelp0407")
public ApiResponse miniFaultRejectedHelp0407(@RequestBody MiniFaultRejectedHelp0407Request data) {
return appraiseService.miniFaultRejectedHelp0407(data.orderCode, data.targetStatus, data.outTimeFlag);
}
@Data
public static class MiniFaultRejectedHelp0407Request {
Long orderCode;
OrderStatus targetStatus;
boolean outTimeFlag;
}
@Autowired
IStoredSellerService storedSellerService;
... ... @@ -76,12 +97,13 @@ public class OrderHelpController {
/**
* 6.9.23的版本,一次性接口
* 将线上的超级卖家全部降级成为普通入驻
*
* @param uids
*/
@IgnoreSignature
@IgnoreSession
@RequestMapping(value = "/degrade")
public ApiResponse degrade(@RequestParam(value = "uids", required = false) List<Integer> uids){
public ApiResponse degrade(@RequestParam(value = "uids", required = false) List<Integer> uids) {
storedSellerService.degrade(uids);
return new ApiResponse.ApiResponseBuilder()
... ... @@ -106,8 +128,6 @@ public class OrderHelpController {
}
@Autowired
private IPaymentService paymentService;
... ... @@ -118,9 +138,13 @@ public class OrderHelpController {
public ApiResponse refund(@RequestParam(name = "orderCode") long orderCode,
@RequestParam(name = "paidOrderCode", required = false) Long paidOrderCode,
@RequestParam(name = "payLevel", defaultValue = "0") int payLevel,
@RequestParam(name = "refundType", required = false) int refundType,
@RequestParam(name = "refundAmount") double refundAmount) {
PaymentRequest request = PaymentRequest.builder().orderCode(orderCode).paidOrderCode(paidOrderCode).payLevel(payLevel).refundAmount(refundAmount).build();
PaymentRequest request = PaymentRequest.builder().orderCode(orderCode).paidOrderCode(paidOrderCode).payLevel(payLevel)
.refundAmount(refundAmount)
.refundattch(MerchantOrderAttachInfo.builder().type(refundType).build())
.build();
PayRefundBo payRefundBo = paymentService.refund(request);
if (payRefundBo.getRefundStatus() == RefundContant.PAYMENT_REFUND_RESULTCODE_SUCCESS) {
... ... @@ -147,7 +171,4 @@ public class OrderHelpController {
}
}
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.yoho.core.rabbitmq.YhProducer;
... ... @@ -821,7 +821,7 @@ 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;
ApiResponse apiResponse = new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null) {
... ... @@ -841,99 +841,195 @@ 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);
//
int sellerUid = buyerOrder.getSellerUid();
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
int skup = bog.getSkup();
return miniFaultRejected(orderCode, targetStatus, outTimeFlag, buyerOrder, buyerUid);
} else {
ApiResponse apiResponse = new ApiResponse();
LOGGER.warn("in miniFaultReject, buyer Order now status {}, expect expectStatus {}",
buyerOrder.getStatus(), expectStatus);
apiResponse.setCode(400);
apiResponse.setMessage("订单状态发生变化");
return apiResponse;
}
}
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
long sellerOrderCode = sellerOrder.getOrderCode();
private ApiResponse miniFaultRejected(Long orderCode, OrderStatus targetStatus, boolean outTimeFlag, BuyerOrder buyerOrder, int buyerUid) {
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)
.uid(buyerUid).orderCode(orderCode).build();
EventBusPublisher.publishEvent(brce);
//
int sellerUid = buyerOrder.getSellerUid();
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
int skup = bog.getSkup();
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
//async refund seller coupon
sellerOrderServiceDelegate.getSellerOrderService()
.asyncCancelWithCouponIfPresent(orderCode, targetStatus.getCode(), sellerOrderGoods);
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
long sellerOrderCode = sellerOrder.getOrderCode();
final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;
final SellerOrderStatus targetSoStatus = SellerOrderStatus.MINI_FAULT_REJECT;
int ucnt = updateSellerOrderStatusAndCleanCache(sellerUid, sellerOrderCode, expectSOStatus, targetSoStatus,
skup, orderCode, buyerUid);
//将卖家的保证金扣掉10元后,剩余的钱退回给卖家
BigDecimal earnestMoney = sellerOrder.getEarnestMoney().subtract(new BigDecimal(miniFaultRejectPunishFee));
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.MINI_FAULT_REJECT, orderCode, sellerUid, sellerOrder, buyerUid, targetSoStatus, earnestMoney.doubleValue());
LOGGER.info("in miniFaultReject,refund ok, refundReqOfSeller {}", refundReqOfSeller);
//退买家的钱
BigDecimal goodsMoney = buyerOrder.getAmount();
boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler()
.loadPaymentRequest(buyerUid, orderCode, buyerOrder.getPayment(), goodsMoney)
.loadTargetOrderStatus(targetStatus)
.loadRefundAction(payRefundService::refund)
.loadLogger(LOGGER)
.loadSellerOrderGoods(sellerUid, skup)
.refund();
if (!refundGoodsMoneyFlag) {
apiResponse.setCode(400);
String content = "瑕疵不接受时,退用户" + sellerUid + "货款订单" + orderCode + "失败";
apiResponse.setMessage(content);
}
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
//async refund seller coupon
sellerOrderServiceDelegate.getSellerOrderService()
.asyncCancelWithCouponIfPresent(orderCode, targetStatus.getCode(), sellerOrderGoods);
//记录订单的状态变更信息
LOGGER.info("in miniFaultReject record status change, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);
try {
//记录订单状态流转
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;
final SellerOrderStatus targetSoStatus = SellerOrderStatus.MINI_FAULT_REJECT;
//瑕疵不接受(用户不接受和超时不接受),只给买家发消息
buyerNoticeFacade.miniFaultUnAccept(buyerOrder, sellerOrderGoods, outTimeFlag);
sellerNoticeFacade.sellerMiniFaultUnAccept(sellerOrderGoods, orderCode, outTimeFlag);
int ucnt = updateSellerOrderStatusAndCleanCache(sellerUid, sellerOrderCode, expectSOStatus, targetSoStatus,
skup, orderCode, buyerUid);
//将卖家的保证金扣掉10元后,剩余的钱退回给卖家
BigDecimal earnestMoney = sellerOrder.getEarnestMoney().subtract(new BigDecimal(miniFaultRejectPunishFee));
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.MINI_FAULT_REJECT, orderCode, sellerUid, sellerOrder, buyerUid, targetSoStatus, earnestMoney.doubleValue());
LOGGER.info("in miniFaultReject,refund ok, refundReqOfSeller {}", refundReqOfSeller);
} catch (Exception ex) {
LOGGER.warn("in miniFaultReject orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
} finally {
/// 物流信息异步执行
executorService.execute(() -> {
//退买家的钱
BigDecimal goodsMoney = buyerOrder.getAmount();
boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler()
.loadPaymentRequest(buyerUid, orderCode, buyerOrder.getPayment(), goodsMoney)
.loadTargetOrderStatus(targetStatus)
.loadRefundAction(payRefundService::refund)
.loadLogger(LOGGER)
.loadSellerOrderGoods(sellerUid, skup)
.refund();
if (!refundGoodsMoneyFlag) {
ApiResponse apiResponse = new ApiResponse();
apiResponse.setCode(400);
String content = "瑕疵不接受时,退用户" + sellerUid + "货款订单" + orderCode + "失败";
apiResponse.setMessage(content);
return apiResponse;
}
//记下订单的操作记录
if (outTimeFlag) {
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode, EnumQualityCheckStatus.REJECT_BY_OUTER_TIME.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by auto orderCode {} ,update quality check record status num {} ", orderCode, updateNum);
orderOperateRecordService.addRecord(orderCode, "系统操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT_BY_OUT_TIME);
} else {
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode, EnumQualityCheckStatus.REJECT_BY_BUYER.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by buyer orderCode {} ,update quality check record status num {} ", orderCode, updateNum);
orderOperateRecordService.addRecord(orderCode, "买家操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT);
}
//记录订单的状态变更信息
LOGGER.info("in miniFaultReject record status change, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);
try {
//记录订单状态流转
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
//更新物流信息,写到最后
//先补加一条鉴定中物流
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
//瑕疵不接受(用户不接受和超时不接受),只给买家发消息
buyerNoticeFacade.miniFaultUnAccept(buyerOrder, sellerOrderGoods, outTimeFlag);
sellerNoticeFacade.sellerMiniFaultUnAccept(sellerOrderGoods, orderCode, outTimeFlag);
operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_not_pass;
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
});
} catch (Exception ex) {
LOGGER.warn("in miniFaultReject orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
} finally {
/// 物流信息异步执行
executorService.execute(() -> {
}
//记下订单的操作记录
if (outTimeFlag) {
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode, EnumQualityCheckStatus.REJECT_BY_OUTER_TIME.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by auto orderCode {} ,update quality check record status num {} ", orderCode, updateNum);
orderOperateRecordService.addRecord(orderCode, "系统操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT_BY_OUT_TIME);
} else {
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode, EnumQualityCheckStatus.REJECT_BY_BUYER.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by buyer orderCode {} ,update quality check record status num {} ", orderCode, updateNum);
orderOperateRecordService.addRecord(orderCode, "买家操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT);
}
} else {
LOGGER.warn("in miniFaultReject, buyer Order now status {}, expect expectStatus {}",
buyerOrder.getStatus(), expectStatus);
//更新物流信息,写到最后
//先补加一条鉴定中物流
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_not_pass;
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
});
}
ApiResponse apiResponse = new ApiResponse();
return apiResponse;
}
@VisibleForTesting
public ApiResponse miniFaultRejectedHelp0407(Long orderCode, OrderStatus targetStatus, boolean outTimeFlag) {
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
Integer buyerUid = buyerOrder.getUid();
int sellerUid = buyerOrder.getSellerUid();
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
int skup = bog.getSkup();
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
final SellerOrderStatus targetSoStatus = SellerOrderStatus.MINI_FAULT_REJECT;
//将卖家的保证金扣掉10元后,剩余的钱退回给卖家
BigDecimal earnestMoney = sellerOrder.getEarnestMoney().subtract(new BigDecimal(miniFaultRejectPunishFee));
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.MINI_FAULT_REJECT, orderCode, sellerUid, sellerOrder, buyerUid, targetSoStatus, earnestMoney.doubleValue());
LOGGER.info("in miniFaultReject,refund ok, refundReqOfSeller {}", refundReqOfSeller);
//退买家的钱
BigDecimal goodsMoney = buyerOrder.getAmount();
boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler()
.loadPaymentRequest(buyerUid, orderCode, buyerOrder.getPayment(), goodsMoney)
.loadTargetOrderStatus(targetStatus)
.loadRefundAction(payRefundService::refund)
.loadLogger(LOGGER)
.loadSellerOrderGoods(sellerUid, skup)
.refund();
if (!refundGoodsMoneyFlag) {
ApiResponse apiResponse = new ApiResponse();
apiResponse.setCode(400);
apiResponse.setMessage("订单状态发生变化");
String content = "瑕疵不接受时,退用户" + sellerUid + "货款订单" + orderCode + "失败";
apiResponse.setMessage(content);
return apiResponse;
}
//记录订单的状态变更信息
LOGGER.info("in miniFaultReject record status change, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);
try {
//记录订单状态流转
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
//瑕疵不接受(用户不接受和超时不接受),只给买家发消息
buyerNoticeFacade.miniFaultUnAccept(buyerOrder, sellerOrderGoods, outTimeFlag);
sellerNoticeFacade.sellerMiniFaultUnAccept(sellerOrderGoods, orderCode, outTimeFlag);
} catch (Exception ex) {
LOGGER.warn("in miniFaultReject orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
} finally {
/// 物流信息异步执行
executorService.execute(() -> {
//记下订单的操作记录
if (outTimeFlag) {
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode, EnumQualityCheckStatus.REJECT_BY_OUTER_TIME.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by auto orderCode {} ,update quality check record status num {} ", orderCode, updateNum);
orderOperateRecordService.addRecord(orderCode, "系统操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT_BY_OUT_TIME);
} else {
//更新瑕疵确认结果
int updateNum = qualityCheckMapper.updateByOrderCode(orderCode, EnumQualityCheckStatus.REJECT_BY_BUYER.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("Buyer Order miniFaultReject by buyer orderCode {} ,update quality check record status num {} ", orderCode, updateNum);
orderOperateRecordService.addRecord(orderCode, "买家操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_REJECT);
}
//更新物流信息,写到最后
//先补加一条鉴定中物流
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_not_pass;
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
});
}
ApiResponse apiResponse = new ApiResponse();
return apiResponse;
}
... ...