Authored by Lixiaodi

Merge branch 'dev' of http://git.yoho.cn/ufo/yohoufo-fore into dev

... ... @@ -309,9 +309,7 @@
<select id="selectListBySellerUidStatus" resultMap="BaseResultMap">
select
count(1)
from buyer_order
select <include refid="Base_Column_List" /> from buyer_order
where <include refid="sql_where_4_select_SellerUidStatus"/>
limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
... ...
package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.common.TabType;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
import com.yohoufo.order.model.response.OrderListInfoRsp;
import com.yohoufo.order.model.response.OrderListInfo;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.impl.SellerOrderService;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -57,7 +58,7 @@ public class BuyerOrderController {
.tabType(tabType)
.actor(actor)
.build();
OrderListInfoRsp orderListInfoRsp;
PageResp<OrderListInfo> orderListInfoRsp;
switch (actor){
case BUY:
orderListInfoRsp = buyerOrderService.getOrderList(orderListRequest);
... ...
package com.yohoufo.order.model.response;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrderListInfoRsp {
List<OrderListInfo> data;
// 页码
private int currPage;
// 每页记录数
private int limit;
// 总记录数
private int total;
// 当前页记录数
private int currTotal;
// 页数
private int pageSize;
}
package com.yohoufo.order.service;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.response.OrderListInfoRsp;
import com.yohoufo.order.model.response.OrderListInfo;
/**
* Created by chenchao on 2018/9/19.
... ... @@ -13,5 +14,5 @@ public interface IOrderListService {
* @param request
* @return
*/
OrderListInfoRsp getOrderList(OrderListRequest request);
PageResp<OrderListInfo> getOrderList(OrderListRequest request);
}
... ...
package com.yohoufo.order.service.impl;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
... ... @@ -10,7 +11,6 @@ import com.yohoufo.order.common.TabType;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.response.GoodsInfo;
import com.yohoufo.order.model.response.OrderListInfo;
import com.yohoufo.order.model.response.OrderListInfoRsp;
import com.yohoufo.order.service.IOrderListService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -44,20 +44,18 @@ public abstract class AbsOrderListService implements IOrderListService{
* @return
*/
@Override
public OrderListInfoRsp getOrderList(OrderListRequest request){
public PageResp<OrderListInfo> getOrderList(OrderListRequest request){
// check and init请求参数
List<Integer> statusQuery = initOrderListRequest(request);
TabType actor = request.getActor();
int total = getTotal(request.getUid(), statusQuery);
int limit = request.getLimit();
int currentTotal = 0;
OrderListInfoRsp.OrderListInfoRspBuilder respBuilder = OrderListInfoRsp.builder()
.currPage(request.getPage())
.limit(limit)
PageResp.PageRespBuilder respBuilder = PageResp.builder()
.page(request.getPage())
.pageSize(limit)
.total(total)
.currTotal(currentTotal)
.pageSize((total % limit == 0) ? (total / limit) : (total / limit + 1));
.pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1));
if (total == 0){
return respBuilder.build();
}
... ... @@ -86,7 +84,7 @@ public abstract class AbsOrderListService implements IOrderListService{
data.add(orderListInfo);
});
OrderListInfoRsp orderListInfoRsp = respBuilder.data(data).currTotal(data.size()).build();
PageResp orderListInfoRsp = respBuilder.data(data).build();
return orderListInfoRsp;
... ...
... ... @@ -2,34 +2,22 @@ package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.common.utils.DateUtil;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.BuyerOrderMetaMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.BuyerOrderMeta;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.common.OrderListType;
import com.yohoufo.order.common.OrderStatus;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.common.TabType;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.constants.OrderConstant;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.GoodsInfo;
import com.yohoufo.order.model.response.OrderDetailInfo;
import com.yohoufo.order.model.response.OrderListInfoRsp;
import com.yohoufo.order.service.IBuyerOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BuyerOrderServiceImpl implements IBuyerOrderService {
... ... @@ -115,20 +103,13 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
@Override
public OrderDetailInfo getOrderDetail(OrderRequest orderRequest) {
return buyerOrderDetailService.getOrderDetail(orderRequest);
}
@Override
public OrderListInfoRsp getOrderList(OrderListRequest request) {
public PageResp getOrderList(OrderListRequest request) {
return buyerOrderListService.getOrderList(request);
}
}
... ...
... ... @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
... ... @@ -16,7 +17,6 @@ import com.yohoufo.order.common.SellerOrderStatus;
import com.yohoufo.order.common.SkupStatus;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.response.OrderListInfo;
import com.yohoufo.order.model.response.OrderListInfoRsp;
import com.yohoufo.order.service.IOrderListService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -46,20 +46,18 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Override
public OrderListInfoRsp getOrderList(OrderListRequest request){
public PageResp<OrderListInfo> getOrderList(OrderListRequest request){
int type;
if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()){
List<Integer> statusList = initOrderListRequest(request);
int total = sellerOrderGoodsMapper.selectCntByUidStatusList(request.getUid(), statusList);
int limit = request.getLimit();
int currentTotal = 0;
OrderListInfoRsp.OrderListInfoRspBuilder respBuilder = OrderListInfoRsp.builder()
.currPage(request.getPage())
.limit(limit)
PageResp.PageRespBuilder respBuilder = PageResp.builder()
.page(request.getPage())
.pageSize(limit)
.total(total)
.currTotal(currentTotal)
.pageSize((total % limit == 0) ? (total / limit) : (total / limit + 1));
.pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1));
if (total == 0){
return respBuilder.build();
}
... ... @@ -74,7 +72,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
.map(sellerOrder -> buildOrderListInfo(skupSellerOrderGoodsMap.get(sellerOrder.getSkup()), sellerOrder))
.collect(Collectors.toList());
OrderListInfoRsp orderListInfoRsp = respBuilder.data(data).currTotal(data.size()).build();
PageResp orderListInfoRsp = respBuilder.data(data).build();
return orderListInfoRsp;
}else{
return super.getOrderList(request);
... ...
package com.yohoufo.order.service.impl;
import com.yoho.service.model.response.UserAddressRspBO;
import com.yohobuy.ufo.model.order.bo.PlatformFee;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.common.utils.PriceFormater;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.order.common.OrderCodeType;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.AddressInfo;
import com.yohoufo.order.model.GoodsInfo;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.model.dto.PlatformFeeDto;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
import com.yohoufo.order.model.response.OrderListInfoRsp;
import com.yohoufo.order.model.response.OrderListInfo;
import com.yohoufo.order.service.IOrderDetailService;
import com.yohoufo.order.service.IOrderListService;
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
... ... @@ -280,7 +274,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
@Override
public OrderListInfoRsp getOrderList(OrderListRequest request){
public PageResp<OrderListInfo> getOrderList(OrderListRequest request){
return sellerOrderListService.getOrderList(request);
}
... ...
... ... @@ -44,13 +44,12 @@ public class ProductController {
@Cachable(expire = 300)
public ApiResponse queryProductDetailById(
@RequestParam(value = "product_id") Integer productId) {
if (null == productId) {
LOG.info("in method=ufo.product.data product_id Is Null");
return new ApiResponse(400, "product_id Is Null", null);
}
LOG.info("in method=ufo.product.data product_id={}", productId);
ProductDetailResp resp = productService.queryProductDetailById(productId);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build();
}
... ... @@ -63,8 +62,10 @@ public class ProductController {
@RequestParam(value = "product_ids") String productIds) {
if (StringUtils.isBlank(productIds)) {
LOG.info("in method=ufo.product.series.template product_ids Is Null or empty");
return new ApiResponse(400, "productIds Is Null", null);
}
LOG.info("in method=ufo.product.series.template product_ids={}", productIds);
ProductSeriesTemplateResp resp = productService.querySeriesTemplateData(productIds);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build();
}
... ... @@ -78,8 +79,10 @@ public class ProductController {
@RequestParam(value = "product_ids") String productIds) {
if (StringUtils.isBlank(productIds)) {
LOG.info("in method=ufo.product.sort.template product_ids Is Null or empty");
return new ApiResponse(400, "productIds Is Null", null);
}
LOG.info("in method=ufo.product.sort.template product_ids={}", productIds);
ProductSortTemplateResp resp = productService.querySortTemplateData(productIds);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build();
}
... ... @@ -88,11 +91,13 @@ public class ProductController {
@RequestMapping(params = "method=ufo.product.storage.leastprice")
@Cachable(expire = 300)
public StorageLeastPriceResp queryStorageLeastprice(
@RequestParam(value = "storage_id", required = true) Integer storageId) {
@RequestParam(value = "storage_id") Integer storageId) {
if (storageId == null) {
LOG.info("in method=ufo.product.storage.leastprice storage_id Is Null");
return null;
}
LOG.info("in method=ufo.product.storage.leastprice storage_id={}", storageId);
return productService.queryStorageLeastPrice(storageId);
}
... ... @@ -101,11 +106,13 @@ public class ProductController {
@RequestMapping(params = "method=ufo.product.storage.data")
@Cachable(expire = 300)
public StorageDataResp queryStorageInfo(
@RequestParam(value = "storage_id", required = true) Integer storageId) {
@RequestParam(value = "storage_id") Integer storageId) {
if (storageId == null) {
LOG.info("in method=ufo.product.storage.data storage_id Is Null");
return null;
}
LOG.info("in method=ufo.product.storage.data storage_id={}", storageId);
return productService.queryStorageInfo(storageId);
}
... ...
... ... @@ -53,6 +53,8 @@ public class ProductSearchController {
ProductSearchReq req = new ProductSearchReq().setOrder(order).setPool(productPool).setBrand(brand).setMidSort(sortIdLevel.getMidSortId()).setMaxSort(sortIdLevel.getMaxSortId())
.setSeries(series).setGender(gender).setSize(size).setIsSoonSale(isSoonSale).setViewNum(limit).setPage(page);
searchHelpService.setQuery(query, req);
LOG.info("in method=ufo.product.search.list req={}", req.toString());
JSONObject resp = productSearchService.searchProductList(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build();
}
... ... @@ -65,8 +67,10 @@ public class ProductSearchController {
public ApiResponse searchProductRecommendById(@RequestParam(value = "product_id") Integer productId) {
if (null == productId) {
LOG.info("in method=ufo.product.data.search.recommend product_id is null");
return new ApiResponse(400, "product_id Is Null", null);
}
LOG.info("in method=ufo.product.data.search.recommend product_id={}", productId);
SearchProductRecommendResp resp = productSearchService.searchProductRecommendById(productId);
return new ApiResponse.ApiResponseBuilder().code(200).message("product.data.search.recommend").data(resp).build();
}
... ... @@ -92,9 +96,9 @@ public class ProductSearchController {
ProductSearchReq req = new ProductSearchReq().setPool(productPool).setBrand(brand).setMidSort(sortIdLevel.getMidSortId()).setMaxSort(sortIdLevel.getMaxSortId())
.setSeries(series).setGender(gender).setSize(size).setIsSoonSale(isSoonSale);
searchHelpService.setQuery(query, req);
LOG.info("in method=ufo.product.search.list req={}", req.toString());
SearchProductListFilterResp resp = productSearchService.searchProductListFilter(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.list.filter").data(resp).build();
}
... ...
package com.yohoufo.product.request;
import org.apache.commons.lang3.builder.ToStringBuilder;
public class ProductSearchReq {
private Integer id;
... ... @@ -18,6 +20,26 @@ public class ProductSearchReq {
private String not_id;
@Override
public String toString() {
return new ToStringBuilder(this)
.append("page", page)
.append("order", order)
.append("gender", gender)
.append("viewNum", viewNum)
.append("brand", brand)
.append("size", size)
.append("query", query)
.append("maxSort", maxSort)
.append("midSort", midSort)
.append("series", series)
.append("pool", pool)
.append("isSoonSale", isSoonSale)
.append("not_id", not_id)
.toString();
}
public Integer getId() {
return id;
}
... ... @@ -144,4 +166,5 @@ public class ProductSearchReq {
this.not_id = not_id;
return this;
}
}
... ...
... ... @@ -67,14 +67,19 @@ public class ProductServiceImpl implements ProductService{
productInfo.setLeastPrice(new BigDecimal(0));
setBrand(productInfo, product.getBrandId());
setSeries(productInfo, product.getSeriesId());
productInfo.setLeastPrice(null);
List<GoodsBO> goodsBOList = getGoodsList(product.getId());
if (!CollectionUtils.isEmpty(goodsBOList) && goodsBOList.get(0) != null) {
GoodsBO goodsBO = goodsBOList.get(0);
List<GoodsSize> goodsSizes = goodsBO.getSizeList();
if (!CollectionUtils.isEmpty(goodsSizes)) {
BigDecimal leastPrice = goodsSizes.stream().map(GoodsSize::getLeastPrice).filter(Objects::nonNull).min((p1, p2) -> (p1.compareTo(p2))).get();
productInfo.setLeastPrice(leastPrice);
List<BigDecimal> leastPriceList = goodsSizes.stream().map(GoodsSize::getLeastPrice).filter(Objects::nonNull).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(leastPriceList)) {
BigDecimal leastPrice = leastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
productInfo.setLeastPrice(leastPrice);
}
goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy));
}
}
... ...
... ... @@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
... ... @@ -38,7 +39,7 @@ public class ProductQueryServiceImpl implements IProductQueryService {
logger.info("begin invoke ufo.product.series.template, param is:{}", params);
ApiResponse apiResponse = ufoServiceCaller.call(SERIES_METHOD, ApiResponse.class, params);
if (null != apiResponse && apiResponse.getCode() == 200) {
JSONObject productSeriesJSON = (JSONObject) apiResponse.getData();
JSONObject productSeriesJSON = (JSONObject) JSON.toJSON(apiResponse.getData());
if (null != productSeriesJSON && null != productSeriesJSON.get("list")) {
data = productSeriesJSON.getJSONArray("list");
}
... ... @@ -83,7 +84,7 @@ public class ProductQueryServiceImpl implements IProductQueryService {
logger.info("begin invoke ufo.product.sort.template, param is:{}", params);
ApiResponse apiResponse = ufoServiceCaller.call(CATEGORY_METHOD, ApiResponse.class, params);
if (null != apiResponse && apiResponse.getCode() == 200) {
JSONObject productCategoryJSON = (JSONObject) apiResponse.getData();
JSONObject productCategoryJSON = (JSONObject) JSON.toJSON(apiResponse.getData());
if (null != productCategoryJSON) {
data = productCategoryJSON;
}
... ...