Authored by chenchao

quick deliver skup list

... ... @@ -13,6 +13,7 @@ import com.yohoufo.order.model.request.SellerGoodsListRequest;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.impl.SkupListService;
import com.yohoufo.order.service.seller.changePrice.ChangePriceService;
import com.yohoufo.order.service.seller.quickDeliver.QuickDeliverGoodsService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -37,6 +38,9 @@ public class SellerGoodsController {
@Autowired
private ChangePriceService changePriceService;
@Autowired
private QuickDeliverGoodsService quickDeliverGoodsService;
@RequestMapping(params = "method=ufo.seller.entryPrdList")
... ... @@ -175,4 +179,41 @@ public class SellerGoodsController {
orderListInfoRsp = skupListService.getImperfectGoodsList(orderListRequest);
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("卖家订单列表").build();
}
@RequestMapping(params = "method=ufo.seller.quickDeliverPrdList")
@ResponseBody
public ApiResponse getQuickDeliverPrdList(@RequestParam("type") int type,
@RequestParam("uid") int uid,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
OrderListRequest orderListRequest = OrderListRequest.builder()
.uid(uid)
.type(type)
.page(page)
.limit(limit)
.build();
logger.info("ufo.seller.quickDeliverPrdList orderListRequest {}", orderListRequest);
PageResp<OrderListInfo> orderListInfoRsp;
orderListInfoRsp = quickDeliverGoodsService.getQuickDeliverGoodsList(orderListRequest);
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("卖家订单列表").build();
}
@RequestMapping(params = "method=ufo.seller.quickDeliverGoodsSizeList")
@ResponseBody
public ApiResponse getQuickDeliverGoodsSizeList(@RequestParam("uid") int uid,
@RequestParam("productId")Integer productId,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
SellerGoodsListRequest orderListRequest = SellerGoodsListRequest.builder()
.uid(uid)
.productId(productId)
.page(page)
.limit(limit)
.build();
logger.info("ufo.seller.quickDeliverGoodsSizeList orderListRequest {}", orderListRequest);
SellerGoodsPageResp<OrderListInfo> orderListInfoRsp;
orderListInfoRsp = quickDeliverGoodsService.getQuickDeliverGoodsSizeList(orderListRequest);
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("卖家订单列表").build();
}
}
... ...
... ... @@ -181,6 +181,8 @@ public class SkupListService {
return respBuilder.build();
}
/**
* 卖家(可以是入驻或非入驻的卖家)非入驻出售中的商品列表
* @param request
... ... @@ -238,7 +240,7 @@ public class SkupListService {
Integer uid = request.getUid();
boolean isEntry = userProxyService.isEntryShop(uid);
if (!isEntry){
logger.warn("getEntryGoodsSizeList not entry seller, req {}", request);
logger.warn("getQuickDeliverGoodsSizeList not entry seller, req {}", request);
return respBuilder.build();
}
... ... @@ -264,16 +266,15 @@ public class SkupListService {
logger.warn("seller get order list SellerOrderGoods is empty,req {}", request);
return respBuilder.build();
}
final SellerType sellerType = SellerType.ENTRY;
Payment payment = Payment.WALLET;
List<OrderListInfo> orderListInfos = buildPrdSkuList(productId, sogList, sellerType, payment);
List<OrderListInfo> orderListInfos = buildEntryPrdSkuList(productId, sogList);
respBuilder.data(orderListInfos);
ProductInfo productInfo = buildProductInfo(uid, status, sogList, pageTotal);
respBuilder.productInfo(productInfo);
return respBuilder.build();
}
ProductInfo buildProductInfo(Integer uid, Integer status, List<SellerOrderGoods> sogList, int pageTotal){
public ProductInfo buildProductInfo(Integer uid, Integer status, List<SellerOrderGoods> sogList, int pageTotal){
ProductInfo productInfo = new ProductInfo();
SellerOrderGoods sog = sogList.get(0);
productInfo.setProductId(sog.getProductId());
... ... @@ -417,13 +418,32 @@ public class SkupListService {
return map;
}
public List<OrderListInfo> buildPrdSkuList(Integer productId, List<SellerOrderGoods> sogList){
private List<OrderListInfo> buildPrdSkuList(Integer productId,
List<SellerOrderGoods> sogList,
SellerType sellerType,
Payment payment){
Set<Integer> storageIds = sogList.parallelStream().map(SellerOrderGoods::getStorageId)
.collect(Collectors.toSet());
ProductProxyService.PrdPriceCollection ppc = productProxyService.getPrdPriceList(productId, storageIds);
List<GoodsInfo> goodsInfoList = ppc.getGoodsInfoList();
Map<Integer, GoodsInfo> storageIdGoodInfoMap = goodsInfoList.parallelStream()
.collect(Collectors.toMap(GoodsInfo::getStorageId, Function.identity()));
Map<Integer, StorageInfoResp> storageDataMap = ppc.getStorageDataMap();
Map<String, String> overPriceTipsMap = buildOverPriceTipsMap(storageIds, sogList, storageDataMap);
List<OrderListInfo> data ;
data = sogList.parallelStream()
.map(sog -> buildEntryOrderListInfo4Sku(sog, overPriceTipsMap, null, storageIdGoodInfoMap, null))
.filter(oli -> Objects.nonNull(oli))
.collect(Collectors.toList());
return data;
}
public List<OrderListInfo> buildEntryPrdSkuList(Integer productId,
List<SellerOrderGoods> sogList){
final SellerType sellerType = SellerType.ENTRY;
final Payment payment = Payment.WALLET;
Set<Integer> storageIds = sogList.parallelStream().map(SellerOrderGoods::getStorageId)
.collect(Collectors.toSet());
ProductProxyService.PrdPriceCollection ppc = productProxyService.getPrdPriceList(productId, storageIds);
... ... @@ -436,7 +456,7 @@ public class SkupListService {
List<OrderListInfo> data ;
data = sogList.parallelStream()
.map(sog -> buildOrderListInfo4Sku(sog, overPriceTipsMap, sellerType, storageIdGoodInfoMap, payment))
.map(sog -> buildEntryOrderListInfo4Sku(sog, overPriceTipsMap, sellerType, storageIdGoodInfoMap, payment))
.filter(oli -> Objects.nonNull(oli))
.collect(Collectors.toList());
return data;
... ... @@ -523,17 +543,17 @@ public class SkupListService {
return orderListInfo;
}
OrderListInfo buildOrderListInfo4Sku(SellerOrderGoods sellerOrderGoods,
Map<String, String> overPriceTipsMap,
SellerType sellerType,
Map<Integer, GoodsInfo> storageIdGoodInfoMap,
Payment payment) {
public OrderListInfo buildEntryOrderListInfo4Sku(SellerOrderGoods sellerOrderGoods,
Map<String, String> overPriceTipsMap,
SellerType sellerType,
Map<Integer, GoodsInfo> storageIdGoodInfoMap,
Payment payment) {
Integer uid;
OrderListInfo orderListInfo = new OrderListInfo();
orderListInfo.setUid(uid = sellerOrderGoods.getUid());
SkupStatus skupStatus = SkupStatus.getSkupStatus(sellerOrderGoods.getStatus());
if (skupStatus == null){
logger.warn("get seller Order List skupStatus not exist, uid is {}, orderCode is {}, status is {}",
logger.warn("buildEntryOrderListInfo4Sku seller Order List skupStatus not exist, uid is {}, orderCode is {}, status is {}",
uid, orderListInfo.getOrderCode(), sellerOrderGoods.getStatus());
return null;
}
... ... @@ -548,6 +568,8 @@ public class SkupListService {
.sellerType(sellerType).skupStatus(skupStatus)
.skupType(skupType).storageNum(storageNum)
.viewType(ViewType.LIST).build();
// 按钮显示
List<ButtonShowBo> buttons = sellerOrderViewService.getButtons(bsfc, 0);
orderListInfo.setButtons(buttons == null ? Lists.newArrayList() : new ArrayList<>(buttons));
... ... @@ -711,4 +733,6 @@ public class SkupListService {
return respBuilder.build();
}
}
... ...
... ... @@ -3,25 +3,36 @@ package com.yohoufo.order.service.seller.quickDeliver;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.bo.ProductInfo;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.QuickDeliverOrderSubmitReq;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.resp.SellerGoodsPageResp;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.alarm.SmsAlarmEvent;
import com.yohoufo.dal.order.SellerOrderGoodsViewMapper;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.QuickDeliverOrderContext;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.SellerGoodsListRequest;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.handler.SellerOrderSubmitHandler;
import com.yohoufo.order.service.impl.SkupListService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.seller.orderMeta.SellerOrderMetaService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author chenchao
... ... @@ -49,6 +60,12 @@ public class QuickDeliverGoodsService {
@Autowired
private SellerOrderMetaService sellerOrderMetaService;
@Autowired
private SellerOrderGoodsViewMapper sellerOrderGoodsViewMapper;
@Autowired
private SkupListService skupListService;
public OrderSubmitResp publish(QuickDeliverOrderSubmitReq req){
QuickDeliverOrderContext qdoc = quickDeliverPublishProcessor.buildPublishCtx(req);
... ... @@ -123,4 +140,99 @@ public class QuickDeliverGoodsService {
}
/**
* 卖家出售中的闪购商品列表
* @param request
* @return
*/
public PageResp<OrderListInfo> getQuickDeliverGoodsList(OrderListRequest request){
PageResp.PageRespBuilder respBuilder;
int limit = request.getLimit();
respBuilder = PageResp.builder()
.page(request.getPage())
.pageSize(limit);
Integer uid = request.getUid();
int type;
if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()) {
SkupStatus viewableStatus = SkupStatus.CAN_SELL;
List<Integer> statusList = Arrays.asList(viewableStatus.getCode());
final List<Integer> skupTypeCodes = getSkupTypeCodes();
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSkc(uid, statusList, skupTypeCodes);
respBuilder.total(total)
.pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1));
if (total == 0){
return respBuilder.build();
}
int offset = (request.getPage() - 1) * limit;
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSkc(uid,
statusList, skupTypeCodes, offset , limit);
if (CollectionUtils.isEmpty(sogList)){
logger.warn("seller get entry order list SellerOrderGoods is empty,req {}", request);
return respBuilder.build();
}
List<OrderListInfo> data = skupListService.buildProductList(sogList, viewableStatus);
respBuilder.data(data);
}
return respBuilder.build();
}
private static final List<Integer> SKUP_TYPE_CODES;
static {
SKUP_TYPE_CODES = new ArrayList<>(1);
SKUP_TYPE_CODES.add(SkupType.QUICK_DELIVER.getCode());
}
public List<Integer> getSkupTypeCodes(){
return SKUP_TYPE_CODES;
}
/**
* 卖家入驻后 单个skc聚合的所有尺码商品
* @param request
* @return
*/
public SellerGoodsPageResp<OrderListInfo> getQuickDeliverGoodsSizeList(SellerGoodsListRequest request){
SellerGoodsPageResp.SGPRBuilder respBuilder;
int limit = request.getLimit();
respBuilder = SellerGoodsPageResp.builder()
.page(request.getPage())
.pageSize(limit);
Integer status = SkupStatus.CAN_SELL.getCode();
Integer uid = request.getUid();
Integer productId;
SellerOrderGoods sogCondition = new SellerOrderGoods();
sogCondition.setProductId(productId=request.getProductId());
sogCondition.setUid(uid);
sogCondition.setStatus(status);
final List<Integer> skupTypeCodes = getSkupTypeCodes();
//
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSku(sogCondition, skupTypeCodes);
respBuilder.total(total);
if (total == 0){
return respBuilder.build();
}
int pageTotal = (total % limit == 0) ? (total / limit) : (total / limit + 1);
respBuilder.pagetotal(pageTotal);
int offset = (request.getPage() - 1) * limit;
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSku(sogCondition,
skupTypeCodes, offset, limit);
//TODO 可以提前计算 total offset limit三者之间的关系,减少一次网络IO
if (CollectionUtils.isEmpty(sogList)){
logger.warn("seller get order list SellerOrderGoods is empty,req {}", request);
return respBuilder.build();
}
List<OrderListInfo> orderListInfos = skupListService.buildPrdSkuList(productId, sogList);
respBuilder.data(orderListInfos);
ProductInfo productInfo = skupListService.buildProductInfo(uid, status, sogList, pageTotal);
respBuilder.productInfo(productInfo);
return respBuilder.build();
}
}
... ...
... ... @@ -10,13 +10,14 @@ import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.utils.SellerGoodsHelper;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Builder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
* Created by chao.chen on 2019/4/16.
... ... @@ -37,6 +38,7 @@ public class ButtonShowFactory {
ViewType viewType;
}
private Context context;
public ButtonShowFactory(Context context) {
... ... @@ -48,6 +50,8 @@ public class ButtonShowFactory {
private final static List<ButtonShowBo> CAN_SELL_LIST_BTNS_4_ENTRY;
private final static List<ButtonShowBo> CAN_SELL_DETAIL_BTNS_4_ENTRY;
private static final List<ButtonShowBo> CAN_SELL_LIST_BTNS_4_QUICK_DELIVER;
static {
CAN_SELL_LIST_BTNS_4_ENTRY_ONLY_ONE_PRD
... ... @@ -56,6 +60,8 @@ public class ButtonShowFactory {
= Arrays.asList(ButtonShow.BATCH_CANCEL_SOLD.getBo(), ButtonShow.CHANGE_PRICE.getBo());
CAN_SELL_DETAIL_BTNS_4_ENTRY = CAN_SELL_LIST_BTNS_4_ENTRY;
CAN_SELL_LIST_BTNS_4_QUICK_DELIVER = CAN_SELL_LIST_BTNS_4_ENTRY;
}
public List<ButtonShowBo> getButtons(){
... ... @@ -80,54 +86,87 @@ public class ButtonShowFactory {
Integer storageNum = context.storageNum;
boolean isEntrySeller = (sellerType == SellerType.ENTRY);
//非入驻商家 或者支付方式不是钱包 or 瑕疵or二手 的订单,均为原先方式
if (payment == null || payment != Payment.WALLET || SellerGoodsHelper.isImperfectGoods(skupType)){
if (SellerGoodsHelper.isImperfectGoods(skupType)){
return skupStatus.getDetailButtons();
}
if(payment == Payment.WALLET){
List<ButtonShowBo> buttonShowBos = null;
//priority : 1 . 闪购 -> 2. 入驻钱包支付
if (SkupType.QUICK_DELIVER.equals(skupType)){
switch (skupStatus){
case CAN_SELL:
buttonShowBos = CAN_SELL_LIST_BTNS_4_QUICK_DELIVER;
break;
}
}else if(payment!=null && payment == Payment.WALLET){
if (storageNum>1 && isEntrySeller) {
if (skupStatus == SkupStatus.CAN_SELL) {
return CAN_SELL_DETAIL_BTNS_4_ENTRY;
buttonShowBos = CAN_SELL_DETAIL_BTNS_4_ENTRY;
}
}
if (storageNum == 1){
if(skupStatus == SkupStatus.CAN_SELL){
return CAN_SELL_LIST_BTNS_4_ENTRY_ONLY_ONE_PRD;
buttonShowBos = CAN_SELL_LIST_BTNS_4_ENTRY_ONLY_ONE_PRD;
}
}
}
//as protect action, fetch default button
if (Objects.isNull(buttonShowBos)){
buttonShowBos = skupStatus.getDetailButtons();
}
return buttonShowBos;
}
public List<ButtonShowBo> getListButtonsOfEntryGoods(){
SkupStatus skupStatus = context.skupStatus;
Integer storageNum = context.storageNum;
List<ButtonShowBo> buttons = null;
final int threshold = 1;
if (storageNum>threshold && isEntrySeller()) {
if (skupStatus == SkupStatus.CAN_SELL) {
return CAN_SELL_LIST_BTNS_4_ENTRY;
}
}
if (storageNum == threshold){
if(skupStatus == SkupStatus.CAN_SELL){
return CAN_SELL_LIST_BTNS_4_ENTRY_ONLY_ONE_PRD;
}
}
return skupStatus.getDetailButtons();
return buttons;
}
private boolean isEntrySeller(){
SellerType sellerType = context.sellerType;
return (sellerType == SellerType.ENTRY);
}
public List<ButtonShowBo> getListButtons() {
SellerType sellerType = context.sellerType;
SkupType skupType = context.skupType;
Payment payment = context.payment;
SkupStatus skupStatus = context.skupStatus;
Integer storageNum = context.storageNum;
boolean isEntrySeller = (sellerType == SellerType.ENTRY);
if (payment == null || payment != Payment.WALLET || SellerGoodsHelper.isImperfectGoods(skupType)){
if (SellerGoodsHelper.isImperfectGoods(skupType)){
return skupStatus.getListButtons();
}
if(payment == Payment.WALLET){
if (storageNum>1 && isEntrySeller) {
if (skupStatus == SkupStatus.CAN_SELL) {
return CAN_SELL_LIST_BTNS_4_ENTRY;
}
List<ButtonShowBo> buttons = null;
//priority : 1 . 闪购 -> 2. 入驻钱包支付
if (SkupType.QUICK_DELIVER.equals(skupType)){
switch (skupStatus){
case CAN_SELL:
buttons = CAN_SELL_LIST_BTNS_4_QUICK_DELIVER;
break;
}
} else if(payment!=null && payment == Payment.WALLET){
buttons = getListButtonsOfEntryGoods();
}
if (storageNum == 1){
if(skupStatus == SkupStatus.CAN_SELL){
return CAN_SELL_LIST_BTNS_4_ENTRY_ONLY_ONE_PRD;
}
}
if (Objects.isNull(buttons)){
buttons = skupStatus.getListButtons();
}
return skupStatus.getListButtons();
return buttons;
}
}
... ...
package com.yohoufo.order.utils;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohobuy.ufo.model.order.constants.RegionEnum;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.order.model.response.DepositResp;
import com.yohoufo.order.service.seller.support.SkupTypeCodeSupport;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.util.Objects;
... ...