Authored by chenchao

filter by client

... ... @@ -29,15 +29,23 @@ public interface BuyerOrderMapper {
int updateByOrderCode(BuyerOrder record);
int selectCntByUidStatus(@Param("uid") int uid, @Param("status") List<Integer> status);
int selectCntByUidStatus(@Param("uid") int uid, @Param("status") List<Integer> status,@Param("orderTypes") List<Integer> orderTypes);
List<BuyerOrder> selectListByUidStatus(@Param("uid") int uid, @Param("orderCode") Long orderCode, @Param("status") List<Integer> status,
@Param("offset")Integer offset, @Param("limit")Integer limit);
List<BuyerOrder> selectListByUidStatus(@Param("uid") int uid,
@Param("orderCode") Long orderCode,
@Param("status") List<Integer> status,
@Param("orderTypes") List<Integer> orderTypes,
@Param("offset")Integer offset,
@Param("limit")Integer limit);
int selectCntBySellerUidStatus(@Param("sellerUid") int suid, @Param("status") List<Integer> status);
int selectCntBySellerUidStatus(@Param("sellerUid") int suid,
@Param("status") List<Integer> status,
@Param("orderTypes") List<Integer> orderTypes);
List<BuyerOrder> selectListBySellerUidStatus(@Param("sellerUid") int suid, @Param("orderCode") Long orderCode,
List<BuyerOrder> selectListBySellerUidStatus(@Param("sellerUid") int suid,
@Param("orderCode") Long orderCode,
@Param("status") List<Integer> status,
@Param("orderTypes") List<Integer> orderTypes,
@Param("offset")Integer offset, @Param("limit")Integer limit);
int updateByPrimaryKey(BuyerOrder record);
... ...
... ... @@ -48,7 +48,11 @@
<select id="selectCntByUidStatus" resultType="java.lang.Integer">
select count(*) from buyer_order
where uid = #{uid,jdbcType=INTEGER}
where <include refid="where_sql_buyer_order_list_by_UidStatus" />
</select>
<sql id="where_sql_buyer_order_list_by_UidStatus">
uid = #{uid,jdbcType=INTEGER}
and buyer_order_status = 1
<if test="status != null">
and status in
... ... @@ -56,21 +60,22 @@
#{item}
</foreach>
</if>
</select>
<if test="orderTypes != null">
and attributes in
<foreach collection="orderTypes" item="attributes" open="(" close=")" separator=",">
#{attributes}
</foreach>
</if>
</sql>
<select id="selectListByUidStatus" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from buyer_order
where uid = #{uid,jdbcType=INTEGER} and buyer_order_status = 1
where <include refid="where_sql_buyer_order_list_by_UidStatus" />
<if test="orderCode != null">
and order_code = #{orderCode,jdbcType=BIGINT}
</if>
<if test="status != null">
and status in
<foreach item="item" index="index" collection="status" open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by create_time desc, update_time desc
limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
... ... @@ -389,6 +394,12 @@
#{item}
</foreach>
</if>
<if test="orderTypes != null">
and attributes in
<foreach collection="orderTypes" item="attributes" open="(" close=")" separator=",">
#{attributes}
</foreach>
</if>
</sql>
<select id="selectCntBySellerUidStatus" resultType="java.lang.Integer">
... ...
... ... @@ -99,7 +99,7 @@ public class PromotionService {
uid, skup, salePrice, promotionId);
//fetch promotions
Map<Integer,Pair<PromotionActivityRspBo,PromotionCalculator>> promotion2CalculatorMap
= buildPromotion2CalculatorMap(uid, skup, context.getChargeParam().getBusinessClient());
= buildPromotion2CalculatorMap(uid, skup, chargeParam.getBusinessClient());
if (MapUtils.isEmpty(promotion2CalculatorMap)){
logger.warn("caculatePromotions.calculateByPromotionId promotion2CalculatorMap empty, uid {} skup {} salePrice {} ",
... ...
... ... @@ -67,6 +67,7 @@ public class BuyerOrderController {
public ApiResponse getOrderList(@RequestParam("type") int type,
@RequestParam("uid") int uid,
@RequestParam("tabType") String tabType,
@RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
TabType actor = TabType.getTabType(tabType);
... ... @@ -80,6 +81,7 @@ public class BuyerOrderController {
.limit(limit)
.tabType(tabType)
.actor(actor)
.businessClient(businessClient)
.build();
LOG.info("in ufo.order.list, req {}", orderListRequest);
PageResp<OrderListInfo> orderListInfoRsp;
... ... @@ -272,6 +274,7 @@ public class BuyerOrderController {
@RequestMapping(params = "method=ufo.order.getAllCnt")
public ApiResponse getOrderCnt(@RequestParam(name = "uid") int uid,
@RequestParam("tabType") String tabType,
@RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient,
@RequestParam(name = "client_type", required = false) String clientType){
LOG.info("in ufo.order.getAllCnt, uid {}, clientType is {}", uid, clientType);
TabType actor = TabType.getTabType(tabType);
... ... @@ -282,6 +285,7 @@ public class BuyerOrderController {
.uid(uid)
.tabType(tabType)
.actor(actor)
.businessClient(businessClient)
.build();
OrderCntResp orderCntResp;
switch (actor){
... ... @@ -311,7 +315,8 @@ public class BuyerOrderController {
public ApiResponse getMyBuyedGoods(
@RequestParam("uid") int uid,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit,
@RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient) {
TabType actor = TabType.BUY;
OrderListRequest orderListRequest = OrderListRequest.builder()
.uid(uid)
... ... @@ -320,6 +325,7 @@ public class BuyerOrderController {
.limit(limit)
.tabType(actor.getValue())
.actor(actor)
.businessClient(businessClient)
.build();
LOG.info("in ufo.getMyBuyedGoods.list, req {}", orderListRequest);
//TODO remove below codes 2 service level
... ...
... ... @@ -33,6 +33,7 @@ public class OrderStatisticController {
@Deprecated
@RequestMapping(value = "/shopping", params = "method=ufo.order.summary")
public ApiResponse summary(@RequestParam(name = "uid") int uid,
@RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient,
@RequestParam(name = "client_type", required = false) String clientType){
logger.info("in ufo.order.summary, uid {}, clientType is {}", uid, clientType);
... ...
... ... @@ -26,4 +26,6 @@ public class OrderRequest {
OrderCancelEvent orderCancelEvent;
String appVersion;
private String businessClient;
}
... ...
... ... @@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.TimeoutBo;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.constants.BusinessClientEnum;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
... ... @@ -45,9 +46,9 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
abstract List<Integer> initOrderListRequest(OrderListRequest request);
abstract int getTotal(int uid, List<Integer> statusQuery);
abstract int getTotal(int uid, List<Integer> statusQuery, List<Integer> orderTypes);
abstract List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, int offset, int limit);
abstract List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, List<Integer> orderTypes, int offset, int limit);
abstract List<BuyerOrderGoods> getOrderGoodsList(int uid, List<Long> orderCodeList);
... ... @@ -163,7 +164,9 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
// check and init请求参数
List<Integer> statusQuery = initOrderListRequest(request);
TabType actor = request.getActor();
int total = getTotal(request.getUid(), statusQuery);
BusinessClientEnum businessClientEnum = OrderAssist.findBusinessClient(request.getBusinessClient());
List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient(businessClientEnum);
int total = getTotal(request.getUid(), statusQuery, orderTypes);
int limit = request.getLimit();
if (total == 0){
return lpNode;
... ... @@ -171,7 +174,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
int offset = (request.getPage() - 1) * limit;
List<BuyerOrder> buyerOrderList = getOrderList(request.getUid(), request.getOrderCode(), statusQuery, offset, limit);
List<BuyerOrder> buyerOrderList = getOrderList(request.getUid(), request.getOrderCode(), statusQuery, orderTypes, offset, limit);
List<Long> orderCodeList = buyerOrderList.stream().map(BuyerOrder::getOrderCode).collect(Collectors.toList());
//TODO 可以提前计算 total offset limit三者之间的关系,减少一次网络I
... ...
... ... @@ -106,13 +106,13 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
}
@Override
int getTotal(int uid, List<Integer> statusQuery){
return buyerOrderMapper.selectCntByUidStatus(uid, statusQuery);
int getTotal(int uid, List<Integer> statusQuery, List<Integer> orderTypes){
return buyerOrderMapper.selectCntByUidStatus(uid, statusQuery, orderTypes);
}
@Override
List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, int offset, int limit){
List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectListByUidStatus(uid, orderCode, statusQuery, offset, limit);
List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery,List<Integer> orderTypes, int offset, int limit){
List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectListByUidStatus(uid, orderCode, statusQuery,orderTypes, offset, limit);
return buyerOrderList;
}
... ...
... ... @@ -781,7 +781,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
public OrderSummaryResp selectBidingOrderNumByUid(int uid, String statKey) {
Integer num = orderCacheService.getStatOrderSummary(uid, TabType.BUY, statKey);
if (num == null) {
num = buyerOrderMapper.selectCntByUidStatus(uid, Lists.newArrayList(OrderStatus.BIDING.getCode()));
num = buyerOrderMapper.selectCntByUidStatus(uid, Lists.newArrayList(OrderStatus.BIDING.getCode()), null);
}
if (num != null) {
orderCacheService.cacheStatOrderSummary(uid, TabType.BUY, statKey, num);
... ...
... ... @@ -344,13 +344,13 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
}
@Override
int getTotal(int uid, List<Integer> statusQuery) {
return buyerOrderMapper.selectCntBySellerUidStatus(uid, statusQuery);
int getTotal(int uid, List<Integer> statusQuery, List<Integer> orderTypes) {
return buyerOrderMapper.selectCntBySellerUidStatus(uid, statusQuery, orderTypes);
}
@Override
List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, int offset, int limit){
List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectListBySellerUidStatus(uid, orderCode, statusQuery, offset, limit);
List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, List<Integer> orderTypes, int offset, int limit){
List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectListBySellerUidStatus(uid, orderCode, statusQuery, orderTypes, offset, limit);
return buyerOrderList;
}
... ...
... ... @@ -95,7 +95,7 @@ public class SellerOrderViewService {
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);
Integer total = buyerOrderMapper.selectCntBySellerUidStatus(uid, statusList, null);
logger.info("in seller order getUnfinishedOrderBySellerUid count uid {}, total {} ", uid, total);
return total;
}
... ...
... ... @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.BusinessClientEnum;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
import com.yohoufo.common.alarm.EventBusPublisher;
... ... @@ -15,6 +16,7 @@ import com.yohoufo.order.convert.builder.AlarmEventBuilder;
import com.yohoufo.order.service.handler.transfer.TransferChancelSelector;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.OrderAssist;
import com.yohoufo.order.utils.SellerGoodsHelper;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -47,12 +49,12 @@ public class ShoppingRiskWatchDog {
@Autowired
TransferChancelSelector transferChancelSelector;
public void checkWaitingPayCnt(int uid){
public void checkWaitingPayCnt(int uid, BusinessClientEnum businessClientEnum){
logger.info("in ShoppingRiskWatchDog.checkWaitingPayCnt uid {}", uid);
List<Integer> statusList = new ArrayList<>(1);
statusList.add(OrderStatus.WAITING_PAY.getCode());
int cnt = buyerOrderMapper.selectCntByUidStatus(uid, statusList);
List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient(businessClientEnum);
int cnt = buyerOrderMapper.selectCntByUidStatus(uid, statusList, orderTypes);
if (cnt >= waitingPayCnt){
logger.warn("in ShoppingRiskWatchDog.checkWaitingPayCnt try monopolizing skup another time,uid {} waiting pay cnt {}",
uid, cnt);
... ...
... ... @@ -7,10 +7,7 @@ import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.constants.ChangePriceStatus;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohobuy.ufo.model.order.constants.OrderDetailDesc;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.constants.*;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.exception.UfoServiceException;
... ... @@ -150,7 +147,9 @@ public class ShoppingServiceImpl implements IShoppingService {
logger.warn("payment uid or skup is null");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
shoppingRiskWatchDog.checkWaitingPayCnt(uid);
BusinessClientEnum businessClientEnum;
businessClientEnum=OrderAssist.findBusinessClient(request.getBusinessClient());
shoppingRiskWatchDog.checkWaitingPayCnt(uid, businessClientEnum);
// 检查 商品sku是否可售
SellerOrderGoods skupGood = checkSkupSellOrNot(uid, request.getSkup());
GoodsPrepareData goodsPrepareData = checkSkupExtraWithlock(uid, skupGood, false);
... ... @@ -423,8 +422,8 @@ public class ShoppingServiceImpl implements IShoppingService {
logger.warn("submit param is null");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
shoppingRiskWatchDog.checkWaitingPayCnt(uid);
BusinessClientEnum businessClientEnum = OrderAssist.findBusinessClient(shoppingRequest.getBusinessClient());
shoppingRiskWatchDog.checkWaitingPayCnt(uid, businessClientEnum);
// 检查skup是否可售
SellerOrderGoods psog = checkSkupSellOrNot(uid, shoppingRequest.getSkup());
GoodsPrepareData goodsPrepareData = checkSkupExtraWithlock(uid, psog, true);
... ...
... ... @@ -13,6 +13,8 @@ import com.yohoufo.order.model.dto.ServiceFeeRate;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
... ... @@ -126,4 +128,17 @@ public class OrderAssist {
}
return businessClientCode;
}
private static final List<Integer> FLEAMARKET_CLIENT_ORDERTYPES = new ArrayList<Integer>(){
{
add(OrderAttributes.COMMON_IN_STOCK.getCode());
}
};
public static List<Integer> matchOrderTypesByBusinessClient(BusinessClientEnum businessClientEnum){
if (Objects.nonNull(businessClientEnum)
&& BusinessClientEnum.TAOBAO_FLEAMARKET_CLIENT.equals(businessClientEnum)){
return FLEAMARKET_CLIENT_ORDERTYPES;
}
return null;
}
}
... ...