...
|
...
|
@@ -32,6 +32,7 @@ import com.yohoufo.order.service.proxy.OrderOperateRecordService; |
|
|
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
|
|
|
import com.yohoufo.order.utils.PaymentHelper;
|
|
|
import com.yohoufo.order.utils.PubThreadFactory;
|
|
|
import lombok.Data;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
...
|
...
|
@@ -408,47 +409,105 @@ public class AppraiseService { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新发到卖家的物流信息
|
|
|
* 将卖家的保证金分账给平台和买家
|
|
|
* 更新买家订单状态
|
|
|
* appraiseFlag 鉴定标志,//true 鉴定不通过 ;false 质检不通过 ;
|
|
|
* @return
|
|
|
* 质检不通过 31->20
|
|
|
* 不发物流
|
|
|
*/
|
|
|
public ApiResponse appraiseFail(AppraiseExpressInfoBo appraiseExpressInfoBo,OrderStatus expectStatus,boolean appraiseNotPassFlag){
|
|
|
LOGGER.info("appraiseFail enter , appraiseExpressInfoBo {} ,appraiseNotPassFlag {}", appraiseExpressInfoBo ,appraiseNotPassFlag);
|
|
|
public ApiResponse qualityCheckReject(AppraiseExpressInfoBo appraiseExpressInfoBo){
|
|
|
LOGGER.info("qualityCheckReject enter , appraiseExpressInfoBo {} ", appraiseExpressInfoBo );
|
|
|
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
|
|
|
OrderStatus targetStatus = OrderStatus.QUALITY_CHECK_FAKE;
|
|
|
Long orderCode = appraiseExpressInfoBo.getOrderCode();
|
|
|
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
|
|
|
String wayBillCode = appraiseExpressInfoBo.getWayBillCode();
|
|
|
Integer depotNum = appraiseExpressInfoBo.getDepotNum();
|
|
|
String mobile = appraiseExpressInfoBo.getMobile();
|
|
|
|
|
|
ApiResponse apiResponse=new ApiResponse();
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
|
|
|
if (buyerOrder == null){
|
|
|
LOGGER.warn("appraiseFail getOrderInfo order not exist, orderCode {}", orderCode);
|
|
|
LOGGER.warn("qualityCheckReject getOrderInfo order not exist, orderCode {}", orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
if (buyerOrder.getStatus() != expectStatus.getCode()){
|
|
|
LOGGER.warn("appraiseFail expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
|
|
LOGGER.warn("qualityCheckReject expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
|
|
buyerOrder.getStatus(), orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
// 更新买家订单状态 为鉴定不通过
|
|
|
// 更新买家订单状态
|
|
|
int buyerUid = buyerOrder.getUid();
|
|
|
OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
|
|
|
LOGGER.info("appraiseFail update buyer order {} ", buyerOrder);
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
LOGGER.info("qualityCheckReject update buyer order {} ", buyerOrder);
|
|
|
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
|
|
|
DateUtil.getCurrentTimeSecond());
|
|
|
|
|
|
if (rows > 0){
|
|
|
RefundMoneyResultModel refundMoneyResultModel= operateMoneyWhenCheckFail(buyerOrder,orderCode,targetStatus);
|
|
|
boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
|
|
|
SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
|
|
|
if (!refundGoodsMoneyFlag){
|
|
|
apiResponse.setCode(400);
|
|
|
String content = "质检不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
|
|
|
apiResponse.setMessage(content);
|
|
|
}
|
|
|
|
|
|
//记录订单的状态变更信息
|
|
|
LOGGER.info("in qualityCheckReject record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
|
|
|
try {
|
|
|
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
|
|
|
|
|
|
//质检不通过
|
|
|
inBoxFacade.noticeBuyerWhenQualityCheckNotPass(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
|
|
inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods,orderCode);
|
|
|
|
|
|
}catch(Exception ex) {
|
|
|
LOGGER.warn("in qualityCheckReject orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
|
|
|
}finally {
|
|
|
/// 物流信息异步执行
|
|
|
executorService.execute(()->{
|
|
|
//质检不通过,不发物流
|
|
|
//先补加一条鉴定中物流
|
|
|
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
|
|
|
//再加一个鉴定不通过的物流
|
|
|
operateTransferCode = EnumExpressDataOperateTransferCode.quality_check_reject;
|
|
|
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
LOGGER.warn("in qualityCheckReject, buyer Order now status {}, expect expectStatus {}",
|
|
|
buyerOrder.getStatus(), expectStatus);
|
|
|
apiResponse.setCode(400);
|
|
|
apiResponse.setMessage("订单状态发生变化");
|
|
|
}
|
|
|
return apiResponse;
|
|
|
}
|
|
|
|
|
|
@Data
|
|
|
class RefundMoneyResultModel{
|
|
|
boolean refundGoodsMoneyFlag;
|
|
|
SellerOrderGoods sellerOrderGoods;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 鉴定不通或者直接不通过
|
|
|
* 操作钱
|
|
|
*/
|
|
|
private RefundMoneyResultModel operateMoneyWhenCheckFail(BuyerOrder buyerOrder,Long orderCode,OrderStatus targetStatus){
|
|
|
LOGGER.info("operateMoney enter , orderCode {},targetStatus {} ", orderCode ,targetStatus);
|
|
|
RefundMoneyResultModel model = new RefundMoneyResultModel();
|
|
|
int buyerUid = buyerOrder.getUid();
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
//refund coupons of buyer
|
|
|
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)
|
|
|
.uid(buyerUid).orderCode(orderCode).build();
|
|
|
EventBusPublisher.publishEvent(brce);
|
|
|
//
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
|
|
|
int skup = bog.getSkup();
|
|
|
|
...
|
...
|
@@ -478,7 +537,7 @@ public class AppraiseService { |
|
|
|
|
|
//改成异步的分账,不关心分账执行结果
|
|
|
executorService.execute(()->{
|
|
|
LOGGER.info("in appraiseFail,begin transfer async");
|
|
|
LOGGER.info("in operateMoney,begin transfer async");
|
|
|
transferService.transfer(tmReq);
|
|
|
});
|
|
|
|
...
|
...
|
@@ -495,6 +554,54 @@ public class AppraiseService { |
|
|
.loadRefundAction(payRefundService::refund)
|
|
|
.loadLogger(LOGGER)
|
|
|
.refund();
|
|
|
|
|
|
model.setRefundGoodsMoneyFlag(refundGoodsMoneyFlag);
|
|
|
model.setSellerOrderGoods(sellerOrderGoods);
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 鉴定不通过 3->13
|
|
|
* 更新发到卖家的物流信息
|
|
|
* 将卖家的保证金分账给平台和买家
|
|
|
* 更新买家订单状态
|
|
|
* @return
|
|
|
*/
|
|
|
public ApiResponse appraiseFail(AppraiseExpressInfoBo appraiseExpressInfoBo ){
|
|
|
LOGGER.info("appraiseFail enter , appraiseExpressInfoBo {} ,appraiseNotPassFlag {}", appraiseExpressInfoBo );
|
|
|
OrderStatus expectStatus = OrderStatus.PLATFORM_CHECKING;
|
|
|
OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
|
|
|
Long orderCode = appraiseExpressInfoBo.getOrderCode();
|
|
|
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
|
|
|
String wayBillCode = appraiseExpressInfoBo.getWayBillCode();
|
|
|
Integer depotNum = appraiseExpressInfoBo.getDepotNum();
|
|
|
String mobile = appraiseExpressInfoBo.getMobile();
|
|
|
|
|
|
ApiResponse apiResponse=new ApiResponse();
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
|
|
|
if (buyerOrder == null){
|
|
|
LOGGER.warn("appraiseFail getOrderInfo order not exist, orderCode {}", orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
if (buyerOrder.getStatus() != expectStatus.getCode()){
|
|
|
LOGGER.warn("appraiseFail expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
|
|
buyerOrder.getStatus(), orderCode);
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
// 更新买家订单状态 为鉴定不通过
|
|
|
int buyerUid = buyerOrder.getUid();
|
|
|
int sellerUid = buyerOrder.getSellerUid();
|
|
|
LOGGER.info("appraiseFail update buyer order {} ", buyerOrder);
|
|
|
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
|
|
|
DateUtil.getCurrentTimeSecond());
|
|
|
|
|
|
if (rows > 0){
|
|
|
RefundMoneyResultModel refundMoneyResultModel= operateMoneyWhenCheckFail(buyerOrder,orderCode,targetStatus);
|
|
|
boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
|
|
|
SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
|
|
|
|
|
|
if (!refundGoodsMoneyFlag){
|
|
|
apiResponse.setCode(400);
|
|
|
String content = "鉴定不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
|
...
|
...
|
@@ -506,16 +613,9 @@ public class AppraiseService { |
|
|
try {
|
|
|
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
|
|
|
|
|
|
//TODO 消息
|
|
|
if(appraiseNotPassFlag){
|
|
|
//鉴定不通过 ,其余的情况不发消息,改成寄回的时候再发消息
|
|
|
inBoxFacade.noticeSellerWhenAppraiseFail(sellerOrderGoods, orderCode, wayBillCode);
|
|
|
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
|
|
}else {
|
|
|
//质检不通过
|
|
|
inBoxFacade.noticeBuyerWhenQualityCheckNotPass(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
|
|
inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods,orderCode);
|
|
|
}
|
|
|
|
|
|
}catch(Exception ex) {
|
|
|
LOGGER.warn("in appraiseFail orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
|
...
|
...
|
@@ -524,7 +624,6 @@ public class AppraiseService { |
|
|
executorService.execute(()->{
|
|
|
//更新物流信息,写到最后
|
|
|
//鉴定不通过,发物流
|
|
|
if(appraiseNotPassFlag){
|
|
|
//补:鉴定不通过
|
|
|
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
...
|
...
|
@@ -533,21 +632,6 @@ public class AppraiseService { |
|
|
|
|
|
//发货物流(平台已发货)
|
|
|
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
|
|
|
}else {
|
|
|
//质检不通过,不发物流
|
|
|
|
|
|
//先补加一条鉴定中物流
|
|
|
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
|
|
|
//再加一个鉴定不通过的物流
|
|
|
operateTransferCode = EnumExpressDataOperateTransferCode.quality_check_reject;
|
|
|
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
...
|
...
|
|