Authored by chenchao

fix quick deliver not show

... ... @@ -21,11 +21,22 @@ public interface SellerOrderGoodsViewMapper {
@Param("offset")Integer offset,
@Param("limit")Integer limit);
int selectCntByUidStatusGBSkc(@Param("uid")int uid,
@Param("statusList") List<Integer> statusList,
@Param("skupTypes")Collection<Integer> skupTypes);
List<SellerOrderGoods> selectListByUidStatusGBSkc(@Param("uid")int uid,
@Param("statusList") List<Integer> statusList,
@Param("skupTypes")Collection<Integer> skupTypes,
@Param("offset")Integer offset,
@Param("limit")Integer limit);
SellerOrderGoods selectByUidStatusGBSkc(@Param("uid")int uid,
@Param("statusList") List<Integer> statusList,
@Param("skupTypes")Collection<Integer> skupTypes,
@Param("productId")Integer productId);
@Param("productId")Integer productId,
@Param("isEntry") boolean isEntry);
int selectNotEntryCntByUidStatus(@Param("uid")int uid,
@Param("statusList") List<Integer> statusList,
... ... @@ -41,10 +52,12 @@ public interface SellerOrderGoodsViewMapper {
List<SellerOrderGoods> selectEntryListByUidStatusGBSku(@Param("condition")SellerOrderGoods condition,
@Param("skupTypes")Collection<Integer> skupTypes,
@Param("offset")Integer offset,
@Param("limit")Integer limit);
@Param("limit")Integer limit,
@Param("isEntry") boolean isEntry);
int selectEntryCntByUidStatusGBSku(@Param("condition") SellerOrderGoods condition,
@Param("skupTypes")Collection<Integer> skupTypes);
@Param("skupTypes")Collection<Integer> skupTypes,
@Param("isEntry") boolean isEntry);
List<SellerOrderGoods> selectCanSellByStorageId(@Param("storageId")int storageId);
... ...
... ... @@ -41,6 +41,20 @@
GROUP BY sog.uid,product_id) t
</select>
<select id="selectCntByUidStatusGBSkc" 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
<include refid="sql_where_skupTyps_scope" />
<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,
... ... @@ -62,13 +76,31 @@
limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
</select>
<select id="selectListByUidStatusGBSkc" 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
<include refid="sql_where_skupTyps_scope" />
<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>
<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
and sog.is_del = 1
<if test="isEntry">
AND so.payment = 11
</if>
<include refid="sql_where_skupTyps_scope" />
<if test="statusList != null">
and sog.status in
... ... @@ -113,7 +145,10 @@
<select id="selectEntryListByUidStatusGBSku" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List_with_table_name" />,COUNT(`size_id`) storage_num
FROM seller_order_goods sog,seller_order so WHERE sog.id = so.skup
AND sog.uid = #{condition.uid,jdbcType=INTEGER} AND so.payment = 11
AND sog.uid = #{condition.uid,jdbcType=INTEGER}
<if test="isEntry">
AND so.payment = 11
</if>
<include refid="sql_where_skupTyps_scope" />
AND sog.status = #{condition.status, jdbcType=TINYINT}
AND product_id = #{condition.productId,jdbcType=INTEGER}
... ... @@ -127,7 +162,10 @@
(
SELECT size_id ,goods_price
FROM seller_order_goods sog,seller_order so WHERE sog.id = so.skup
AND sog.uid = #{condition.uid,jdbcType=INTEGER} AND so.payment = 11
AND sog.uid = #{condition.uid,jdbcType=INTEGER}
<if test="isEntry">
AND so.payment = 11
</if>
<include refid="sql_where_skupTyps_scope" />
AND sog.status = #{condition.status, jdbcType=TINYINT}
AND product_id = #{condition.productId,jdbcType=INTEGER}
... ...
... ... @@ -174,7 +174,7 @@ public class SkupListService {
logger.warn("seller get entry order list SellerOrderGoods is empty,req {}", request);
return respBuilder.build();
}
List<OrderListInfo> data = buildProductList(sogList, viewableStatus);
List<OrderListInfo> data = buildProductList(sogList, viewableStatus, skupTypeCodes, isEntry);
respBuilder.data(data);
}
... ... @@ -251,7 +251,7 @@ public class SkupListService {
sogCondition.setStatus(status);
final List<Integer> skupTypeCodes = ENTRY_SKUP_TYPES;
//
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSku(sogCondition, skupTypeCodes);
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSku(sogCondition, skupTypeCodes, isEntry);
respBuilder.total(total);
if (total == 0){
return respBuilder.build();
... ... @@ -260,7 +260,7 @@ public class SkupListService {
respBuilder.pagetotal(pageTotal);
int offset = (request.getPage() - 1) * limit;
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSku(sogCondition,
skupTypeCodes, offset, limit);
skupTypeCodes, offset, limit, isEntry);
//TODO 可以提前计算 total offset limit三者之间的关系,减少一次网络IO
if (CollectionUtils.isEmpty(sogList)){
logger.warn("seller get order list SellerOrderGoods is empty,req {}", request);
... ... @@ -269,12 +269,16 @@ public class SkupListService {
List<OrderListInfo> orderListInfos = buildEntryPrdSkuList(productId, sogList);
respBuilder.data(orderListInfos);
ProductInfo productInfo = buildProductInfo(uid, status, sogList, pageTotal);
ProductInfo productInfo = buildProductInfo(uid, status, sogList, pageTotal, skupTypeCodes, isEntry);
respBuilder.productInfo(productInfo);
return respBuilder.build();
}
public ProductInfo buildProductInfo(Integer uid, Integer status, List<SellerOrderGoods> sogList, int pageTotal){
public ProductInfo buildProductInfo(Integer uid,
Integer status,
List<SellerOrderGoods> sogList,
int pageTotal,
List<Integer> skupTypeCodes,boolean isEntry){
ProductInfo productInfo = new ProductInfo();
SellerOrderGoods sog = sogList.get(0);
productInfo.setProductId(sog.getProductId());
... ... @@ -298,7 +302,8 @@ public class SkupListService {
sizeNum = sizeIds.size();
}
if (pageTotal>1){
SellerOrderGoods psogOfMerge = fetchSellerOrderGoodsFromDB(uid, Arrays.asList(status), sog.getProductId());
SellerOrderGoods psogOfMerge = fetchSellerOrderGoodsFromDB(uid, Arrays.asList(status), sog.getProductId(),
skupTypeCodes, isEntry);
if (psogOfMerge != null) {
storageNum = psogOfMerge.getStorageNum();
sizeNum = psogOfMerge.getSizeNum();
... ... @@ -319,8 +324,10 @@ public class SkupListService {
*/
private SellerOrderGoods fetchSellerOrderGoodsFromDB(int uid,
List<Integer> statusList,
Integer productId){
SellerOrderGoods psogOfMerge = sellerOrderGoodsViewMapper.selectByUidStatusGBSkc(uid, statusList, ENTRY_SKUP_TYPES, productId);
Integer productId,
List<Integer> skupTypeCodes,
boolean isEntry){
SellerOrderGoods psogOfMerge = sellerOrderGoodsViewMapper.selectByUidStatusGBSkc(uid, statusList, skupTypeCodes, productId, isEntry);
logger.info("fetchSellerOrderGoodsFromDB uid {} statusList {} prd id {}", uid, statusList, productId);
return psogOfMerge;
}
... ... @@ -338,14 +345,14 @@ public class SkupListService {
sogCondition.setStatus(status);
List<Integer> skupTypesCondition = NORMAL_SKUPTYPES;
//
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSku(sogCondition, skupTypesCondition);
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSku(sogCondition, skupTypesCondition, true);
if (total == 0){
return popDTO;
}
int offset = 0, limit = total;
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSku(sogCondition, skupTypesCondition,
offset, limit);
offset, limit, true);
if (CollectionUtils.isEmpty(sogList)){
logger.warn("seller getPrdOverPriceDTO use SellerOrderGoods is empty,uid {} productId {}", uid, productId);
return popDTO;
... ... @@ -463,11 +470,13 @@ public class SkupListService {
}
public List<OrderListInfo> buildProductList(List<SellerOrderGoods> sogList,SkupStatus viewableStatus){
public List<OrderListInfo> buildProductList(List<SellerOrderGoods> sogList,
SkupStatus viewableStatus,
List<Integer> skupTypeCodes,boolean isEntry){
List<OrderListInfo> data ;
data = sogList.parallelStream()
.map(sog -> {
OrderListInfo oli = buildEntryOrderListInfo(sog, viewableStatus);
OrderListInfo oli = buildEntryOrderListInfo(sog, viewableStatus, skupTypeCodes, isEntry);
return oli;
})
.filter(oli -> Objects.nonNull(oli))
... ... @@ -481,6 +490,7 @@ public class SkupListService {
* @return
*/
public OrderListInfo getOrderListInfo(SellerGoodsRequest req){
List<Integer> skupTypeCodes = ENTRY_SKUP_TYPES;
SkupStatus ss = SkupStatus.CAN_SELL;
Integer status = ss.getCode();
Integer uid = req.getUid();
... ... @@ -489,15 +499,17 @@ public class SkupListService {
sogCondition.setProductId(productId=req.getProductId());
sogCondition.setUid(uid);
sogCondition.setStatus(status);
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSku(sogCondition, ENTRY_SKUP_TYPES, 0, 1);
boolean isEntry = true;
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSku(sogCondition, skupTypeCodes , 0, 1, isEntry);
if (CollectionUtils.isEmpty(sogList)){
logger.warn("in getOrderListInfo soglist is empty req {}", req);
return null;
}
return buildEntryOrderListInfo(sogList.get(0), ss);
return buildEntryOrderListInfo(sogList.get(0), ss, skupTypeCodes, isEntry);
}
OrderListInfo buildEntryOrderListInfo(SellerOrderGoods sellerOrderGoods, SkupStatus skupStatus) {
OrderListInfo buildEntryOrderListInfo(SellerOrderGoods sellerOrderGoods, SkupStatus skupStatus,
List<Integer> skupTypeCodes, boolean isEntry) {
Integer uid;
OrderListInfo orderListInfo = new OrderListInfo();
orderListInfo.setUid(uid = sellerOrderGoods.getUid());
... ... @@ -526,7 +538,7 @@ public class SkupListService {
productInfo.setEntryFlag(true);
//
List<Integer> statusList = Arrays.asList(skupStatus.getCode());
SellerOrderGoods psogOfMerge = fetchSellerOrderGoodsFromDB(uid,statusList,productId);
SellerOrderGoods psogOfMerge = fetchSellerOrderGoodsFromDB(uid,statusList,productId, skupTypeCodes, isEntry);
if (psogOfMerge != null){
productInfo.setStorageNum(psogOfMerge.getStorageNum());
productInfo.setSizeNum(psogOfMerge.getSizeNum());
... ...
... ... @@ -171,20 +171,20 @@ public class QuickDeliverGoodsService {
SkupStatus viewableStatus = SkupStatus.CAN_SELL;
List<Integer> statusList = Arrays.asList(viewableStatus.getCode());
final List<Integer> skupTypeCodes = getSkupTypeCodes();
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSkc(uid, statusList, skupTypeCodes);
int total = sellerOrderGoodsViewMapper.selectCntByUidStatusGBSkc(uid, statusList, skupTypeCodes);
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(uid,
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectListByUidStatusGBSkc(uid,
statusList, skupTypeCodes, offset , limit);
if (CollectionUtils.isEmpty(sogList)){
logger.warn("seller get entry order list SellerOrderGoods is empty,req {}", request);
return respBuilder.build();
}
List<OrderListInfo> data = skupListService.buildProductList(sogList, viewableStatus);
List<OrderListInfo> data = skupListService.buildProductList(sogList, viewableStatus, skupTypeCodes, false);
respBuilder.data(data);
}
... ... @@ -225,7 +225,7 @@ public class QuickDeliverGoodsService {
sogCondition.setStatus(status);
final List<Integer> skupTypeCodes = getSkupTypeCodes();
//
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSku(sogCondition, skupTypeCodes);
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSku(sogCondition, skupTypeCodes, false);
respBuilder.total(total);
if (total == 0){
return respBuilder.build();
... ... @@ -234,7 +234,7 @@ public class QuickDeliverGoodsService {
respBuilder.pagetotal(pageTotal);
int offset = (request.getPage() - 1) * limit;
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSku(sogCondition,
skupTypeCodes, offset, limit);
skupTypeCodes, offset, limit, false);
//TODO 可以提前计算 total offset limit三者之间的关系,减少一次网络IO
if (CollectionUtils.isEmpty(sogList)){
logger.warn("seller get order list SellerOrderGoods is empty,req {}", request);
... ... @@ -243,7 +243,7 @@ public class QuickDeliverGoodsService {
List<OrderListInfo> orderListInfos = skupListService.buildPrdSkuList(productId, sogList);
respBuilder.data(orderListInfos);
ProductInfo productInfo = skupListService.buildProductInfo(uid, status, sogList, pageTotal);
ProductInfo productInfo = skupListService.buildProductInfo(uid, status, sogList, pageTotal, skupTypeCodes, false);
respBuilder.productInfo(productInfo);
return respBuilder.build();
}
... ...