...
|
...
|
@@ -152,9 +152,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
|
|
|
/**
|
|
|
* 提交订单
|
|
|
*
|
|
|
* @param orderRequest
|
|
|
*/
|
|
|
public void confirm(OrderRequest orderRequest){
|
|
|
public void confirm(OrderRequest orderRequest) {
|
|
|
|
|
|
// 参数检查 ![待收货] 不合法
|
|
|
DataNode node = checkBase(orderRequest);
|
...
|
...
|
@@ -162,12 +163,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
OrderStatus buyerOrderStatus = OrderStatus.getOrderStatus(buyerOrder.getStatus());
|
|
|
OrderStatus expectStatus;
|
|
|
// 如果当前订单状态为待寄存或待收货
|
|
|
if(buyerOrderStatus == OrderStatus.JUDGE_PASS_WAIT_WAREHOUSE){
|
|
|
if (buyerOrderStatus == OrderStatus.JUDGE_PASS_WAIT_WAREHOUSE) {
|
|
|
expectStatus = OrderStatus.JUDGE_PASS_WAIT_WAREHOUSE;
|
|
|
} else {
|
|
|
expectStatus = OrderStatus.WAITING_RECEIVE;
|
|
|
}
|
|
|
checkStatus(node,orderRequest, expectStatus);
|
|
|
checkStatus(node, orderRequest, expectStatus);
|
|
|
int uid = buyerOrder.getUid();
|
|
|
long orderCode = buyerOrder.getOrderCode();
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
...
|
...
|
@@ -189,8 +190,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
.build());
|
|
|
|
|
|
//记录状态信息
|
|
|
logger.info("in seller confirm record status change, orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
|
|
|
orderStatusFlowService.addAsy(orderCode,OrderStatus.DONE.getCode());
|
|
|
logger.info("in seller confirm record status change, orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
|
|
|
orderStatusFlowService.addAsy(orderCode, OrderStatus.DONE.getCode());
|
|
|
cacheCleaner.cleanSellerAndBuyerOrderDetailAndList(sellerUid, uid, orderCode);
|
|
|
|
|
|
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(uid); // 清理有货个人中心接口缓存的UFO订单数量的缓存
|
...
|
...
|
@@ -201,8 +202,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 买家修改收货地址:
|
|
|
* 鉴定中心确定收货之前,都可以修改地址
|
...
|
...
|
@@ -211,45 +210,42 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
@Override
|
|
|
public boolean buyerModifyAddress(int uid, long orderCode,
|
|
|
AddressInfo changedAddress,
|
|
|
final boolean fromPlatform){
|
|
|
final boolean fromPlatform) {
|
|
|
|
|
|
boolean result = buyerOrderMetaService.buyerSelfModifyAddress(uid, orderCode,changedAddress, fromPlatform);
|
|
|
boolean result = buyerOrderMetaService.buyerSelfModifyAddress(uid, orderCode, changedAddress, fromPlatform);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 取消订单
|
|
|
*
|
|
|
* @param orderRequest
|
|
|
*/
|
|
|
@Override
|
|
|
public void cancel(OrderRequest orderRequest){
|
|
|
public void cancel(OrderRequest orderRequest) {
|
|
|
logger.info("Buyer Order cancel (OrderRequest) {}", orderRequest);
|
|
|
doCancel(orderRequest);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void cancelByCS(BuyerOrderCancelReq request) {
|
|
|
logger.info("in buyer order cancelByCS, req {}",request);
|
|
|
logger.info("in buyer order cancelByCS, req {}", request);
|
|
|
int uid = request.getUid();
|
|
|
long orderCode = request.getOrderCode();
|
|
|
int cancelType = request.getCancelType();
|
|
|
BuyerOrderCancelType boct = BuyerOrderCancelType.getBuyerOrderCancelType(cancelType);
|
|
|
if (Objects.isNull(boct)){
|
|
|
if (Objects.isNull(boct)) {
|
|
|
buyerOrderCancelService.cancelForSellerShamSendOut(uid, orderCode, OrderStatus.SELLER_SHAM_SEND_OUT);
|
|
|
return;
|
|
|
}
|
|
|
switch (boct){
|
|
|
switch (boct) {
|
|
|
case PULL_WOOL:
|
|
|
logger.info("in buyer order cancelByCS because pull wool, req {}",request);
|
|
|
logger.info("in buyer order cancelByCS because pull wool, req {}", request);
|
|
|
buyerOrderCancelService.cancelForBuyerPullWool(request);
|
|
|
break;
|
|
|
case SELLER_CAN_NOT_SEND_OUT:
|
|
|
buyerOrderCancelService.cancelForSellerCanNotSendOut(uid, orderCode);
|
|
|
default:
|
|
|
logger.warn("in buyer order cancelByCS not match any BuyerOrderCancelType, req {}", request);
|
|
|
break;
|
...
|
...
|
@@ -299,28 +295,29 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
|
|
|
/**
|
|
|
* protect hack action
|
|
|
*
|
|
|
* @param buyerOrder
|
|
|
* @param pbog
|
|
|
*/
|
|
|
private void checkCancelable(BuyerOrder buyerOrder, BuyerOrderGoods pbog){
|
|
|
private void checkCancelable(BuyerOrder buyerOrder, BuyerOrderGoods pbog) {
|
|
|
boolean isDepositOrder = BuyerOrderUtils.isDeposit(buyerOrder);
|
|
|
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(pbog.getSkup());
|
|
|
SkupType skupType = SkupType.getSkupType(psog.getAttributes());
|
|
|
boolean isQuickDeliverGoods = SellerGoodsHelper.isQuickDeliver(skupType);
|
|
|
|
|
|
if (isDepositOrder && isQuickDeliverGoods){
|
|
|
if (isDepositOrder && isQuickDeliverGoods) {
|
|
|
logger.warn("checkCancelable find illegal action, uid {} orderCode {}", buyerOrder.getUid(), buyerOrder.getOrderCode());
|
|
|
throw new UfoServiceException(400, "闪购商品订单不允许取消");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void doCancel(OrderRequest orderRequest){
|
|
|
private void doCancel(OrderRequest orderRequest) {
|
|
|
DataNode node = checkBase(orderRequest);
|
|
|
BuyerOrder buyerOrder = node.buyerOrderInDB;
|
|
|
Integer orderStatus = buyerOrder.getStatus();
|
|
|
OrderStatus expectStatus = null ;
|
|
|
if (orderStatus == null || (expectStatus = OrderStatus.getOrderStatus(orderStatus))== null){
|
|
|
logger.warn("in buyer cancel check orderStatus fail, orderStatus {} expectStatus {}", orderStatus,expectStatus );
|
|
|
OrderStatus expectStatus = null;
|
|
|
if (orderStatus == null || (expectStatus = OrderStatus.getOrderStatus(orderStatus)) == null) {
|
|
|
logger.warn("in buyer cancel check orderStatus fail, orderStatus {} expectStatus {}", orderStatus, expectStatus);
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
logger.info("in buyer cancel, req {} expectStatus {}", orderRequest, expectStatus);
|
...
|
...
|
@@ -332,7 +329,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
Long orderCode = buyerOrder.getOrderCode();
|
|
|
|
|
|
boolean useDepositGoods = node.useDepositGoods;
|
|
|
switch (expectStatus){
|
|
|
switch (expectStatus) {
|
|
|
case WAITING_PAY_DEPOSIT:
|
|
|
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOSIT_PAY;
|
|
|
buyerOrderStateChangers.selectOneToChange(buyerOrder, OrderStatus.WAITING_PAY_DEPOSIT, targetStatus);
|
...
|
...
|
@@ -372,18 +369,18 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
.useDepositGoods(useDepositGoods)
|
|
|
.build();
|
|
|
int updateOrderFlag = buyerOrderCancelService.cancel(bsde);
|
|
|
if (updateOrderFlag>0){
|
|
|
if (node.isDepositGoods){
|
|
|
if (updateOrderFlag > 0) {
|
|
|
if (node.isDepositGoods) {
|
|
|
asyncUnlockDepositGoods(buyerOrder.getSellerUid(), node.depositCodeOfSkup);
|
|
|
}
|
|
|
}
|
|
|
//取消事件
|
|
|
orderChangeListenerContainer.fireAsyncEvent(new BuyerOrderChangeEvent(buyerOrder, BuyerOrderChangeEvent.BizCase.CANCEL_BYBUYER, targetStatus));
|
|
|
orderStatusFlowService.addAsy(orderCode,targetStatus.getCode());
|
|
|
orderStatusFlowService.addAsy(orderCode, targetStatus.getCode());
|
|
|
break;
|
|
|
case SELLER_SEND_OUT:
|
|
|
bog = buyerOrderGoodsMapper.selectByOrderCode(uid = orderRequest.getUid(),
|
|
|
orderCode=orderRequest.getOrderCode());
|
|
|
orderCode = orderRequest.getOrderCode());
|
|
|
skup = bog.getSkup();
|
|
|
targetStatus = useDepositGoods ? OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE_USE_DEPOSIT_GOODS
|
|
|
: OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
|
...
|
...
|
@@ -397,18 +394,18 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
buyerOrderCancelService.cancel(bdre);
|
|
|
//取消事件
|
|
|
orderChangeListenerContainer.fireAsyncEvent(new BuyerOrderChangeEvent(buyerOrder, BuyerOrderChangeEvent.BizCase.CANCEL_BYBUYER, targetStatus));
|
|
|
orderStatusFlowService.addAsy(orderCode,targetStatus.getCode());
|
|
|
orderStatusFlowService.addAsy(orderCode, targetStatus.getCode());
|
|
|
break;
|
|
|
default:
|
|
|
logger.warn("in buyer cancel fail uid {} order code {} expectStatus {}",
|
|
|
buyerOrder.getUid(),buyerOrder.getOrderCode(), expectStatus);
|
|
|
buyerOrder.getUid(), buyerOrder.getOrderCode(), expectStatus);
|
|
|
throw new UfoServiceException(401, "订单状态已变更,不能取消");
|
|
|
}
|
|
|
//记录状态变更信息
|
|
|
logger.info("in doCancel record status {} change to {}, orderRequest {}", expectStatus, targetStatus, orderRequest);
|
|
|
}
|
|
|
|
|
|
private void asyncUnlockDepositGoods(Integer sellerUid,String depositCode){
|
|
|
private void asyncUnlockDepositGoods(Integer sellerUid, String depositCode) {
|
|
|
Callable<Integer> depositGoodsTask = () -> depositService.updateSellLock(sellerUid, depositCode, 0);
|
|
|
Future<Integer> future = ThreadPoolFactory.getCommomExecutorService().submit(depositGoodsTask);
|
|
|
logger.info("asyncUnlockDepositGoodsIf depositCode {} future.isDone {}", depositCode, future.isDone());
|
...
|
...
|
@@ -416,13 +413,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void cancelBeforePaid(OrderRequest orderRequest, DataNode dataNode, OrderStatus exceptStatus, OrderStatus targetStatus){
|
|
|
public void cancelBeforePaid(OrderRequest orderRequest, DataNode dataNode, OrderStatus exceptStatus, OrderStatus targetStatus) {
|
|
|
// 状态 ![待付款] 不合法
|
|
|
checkStatus(dataNode, orderRequest, exceptStatus);
|
|
|
|
|
|
// 近一分钟内有预支付记录
|
|
|
if (orderRequest.getOrderCancelEvent()!=null && !orderRequest.getOrderCancelEvent().isFinalRetry()){
|
|
|
if (orderRequest.getOrderCancelEvent() != null && !orderRequest.getOrderCancelEvent().isFinalRetry()) {
|
|
|
paymentService.checkPrePay(orderRequest.getUid(), orderRequest.getOrderCode());
|
|
|
}
|
|
|
final BuyerOrder buyerOrder = dataNode.buyerOrderInDB;
|
...
|
...
|
@@ -437,13 +433,13 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
tbo.setOrderCode(orderCode = orderRequest.getOrderCode());
|
|
|
tbo.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
buyerOrderMapper.updateByOrderCode(tbo);
|
|
|
if (dataNode.isDepositGoods){
|
|
|
if (dataNode.isDepositGoods) {
|
|
|
asyncUnlockDepositGoods(sellerUid, dataNode.depositCodeOfSkup);
|
|
|
}
|
|
|
// 更新skup的状态[出售中] 卖家订单为[可售]
|
|
|
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(orderRequest.getUid(), orderCode);
|
|
|
int skup = bog.getSkup();
|
|
|
SellerOrderGoods psog= sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
Integer skupStatus = psog.getStatus();
|
|
|
//todo check skupStatus
|
|
|
SellerOrderGoods tsog = new SellerOrderGoods();
|
...
|
...
|
@@ -455,7 +451,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
boolean isReturnSuccess = productProxyService.returnStorage(skup);
|
|
|
|
|
|
// 急速发货的场合,释放库存
|
|
|
if (fastDeliveryProxyService.isFastDeliveryGoods(skup)){
|
|
|
if (fastDeliveryProxyService.isFastDeliveryGoods(skup)) {
|
|
|
fastDeliveryProxyService.cancel(psog.getUid(), skup);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -476,7 +472,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
class DataNode{
|
|
|
class DataNode {
|
|
|
BuyerOrder buyerOrderInDB;
|
|
|
String depositCodeOfSellerUsingDeliver;
|
|
|
boolean useDepositGoods;
|
...
|
...
|
@@ -484,12 +480,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
boolean isDepositGoods;
|
|
|
}
|
|
|
|
|
|
DataNode checkBase(OrderRequest orderRequest){
|
|
|
DataNode checkBase(OrderRequest orderRequest) {
|
|
|
int uid;
|
|
|
long orderCode;
|
|
|
// 参数检查
|
|
|
if ((uid=orderRequest.getUid()) < 0
|
|
|
|| (orderCode=orderRequest.getOrderCode()) < 0){
|
|
|
if ((uid = orderRequest.getUid()) < 0
|
|
|
|| (orderCode = orderRequest.getOrderCode()) < 0) {
|
|
|
logger.warn("check uid or orderCode empty");
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
...
|
...
|
@@ -497,16 +493,16 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
// 订单存在 & 待付款的状态
|
|
|
// 查询订单状态
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderRequest.getOrderCode(), orderRequest.getUid());
|
|
|
if (buyerOrder == null){
|
|
|
if (buyerOrder == null) {
|
|
|
logger.warn("check orderCode exist, uid is {}, orderCode is {}",
|
|
|
orderRequest.getUid(), orderRequest.getOrderCode() );
|
|
|
orderRequest.getUid(), orderRequest.getOrderCode());
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
DataNode node = new DataNode();
|
|
|
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
|
|
|
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(buyerOrderGoods.getSkup());
|
|
|
SkupType skupType = SkupType.getSkupType(sellerOrderGoods.getAttributes());
|
|
|
if(skupType == SkupType.QUICK_DELIVER) {
|
|
|
if (skupType == SkupType.QUICK_DELIVER) {
|
|
|
String depositCode = findDepoistGoods(buyerOrder.getSellerUid(), buyerOrderGoods.getSkup());
|
|
|
node.depositCodeOfSkup = depositCode;
|
|
|
node.isDepositGoods = true;
|
...
|
...
|
@@ -520,33 +516,32 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String findDepositCodeOfSellerUsingDeliver(Integer uid, Long orderCode){
|
|
|
private String findDepositCodeOfSellerUsingDeliver(Integer uid, Long orderCode) {
|
|
|
|
|
|
String depositCode = buyerOrderMetaService.getDepositCode(uid, orderCode);
|
|
|
return depositCode;
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
private SellerOrderMetaService sellerOrderMetaService;
|
|
|
|
|
|
private String findDepoistGoods(Integer sellerUid, Integer skup){
|
|
|
private String findDepoistGoods(Integer sellerUid, Integer skup) {
|
|
|
String depoistCode = sellerOrderMetaService.getDepoistCode(sellerUid, skup);
|
|
|
|
|
|
return depoistCode;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param orderRequest
|
|
|
* @param orderStatusEx
|
|
|
*/
|
|
|
private void checkStatus(DataNode node, OrderRequest orderRequest, OrderStatus orderStatusEx ) {
|
|
|
private void checkStatus(DataNode node, OrderRequest orderRequest, OrderStatus orderStatusEx) {
|
|
|
|
|
|
BuyerOrder buyerOrder = node.buyerOrderInDB;
|
|
|
// 检查 订单状态
|
|
|
int status = buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus().intValue();
|
|
|
OrderStatus orderStatus = OrderStatus.getOrderStatus(status);
|
|
|
if (orderStatus == null || orderStatus.getCode() != orderStatusEx.getCode()){
|
|
|
if (orderStatus == null || orderStatus.getCode() != orderStatusEx.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);
|
...
|
...
|
@@ -554,11 +549,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
|
|
|
// 状态是待支付的场合,到第三方检查是否支付过了
|
|
|
Payment payment = Payment.getPayment(buyerOrder.getPayment());
|
|
|
if (payment != null && status == OrderStatus.WAITING_PAY.getCode()){
|
|
|
if (payment != null && status == OrderStatus.WAITING_PAY.getCode()) {
|
|
|
AbstractPayService payService = paymentService.getPayService(payment.getCode());
|
|
|
PayQueryBo payQueryBo = payService.payQuery(String.valueOf(buyerOrder.getOrderCode()), buyerOrder.getCreateTime());
|
|
|
|
|
|
if (payQueryBo != null && payQueryBo.isPayStatus()){
|
|
|
if (payQueryBo != null && payQueryBo.isPayStatus()) {
|
|
|
logger.warn("check status failed ,confirm paid, uid is {}, orderCode is {}, status is {}",
|
|
|
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrder.getStatus());
|
|
|
// 主动触发支付结果确认
|
...
|
...
|
@@ -571,23 +566,21 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询订单数量
|
|
|
*
|
|
|
* @param uid
|
|
|
* @return
|
|
|
*/
|
|
|
public BuyerOrderNums getBuyerOrderNums(int uid){
|
|
|
public BuyerOrderNums getBuyerOrderNums(int uid) {
|
|
|
|
|
|
if (uid < 0){
|
|
|
if (uid < 0) {
|
|
|
logger.warn("buyer delete, uid or orderCode empty, uid {}", uid);
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
|
|
|
BuyerOrderNums buyerOrderNumsCache = orderCacheService.getBuyerOrderNums(uid);
|
|
|
if (buyerOrderNumsCache != null){
|
|
|
if (buyerOrderNumsCache != null) {
|
|
|
logger.info("getBuyerOrderNums result uid is {}, result is {}", uid, buyerOrderNumsCache);
|
|
|
return buyerOrderNumsCache;
|
|
|
}
|
...
|
...
|
@@ -595,7 +588,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
|
|
|
List<BuyOrderNums> buyOrderNumList = buyerOrderMapper.selectCntByUidStatusAll(uid);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(buyOrderNumList)){
|
|
|
if (CollectionUtils.isEmpty(buyOrderNumList)) {
|
|
|
return BuyerOrderNums.builder().build();
|
|
|
}
|
|
|
|
...
|
...
|
@@ -618,12 +611,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
return buyerOrderNums;
|
|
|
}
|
|
|
|
|
|
private int getValueDefalutZero(Map<Integer, Integer> map, List<Integer> status){
|
|
|
private int getValueDefalutZero(Map<Integer, Integer> map, List<Integer> status) {
|
|
|
|
|
|
int sum = 0;
|
|
|
for(Integer key : status){
|
|
|
for (Integer key : status) {
|
|
|
int num = Objects.isNull(map.get(key)) ? 0 : map.get(key);
|
|
|
sum+=num;
|
|
|
sum += num;
|
|
|
}
|
|
|
|
|
|
return sum;
|
...
|
...
|
@@ -633,54 +626,52 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
@Override
|
|
|
public boolean delete(int uid, long orderCode) {
|
|
|
if (uid < 0
|
|
|
|| orderCode < 0){
|
|
|
|| orderCode < 0) {
|
|
|
logger.warn("buyer delete, uid or orderCode empty, uid {}, orderCode {}", uid, orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, uid);
|
|
|
if (Objects.isNull(buyerOrder) || buyerOrder.getBuyerOrderStatus() == DelStatus.IS_DEL.getCode()){
|
|
|
if (Objects.isNull(buyerOrder) || buyerOrder.getBuyerOrderStatus() == DelStatus.IS_DEL.getCode()) {
|
|
|
logger.warn("buyer delete, order not exist, uid {}, orderCode {}", uid, orderCode);
|
|
|
return false;
|
|
|
}
|
|
|
Integer status;
|
|
|
if(ActionStatusHold.getBuyerCanDelStatusList().contains(status=buyerOrder.getStatus())){
|
|
|
if (ActionStatusHold.getBuyerCanDelStatusList().contains(status = buyerOrder.getStatus())) {
|
|
|
BuyerOrder target = new BuyerOrder();
|
|
|
target.setId(buyerOrder.getId());
|
|
|
target.setBuyerOrderStatus(DelStatus.IS_DEL.getCode());
|
|
|
boolean result = buyerOrderMapper.updateByPrimaryKeySelective(target) == 1;
|
|
|
if(result){
|
|
|
if (result) {
|
|
|
cacheCleaner.cleanList(uid, TabType.BUY.getValue());
|
|
|
}
|
|
|
return result;
|
|
|
}else{
|
|
|
} else {
|
|
|
logger.warn("buyer delete fail, order status {}", status);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void confirmReceive(long orderCode) {
|
|
|
logger.info("in confirmReceive, orderCode {}", orderCode);
|
|
|
if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
|
|
|
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)) {
|
|
|
logger.info("in confirmReceive isGoodsServiceOrder, orderCode {}", orderCode);
|
|
|
|
|
|
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
|
|
|
int rows = existenceNode.getGoodsService().platformReceiveGoods(existenceNode.appraiseOrder);
|
|
|
if (rows==0){
|
|
|
if (rows == 0) {
|
|
|
return;
|
|
|
}
|
|
|
// 确认收货过来的是子订单号
|
|
|
int uid = existenceNode.getAppraiseOrder().getUid();
|
|
|
Long parentOrderCode = existenceNode.getAppraiseOrder().getParentOrderCode();
|
|
|
if (parentOrderCode == null){
|
|
|
if (parentOrderCode == null) {
|
|
|
// 平台收货 内部调拨信息
|
|
|
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.platform_receive;
|
|
|
expressInfoService.saveOperateTransferExpressInfo(existenceNode.getAppraiseOrder().getUid(), orderCode ,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
expressInfoService.saveOperateTransferExpressInfo(existenceNode.getAppraiseOrder().getUid(), orderCode, expressType.getCode(), expressDataType, operateTransferCode);
|
|
|
return;
|
|
|
}
|
|
|
// 上一个状态是[卖家已发货] 该父订单下状态为[卖家已发货]的子订单数量为0,代表父订单状态应该为 [已收货]
|
...
|
...
|
@@ -689,28 +680,28 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
logger.info("no confirm delivery sub order cnt is {}, parentOrderCode {}", cnt, parentOrderCode);
|
|
|
int cdt = DateUtil.getCurrentTimeSecond();
|
|
|
//
|
|
|
if (cnt == 0){
|
|
|
if (cnt == 0) {
|
|
|
// 平台收货 内部调拨信息
|
|
|
try {
|
|
|
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.platform_receive;
|
|
|
expressInfoService.saveOperateTransferExpressInfo(existenceNode.getAppraiseOrder().getUid(), parentOrderCode, expressType.getCode(), expressDataType, operateTransferCode);
|
|
|
}catch (Exception ex){
|
|
|
} catch (Exception ex) {
|
|
|
logger.warn("in confirmReceive isGoodsServiceOrder saveOperateTransferExpressInfo fail ,orderCode {} ", orderCode, ex);
|
|
|
}
|
|
|
//update
|
|
|
sellerDepositOrderService.platformFinishReceiveGoods(uid, parentOrderCode);
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
} else {
|
|
|
|
|
|
confirmReceive4BuyerOrder(orderCode);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void confirmReceive4BuyerOrder(long orderCode){
|
|
|
private void confirmReceive4BuyerOrder(long orderCode) {
|
|
|
|
|
|
OrderStatus expectStatus = OrderStatus.SELLER_SEND_OUT;
|
|
|
OrderStatus targetStatus = OrderStatus.PLATFORM_RECEIVE;
|
...
|
...
|
@@ -718,40 +709,41 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
BuyerOrderAssistant.PreparedData preparedData = buyerOrderAssistant.prepare(orderCode);
|
|
|
BuyerOrder buyerOrder = preparedData.getBuyerOrder();
|
|
|
|
|
|
if (buyerOrder != null && buyerOrder.getStatus() == expectStatus.getCode()){
|
|
|
if (buyerOrder != null && buyerOrder.getStatus() == expectStatus.getCode()) {
|
|
|
int uid = buyerOrder.getUid();
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
logger.info("in confirmReceive begin update status orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
|
|
|
logger.info("in confirmReceive begin update status orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
|
|
|
int num = buyerOrderMapper.updateStatusByOrderCode(orderCode, uid, expectStatus.getCode(),
|
|
|
targetStatus.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
|
|
|
//记录订单的状态变更信息
|
|
|
if(num>=1){
|
|
|
logger.info("in confirmReceive record status change, orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
|
|
|
if (num >= 1) {
|
|
|
logger.info("in confirmReceive record status change, orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
|
|
|
buyerNoticeFacade.platformReceiveGoods(buyerOrder);
|
|
|
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetStatus.getCode());
|
|
|
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
|
|
|
//
|
|
|
finishDepositGoodsIf(preparedData);
|
|
|
}else{
|
|
|
logger.warn("in confirmReceive not record status change cause of update empty num , orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
|
|
|
} else {
|
|
|
logger.warn("in confirmReceive not record status change cause of update empty num , orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
|
|
|
}
|
|
|
|
|
|
//记录调拨信息(只保存卖家一条)
|
|
|
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.platform_receive;
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
|
|
|
|
|
|
cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
|
|
|
cleanCacheAfterUpdateStatus(orderCode, uid, sellerUid);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 现货寄存订单
|
|
|
* 卖家使用寄存商品发货
|
|
|
*
|
|
|
* @param preparedData
|
|
|
*/
|
|
|
private void finishDepositGoodsIf(BuyerOrderAssistant.PreparedData preparedData){
|
|
|
private void finishDepositGoodsIf(BuyerOrderAssistant.PreparedData preparedData) {
|
|
|
BuyerOrder buyerOrder = preparedData.getBuyerOrder();
|
|
|
int uid = buyerOrder.getUid();
|
|
|
Long orderCode = buyerOrder.getOrderCode();
|
...
|
...
|
@@ -759,11 +751,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
SkupType skupType = SkupType.getSkupType(psog.getAttributes());
|
|
|
boolean isInstockDepositOrder = BuyerOrderUtils.isInstockDeposit(skupType, buyerOrder.getAttributes());
|
|
|
logger.info("platform confirmReceive orderCode {} buyerUid {} isInstockDepositOrder {}", orderCode, uid, isInstockDepositOrder);
|
|
|
if(isInstockDepositOrder){
|
|
|
if (isInstockDepositOrder) {
|
|
|
String depositCode = buyerOrderMetaService.getDepositCode(uid, orderCode);
|
|
|
logger.info("platform confirmReceive orderCode {} buyerUid {} isInstockDepositOrder {} depositCode {}",
|
|
|
orderCode, uid, isInstockDepositOrder, depositCode);
|
|
|
if (StringUtils.isNotBlank(depositCode)){
|
|
|
if (StringUtils.isNotBlank(depositCode)) {
|
|
|
int depositUpdate = depositService.updateDelStatus(psog.getUid(), depositCode);
|
|
|
logger.info("platform confirmReceive update deposit DelStatus {} orderCode {} buyerUid {} depositCode {}",
|
|
|
depositUpdate, orderCode, uid, depositCode);
|
...
|
...
|
@@ -775,65 +767,64 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
// 质检通过,不需要记录物流调拨信息
|
|
|
@Override
|
|
|
@Deprecated
|
|
|
public void qualityCheckPass(long orderCode){
|
|
|
public void qualityCheckPass(long orderCode) {
|
|
|
logger.info("in qualityCheckPass, orderCode {}", orderCode);
|
|
|
|
|
|
|
|
|
|
|
|
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
|
|
|
OrderStatus targetStatus = OrderStatus.PLATFORM_CHECKING;
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
|
|
|
|
|
|
if (buyerOrder != null && buyerOrder.getStatus() == expectStatus.getCode()){
|
|
|
if (buyerOrder != null && buyerOrder.getStatus() == expectStatus.getCode()) {
|
|
|
int uid = buyerOrder.getUid();
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
logger.info("in qualityCheckPass begin update status orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
|
|
|
int num=buyerOrderMapper.updateStatusByOrderCode(orderCode, uid, expectStatus.getCode(),
|
|
|
logger.info("in qualityCheckPass begin update status orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
|
|
|
int num = buyerOrderMapper.updateStatusByOrderCode(orderCode, uid, expectStatus.getCode(),
|
|
|
targetStatus.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
|
|
|
//记录订单的状态变更信息
|
|
|
if(num>=1){
|
|
|
logger.info("in qualityCheckPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
|
|
|
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetStatus.getCode());
|
|
|
if (num >= 1) {
|
|
|
logger.info("in qualityCheckPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
|
|
|
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
|
|
|
|
|
|
//记录调拨信息(只保存卖家一条)
|
|
|
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
|
|
|
|
|
|
|
|
|
}else{
|
|
|
logger.warn("in qualityCheckPass not record status change cause of update empty num , orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
|
|
|
} else {
|
|
|
logger.warn("in qualityCheckPass not record status change cause of update empty num , orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
|
|
|
}
|
|
|
|
|
|
cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
|
|
|
cleanCacheAfterUpdateStatus(orderCode, uid, sellerUid);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 瑕疵创建
|
|
|
@Override
|
|
|
public void miniFaultCreate(SaveQualityCheckInfoRequest request){
|
|
|
public void miniFaultCreate(SaveQualityCheckInfoRequest request) {
|
|
|
logger.info("in miniFaultCreate, orderCode {}", request);
|
|
|
long orderCode = request.getOrderCode();
|
|
|
QualityCheck qualityCheck = request.getQualityCheck();
|
|
|
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
|
|
|
OrderStatus targetStatus = OrderStatus.MINI_FAULT_WAITING;
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
|
|
|
if (buyerOrder == null ){
|
|
|
throw new ServiceException(400,"订单为空");
|
|
|
if (buyerOrder == null) {
|
|
|
throw new ServiceException(400, "订单为空");
|
|
|
}
|
|
|
|
|
|
if( buyerOrder.getStatus() != expectStatus.getCode()){
|
|
|
throw new ServiceException(400,"订单状态发生变化");
|
|
|
if (buyerOrder.getStatus() != expectStatus.getCode()) {
|
|
|
throw new ServiceException(400, "订单状态发生变化");
|
|
|
}
|
|
|
int uid = buyerOrder.getUid();
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
|
|
|
//保存质检有问题的图片信息
|
|
|
if(qualityCheck==null){
|
|
|
logger.warn("in miniFaultCreate qualityCheck is null, orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
|
|
|
throw new ServiceException(400,"瑕疵信息为空");
|
|
|
if (qualityCheck == null) {
|
|
|
logger.warn("in miniFaultCreate qualityCheck is null, orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
|
|
|
throw new ServiceException(400, "瑕疵信息为空");
|
|
|
}
|
|
|
qualityCheckMapper.insert(qualityCheck);
|
|
|
|
...
|
...
|
@@ -845,24 +836,24 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
|
|
|
|
|
|
//记录调拨信息(只保存卖家一条)
|
|
|
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_create;
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
|
|
|
|
|
|
//TODO 产生一个延时队列(24小时后,超时确认)
|
|
|
BuyerMiniFaultOuterTimeEvent miniFaultOuterTimeEvent = BuyerMiniFaultOuterTimeEvent.builder().uid(uid).orderCode(orderCode).build();
|
|
|
logger.info("in miniFaultCreate, push event uid {} ,order code {} ", miniFaultOuterTimeEvent.getUid(),miniFaultOuterTimeEvent.getOrderCode());
|
|
|
logger.info("in miniFaultCreate, push event uid {} ,order code {} ", miniFaultOuterTimeEvent.getUid(), miniFaultOuterTimeEvent.getOrderCode());
|
|
|
EventBusPublisher.publishEvent(miniFaultOuterTimeEvent);
|
|
|
|
|
|
|
|
|
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
|
|
|
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(orderCode, uid, sellerUid);
|
|
|
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
|
|
|
//消息
|
|
|
buyerNoticeFacade.miniFaultCreated(buyerOrder,sellerOrderGoods,product);
|
|
|
buyerNoticeFacade.miniFaultCreated(buyerOrder, sellerOrderGoods, product);
|
|
|
|
|
|
//记录订单的状态变更信息
|
|
|
logger.info("in miniFaultCreate record status change, orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
|
...
|
...
|
@@ -871,29 +862,27 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void modifyAddressOfDepositOrder(int uid, Long orderCode, String addressIdstr) {
|
|
|
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
|
|
|
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)) {
|
|
|
sellerDepositOrderService.addOrModifyAddress(uid, orderCode, addressIdstr);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
int addressId = AddressUtil.getDecryptStr(addressIdstr);
|
|
|
if (addressId < 0){
|
|
|
if (addressId < 0) {
|
|
|
logger.warn("modifyAddressOfDepositOrder addressId invalidate, uid {}, orderCode {}, addressId is {}",
|
|
|
uid, orderCode, addressIdstr);
|
|
|
throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE);
|
|
|
}
|
|
|
BuyerOrder pbo = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
if (pbo == null ){
|
|
|
if (pbo == null) {
|
|
|
logger.warn("in modifyAddressOfDepositOrder BuyerOrder is null,uid {} orderCode {} addressIdstr {}",
|
|
|
uid, orderCode, addressIdstr);
|
|
|
return;
|
|
|
}
|
|
|
Integer oa;
|
|
|
if (OrderAttributes.DEPOSITE.getCode() != (oa=pbo.getAttributes())){
|
|
|
if (OrderAttributes.DEPOSITE.getCode() != (oa = pbo.getAttributes())) {
|
|
|
logger.warn("in modifyAddressOfDepositOrder BuyerOrder.Attributes is {},uid {} orderCode {} addressIdstr {}",
|
|
|
oa, uid, orderCode, addressIdstr);
|
|
|
return;
|
...
|
...
|
@@ -936,7 +925,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
|
|
|
@Override
|
|
|
public BuyerOrderMeta buildnoHiddenAddressMeta(int uid, long orderCode, String key, AddressInfo noHiddenBackAddress) {
|
|
|
BuyerOrderMeta noHiddenAddressMeta=new BuyerOrderMeta();
|
|
|
BuyerOrderMeta noHiddenAddressMeta = new BuyerOrderMeta();
|
|
|
noHiddenAddressMeta.setUid(uid);
|
|
|
noHiddenAddressMeta.setOrderCode(orderCode);
|
|
|
noHiddenAddressMeta.setMetaKey(key);
|
...
|
...
|
@@ -946,7 +935,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
|
|
|
@Override
|
|
|
public BuyerOrderMeta buildHiddenAddressMeta(int uid, long orderCode, String hiddenKey, AddressInfo hiddenBackAddress) {
|
|
|
BuyerOrderMeta hiddenAddressMeta=new BuyerOrderMeta();
|
|
|
BuyerOrderMeta hiddenAddressMeta = new BuyerOrderMeta();
|
|
|
hiddenAddressMeta.setUid(uid);
|
|
|
hiddenAddressMeta.setOrderCode(orderCode);
|
|
|
hiddenAddressMeta.setMetaKey(hiddenKey);
|
...
|
...
|
@@ -968,13 +957,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//清理缓存
|
|
|
private SellerOrderGoods cleanCacheAfterUpdateStatus(long orderCode,int uid,int sellerUid){
|
|
|
private SellerOrderGoods cleanCacheAfterUpdateStatus(long orderCode, int uid, int sellerUid) {
|
|
|
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
|
|
|
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup());
|
|
|
logger.info("in cleanCacheAfterUpdateStatus begin clean cache orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
|
|
|
logger.info("in cleanCacheAfterUpdateStatus begin clean cache orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
|
|
|
|
|
|
cacheCleaner.cleanSellerAndBuyerOrderDetailAndList(sellerUid, uid, orderCode);
|
|
|
|
...
|
...
|
@@ -984,12 +971,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public int processOrderDeliverByDepositGoods(BuyerOrderAssistant.PreparedData preparedData,
|
|
|
BuyerOrderAssistant.DepositSkuCheckNode dscNode){
|
|
|
BuyerOrderAssistant.DepositSkuCheckNode dscNode) {
|
|
|
|
|
|
if (!dscNode.isExistDepositGoods()){
|
|
|
if (!dscNode.isExistDepositGoods()) {
|
|
|
return 0;
|
|
|
}
|
|
|
BuyerOrderGoods pbog = preparedData.getBuyerOrderGoods();
|
...
|
...
|
@@ -1001,7 +987,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
Integer ownerUid = psd.getOwnerUid();
|
|
|
Integer sellerUid = buyerOrder.getSellerUid();
|
|
|
Integer skup;
|
|
|
boolean isExistSkup = Objects.nonNull(skup = psd.getNewSkup()) && skup>0;
|
|
|
boolean isExistSkup = Objects.nonNull(skup = psd.getNewSkup()) && skup > 0;
|
|
|
logger.info("processOrderDeliverByDepositGoods orderCode {} depositCode {} skup {}", orderCode, depositCode, skup);
|
|
|
|
|
|
//寄存商品 出库准备
|
...
|
...
|
@@ -1031,7 +1017,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
logger.info("processOrderDeliverByDepositGoods orderCode {} depositCode {} updateDepositWaitToPick {}", orderCode, depositCode, rows);
|
|
|
|
|
|
|
|
|
if (rows>0){
|
|
|
if (rows > 0) {
|
|
|
//bind deposit code 2 buyer order
|
|
|
buyerOrderMetaService.saveDepositCode(depositCode, buyerUid, orderCode);
|
|
|
//check
|
...
|
...
|
@@ -1041,7 +1027,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
|
|
|
//skup 下架
|
|
|
//skup 竟然在数据库有默认值0,什么鬼!!!
|
|
|
if (isExistSkup){
|
|
|
if (isExistSkup) {
|
|
|
// 减库存
|
|
|
asyncExecutePrdTask(psd);
|
|
|
//
|
...
|
...
|
@@ -1052,11 +1038,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
private Future<Boolean> asyncExecutePrdTask(StorageDeposit psd){
|
|
|
private Future<Boolean> asyncExecutePrdTask(StorageDeposit psd) {
|
|
|
Integer skup = psd.getNewSkup();
|
|
|
Integer productId = psd.getProductId();
|
|
|
final ExecutorService executorService = ThreadPoolFactory.getCommomExecutorService();
|
|
|
FutureTask<Boolean> futureTask = new FutureTask<>(()->productProxyService.subtractStorage(productId, skup));
|
|
|
FutureTask<Boolean> futureTask = new FutureTask<>(() -> productProxyService.subtractStorage(productId, skup));
|
|
|
executorService.submit(futureTask);
|
|
|
logger.info("asyncExecutePrdTask submit task, skup {} productId {}", skup, productId);
|
|
|
return futureTask;
|
...
|
...
|
@@ -1065,6 +1051,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
/**
|
|
|
* 这个方法请尽量保持单一原则
|
|
|
* 如果有复杂的业务逻辑 如入参数据需要动态判定时 请在调用前处理
|
|
|
*
|
|
|
* @param preparedData (include buyerOrder)
|
|
|
* @param req4Log
|
|
|
* @return
|
...
|
...
|
@@ -1074,7 +1061,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
OrderStatus targetOrderStatus,
|
|
|
SellerDeliverToDepotReq req4Log
|
|
|
|
|
|
){
|
|
|
) {
|
|
|
/*Integer expressCompanyId,
|
|
|
Integer expressType,
|
|
|
String wayBillCode,*/
|
...
|
...
|
@@ -1085,7 +1072,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
final OrderStatus expectOrderStatus = OrderStatus.HAS_PAYED;
|
|
|
|
|
|
logger.info("processBuyerOrderWhenSellerDeliver req {}, orderCode {},expectOrderStatus {} ,targetOrderStatus {} ",
|
|
|
new Object[]{req4Log, orderCode, expectOrderStatus, targetOrderStatus});
|
|
|
new Object[]{req4Log, orderCode, expectOrderStatus, targetOrderStatus});
|
|
|
Integer orderStatus = buyerOrder.getStatus();
|
|
|
if (orderStatus != expectOrderStatus.getCode()) {
|
|
|
logger.warn("deliverToDepot order status changed , orderCode {} orderStatus {}", orderCode, orderStatus);
|
...
|
...
|
@@ -1103,7 +1090,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerOrder.getUid(),
|
|
|
expectOrderStatus.getCode(), targetOrderStatus.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
logger.info("processBuyerOrderWhenSellerDeliver updateBuyerCnt {}, orderCode {}", updateBuyerCnt, orderCode);
|
|
|
if (updateBuyerCnt>0){
|
|
|
if (updateBuyerCnt > 0) {
|
|
|
//根据skup ,更新鉴定中心
|
|
|
int skup;
|
|
|
skupService.setDepotNum(skup = buyerOrderGoods.getSkup(), depotNum);
|
...
|
...
|
@@ -1112,12 +1099,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
final SellerOrderGoods psog = preparedData.getSellerOrderGoods();
|
|
|
|
|
|
// 极速: 无需再向买家发一遍[卖家发货]消息 & 虚拟单号无物流
|
|
|
if (psog.getAttributes() == OrderAttributes.FAST_DELIVERY.getCode()){
|
|
|
if (psog.getAttributes() == OrderAttributes.FAST_DELIVERY.getCode()) {
|
|
|
|
|
|
// 物流直接更新成1
|
|
|
buyerOrderMapper.updateSellerDeliveryStatusByOrderCode(orderCode, buyerUid,1);
|
|
|
}else{
|
|
|
if (targetOrderStatus == OrderStatus.SELLER_SEND_OUT){
|
|
|
buyerOrderMapper.updateSellerDeliveryStatusByOrderCode(orderCode, buyerUid, 1);
|
|
|
} else {
|
|
|
if (targetOrderStatus == OrderStatus.SELLER_SEND_OUT) {
|
|
|
buyerNoticeFacade.sellerDeliver2Depot(buyerOrder, psog);
|
|
|
//卖家物流检查
|
|
|
BuyerOrderSellerDeliveryCheckEvent sellerDeliveryCheckEvent = BuyerOrderSellerDeliveryCheckEvent.builder().uid(buyerUid).sellerUid(sellerUid).orderCode(orderCode).build();
|
...
|
...
|
@@ -1127,7 +1114,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
//
|
|
|
try {
|
|
|
cacheCleaner.cleanSellerAndBuyerOrderDetailAndList(sellerUid, buyerUid, orderCode);
|
|
|
}catch (Exception ex){
|
|
|
} catch (Exception ex) {
|
|
|
logger.warn("{}.processBuyerOrder clean cache fail, {}", getClass().getSimpleName(), orderCode, ex);
|
|
|
}
|
|
|
|
...
|
...
|
|