Authored by LUOXC

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,
... ...
... ... @@ -16,5 +16,5 @@ public interface OrdersPayRefundMapper {
//查看部分退款记录是否存在 -- (新)
OrdersPayRefund selectByRefundCode(@Param("refundCode") String refundCode);
List<OrdersPayRefund> selectByRefundCodes(@Param("refundCodes") Collection<String> refundCode);
List<OrdersPayRefund> selectByRefundCodes(@Param("refundOrderCodes") Collection<String> refundCode);
}
\ No newline at end of file
... ...
... ... @@ -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" />
... ...
... ... @@ -42,8 +42,8 @@
select
<include refid="Base_Column_List" />
from orders_pay_refund
where refund_order_code in
<foreach collection="refundOrderCodes" open="(" close=")" separator="," item="refundOrderCode">
where refund_code in
<foreach collection="refundOrderCodes" open="(" close=")" separator="," item="refundCode">
#{refundCode,jdbcType=VARCHAR}
</foreach>
</select>
... ...
package com.yohoufo.order.service;
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.OrderInfo;
... ... @@ -137,18 +138,30 @@ public class AppraiseOrderPaymentService extends AbstractOrderPaymentService {
}
return false;
}
private static final List<Integer> canRefundStatusListOfPaidAppraiseOrder = Lists.newArrayList(
AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode()
);
final static List<Integer> canRefundStatusList = Arrays.asList(AppraiseOrderStatus.WAITING_PAY.getCode(),
AppraiseOrderStatus.HAS_PAYED.getCode());
private static final List<Integer> canRefundStatusListOfDepositOrder = Lists.newArrayList(
AppraiseOrderStatus.HAS_PAYED.getCode(),
AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode(),
AppraiseOrderStatus.JUDGE_PASS_WAIT_WAREHOUSE.getCode(),
AppraiseOrderStatus.SHAM_SEND_OUT.getCode(),
AppraiseOrderStatus.SEND_OUT_TIMEOUT.getCode()
);
@Override
public boolean canRefund(OrderInfo orderInfo) {
OrderAttributes oa = OrderAttributes.getOrderAttributes(orderInfo.getAttributes());
switch (oa){
case APPRAISE:
if (canRefundStatusListOfPaidAppraiseOrder.contains(orderInfo.getStatus())){
return true;
}
throw new UfoServiceException(400, "鉴定订单暂不支持退款");
case DEPOSITE:
if (orderInfo.getStatus() != null && canRefundStatusList.contains(orderInfo.getStatus().intValue())){
if (orderInfo.getStatus() != null && canRefundStatusListOfDepositOrder.contains(orderInfo.getStatus().intValue())){
return true;
}
break;
... ...
... ... @@ -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);
... ... @@ -111,7 +122,7 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE;
int rows = triggerStatusChange(orderCode, targetStatus, expectedStatus);
logger.info("appraise order appraiseFake update status, orderCode {} rows {}", orderCode, rows);
logger.info("appraise order unsure update status, orderCode {} rows {}", orderCode, rows);
return rows;
}
... ... @@ -122,7 +133,7 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
expectedStatus = AppraiseOrderStatus.SELLER_SEND_OUT;
int rows = triggerStatusChange(orderCode, targetStatus, expectedStatus);
logger.info("appraise order appraiseFake update status, orderCode {} rows {}", orderCode, rows);
logger.info("appraise order shamDeliver update status, orderCode {} rows {}", orderCode, rows);
return rows;
}
... ... @@ -133,7 +144,7 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE;
int rows = triggerStatusChange(orderCode, targetStatus, expectedStatus);
logger.info("appraise order appraiseFake update status, orderCode {} rows {}", orderCode, rows);
logger.info("appraise order findFlaw update status, orderCode {} rows {}", orderCode, rows);
return rows;
}
}
... ...
... ... @@ -19,10 +19,7 @@ import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
import com.yohoufo.dal.order.AppraiseOrderMapper;
import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
import com.yohoufo.dal.order.model.AppraiseOrder;
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
import com.yohoufo.dal.order.model.AppraiseOrderMeta;
import com.yohoufo.dal.order.model.QiniuLiveRecord;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.ClientType;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.convert.AppraiseOrderGoodsConvertor;
... ... @@ -30,6 +27,7 @@ import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.dto.AppraiseOrderContext;
import com.yohoufo.order.service.IExpressInfoService;
import com.yohoufo.order.service.IGoodsService;
import com.yohoufo.order.service.handler.GoodsServiceRefundHandler;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.UserProxyService;
... ... @@ -86,6 +84,9 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
@Autowired
private InBoxFacade inBoxFacade;
@Autowired
private PayRefundService payRefundService;
public AppraiseOrderComputeResp compute(AppraiseOrderComputeReq req){
logger.info("in AppraiseOrderService.compute req {}", req);
... ... @@ -410,6 +411,7 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
return rows;
}
/**
* 无法鉴别
* @param appraiseOrder
... ... @@ -418,8 +420,20 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
public int unsure(AppraiseOrder appraiseOrder){
int rows;
if ((rows=super.unsure(appraiseOrder))>0){
Integer uid = appraiseOrder.getUid();
Long orderCode = appraiseOrder.getOrderCode();
new GoodsServiceRefundHandler()
.loadLogger(logger)
.loadUser(uid)
.loadActionCase(SellerWalletDetail.Type.APPRAISE_UNSURE)
.loadRefundAction(payRefundService::refund)
.loadOrder(orderCode, orderCode, appraiseOrder.getPayment(), appraiseOrder.getAmount())
.refund();
AppraiseOrderStatus targetStatus = AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE;
inBoxFacade.paidAppraiseOrderNotice(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), targetStatus);
inBoxFacade.paidAppraiseOrderNotice(uid, orderCode, targetStatus);
}
return rows;
}
... ...
... ... @@ -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);
}));
}
... ...
... ... @@ -146,6 +146,10 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
private final String last_seller_un_accept = "。";
private final String last_seller_confirm = ",等待买家确认。";
private final static String DEFAULT_EXPRESS_TITLE = "订单跟踪";
private final static String APPRAISE_EXPRESS_TITLE = "物流详情";
@Autowired
private SkupService skupService;
... ... @@ -494,7 +498,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
}
//1.物流单号信息
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo, DEFAULT_EXPRESS_TITLE);
// 构造物流信息
if (expressTypeList.size() == 1) {
... ... @@ -600,7 +604,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
}
// 物流单号信息
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo, APPRAISE_EXPRESS_TITLE);
// 根据订单号and物流类型 返回物流信息
List<ExpressInfoDetail> expressInfoDetailList = getExpressInfoDetailListByOrderCodeExpressType(orderCode, expressTypeList);
... ... @@ -629,7 +633,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
}
// 物流单号信息
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo, DEFAULT_EXPRESS_TITLE);
// 根据订单号and物流类型 返回物流信息
List<ExpressInfoDetail> expressInfoDetailList = getExpressInfoDetailListByOrderCodeExpressType(orderCode, expressTypeList);
... ... @@ -650,7 +654,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
}
// 物流单号信息
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo, DEFAULT_EXPRESS_TITLE);
// 其中是否包含了 鉴定中心内部调拨信息
if (expressTypeList.contains(EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode())){
... ... @@ -694,7 +698,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
//如果还没有新的物流信息,卖家显示上一个阶段的物流
if (StringUtils.isBlank(expressInfoRespBo.getExpressSender())) {
//物流单号信息
constructWayBillInfo(orderCode, Arrays.asList(EnumExpressType.EXPRESS_TYPE_1.getCode()), expressInfoRespBo);
constructWayBillInfo(orderCode, Arrays.asList(EnumExpressType.EXPRESS_TYPE_1.getCode()), expressInfoRespBo, DEFAULT_EXPRESS_TITLE);
}
List<ExpressInfo> previousExpressInfoList = getExpressInfoListByStage(actor, orderCode, EnumExpressType.EXPRESS_TYPE_1.getCode());
constructExpressInfo(actor, previousExpressInfoList, expressInfoRespBo.getSupplementExpressInfoDetailList());
... ... @@ -703,7 +707,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
}
//物流单号信息
private void constructWayBillInfo(Long orderCode, List<Integer> expressTypeList, ExpressInfoRespBo expressInfoRespBo) {
private void constructWayBillInfo(Long orderCode, List<Integer> expressTypeList, ExpressInfoRespBo expressInfoRespBo, String expressTitle) {
Integer expressType = 0;
for (Integer i : expressTypeList) {
if (EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode().equals(i)) {
... ... @@ -720,7 +724,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
//物流类型
expressInfoRespBo.setExpressType(expressType.byteValue());
//物流发货方
expressInfoRespBo.setExpressSender(getSenderName(expressInfoRespBo.getExpressType().intValue()));
expressInfoRespBo.setExpressSender(expressTitle);
// 快递公司名称
expressInfoRespBo.setExpressCompanyName(expressCompanyService.getExpressName(expressRecord.getLogisticsType()));
}
... ...
... ... @@ -3,13 +3,18 @@ package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
import com.yohoufo.dal.order.SellerOrderMetaMapper;
import com.yohoufo.dal.order.TradeBillsMapper;
import com.yohoufo.dal.order.model.AppraiseOrderMeta;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderMeta;
import com.yohoufo.dal.order.model.TradeBills;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohoufo.order.common.BillTradeStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -33,6 +38,12 @@ public class TradeBillsService {
@Autowired
TradeBillsMapper tradeBillsMapper;
@Autowired
private ServiceOrderProcessor serviceOrderProcessor;
@Autowired
private AppraiseOrderMetaMapper appraiseOrderMetaMapper;
/**
* 退保证金流水记录
*
... ... @@ -42,27 +53,59 @@ public class TradeBillsService {
* @param payType
* @param tradeStatus
*/
public void backPayEnsureRecord(Integer uid, Integer skup, Long orderCode, Integer payType, Integer tradeStatus) {
backPayEnsureRecord(uid, skup, orderCode, payType, tradeStatus, null, null);
}
public void backPayEnsureRecord(Integer uid,
Integer skup,
Long orderCode,
Integer payType,
Integer tradeStatus) {
public void backPayEnsureRecord(SellerOrder sellerOrder, Integer tradeStatus, BigDecimal backEarnestMoney, SellerOrderMeta meta) {
backPayEnsureRecord(sellerOrder.getUid(), sellerOrder.getSkup(), sellerOrder.getOrderCode(), sellerOrder.getPayment(), tradeStatus, backEarnestMoney, meta);
}
private void backPayEnsureRecord(Integer uid, Integer skup, Long orderCode, Integer payType,
Integer tradeStatus,
BigDecimal backEarnestMoney, SellerOrderMeta meta) {
if (payType != null && Payment.WALLET.getCode() == payType) {
String computeResultVal = null;
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
AppraiseOrderMeta feeCondition = new AppraiseOrderMeta();
feeCondition.setOrderCode(orderCode);
feeCondition.setMetaKey(MetaKey.SELLER_FEE);
AppraiseOrderMeta feeMeta = appraiseOrderMetaMapper.selectByOrderCode(feeCondition);
computeResultVal = Objects.nonNull(feeMeta) ? feeMeta.getMetaValue() : null;
logger.info("in backPayEnsureRecord isGoodsServiceOrder orderCode {} computeResultVal {}", orderCode, computeResultVal);
}else {
SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(uid, skup, MetaKey.SELLER_FEE);
computeResultVal = Objects.nonNull(meta) ? meta.getMetaValue() : null;
logger.info("in backPayEnsureRecord buyerorder orderCode {} computeResultVal {}", orderCode, computeResultVal);
}
if (Objects.isNull(computeResultVal)) {
logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, uid = {}, skup={}", uid, skup);
return;
}
if (Objects.isNull(meta)) {
meta = sellerOrderMetaMapper.selectByMetaKey(uid, skup, "fee");
try{
SellerOrderComputeResult socr = JSONObject.parseObject(computeResultVal, SellerOrderComputeResult.class);
BigDecimal earnestMoney = socr.getEarnestMoney().getEarnestMoney();
BigDecimal systemAmount = calSystemAmountByComputeResult(socr);
backPayEnsureRecord0(uid, orderCode, payType, tradeStatus, earnestMoney, systemAmount);
}catch (Exception ex){
logger.error("backPayEnsureRecord error, uid {},orderCode {} computeResultVal {}",
uid, orderCode, computeResultVal, ex);
}
if (Objects.isNull(meta)) {
logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, uid = {}, skup={}", uid, skup);
}
private void backPayEnsureRecord0(Integer uid,
Long orderCode,
Integer payType,
Integer tradeStatus,
BigDecimal earnestMoney,
BigDecimal systemAmount
) {
if (payType != null && Payment.WALLET.getCode() == payType) {
return;
}
// 增加流水记录
TradeBills record = new TradeBills();
record.setUid(uid);
... ... @@ -72,25 +115,26 @@ public class TradeBillsService {
record.setPayType(payType);// 1:支付宝; 2:微信
record.setTradeType(1);//1:保证金;2:货款;3:补偿款
record.setIncomeOutcome(1);// 1:用户收入; 2:用户支出
BigDecimal earnestMoney = backEarnestMoney;
BigDecimal amount = BigDecimal.ZERO;
try {
JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
if (Objects.isNull(earnestMoney)) {
earnestMoney = metavalue.getJSONObject("earnestMoney").getBigDecimal("earnestMoney");
}
amount = earnestMoney.multiply(BigDecimal.ONE.subtract(rate)).multiply(new BigDecimal("-1")).setScale(2, BigDecimal.ROUND_HALF_UP);
} catch (Exception e) {
logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
}
record.setAmount(earnestMoney);
record.setSystemAmount(amount);// 有货收入
record.setSystemAmount(systemAmount);// 有货收入
record.setTradeStatus(tradeStatus);//0:订单未完结;1:订单完结
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
addTradeBills(record);
}
BigDecimal calSystemAmountByComputeResult(SellerOrderComputeResult socr){
BigDecimal amount = BigDecimal.ZERO;
try {
BigDecimal rate = socr.getServiceFeeRate().getPayChannelRate();
BigDecimal earnestMoney = socr.getEarnestMoney().getEarnestMoney();
amount = BigDecimalHelper.halfUp(earnestMoney.multiply(BigDecimal.ONE.subtract(rate)).negate());
} catch (Exception e) {
logger.warn("calSystemAmountByComputeResult fail SellerOrderComputeResult {}", socr);
}
return amount;
}
/**
* 退付货款流水记录
*
... ...
... ... @@ -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;
... ...
... ... @@ -16,6 +16,7 @@ import com.yohobuy.ufo.model.order.vo.GoodsVo;
import com.yohobuy.ufo.model.order.vo.ProductVo;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.constants.MetaKey;
... ... @@ -200,6 +201,8 @@ public class SellerDepositOrderListService extends AbsOrderViewService {
.orderCode(pao.getOrderCode())
.status(pao.getStatus())
.statuStr(appraiseOrderStatus.statusStr(oa))
.payTime(DateUtil.formatYYMMddHHmmssPoint(pao.getCreateTime()))
.payTime(DateUtil.formatYYMMddHHmmssPoint(ordersPayRefund.getCreateTime()))
.build();
return resp;
... ...
... ... @@ -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)){
... ... @@ -255,17 +260,19 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
switch (appraiseOrderStatus){
case WAITING_PAY:
Payment payment = Payment.getPayment(pao.getPayment());
AbstractPayService payService = paymentService.getPayService(payment.getCode());
PayQueryBo payQueryBo = payService.payQuery(String.valueOf(orderCode), pao.getCreateTime());
if (payQueryBo != null && payQueryBo.isPayStatus()){
logger.info("seller deposit order auto cancel failed, confirm paid. uid is {}, orderCode is {}", uid, orderCode);
PayConfirmEvent event = new PayConfirmEvent(uid, orderCode, pao.getPayment());
EventBusPublisher.publishEvent(event);
}
// 如果近1分钟有预支付记录,则发送 自动取消延迟消息
if ( !orderCancelEvent.isFinalRetry()){
paymentService.checkPrePay(uid, orderCode);
if (Objects.nonNull(payment)) {
AbstractPayService payService = paymentService.getPayService(payment.getCode());
PayQueryBo payQueryBo = payService.payQuery(String.valueOf(orderCode), pao.getCreateTime());
if (payQueryBo != null && payQueryBo.isPayStatus()) {
logger.info("seller deposit order auto cancel failed, confirm paid. uid is {}, orderCode is {}", uid, orderCode);
PayConfirmEvent event = new PayConfirmEvent(uid, orderCode, pao.getPayment());
EventBusPublisher.publishEvent(event);
}
// 如果近1分钟有预支付记录,则发送 自动取消延迟消息
if (!orderCancelEvent.isFinalRetry()) {
paymentService.checkPrePay(uid, orderCode);
}
}
rows = super.triggerStatusChange(orderCode, AppraiseOrderStatus.CANCEL_TIMEOUT, appraiseOrderStatus);
break;
... ... @@ -287,7 +294,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 +346,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 +412,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 +440,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 +458,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 +591,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 +621,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 +734,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 +762,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;
}
... ... @@ -758,6 +770,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
}
public void triggerStatusConsistencyCheck(long orderCode){
logger.info("triggerStatusConsistencyCheck orderCode {}", orderCode);
SellerDepositOrderStatusConsistencyAsyncEvent asyncEvent
= new SellerDepositOrderStatusConsistencyAsyncEvent(this::detectAppraiseFinish);
asyncEvent.setOrderCode(orderCode);
... ... @@ -800,7 +813,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);
}
... ...