Authored by chenchao

get seller entry goods list

  1 +package com.yohoufo.dal.order;
  2 +
  3 +import com.yohoufo.dal.order.model.SellerOrderGoods;
  4 +import org.apache.ibatis.annotations.Param;
  5 +
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * Created by chao.chen on 2018/12/19.
  10 + */
  11 +public interface SellerOrderGoodsViewMapper {
  12 +
  13 + int selectEntryCntByUidStatusGBSkc(@Param("uid")int uid, @Param("statusList") List<Integer> statusList);
  14 +
  15 + List<SellerOrderGoods> selectEntryListByUidStatusGBSkc(@Param("uid")int uid,
  16 + @Param("statusList") List<Integer> statusList,
  17 + @Param("offset")Integer offset,
  18 + @Param("limit")Integer limit);
  19 +}
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.yohoufo.dal.order.SellerOrderGoodsViewMapper">
  4 + <resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.SellerOrderGoods">
  5 + <id column="id" jdbcType="INTEGER" property="id" />
  6 + <result column="product_id" jdbcType="INTEGER" property="productId" />
  7 + <result column="uid" jdbcType="INTEGER" property="uid" />
  8 + <result column="product_name" jdbcType="VARCHAR" property="productName" />
  9 + <result column="storage_id" jdbcType="INTEGER" property="storageId" />
  10 + <result column="depot_no" jdbcType="INTEGER" property="depotNo" />
  11 + <result column="size_id" jdbcType="INTEGER" property="sizeId" />
  12 + <result column="size_name" jdbcType="VARCHAR" property="sizeName" />
  13 + <result column="color_id" jdbcType="SMALLINT" property="colorId" />
  14 + <result column="color_name" jdbcType="VARCHAR" property="colorName" />
  15 + <result column="goods_price" jdbcType="DECIMAL" property="goodsPrice" />
  16 + <result column="status" jdbcType="TINYINT" property="status" />
  17 + <result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
  18 + <result column="is_del" jdbcType="TINYINT" property="isDel" />
  19 + <result column="batch_no" jdbcType="BIGINT" property="batchNo" />
  20 + <result column="num" jdbcType="INTEGER" property="num" />
  21 + <result column="skup_list" jdbcType="VARCHAR" property="skupList" />
  22 + </resultMap>
  23 + <sql id="Base_Column_List">
  24 + id, uid, product_id, product_name, storage_id, depot_no, size_id, size_name,
  25 + color_id, color_name, goods_price, status, image_url, is_del, batch_no
  26 + </sql>
  27 +
  28 + <select id="selectEntryCntByUidStatusGBSkc" resultType="java.lang.Integer">
  29 + SELECT COUNT(*) from (select sog.id FROM seller_order_goods sog,seller_order so
  30 + WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER} and sog.is_del = 1
  31 + AND so.payment = 11
  32 + <if test="statusList != null">
  33 + and sog.status in
  34 + <foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
  35 + #{status, jdbcType=TINYINT}
  36 + </foreach>
  37 + </if>
  38 + GROUP BY sog.uid,product_id) t
  39 + </select>
  40 +
  41 + <sql id="Base_Column_List_with_table_name">
  42 + sog.id as id, sog.uid as uid, product_id, product_name,storage_id,depot_no,size_id,size_name,
  43 + color_id, color_name, goods_price, sog.status as status, image_url, sog.is_del as is_del, batch_no
  44 + </sql>
  45 +
  46 + <select id="selectEntryListByUidStatusGBSkc" resultMap="BaseResultMap">
  47 + SELECT <include refid="Base_Column_List_with_table_name" /> FROM seller_order_goods sog,seller_order so
  48 + WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER} and sog.is_del = 1 AND so.payment = 11
  49 + <if test="statusList != null">
  50 + and sog.status in
  51 + <foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
  52 + #{status, jdbcType=TINYINT}
  53 + </foreach>
  54 + </if>
  55 + GROUP BY sog.uid,product_id ORDER BY id DESC
  56 + limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
  57 + </select>
  58 +</mapper>
  1 +package com.yohoufo.order.controller;
  2 +
  3 +import com.yohobuy.ufo.model.order.resp.OrderListInfo;
  4 +import com.yohobuy.ufo.model.order.resp.PageResp;
  5 +import com.yohoufo.common.ApiResponse;
  6 +import com.yohoufo.order.model.request.OrderListRequest;
  7 +import com.yohoufo.order.service.impl.SkupListService;
  8 +import com.yohoufo.order.utils.LoggerUtils;
  9 +import org.slf4j.Logger;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Controller;
  12 +import org.springframework.web.bind.annotation.RequestMapping;
  13 +import org.springframework.web.bind.annotation.RequestParam;
  14 +import org.springframework.web.bind.annotation.ResponseBody;
  15 +
  16 +/**
  17 + * Created by chao.chen on 2018/12/19.
  18 + */
  19 +@Controller
  20 +public class SellerGoodsController {
  21 +
  22 +
  23 + private final Logger logger = LoggerUtils.getSellerOrderLogger();
  24 +
  25 +
  26 + @Autowired
  27 + private SkupListService skupListService;
  28 +
  29 +
  30 +
  31 + @RequestMapping(params = "method=ufo.seller.entryPrdList")
  32 + @ResponseBody
  33 + public ApiResponse getEntryGoodsList(@RequestParam("type") int type,
  34 + @RequestParam("uid") int uid,
  35 + @RequestParam(value = "page", required = false, defaultValue = "1") int page,
  36 + @RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
  37 + OrderListRequest orderListRequest = OrderListRequest.builder()
  38 + .uid(uid)
  39 + .type(type)
  40 + .page(page)
  41 + .limit(limit)
  42 + .build();
  43 + logger.info("ufo.seller.entryPrdList orderListRequest {}", orderListRequest);
  44 + PageResp<OrderListInfo> orderListInfoRsp;
  45 + orderListInfoRsp = skupListService.getEntryGoodsList(orderListRequest);
  46 + return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("卖家订单列表").build();
  47 + }
  48 +
  49 + @RequestMapping(params = "method=ufo.seller.notEntryPrdList")
  50 + @ResponseBody
  51 + public ApiResponse getNotEntryGoodsList(@RequestParam("type") int type,
  52 + @RequestParam("uid") int uid,
  53 + @RequestParam(value = "page", required = false, defaultValue = "1") int page,
  54 + @RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
  55 + OrderListRequest orderListRequest = OrderListRequest.builder()
  56 + .uid(uid)
  57 + .type(type)
  58 + .page(page)
  59 + .limit(limit)
  60 + .build();
  61 + logger.info("ufo.seller.notEntryPrdList orderListRequest {}", orderListRequest);
  62 + PageResp<OrderListInfo> orderListInfoRsp;
  63 + orderListInfoRsp = skupListService.getNotEntryGoodsList(orderListRequest);
  64 + return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("卖家订单列表").build();
  65 + }
  66 +
  67 + @RequestMapping(params = "method=ufo.seller.entryGoodsSizeList")
  68 + @ResponseBody
  69 + public ApiResponse getEntryGoodsSizeList(@RequestParam("type") int type,
  70 + @RequestParam("uid") int uid,
  71 + @RequestParam(value = "page", required = false, defaultValue = "1") int page,
  72 + @RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
  73 + OrderListRequest orderListRequest = OrderListRequest.builder()
  74 + .uid(uid)
  75 + .type(type)
  76 + .page(page)
  77 + .limit(limit)
  78 + .build();
  79 + logger.info("ufo.seller.entryGoodsSizeList orderListRequest {}", orderListRequest);
  80 + PageResp<OrderListInfo> orderListInfoRsp;
  81 + orderListInfoRsp = skupListService.getEntryGoodsSizeList(orderListRequest);
  82 + return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("卖家订单列表").build();
  83 + }
  84 +
  85 +
  86 +
  87 +}
