Authored by LUOXC

Merge branch 'hotfix-helper' into test6.9.13

# Conflicts:
#	order/src/main/java/com/yohoufo/order/service/PaymentSupportService.java
... ... @@ -9,10 +9,14 @@ import com.yohoufo.common.annotation.InnerApi;
import com.yohoufo.common.lock.RedisLock;
import com.yohoufo.common.lock.RedisLockFactory;
import com.yohoufo.common.utils.ExecutorServiceUtils;
import com.yohoufo.dal.order.model.SellerWalletDetail;
import com.yohoufo.order.model.PayRefundBo;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.request.TransferMoneyRequest;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.concurrent.ThreadPoolFactory;
import com.yohoufo.order.service.impl.BuyerOrderCancelService;
import com.yohoufo.order.service.impl.PaymentServiceImpl;
import com.yohoufo.order.service.impl.TransferService;
import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
... ... @@ -28,10 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.UUID;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
import java.util.stream.IntStream;
@Slf4j
... ... @@ -54,6 +55,9 @@ public class OrderHelpController {
@Autowired
IBuyerOrderService buyerOrderService;
@Autowired
BuyerOrderCancelService buyerOrderCancelService;
/**
* 转账
... ... @@ -157,5 +161,16 @@ public class OrderHelpController {
return new ApiResponse.ApiResponseBuilder().code(200).message("处理成功").build();
}
@IgnoreSession
@IgnoreSignature
@InnerApi
@RequestMapping(value="/helperRefund")
public ApiResponse helperRefund(@RequestParam long orderCode, @RequestParam int uid) {
buyerOrderCancelService.helperRefund(uid,orderCode);
return new ApiResponse.ApiResponseBuilder().code(200).message("处理成功").build();
}
}
... ...
... ... @@ -72,15 +72,12 @@ public class PaymentSupportService {
if (codeMeta.getType() == OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE.getType()){
return Lists.newArrayList(PayChannelType.REAL);
}
// 个人卖家上架保证金 ==> 用户没有入驻,上架商品缴纳的保证金
else if (codeMeta.getType() == OrderCodeType.SELLER_TYPE.getType()){
Pair<Integer, Integer> attributes = getOrderAttributes(orderCode);
// 海外
if (attributes.getRight() != null
&& (attributes.getRight() == OrderAttributes.OVERSEAS_IN_STOCK.getCode()
|| attributes.getRight() == OrderAttributes.OVERSEAS_PRE_SALE.getCode())){
if (isHkOrder(attributes)){
return Lists.newArrayList(PayChannelType.CROSS_BORDER);
}else{
return Lists.newArrayList(PayChannelType.REAL);
... ... @@ -90,12 +87,12 @@ public class PaymentSupportService {
else if (codeMeta.getType() == OrderCodeType.BUYER_TYPE.getType()){
Pair<Integer, Integer> attributes = getOrderAttributes(orderCode);
// 海外
if (isHkOrder(attributes)){
return Lists.newArrayList(PayChannelType.CROSS_BORDER);
}
// 闪购寄存
if (attributes.getLeft()!=null
&& attributes.getRight()!=null
&& attributes.getLeft() == OrderAttributes.DEPOSITE.getCode()
&& attributes.getRight() == OrderAttributes.QUICK_DELIVER.getCode()){
else if (isQuickDeliverDepositeOrder(attributes)){
return Lists.newArrayList(PayChannelType.REAL);
}else{
return Lists.newArrayList(PayChannelType.REAL, PayChannelType.VIRTUAL);
... ... @@ -122,6 +119,12 @@ public class PaymentSupportService {
return Lists.newArrayList(PayChannelType.REAL, PayChannelType.VIRTUAL);
}
private boolean isQuickDeliverDepositeOrder(Pair<Integer, Integer> attributes) {
return attributes.getLeft()!=null
&& attributes.getRight()!=null
&& attributes.getLeft() == OrderAttributes.DEPOSITE.getCode()
&& attributes.getRight() == OrderAttributes.QUICK_DELIVER.getCode();
}
/**
* 特定的支付方式
... ... @@ -134,6 +137,11 @@ public class PaymentSupportService {
return abstractOrderPaymentService.getAllowedPayments(orderCode);
}
private boolean isHkOrder(Pair<Integer, Integer> attributes) {
return attributes.getRight() != null
&& (attributes.getRight() == OrderAttributes.OVERSEAS_IN_STOCK.getCode()
|| attributes.getRight() == OrderAttributes.OVERSEAS_PRE_SALE.getCode());
}
private Pair<Integer, Integer> getOrderAttributes(long orderCode){
... ...
... ... @@ -366,6 +366,26 @@ public class BuyerOrderCancelService {
}
}
public void helperRefund(int uid,long orderCode){
OrderStatus targetOrderStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if(targetOrderStatus.getCode() == buyerOrder.getStatus().intValue()){
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(uid,orderCode);
BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, buyerOrderGoods, targetOrderStatus);
TransferCase transferCase = TransferCase.PART_GOODS_MONEY_TO_SELLER;
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerOrder, buyerOrderGoods.getSkup(),
bpcr, transferCase,false);
bcapt.targetOrderStatus = targetOrderStatus;
bcapt.setSwdType(SellerWalletDetail.Type.BUYER_CANCEL_DELIVERY);
try {
bcapt.call();
} catch (Exception e) {
throwServiceException("服务异常");
logger.warn("helperRefund fail uid {}, orderCode {}", uid, orderCode);
}
}
}
... ...
... ... @@ -88,9 +88,8 @@ public class OrdersPayService {
List<PayListDetailVO.CmsPayVO> cmsPayRspList = cmsPayList.stream()
.filter(e -> Objects.nonNull(e.getPaymentId()))
.filter(e -> AppVersion.of(request.getAppVersion()).between(AppVersion.of(e.getStartVersion()), AppVersion.of(e.getEndVersion())))
.map(e -> {
return convertToCmsPayVO(e);
}).collect(Collectors.toList());
.map(e -> convertToCmsPayVO(e))
.collect(Collectors.toList());
if (request.getOrderCode() > 0){
... ... @@ -99,7 +98,10 @@ public class OrdersPayService {
cmsPayRspList = cmsPayRspList.stream()
.filter(cmsPayVO -> {
Payment payment = Payment.getPayment(cmsPayVO.getPaymentId());
if (payment==null || payment.getPayChannelType() == null){
if (Objects.isNull(payment)) {
return false;
}
if (payment.getPayChannelType() == null) {
return true;
}
return payChannelTypeList.contains(payment.getPayChannelType());
... ... @@ -130,12 +132,8 @@ public class OrdersPayService {
// 4. 处理花呗分期
// 存在花呗分期的时候,需要计算花呗分期的每一期还款信息
if (hbfq.isPresent()){
OrderInfo orderInfo = iPaymentService.getOrderInfoByOrderCode(request.getUid(), request.getOrderCode());
// 获取订单实付金额
orderInfo = iPaymentService.getOrderInfoByOrderCode(request.getUid(), request.getOrderCode());
OrderInfo orderInfo = iPaymentService.getOrderInfoByOrderCode(request.getUid(), request.getOrderCode());
// 计算花呗分期每一期的还款信息
hbfq.get().setHbfqBOList(hbCalc(orderInfo.getAmount().doubleValue()));
}
... ...