Authored by qinchao

记录平台发货状态

package com.yohoufo.common.constant;
/**
* 平台发货的标识
*/
public enum EnumPlatformDeliveryStatus {
delivery_to_seller(1,"鉴定中心发货到卖家"),
delivery_to_buyer (2,"鉴定中心发货到买家"),
;
private Integer code;
private String name;
EnumPlatformDeliveryStatus(Integer code, String name){
this.code = code;
this.name = name;
}
public int getCode() {
return code;
}
}
... ...
... ... @@ -51,10 +51,8 @@ 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);
// 修改订单的平台发货状态
int updatePlatformDeliveryStatusByOrderCode(@Param("orderCode")long orderCode, @Param("uid")int uid, @Param("targetPlatformDeliveryStatus")int targetPlatformDeliveryStatus,@Param("currentTime")int currentTime);
// 根据uid查询订单总数
Integer selectOrderNumByUid(@Param("uid")int uid);
... ...
... ... @@ -41,6 +41,9 @@ public class BuyerOrder {
private Integer sellerOrderStatus;
@Getter@Setter
private Integer platformDeliveryStatus;//1 平台发货给卖家, 2 平台发货给买家
@Getter@Setter
private Integer attributes;
public Integer getId() {
... ...
... ... @@ -19,10 +19,11 @@
<result column="seller_order_status" jdbcType="INTEGER" property="sellerOrderStatus" />
<result column="channel_no" jdbcType="VARCHAR" property="channelNo" />
<result column="attributes" jdbcType="INTEGER" property="attributes" />
<result column="platform_delivery_status" jdbcType="INTEGER" property="platformDeliveryStatus" />
</resultMap>
<sql id="Base_Column_List">
id, uid, order_code, seller_uid, client_type, payment, payment_type, is_cancel, amount,
ship_fee, status, create_time, update_time, buyer_order_status, seller_order_status, channel_no, attributes
ship_fee, status, create_time, update_time, buyer_order_status, seller_order_status, channel_no, attributes,platform_delivery_status
</sql>
... ... @@ -137,13 +138,13 @@
client_type, payment, payment_type,
is_cancel, amount, ship_fee,
status, create_time, update_time,
buyer_order_status, seller_order_status, channel_no, attributes)
buyer_order_status, seller_order_status, channel_no, attributes,platform_delivery_status)
values (#{uid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT}, #{sellerUid,jdbcType=INTEGER},
#{clientType,jdbcType=INTEGER}, #{payment,jdbcType=INTEGER}, #{paymentType,jdbcType=TINYINT},
#{isCancel,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{shipFee,jdbcType=DECIMAL},
#{status,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
#{buyerOrderStatus,jdbcType=INTEGER}, #{sellerOrderStatus,jdbcType=INTEGER}, #{channelNo,jdbcType=VARCHAR},
#{attributes,jdbcType=INTEGER})
#{attributes,jdbcType=INTEGER},#{platformDeliveryStatus,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrder" useGeneratedKeys="true">
insert into buyer_order
... ... @@ -197,6 +198,9 @@
<if test="attributes != null">
attributes,
</if>
<if test="platformDeliveryStatus != null">
platform_delivery_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="uid != null">
... ... @@ -247,6 +251,9 @@
<if test="attributes != null">
#{attributes,jdbcType=INTEGER},
</if>
<if test="platformDeliveryStatus != null">
#{platformDeliveryStatus,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.BuyerOrder">
... ... @@ -387,18 +394,11 @@
where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT} and status = #{status, jdbcType=INTEGER}
</update>
<!--
<update id="updateStatusByOrderCodeMoreExpectStatus">
<update id="updatePlatformDeliveryStatusByOrderCode">
update buyer_order set
status = #{targetStatus,jdbcType=INTEGER},
update_time = #{currentTime,jdbcType=INTEGER}
platform_delivery_status = #{targetPlatformDeliveryStatus,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
... ...
... ... @@ -13,6 +13,7 @@ import com.yohobuy.ufo.model.promotion.request.CouponSendMqBean;
import com.yohobuy.ufo.model.promotion.request.CouponSendType;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.constant.EnumPlatformDeliveryStatus;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
... ... @@ -68,7 +69,7 @@ public class AppraiseService {
private static final Logger LOGGER = LoggerFactory.getLogger(AppraiseService.class);
private ExecutorService executorService = new ThreadPoolExecutor(3, 5, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(100), new PubThreadFactory("appraise-processor"));
private ExecutorService executorService = new ThreadPoolExecutor(3, 5, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1000), new PubThreadFactory("appraise-processor"));
@Autowired
private IExpressInfoService expressInfoService;
... ... @@ -214,10 +215,15 @@ public class AppraiseService {
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
EventBusPublisher.publishEvent(buyerConfirmEvent);
//记录物流信息
//发物流
expressInfoService.deliverGoods(buyerUid, appraiseExpressInfoBo.getExpressCompanyId(), orderCode, appraiseExpressInfoBo.getWayBillCode(), appraiseExpressInfoBo.getDepotNum(), appraiseExpressInfoBo.getMobile());
executorService.execute(() -> {
//记录物流信息
//发物流
expressInfoService.deliverGoods(buyerUid, appraiseExpressInfoBo.getExpressCompanyId(), orderCode, appraiseExpressInfoBo.getWayBillCode(), appraiseExpressInfoBo.getDepotNum(), appraiseExpressInfoBo.getMobile());
//更新平台物流状态为已发货
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
EnumPlatformDeliveryStatus.delivery_to_buyer.getCode(), DateUtil.getCurrentTimeSecond());
});
//记录订单的状态变更信息
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
... ... @@ -291,11 +297,16 @@ public class AppraiseService {
LOGGER.info("returnBackOrderCauseOfJudgeFailure check status ok expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), orderCode);
executorService.execute(() -> {
//更新物流信息
int sellerUid = buyerOrder.getSellerUid();
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
//更新物流信息
int sellerUid = buyerOrder.getSellerUid();
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
//更新平台物流状态为已发货
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
});
//清缓存
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
... ... @@ -342,10 +353,15 @@ public class AppraiseService {
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
//记录物流信息
int sellerUid = buyerOrder.getSellerUid();
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, false);
executorService.execute(() -> {
//记录物流信息
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, false);
//更新平台物流状态为已发货
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
});
//发送消息
inBoxFacade.sendCancelledProductToSellerByCenter(sellerUid, wayBillCode);
... ... @@ -384,8 +400,14 @@ public class AppraiseService {
//记录物流信息
int sellerUid = buyerOrder.getSellerUid();
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, true);
executorService.execute(() -> {
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, true);
//更新平台物流状态为已发货
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
});
//发送消息
//清缓存
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
... ... @@ -747,6 +769,10 @@ public class AppraiseService {
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
expressInfoService.saveOperateTransferExpressInfo(sellerUid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
//更新平台物流状态为已发货
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
//发货物流(平台已发货)
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
... ... @@ -1250,6 +1276,11 @@ public class AppraiseService {
//鉴定通过后自动发货,这个时候产生:买家确认收货的mq
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
EventBusPublisher.publishEvent(buyerConfirmEvent);
//更新平台物流状态为已发货
buyerOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
EnumPlatformDeliveryStatus.delivery_to_buyer.getCode(), DateUtil.getCurrentTimeSecond());
//记录物流信息
//发物流
expressInfoService.deliverGoods(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
... ...