...
|
...
|
@@ -10,6 +10,7 @@ import com.yohobuy.ufo.model.order.common.TabType; |
|
|
import com.yohoufo.common.ApiResponse;
|
|
|
import com.yohoufo.common.alarm.EventBusPublisher;
|
|
|
import com.yohoufo.common.alarm.SmsAlarmEvent;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
...
|
...
|
@@ -104,7 +105,7 @@ public class AppraiseService { |
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
final OrderStatus expectOrderStatus = OrderStatus.PLATFORM_CHECKING;
|
|
|
final OrderStatus targetOrderStatus = OrderStatus.WAITING_RECEIVE;
|
|
|
final OrderStatus targetOrderStatus = OrderStatus.JUDGE_PASS;
|
|
|
if (expectOrderStatus.getCode() != buyerOrder.getStatus().intValue()){
|
|
|
LOGGER.warn("in appraiseSuccess, buyer Order orderCode {} pstatus {}, expect Order Status {}",
|
|
|
orderCode, buyerOrder.getStatus(), expectOrderStatus);
|
...
|
...
|
@@ -188,7 +189,8 @@ public class AppraiseService { |
|
|
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
|
|
|
EventBusPublisher.publishEvent(buyerConfirmEvent);
|
|
|
//记录物流信息
|
|
|
expressInfoService.appraiseSuccess(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
|
|
|
//不发物流
|
|
|
//expressInfoService.appraiseSuccess(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
|
|
|
//平台已发货给买家
|
|
|
inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods);
|
|
|
}catch (Exception ex){
|
...
|
...
|
@@ -273,6 +275,106 @@ public class AppraiseService { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发货
|
|
|
* (1)更新订单状态
|
|
|
* (2)记录物流
|
|
|
* (3)消息
|
|
|
*/
|
|
|
public void deliverGoods(AppraiseExpressInfoBo appraiseExpressInfoBo){
|
|
|
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
|
|
|
Long orderCode=appraiseExpressInfoBo.getOrderCode();
|
|
|
String wayBillCode=appraiseExpressInfoBo.getWayBillCode();
|
|
|
Integer depotNum=appraiseExpressInfoBo.getDepotNum();
|
|
|
String mobile=appraiseExpressInfoBo.getMobile();
|
|
|
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
|
|
|
if (buyerOrder == null){
|
|
|
LOGGER.warn("deliverGoods getOrderInfo order not exist, orderCode {}", orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
OrderStatus expectStatus = OrderStatus.JUDGE_PASS;
|
|
|
final OrderStatus targetStatus = OrderStatus.WAITING_RECEIVE;
|
|
|
if (buyerOrder.getStatus() != expectStatus.getCode()){
|
|
|
LOGGER.warn("deliverGoods expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
|
|
buyerOrder.getStatus(), orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
|
|
|
//更新状态为 (待收货[买家])
|
|
|
int buyerUid = buyerOrder.getUid();
|
|
|
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
|
|
|
int skup = bog.getSkup();
|
|
|
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
|
|
|
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
|
|
|
int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid,
|
|
|
expectStatus.getCode(), targetStatus.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
|
|
|
LOGGER.info("deliverGoods updateBuyerCnt {} ,expectStatus {}, actual status {}, orderCode {}", updateBuyerCnt ,expectStatus,
|
|
|
buyerOrder.getStatus(), orderCode);
|
|
|
if(updateBuyerCnt==1){
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
|
|
|
//记录物流信息
|
|
|
expressInfoService.appraiseSuccess(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
|
|
|
//平台已发货给买家 TODO
|
|
|
//inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods);
|
|
|
|
|
|
//清理
|
|
|
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
|
|
|
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
|
|
|
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
|
|
|
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
|
|
|
CacheKeyBuilder.orderDetailKey(buyerUid,TabType.BUY.getValue(), orderCode),
|
|
|
CacheKeyBuilder.buyerOrderNums(buyerUid)));
|
|
|
|
|
|
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid);
|
|
|
EventBusPublisher.publishEvent(event);
|
|
|
|
|
|
}else{
|
|
|
LOGGER.warn("in deliverGoods update buyer count fail ,expectStatus {}, actual status {}, orderCode {}", updateBuyerCnt ,expectStatus,
|
|
|
buyerOrder.getStatus(), orderCode);
|
|
|
throw new UfoServiceException(400,"更新订单状态失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 鉴定不通过退回
|
|
|
* (1)记录物流
|
|
|
* (2)消息
|
|
|
*/
|
|
|
public void returnBackOrderCauseOfJudgeFailure(AppraiseExpressInfoBo appraiseExpressInfoBo){
|
|
|
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
|
|
|
Long orderCode=appraiseExpressInfoBo.getOrderCode();
|
|
|
String wayBillCode=appraiseExpressInfoBo.getWayBillCode();
|
|
|
Integer depotNum=appraiseExpressInfoBo.getDepotNum();
|
|
|
String mobile=appraiseExpressInfoBo.getMobile();
|
|
|
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
|
|
|
if (buyerOrder == null){
|
|
|
LOGGER.warn("returnBackOrderCauseOfJudgeFailure getOrderInfo order not exist, orderCode {}", orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
OrderStatus expectStatus = OrderStatus.CHECKING_FAKE;
|
|
|
if (buyerOrder.getStatus() != expectStatus.getCode()){
|
|
|
LOGGER.warn("returnBackOrderCauseOfJudgeFailure expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
|
|
buyerOrder.getStatus(), orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
|
|
|
//更新物流信息
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
expressInfoService.appraiseFail(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
|
|
|
|
|
|
//发消息给卖家 TODO
|
|
|
//inBoxFacade.sendCancelledProductToSellerByCenter(sellerUid,wayBillCode);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 直接退回商品,记录物流,不涉及状态更改
|
|
|
* @param expressCompanyId
|
|
|
* @param orderCode
|
...
|
...
|
@@ -396,6 +498,7 @@ public class AppraiseService { |
|
|
payRefundService.refund(req, bleb);
|
|
|
//
|
|
|
|
|
|
//TODO 消息
|
|
|
inBoxFacade.noticeSellerWhenAppraiseFail( sellerOrderGoods,orderCode,wayBillCode);
|
|
|
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
|
|
}catch (Exception ex){
|
...
|
...
|
@@ -414,7 +517,8 @@ public class AppraiseService { |
|
|
}finally {
|
|
|
|
|
|
//更新物流信息,写到最后
|
|
|
expressInfoService.appraiseFail(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
|
|
|
//鉴定不通过,不发物流
|
|
|
//expressInfoService.appraiseFail(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
|
|
|
}
|
|
|
|
|
|
}else{
|
...
|
...
|
|