...
|
...
|
@@ -17,6 +17,7 @@ import java.util.stream.Collectors; |
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import com.yohobuy.ufo.model.order.common.*;
|
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
|
|
import com.yohoufo.order.service.*;
|
|
|
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
|
...
|
...
|
@@ -46,14 +47,6 @@ import com.yohoufo.common.alarm.EventBusPublisher; |
|
|
import com.yohoufo.common.caller.UfoServiceCaller;
|
|
|
import com.yohoufo.common.constant.EnumPlatformDeliveryStatus;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
|
|
import com.yohoufo.dal.order.ExpressRecordMapper;
|
|
|
import com.yohoufo.dal.order.QualityCheckMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderMetaMapper;
|
|
|
import com.yohoufo.dal.order.StorageDepositMapper;
|
|
|
import com.yohoufo.dal.product.ProductMapper;
|
|
|
import com.yohoufo.dal.product.model.Product;
|
|
|
import com.yohoufo.order.common.RefundCase;
|
...
|
...
|
@@ -195,7 +188,13 @@ public class AppraiseService { |
|
|
private DepositService depositService;
|
|
|
|
|
|
@Autowired
|
|
|
private OrderCodeGenerator orderCodeGenerator;
|
|
|
AppraiseOrderMapper appraiseOrderMapper;
|
|
|
|
|
|
@Autowired
|
|
|
AppraiseOrderGoodsMapper appraiseOrderGoodsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
AppraiseOrderStorageMapper appraiseOrderStorageMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private ServiceOrderProcessor serviceOrderProcessor;
|
...
|
...
|
@@ -505,6 +504,105 @@ public class AppraiseService { |
|
|
return apiResponse;
|
|
|
}
|
|
|
|
|
|
// 1.瑕疵,鉴定为假,虚假发货,质检不通过取消
|
|
|
List<Integer> APPRAISE_FAIL_STATUS_CODE = Lists.newArrayList(AppraiseOrderStatus.FLAW.getCode(),AppraiseOrderStatus.CHECKING_FAKE.getCode(),
|
|
|
AppraiseOrderStatus.SHAM_SEND_OUT.getCode(), AppraiseOrderStatus.QUALITY_CHECK_FAKE.getCode());
|
|
|
|
|
|
// 2.无法鉴定
|
|
|
List<Integer> CANNOT_APPRAISE_STATUS_CODE = Lists.newArrayList(
|
|
|
AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode());
|
|
|
|
|
|
// 3.鉴定通过
|
|
|
List<Integer> APPRAISE_SUCCESS_STATUS_CODE = Lists.newArrayList(AppraiseOrderStatus.JUDGE_PASS.getCode());
|
|
|
|
|
|
/**
|
|
|
* 给付费寄存 and 付费鉴定 发货用<br><br/>
|
|
|
* 鉴定结果为以下场景,寄回
|
|
|
* 1.瑕疵,鉴定为假,虚假发货,质检不通过取消
|
|
|
* 2.无法鉴定
|
|
|
* 3.鉴定通过
|
|
|
*
|
|
|
* 提供给运营平台使用
|
|
|
*/
|
|
|
public ApiResponse deliveryForAppraise(AppraiseExpressInfoBo appraiseExpressInfoBo) {
|
|
|
|
|
|
long orderCode = appraiseExpressInfoBo.getOrderCode();
|
|
|
if (!serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
|
|
|
LOGGER.warn("deliveryForAppraise orderCode is not goodsService, orderCode {}", orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
|
|
|
String wayBillCode = appraiseExpressInfoBo.getWayBillCode();
|
|
|
Integer depotNum = appraiseExpressInfoBo.getDepotNum();
|
|
|
String mobile = appraiseExpressInfoBo.getMobile();
|
|
|
|
|
|
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
|
|
|
|
|
|
// 订单是否为空无需检查,上面调用方法的时候已经检查了
|
|
|
AppraiseOrder appraiseOrder =existenceNode.getAppraiseOrder();
|
|
|
|
|
|
if(!APPRAISE_FAIL_STATUS_CODE.contains(appraiseOrder.getStatus())
|
|
|
&& !CANNOT_APPRAISE_STATUS_CODE.contains(appraiseOrder.getStatus())
|
|
|
&& !APPRAISE_SUCCESS_STATUS_CODE.contains(appraiseOrder.getOrderCode())){
|
|
|
|
|
|
LOGGER.warn("deliveryForAppraise status {}, orderCode {}", appraiseOrder.getStatus(), orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
|
|
|
//记录物流信息
|
|
|
int uid = appraiseOrder.getUid();
|
|
|
executorService.execute(() -> {
|
|
|
|
|
|
// 1.瑕疵,鉴定为假,虚假发货,质检不通过取消
|
|
|
if (APPRAISE_FAIL_STATUS_CODE.contains(appraiseOrder.getStatus())){
|
|
|
expressInfoService.returnBackOrderCauseOfJudgeFailure(uid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
|
|
|
}
|
|
|
// 2.无法鉴定
|
|
|
else if(CANNOT_APPRAISE_STATUS_CODE.contains(appraiseOrder.getStatus())){
|
|
|
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(uid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, true);
|
|
|
}
|
|
|
// 3.鉴定通过
|
|
|
else if(APPRAISE_SUCCESS_STATUS_CODE.contains(appraiseOrder.getStatus())){
|
|
|
expressInfoService.deliverGoods(appraiseOrder.getUid(),
|
|
|
appraiseExpressInfoBo.getExpressCompanyId(),
|
|
|
appraiseOrder.getOrderCode(),
|
|
|
appraiseExpressInfoBo.getWayBillCode(),
|
|
|
appraiseExpressInfoBo.getDepotNum(),
|
|
|
appraiseExpressInfoBo.getMobile());
|
|
|
}
|
|
|
|
|
|
//更新平台物流状态为已发货
|
|
|
appraiseOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, appraiseOrder.getUid(),
|
|
|
EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
});
|
|
|
|
|
|
//发送消息
|
|
|
// 付费鉴定的场合,发货需要消息
|
|
|
if (appraiseOrder.getAttributes() == AppraiseOrderAttributes.PAID_APPRAISE.getCode()){
|
|
|
|
|
|
List<AppraiseOrderGoods> appraiseOrderGoods = appraiseOrderGoodsMapper.selectByOrderCode(orderCode);
|
|
|
if (CollectionUtils.isEmpty(appraiseOrderGoods)){
|
|
|
LOGGER.warn("appraise order goods not exist {}", orderCode);
|
|
|
return new ApiResponse();
|
|
|
}
|
|
|
|
|
|
AppraiseOrderStorage appraiseOrderStorage = appraiseOrderStorageMapper.selectByOrderCode(orderCode);
|
|
|
if (appraiseOrderStorage == null){
|
|
|
LOGGER.warn("appraise order storage not exist {}", orderCode);
|
|
|
return new ApiResponse();
|
|
|
}
|
|
|
|
|
|
// 子订单对应商品 1:1
|
|
|
AppraiseOrderGoods oneAppraiseOrderGood = appraiseOrderGoods.get(0);
|
|
|
inBoxFacade.sendInboxSmsWhenAppraiseFinished(uid, oneAppraiseOrderGood.getProductName(),appraiseOrderStorage.getSizeName(), oneAppraiseOrderGood.getProductCode(), wayBillCode);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ApiResponse();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 无法鉴定退回
|
|
|
*
|
...
|
...
|
|