Authored by LUOXC

fixbug

... ... @@ -11,6 +11,7 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import javax.annotation.Resource;
... ... @@ -310,13 +311,21 @@ public class AppraiseService {
buyerNoticeFacade.deliveryDepositGoodsToBuyer(buyerOrder.getUid(), appraiseExpressInfoBo.getWayBillCode(),
() -> cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid()),
sellerOrderGoods -> Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null));
}else {
}
// 买家接受瑕疵,走非寄存流程
else if (buyerOrder.getStatus() == OrderStatus.MINI_FAULT_ACCEPT.getCode()) {
deliveryNonDepositGoodsToBuyerAndRun(appraiseExpressInfoBo,buyerOrder,sog -> {
// 通知买家已发货
buyerNoticeFacade.deliveryDepositGoodsToBuyer(buyerOrder.getUid(), appraiseExpressInfoBo.getWayBillCode(), sog,
sellerOrderGoods -> Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null));
});
} else {
LOGGER.warn("in deliveryGoodsToBuyer, buyer Deposit Order orderCode {}", buyerOrder.getOrderCode());
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
}
private void deliveryNonDepositGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo, BuyerOrder buyerOrder) {
private void deliveryNonDepositGoodsToBuyerAndRun(AppraiseExpressInfoBo appraiseExpressInfoBo, BuyerOrder buyerOrder, Consumer<SellerOrderGoods> run) {
final Long orderCode = buyerOrder.getOrderCode();
final OrderStatus expectOrderStatus;
final OrderStatus targetOrderStatus = OrderStatus.WAITING_RECEIVE;
... ... @@ -350,11 +359,12 @@ public class AppraiseService {
});
//记录订单的状态变更信息
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
//清缓存
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
buyerNoticeFacade.deliveryGoodsToBuyer(buyerOrder, sellerOrderGoods, product);
if(Objects.nonNull(run)){
run.accept(sellerOrderGoods);
}
} else {
LOGGER.warn("in deliveryGoodsToBuyer update status number zero, buyer Order orderCode {} pstatus {}, expect Order Status {}",
orderCode, buyerOrder.getStatus(), expectOrderStatus);
... ... @@ -362,6 +372,13 @@ public class AppraiseService {
}
}
private void deliveryNonDepositGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo, BuyerOrder buyerOrder) {
deliveryNonDepositGoodsToBuyerAndRun(appraiseExpressInfoBo, buyerOrder, sellerOrderGoods -> {
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
buyerNoticeFacade.deliveryGoodsToBuyer(buyerOrder, sellerOrderGoods, product);
});
}
/**
* 鉴定不通过退回
* (1)记录物流
... ...
... ... @@ -345,11 +345,24 @@ public class BuyerNoticeFacade extends BaseNoticeFacade {
*/
public void deliveryDepositGoodsToBuyer(int buyerUid, String wayBillCode, Supplier<SellerOrderGoods> psogSupplier, Function<SellerOrderGoods, Product> productFunction) {
try {
log.info("notice buyer delivery deposit goods to buyer, uid {}, wayBillCode {}", buyerUid, wayBillCode);
SellerOrderGoods psog = psogSupplier.get();
Product product = productFunction.apply(psog);
String prdName = psog.getProductName();
String sizeName = psog.getSizeName();
deliveryDepositGoodsToBuyer(buyerUid, wayBillCode, psog, productFunction);
} catch (Exception e) {
log.warn("notice buyer delivery deposit goods to buyer fail, uid {}, wayBillCode {}", buyerUid, wayBillCode, e);
}
}
/**
* 平台发货寄存商品给买家
*
* @return
*/
public void deliveryDepositGoodsToBuyer(int buyerUid, String wayBillCode, SellerOrderGoods sog, Function<SellerOrderGoods, Product> productFunction) {
try {
Product product = productFunction.apply(sog);
String prdName = sog.getProductName();
String sizeName = sog.getSizeName();
String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
newNotice(buyerUid)
.withLogPrefix("notice buyer delivery deposit goods to buyer")
... ... @@ -413,20 +426,20 @@ public class BuyerNoticeFacade extends BaseNoticeFacade {
try {
newNotice(buyerUid)
.withLogPrefix("notice buyer buyer cancel before depot receive")
.withInBox(InboxBusinessTypeEnum.PURCHASE_CLOSED_BY_BUYER_AFTER_DELIVERY, orderCode,compesant)
.withInBox(InboxBusinessTypeEnum.PURCHASE_CLOSED_BY_BUYER_AFTER_DELIVERY, orderCode, compesant)
.send();
} catch (Exception e) {
log.warn("notice buyer buyer cancel before depot receive, buyerUid {}, orderCode {}", buyerUid, orderCode, e);
}
}
public void buyerCancelBeforeSellerDeliver(@NonNull BuyerOrder buyerOrder,String compesant, SellerOrderGoods sog) {
public void buyerCancelBeforeSellerDeliver(@NonNull BuyerOrder buyerOrder, String compesant, SellerOrderGoods sog) {
Integer buyerUid = buyerOrder.getUid();
Long orderCode = buyerOrder.getOrderCode();
try {
newNotice(buyerUid)
.withLogPrefix("notice buyer buyer cancel before seller receive")
.withInBox(InboxBusinessTypeEnum.PURCHASE_CLOSED_BY_BUYER_AFTER_PAID, orderCode,compesant)
.withInBox(InboxBusinessTypeEnum.PURCHASE_CLOSED_BY_BUYER_AFTER_PAID, orderCode, compesant)
.send();
} catch (Exception e) {
log.warn("notice buyer buyer cancel before seller receive fail, buyerUid {}, orderCode {}", buyerUid, orderCode, e);
... ...