Authored by chenchao

get seller entry goods list

package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Created by chao.chen on 2018/12/19.
*/
public interface SellerOrderGoodsViewMapper {
int selectEntryCntByUidStatusGBSkc(@Param("uid")int uid, @Param("statusList") List<Integer> statusList);
List<SellerOrderGoods> selectEntryListByUidStatusGBSkc(@Param("uid")int uid,
@Param("statusList") List<Integer> statusList,
@Param("offset")Integer offset,
@Param("limit")Integer limit);
}
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yohoufo.dal.order.SellerOrderGoodsViewMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.SellerOrderGoods">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="product_id" jdbcType="INTEGER" property="productId" />
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="product_name" jdbcType="VARCHAR" property="productName" />
<result column="storage_id" jdbcType="INTEGER" property="storageId" />
<result column="depot_no" jdbcType="INTEGER" property="depotNo" />
<result column="size_id" jdbcType="INTEGER" property="sizeId" />
<result column="size_name" jdbcType="VARCHAR" property="sizeName" />
<result column="color_id" jdbcType="SMALLINT" property="colorId" />
<result column="color_name" jdbcType="VARCHAR" property="colorName" />
<result column="goods_price" jdbcType="DECIMAL" property="goodsPrice" />
<result column="status" jdbcType="TINYINT" property="status" />
<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" />
</resultMap>
<sql id="Base_Column_List">
id, uid, product_id, product_name, storage_id, depot_no, size_id, size_name,
color_id, color_name, goods_price, status, image_url, is_del, batch_no
</sql>
<select id="selectEntryCntByUidStatusGBSkc" resultType="java.lang.Integer">
SELECT COUNT(*) from (select sog.id 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>
GROUP BY sog.uid,product_id) t
</select>
<sql id="Base_Column_List_with_table_name">
sog.id as id, sog.uid as uid, product_id, product_name,storage_id,depot_no,size_id,size_name,
color_id, color_name, goods_price, sog.status as status, image_url, sog.is_del as is_del, batch_no
</sql>
<select id="selectEntryListByUidStatusGBSkc" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List_with_table_name" /> 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>
GROUP BY sog.uid,product_id ORDER BY id DESC
limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.service.impl.SkupListService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* Created by chao.chen on 2018/12/19.
*/
@Controller
public class SellerGoodsController {
private final Logger logger = LoggerUtils.getSellerOrderLogger();
@Autowired
private SkupListService skupListService;
@RequestMapping(params = "method=ufo.seller.entryPrdList")
@ResponseBody
public ApiResponse getEntryGoodsList(@RequestParam("type") int type,
@RequestParam("uid") int uid,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
OrderListRequest orderListRequest = OrderListRequest.builder()
.uid(uid)
.type(type)
.page(page)
.limit(limit)
.build();
logger.info("ufo.seller.entryPrdList orderListRequest {}", orderListRequest);
PageResp<OrderListInfo> orderListInfoRsp;
orderListInfoRsp = skupListService.getEntryGoodsList(orderListRequest);
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("卖家订单列表").build();
}
@RequestMapping(params = "method=ufo.seller.notEntryPrdList")
@ResponseBody
public ApiResponse getNotEntryGoodsList(@RequestParam("type") int type,
@RequestParam("uid") int uid,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
OrderListRequest orderListRequest = OrderListRequest.builder()
.uid(uid)
.type(type)
.page(page)
.limit(limit)
.build();
logger.info("ufo.seller.notEntryPrdList orderListRequest {}", orderListRequest);
PageResp<OrderListInfo> orderListInfoRsp;
orderListInfoRsp = skupListService.getNotEntryGoodsList(orderListRequest);
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("卖家订单列表").build();
}
@RequestMapping(params = "method=ufo.seller.entryGoodsSizeList")
@ResponseBody
public ApiResponse getEntryGoodsSizeList(@RequestParam("type") int type,
@RequestParam("uid") int uid,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
OrderListRequest orderListRequest = OrderListRequest.builder()
.uid(uid)
.type(type)
.page(page)
.limit(limit)
.build();
logger.info("ufo.seller.entryGoodsSizeList orderListRequest {}", orderListRequest);
PageResp<OrderListInfo> orderListInfoRsp;
orderListInfoRsp = skupListService.getEntryGoodsSizeList(orderListRequest);
return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("卖家订单列表").build();
}
}
... ...
... ... @@ -19,6 +19,7 @@ import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.service.impl.SellerService;
import com.yohoufo.order.service.impl.SkupListService;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.kafka.common.requests.LeaderAndIsrRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -39,7 +40,7 @@ import java.util.Objects;
public class SellerOrderController {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final Logger logger = LoggerUtils.getSellerOrderLogger();
@Autowired
private SellerOrderService sellerOrderService;
... ...
... ... @@ -5,8 +5,8 @@ import com.yohobuy.ufo.model.order.common.SellerOrderListType;
import com.yohobuy.ufo.model.order.common.SellerType;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.vo.OrderListVo;
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;
... ... @@ -20,7 +20,6 @@ import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
/**
* Created by chao.chen on 2018/12/13.
... ... @@ -44,6 +43,9 @@ public class SkupListService {
@Autowired
private SellerOrderListService sellerOrderListService;
@Autowired
private SellerOrderGoodsViewMapper sellerOrderGoodsViewMapper;
static Integer getMinSkupId(String skupList){
Integer lastSkup = null;
if (StringUtils.isNotBlank(skupList)){
... ... @@ -96,5 +98,58 @@ public class SkupListService {
}
public PageResp<OrderListInfo> getEntryGoodsList(OrderListRequest request){
PageResp.PageRespBuilder respBuilder;
int limit = request.getLimit();
respBuilder = PageResp.builder()
.page(request.getPage())
.pageSize(limit);
int type;
if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()) {
List<Integer> statusList = sellerOrderListService.initOrderListRequest(request);
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSkc(request.getUid(), statusList);
respBuilder.total(total)
.pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1));
if (total == 0){
return respBuilder.build();
}
int offset = (request.getPage() - 1) * limit;
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSkc(request.getUid(),
statusList, offset , limit);
if (CollectionUtils.isEmpty(sogList)){
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);
respBuilder.data(data);
}
return respBuilder.build();
}
public PageResp<OrderListInfo> getNotEntryGoodsList(OrderListRequest request){
PageResp.PageRespBuilder respBuilder;
int limit = request.getLimit();
respBuilder = PageResp.builder()
.page(request.getPage())
.pageSize(limit);
return respBuilder.build();
}
public PageResp<OrderListInfo> getEntryGoodsSizeList(OrderListRequest request){
PageResp.PageRespBuilder respBuilder;
int limit = request.getLimit();
respBuilder = PageResp.builder()
.page(request.getPage())
.pageSize(limit);
return respBuilder.build();
}
}
... ...
... ... @@ -60,6 +60,7 @@ datasources:
- com.yohoufo.dal.order.StoredSellerMapper
- com.yohoufo.dal.order.SuperEntrySellerMapper
- com.yohoufo.dal.order.QiniuLiveRecordMapper
- com.yohoufo.dal.order.SellerOrderGoodsViewMapper
ufo_promotion:
servers:
... ...
... ... @@ -60,6 +60,7 @@ datasources:
- com.yohoufo.dal.order.StoredSellerMapper
- com.yohoufo.dal.order.SuperEntrySellerMapper
- com.yohoufo.dal.order.QiniuLiveRecordMapper
- com.yohoufo.dal.order.SellerOrderGoodsViewMapper
ufo_promotion:
servers:
... ...