...
|
...
|
@@ -104,12 +104,12 @@ public class SellerOrderCancelService { |
|
|
logger.warn("seller cancel orderCode illegal, req {}", event);
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
OrderCodeType actor = OrderCodeType.getOrderCodeType(codeMeta.getType());
|
|
|
logger.info("in cancel uid {},orderCode {}, actor {}", uid, orderCode, actor);
|
|
|
OrderCodeType codeType = OrderCodeType.getOrderCodeType(codeMeta.getType());
|
|
|
logger.info("in cancel uid {},orderCode {}, actor {}", uid, orderCode, codeType);
|
|
|
//case 1: 未支付时
|
|
|
//case 2: 支付完成,没有买家下单
|
|
|
//case 3: 支付完成,有买家下单
|
|
|
cancel(uid, orderCode, actor);
|
|
|
cancel(uid, orderCode, codeType);
|
|
|
}
|
|
|
|
|
|
private final static List<Integer> relatedBuyerStatusList = Arrays.asList(OrderStatus.WAITING_PAY.getCode(),
|
...
|
...
|
@@ -134,22 +134,22 @@ public class SellerOrderCancelService { |
|
|
return buyerOrder;
|
|
|
}
|
|
|
|
|
|
public int cancel(int uid, long orderCode, OrderCodeType actor){
|
|
|
public int cancel(int uid, long orderCode, OrderCodeType codeType){
|
|
|
int result = 0;
|
|
|
SellerOrder sellerOrder = null;
|
|
|
BuyerOrder buyerOrder = null;
|
|
|
Integer skup=null;
|
|
|
//seller order code
|
|
|
if (OrderCodeType.SELLER_TYPE.equals(actor)){
|
|
|
if (OrderCodeType.SELLER_TYPE.equals(codeType)){
|
|
|
sellerOrder = sellerOrderMapper.selectByOrderCodeUid(orderCode, uid);
|
|
|
if (Objects.isNull(sellerOrder)){
|
|
|
return result;
|
|
|
}
|
|
|
skup = sellerOrder.getSkup();
|
|
|
buyerOrder = getBuyerOrderBySkup(skup, uid, orderCode, actor);
|
|
|
buyerOrder = getBuyerOrderBySkup(skup, uid, orderCode, codeType);
|
|
|
}
|
|
|
//buyer order code
|
|
|
if (OrderCodeType.BUYER_TYPE.equals(actor)){
|
|
|
if (OrderCodeType.BUYER_TYPE.equals(codeType)){
|
|
|
buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
|
|
|
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(), orderCode);
|
|
|
sellerOrder = sellerOrderMapper.selectBySkup(buyerOrderGoods.getSkup());
|
...
|
...
|
@@ -187,7 +187,7 @@ public class SellerOrderCancelService { |
|
|
//case 3: 支付完成,有买家下单
|
|
|
if (SellerOrderStatus.HAS_PAYED.getCode() == status){
|
|
|
logger.info("in seller cancel after paid, uid {} skup {} orderCode {}", uid, skup, orderCode);
|
|
|
result = cancelAfterPayAction(sellerOrder, buyerOrder);
|
|
|
result = cancelAfterPayAction(sellerOrder, buyerOrder, codeType);
|
|
|
}
|
|
|
|
|
|
return result;
|
...
|
...
|
@@ -344,9 +344,15 @@ public class SellerOrderCancelService { |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int cancelAfterPayExistBuyAction(SellerOrder sellerOrder, BuyerOrder buyerOrder){
|
|
|
/**
|
|
|
* 卖家支付完成(上架成功),买家下单(状态未知)
|
|
|
*
|
|
|
* @param sellerOrder
|
|
|
* @param buyerOrder
|
|
|
* @param codeType
|
|
|
* @return
|
|
|
*/
|
|
|
private int cancelAfterPayExistBuyAction(SellerOrder sellerOrder, BuyerOrder buyerOrder, OrderCodeType codeType){
|
|
|
/**
|
|
|
* case 3: 支付完成,有买家下单
|
|
|
* actions as blow:
|
...
|
...
|
@@ -356,16 +362,26 @@ public class SellerOrderCancelService { |
|
|
* 4. 瓜分保证金 退货款
|
|
|
*/
|
|
|
Integer buyerOrderStatus = buyerOrder.getStatus();
|
|
|
if (Objects.isNull(buyerOrderStatus) || !ActionStatusHold.sellerCanCancelBuyerOrder(buyerOrderStatus)){
|
|
|
throw new UfoServiceException(501, "买家支付中,不能取消");
|
|
|
}
|
|
|
|
|
|
final int sellerUid = sellerOrder.getUid(), buyerUid = buyerOrder.getUid();
|
|
|
final long sellerOrderCode = sellerOrder.getOrderCode(), buyerOrderCode = buyerOrder.getOrderCode();
|
|
|
|
|
|
logger.info("in seller cancel After Paid while Exist Buy Action, uid {}, orderCode {}, buyerOrderCode {}",
|
|
|
sellerUid, sellerOrderCode, buyerOrderCode);
|
|
|
|
|
|
if (Objects.equals(buyerOrderStatus, OrderStatus.WAITING_PAY.getCode())){
|
|
|
logger.warn("cancelAfterPayExistBuyAction canceling order is waiting buyer pay, seller [uid:{} orderCode:{}],buyer [uid:{} orderCode:{}],buyerOrderStatus {}",
|
|
|
sellerUid, sellerOrderCode, buyerUid, buyerOrderCode, buyerOrderStatus);
|
|
|
throw new UfoServiceException(501, "买家支付中,不能取消");
|
|
|
}
|
|
|
/**
|
|
|
* 这种操作主要是买家下单 卖家停留在出售列表时的场景,
|
|
|
* 此时此刻卖家不感知买家下单,不买了的入参是卖家订单号
|
|
|
* 根据codeType判断即可
|
|
|
*/
|
|
|
if (OrderCodeType.getSellerTypes().contains(codeType)){
|
|
|
logger.warn("cancelAfterPayExistBuyAction canceling order buyer operated, seller [uid:{} orderCode:{}],buyer [uid:{} orderCode:{}] codeType {} buyerOrderStatus {}",
|
|
|
sellerUid, sellerOrderCode, buyerUid, buyerOrderCode, codeType, buyerOrderStatus);
|
|
|
String errorMsg = "您的商品已经被购买,不能下架该商品!";
|
|
|
throw new UfoServiceException(501, errorMsg);
|
|
|
}
|
|
|
int result = 0;
|
|
|
//actions of buyer order and related
|
|
|
//update buyer Order
|
...
|
...
|
@@ -433,7 +449,7 @@ public class SellerOrderCancelService { |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private int cancelAfterPayAction(SellerOrder sellerOrder, BuyerOrder buyerOrder){
|
|
|
private int cancelAfterPayAction(SellerOrder sellerOrder, BuyerOrder buyerOrder, OrderCodeType codeType){
|
|
|
|
|
|
final int sellerUid = sellerOrder.getUid();
|
|
|
final long orderCode = sellerOrder.getOrderCode();
|
...
|
...
|
@@ -463,8 +479,9 @@ public class SellerOrderCancelService { |
|
|
* 4. 瓜分保证金 退货款给买家
|
|
|
*/
|
|
|
//查询买家订单,状态是支付成功的
|
|
|
|
|
|
result = cancelAfterPayExistBuyAction(sellerOrder, buyerOrder);
|
|
|
if (buyOrderCnt>0){
|
|
|
result = cancelAfterPayExistBuyAction(sellerOrder, buyerOrder, codeType);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
...
|
...
|
|