Authored by chenchao

add get entry goods list

... ... @@ -16,4 +16,9 @@ public interface SellerOrderGoodsViewMapper {
@Param("statusList") List<Integer> statusList,
@Param("offset")Integer offset,
@Param("limit")Integer limit);
SellerOrderGoods selectByUidStatusGBSkc(@Param("uid")int uid,
@Param("statusList") List<Integer> statusList,
@Param("productId")Integer productId);
}
... ...
package com.yohoufo.dal.order.model;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
public class SellerOrderGoods {
... ... @@ -39,6 +42,12 @@ public class SellerOrderGoods {
private String skupList;
@Getter@Setter
private Integer sizeNum;
@Getter@Setter
private Integer storageNum;
public String getImageUrl() {
return imageUrl;
}
... ...
... ... @@ -17,8 +17,8 @@
<result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
<result column="is_del" jdbcType="TINYINT" property="isDel" />
<result column="batch_no" jdbcType="BIGINT" property="batchNo" />
<result column="num" jdbcType="INTEGER" property="num" />
<result column="skup_list" jdbcType="VARCHAR" property="skupList" />
<result column="storage_num" jdbcType="INTEGER" property="storageNum" />
<result column="size_num" jdbcType="INTEGER" property="sizeNum" />
</resultMap>
<sql id="Base_Column_List">
id, uid, product_id, product_name, storage_id, depot_no, size_id, size_name,
... ... @@ -55,4 +55,21 @@
GROUP BY sog.uid,product_id ORDER BY id DESC
limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
<select id="selectByUidStatusGBSkc" resultMap="BaseResultMap">
SELECT `uid`,`product_id`,`product_name`,`color_id`,`color_name`,COUNT(size_id) size_num,SUM(size_storage) storage_num FROM
(
SELECT sog.`uid`,`product_id`,`product_name`,`color_id`,`color_name`,size_id,COUNT(`size_id`) size_storage
FROM seller_order_goods sog,seller_order so
WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER} and sog.is_del = 1 AND so.payment = 11
<if test="statusList != null">
and sog.status in
<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
#{status, jdbcType=TINYINT}
</foreach>
</if>
AND product_id = #{productId,jdbcType=INTEGER}
GROUP BY sog.uid,size_id
) t
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -2,8 +2,10 @@ package com.yohoufo.order.controller;
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.ApiResponse;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.SellerGoodsListRequest;
import com.yohoufo.order.service.impl.SkupListService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
... ... @@ -66,18 +68,18 @@ public class SellerGoodsController {
@RequestMapping(params = "method=ufo.seller.entryGoodsSizeList")
@ResponseBody
public ApiResponse getEntryGoodsSizeList(@RequestParam("type") int type,
@RequestParam("uid") int uid,
public ApiResponse getEntryGoodsSizeList(@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) {
OrderListRequest orderListRequest = OrderListRequest.builder()
SellerGoodsListRequest orderListRequest = SellerGoodsListRequest.builder()
.uid(uid)
.type(type)
.productId(productId)
.page(page)
.limit(limit)
.build();
logger.info("ufo.seller.entryGoodsSizeList orderListRequest {}", orderListRequest);
PageResp<OrderListInfo> orderListInfoRsp;
SellerGoodsPageResp<OrderListInfo> orderListInfoRsp;
orderListInfoRsp = skupListService.getEntryGoodsSizeList(orderListRequest);
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("卖家订单列表").build();
}
... ...
package com.yohoufo.order.model.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
/**
* Created by chao.chen on 2018/12/20.
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SellerGoodsListRequest {
private int uid;
private Integer productId;
private int page;
private int limit;
}
... ...
... ... @@ -765,7 +765,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}
boolean isEntry = userProxyService.isEntryShop(uid);
final SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON;
log.info("seller refresh ready 2 buildOrderList req {}", req);
log.info("seller refresh ready 2 buildProductList req {}", req);
List<OrderListInfo> list = sellerOrderListService.buildOrderList(psogList,sellerType);
return SellerOrderListResp.builder().orderListInfos(list).batchNo(bn).build();
}
... ...
package com.yohoufo.order.service.impl;
import com.google.common.base.Splitter;
import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
import com.yohobuy.ufo.model.order.bo.ProductInfo;
import com.yohobuy.ufo.model.order.common.ButtonShow;
import com.yohobuy.ufo.model.order.common.SellerOrderListType;
import com.yohobuy.ufo.model.order.common.SellerType;
import com.yohobuy.ufo.model.order.common.SkupStatus;
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.helper.ImageUrlAssist;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.SellerOrderGoodsViewMapper;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.model.request.SellerGoodsListRequest;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -18,8 +24,11 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* Created by chao.chen on 2018/12/13.
... ... @@ -33,8 +42,6 @@ public class SkupListService {
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
private OrderCacheService orderCacheService;
@Autowired
private UserProxyService userProxyService;
... ... @@ -106,7 +113,7 @@ public class SkupListService {
.pageSize(limit);
int type;
if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()) {
List<Integer> statusList = sellerOrderListService.initOrderListRequest(request);
List<Integer> statusList = Arrays.asList(SkupStatus.CAN_SELL.getCode());
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSkc(request.getUid(), statusList);
respBuilder.total(total)
.pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1));
... ... @@ -120,9 +127,7 @@ public class SkupListService {
logger.warn("seller get entry order list SellerOrderGoods is empty,req {}", request);
return respBuilder.build();
}
boolean isEntry = userProxyService.isEntryShop(request.getUid());
final SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON;
List<OrderListInfo> data = sellerOrderListService.buildOrderList(sogList, sellerType);
List<OrderListInfo> data = buildProductList(sogList, statusList);
respBuilder.data(data);
}
... ... @@ -142,14 +147,60 @@ public class SkupListService {
public PageResp<OrderListInfo> getEntryGoodsSizeList(OrderListRequest request){
PageResp.PageRespBuilder respBuilder;
public SellerGoodsPageResp<OrderListInfo> getEntryGoodsSizeList(SellerGoodsListRequest request){
SellerGoodsPageResp.SGPRBuilder respBuilder;
int limit = request.getLimit();
respBuilder = PageResp.builder()
respBuilder = SellerGoodsPageResp.builder()
.page(request.getPage())
.pageSize(limit);
return respBuilder.build();
}
public List<OrderListInfo> buildProductList(List<SellerOrderGoods> sogList, List<Integer> statusList){
List<OrderListInfo> data ;
data = sogList.parallelStream()
.map(sog -> buildOrderListInfo(sog, statusList))
.filter(oli -> Objects.nonNull(oli))
.collect(Collectors.toList());
return data;
}
OrderListInfo buildOrderListInfo(SellerOrderGoods sellerOrderGoods, List<Integer> statusList) {
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 {}",
uid, orderListInfo.getOrderCode(), sellerOrderGoods.getStatus());
return null;
}
// 订单中状态显示
orderListInfo.setStatus(skupStatus.getCode());
orderListInfo.setStatuStr(skupStatus.getDesc());
// 按钮显示
List<ButtonShowBo> buttons = Arrays.asList(ButtonShow.STORAGE_MANAGE.getBo());
orderListInfo.setButtons(buttons);
//
ProductInfo productInfo = new ProductInfo();
productInfo.setColorName(sellerOrderGoods.getColorName());
productInfo.setProductName(sellerOrderGoods.getProductName());
String imageUrl = ImageUrlAssist.getAllProductPicUrl(sellerOrderGoods.getImageUrl(), "goodsimg", "center", "d2hpdGU=");
productInfo.setImageUrl(imageUrl);
Integer productId;
productInfo.setProductId(productId=sellerOrderGoods.getProductId());
//
SellerOrderGoods psogOfMerge = sellerOrderGoodsViewMapper.selectByUidStatusGBSkc(uid,statusList,productId);
if (psogOfMerge != null){
productInfo.setStorageNum(psogOfMerge.getStorageNum());
productInfo.setSizeNum(psogOfMerge.getSizeNum());
}
orderListInfo.setProductInfo(productInfo);
return orderListInfo;
}
}
... ...