Authored by qinchao

Merge branch 'dev6.8.6.5-quality4app' into test6.8.6.5

# Conflicts:
#	order/src/main/java/com/yohoufo/order/service/impl/AppraiseService.java
... ... @@ -50,6 +50,11 @@ public interface BuyerOrderMapper {
// 修改订单状态
int updateStatusByOrderCode(@Param("orderCode")long orderCode, @Param("uid")int uid, @Param("status")int status, @Param("targetStatus")int targetStatus, @Param("currentTime")int currentTime);
//修改订单状态 , 6.8.7版本以后去掉 ,不要引用该方法
//拆分出瑕疵确认状态,系统上线之初存在多种状态的情况
@Deprecated
int updateStatusByOrderCodeMoreExpectStatus(@Param("orderCode")long orderCode, @Param("uid")int uid, @Param("expectStatusList")List<Integer> expectStatusList, @Param("targetStatus")int targetStatus, @Param("currentTime")int currentTime);
// 根据uid查询订单总数
Integer selectOrderNumByUid(@Param("uid")int uid);
... ...
... ... @@ -381,6 +381,17 @@
where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT} and status = #{status, jdbcType=INTEGER}
</update>
<update id="updateStatusByOrderCodeMoreExpectStatus">
update buyer_order set
status = #{targetStatus,jdbcType=INTEGER},
update_time = #{currentTime,jdbcType=INTEGER}
where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT}
and status in
<foreach item="item" index="index" collection="expectStatusList" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<select id="selectOrderNumByUid" resultType="java.lang.Integer">
select count(*) from buyer_order where uid = #{uid,jdbcType=INTEGER} and buyer_order_status = 1
</select>
... ...
... ... @@ -24,10 +24,15 @@ public class ActionStatusHold {
OrderStatus.SELLER_SEND_OUT.getCode(),
OrderStatus.PLATFORM_RECEIVE.getCode(),
OrderStatus.PLATFORM_CHECKING.getCode(),
//OrderStatus.JUDGE_PASS.getCode(),
OrderStatus.MINI_FAULT_WAITING.getCode(),
OrderStatus.MINI_FAULT_ACCEPT.getCode(),
OrderStatus.JUDGE_PASS.getCode(),
OrderStatus.WAITING_RECEIVE.getCode(),
OrderStatus.DONE.getCode(),
OrderStatus.CHECKING_FAKE.getCode(),
OrderStatus.QUALITY_CHECK_FAKE.getCode(),
OrderStatus.MINI_FAULT_REJECT.getCode(),
OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode()
);
... ... @@ -38,6 +43,9 @@ public class ActionStatusHold {
OrderStatus.SELLER_CANCEL_AFTER_PAY.getCode(),
OrderStatus.SEND_OUT_TIMEOUT.getCode(),
OrderStatus.CHECKING_FAKE.getCode(),//鉴权不通过
OrderStatus.QUALITY_CHECK_FAKE.getCode(),
OrderStatus.MINI_FAULT_REJECT.getCode(),
OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode(),
OrderStatus.WAITING_RECEIVE.getCode(),//
OrderStatus.BUYER_CANCEL_BEFORE_PAY.getCode(),
OrderStatus.BUYER_CANCEL_TIMEOUT.getCode(),
... ... @@ -58,7 +66,9 @@ public class ActionStatusHold {
OrderStatus.PLATFORM_CHECKING.getCode(),
OrderStatus.WAITING_RECEIVE.getCode(),
OrderStatus.PLATFORM_RECEIVE.getCode(),
//OrderStatus.JUDGE_PASS.getCode(),
OrderStatus.MINI_FAULT_WAITING.getCode(),
OrderStatus.MINI_FAULT_ACCEPT.getCode(),
OrderStatus.JUDGE_PASS.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode());
}
... ... @@ -89,8 +99,13 @@ public class ActionStatusHold {
final static List<Integer> View_Express_Status = Arrays.asList(OrderStatus.SELLER_SEND_OUT.getCode(),
OrderStatus.PLATFORM_RECEIVE.getCode(),
OrderStatus.PLATFORM_CHECKING.getCode(),
//OrderStatus.JUDGE_PASS.getCode(),
OrderStatus.MINI_FAULT_WAITING.getCode(),
OrderStatus.MINI_FAULT_ACCEPT.getCode(),
OrderStatus.JUDGE_PASS.getCode(),
OrderStatus.CHECKING_FAKE.getCode(),
OrderStatus.QUALITY_CHECK_FAKE.getCode(),
OrderStatus.MINI_FAULT_REJECT.getCode(),
OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode(),
OrderStatus.WAITING_RECEIVE.getCode(),OrderStatus.DONE.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode());
//
... ... @@ -144,6 +159,9 @@ public class ActionStatusHold {
OrderStatus.SELLER_CANCEL_AFTER_PAY.getCode(),
OrderStatus.SEND_OUT_TIMEOUT.getCode(),
OrderStatus.CHECKING_FAKE.getCode(),
OrderStatus.QUALITY_CHECK_FAKE.getCode(),
OrderStatus.MINI_FAULT_REJECT.getCode(),
OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode(),
OrderStatus.WAITING_RECEIVE.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_PAY.getCode(),
OrderStatus.BUYER_CANCEL_TIMEOUT.getCode(),
... ...
package com.yohoufo.order.controller;
import com.yoho.core.rest.annotation.ServiceDesc;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.order.service.impl.AppraiseService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -63,9 +65,20 @@ public class AppraiseController {
@IgnoreSignature
public ApiResponse appraiseFail(@RequestBody AppraiseExpressInfoBo appraiseExpressInfoBo) {
logger.info("in appraise Fail, req {}", appraiseExpressInfoBo);
OrderStatus expectStatus = OrderStatus.PLATFORM_CHECKING;
//1 鉴定不通过 ;2 质检不通过 ;
return appraiseService.appraiseFail(appraiseExpressInfoBo,expectStatus,true);
return appraiseService.appraiseFailAndDelivery(appraiseExpressInfoBo);
}
/**
* 商品鉴定不通过,不发物流
* @return
*/
@RequestMapping(value="/judgeCenterNotPass")
@IgnoreSession
@IgnoreSignature
public ApiResponse judgeCenterNotPass(@RequestBody AppraiseExpressInfoBo appraiseExpressInfoBo) {
logger.info("in judgeCenterNotPass, req {}", appraiseExpressInfoBo);
return appraiseService.judgeCenterNotPass(appraiseExpressInfoBo);
}
/**
... ... @@ -80,9 +93,7 @@ public class AppraiseController {
@IgnoreSignature
public ApiResponse appraiseFailWithoutExpress(@RequestBody AppraiseExpressInfoBo appraiseExpressInfoBo) {
logger.info("in appraiseFailWithoutExpress , req {}", appraiseExpressInfoBo);
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
//1 鉴定不通过 ;2 质检不通过 ;
return appraiseService.appraiseFail( appraiseExpressInfoBo,expectStatus,false);
return appraiseService.qualityCheckReject(appraiseExpressInfoBo);
}
... ... @@ -111,7 +122,34 @@ public class AppraiseController {
@IgnoreSignature
public ApiResponse appraiseSuccess(@RequestBody AppraiseExpressInfoBo appraiseExpressInfoBo) {
logger.info("in appraiseSuccess, req {}", appraiseExpressInfoBo);
return appraiseService.appraiseSuccess(appraiseExpressInfoBo.getExpressCompanyId(), appraiseExpressInfoBo.getOrderCode(), appraiseExpressInfoBo.getWayBillCode(),appraiseExpressInfoBo.getDepotNum(),appraiseExpressInfoBo.getMobile());
return appraiseService.appraiseSuccessAndDelivery(appraiseExpressInfoBo.getExpressCompanyId(), appraiseExpressInfoBo.getOrderCode(), appraiseExpressInfoBo.getWayBillCode(),appraiseExpressInfoBo.getDepotNum(),appraiseExpressInfoBo.getMobile());
}
/**
* TODO 手机质检: 鉴定通过流程,订单进入JUDGE_PASS状态,但是没有发货
* 瑕疵确认通过 -->鉴定通过
* 平台鉴定中 -->鉴定通过
*/
@RequestMapping(value="/judgeCenterPass")
@IgnoreSession
@IgnoreSignature
public ApiResponse judgeCenterPass(Long orderCode){
logger.info("in judgeCenterPass, orderCode {}", orderCode);
return appraiseService.judgeCenterPass(orderCode);
}
/**
* TODO 手机质检: 发货
* 鉴定通过 -- 待收货
*/
@RequestMapping(value="/deliveryGoodsToBuyer")
@IgnoreSession
@IgnoreSignature
public ApiResponse deliveryGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo){
logger.info("in deliveryGoodsToBuyer, appraiseExpressInfoBo {}", appraiseExpressInfoBo);
appraiseService.deliveryGoodsToBuyer(appraiseExpressInfoBo);
return new ApiResponse();
}
/*
... ...
... ... @@ -57,6 +57,9 @@ public class AlarmEventBuilder {
AlarmConfig alarmConfig;
switch(orderStatus){
case CHECKING_FAKE:
case QUALITY_CHECK_FAKE:
case MINI_FAULT_REJECT:
case MINI_FAULT_OUT_TIME_REJECT:
alarmConfig = AlarmConfig.APPRAISE_FAIL;
smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getRefundName(), alarmConfig.name(), content);
break;
... ...
... ... @@ -36,14 +36,10 @@ public class BuyerOrderMiniFaultOuterTimeDelayMsgConsumer implements YhConsumer
logger.info("BuyerOrderMiniFaultOuterTimeDelayMsgConsumer topic {}, msg {} ", getMessageTopic(), o);
BuyerMiniFaultOuterTimeEvent event = JSONObject.parseObject(o.toString(), BuyerMiniFaultOuterTimeEvent.class);
//Integer buyerUid = event.getUid();
Long orderCode = event.getOrderCode();
//AppraiseExpressInfoBo appraiseExpressInfoBo = new AppraiseExpressInfoBo();
//appraiseExpressInfoBo.setOrderCode(orderCode);
//OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
//int type= 4; //1 鉴定不通过 ;2 质检不通过 ; 3,瑕疵确认不通过 ,4,瑕疵确认不通过(超时)
appraiseService.miniFaultReject(orderCode,true);
OrderStatus targetStatus = OrderStatus.MINI_FAULT_OUT_TIME_REJECT;
appraiseService.miniFaultReject(orderCode,targetStatus,true);
logger.info("BuyerOrderMiniFaultOuterTimeDelayMsgConsumer topic {}, msg {} finish", getMessageTopic(), event);
}
... ...
... ... @@ -255,6 +255,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
OrderStatus.SELLER_CANCEL_AFTER_PAY.getCode(),
OrderStatus.SEND_OUT_TIMEOUT.getCode(),
OrderStatus.CHECKING_FAKE.getCode(),
OrderStatus.QUALITY_CHECK_FAKE.getCode(),
OrderStatus.MINI_FAULT_REJECT.getCode(),
OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode(),
// 支付成功回调超时,但已经被超时取消,这种场景是可以退款的
... ...
... ... @@ -95,6 +95,9 @@ public interface IExpressInfoService {
List<Integer> status2OnlySellerExpressType = Arrays.asList(OrderStatus.PLATFORM_RECEIVE.getCode(),
OrderStatus.PLATFORM_CHECKING.getCode(), OrderStatus.WAITING_RECEIVE.getCode(),
OrderStatus.MINI_FAULT_WAITING.getCode(),
OrderStatus.MINI_FAULT_ACCEPT.getCode(),
OrderStatus.JUDGE_PASS.getCode(),
OrderStatus.DONE.getCode());
/**
... ... @@ -104,7 +107,10 @@ public interface IExpressInfoService {
List<Integer> types = null;
if(Objects.equals(OrderStatus.SELLER_SEND_OUT.getCode(), status)){
types = Arrays.asList(EnumExpressType.EXPRESS_TYPE_1.getCode());
}else if (Objects.equals(OrderStatus.CHECKING_FAKE.getCode(), status)){
}else if (Objects.equals(OrderStatus.CHECKING_FAKE.getCode(), status)
||Objects.equals(OrderStatus.QUALITY_CHECK_FAKE.getCode(), status)
||Objects.equals(OrderStatus.MINI_FAULT_REJECT.getCode(), status)
||Objects.equals(OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode(), status)){
types = Arrays.asList( EnumExpressType.EXPRESS_TYPE_3.getCode(),EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode(),EnumExpressType.EXPRESS_TYPE_1.getCode());
}else if(Objects.equals(OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode(), status)){
types = Arrays.asList( EnumExpressType.EXPRESS_TYPE_REBACK.getCode() ,EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode(),EnumExpressType.EXPRESS_TYPE_1.getCode());
... ... @@ -117,8 +123,13 @@ public interface IExpressInfoService {
List<Integer> status2BuyerDeliverExpressStatusList = Arrays.asList(
OrderStatus.PLATFORM_RECEIVE.getCode(),
OrderStatus.PLATFORM_CHECKING.getCode(),
//OrderStatus.JUDGE_PASS.getCode(),
OrderStatus.MINI_FAULT_WAITING.getCode(),
OrderStatus.MINI_FAULT_ACCEPT.getCode(),
OrderStatus.JUDGE_PASS.getCode(),
OrderStatus.CHECKING_FAKE.getCode(),
OrderStatus.QUALITY_CHECK_FAKE.getCode(),
OrderStatus.MINI_FAULT_REJECT.getCode(),
OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode()
);
... ...
... ... @@ -297,7 +297,11 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
}
final static List<Integer> canRefundStatusList = Arrays.asList(OrderStatus.SELLER_CANCEL_AFTER_PAY.getCode(),
OrderStatus.SEND_OUT_TIMEOUT.getCode(), OrderStatus.CHECKING_FAKE.getCode());
OrderStatus.SEND_OUT_TIMEOUT.getCode()
, OrderStatus.CHECKING_FAKE.getCode()
,OrderStatus.QUALITY_CHECK_FAKE.getCode()
,OrderStatus.MINI_FAULT_REJECT.getCode()
,OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode());
@Override
public boolean canRefund(OrderInfo orderInfo) {
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
... ... @@ -36,6 +37,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;
... ... @@ -45,6 +47,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
... ... @@ -169,7 +172,7 @@ public class AppraiseService {
/**
* 鉴定不通过退回
* (1)记录物流
* (2)消息 :寄回有三种情形: 质检不通过的而商品、瑕疵不接受的 、瑕疵不接受(超时)的
* (2)消息 :寄回有4种情形: 鉴定不通过、质检不通过的商品、瑕疵不接受的 、瑕疵不接受(超时)的
*/
public void returnBackOrderCauseOfJudgeFailure(AppraiseExpressInfoBo appraiseExpressInfoBo){
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
... ... @@ -185,12 +188,46 @@ public class AppraiseService {
throw new ServiceException(ServiceError.ORDER_NULL);
}
OrderStatus expectStatus = OrderStatus.CHECKING_FAKE;
if (buyerOrder.getStatus() != expectStatus.getCode()){
LOGGER.warn("returnBackOrderCauseOfJudgeFailure expectStatus {}, actual status {}, orderCode {}", expectStatus,
OrderStatus expectStatus ;
int type = 0 ;//鉴定不通过
if (buyerOrder.getStatus() == OrderStatus.CHECKING_FAKE.getCode()){
expectStatus = OrderStatus.CHECKING_FAKE;
//TODO 新版本6.8.7以后,判断type可直接根据状态,而不再需要根据qualityCheck,可去掉以下if判断
//TODO 现在6.8.6.5手机质检版本上线,还需要保留,存在过度订单,鉴定不通过都是类型:13
QualityCheck qualityCheck = qualityCheckMapper.selectByOrderCode(orderCode);
if(qualityCheck!=null&&qualityCheck.getType()!=null){
if(EnumQualityCheckType.CHECK_NOT_PASS.getCode().intValue()==qualityCheck.getType().intValue()){
type = 1;//质检不通过
}else if(EnumQualityCheckType.MINI_FAULT.getCode().intValue()==qualityCheck.getType().intValue()){
if(qualityCheck.getStatus()!=null){
if(EnumQualityCheckStatus.REJECT_BY_BUYER.getCode().intValue()==qualityCheck.getStatus().intValue()){
type = 2;//用户不接受瑕疵
}else if(EnumQualityCheckStatus.REJECT_BY_OUTER_TIME.getCode().intValue()==qualityCheck.getStatus().intValue()){
type = 3;//用户不接受超时
}
}
}
}
}else if(buyerOrder.getStatus() == OrderStatus.QUALITY_CHECK_FAKE.getCode()){
type = 1;//质检不通过
expectStatus = OrderStatus.QUALITY_CHECK_FAKE;
}else if(buyerOrder.getStatus() == OrderStatus.MINI_FAULT_REJECT.getCode()){
type = 2;//用户不接受瑕疵
expectStatus = OrderStatus.MINI_FAULT_REJECT;
}else if(buyerOrder.getStatus() == OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode()){
type = 3;//用户不接受超时
expectStatus = OrderStatus.MINI_FAULT_OUT_TIME_REJECT;
}else{
//if (buyerOrder.getStatus() != expectStatus.getCode()){
LOGGER.warn("returnBackOrderCauseOfJudgeFailure expectStatus CHECKING_FAKE QUALITY_CHECK_FAKE MINI_FAULT_REJECT or MINI_FAULT_OUT_TIME_REJECT, actual status {}, orderCode {}",
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
LOGGER.info("returnBackOrderCauseOfJudgeFailure check status ok expectStatus {}, actual status {}, orderCode {}",expectStatus,
buyerOrder.getStatus(), orderCode);
//更新物流信息
int sellerUid = buyerOrder.getSellerUid();
... ... @@ -199,6 +236,7 @@ public class AppraiseService {
//清缓存
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
/*
//发消息给卖家
QualityCheck qualityCheck = qualityCheckMapper.selectByOrderCode(orderCode);
int type = 1 ;//鉴定不通过
... ... @@ -211,6 +249,7 @@ public class AppraiseService {
}
}
*/
inBoxFacade.sellerQualityCheckNotPass_send_back(sellerOrderGoods,orderCode,wayBillCode, type);
}
... ... @@ -271,9 +310,12 @@ public class AppraiseService {
* @outTimeFlag 超时
* @return
*/
public ApiResponse miniFaultReject(Long orderCode,boolean outTimeFlag){
LOGGER.info("miniFaultReject enter , orderCode {} ,outTimeFlag {}", orderCode ,outTimeFlag);
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
public ApiResponse miniFaultReject(Long orderCode,OrderStatus targetStatus,boolean outTimeFlag){
LOGGER.info("miniFaultReject enter , orderCode {} ,targetStatus {},outTimeFlag {}", orderCode ,targetStatus ,outTimeFlag);
OrderStatus expectStatusNew = OrderStatus.MINI_FAULT_WAITING;
//拆分状态,版本升级之后存在的特殊订单
OrderStatus expectStatusAnother = OrderStatus.PLATFORM_RECEIVE;
List<Integer> expectStatusList= Lists.newArrayList(expectStatusNew.getCode(),expectStatusAnother.getCode());
ApiResponse apiResponse=new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
... ... @@ -282,16 +324,18 @@ public class AppraiseService {
throw new ServiceException(ServiceError.ORDER_NULL);
}
if (buyerOrder.getStatus() != expectStatus.getCode()){
LOGGER.warn("miniFaultReject expectStatus {}, actual status {}, orderCode {}", expectStatus,
//if (buyerOrder.getStatus() != expectStatus.getCode()){
if (!expectStatusList.contains(buyerOrder.getStatus())){
LOGGER.warn("miniFaultReject expectStatus {}, actual status {}, orderCode {}", expectStatusList,
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
// 更新买家订单状态 为鉴定不通过
// 更新买家订单状态
int buyerUid = buyerOrder.getUid();
OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
LOGGER.info("miniFaultReject update buyer order {} ", buyerOrder);
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
/* int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
DateUtil.getCurrentTimeSecond());*/
int rows = buyerOrderMapper.updateStatusByOrderCodeMoreExpectStatus(orderCode, buyerUid, expectStatusList, targetStatus.getCode(),
DateUtil.getCurrentTimeSecond());
if (rows > 0){
... ... @@ -383,7 +427,7 @@ public class AppraiseService {
}else{
LOGGER.warn("in miniFaultReject, buyer Order now status {}, expect expectStatus {}",
buyerOrder.getStatus(), expectStatus);
buyerOrder.getStatus(), expectStatusList);
apiResponse.setCode(400);
apiResponse.setMessage("订单状态发生变化");
}
... ... @@ -418,11 +462,12 @@ public class AppraiseService {
* 更新发到卖家的物流信息
* 将卖家的保证金分账给平台和买家
* 更新买家订单状态
* appraiseFlag 鉴定标志,//true 鉴定不通过 ;false 质检不通过 ;
* @return
*/
public ApiResponse appraiseFail(AppraiseExpressInfoBo appraiseExpressInfoBo,OrderStatus expectStatus,boolean appraiseNotPassFlag){
LOGGER.info("appraiseFail enter , appraiseExpressInfoBo {} ,appraiseNotPassFlag {}", appraiseExpressInfoBo ,appraiseNotPassFlag);
public ApiResponse appraiseFailAndDelivery(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();
... ... @@ -444,18 +489,19 @@ public class AppraiseService {
}
// 更新买家订单状态 为鉴定不通过
int buyerUid = buyerOrder.getUid();
OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
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){
/*
//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();
... ... @@ -512,6 +558,11 @@ public class AppraiseService {
.loadRefundAction(payRefundService::refund)
.loadLogger(LOGGER)
.refund();
*/
RefundMoneyResultModel refundMoneyResultModel= operateMoneyWhenCheckFail(buyerOrder,orderCode,targetStatus);
boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
if (!refundGoodsMoneyFlag){
apiResponse.setCode(400);
String content = "鉴定不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
... ... @@ -524,15 +575,9 @@ public class AppraiseService {
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);
}
//鉴定不通过 ,其余的情况不发消息,改成寄回的时候再发消息
inBoxFacade.noticeSellerWhenAppraiseFail(sellerOrderGoods, orderCode, wayBillCode);
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
}catch(Exception ex) {
LOGGER.warn("in appraiseFail orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
... ... @@ -541,30 +586,15 @@ public class AppraiseService {
executorService.execute(()->{
//更新物流信息,写到最后
//鉴定不通过,发物流
if(appraiseNotPassFlag){
//补:鉴定不通过
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
//补:鉴定不通过
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
//发货物流(平台已发货)
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
}else {
//质检不通过,不发物流
//发货物流(平台已发货)
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
//先补加一条鉴定中物流
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);
}
});
}
... ... @@ -648,7 +678,418 @@ public class AppraiseService {
}
}
public ApiResponse appraiseSuccess(Integer expressCompanyId, Long orderCode, String wayBillCode,Integer depotNum,String mobile){
@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);
//
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
int skup = bog.getSkup();
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
long sellerOrderCode = sellerOrder.getOrderCode();
final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;
final SellerOrderStatus targetSoStatus = SellerOrderStatus.APPRAISAL_FAIL_COMPENSATE;
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
skup, orderCode, buyerUid);
//将卖家的保证金分账给平台和买家
PenaltyResult penaltyResult = SellerEarnestMoney2BuyerPenaltyCalculator.from(sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee"))
.calculate()
.orElse(null);
if(Objects.nonNull(penaltyResult)){
TransferCase transferCase = TransferCase.EARNEST_MONEY_TO_BUYER;
TranseferCellNode transeferCellNode = new TranseferCellNode();
transeferCellNode.setUid(buyerUid);
transeferCellNode.setAmount(penaltyResult.getPenaltyAmountWithoutYhServiceAmount());
TransferMoneyRequest tmReq = TransferMoneyRequest.builder()
.sellerUid(sellerUid)
.buyerOrderCode(orderCode)
.type(transferCase.getCode())
.transferCase(transferCase)
.transeferCellNode(transeferCellNode)
.swdType(SellerWalletDetail.Type.APPRAISE_FAIL)
.alarmConfig(AlarmConfig.APPRAISE_FAIL)
.build();
//先校验,提前把错误抛出
paymentService.transferMonCheck(tmReq);
//再分账
//改成异步的分账,不关心分账执行结果
executorService.execute(()->{
LOGGER.info("in appraiseFail,begin transfer async");
transferService.transfer(tmReq);
});
}
//退钱给买家
BigDecimal goodsMoney = buyerOrder.getAmount();
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)
.payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
.amount(goodsMoney)
.skup(skup);
boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler().loadPaymentRequest(buyerUid,orderCode,goodsMoney)
.loadBillLogEventBuilder(bleb)
.loadTargetOrderStatus(targetStatus)
.loadRefundAction(payRefundService::refund)
.loadLogger(LOGGER)
.refund();
model.setRefundGoodsMoneyFlag(refundGoodsMoneyFlag);
model.setSellerOrderGoods(sellerOrderGoods);
return model;
}
/**
* 鉴定不通过 3->13 或者 MINI_FAULT_ACCEPT ->13
* 不发物流
*/
public ApiResponse judgeCenterNotPass(AppraiseExpressInfoBo appraiseExpressInfoBo){
LOGGER.info("judgeCenterNotPass enter , appraiseExpressInfoBo {} ", appraiseExpressInfoBo );
OrderStatus expectStatus ;
OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
Long orderCode = appraiseExpressInfoBo.getOrderCode();
ApiResponse apiResponse=new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("judgeCenterNotPass getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
if(buyerOrder.getStatus() == OrderStatus.PLATFORM_CHECKING.getCode()){
expectStatus = OrderStatus.PLATFORM_CHECKING;
}else if(buyerOrder.getStatus() == OrderStatus.MINI_FAULT_ACCEPT.getCode()){
expectStatus = OrderStatus.MINI_FAULT_ACCEPT;
}else{
LOGGER.warn("judgeCenterNotPass expectStatus PLATFORM_CHECKING or MINI_FAULT_ACCEPT, actual status {}, orderCode {}",
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
// 更新买家订单状态
int buyerUid = buyerOrder.getUid();
int sellerUid = buyerOrder.getSellerUid();
LOGGER.info("judgeCenterNotPass 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 judgeCenterNotPass 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 judgeCenterNotPass 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.judge_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
});
}
}else{
LOGGER.warn("in judgeCenterNotPass, buyer Order now status {}, expect expectStatus {}",
buyerOrder.getStatus(), expectStatus);
apiResponse.setCode(400);
apiResponse.setMessage("订单状态发生变化");
}
return apiResponse;
}
/**
* 质检不通过 31->20
* 不发物流
*/
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();
ApiResponse apiResponse=new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("qualityCheckReject getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
if (buyerOrder.getStatus() != expectStatus.getCode()){
LOGGER.warn("qualityCheckReject 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("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;
}
/**
* 正常发货
* 鉴定通过 -- 待收货
*/
public void deliveryGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo){
LOGGER.info("deliveryGoodsToBuyer enter req {}", appraiseExpressInfoBo);
final OrderStatus expectOrderStatus = OrderStatus.JUDGE_PASS;
final OrderStatus targetOrderStatus = OrderStatus.WAITING_RECEIVE;
Long orderCode = appraiseExpressInfoBo.getOrderCode();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("deliveryGoodsToBuyer getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
if (expectOrderStatus.getCode() != buyerOrder.getStatus().intValue()){
LOGGER.warn("in deliveryGoodsToBuyer, buyer Order orderCode {} pstatus {}, expect Order Status {}",
orderCode, buyerOrder.getStatus(), expectOrderStatus);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
Integer buyerUid = buyerOrder.getUid();
int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid,
expectOrderStatus.getCode(), targetOrderStatus.getCode(), DateUtil.getCurrentTimeSecond());
if (updateBuyerCnt == 1){
//发货,这个时候产生:买家确认收货的mq
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
EventBusPublisher.publishEvent(buyerConfirmEvent);
//记录物流信息
//发物流
expressInfoService.deliverGoods(buyerUid, appraiseExpressInfoBo.getExpressCompanyId(), orderCode, appraiseExpressInfoBo.getWayBillCode(), appraiseExpressInfoBo.getDepotNum(),appraiseExpressInfoBo.getMobile());
//记录订单的状态变更信息
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetOrderStatus.getCode());
//TODO 平台已发货给买家
//清缓存
cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
}else{
LOGGER.warn("in deliveryGoodsToBuyer update status number zero, buyer Order orderCode {} pstatus {}, expect Order Status {}",
orderCode, buyerOrder.getStatus(), expectOrderStatus);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
}
/**
* 鉴定通过,但是不发货
* @return
*/
public ApiResponse judgeCenterPass(Long orderCode){
LOGGER.info("judgeCenterPass enter orderCode {}", orderCode);
ApiResponse apiResponse=new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("judgeCenterPass getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
final OrderStatus expectOrderStatus ;
final OrderStatus targetOrderStatus = OrderStatus.JUDGE_PASS;
if( OrderStatus.PLATFORM_CHECKING.getCode() == buyerOrder.getStatus().intValue()){
expectOrderStatus = OrderStatus.PLATFORM_CHECKING;
}else if(OrderStatus.MINI_FAULT_ACCEPT.getCode() == buyerOrder.getStatus().intValue()){
expectOrderStatus = OrderStatus.MINI_FAULT_ACCEPT;
}else{
LOGGER.warn("in judgeCenterPass, buyer Order orderCode {} status {}, expect Order Status is OrderStatus.PLATFORM_CHECKING or OrderStatus.MINI_FAULT_ACCEPT ",
orderCode, buyerOrder.getStatus());
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
LOGGER.info("judgeCenterPass enter orderCode {} ,expectOrderStatus {}", orderCode ,expectOrderStatus);
Integer buyerUid = buyerOrder.getUid();
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
int skup = bog.getSkup();
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid,
expectOrderStatus.getCode(), targetOrderStatus.getCode(), DateUtil.getCurrentTimeSecond());
if (updateBuyerCnt == 1){
final Integer sellerUid = sellerOrder.getUid();
final Long sellerOrderCode = sellerOrder.getOrderCode();
final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;
final SellerOrderStatus targetSoStatus = SellerOrderStatus.FINISH;
/**
* 更新卖家订单状态,
*/
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
skup, orderCode, buyerUid);
//退款给卖家(仅退一次)
PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid,orderCode,skup,sellerOrder,targetSoStatus);
try {
//记录订单的状态变更信息
LOGGER.info("in judgeCenterPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetOrderStatus.getCode());
//TODO 鉴定通过,等待发货,消息
//inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods);
}catch (Exception ex){
LOGGER.warn("in judgeCenterPass,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
String content = "后台鉴定通过商品,订单"+ orderCode + "退还保证金失败";
apiResponse.setCode(400);
apiResponse.setMessage(content);
}finally {
//记录调拨信息
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_pass;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
}
LOGGER.info("in judgeCenterPass, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
sellerUid, sellerOrderCode, skup, sellerOrder.getEarnestMoney() );
}else{
LOGGER.warn("in judgeCenterPass, buyer Order pstatus {}, expect expectOrderStatus {}",
buyerOrder.getStatus(), expectOrderStatus);
apiResponse.setCode(400);
apiResponse.setMessage("订单状态发生变化");
}
return apiResponse;
}
/**
* 通过时 ,操作钱
*/
private PaymentRequest operateMoneyWhenOk(Integer buyerUid,Long orderCode,int skup,SellerOrder sellerOrder,SellerOrderStatus targetSoStatus){
final Integer sellerUid = sellerOrder.getUid();
BigDecimal saleIncome = getSaleIncome(sellerUid, skup);
TransferCase transferCase = TransferCase.ALL_GOODS_MONEY_TO_SELLER;
TranseferCellNode transeferCellNode = new TranseferCellNode();
transeferCellNode.setUid(sellerUid);
transeferCellNode.setAmount(saleIncome);
TransferMoneyRequest tmReq = TransferMoneyRequest.builder()
.buyerOrderCode(orderCode)
.type(transferCase.getCode())
.transferCase(transferCase)
.transeferCellNode(transeferCellNode)
.alarmConfig(AlarmConfig.APPRAISE_SUCCESS)
.build();
//先校验,提前把错误抛出
paymentService.transferMonCheck(tmReq);
//改成异步的分账,不关心分账执行结果
executorService.execute(()->{
LOGGER.info("in appraiseSuccess,begin transfer async");
transferService.transfer(tmReq);
});
//退保证金给卖家
//refund earnestMoney
BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.APPRAISE_OK,orderCode,sellerUid ,sellerOrder,skup,buyerUid,targetSoStatus,earnestMoney.doubleValue());
LOGGER.info("in appraiseSuccess,refund ok, refundReqOfSeller {}", refundReqOfSeller);
return refundReqOfSeller;
}
public ApiResponse appraiseSuccessAndDelivery(Integer expressCompanyId, Long orderCode, String wayBillCode,Integer depotNum,String mobile){
ApiResponse apiResponse=new ApiResponse();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
... ... @@ -683,6 +1124,7 @@ public class AppraiseService {
* 退款给卖家(仅退一次)
*
*/
/*
SellerOrder tso = new SellerOrder();
tso.setUid(sellerUid);
tso.setOrderCode(sellerOrderCode);
... ... @@ -690,6 +1132,15 @@ public class AppraiseService {
tso.setUpdateTime(DateUtil.getCurrentTimeSecond());
tso.setExceptStatus(expectSOStatus.getCode());
int soCnt = sellerOrderMapper.updateByOrderCode(tso);
*/
//更新卖家订单状态
SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
skup, orderCode, buyerUid);
//退款给卖家(仅退一次)
PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid,orderCode,skup,sellerOrder,targetSoStatus);
/*
BigDecimal saleIncome = getSaleIncome(sellerUid, skup);
TransferCase transferCase = TransferCase.ALL_GOODS_MONEY_TO_SELLER;
... ... @@ -713,15 +1164,14 @@ public class AppraiseService {
transferService.transfer(tmReq);
});
/**
* 退保证金给卖家
*/
//退保证金给卖家
//refund earnestMoney
BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.APPRAISE_OK,orderCode,sellerUid ,sellerOrder,skup,buyerUid,targetSoStatus,earnestMoney.doubleValue());
LOGGER.info("in appraiseSuccess,refund ok, refundReqOfSeller {}", refundReqOfSeller);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
*/
try {
//鉴定通过后自动发货,这个时候产生:买家确认收货的mq
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
... ... @@ -749,6 +1199,7 @@ public class AppraiseService {
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
}
/*
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
... ... @@ -758,9 +1209,10 @@ public class AppraiseService {
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid);
EventBusPublisher.publishEvent(event);
*/
LOGGER.info("in appraiseSuccess, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
sellerUid, sellerOrderCode, skup, earnestMoney );
sellerUid, sellerOrderCode, skup, sellerOrder.getEarnestMoney() );
}else{
... ...
... ... @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
... ... @@ -482,6 +483,43 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
node.buyerOrderInDB = buyerOrder;
return node;
}
/**
* 该方法再6.8.6.5版本中使用,拆分订单的时候,存在多种情况expectStatus
* 瑕疵接受
* 瑕疵不接受 这两种情形使用
*/
@Deprecated
private void checkStatusWithMoreExpectStatus(DataNode node, OrderRequest orderRequest, List<Integer> expectStatusList ) {
BuyerOrder buyerOrder = node.buyerOrderInDB;
// 检查 订单状态
int status = buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus().intValue();
OrderStatus orderStatus = OrderStatus.getOrderStatus(status);
if (orderStatus == null || !expectStatusList.contains(orderStatus.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);
}
// 状态是待支付的场合,到第三方检查是否支付过了
Payment payment = Payment.getPayment(buyerOrder.getPayment());
if (payment != null && status == OrderStatus.WAITING_PAY.getCode()){
/*AbstractPayService payService = paymentService.getPayService(payment.getCode());
PayQueryBo payQueryBo = payService.payQuery(String.valueOf(buyerOrder.getOrderCode()));
if (payQueryBo != null && payQueryBo.isPayStatus()){
logger.warn("check status failed ,confirm paid, uid is {}, orderCode is {}, status is {}",
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrder.getStatus());
// 主动触发支付结果确认
PayConfirmEvent event = new PayConfirmEvent(buyerOrder.getUid(), buyerOrder.getOrderCode(), buyerOrder.getPayment());
EventBusPublisher.publishEvent(event);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}*/
}
}
/**
*
* @param orderRequest
... ... @@ -743,6 +781,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
public void miniFaultCreate(long orderCode){
logger.info("in miniFaultCreate, orderCode {}", orderCode);
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
OrderStatus targetStatus = OrderStatus.MINI_FAULT_WAITING;
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if (buyerOrder == null ){
throw new ServiceException(400,"订单为空");
... ... @@ -754,30 +793,33 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
int uid = buyerOrder.getUid();
int sellerUid = buyerOrder.getSellerUid();
if (1 == buyerOrderMapper.updateStatusByOrderCode(orderCode, uid,
expectStatus.getCode(),
targetStatus.getCode(),
DateUtil.getCurrentTimeSecond())) {
//先补一条鉴定中
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
//先补一条鉴定中
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
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);
//TODO 产生一个延时队列(24小时后,超时确认)
BuyerMiniFaultOuterTimeEvent miniFaultOuterTimeEvent = BuyerMiniFaultOuterTimeEvent.builder().uid(uid).orderCode(orderCode).build();
logger.info("in miniFaultCreate, push event uid {} ,order code {} ", miniFaultOuterTimeEvent.getUid(),miniFaultOuterTimeEvent.getOrderCode());
EventBusPublisher.publishEvent(miniFaultOuterTimeEvent);
//记录调拨信息(只保存卖家一条)
expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
expressDataType = EnumExpressDataType.operate_transfer;
operateTransferCode = EnumExpressDataOperateTransferCode.mini_fault_create;
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());
EventBusPublisher.publishEvent(miniFaultOuterTimeEvent);
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
//消息
inBoxFacade.buyerMiniFaultCreate(uid,orderCode,sellerOrderGoods.getProductName());
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
//消息
inBoxFacade.buyerMiniFaultCreate(uid,orderCode,sellerOrderGoods.getProductName());
}
}
/**
... ... @@ -788,18 +830,21 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
public void miniFaultAccept(OrderRequest orderRequest){
logger.info("Buyer Order miniFaultAccept (OrderRequest) {}", orderRequest);
//订单状态变更为鉴定中 ,记录调拨的物流信息 ,发消息 ,
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
OrderStatus targetStatus = OrderStatus.PLATFORM_CHECKING;
OrderStatus expectStatusNew = OrderStatus.MINI_FAULT_WAITING;
//拆分状态,版本升级之后存在的特殊订单
OrderStatus expectStatusAnother = OrderStatus.PLATFORM_RECEIVE;
List<Integer> expectStatusList= Lists.newArrayList(expectStatusNew.getCode(),expectStatusAnother.getCode());
OrderStatus targetStatus = OrderStatus.MINI_FAULT_ACCEPT;
// 参数检查
DataNode node = checkBase(orderRequest);
checkStatus(node,orderRequest, expectStatus);
checkStatusWithMoreExpectStatus(node,orderRequest, expectStatusList);
int uid=orderRequest.getUid();
long orderCode=orderRequest.getOrderCode();
BuyerOrder buyerOrder = node.buyerOrderInDB;
int sellerUid = buyerOrder.getSellerUid();
if (1 == buyerOrderMapper.updateStatusByOrderCode(orderCode, uid,
expectStatus.getCode(),
if (1 == buyerOrderMapper.updateStatusByOrderCodeMoreExpectStatus(orderCode, uid,
expectStatusList,
targetStatus.getCode(),
DateUtil.getCurrentTimeSecond())) {
logger.info("Buyer Order miniFaultAccept (OrderRequest) {} ,update status success ", orderRequest);
... ... @@ -832,21 +877,16 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
public void miniFaultReject(OrderRequest orderRequest){
logger.info("Buyer Order miniFaultReject (OrderRequest) {}", orderRequest);
//订单状态变更为 鉴定不通过 ,记录调拨的物流信息 ,发消息 ,
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
//OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
OrderStatus expectStatusNew = OrderStatus.MINI_FAULT_WAITING;
//拆分状态,版本升级之后存在的特殊订单
OrderStatus expectStatusAnother = OrderStatus.PLATFORM_RECEIVE;
List<Integer> expectStatusList= Lists.newArrayList(expectStatusNew.getCode(),expectStatusAnother.getCode());
OrderStatus targetStatus = OrderStatus.MINI_FAULT_REJECT;
// 参数检查
DataNode node = checkBase(orderRequest);
checkStatus(node,orderRequest, expectStatus);
//int uid=orderRequest.getUid();
checkStatusWithMoreExpectStatus(node,orderRequest, expectStatusList);
long orderCode=orderRequest.getOrderCode();
//BuyerOrder buyerOrder = node.buyerOrderInDB;
//int sellerUid = buyerOrder.getSellerUid();
//调用鉴定不通过的逻辑
//AppraiseExpressInfoBo appraiseExpressInfoBo=new AppraiseExpressInfoBo();
//appraiseExpressInfoBo.setOrderCode(orderCode);
ApiResponse result=appraiseService.miniFaultReject(orderCode,false);
ApiResponse result=appraiseService.miniFaultReject(orderCode,targetStatus,false);
if(result!=null&&result.getCode()==200){
//TODO 发消息
... ...
... ... @@ -440,7 +440,10 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
//5 卖家发货 == 交易关闭 ,全部点亮
expressInfoRespBo.setStage(1);
if(OrderStatus.PLATFORM_RECEIVE.getCode()==status
||OrderStatus.PLATFORM_CHECKING.getCode()==status){
||OrderStatus.PLATFORM_CHECKING.getCode()==status
||OrderStatus.MINI_FAULT_WAITING.getCode()==status
||OrderStatus.MINI_FAULT_ACCEPT.getCode()==status
||OrderStatus.JUDGE_PASS.getCode()==status){
expressInfoRespBo.setStage(2);
}else if(OrderStatus.WAITING_RECEIVE.getCode()==status){
if(TabType.BUY==actor){
... ... @@ -452,7 +455,10 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
}
}else if(OrderStatus.DONE.getCode()==status){
expressInfoRespBo.setStage(3);
}else if(OrderStatus.CHECKING_FAKE.getCode()==status){
}else if(OrderStatus.CHECKING_FAKE.getCode()==status
||OrderStatus.QUALITY_CHECK_FAKE.getCode()==status
||OrderStatus.MINI_FAULT_REJECT.getCode()==status
||OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode()==status){
expressInfoRespBo.setStage(4);
}else if(OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode()==status){
expressInfoRespBo.setStage(5);
... ... @@ -519,12 +525,18 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
){
return Arrays.asList(EnumExpressType.EXPRESS_TYPE_1.getCode());
}else if(OrderStatus.PLATFORM_RECEIVE.getCode()==status
||OrderStatus.PLATFORM_CHECKING.getCode()==status){
||OrderStatus.PLATFORM_CHECKING.getCode()==status
||OrderStatus.MINI_FAULT_WAITING.getCode()==status
||OrderStatus.MINI_FAULT_ACCEPT.getCode()==status
||OrderStatus.JUDGE_PASS.getCode()==status){
return Arrays.asList(EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode(),EnumExpressType.EXPRESS_TYPE_1.getCode());
}else if(OrderStatus.WAITING_RECEIVE.getCode()==status||OrderStatus.DONE.getCode()==status){
//4 和 5 状态有问题 ,买家查看物流是没问题的,卖家查看物流有问题啊.
return Arrays.asList(EnumExpressType.EXPRESS_TYPE_2.getCode(),EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode(),EnumExpressType.EXPRESS_TYPE_1.getCode());
}else if(OrderStatus.CHECKING_FAKE.getCode()==status){
}else if(OrderStatus.CHECKING_FAKE.getCode()==status
||OrderStatus.QUALITY_CHECK_FAKE.getCode()==status
||OrderStatus.MINI_FAULT_REJECT.getCode()==status
||OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode()==status){
return Arrays.asList(EnumExpressType.EXPRESS_TYPE_3.getCode(),EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode(),EnumExpressType.EXPRESS_TYPE_1.getCode());
}else if(OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode()==status){
return Arrays.asList(EnumExpressType.EXPRESS_TYPE_REBACK.getCode(),EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode(),EnumExpressType.EXPRESS_TYPE_1.getCode());
... ...
... ... @@ -18,7 +18,7 @@
<properties>
<qiniu.version>7.0.5</qiniu.version>
<project-name>yohoufo-fore</project-name>
<model.version>6.0-SNAPSHOT</model.version>
<model.version>6.5-SNAPSHOT</model.version>
</properties>
<dependencyManagement>
... ...