Authored by mali

Merge branch 'dev_20190403_代码优化'

  1 +package com.yohoufo.common.constant;
  2 +
  3 +/**
  4 + * 平台发货的标识
  5 + */
  6 +
  7 +public enum EnumPlatformDeliveryStatus {
  8 + delivery_to_seller(1,"鉴定中心发货到卖家"),
  9 + delivery_to_buyer (2,"鉴定中心发货到买家"),
  10 + ;
  11 +
  12 + private Integer code;
  13 + private String name;
  14 +
  15 + EnumPlatformDeliveryStatus(Integer code, String name){
  16 + this.code = code;
  17 + this.name = name;
  18 + }
  19 +
  20 + public int getCode() {
  21 + return code;
  22 + }
  23 +}
@@ -51,10 +51,8 @@ public interface BuyerOrderMapper { @@ -51,10 +51,8 @@ public interface BuyerOrderMapper {
51 // 修改订单状态 51 // 修改订单状态
52 int updateStatusByOrderCode(@Param("orderCode")long orderCode, @Param("uid")int uid, @Param("status")int status, @Param("targetStatus")int targetStatus, @Param("currentTime")int currentTime); 52 int updateStatusByOrderCode(@Param("orderCode")long orderCode, @Param("uid")int uid, @Param("status")int status, @Param("targetStatus")int targetStatus, @Param("currentTime")int currentTime);
53 53
54 - //修改订单状态 , 6.8.7版本以后去掉 ,不要引用该方法  
55 - //拆分出瑕疵确认状态,系统上线之初存在多种状态的情况  
56 - //@Deprecated  
57 - //int updateStatusByOrderCodeMoreExpectStatus(@Param("orderCode")long orderCode, @Param("uid")int uid, @Param("expectStatusList")List<Integer> expectStatusList, @Param("targetStatus")int targetStatus, @Param("currentTime")int currentTime); 54 + // 修改订单的平台发货状态
  55 + int updatePlatformDeliveryStatusByOrderCode(@Param("orderCode")long orderCode, @Param("uid")int uid, @Param("targetPlatformDeliveryStatus")int targetPlatformDeliveryStatus,@Param("currentTime")int currentTime);
58 56
59 // 根据uid查询订单总数 57 // 根据uid查询订单总数
60 Integer selectOrderNumByUid(@Param("uid")int uid); 58 Integer selectOrderNumByUid(@Param("uid")int uid);
@@ -41,6 +41,9 @@ public class BuyerOrder { @@ -41,6 +41,9 @@ public class BuyerOrder {
41 private Integer sellerOrderStatus; 41 private Integer sellerOrderStatus;
42 42
43 @Getter@Setter 43 @Getter@Setter
  44 + private Integer platformDeliveryStatus;//1 平台发货给卖家, 2 平台发货给买家
  45 +
  46 + @Getter@Setter
44 private Integer attributes; 47 private Integer attributes;
45 48
46 public Integer getId() { 49 public Integer getId() {
@@ -19,10 +19,11 @@ @@ -19,10 +19,11 @@
19 <result column="seller_order_status" jdbcType="INTEGER" property="sellerOrderStatus" /> 19 <result column="seller_order_status" jdbcType="INTEGER" property="sellerOrderStatus" />
20 <result column="channel_no" jdbcType="VARCHAR" property="channelNo" /> 20 <result column="channel_no" jdbcType="VARCHAR" property="channelNo" />
21 <result column="attributes" jdbcType="INTEGER" property="attributes" /> 21 <result column="attributes" jdbcType="INTEGER" property="attributes" />
  22 + <result column="platform_delivery_status" jdbcType="INTEGER" property="platformDeliveryStatus" />
22 </resultMap> 23 </resultMap>
23 <sql id="Base_Column_List"> 24 <sql id="Base_Column_List">
24 id, uid, order_code, seller_uid, client_type, payment, payment_type, is_cancel, amount, 25 id, uid, order_code, seller_uid, client_type, payment, payment_type, is_cancel, amount,
25 - ship_fee, status, create_time, update_time, buyer_order_status, seller_order_status, channel_no, attributes 26 + ship_fee, status, create_time, update_time, buyer_order_status, seller_order_status, channel_no, attributes,platform_delivery_status
26 </sql> 27 </sql>
27 28
28 29
@@ -137,13 +138,13 @@ @@ -137,13 +138,13 @@
137 client_type, payment, payment_type, 138 client_type, payment, payment_type,
138 is_cancel, amount, ship_fee, 139 is_cancel, amount, ship_fee,
139 status, create_time, update_time, 140 status, create_time, update_time,
140 - buyer_order_status, seller_order_status, channel_no, attributes) 141 + buyer_order_status, seller_order_status, channel_no, attributes,platform_delivery_status)
141 values (#{uid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT}, #{sellerUid,jdbcType=INTEGER}, 142 values (#{uid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT}, #{sellerUid,jdbcType=INTEGER},
142 #{clientType,jdbcType=INTEGER}, #{payment,jdbcType=INTEGER}, #{paymentType,jdbcType=TINYINT}, 143 #{clientType,jdbcType=INTEGER}, #{payment,jdbcType=INTEGER}, #{paymentType,jdbcType=TINYINT},
143 #{isCancel,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{shipFee,jdbcType=DECIMAL}, 144 #{isCancel,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{shipFee,jdbcType=DECIMAL},
144 #{status,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}, 145 #{status,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
145 #{buyerOrderStatus,jdbcType=INTEGER}, #{sellerOrderStatus,jdbcType=INTEGER}, #{channelNo,jdbcType=VARCHAR}, 146 #{buyerOrderStatus,jdbcType=INTEGER}, #{sellerOrderStatus,jdbcType=INTEGER}, #{channelNo,jdbcType=VARCHAR},
146 - #{attributes,jdbcType=INTEGER}) 147 + #{attributes,jdbcType=INTEGER},#{platformDeliveryStatus,jdbcType=INTEGER})
147 </insert> 148 </insert>
148 <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrder" useGeneratedKeys="true"> 149 <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrder" useGeneratedKeys="true">
149 insert into buyer_order 150 insert into buyer_order
@@ -197,6 +198,9 @@ @@ -197,6 +198,9 @@
197 <if test="attributes != null"> 198 <if test="attributes != null">
198 attributes, 199 attributes,
199 </if> 200 </if>
  201 + <if test="platformDeliveryStatus != null">
  202 + platform_delivery_status,
  203 + </if>
200 </trim> 204 </trim>
201 <trim prefix="values (" suffix=")" suffixOverrides=","> 205 <trim prefix="values (" suffix=")" suffixOverrides=",">
202 <if test="uid != null"> 206 <if test="uid != null">
@@ -247,6 +251,9 @@ @@ -247,6 +251,9 @@
247 <if test="attributes != null"> 251 <if test="attributes != null">
248 #{attributes,jdbcType=INTEGER}, 252 #{attributes,jdbcType=INTEGER},
249 </if> 253 </if>
  254 + <if test="platformDeliveryStatus != null">
  255 + #{platformDeliveryStatus,jdbcType=INTEGER},
  256 + </if>
250 </trim> 257 </trim>
251 </insert> 258 </insert>
252 <update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.BuyerOrder"> 259 <update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.BuyerOrder">
@@ -387,18 +394,11 @@ @@ -387,18 +394,11 @@
387 where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT} and status = #{status, jdbcType=INTEGER} 394 where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT} and status = #{status, jdbcType=INTEGER}
388 </update> 395 </update>
389 396
390 - <!--  
391 - <update id="updateStatusByOrderCodeMoreExpectStatus"> 397 + <update id="updatePlatformDeliveryStatusByOrderCode">
392 update buyer_order set 398 update buyer_order set
393 - status = #{targetStatus,jdbcType=INTEGER},  
394 - update_time = #{currentTime,jdbcType=INTEGER} 399 + platform_delivery_status = #{targetPlatformDeliveryStatus,jdbcType=INTEGER}, update_time = #{currentTime,jdbcType=INTEGER}
395 where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT} 400 where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT}
396 - and status in  
397 - <foreach item="item" index="index" collection="expectStatusList" open="(" separator="," close=")">  
398 - #{item}  
399 - </foreach>  
400 </update> 401 </update>
401 - -->  
402 402
403 <select id="selectOrderNumByUid" resultType="java.lang.Integer"> 403 <select id="selectOrderNumByUid" resultType="java.lang.Integer">
404 select count(*) from buyer_order where uid = #{uid,jdbcType=INTEGER} and buyer_order_status = 1 404 select count(*) from buyer_order where uid = #{uid,jdbcType=INTEGER} and buyer_order_status = 1
@@ -13,6 +13,7 @@ import com.yohobuy.ufo.model.promotion.request.CouponSendMqBean; @@ -13,6 +13,7 @@ import com.yohobuy.ufo.model.promotion.request.CouponSendMqBean;
13 import com.yohobuy.ufo.model.promotion.request.CouponSendType; 13 import com.yohobuy.ufo.model.promotion.request.CouponSendType;
14 import com.yohoufo.common.ApiResponse; 14 import com.yohoufo.common.ApiResponse;
15 import com.yohoufo.common.alarm.EventBusPublisher; 15 import com.yohoufo.common.alarm.EventBusPublisher;
  16 +import com.yohoufo.common.constant.EnumPlatformDeliveryStatus;
16 import com.yohoufo.common.utils.DateUtil; 17 import com.yohoufo.common.utils.DateUtil;
17 import com.yohoufo.dal.order.*; 18 import com.yohoufo.dal.order.*;
18 import com.yohoufo.dal.order.model.*; 19 import com.yohoufo.dal.order.model.*;
@@ -68,7 +69,7 @@ public class AppraiseService { @@ -68,7 +69,7 @@ public class AppraiseService {
68 69
69 private static final Logger LOGGER = LoggerFactory.getLogger(AppraiseService.class); 70 private static final Logger LOGGER = LoggerFactory.getLogger(AppraiseService.class);
70 71
71 - private ExecutorService executorService = new ThreadPoolExecutor(3, 5, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(100), new PubThreadFactory("appraise-processor")); 72 + private ExecutorService executorService = new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1000), new PubThreadFactory("appraise-processor"));
72 73
73 @Autowired 74 @Autowired
74 private IExpressInfoService expressInfoService; 75 private IExpressInfoService expressInfoService;
@@ -214,10 +215,15 @@ public class AppraiseService { @@ -214,10 +215,15 @@ public class AppraiseService {
214 BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build(); 215 BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
215 EventBusPublisher.publishEvent(buyerConfirmEvent); 216 EventBusPublisher.publishEvent(buyerConfirmEvent);
216 217
  218 + executorService.execute(() -> {
217 //记录物流信息 219 //记录物流信息
218 //发物流 220 //发物流
219 expressInfoService.deliverGoods(buyerUid, appraiseExpressInfoBo.getExpressCompanyId(), orderCode, appraiseExpressInfoBo.getWayBillCode(), appraiseExpressInfoBo.getDepotNum(), appraiseExpressInfoBo.getMobile()); 221 expressInfoService.deliverGoods(buyerUid, appraiseExpressInfoBo.getExpressCompanyId(), orderCode, appraiseExpressInfoBo.getWayBillCode(), appraiseExpressInfoBo.getDepotNum(), appraiseExpressInfoBo.getMobile());
220 222
  223 + //更新平台物流状态为已发货
  224 + buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
  225 + EnumPlatformDeliveryStatus.delivery_to_buyer.getCode(), DateUtil.getCurrentTimeSecond());
  226 + });
221 //记录订单的状态变更信息 227 //记录订单的状态变更信息
222 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode()); 228 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
223 229
@@ -291,11 +297,16 @@ public class AppraiseService { @@ -291,11 +297,16 @@ public class AppraiseService {
291 LOGGER.info("returnBackOrderCauseOfJudgeFailure check status ok expectStatus {}, actual status {}, orderCode {}", expectStatus, 297 LOGGER.info("returnBackOrderCauseOfJudgeFailure check status ok expectStatus {}, actual status {}, orderCode {}", expectStatus,
292 buyerOrder.getStatus(), orderCode); 298 buyerOrder.getStatus(), orderCode);
293 299
294 - 300 + executorService.execute(() -> {
295 //更新物流信息 301 //更新物流信息
296 int sellerUid = buyerOrder.getSellerUid(); 302 int sellerUid = buyerOrder.getSellerUid();
297 expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile); 303 expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
298 304
  305 + //更新平台物流状态为已发货
  306 + buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
  307 + EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
  308 +
  309 + });
299 //清缓存 310 //清缓存
300 SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid()); 311 SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
301 312
@@ -342,10 +353,15 @@ public class AppraiseService { @@ -342,10 +353,15 @@ public class AppraiseService {
342 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); 353 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
343 } 354 }
344 355
345 - //记录物流信息  
346 int sellerUid = buyerOrder.getSellerUid(); 356 int sellerUid = buyerOrder.getSellerUid();
  357 + executorService.execute(() -> {
  358 + //记录物流信息
347 expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, false); 359 expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, false);
348 360
  361 + //更新平台物流状态为已发货
  362 + buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
  363 + EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
  364 + });