@@ -19,6 +19,7 @@ import com.yohoufo.order.service.handler.SellerOrderComputeHandler; @@ -19,6 +19,7 @@ import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
19 import com.yohoufo.order.service.impl.SellerOrderService; 19 import com.yohoufo.order.service.impl.SellerOrderService;
20 import com.yohoufo.order.service.impl.SellerService; 20 import com.yohoufo.order.service.impl.SellerService;
21 import com.yohoufo.order.service.impl.SkupListService; 21 import com.yohoufo.order.service.impl.SkupListService;
  22 +import com.yohoufo.order.utils.LoggerUtils;
22 import org.apache.kafka.common.requests.LeaderAndIsrRequest; 23 import org.apache.kafka.common.requests.LeaderAndIsrRequest;
23 import org.slf4j.Logger; 24 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory; 25 import org.slf4j.LoggerFactory;
@@ -39,7 +40,7 @@ import java.util.Objects; @@ -39,7 +40,7 @@ import java.util.Objects;
39 public class SellerOrderController { 40 public class SellerOrderController {
40 41
41 42
42 - private final Logger logger = LoggerFactory.getLogger(getClass()); 43 + private final Logger logger = LoggerUtils.getSellerOrderLogger();
43 44
44 @Autowired 45 @Autowired
45 private SellerOrderService sellerOrderService; 46 private SellerOrderService sellerOrderService;
@@ -5,8 +5,8 @@ import com.yohobuy.ufo.model.order.common.SellerOrderListType; @@ -5,8 +5,8 @@ import com.yohobuy.ufo.model.order.common.SellerOrderListType;
5 import com.yohobuy.ufo.model.order.common.SellerType; 5 import com.yohobuy.ufo.model.order.common.SellerType;
6 import com.yohobuy.ufo.model.order.resp.OrderListInfo; 6 import com.yohobuy.ufo.model.order.resp.OrderListInfo;
7 import com.yohobuy.ufo.model.order.resp.PageResp; 7 import com.yohobuy.ufo.model.order.resp.PageResp;
8 -import com.yohobuy.ufo.model.order.vo.OrderListVo;  
9 import com.yohoufo.dal.order.SellerOrderGoodsMapper; 8 import com.yohoufo.dal.order.SellerOrderGoodsMapper;
  9 +import com.yohoufo.dal.order.SellerOrderGoodsViewMapper;
10 import com.yohoufo.dal.order.model.SellerOrderGoods; 10 import com.yohoufo.dal.order.model.SellerOrderGoods;
11 import com.yohoufo.order.model.request.OrderListRequest; 11 import com.yohoufo.order.model.request.OrderListRequest;
12 import com.yohoufo.order.service.cache.OrderCacheService; 12 import com.yohoufo.order.service.cache.OrderCacheService;
@@ -20,7 +20,6 @@ import org.springframework.stereotype.Service; @@ -20,7 +20,6 @@ import org.springframework.stereotype.Service;
20 20
21 import java.util.Comparator; 21 import java.util.Comparator;
22 import java.util.List; 22 import java.util.List;
23 -import java.util.Objects;  
24 23
25 /** 24 /**
26 * Created by chao.chen on 2018/12/13. 25 * Created by chao.chen on 2018/12/13.
@@ -44,6 +43,9 @@ public class SkupListService { @@ -44,6 +43,9 @@ public class SkupListService {
44 @Autowired 43 @Autowired
45 private SellerOrderListService sellerOrderListService; 44 private SellerOrderListService sellerOrderListService;
46 45
  46 + @Autowired
  47 + private SellerOrderGoodsViewMapper sellerOrderGoodsViewMapper;
  48 +
47 static Integer getMinSkupId(String skupList){ 49 static Integer getMinSkupId(String skupList){
48 Integer lastSkup = null; 50 Integer lastSkup = null;
49 if (StringUtils.isNotBlank(skupList)){ 51 if (StringUtils.isNotBlank(skupList)){
@@ -96,5 +98,58 @@ public class SkupListService { @@ -96,5 +98,58 @@ public class SkupListService {
96 } 98 }
97 99
98 100
  101 + public PageResp<OrderListInfo> getEntryGoodsList(OrderListRequest request){
  102 + PageResp.PageRespBuilder respBuilder;
  103 + int limit = request.getLimit();
  104 + respBuilder = PageResp.builder()
  105 + .page(request.getPage())
  106 + .pageSize(limit);
  107 + int type;
  108 + if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()) {
  109 + List<Integer> statusList = sellerOrderListService.initOrderListRequest(request);
  110 + int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSkc(request.getUid(), statusList);
  111 + respBuilder.total(total)
  112 + .pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1));
  113 + if (total == 0){
  114 + return respBuilder.build();
  115 + }
  116 + int offset = (request.getPage() - 1) * limit;
  117 + List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSkc(request.getUid(),
  118 + statusList, offset , limit);
  119 + if (CollectionUtils.isEmpty(sogList)){
  120 + logger.warn("seller get entry order list SellerOrderGoods is empty,req {}", request);
  121 + return respBuilder.build();
  122 + }
  123 + boolean isEntry = userProxyService.isEntryShop(request.getUid());
  124 + final SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON;
  125 + List<OrderListInfo> data = sellerOrderListService.buildOrderList(sogList, sellerType);
  126 + respBuilder.data(data);
  127 + }
  128 +
  129 + return respBuilder.build();
  130 + }
  131 +
  132 + public PageResp<OrderListInfo> getNotEntryGoodsList(OrderListRequest request){
  133 + PageResp.PageRespBuilder respBuilder;
  134 + int limit = request.getLimit();
  135 + respBuilder = PageResp.builder()
  136 + .page(request.getPage())
  137 + .pageSize(limit);
  138 +
  139 +
  140 + return respBuilder.build();
  141 + }
  142 +
99 143
  144 +
  145 + public PageResp<OrderListInfo> getEntryGoodsSizeList(OrderListRequest request){
  146 + PageResp.PageRespBuilder respBuilder;
  147 + int limit = request.getLimit();
  148 + respBuilder = PageResp.builder()
  149 + .page(request.getPage())
  150 + .pageSize(limit);
  151 +
  152 +
  153 + return respBuilder.build();
  154 + }
100 } 155 }
@@ -60,6 +60,7 @@ datasources: @@ -60,6 +60,7 @@ datasources:
60 - com.yohoufo.dal.order.StoredSellerMapper 60 - com.yohoufo.dal.order.StoredSellerMapper
61 - com.yohoufo.dal.order.SuperEntrySellerMapper 61 - com.yohoufo.dal.order.SuperEntrySellerMapper
62 - com.yohoufo.dal.order.QiniuLiveRecordMapper 62 - com.yohoufo.dal.order.QiniuLiveRecordMapper
  63 + - com.yohoufo.dal.order.SellerOrderGoodsViewMapper
63 64
64 ufo_promotion: 65 ufo_promotion:
65 servers: 66 servers:
@@ -60,6 +60,7 @@ datasources: @@ -60,6 +60,7 @@ datasources:
60 - com.yohoufo.dal.order.StoredSellerMapper 60 - com.yohoufo.dal.order.StoredSellerMapper
61 - com.yohoufo.dal.order.SuperEntrySellerMapper 61 - com.yohoufo.dal.order.SuperEntrySellerMapper
62 - com.yohoufo.dal.order.QiniuLiveRecordMapper 62 - com.yohoufo.dal.order.QiniuLiveRecordMapper
  63 + - com.yohoufo.dal.order.SellerOrderGoodsViewMapper
63 64
64 ufo_promotion: 65 ufo_promotion:
65 servers: 66 servers: