Authored by mali

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

... ... @@ -247,29 +247,20 @@ public class ChargeService {
break;
case SF:
default:
deliveryWayCost = deliveryWayCostSupport.getCostOfSf();
if(chargeContext.getUserAddressPair() != null) {
String areaCode = chargeContext.getUserAddressPair().getLeft().getAreaCode();
deliveryWayCost = deliveryWayCostSupport.getCostOfSfByAreaCode(areaCode);
}else {
//默认 没有选地址的场景
deliveryWayCost = deliveryWayCostSupport.getCostOfSf();
}
finalDeliverAmount = deliveryWayCost;
break;
}
}
}
/*
if (shoppingSupport.isDeliveryWayByStore()){
deliveryWayCost = 0D;
}else/* if(chargeContext.getUserAddressPair() != null){
String areaCode = chargeContext.getUserAddressPair().getLeft().getAreaCode();
deliveryWayCost = deliveryWayCostSupport.getCostOfSfByAreaCode(areaCode);
}else{
//运费的最终保证
if (chargeContext.isShipFeeRequird()){
deliveryWayCost = deliveryWayCostSupport.getCostOfSf();
}
}*/
/*{
deliveryWayCost = deliveryWayCostSupport.getCostOfSf();
}
*/
//运费
chargeContext.getChargeResult().setDeliveryWay(chargeContext.getChargeParam().getDeliveryWay());
chargeContext.getChargeResult().setShippingAmount(deliveryWayCost);
... ...
... ... @@ -14,6 +14,7 @@ import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.impl.AppraiseService;
import com.yohoufo.order.service.impl.BuyerOrderViewService;
import com.yohoufo.order.service.seller.orderMeta.SellerFeeService;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.service.impl.SellerOrderViewService;
... ... @@ -49,6 +50,9 @@ public class BuyerOrderController {
@Autowired
private AppraiseService appraiseService;
@Autowired
private BuyerOrderViewService buyerOrderViewService;
/**
* [购买]订单列表
* 1: 全部
... ... @@ -80,7 +84,7 @@ public class BuyerOrderController {
PageResp<OrderListInfo> orderListInfoRsp;
switch (actor){
case BUY:
orderListInfoRsp = buyerOrderService.getOrderList(orderListRequest, false);
orderListInfoRsp = buyerOrderViewService.getOrderList(orderListRequest, false);
break;
case SELL:
orderListInfoRsp = sellerOrderService.getOrderList(orderListRequest, false);
... ... @@ -121,7 +125,7 @@ public class BuyerOrderController {
OrderDetailInfo orderDetailInfo;
switch (actor){
case BUY:
orderDetailInfo = buyerOrderService.getOrderDetail(orderRequest);
orderDetailInfo = buyerOrderViewService.getOrderDetail(orderRequest);
break;
case SELL:
orderDetailInfo = sellerOrderService.getOrderDetail(orderRequest);
... ... @@ -318,7 +322,7 @@ public class BuyerOrderController {
.build();
LOG.info("in ufo.getMyBuyedGoods.list, req {}", orderListRequest);
//TODO remove below codes 2 service level
PageResp<OrderListInfo> orderListInfoRsp = buyerOrderService.getOrderList(orderListRequest, false);
PageResp<OrderListInfo> orderListInfoRsp = buyerOrderViewService.getOrderList(orderListRequest, false);
List<JSONObject> goods = Lists.newArrayList();
List<Integer> goodsId = Lists.newArrayList();
if(null != orderListInfoRsp.getData() ){
... ... @@ -357,7 +361,7 @@ public class BuyerOrderController {
.uid(uid)
.orderCode(orderCode)
.build();
OrderCancelComputeResult occr = buyerOrderService.cancelCompute(orderRequest);
OrderCancelComputeResult occr = buyerOrderViewService.cancelCompute(orderRequest);
LOG.info("method ufo.buyer.cancelCompute out, orderCode is {}, uid is {}", orderCode, uid);
return new ApiResponse.ApiResponseBuilder().data(occr).code(200).message("成功").build();
}
... ...
... ... @@ -19,6 +19,7 @@ import com.yohoufo.order.model.request.SaveQualityCheckInfoRequest;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.impl.BuyerOrderCancelService;
import com.yohoufo.order.service.impl.BuyerOrderViewService;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
... ... @@ -46,6 +47,9 @@ public class ErpGWOrderController {
@Autowired
BuyerOrderCancelService buyerOrderCancelService;
@Autowired
private BuyerOrderViewService buyerOrderViewService;
@RequestMapping(params = "method=ufo.buyer.orderNums")
@IgnoreSession
public BuyerOrderNums getBuyerOrderNums(@RequestParam("uid") int uid){
... ... @@ -83,7 +87,7 @@ public class ErpGWOrderController {
case BUY:
orderListRequest.setType(OrderListType.ALL.getType()); // 默认全部
//TODO 换成独立的service 继承共同的抽象服务类, 除了必要的复用,尽量从service 到 dao 独立隔离;
orderListInfoRsp = buyerOrderService.getOrderListForErpGW(orderListRequest);
orderListInfoRsp = buyerOrderViewService.getOrderListForErpGW(orderListRequest);
break;
case SELL:
orderListRequest.setType(SellerOrderListType.ALL.getType()); // 默认全部
... ...
... ... @@ -4,6 +4,8 @@ import com.alibaba.fastjson.annotation.JSONField;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
/**
* Created by li.ma on 2018/9/27.
*/
... ... @@ -21,6 +23,9 @@ public class AppraiseAddressResp {
@JSONField(name="id")
private Integer type;
@Getter@Setter
private BigDecimal shipFee;
/**
* 是否变更
*/
... ...
... ... @@ -9,6 +9,7 @@ import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
... ... @@ -17,8 +18,6 @@ import com.yohoufo.dal.order.BuyerOrderMetaMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.service.impl.TradeBillsService;
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
import com.yohoufo.order.event.DeliverNoticeEvent;
import com.yohoufo.order.event.ErpBuyerOrderEvent;
import com.yohoufo.order.event.SellerCancelDeliverEvent;
... ... @@ -30,6 +29,8 @@ import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.impl.MetaConfigService;
import com.yohoufo.order.service.impl.OrderOverTimeService;
import com.yohoufo.order.service.impl.TradeBillsService;
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
import com.yohoufo.order.service.listener.OrderChangeListenerContainer;
import com.yohoufo.order.service.proxy.DeliveryMinutesService;
import com.yohoufo.order.service.proxy.InBoxFacade;
... ... @@ -42,7 +43,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
... ... @@ -90,6 +90,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
@Autowired
private TradeBillsService tradeBillsService;
@Autowired
private DepositService depositService;
/**
* 更新订单状态
* @param orderInfo
... ... @@ -124,8 +127,27 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
return result;
}
private void processInStockOrder(OrderInfo orderInfo,BuyerOrderGoods buyerOrderGoods,
SellerOrderGoods sellerOrderGoods){
private void processDepositOrder(BuyerOrder buyerOrder, SellerOrderGoods sellerOrderGoods){
//寄存订单 & 闪购商品
if (SkupType.QUICK_DELIVER.getCode() == sellerOrderGoods.getAttributes()){
Integer sellerUid = null;
Integer buyerUid = null;
Long orderCode = null;
Integer skup = null;
try {
depositService.changeOwner(sellerUid = buyerOrder.getSellerUid(), skup = sellerOrderGoods.getId(),
orderCode = buyerOrder.getOrderCode(), buyerUid = buyerOrder.getUid());
}catch (Exception ex){
logger.warn("pay successful, processDepositOrder invoke depositService.changeOwner fail, sellerUid {}, buyerUid {},orderCode {},skup {}",
sellerUid, buyerUid, orderCode, skup);
}
}
processInStockOrder(buyerOrder, sellerOrderGoods);
}
private void processInStockOrder(BuyerOrder orderInfo, SellerOrderGoods sellerOrderGoods){
Integer uid = orderInfo.getUid();
Integer sellerUid = orderInfo.getSellerUid();
long orderCode = orderInfo.getOrderCode();
... ... @@ -154,7 +176,7 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
/**
* 预售
*/
private void processPreSaleOrder(OrderInfo orderInfo,SellerOrderGoods sellerOrderGoods){
private void processPreSaleOrder(BuyerOrder orderInfo,SellerOrderGoods sellerOrderGoods){
// 立即消息通知
Integer uid = orderInfo.getUid();
long orderCode = orderInfo.getOrderCode();
... ... @@ -174,6 +196,11 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
orderOverTimeService.insertDeliveryTime(new OrderOverTime(orderCode, ts + secondsOfLimit, minutes));
}
private void processQuickDeliverOrder(BuyerOrder orderInfo, SellerOrderGoods sellerOrderGoods){
}
@Override
public void processAfterPay(OrderInfo orderInfo) {
Integer uid = orderInfo.getUid();
... ... @@ -206,16 +233,20 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
case COMMON_IN_STOCK:
case FLAW:
case SECOND_HAND:
processInStockOrder(orderInfo, buyerOrderGoods, sellerOrderGoods);
default:
processInStockOrder(buyerOrder, sellerOrderGoods);
break;
case ADVANCE_SALE:
processPreSaleOrder(orderInfo, sellerOrderGoods);
processPreSaleOrder(buyerOrder, sellerOrderGoods);
break;
case OFFLINE:
//门店ufo订单这里啥都不干
break;
default:
processInStockOrder(orderInfo, buyerOrderGoods, sellerOrderGoods);
case QUICK_DELIVER:
processQuickDeliverOrder(buyerOrder, sellerOrderGoods);
break;
case DEPOSITE:
processDepositOrder(buyerOrder, sellerOrderGoods);
break;
}
... ...
... ... @@ -33,7 +33,7 @@ public interface DepositService {
// 转卖
boolean changeOwner(Integer uid, Integer skup, long buyOrderCode, Integer newUid);
boolean changeOwner(Integer uid, Integer skup, long buyOrderCode, Integer newUid, boolean isDeposit);
// 可上架数量
int getDepositOffShelvesCount(Integer uid, Integer storageId);
// 可上架数量
... ...
... ... @@ -4,14 +4,12 @@ import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohobuy.ufo.model.order.resp.BuyerOrderNums;
import com.yohobuy.ufo.model.order.resp.OrderCancelComputeResult;
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.request.SaveQualityCheckInfoRequest;
import com.yohoufo.order.model.response.OrderSummaryResp;
public interface IBuyerOrderService extends IOrderListService, IOrderDetailService{
public interface IBuyerOrderService {
/**
... ... @@ -66,6 +64,5 @@ public interface IBuyerOrderService extends IOrderListService, IOrderDetailServi
OrderCntResp getOrderCnt(OrderRequest req, OrderListType listType);
OrderCancelComputeResult cancelCompute(OrderRequest orderRequest);
}
... ...
... ... @@ -81,19 +81,11 @@ public interface IExpressInfoService {
AppraiseAddressResp noticeAppraiseAddressChanged(Integer uid, Long orderCode);
/**
* 根据订单号获取快递类型
* 1:卖家到鉴定中心
* 2:鉴定中心到买家
* 3:鉴定中心退回到卖家
*
* @param orderCode
* @return
*/
//Integer getExpressType(Long orderCode);
AppraiseAddressResp queryByUserAddress(int uid,String addressId);
//ExpressInfoRespBo queryLastExpressDetailInfo(Long orderCode,int type);
ExpressInfoDetail getLastExpressInfoDetail(TabType actor,int status, Long orderCode);
... ...
... ... @@ -20,6 +20,7 @@ import java.security.SecureRandom;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
/**
... ... @@ -95,13 +96,17 @@ public class AppraiseAddressService {
List<AppraiseAddressResp> appraiseAddressResps = queryAddressInfoList();
if (CollectionUtils.isEmpty(appraiseAddressResps)) {
return new AppraiseAddressResp.builder().setMobile(DEFAULT_MOBILE).setType(0)
.setAddressName(addressName)
.setAddress(address).build();
return buildDefaultNanJingDepot();
}
return appraiseAddressResps.get(0);
}
private AppraiseAddressResp buildDefaultNanJingDepot(){
return new AppraiseAddressResp.builder().setMobile(DEFAULT_MOBILE).setType(0)
.setAddressName(addressName)
.setAddress(address).build();
}
// 根据默认鉴定中心地址
public AppraiseAddressResp queryInitAddressByDepotNum(int depotNum) {
... ... @@ -129,6 +134,18 @@ public class AppraiseAddressService {
return value;
}
public AppraiseAddressResp findByDepotType(int type){
List<AppraiseAddressResp> aas = queryAddressInfoList();
Supplier<AppraiseAddressResp> aarSupplier ;
if (type == DepotType.NJ.getCode()){
aarSupplier = this::buildDefaultNanJingDepot;
}else{
aarSupplier = this::queryInitAddress;
}
return aas.stream().filter(aar-> aar.getType() == type).findAny().orElseGet(aarSupplier);
}
public Map<Integer, AppraiseAddress> buildCodeAppraiseAddressMap(){
Map<Integer, AppraiseAddress> result = new CacheDataConvert<Map<Integer, AppraiseAddress>>()
.convert(CACHE_KEY, MAP_CACHE_KEY);
... ...
... ... @@ -6,9 +6,9 @@ import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
import com.yohobuy.ufo.model.order.resp.*;
import com.yohobuy.ufo.model.order.resp.BuyerOrderNums;
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohobuy.ufo.model.order.vo.OrderListVo;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.DateUtil;
... ... @@ -22,14 +22,10 @@ import com.yohoufo.dal.product.ProductMapper;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.order.common.ActionStatusHold;
import com.yohoufo.order.common.DelStatus;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohoufo.order.event.*;
import com.yohoufo.order.model.PayQueryBo;
import com.yohoufo.order.model.dto.BuyerPenaltyCalResult;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.request.SaveQualityCheckInfoRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
import com.yohoufo.order.model.response.OrderSummaryResp;
import com.yohoufo.order.service.IBuyerOrderMetaService;
import com.yohoufo.order.service.IBuyerOrderService;
... ... @@ -38,7 +34,6 @@ import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
import com.yohoufo.order.service.listener.OrderChangeListenerContainer;
import com.yohoufo.order.service.pay.AbstractPayService;
... ... @@ -53,7 +48,6 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
... ... @@ -70,12 +64,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Autowired
SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
private BuyerOrderListServiceImpl buyerOrderListService;
@Autowired
private BuyerOrderDetailService buyerOrderDetailService;
@Autowired
private ProductProxyService productProxyService;
... ... @@ -107,8 +95,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Autowired
private QualityCheckMapper qualityCheckMapper;
@Autowired
private BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler;
@Autowired
private ProductMapper productMapper;
... ... @@ -493,11 +479,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
private class DataNode{
class DataNode{
BuyerOrder buyerOrderInDB;
}
private DataNode checkBase(OrderRequest orderRequest){
DataNode checkBase(OrderRequest orderRequest){
// 参数检查
if (orderRequest.getUid() < 0
|| orderRequest.getOrderCode() < 0){
... ... @@ -554,10 +540,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
@Override
public OrderDetailInfo getOrderDetail(OrderRequest orderRequest) {
return buyerOrderDetailService.getOrderDetail(orderRequest);
}
/**
... ... @@ -614,40 +597,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return sum;
}
@Override
public PageResp getOrderListForErpGW(OrderListRequest request) {
return buyerOrderListService.getOrderListForErpGW(request);
}
@Override
public PageResp getOrderList(OrderListRequest request, boolean isPlatform) {
OrderListVo orderListVo = orderCacheService.getOrderListInfos(request);
PageResp.PageRespBuilder respBuilder;
if (Objects.nonNull(orderListVo)){
respBuilder = PageResp.builder()
.page(request.getPage())
.pageSize(orderListVo.getPageSize())
.total(orderListVo.getTotal())
.pagetotal(orderListVo.getPagetotal());
List<OrderListInfo> oliList = orderListVo.getOrderList();
buyerOrderListService.resetDynamicProporties(oliList, request.getType());
return respBuilder.data(oliList).build();
}
PageResp orderListInfoRsp = buyerOrderListService.getOrderList(request, isPlatform);
if (orderListInfoRsp != null){
orderListVo = OrderListVo.builder().page(orderListInfoRsp.getPage())
.pageSize(orderListInfoRsp.getPageSize())
.orderList(orderListInfoRsp.getData())
.total(orderListInfoRsp.getTotal())
.pagetotal(orderListInfoRsp.getPagetotal()).build();
orderCacheService.cacheOrderList(request, orderListVo);
}
return orderListInfoRsp;
}
/**
... ... @@ -861,62 +811,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return resp;
}
@Override
public OrderCancelComputeResult cancelCompute(OrderRequest orderRequest) {
DataNode node = checkBase(orderRequest);
BuyerOrder buyerOrder = node.buyerOrderInDB;
Integer orderStatus = buyerOrder.getStatus();
OrderStatus expectStatus = null ;
if (orderStatus == null || (expectStatus = OrderStatus.getOrderStatus(orderStatus))== null){
logger.warn("in buyer cancelCompute check orderStatus fail, orderStatus {} expectStatus {}", orderStatus,expectStatus );
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
logger.info("in buyer cancelCompute, req {} expectStatus {}", orderRequest, expectStatus);
//case 1 :支付前
//case 2 :支付后,卖家发货前
//case 3 :卖家发货后,鉴定中心接受前
OrderStatus targetStatus = null;
BuyerPenaltyCalResult bpcr = null;
OrderCancelComputeResult occr = null;
switch (expectStatus){
case WAITING_PAY:
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_PAY;
occr = OrderCancelComputeResult.builder()
.confirmDesc("确定取消订单?").build();
break;
case HAS_PAYED:
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER;
bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder,
buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode()),
targetStatus);
occr = bpcr2occr(bpcr);
occr.setNeedPenalty(true);
break;
case SELLER_SEND_OUT:
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder,
buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode()),
targetStatus);
occr = bpcr2occr(bpcr);
occr.setNeedPenalty(true);
break;
}
return occr;
}
private OrderCancelComputeResult bpcr2occr(BuyerPenaltyCalResult bpcr){
String currencyUnit = "元";
String orderPrice = bpcr.getOrderActualAmount().toPlainString() + currencyUnit;
String penaltyRate = bpcr.getPenaltyRate().multiply(new BigDecimal(100)).toPlainString() + "%";
String penaltyAmount = "-"+bpcr.getPenaltyAmount().toPlainString() + currencyUnit;
String refundAmount = bpcr.getLeftAmount().toPlainString() + currencyUnit;
OrderCancelComputeResult occr = OrderCancelComputeResult.builder()
.orderPrice(orderPrice)
.penaltyRate(penaltyRate)
.penaltyAmount(penaltyAmount)
.refundAmount(refundAmount)
.showPrice(true)
.build();
return occr;
}
}
... ...
package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.resp.OrderCancelComputeResult;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.vo.OrderListVo;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.order.model.dto.BuyerPenaltyCalResult;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
import com.yohoufo.order.service.IOrderDetailService;
import com.yohoufo.order.service.IOrderListService;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
@Service
public class BuyerOrderViewService implements IOrderListService, IOrderDetailService {
private final Logger logger = LoggerUtils.getBuyerOrderLogger();
@Autowired
private BuyerOrderListServiceImpl buyerOrderListService;
@Autowired
private BuyerOrderDetailService buyerOrderDetailService;
@Autowired
private OrderCacheService orderCacheService;
@Autowired
private BuyerOrderServiceImpl buyerOrderService;
@Autowired
private BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler;
@Autowired
BuyerOrderGoodsMapper buyerOrderGoodsMapper;
@Override
public PageResp getOrderListForErpGW(OrderListRequest request) {
return buyerOrderListService.getOrderListForErpGW(request);
}
@Override
public PageResp getOrderList(OrderListRequest request, boolean isPlatform) {
OrderListVo orderListVo = orderCacheService.getOrderListInfos(request);
PageResp.PageRespBuilder respBuilder;
if (Objects.nonNull(orderListVo)){
respBuilder = PageResp.builder()
.page(request.getPage())
.pageSize(orderListVo.getPageSize())
.total(orderListVo.getTotal())
.pagetotal(orderListVo.getPagetotal());
List<OrderListInfo> oliList = orderListVo.getOrderList();
buyerOrderListService.resetDynamicProporties(oliList, request.getType());
return respBuilder.data(oliList).build();
}
PageResp orderListInfoRsp = buyerOrderListService.getOrderList(request, isPlatform);
if (orderListInfoRsp != null){
orderListVo = OrderListVo.builder().page(orderListInfoRsp.getPage())
.pageSize(orderListInfoRsp.getPageSize())
.orderList(orderListInfoRsp.getData())
.total(orderListInfoRsp.getTotal())
.pagetotal(orderListInfoRsp.getPagetotal()).build();
orderCacheService.cacheOrderList(request, orderListVo);
}
return orderListInfoRsp;
}
@Override
public OrderDetailInfo getOrderDetail(OrderRequest orderRequest) {
return buyerOrderDetailService.getOrderDetail(orderRequest);
}
public OrderCancelComputeResult cancelCompute(OrderRequest orderRequest) {
BuyerOrderServiceImpl.DataNode node = buyerOrderService.checkBase(orderRequest);
BuyerOrder buyerOrder = node.buyerOrderInDB;
Integer orderStatus = buyerOrder.getStatus();
OrderStatus expectStatus = null ;
if (orderStatus == null || (expectStatus = OrderStatus.getOrderStatus(orderStatus))== null){
logger.warn("in buyer cancelCompute check orderStatus fail, orderStatus {} expectStatus {}", orderStatus,expectStatus );
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
logger.info("in buyer cancelCompute, req {} expectStatus {}", orderRequest, expectStatus);
//case 1 :支付前
//case 2 :支付后,卖家发货前
//case 3 :卖家发货后,鉴定中心接受前
OrderStatus targetStatus = null;
BuyerPenaltyCalResult bpcr = null;
OrderCancelComputeResult occr = null;
switch (expectStatus){
case WAITING_PAY:
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_PAY;
occr = OrderCancelComputeResult.builder()
.confirmDesc("确定取消订单?").build();
break;
case HAS_PAYED:
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER;
bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder,
buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode()),
targetStatus);
occr = bpcr2occr(bpcr);
occr.setNeedPenalty(true);
break;
case SELLER_SEND_OUT:
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder,
buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(),buyerOrder.getOrderCode()),
targetStatus);
occr = bpcr2occr(bpcr);
occr.setNeedPenalty(true);
break;
}
return occr;
}
private OrderCancelComputeResult bpcr2occr(BuyerPenaltyCalResult bpcr){
String currencyUnit = "元";
String orderPrice = bpcr.getOrderActualAmount().toPlainString() + currencyUnit;
String penaltyRate = bpcr.getPenaltyRate().multiply(new BigDecimal(100)).toPlainString() + "%";
String penaltyAmount = "-"+bpcr.getPenaltyAmount().toPlainString() + currencyUnit;
String refundAmount = bpcr.getLeftAmount().toPlainString() + currencyUnit;
OrderCancelComputeResult occr = OrderCancelComputeResult.builder()
.orderPrice(orderPrice)
.penaltyRate(penaltyRate)
.penaltyAmount(penaltyAmount)
.refundAmount(refundAmount)
.showPrice(true)
.build();
return occr;
}
}
... ...
... ... @@ -233,8 +233,8 @@ public class DepositServiceImpl implements DepositService {
// 转卖
@Override
public boolean changeOwner(Integer uid, Integer skup, long buyOrderCode, Integer newUid) {
LOGGER.info("changeOwner success! uid {}, skup is {}, buyOrderCode is {}, newUid is {}", uid, skup, buyOrderCode, newUid);
public boolean changeOwner(Integer uid, Integer skup, long buyOrderCode, Integer newUid, boolean isDeposit) {
LOGGER.info("changeOwner success! uid {}, skup is {}, buyOrderCode is {}, newUid is {}, isDeposit is {}", uid, skup, buyOrderCode, newUid, isDeposit);
StorageDeposit sd = storageDepositMapper.queryByOwnerSkup(uid, skup);
if (sd == null) {
return false;
... ... @@ -247,7 +247,8 @@ public class DepositServiceImpl implements DepositService {
sd.setOwnerUid(newUid);
sd.setOrderCode(buyOrderCode);
sd.setSkup(sd.getNewSkup());
sd.setStatus(1);
sd.setStatus(isDeposit ? 1 : 2);
sd.setOutType(isDeposit ? 0 : 2);
sd.setOrderStatus(0);
sd.setUpdateTime(0);
int now = (int) (System.currentTimeMillis() / 1000);
... ...
... ... @@ -20,6 +20,7 @@ import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.constant.ExpressInfoConstant;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.AddressUtil;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.common.utils.UserInfoHiddenHelper;
import com.yohoufo.dal.order.*;
... ... @@ -37,6 +38,7 @@ import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.seller.setting.SellerService;
import com.yohoufo.order.service.seller.setting.SellerWrapper;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -111,6 +113,9 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
@Autowired
private IBuyerOrderMetaService buyerOrderMetaService;
@Autowired
private UserProxyService userProxyService;
private static String EXPRESS_MQ_SEND = "third.logistics.logistics_data";
//物流文案设置
... ... @@ -1050,6 +1055,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
return appraiseAddressService.queryHKAppraiseAddress();
}
boolean skupIsNull = (null == skup);
boolean orderCodeIsNull = (null == orderCode);
if (skupIsNull && orderCodeIsNull) {
... ... @@ -1057,6 +1063,14 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
return appraiseAddressService.queryInitAddress();
}
//寄存订单
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
//防止较早版本出错
if (Objects.nonNull(buyerOrder)){
if (OrderAttributes.DEPOSITE.getCode() == buyerOrder.getAttributes()){
return appraiseAddressService.findByDepotType(DepotType.NJ.getCode());
}
}
AddressInfo buyerAddress = findSellerAddressInfo(uid, skup);
... ... @@ -1111,5 +1125,33 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
return resp;
}
@Override
public AppraiseAddressResp queryByUserAddress(int uid, String addressIdStr) {
int addressId = AddressUtil.getDecryptStr(addressIdStr);
if (addressId < 0){
LOGGER.warn("queryByUserAddess addressId invalidate, uid {}, addressId is {}",
uid, addressIdStr);
throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE);
}
//query the address
AddressInfo hiddenBackAddress = userProxyService.getHiddenAddressInfo(uid, addressId);
// 根据用户id查询默认地址的省份
AppraiseAddressResp resp = null;
if (null != hiddenBackAddress ) {
// 根据产品给的哪些用户的省份匹配到对应的鉴定中心地址
AppraiseAddress address = appraiseAddressService.queryAppraiseAddressByAreaCode(hiddenBackAddress.getAreaCode());
resp = new AppraiseAddressResp.builder().setAreaCode(address.getAreaCode()).build();
resp.setShipFee(address.getShipFee());
LOGGER.info("In queryByUserAddess hiddenBackAddress success, uid {} addressIdStr {}, AppraiseAddressResp",
uid, addressIdStr, resp);
}else {
LOGGER.warn("In queryByUserAddess hiddenBackAddress is null, uid {} addressIdStr {}", uid, addressIdStr);
}
return resp;
}
}
... ...
... ... @@ -375,10 +375,10 @@ public class ShoppingServiceImpl implements IShoppingService {
ActivityPrice activityPrice = checkAndGetActivityPrice(request, skupGood);
//构建算费
ChargeContext chargeContext = buildChargeContext(request, skupGood, activityPrice, ChargeParam.COMPUTE);
/*if (StringUtils.isNoneBlank(request.getAddressId())){
if (StringUtils.isNoneBlank(request.getAddressId())){
Pair<AddressInfo, AddressInfo> addressInfoPair = getAndCheckAddressInfo(request);
chargeContext.setUserAddressPair(addressInfoPair);
}*/
}
//算费
chargeService.charge(chargeContext);
//算费结果
... ...