Authored by chenchao

seller see in-stock only in flea market client

@@ -2,13 +2,12 @@ package com.yohoufo.order.controller; @@ -2,13 +2,12 @@ package com.yohoufo.order.controller;
2 2
3 import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; 3 import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
4 import com.yohobuy.ufo.model.order.common.SkupListType; 4 import com.yohobuy.ufo.model.order.common.SkupListType;
5 -import com.yohobuy.ufo.model.order.req.SingleGoodsChangePriceReq;  
6 import com.yohobuy.ufo.model.order.req.SellerGoodsRequest; 5 import com.yohobuy.ufo.model.order.req.SellerGoodsRequest;
  6 +import com.yohobuy.ufo.model.order.req.SingleGoodsChangePriceReq;
7 import com.yohobuy.ufo.model.order.resp.OrderListInfo; 7 import com.yohobuy.ufo.model.order.resp.OrderListInfo;
8 import com.yohobuy.ufo.model.order.resp.PageResp; 8 import com.yohobuy.ufo.model.order.resp.PageResp;
9 import com.yohobuy.ufo.model.order.resp.SellerGoodsPageResp; 9 import com.yohobuy.ufo.model.order.resp.SellerGoodsPageResp;
10 import com.yohoufo.common.ApiResponse; 10 import com.yohoufo.common.ApiResponse;
11 -import com.yohoufo.common.exception.GatewayException;  
12 import com.yohoufo.order.model.request.OrderListRequest; 11 import com.yohoufo.order.model.request.OrderListRequest;
13 import com.yohoufo.order.model.request.SellerGoodsListRequest; 12 import com.yohoufo.order.model.request.SellerGoodsListRequest;
14 import com.yohoufo.order.model.response.OrderSubmitResp; 13 import com.yohoufo.order.model.response.OrderSubmitResp;
@@ -112,13 +112,15 @@ public class SellerOrderViewService { @@ -112,13 +112,15 @@ public class SellerOrderViewService {
112 Integer cnt = orderCacheService.getOrderSummary(uid, TabType.SELL, businessClient); 112 Integer cnt = orderCacheService.getOrderSummary(uid, TabType.SELL, businessClient);
113 if (cnt == null) { 113 if (cnt == null) {
114 final BusinessClientEnum bce = OrderAssist.findBusinessClient(businessClient); 114 final BusinessClientEnum bce = OrderAssist.findBusinessClient(businessClient);
  115 + //set number of seller goods
  116 + int num = getSellerGoodsNumOfInSale(uid, bce);
  117 + //set number of buyer order related seller goods
115 List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient4Seller(bce); 118 List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient4Seller(bce);
116 - Integer num = sellerOrderGoodsMapper.selectCntByUidStatusList(uid, Arrays.asList(SkupStatus.CAN_SELL.getCode()), orderTypes);  
117 - List<SellerOrderListType> types = Arrays.asList(SellerOrderListType.SEND_OUT, SellerOrderListType.WAITING_PAY);  
118 - List<Integer> statusList = types.parallelStream().flatMap(solt -> solt.getStatus().parallelStream()).collect(Collectors.toList()); 119 + List<SellerOrderListType> orderListTypes = Arrays.asList(SellerOrderListType.SEND_OUT, SellerOrderListType.WAITING_PAY);
  120 + List<Integer> statusList = orderListTypes.parallelStream().flatMap(solt -> solt.getStatus().parallelStream()).collect(Collectors.toList());
119 Integer buyerOrderNum = buyerOrderMapper.selectCntBySellerUidStatus(uid, statusList, orderTypes); 121 Integer buyerOrderNum = buyerOrderMapper.selectCntBySellerUidStatus(uid, statusList, orderTypes);
120 logger.info("in seller order count uid {}, num {}, buyerOrderNum {}", uid, num, buyerOrderNum); 122 logger.info("in seller order count uid {}, num {}, buyerOrderNum {}", uid, num, buyerOrderNum);
121 - if (num == null) { 123 + if (num == 0) {
122 cnt = 0; 124 cnt = 0;
123 } else { 125 } else {
124 if (buyerOrderNum != null) { 126 if (buyerOrderNum != null) {
@@ -135,19 +137,26 @@ public class SellerOrderViewService { @@ -135,19 +137,26 @@ public class SellerOrderViewService {
135 return new OrderSummaryResp("sell", cnt); 137 return new OrderSummaryResp("sell", cnt);
136 } 138 }
137 139
  140 + private int getSellerGoodsNumOfInSale(int uid, final BusinessClientEnum bce){
  141 + List<Integer> sellerGoodsTypes = OrderAssist.matchSellerGoodsTypes(bce);
  142 + int num = sellerOrderGoodsMapper.selectCntByUidStatusList(uid, Arrays.asList(SkupStatus.CAN_SELL.getCode()), sellerGoodsTypes);
  143 + return num;
  144 + }
  145 +
138 public List<OrderSummaryResp> getOrderCntListByUid(int uid, String businessClient) { 146 public List<OrderSummaryResp> getOrderCntListByUid(int uid, String businessClient) {
139 final BusinessClientEnum bce = OrderAssist.findBusinessClient(businessClient); 147 final BusinessClientEnum bce = OrderAssist.findBusinessClient(businessClient);
  148 + //fetch from cache
140 List<OrderSummaryResp> list = orderCacheService.getSellerSaleGoodsTabSummary(uid, bce); 149 List<OrderSummaryResp> list = orderCacheService.getSellerSaleGoodsTabSummary(uid, bce);
141 final String actor = TabType.SELL.getValue(); 150 final String actor = TabType.SELL.getValue();
142 - //not hit in cache 151 + //not hit in cache, sourcing database
143 if (CollectionUtils.isEmpty(list)) { 152 if (CollectionUtils.isEmpty(list)) {
144 - List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient4Seller(bce);  
145 list = new ArrayList<>(8); 153 list = new ArrayList<>(8);
146 SellerOrderListType insale = SellerOrderListType.IN_SALE; 154 SellerOrderListType insale = SellerOrderListType.IN_SALE;
147 - int num = sellerOrderGoodsMapper.selectCntByUidStatusList(uid, Arrays.asList(SkupStatus.CAN_SELL.getCode()), orderTypes); 155 + int num = getSellerGoodsNumOfInSale(uid, bce);
148 OrderSummaryResp sellerGoodsSummary = new OrderSummaryResp(actor, insale.getType(), num); 156 OrderSummaryResp sellerGoodsSummary = new OrderSummaryResp(actor, insale.getType(), num);
149 list.add(sellerGoodsSummary); 157 list.add(sellerGoodsSummary);
150 // 158 //
  159 + List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient4Seller(bce);
151 List<SellerOrderListType> types = Arrays.asList(SellerOrderListType.WAITING_PAY, 160 List<SellerOrderListType> types = Arrays.asList(SellerOrderListType.WAITING_PAY,
152 SellerOrderListType.SEND_OUT, 161 SellerOrderListType.SEND_OUT,
153 SellerOrderListType.ORDER_SUCCESS, 162 SellerOrderListType.ORDER_SUCCESS,
@@ -64,7 +64,7 @@ public class SkupService { @@ -64,7 +64,7 @@ public class SkupService {
64 */ 64 */
65 public int getCanSellSkupBySellerUid(Integer uid){ 65 public int getCanSellSkupBySellerUid(Integer uid){
66 logger.info("in seller order getCanSellSkupBySellerUid count uid {} ", uid); 66 logger.info("in seller order getCanSellSkupBySellerUid count uid {} ", uid);
67 - Integer total = sellerOrderGoodsMapper.selectCntByUidStatusList(uid, Arrays.asList(SkupStatus.CAN_SELL.getCode()), null); 67 + int total = sellerOrderGoodsMapper.selectCntByUidStatusList(uid, Arrays.asList(SkupStatus.CAN_SELL.getCode()), null);
68 logger.info("in seller order getCanSellSkupBySellerUid count uid {}, total {} ", uid, total); 68 logger.info("in seller order getCanSellSkupBySellerUid count uid {}, total {} ", uid, total);
69 return total; 69 return total;
70 } 70 }
@@ -129,6 +129,13 @@ public class OrderAssist { @@ -129,6 +129,13 @@ public class OrderAssist {
129 } 129 }
130 return businessClientCode; 130 return businessClientCode;
131 } 131 }
  132 + private static final List<Integer> FLEAMARKET_CLIENT_GOODSTYPES = new ArrayList<Integer>(){
  133 + {
  134 + add(SkupType.IN_STOCK.getCode());
  135 + }
  136 + };
  137 +
  138 +
132 private static final List<Integer> FLEAMARKET_CLIENT_ORDERTYPES = new ArrayList<Integer>(){ 139 private static final List<Integer> FLEAMARKET_CLIENT_ORDERTYPES = new ArrayList<Integer>(){
133 { 140 {
134 add(OrderAttributes.COMMON_IN_STOCK.getCode()); 141 add(OrderAttributes.COMMON_IN_STOCK.getCode());
@@ -150,6 +157,14 @@ public class OrderAssist { @@ -150,6 +157,14 @@ public class OrderAssist {
150 return null; 157 return null;
151 } 158 }
152 159
  160 + public static List<Integer> matchSellerGoodsTypes(BusinessClientEnum businessClientEnum){
  161 + if (Objects.nonNull(businessClientEnum)
  162 + && BusinessClientEnum.TAOBAO_FLEAMARKET_CLIENT.equals(businessClientEnum)){
  163 + return FLEAMARKET_CLIENT_GOODSTYPES;
  164 + }
  165 + return null;
  166 + }
  167 +
153 public static String matchClientName(BusinessClientEnum businessClientEnum){ 168 public static String matchClientName(BusinessClientEnum businessClientEnum){
154 if (Objects.nonNull(businessClientEnum) 169 if (Objects.nonNull(businessClientEnum)
155 && BusinessClientEnum.TAOBAO_FLEAMARKET_CLIENT.equals(businessClientEnum)){ 170 && BusinessClientEnum.TAOBAO_FLEAMARKET_CLIENT.equals(businessClientEnum)){