349 //发送消息 365 //发送消息
350 inBoxFacade.sendCancelledProductToSellerByCenter(sellerUid, wayBillCode); 366 inBoxFacade.sendCancelledProductToSellerByCenter(sellerUid, wayBillCode);
351 367
@@ -384,8 +400,14 @@ public class AppraiseService { @@ -384,8 +400,14 @@ public class AppraiseService {
384 400
385 //记录物流信息 401 //记录物流信息
386 int sellerUid = buyerOrder.getSellerUid(); 402 int sellerUid = buyerOrder.getSellerUid();
  403 + executorService.execute(() -> {
387 expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, true); 404 expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, true);
388 405
  406 + //更新平台物流状态为已发货
  407 + buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
  408 + EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
  409 + });
  410 +
389 //发送消息 411 //发送消息
390 //清缓存 412 //清缓存
391 SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid()); 413 SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
@@ -403,9 +425,6 @@ public class AppraiseService { @@ -403,9 +425,6 @@ public class AppraiseService {
403 LOGGER.info("Buyer Order miniFaultAccept (OrderRequest) {}", orderRequest); 425 LOGGER.info("Buyer Order miniFaultAccept (OrderRequest) {}", orderRequest);
404 //订单状态变更为鉴定中 ,记录调拨的物流信息 ,发消息 , 426 //订单状态变更为鉴定中 ,记录调拨的物流信息 ,发消息 ,
405 OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING; 427 OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING;
406 - //拆分状态,版本升级之后存在的特殊订单  
407 - //OrderStatus expectStatusAnother = OrderStatus.PLATFORM_RECEIVE;  
408 - //List<Integer> expectStatusList= Lists.newArrayList(expectStatus.getCode(),expectStatusAnother.getCode());  
409 OrderStatus targetStatus = OrderStatus.MINI_FAULT_ACCEPT; 428 OrderStatus targetStatus = OrderStatus.MINI_FAULT_ACCEPT;
410 429
411 // 参数检查 430 // 参数检查
@@ -426,8 +445,6 @@ public class AppraiseService { @@ -426,8 +445,6 @@ public class AppraiseService {
426 buyerOrder.getStatus(), buyerOrder.getOrderCode()); 445 buyerOrder.getStatus(), buyerOrder.getOrderCode());
427 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); 446 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
428 } 447 }
429 - //checkStatusWithMoreExpectStatus(buyerOrder,orderRequest, expectStatusList);  
430 -  
431 int buyerUid = orderRequest.getUid(); 448 int buyerUid = orderRequest.getUid();
432 long orderCode = orderRequest.getOrderCode(); 449 long orderCode = orderRequest.getOrderCode();
433 int sellerUid = buyerOrder.getSellerUid(); 450 int sellerUid = buyerOrder.getSellerUid();
@@ -497,9 +514,7 @@ public class AppraiseService { @@ -497,9 +514,7 @@ public class AppraiseService {
497 LOGGER.info("Buyer Order miniFaultNotAccept (OrderRequest) {}", orderRequest); 514 LOGGER.info("Buyer Order miniFaultNotAccept (OrderRequest) {}", orderRequest);
498 //订单状态变更为 鉴定不通过 ,记录调拨的物流信息 ,发消息 , 515 //订单状态变更为 鉴定不通过 ,记录调拨的物流信息 ,发消息 ,
499 OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING; 516 OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING;
500 - //拆分状态,版本升级之后存在的特殊订单  
501 - //OrderStatus expectStatusAnother = OrderStatus.PLATFORM_RECEIVE;  
502 - //List<Integer> expectStatusList= Lists.newArrayList(expectStatusNew.getCode(),expectStatusAnother.getCode()); 517 +
503 OrderStatus targetStatus = OrderStatus.MINI_FAULT_REJECT; 518 OrderStatus targetStatus = OrderStatus.MINI_FAULT_REJECT;
504 // 参数检查 519 // 参数检查
505 if (orderRequest.getUid() < 0 520 if (orderRequest.getUid() < 0
@@ -521,8 +536,6 @@ public class AppraiseService { @@ -521,8 +536,6 @@ public class AppraiseService {
521 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); 536 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
522 } 537 }
523 538
524 - //checkStatusWithMoreExpectStatus(buyerOrder,orderRequest, expectStatusList);  
525 -  
526 long orderCode = orderRequest.getOrderCode(); 539 long orderCode = orderRequest.getOrderCode();
527 ApiResponse result = this.miniFaultReject(orderCode, targetStatus, false); 540 ApiResponse result = this.miniFaultReject(orderCode, targetStatus, false);
528 541
@@ -536,21 +549,6 @@ public class AppraiseService { @@ -536,21 +549,6 @@ public class AppraiseService {
536 549
537 } 550 }
538 551
539 - /*  
540 - * 该方法再6.8.6.5版本中使用,拆分订单的时候,存在多种情况expectStatus  
541 - * 瑕疵接受  
542 - * 瑕疵不接受 这两种情形使用  
543 - @Deprecated  
544 - private void checkStatusWithMoreExpectStatus(BuyerOrder buyerOrder, OrderRequest orderRequest, List<Integer> expectStatusList ) {  
545 - // 检查 订单状态  
546 - int status = buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus().intValue();  
547 - OrderStatus orderStatus = OrderStatus.getOrderStatus(status);  
548 - if (orderStatus == null || !expectStatusList.contains(orderStatus.getCode())){  
549 - LOGGER.warn("check status invalidate, uid is {}, orderCode is {}, status is {}",  
550 - orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrder.getStatus());  
551 - throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);  
552 - }  
553 - }*/  
554 552
555 /** 553 /**
556 * 瑕疵不通过: 买家不接受或者超时确认 554 * 瑕疵不通过: 买家不接受或者超时确认
@@ -561,9 +559,6 @@ public class AppraiseService { @@ -561,9 +559,6 @@ public class AppraiseService {
561 public ApiResponse miniFaultReject(Long orderCode, OrderStatus targetStatus, boolean outTimeFlag) { 559 public ApiResponse miniFaultReject(Long orderCode, OrderStatus targetStatus, boolean outTimeFlag) {
562 LOGGER.info("miniFaultReject enter , orderCode {} ,targetStatus {},outTimeFlag {}", orderCode, targetStatus, outTimeFlag); 560 LOGGER.info("miniFaultReject enter , orderCode {} ,targetStatus {},outTimeFlag {}", orderCode, targetStatus, outTimeFlag);
563 OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING; 561 OrderStatus expectStatus = OrderStatus.MINI_FAULT_WAITING;
564 - //拆分状态,版本升级之后存在的特殊订单  
565 - //OrderStatus expectStatusAnother = OrderStatus.PLATFORM_RECEIVE;  
566 - //List<Integer> expectStatusList= Lists.newArrayList(expectStatusNew.getCode(),expectStatusAnother.getCode());  
567 ApiResponse apiResponse = new ApiResponse(); 562 ApiResponse apiResponse = new ApiResponse();
568 BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode); 563 BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
569 564
@@ -741,70 +736,6 @@ public class AppraiseService { @@ -741,70 +736,6 @@ public class AppraiseService {
741 DateUtil.getCurrentTimeSecond()); 736 DateUtil.getCurrentTimeSecond());
742 737
743 if (rows > 0) { 738 if (rows > 0) {
744 - /*  
745 - //refund coupons of buyer  
746 - BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)  
747 - .uid(buyerUid).orderCode(orderCode).build();  
748 - EventBusPublisher.publishEvent(brce);  
749 - //  
750 -  
751 - BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);  
752 - int skup = bog.getSkup();  
753 -  
754 - SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);  
755 - long sellerOrderCode = sellerOrder.getOrderCode();  
756 -  
757 - final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;  
758 - final SellerOrderStatus targetSoStatus = SellerOrderStatus.APPRAISAL_FAIL_COMPENSATE;  
759 -  
760 - SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,  
761 - skup, orderCode, buyerUid);  
762 -  
763 - //将卖家的保证金分账给平台和买家  
764 - PenaltyResult penaltyResult = SellerEarnestMoney2BuyerPenaltyCalculator.from(sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee"))  
765 - .calculate()  
766 - .orElse(null);  
767 - if(Objects.nonNull(penaltyResult)){  
768 - TransferCase transferCase = TransferCase.EARNEST_MONEY_TO_BUYER;  
769 - TranseferCellNode transeferCellNode = new TranseferCellNode();  
770 - transeferCellNode.setUid(buyerUid);  
771 - transeferCellNode.setAmount(penaltyResult.getPenaltyAmountWithoutYhServiceAmount());  
772 - TransferMoneyRequest tmReq = TransferMoneyRequest.builder()  
773 - .sellerUid(sellerUid)  
774 - .buyerOrderCode(orderCode)  
775 - .type(transferCase.getCode())  
776 - .transferCase(transferCase)  
777 - .transeferCellNode(transeferCellNode)  
778 - .swdType(SellerWalletDetail.Type.APPRAISE_FAIL)  
779 - .alarmConfig(AlarmConfig.APPRAISE_FAIL)  
780 - .build();  
781 -  
782 - //先校验,提前把错误抛出  
783 - paymentService.transferMonCheck(tmReq);  
784 - //再分账  
785 -  
786 - //改成异步的分账,不关心分账执行结果  
787 - executorService.execute(()->{  
788 - LOGGER.info("in appraiseFail,begin transfer async");  
789 - transferService.transfer(tmReq);  
790 - });  
791 - }  
792 -  
793 -  
794 - //退钱给买家  
795 - BigDecimal goodsAmount = buyerOrder.getAmount();  
796 - BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()  
797 - .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)  
798 - .payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)  
799 - .amount(goodsAmount)  
800 - .skup(skup);  
801 - boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler().loadPaymentRequest(buyerUid,orderCode,goodsAmount)  
802 - .loadBillLogEventBuilder(bleb)  
803 - .loadTargetOrderStatus(targetStatus)  
804 - .loadRefundAction(payRefundService::refund)  
805 - .loadLogger(LOGGER)  
806 - .refund();  
807 - */  
808 RefundMoneyResultModel refundMoneyResultModel = operateMoneyWhenCheckFail(buyerOrder, orderCode, targetStatus); 739 RefundMoneyResultModel refundMoneyResultModel = operateMoneyWhenCheckFail(buyerOrder, orderCode, targetStatus);
809 boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag(); 740 boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
810 SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods(); 741 SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
@@ -838,6 +769,10 @@ public class AppraiseService { @@ -838,6 +769,10 @@ public class AppraiseService {
838 EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject; 769 EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
839 expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode); 770 expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
840 771
  772 + //更新平台物流状态为已发货
  773 + buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
  774 + EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
  775 +
841 //发货物流(平台已发货) 776 //发货物流(平台已发货)
842 expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile); 777 expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
843 778
@@ -1331,59 +1266,21 @@ public class AppraiseService { @@ -1331,59 +1266,21 @@ public class AppraiseService {
1331 * 退款给卖家(仅退一次) 1266 * 退款给卖家(仅退一次)
1332 * 1267 *
1333 */ 1268 */
1334 - /*  
1335 - SellerOrder tso = new SellerOrder();  
1336 - tso.setUid(sellerUid);  
1337 - tso.setOrderCode(sellerOrderCode);  
1338 - tso.setStatus(targetSoStatus.getCode());  
1339 - tso.setUpdateTime(DateUtil.getCurrentTimeSecond());  
1340 - tso.setExceptStatus(expectSOStatus.getCode());  
1341 - int soCnt = sellerOrderMapper.updateByOrderCode(tso);  
1342 - */  
1343 //更新卖家订单状态 1269 //更新卖家订单状态
1344 SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid, sellerOrderCode, expectSOStatus, targetSoStatus, 1270 SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid, sellerOrderCode, expectSOStatus, targetSoStatus,
1345 skup, orderCode, buyerUid); 1271 skup, orderCode, buyerUid);
1346 1272
1347 //退款给卖家(仅退一次) 1273 //退款给卖家(仅退一次)
1348 PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid, orderCode, skup, sellerOrder, targetSoStatus); 1274 PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid, orderCode, skup, sellerOrder, targetSoStatus);
1349 -  
1350 -  
1351 - /*  
1352 - BigDecimal saleIncome = getSaleIncome(sellerUid, skup);  
1353 -  
1354 - TransferCase transferCase = TransferCase.ALL_GOODS_MONEY_TO_SELLER;  
1355 - TranseferCellNode transeferCellNode = new TranseferCellNode();  
1356 - transeferCellNode.setUid(sellerUid);  
1357 - transeferCellNode.setAmount(saleIncome);  
1358 - TransferMoneyRequest tmReq = TransferMoneyRequest.builder()  
1359 - .buyerOrderCode(orderCode)  
1360 - .type(transferCase.getCode())  
1361 - .transferCase(transferCase)  
1362 - .transeferCellNode(transeferCellNode)  
1363 - .alarmConfig(AlarmConfig.APPRAISE_SUCCESS)  
1364 - .build();  
1365 -  
1366 - //先校验,提前把错误抛出  
1367 - paymentService.transferMonCheck(tmReq);  
1368 -  
1369 - //改成异步的分账,不关心分账执行结果  
1370 - executorService.execute(()->{  
1371 - LOGGER.info("in appraiseSuccess,begin transfer async");  
1372 - transferService.transfer(tmReq);  
1373 - });  
1374 -  
1375 - //退保证金给卖家  
1376 - //refund earnestMoney  
1377 - BigDecimal earnestMoney = sellerOrder.getEarnestMoney();  
1378 - PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.APPRAISE_OK,orderCode,sellerUid ,sellerOrder,skup,buyerUid,targetSoStatus,earnestMoney.doubleValue());  
1379 - LOGGER.info("in appraiseSuccess,refund ok, refundReqOfSeller {}", refundReqOfSeller);  
1380 -  
1381 - SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);  
1382 - */  
1383 try { 1275 try {
1384 //鉴定通过后自动发货,这个时候产生:买家确认收货的mq 1276 //鉴定通过后自动发货,这个时候产生:买家确认收货的mq
1385 BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build(); 1277 BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
1386 EventBusPublisher.publishEvent(buyerConfirmEvent); 1278 EventBusPublisher.publishEvent(buyerConfirmEvent);
  1279 +
  1280 + //更新平台物流状态为已发货
  1281 + buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
  1282 + EnumPlatformDeliveryStatus.delivery_to_buyer.getCode(), DateUtil.getCurrentTimeSecond());
  1283 +
1387 //记录物流信息 1284 //记录物流信息
1388 //发物流 1285 //发物流
1389 expressInfoService.deliverGoods(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile); 1286 expressInfoService.deliverGoods(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
@@ -1409,18 +1306,6 @@ public class AppraiseService { @@ -1409,18 +1306,6 @@ public class AppraiseService {
1409 expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode); 1306 expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
1410 } 1307 }
1411 1308
1412 - /*  
1413 - cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),  
1414 - CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),  
1415 - CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),  
1416 - CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),  
1417 - CacheKeyBuilder.orderDetailKey(buyerUid,TabType.BUY.getValue(), orderCode),  
1418 - CacheKeyBuilder.buyerOrderNums(buyerUid)));  
1419 -  
1420 - ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid);  
1421 - EventBusPublisher.publishEvent(event);  
1422 - */  
1423 -  
1424 LOGGER.info("in appraiseSuccess, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}", 1309 LOGGER.info("in appraiseSuccess, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
1425 sellerUid, sellerOrderCode, skup, sellerOrder.getEarnestMoney()); 1310 sellerUid, sellerOrderCode, skup, sellerOrder.getEarnestMoney());
1426 1311
@@ -795,6 +795,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -795,6 +795,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
795 Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null); 795 Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
796 //消息 796 //消息
797 inBoxFacade.buyerMiniFaultCreate(uid,orderCode,sellerOrderGoods,product); 797 inBoxFacade.buyerMiniFaultCreate(uid,orderCode,sellerOrderGoods,product);
  798 +
  799 + //记录订单的状态变更信息
  800 + logger.info("in miniFaultCreate record status change, orderCode {},uid {} ,sellerUid {}", orderCode, uid, sellerUid);
  801 + orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
798 } 802 }
799 } 803 }
800 804
@@ -222,6 +222,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { @@ -222,6 +222,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService {
222 buyerOrder.setBuyerOrderStatus(DelStatus.NOT_DEL.getCode()); 222 buyerOrder.setBuyerOrderStatus(DelStatus.NOT_DEL.getCode());
223 buyerOrder.setSellerOrderStatus(DelStatus.NOT_DEL.getCode()); 223 buyerOrder.setSellerOrderStatus(DelStatus.NOT_DEL.getCode());
224 buyerOrder.setAttributes(orderBuilder.getAttributes()); 224 buyerOrder.setAttributes(orderBuilder.getAttributes());
  225 + buyerOrder.setPlatformDeliveryStatus(0);//平台发货状态给默认值
225 buyerOrderMapper.insert(buyerOrder); 226 buyerOrderMapper.insert(buyerOrder);
226 } 227 }
227 228