Authored by chenchao

add list refresh

... ... @@ -62,4 +62,8 @@ public interface SellerOrderGoodsMapper {
List<SellerOrderGoods> selectGPByBNStatusPrice(SellerOrderGoods condition);
int batchDelete(@Param("skups") Collection<Integer> skups);
List<SellerOrderGoods> selectByUidBNStatusGBBPSList(@Param("uid")int uid,
@Param("batchNo")Long batchNo,
@Param("statusList") List<Integer> statusList);
}
\ No newline at end of file
... ...
... ... @@ -367,4 +367,10 @@
</foreach>
</update>
<select id="selectByUidBNStatusGBBPSList" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />,count(*) num,GROUP_CONCAT(id) skup_list from seller_order_goods
where batch_no = #{batchNo,jdbcType=BIGINT}
and <include refid="sql_where_4_select_UidStatusGBBNList"/>
order by id desc
</select>
</mapper>
\ No newline at end of file
... ...
package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.req.*;
import com.yohobuy.ufo.model.order.resp.BatchChangePriceResp;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
import com.yohoufo.order.service.impl.SellerOrderService;
import org.apache.kafka.common.requests.LeaderAndIsrRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -20,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Objects;
/**
* Created by chenchao on 2018/9/13.
*/
... ... @@ -233,4 +242,41 @@ public class SellerOrderController {
return new ApiResponse.ApiResponseBuilder().code(200).data(computeBo).message("算费成功").build();
}
@RequestMapping(params = "method=ufo.order.refresh")
@ResponseBody
public ApiResponse refresh(@RequestParam("type") int type,
@RequestParam("uid") int uid,
@RequestParam("tabType") String tabType,
@RequestParam(value = "orderCode") long orderCode) {
TabType actor = TabType.getTabType(tabType);
if (Objects.isNull(actor)){
return new ApiResponse.ApiResponseBuilder().code(400).message("非法的tab").build();
}
OrderRequest orderRequest = OrderRequest.builder()
.uid(uid)
.type(type)
.tabType(tabType)
.actor(actor)
.orderCode(orderCode)
.build();
logger.info("in ufo.order.refresh, req {}", orderRequest);
List<OrderListInfo> orderListInfoRsp = null;
switch (actor){
case BUY:
break;
case SELL:
orderListInfoRsp = sellerOrderService.refresh(orderRequest);
break;
default:
orderListInfoRsp = null;
}
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("刷新成功").build();
}
}
... ...
... ... @@ -16,6 +16,8 @@ public class OrderRequest {
long orderCode;
int type;
String tabType;
TabType actor;
... ...
... ... @@ -74,6 +74,24 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
@Autowired
private SellerOrderPrepareProcessor sellerOrderPrepareProcessor;
public List<OrderListInfo> buildOrderList(List<SellerOrderGoods> sogList, SellerType sellerType){
sogList.stream().forEach(item -> {
item.setImageUrl(ImageUrlAssist.getAllProductPicUrl(item.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
});
Map<String, String> overPriceTipsMap = buildOverPriceTipsMap(sogList);
Map<Integer, SellerOrderGoods> skupSellerOrderGoodsMap = sogList.parallelStream()
.collect(Collectors.toMap(SellerOrderGoods::getId, (SellerOrderGoods sog) -> sog));
List<Integer> skupList = sogList.parallelStream().map(SellerOrderGoods::getId).collect(Collectors.toList());
List<SellerOrder> sellerOrders = sellerOrderMapper.selectBySkups(skupList);
List<OrderListInfo> data ;
data = sellerOrders.parallelStream()
.map(sellerOrder -> buildOrderListInfo(skupSellerOrderGoodsMap.get(sellerOrder.getSkup()),
sellerOrder, sellerType, overPriceTipsMap))
.filter(oli -> Objects.nonNull(oli))
.collect(Collectors.toList());
return data;
}
@Override
public PageResp<OrderListInfo> getOrderList(OrderListRequest request){
OrderListVo orderListVo = orderCacheService.getOrderListInfos(request);
... ... @@ -92,8 +110,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
int type;
if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()){
List<Integer> statusList = initOrderListRequest(request);
boolean isEntry = userProxyService.isEntryShop(request.getUid());
final SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON;
int total = sellerOrderGoodsMapper.selectCntByUidStatusGBBNList(request.getUid(), statusList);
int limit = request.getLimit();
respBuilder = PageResp.builder()
... ... @@ -112,23 +129,10 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
log.warn("seller get order list SellerOrderGoods is empty,req {}", request);
return respBuilder.build();
}
sogList.stream().forEach(item -> {
item.setImageUrl(ImageUrlAssist.getAllProductPicUrl(item.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
});
Map<String, String> overPriceTipsMap = buildOverPriceTipsMap(sogList);
Map<Integer, SellerOrderGoods> skupSellerOrderGoodsMap = sogList.parallelStream()
.collect(Collectors.toMap(SellerOrderGoods::getId, (SellerOrderGoods sog) -> sog));
List<Integer> skupList = sogList.parallelStream().map(SellerOrderGoods::getId).collect(Collectors.toList());
List<SellerOrder> sellerOrders = sellerOrderMapper.selectBySkups(skupList);
List<OrderListInfo> data ;
data = sellerOrders.parallelStream()
.map(sellerOrder -> buildOrderListInfo(skupSellerOrderGoodsMap.get(sellerOrder.getSkup()),
sellerOrder, sellerType, overPriceTipsMap))
.filter(oli -> Objects.nonNull(oli))
.collect(Collectors.toList());
boolean isEntry = userProxyService.isEntryShop(request.getUid());
final SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON;
List<OrderListInfo> data = buildOrderList(sogList, sellerType);
orderListInfoRsp = respBuilder.data(data).build();
}else{
orderListInfoRsp = super.getOrderList(request);
}
... ...
... ... @@ -57,6 +57,7 @@ import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase;
import com.yohoufo.order.service.impl.visitor.UserCancelCase;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import com.yohoufo.order.utils.LoggerUtils;
... ... @@ -138,6 +139,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
@Autowired
private SellerFeeService sellerFeeService;
@Autowired
private UserProxyService userProxyService;
public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException {
... ... @@ -705,7 +708,48 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
return total;
}
public List<OrderListInfo> refresh(){
public List<OrderListInfo> refresh(OrderRequest req){
int uid = req.getUid();
if(uid <= 0){
log.warn("seller refresh uid illegal , req {}", req);
throw new UfoServiceException(400, "用户ID错误");
}
long orderCode = req.getOrderCode();
if(orderCode <= 0L){
log.warn("seller refresh orderCode illegal , req {}", req);
throw new UfoServiceException(400, "订单号错误");
}
CodeMeta codeMeta = orderCodeGenerator.expId(orderCode);
if (Objects.isNull(codeMeta)){
log.warn("seller refresh orderCode illegal, req {}", req);
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
int type = req.getType();
SellerOrderListType solt = SellerOrderListType.getOrderListType(type);
if (solt == null){
log.warn("seller refresh type illegal, req {}", req);
throw new UfoServiceException(400, "type错误");
}
if(OrderCodeType.SELLER_TYPE.getType() == codeMeta.getType()){
SellerOrder pso = sellerOrderMapper.selectByOrderCodeUid(orderCode, uid);
if (pso == null){
log.warn("seller refresh SellerOrder is null,req {}", req);
return null;
}
int skup = pso.getSkup();
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
Long bn = psog.getBatchNo();
List<SellerOrderGoods> psogList = sellerOrderGoodsMapper.selectByUidBNStatusGBBPSList(uid, bn, solt.getStatus());
if (CollectionUtils.isEmpty(psogList)){
log.warn("seller refresh,SellerOrderGoods is empty,req {} bn {} status {}", req, bn, solt.getStatus());
return null;
}
boolean isEntry = userProxyService.isEntryShop(uid);
final SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON;
log.info("seller refresh ready 2 buildOrderList req {}", req);
return sellerOrderListService.buildOrderList(psogList,sellerType);
}
return null;
}
... ...