Authored by chenchao

optimized construct

... ... @@ -16,6 +16,7 @@ import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.impl.AppraiseService;
import com.yohoufo.order.service.impl.SellerFeeService;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.service.impl.SellerOrderViewService;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -40,6 +41,9 @@ public class BuyerOrderController {
private SellerOrderService sellerOrderService;
@Autowired
private SellerOrderViewService sellerOrderViewService;
@Autowired
private SellerFeeService sellerFeeService;
@Autowired
... ... @@ -279,7 +283,7 @@ public class BuyerOrderController {
orderCntResp = buyerOrderService.getOrderCnt(orderRequest, OrderListType.ALL);
break;
case SELL:
orderCntResp = sellerOrderService.getOrderCnt(orderRequest, SellerOrderListType.ALL);
orderCntResp = sellerOrderViewService.getOrderCnt(orderRequest, SellerOrderListType.ALL);
break;
default:
orderCntResp = OrderCntResp.builder().uid(uid).cnt(0L).actor(tabType).build();
... ...
... ... @@ -8,6 +8,7 @@ import com.yohoufo.order.model.response.*;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.IShoppingService;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.service.impl.SellerOrderViewService;
import com.yohoufo.order.utils.CouponCodeUtils;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.lang3.StringUtils;
... ... @@ -27,7 +28,7 @@ public class ShoppingController {
@Autowired
SellerOrderService sellerOrderService;
private SellerOrderViewService sellerOrderViewService;
@Autowired
IBuyerOrderService ibuyerOrderService;
... ... @@ -112,7 +113,7 @@ public class ShoppingController {
logger.info("in ufo.order.summary, uid {}, clientType is {}", uid, clientType);
OrderSummaryResp orderSummaryResp1 = sellerOrderService.selectOrderNumByUid(uid);
OrderSummaryResp orderSummaryResp1 = sellerOrderViewService.selectOrderNumByUid(uid);
OrderSummaryResp orderSummaryResp2 = ibuyerOrderService.selectOrderNumByUid(uid);
... ...
package com.yohoufo.order.convert;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import java.util.Optional;
... ...
... ... @@ -108,8 +108,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
@Autowired
private BuyerOrderMapper buyerOrderMapper;
@Autowired
private OrderCacheService orderCacheService;
@Autowired
private CacheCleaner cacheCleaner;
... ... @@ -168,6 +167,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
@Autowired
private ResourcesProxyService resourcesProxyService;
@Autowired
private SkupListService skupListService;
private static final int MAX_DEAL = 10;
... ... @@ -340,6 +341,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
* @param req
* @return
*/
@Deprecated
public boolean batchCancel(SellerOrderBatchCancelReq req){
boolean result = false;
//check
... ... @@ -499,6 +501,9 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
return true;
}
private void checkBuyCanDelStatus(Integer status) {
if (!ActionStatusHold.getSellerCanDelBuyerStatusList().contains(status)) {
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
... ... @@ -531,10 +536,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
}
public PageResp<OrderListInfo> getOrderListForErpGW(OrderListRequest request){
return sellerOrderListService.getOrderListForErpGW(request);
}
@Override
public PageResp<OrderListInfo> getOrderList(OrderListRequest request, boolean isPlatform){
... ... @@ -543,57 +545,19 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
}
@Override
public PageResp<OrderListInfo> getOrderListForErpGW(OrderListRequest request){
return sellerOrderListService.getOrderListForErpGW(request);
}
@Override
public OrderDetailInfo getOrderDetail(OrderRequest orderRequest) {
return sellerOrderDetailService.getOrderDetail(orderRequest);
}
/**
* 根据用户id查询卖的单数
* 出售栏目显示的数量=出售tab下商品“出售中”状态的数量+待发货tab下所有的订单数+已发货tab下所有订单数
* @param uid
* @return
*/
public OrderSummaryResp selectOrderNumByUid(int uid) {
Integer cnt = orderCacheService.getOrderSummary(uid, TabType.SELL);
if (cnt == null) {
//todo add cache
Integer num = sellerOrderGoodsMapper.selectCntByUidStatusList(uid, Arrays.asList(SkupStatus.CAN_SELL.getCode()));
List<SellerOrderListType> types = Arrays.asList(SellerOrderListType.WAITING_SEND, SellerOrderListType.WAITING_PAY);
List<Integer> statusList = types.parallelStream().flatMap(solt -> solt.getStatus().parallelStream()).collect(Collectors.toList());
Integer buyerOrderNum = buyerOrderMapper.selectCntBySellerUid(uid, statusList);
log.info("in seller order count uid {}, num {}, buyerOrderNum {}", uid, num, buyerOrderNum);
if (num == null) {
cnt = 0;
} else {
if (buyerOrderNum != null) {
cnt = num + buyerOrderNum;
} else {
cnt = num;
}
}
}
if (cnt != null){
orderCacheService.cacheOrderSummary(uid, TabType.SELL, cnt);
}
return new OrderSummaryResp("sell", cnt);
}
public OrderCntResp getOrderCnt(OrderRequest orderRequest, SellerOrderListType listType){
log.info("in seller getOrderCnt req {} listType {}", orderRequest, listType);
int cnt ;
switch (listType){
case ALL:
cnt = sellerOrderGoodsMapper.selectCntByUid(orderRequest.getUid());
break;
default:
cnt = 0;
break;
}
return OrderCntResp.builder().cnt(cnt).uid(orderRequest.getUid())
.actor(orderRequest.getTabType()).build();
}
/**
... ... @@ -810,19 +774,9 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
}
}
/**
* 商家未完成订单数量
*/
public int getUnfinishedOrderBySellerUid(Integer uid){
log.info("in seller order getUnfinishedOrderBySellerUid count uid {} ", uid);
List<Integer> statusList = ActionStatusHold.getUnfinishedOrderStatusCode();
Integer total = buyerOrderMapper.selectCntBySellerUidStatus(uid, statusList);
log.info("in seller order getUnfinishedOrderBySellerUid count uid {}, total {} ", uid, total);
return total;
}
@Autowired
private SkupListService skupListService;
public SellerOrderListResp refresh(OrderRequest req){
int uid = req.getUid();
... ...
... ... @@ -2,13 +2,21 @@ package com.yohoufo.order.service.impl;
import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
import com.yohobuy.ufo.model.order.bo.PrdPrice;
import com.yohobuy.ufo.model.order.common.ButtonShow;
import com.yohobuy.ufo.model.order.common.SellerType;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.response.StorageDataResp;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.order.common.ActionStatusHold;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderSummaryResp;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.MsgHelper;
... ... @@ -21,6 +29,7 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created by chao.chen on 2018/11/26.
... ... @@ -32,6 +41,15 @@ public class SellerOrderViewService {
@Autowired
ProductProxyService productProxyService;
@Autowired
private BuyerOrderMapper buyerOrderMapper;
@Autowired
private OrderCacheService orderCacheService;
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
List<Integer> SHOW_OVER_FLOW_PRICE_STATUS = Arrays.asList(SkupStatus.CAN_SELL.getCode());
public boolean showOverFlowPrice(int skupStatus){
... ... @@ -94,6 +112,65 @@ public class SellerOrderViewService {
return prdPrice;
}
/**
* 商家未完成订单数量
*/
public int getUnfinishedOrderBySellerUid(Integer uid){
logger.info("in seller order getUnfinishedOrderBySellerUid count uid {} ", uid);
List<Integer> statusList = ActionStatusHold.getUnfinishedOrderStatusCode();
Integer total = buyerOrderMapper.selectCntBySellerUidStatus(uid, statusList);
logger.info("in seller order getUnfinishedOrderBySellerUid count uid {}, total {} ", uid, total);
return total;
}
/**
* 根据用户id查询卖的单数
* 出售栏目显示的数量=出售tab下商品“出售中”状态的数量+待发货tab下所有的订单数+已发货tab下所有订单数
* @param uid
* @return
*/
public OrderSummaryResp selectOrderNumByUid(int uid) {
Integer cnt = orderCacheService.getOrderSummary(uid, TabType.SELL);
if (cnt == null) {
//todo add cache
Integer num = sellerOrderGoodsMapper.selectCntByUidStatusList(uid, Arrays.asList(SkupStatus.CAN_SELL.getCode()));
List<SellerOrderListType> types = Arrays.asList(SellerOrderListType.WAITING_SEND, SellerOrderListType.WAITING_PAY);
List<Integer> statusList = types.parallelStream().flatMap(solt -> solt.getStatus().parallelStream()).collect(Collectors.toList());
Integer buyerOrderNum = buyerOrderMapper.selectCntBySellerUid(uid, statusList);
logger.info("in seller order count uid {}, num {}, buyerOrderNum {}", uid, num, buyerOrderNum);
if (num == null) {
cnt = 0;
} else {
if (buyerOrderNum != null) {
cnt = num + buyerOrderNum;
} else {
cnt = num;
}
}
}
if (cnt != null){
orderCacheService.cacheOrderSummary(uid, TabType.SELL, cnt);
}
return new OrderSummaryResp("sell", cnt);
}
public OrderCntResp getOrderCnt(OrderRequest orderRequest, SellerOrderListType listType){
logger.info("in seller getOrderCnt req {} listType {}", orderRequest, listType);
int cnt ;
switch (listType){
case ALL:
cnt = sellerOrderGoodsMapper.selectCntByUid(orderRequest.getUid());
break;
default:
cnt = 0;
break;
}
return OrderCntResp.builder().cnt(cnt).uid(orderRequest.getUid())
.actor(orderRequest.getTabType()).build();
}
String buildLeastPriceTips(BigDecimal leastPrice){
return "该尺码最低售价¥" + BigDecimalHelper.formatNumber(leastPrice, BigDecimalHelper.FORMAT_NOPOINT);
}
... ...
... ... @@ -21,9 +21,7 @@ import com.yohoufo.dal.order.model.EntrySellerRechargeOrder;
import com.yohoufo.dal.order.model.SellerWallet;
import com.yohoufo.dal.order.model.StoredSeller;
import com.yohoufo.order.common.EnterQuitEnum;
import com.yohoufo.order.common.InviterType;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.event.BuyerConfirmEvent;
import com.yohoufo.order.event.InviteRecordEvent;
import com.yohoufo.order.model.request.ShoppingRequest;
import com.yohoufo.order.model.response.OrderSubmitResponse;
... ... @@ -34,7 +32,6 @@ import com.yohoufo.order.service.MerchantOrderPaymentService;
import com.yohoufo.order.service.cache.StoredSellerCacheService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -67,7 +64,7 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi
EntrySellerRechargeOrderMapper entrySellerRechargeOrderMapper;
@Autowired
SellerOrderService sellerOrderService;
SellerOrderViewService sellerOrderViewService;
@Autowired
MerchantOrderPaymentService merchantOrderPaymentService;
... ... @@ -88,9 +85,6 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi
private SkupService skupService;
@Autowired
private SellerService sellerService;
@Autowired
private SellerEnterApplyService sellerEnterApplyService;
@Autowired
SellerWalletMapper sellerWalletMapper;
... ... @@ -258,7 +252,7 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi
Integer expectStatus= StoredSellerStatusEnum.entered.getId();
// 检查商户是否有出售中的商品,或者有订单未完成的 ,都不可以提交
Integer total=sellerOrderService.getUnfinishedOrderBySellerUid(uid);
Integer total= sellerOrderViewService.getUnfinishedOrderBySellerUid(uid);
if(total!=null && total>0){
logger.error("quitStoredSeller not allowed cause of unfinished order ,uid {} ,total {}" ,uid,total);
... ...
... ... @@ -101,7 +101,7 @@ public class ImperfectPublishProcessor implements PublishProcessor<ImperfectOrde
boolean isEntryShop = sellerTypeNode.isCommonEntry() || sellerTypeNode.isSuper();
SkupStatus tss;
if (isEntryShop){
tss = SkupStatus.WAITING_AUDIT;
tss = SkupStatus.CAN_SELL;
}else{
tss = SkupStatus.CAN_NOT_SELL;
}
... ...