...
|
...
|
@@ -15,6 +15,7 @@ import com.yohoufo.common.alarm.EventBusPublisher; |
|
|
import com.yohoufo.common.alarm.SmsAlarmEvent;
|
|
|
import com.yohoufo.common.exception.GatewayException;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.BigDecimalHelper;
|
|
|
import com.yohoufo.common.utils.PageHelper;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
|
...
|
...
|
@@ -26,11 +27,11 @@ import com.yohoufo.order.convert.SellerOrderConvertor; |
|
|
import com.yohoufo.order.event.*;
|
|
|
import com.yohoufo.order.model.SellerOrderContext;
|
|
|
import com.yohoufo.order.model.SellerOrderRelatedBuyerOrderContext;
|
|
|
import com.yohoufo.order.model.bo.CouponBo;
|
|
|
import com.yohoufo.order.model.bo.CouponBoList;
|
|
|
import com.yohoufo.order.model.dto.*;
|
|
|
import com.yohoufo.order.model.request.OrderListRequest;
|
|
|
import com.yohoufo.order.model.request.OrderRequest;
|
|
|
import com.yohobuy.ufo.model.order.resp.OrderDetailInfo;
|
|
|
import com.yohoufo.order.model.response.OrderSubmitResp;
|
|
|
import com.yohoufo.order.mq.DelayTime;
|
|
|
import com.yohoufo.order.service.IOrderDetailService;
|
...
|
...
|
@@ -46,16 +47,13 @@ import com.yohoufo.order.service.handler.SellerOrderSubmitHandler; |
|
|
import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase;
|
|
|
import com.yohoufo.order.service.impl.visitor.UserCancelCase;
|
|
|
import com.yohoufo.order.service.proxy.*;
|
|
|
import com.yohoufo.order.service.seller.SellerAuthCheckService;
|
|
|
import com.yohoufo.order.service.seller.SellerOrderCancelService;
|
|
|
import com.yohoufo.order.service.seller.support.SellerOrderContextFactory;
|
|
|
import com.yohoufo.order.service.seller.trade.SellerOrderComputeService;
|
|
|
import com.yohoufo.order.service.seller.SellerOrderServiceDelegate;
|
|
|
import com.yohoufo.order.service.seller.SkupBatchService;
|
|
|
import com.yohoufo.order.service.seller.orderMeta.SellerFeeService;
|
|
|
import com.yohoufo.order.service.seller.processor.*;
|
|
|
import com.yohoufo.order.service.seller.setting.SellerService;
|
|
|
import com.yohoufo.order.service.seller.setting.SellerWrapper;
|
|
|
import com.yohoufo.order.service.seller.trade.SellerOrderSubmitService;
|
|
|
import com.yohoufo.order.service.seller.support.SellerOrderContextFactory;
|
|
|
import com.yohoufo.order.service.support.CouponSupport;
|
|
|
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
|
|
|
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
|
...
|
...
|
@@ -137,33 +135,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
private SellerDownShelfPrepareProcessor sellerDownShelfPrepareProcessor;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerFeeService sellerFeeService;
|
|
|
|
|
|
@Autowired
|
|
|
private UserProxyService userProxyService;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerTaskProcessor sellerTaskProcessor;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerIncrPriceTaskHandler sellerIncrPriceTaskHandler;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerDecrPriceTaskHandler sellerDecrPriceTaskHandler;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerDownShelfTaskHandler sellerDownShelfTaskHandler;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerOrderComputeService sellerOrderComputeService;
|
|
|
private SellerOrderServiceDelegate sellerOrderServiceDelegate;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerNoticeFacade sellerNoticeFacade;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerAuthCheckService sellerAuthCheckService;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerBatchCancelPrepareProcessor sellerBatchCancelPrepareProcessor;
|
|
|
|
|
|
@Autowired
|
...
|
...
|
@@ -176,13 +156,10 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
private MetaConfigService metaConfigService;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerService sellerService;
|
|
|
|
|
|
@Autowired
|
|
|
private BuyerOrderAssistant buyerOrderAssistant;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerOrderSubmitService sellerOrderSubmitService;
|
|
|
private CouponProxyService couponProxyService;
|
|
|
|
|
|
private static final int MAX_DEAL = 10;
|
|
|
|
...
|
...
|
@@ -302,7 +279,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
public OrderSubmitResp publishPrd(SellerOrderSubmitReq req) {
|
|
|
protectPublish(req);
|
|
|
int uid = req.getUid();
|
|
|
SellerWrapper sellerWrapper = sellerService.getFullDimensionSeller(uid);
|
|
|
SellerWrapper sellerWrapper = sellerOrderServiceDelegate.getSellerService().getFullDimensionSeller(uid);
|
|
|
SellerBo sellerBo = sellerWrapper.buildSellerBo();
|
|
|
if (sellerBo.isLargeSettlementSuper()){
|
|
|
log.warn("publishPrd user is overseas ,uid {}", uid);
|
...
|
...
|
@@ -341,7 +318,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
//扣减保证金
|
|
|
final int num = req.getNum();
|
|
|
int uid = req.getUid();
|
|
|
SellerBo sellerBo = sellerAuthCheckService.checkAuth(uid, ctx.getSkupType(), SellerFuncEnum.BATCH_PUBLISH);
|
|
|
SellerBo sellerBo = sellerOrderServiceDelegate.getSellerAuthCheckService().checkAuth(uid, ctx.getSkupType(), SellerFuncEnum.BATCH_PUBLISH);
|
|
|
Boolean isSuper = sellerBo.isSuper();
|
|
|
SellerOrderComputeResult socr = ctx.getSellerOrderComputeResult();
|
|
|
BigDecimal singleEarestMoney = socr.getEarnestMoney().getEarnestMoney();
|
...
|
...
|
@@ -429,7 +406,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
}
|
|
|
SellerWalletDetail.Type swdType = SellerWalletDetail.Type.SELLER_OFF;
|
|
|
int uid = req.getUid();
|
|
|
SellerBo sellerBo = sellerAuthCheckService.checkAuth(uid, null, SellerFuncEnum.BATCH_OFFSHELVE);
|
|
|
SellerBo sellerBo = sellerOrderServiceDelegate.getSellerAuthCheckService().checkAuth(uid, null, SellerFuncEnum.BATCH_OFFSHELVE);
|
|
|
Boolean isSuper = sellerBo.isSuper();
|
|
|
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
|
|
|
.earnestMoney(totalRefundEM).productCount(needCancelSkups.size())
|
...
|
...
|
@@ -600,11 +577,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
* @return
|
|
|
*/
|
|
|
@Deprecated
|
|
|
public BatchChangePriceResp batchChangePrice(BatchChangePriceReq req) throws GatewayException {
|
|
|
public BatchChangePriceResp batchChangePrice(BatchChangePriceReq req) {
|
|
|
ChangePricePrepareDTO cppDto = changePricePrepareProcessor.checkAndAcquire(req);
|
|
|
BigDecimal preSalePrice = cppDto.getPreSalePrice(),
|
|
|
salePrice = cppDto.getSalePrice();
|
|
|
SellerBo sellerBo = sellerAuthCheckService.checkAuth(req.getUid(), null, SellerFuncEnum.BATCH_CHANGEPRICE);
|
|
|
SellerBo sellerBo = sellerOrderServiceDelegate.getSellerAuthCheckService()
|
|
|
.checkAuth(req.getUid(), null, SellerFuncEnum.BATCH_CHANGEPRICE);
|
|
|
boolean isSuper = sellerBo.isSuper();
|
|
|
int uid = req.getUid();
|
|
|
Map<Integer, SkupDto> skupMap = cppDto.getSkupMap();
|
...
|
...
|
@@ -642,7 +620,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
sogc.setGoodsPrice(salePrice);
|
|
|
sellerOrderGoodsMapper.updateByPrimaryKeys(sogc, skupSet);
|
|
|
|
|
|
sellerFeeService.updateBatch(skupSet,computeResult );
|
|
|
sellerOrderServiceDelegate.getSellerFeeService().updateBatch(skupSet,computeResult );
|
|
|
|
|
|
//4 划账记录
|
|
|
List<SellerOrder> psoList = sellerOrderMapper.selectBySkups(skupSet);
|
...
|
...
|
@@ -708,25 +686,26 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
//校验及计算金额
|
|
|
ChangePricePrepareDTO cppDto = adjustPricePrepareProcessor.checkAndAcquire(req);
|
|
|
final SkupType skupType = cppDto.getSkupType();
|
|
|
SellerBo sellerBo = sellerAuthCheckService.checkAuth(req.getUid(), skupType, SellerFuncEnum.BATCH_CHANGEPRICE);
|
|
|
SellerBo sellerBo = sellerOrderServiceDelegate.getSellerAuthCheckService()
|
|
|
.checkAuth(req.getUid(), skupType, SellerFuncEnum.BATCH_CHANGEPRICE);
|
|
|
SellerTaskDTO<ChangePricePrepareDTO> taskDTO = null;
|
|
|
if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) > 0) {
|
|
|
//涨价
|
|
|
taskDTO = new SellerTaskDTO(req.getUid(),
|
|
|
SellerWalletDetail.Type.ADD_PRICE.getValue(),
|
|
|
sellerIncrPriceTaskHandler,
|
|
|
sellerOrderServiceDelegate.getSellerIncrPriceTaskHandler(),
|
|
|
JSON.toJSONString(req),cppDto);
|
|
|
} else if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) < 0) {
|
|
|
//降价
|
|
|
taskDTO = new SellerTaskDTO(req.getUid(),
|
|
|
SellerWalletDetail.Type.SUBTRACT_PRICE.getValue(),
|
|
|
sellerDecrPriceTaskHandler,
|
|
|
sellerOrderServiceDelegate.getSellerDecrPriceTaskHandler(),
|
|
|
JSON.toJSONString(req),cppDto);
|
|
|
} else {
|
|
|
throw new UfoServiceException(400, "价格没有变化");
|
|
|
}
|
|
|
|
|
|
SellerTaskResult result = sellerTaskProcessor.process(taskDTO);
|
|
|
SellerTaskResult result = sellerOrderServiceDelegate.getSellerTaskProcessor().process(taskDTO);
|
|
|
|
|
|
//返还结果
|
|
|
BatchChangePriceResp resp = BatchChangePriceResp.builder().successCnt(result.successCnt).failCnt(result.failCnt)
|
...
|
...
|
@@ -743,11 +722,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
SkupDownShelfPrepareDto skupDtoMap = sellerDownShelfPrepareProcessor.checkAndAcquire(req);
|
|
|
SellerTaskDTO<SkupDownShelfPrepareDto> taskDTO = new SellerTaskDTO(req.getUid(),
|
|
|
SellerWalletDetail.Type.SELLER_OFF.getValue(),
|
|
|
sellerDownShelfTaskHandler,
|
|
|
sellerOrderServiceDelegate.getSellerDownShelfTaskHandler(),
|
|
|
JSON.toJSONString(req),
|
|
|
skupDtoMap);
|
|
|
|
|
|
SellerTaskResult result = sellerTaskProcessor.process(taskDTO);
|
|
|
SellerTaskResult result = sellerOrderServiceDelegate.getSellerTaskProcessor().process(taskDTO);
|
|
|
return result.successCnt > 0 ? true : false;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -971,7 +950,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
|
|
|
SellerOrderGoods psog = preparedData.getSellerOrderGoods();
|
|
|
|
|
|
SellerOrderComputeResult computeResult = sellerFeeService.getSellerOrderComputeResult(psog.getUid(), psog.getId());
|
|
|
SellerOrderComputeResult computeResult = sellerOrderServiceDelegate.getSellerFeeService()
|
|
|
.getSellerOrderComputeResult(psog.getUid(), psog.getId());
|
|
|
|
|
|
//todo next version maybe set autoRecommended
|
|
|
boolean autoRecommended = "Y".equalsIgnoreCase(req.getAutoRecommended());
|
...
|
...
|
@@ -988,7 +968,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
sorboc.setChargeParam(chargeParam);
|
|
|
sorboc.setSellerOrderComputeResult(computeResult);
|
|
|
|
|
|
sellerOrderComputeService.compute(sorboc);
|
|
|
sellerOrderServiceDelegate.getSellerOrderComputeService().compute(sorboc);
|
|
|
|
|
|
return SellerOrderConvertor.convertWithCoupon(sorboc);
|
|
|
}
|
...
|
...
|
@@ -1002,7 +982,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
SellerOrderChargeParam chargeParam = SellerOrderChargeParam.builder()
|
|
|
.chargeStage(SellerOrderChargeParam.SUBMIT).build();
|
|
|
|
|
|
Supplier<SellerOrderComputeResult> computeResultSupplier = ()->sellerFeeService.getSellerOrderComputeResult(psog.getUid(), psog.getId());
|
|
|
Supplier<SellerOrderComputeResult> computeResultSupplier = ()->sellerOrderServiceDelegate.getSellerFeeService()
|
|
|
.getSellerOrderComputeResult(psog.getUid(), psog.getId());
|
|
|
SellerOrderRelatedBuyerOrderContext sorboc = SellerOrderContextFactory.builder()
|
|
|
.uid(psog.getUid())
|
|
|
.couponCode(couponCode).businessClient(businessClient)
|
...
|
...
|
@@ -1011,9 +992,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
.sellerOrderGoods(psog)
|
|
|
.build().buildSellerOrderRelatedBuyerOrderContext();
|
|
|
|
|
|
|
|
|
|
|
|
sellerOrderComputeService.compute(sorboc);
|
|
|
sellerOrderServiceDelegate.getSellerOrderComputeService().compute(sorboc);
|
|
|
//TODO how to keep atomic,rollback when fail
|
|
|
|
|
|
|
...
|
...
|
@@ -1030,13 +1009,73 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic |
|
|
.couponBoList(couponBoList)
|
|
|
.computeResult(computeResult)
|
|
|
.build();
|
|
|
sellerOrderSubmitService.submitByOld(submitDTO);
|
|
|
sellerOrderServiceDelegate.getSellerOrderSubmitService().submitByOld(submitDTO);
|
|
|
}
|
|
|
|
|
|
public void asyncCancelWithCouponIfPresent(Long buyerOrderCode,Integer orderStatus, SellerOrderGoods sellerOrderGoods){
|
|
|
log.info("asyncCancelWithCouponIfPresent buyerOrderCode {} OrderStatus {}", buyerOrderCode, orderStatus);
|
|
|
if (!ActionStatusHold.canRefundSellerCoupon(orderStatus)){
|
|
|
log.info("asyncCancelWithCouponIfPresent orderStatus not illegal buyerOrderCode {} OrderStatus {}", buyerOrderCode, orderStatus);
|
|
|
return;
|
|
|
}
|
|
|
CancelSellerCouponAsyncEvent asyncEvent = new CancelSellerCouponAsyncEvent(this::cancelWithCouponIfPresent);
|
|
|
asyncEvent.setBuyerOrderCode(buyerOrderCode);
|
|
|
asyncEvent.setSellerOrderGoods(sellerOrderGoods);
|
|
|
EventBusPublisher.publishEvent(asyncEvent);
|
|
|
log.info("asyncCancelWithCouponIfPresent producer finish, buyerOrderCode {}", buyerOrderCode);
|
|
|
}
|
|
|
|
|
|
public boolean cancelWithCouponIfPresent(CancelSellerCouponAsyncEvent asyncEvent){
|
|
|
log.info("async cancelWithCouponIfPresent consumer accept, buyerOrderCode {}", asyncEvent.getBuyerOrderCode());
|
|
|
cancelWithCouponIfPresent(asyncEvent.getBuyerOrderCode(), asyncEvent.getSellerOrderGoods());
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
public void cancelWithCoupon(){
|
|
|
/**
|
|
|
*
|
|
|
* @param buyerOrderCode
|
|
|
* @param sellerOrderGoods
|
|
|
*/
|
|
|
public void cancelWithCouponIfPresent(Long buyerOrderCode,SellerOrderGoods sellerOrderGoods){
|
|
|
|
|
|
log.info("cancel seller CouponIfPresent, buyerOrderCode {}",buyerOrderCode);
|
|
|
try {
|
|
|
Integer skup = sellerOrderGoods.getId();
|
|
|
|
|
|
//
|
|
|
List<CouponBo> couponBos = sellerOrderServiceDelegate.getSellerOrderMetaService()
|
|
|
.getUsedCoupons(skup, sellerOrderGoods.getUid());
|
|
|
if (CollectionUtils.isEmpty(couponBos)) {
|
|
|
log.warn("cancel seller Coupon not Present, buyerOrderCode {}", buyerOrderCode);
|
|
|
return;
|
|
|
}
|
|
|
List<String> couponCodes = couponBos.stream().map(CouponBo::getCouponCode).collect(Collectors.toList());
|
|
|
SellerOrder pso = sellerOrderMapper.selectBySkup(skup);
|
|
|
couponProxyService.orderCancelCoupon(pso.getUid(), pso.getOrderCode(), couponCodes);
|
|
|
//
|
|
|
CouponBoList couponBoList = CouponBoList.builder().couponBos(couponBos).build();
|
|
|
//
|
|
|
SellerOrderComputeResult computeResult = sellerOrderServiceDelegate.getSellerFeeService()
|
|
|
.getSellerOrderComputeResult(pso.getUid(), skup);
|
|
|
computeResult.setAmountIsReset(true);
|
|
|
//
|
|
|
BigDecimal couponCutAmount = pso.getCouponCutAmount();
|
|
|
BigDecimal oldIncome = pso.getIncome();
|
|
|
BigDecimal newIncome = BigDecimalHelper.sub(oldIncome, couponCutAmount);
|
|
|
BigDecimal newCouponCutAmount = BigDecimal.ZERO;
|
|
|
log.info("cancel seller Coupon, income [{}->{}],couponCutAmount [{}->{}]", oldIncome, newIncome, couponCutAmount, newCouponCutAmount);
|
|
|
computeResult.setIncome(newIncome);
|
|
|
computeResult.setCouponCutAmount(newCouponCutAmount);
|
|
|
|
|
|
SellerOrderSubmitDTO submitDTO = SellerOrderSubmitDTO.builder()
|
|
|
.sellerOrder(pso)
|
|
|
.couponBoList(couponBoList)
|
|
|
.computeResult(computeResult)
|
|
|
.build();
|
|
|
sellerOrderServiceDelegate.getSellerOrderUpdateService().updateCouponAmount(submitDTO);
|
|
|
}catch (Exception ex){
|
|
|
log.warn("cancel seller CouponIfPresent occur some error, buyerOrderCode {}",buyerOrderCode, ex);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
|