Authored by tanling

Merge branch 'test6.9.10' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.10

... ... @@ -48,6 +48,11 @@ public interface AppraiseOrderMapper {
@Param("expectedStatus")int expectedStatus,
@Param("updateTime")int updateTime);
int updateStatusByParentOrderCode(@Param("parentOrderCode") long parentOrderCode,
@Param("targetStatus")int targetStatus,
@Param("expectedStatus")int expectedStatus,
@Param("updateTime")int updateTime);
// 修改订单的平台发货状态
int updatePlatformDeliveryStatusByOrderCode(@Param("orderCode")long orderCode,
@Param("uid")int uid,
... ...
... ... @@ -261,6 +261,16 @@
where order_code =#{orderCode,jdbcType=BIGINT} and status = #{expectedStatus,jdbcType=TINYINT}
</update>
<update id="updateStatusByParentOrderCode">
update appraise_order
<set>
status = #{targetStatus,jdbcType=TINYINT},
update_time = #{updateTime,jdbcType=INTEGER}
</set>
where parent_order_code =#{parentOrderCode,jdbcType=BIGINT} and status = #{expectedStatus,jdbcType=TINYINT}
</update>
<select id="selectByOrderCodeList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
... ...
... ... @@ -62,6 +62,9 @@ public class GoodsServiceRefundHandler extends AbsRefundOrderHandler {
@Override
public boolean refund() {
logger.info("{}.refund uid {} orderCode {} paidOrderCode {}",
getClass().getSimpleName(), uid, orderCode, paidOrderCode);
if (paidOrderCode == null){
throw new UfoServiceException(400, "退款订单不存在");
}
... ...
... ... @@ -42,6 +42,17 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
return rows;
}
protected int triggerStatusChangeByParentCode(Long parentOrderCode, AppraiseOrderStatus targetStatus, AppraiseOrderStatus expectedStatus){
int cdt = DateUtil.getCurrentTimeSecond();
int rows = appraiseOrderMapper.updateStatusByParentOrderCode(parentOrderCode, targetStatus.getCode(), expectedStatus.getCode(), cdt);
if (rows==0){
logger.warn("appraise order triggerStatusChange no need update status, parentOrderCode {}", parentOrderCode);
return 0;
}
return rows;
}
public int triggerStatusChange(Long orderCode, AppraiseOrderStatus targetStatus, AppraiseOrderStatus expectedStatus){
int cdt = DateUtil.getCurrentTimeSecond();
int rows = appraiseOrderMapper.updateStatusByOrderCode(orderCode, targetStatus.getCode(), expectedStatus.getCode(), cdt);
... ...
... ... @@ -184,9 +184,11 @@ public class DepositHelpService {
List<AppraiseOrder> appraiseOrders = appraiseOrderMapper.selectByOrderCodeList(appraiseOrderList);
return appraiseOrders.stream().collect(Collectors.toMap(AppraiseOrder::getOrderCode,
item -> AppraiseOrderStatus.getStatusStrByCode(item.getStatus())));
item -> {
AppraiseOrderStatus aos = AppraiseOrderStatus.getByCode(item.getStatus());
return aos.statusStr(OrderAttributes.DEPOSITE);
}));
}
... ...
... ... @@ -1039,7 +1039,7 @@ public class InBoxFacade extends BaseNoticeFacade{
public void sellerDepositOrderNotice(int uid,long orderCode, AppraiseOrderStatus targetStatus){
public void sellerDepositOrderNotice(int uid,long orderCode, AppraiseOrderStatus targetStatus, boolean isParent){
log.info("enter sellerDepositOrderNotice uid {} orderCode {} targetStatus {}", uid, orderCode, targetStatus);
try {
//
... ... @@ -1089,9 +1089,16 @@ public class InBoxFacade extends BaseNoticeFacade{
smsParams = new Object[]{orderCode};
break;
case SHAM_SEND_OUT:
inboxType = InboxBusinessTypeEnum.NOTICE_SELLER_DEPOSIT_ORDER_MISS_GOODS;
// get product info 「商品名称」「尺码」「货号」
inboxParams = buildParams4SellerDepositOrder(orderCode);
if(isParent){
inboxType = InboxBusinessTypeEnum.NOTICE_SELLER_DEPOSIT_ORDER_SHAM_DELIVER;
inboxParams = new Object[]{orderCode};
smsType = InboxBusinessTypeEnum.SMS_NOTICE_SELLER_DEPOSIT_ORDER_SHAM_DELIVER;
smsParams = inboxParams;
}else {
inboxType = InboxBusinessTypeEnum.NOTICE_SELLER_DEPOSIT_ORDER_MISS_GOODS;
// get product info 「商品名称」「尺码」「货号」
inboxParams = buildParams4SellerDepositOrder(orderCode);
}
break;
case QUALITY_CHECK_FAKE:
inboxType = InboxBusinessTypeEnum.NOTICE_SELLER_DEPOSIT_ORDER_FIND_FLAW_OR_BIGGER;
... ...
... ... @@ -225,16 +225,21 @@ public class SellerDepositOrderListService extends AbsOrderViewService {
}
int offset = (req.getPage() - 1) * limit;
List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectAllByOrderCode(orderCode, offset, limit);
List<ProductVo> productVoList = buildProductVoListWithSkuSummary(paogs);
Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = new HashMap<>(paogs.size());
for(AppraiseOrderGoods paog : paogs) {
Integer prdId;
List<AppraiseOrderStorage> paosList = appraiseOrderStorageMapper.selectAllByOrderCodePrdId(orderCode, prdId = paog.getProductId());
prdIdAOSListMap.put(prdId, paosList);
}
List<ProductVo> productVoList = buildProductVoListWithSkuSummary(paogs, prdIdAOSListMap);
respBuilder.data(productVoList);
return respBuilder.build();
}
List<ProductVo> buildProductVoListWithSkuSummary(List<AppraiseOrderGoods> paogs){
return paogs.parallelStream().map(paog-> ProductConvertor.convertProductVo(paog, null))
List<ProductVo> buildProductVoListWithSkuSummary(List<AppraiseOrderGoods> paogs,Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap){
Function<List<AppraiseOrderStorage>,ProductVo> function = (aosList)-> ProductVo.builder().sizeNum(aosList.size()).build();
return paogs.parallelStream().map(paog-> ProductConvertor.convertProductVo(paog, function.apply(prdIdAOSListMap.get(paog.getProductId()))))
.collect(Collectors.toCollection(()->new ArrayList<>(paogs.size())));
}
... ... @@ -354,4 +359,7 @@ public class SellerDepositOrderListService extends AbsOrderViewService {
.storageIdSOCRMap(storageIdSOCRMap)
.build();
}
}
... ...
... ... @@ -164,8 +164,12 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
.orderAttributes(getOrderAttributes())
.build();
appraiseOrderCreateService.createSellerDepoistOrder(context);
//TODO notice
//
SellerDepositOrderCancelAsyncEvent event = new SellerDepositOrderCancelAsyncEvent(this::handleOrderCancelAsyncEvent);
event.setUid(req.getUid());
event.setOrderCode(orderCode);
EventBusPublisher.publishEvent(event);
logger.info("submit seller deposit order , SellerDepositOrderCancelAsyncEvent send out, event {}", event);
return SellerDepositOrderSubmitResp.builder().orderCode(orderCode).build();
}
... ... @@ -208,12 +212,12 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
case WAITING_PAY:
targetOrderStatus = AppraiseOrderStatus.CANCEL_BEFORE_PAY;
super.triggerStatusChange(orderCode, targetOrderStatus, appraiseOrderStatus);
inBoxFacade.sellerDepositOrderNotice(pao.getUid(), orderCode, targetOrderStatus);
inBoxFacade.sellerDepositOrderNotice(pao.getUid(), orderCode, targetOrderStatus, true);
break;
case HAS_PAYED:
targetOrderStatus = AppraiseOrderStatus.CANCEL_BEFORE_DELIVER;
super.triggerStatusChange(orderCode, targetOrderStatus , appraiseOrderStatus);
inBoxFacade.sellerDepositOrderNotice(pao.getUid(), orderCode, targetOrderStatus);
inBoxFacade.sellerDepositOrderNotice(pao.getUid(), orderCode, targetOrderStatus, true);
//refund amount
new GoodsServiceRefundHandler()
.loadLogger(logger)
... ... @@ -231,6 +235,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
}
public int cancelByTimeout(OrderCancelEvent orderCancelEvent){
logger.info("in seller deposit order cancelByTimeout orderCancelEvent {}", orderCancelEvent);
Long orderCode = orderCancelEvent.getOrderCode();
int uid = orderCancelEvent.getUid();
if(!serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
... ... @@ -287,7 +292,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
Long orderCode = req.getOrderCode();
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.SELLER_SEND_OUT;
//
inBoxFacade.sellerDepositOrderNotice(req.getUid(), orderCode, targetOrderStatus);
inBoxFacade.sellerDepositOrderNotice(req.getUid(), orderCode, targetOrderStatus, true);
//split sku 2 order
List<AppraiseOrderGoods> paogList = appraiseOrderGoodsMapper.selectByOrderCode(orderCode);
SellerDepositOrderListService.OrderDataNode node = sellerDepositOrderListService.buildDataSourceOfParentOrder(orderCode, paogList);
... ... @@ -339,7 +344,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
triggerStatusConsistencyCheck(orderCode);
Long paidCode = pao.getParentOrderCode();
inBoxFacade.sellerDepositOrderNotice(pao.getUid(), orderCode, targetStatus);
inBoxFacade.sellerDepositOrderNotice(pao.getUid(), orderCode, targetStatus, false);
BigDecimal left = calLeftMoney(pao.getAmount(), orderCode);
if (left.compareTo(BigDecimal.ZERO)>0){
... ... @@ -405,7 +410,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
triggerStatusConsistencyCheck(orderCode);
//
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.CHECKING_FAKE;
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), targetOrderStatus);
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), orderCode, targetOrderStatus, false);
depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
return rows;
}
... ... @@ -433,7 +438,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
.refund();
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE;
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), targetOrderStatus);
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), targetOrderStatus, false);
depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
return rows;
}
... ... @@ -451,10 +456,18 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
}
//
Long orderCode = appraiseOrder.getOrderCode();
triggerStatusConsistencyCheck(orderCode);
//
Long parentOrderCode;
boolean isParent = Objects.isNull(parentOrderCode=appraiseOrder.getParentOrderCode());
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.SHAM_SEND_OUT;
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), targetOrderStatus);
AppraiseOrderStatus expectedStatus = AppraiseOrderStatus.SELLER_SEND_OUT;
if(isParent){
triggerStatusChangeByParentCode(parentOrderCode, targetOrderStatus, expectedStatus);
}else {
//no parent
triggerStatusConsistencyCheck(orderCode);
}
//notice
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), orderCode, targetOrderStatus, isParent);
//refund amount
new GoodsServiceRefundHandler()
.loadLogger(logger)
... ... @@ -576,7 +589,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
Long orderCode = appraiseOrder.getOrderCode();
triggerStatusConsistencyCheck(orderCode);
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.QUALITY_CHECK_FAKE;
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), orderCode, targetOrderStatus);
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), orderCode, targetOrderStatus, false);
new GoodsServiceRefundHandler()
.loadLogger(logger)
.loadUser(appraiseOrder.getUid())
... ... @@ -606,12 +619,9 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
Long orderCode = orderInfo.getOrderCode();
Integer uid = orderInfo.getUid();
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.HAS_PAYED;
inBoxFacade.sellerDepositOrderNotice(orderInfo.getUid(), orderInfo.getOrderCode(), targetOrderStatus);
SellerDepositOrderCancelAsyncEvent event = new SellerDepositOrderCancelAsyncEvent(this::handleOrderCancelAsyncEvent);
event.setUid(uid);
event.setOrderCode(orderCode);
EventBusPublisher.publishEvent(event);
logger.info("processAfterPay seller deposit order , SellerDepositOrderCancelAsyncEvent send out, event {}", event);
inBoxFacade.sellerDepositOrderNotice(uid, orderInfo.getOrderCode(), targetOrderStatus, true);
SellerCancelDeliverEvent cancelDeliverEvent =
SellerCancelDeliverEvent.builder()
.uid(orderInfo.getUid())
... ... @@ -722,7 +732,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
if(rows>0){
AppraiseOrderStatus targetOrderStatus = AppraiseOrderStatus.PLATFORM_RECEIVE;
inBoxFacade.sellerDepositOrderNotice(uid, parentCode, targetOrderStatus);
inBoxFacade.sellerDepositOrderNotice(uid, parentCode, targetOrderStatus, true);
}
return rows;
... ... @@ -750,7 +760,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
orderCode, parentOrderCode, prows);
if (prows>0){
AppraiseOrderStatus targetStatus = AppraiseOrderStatus.FINISH;
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), parentOrderCode, targetStatus);
inBoxFacade.sellerDepositOrderNotice(appraiseOrder.getUid(), parentOrderCode, targetStatus, true);
}
return prows;
}
... ... @@ -800,7 +810,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
.loadOrder(orderCode, orderCode, pao.getPayment(), pao.getAmount())
.refund();
//notice
inBoxFacade.sellerDepositOrderNotice(uid, orderCode, targetOrderStatus);
inBoxFacade.sellerDepositOrderNotice(uid, orderCode, targetOrderStatus, true);
}
... ...