Commit f20d798f by weijiguang

优化店铺距离限制

parent b7bfea54
...@@ -138,10 +138,10 @@ public class Goods extends BaseEntity { ...@@ -138,10 +138,10 @@ public class Goods extends BaseEntity {
private String preferential; private String preferential;
/** 商品sku数量 */ /** 商品sku数量 */
private Integer skuCount; private Integer skuCount = 0;
/** 商品售罄sku数量 */ /** 商品售罄sku数量 */
private Integer selloutCount; private Integer selloutCount = 0;
/** /**
* 总销量 * 总销量
......
package com.soss.system.domain.vo;
import lombok.Data;
@Data
public class SkuCountVo {
private Integer sellin = 0;
private Integer sellout = 0;
}
...@@ -2,7 +2,6 @@ package com.soss.system.mapper; ...@@ -2,7 +2,6 @@ package com.soss.system.mapper;
import com.soss.system.domain.GoodsSku; import com.soss.system.domain.GoodsSku;
import com.soss.system.domain.ShopGoodsSku; import com.soss.system.domain.ShopGoodsSku;
import com.soss.system.domain.vo.SkuCountVo;
import com.soss.system.domain.vo.orderTaking.SkuVo; import com.soss.system.domain.vo.orderTaking.SkuVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -32,10 +31,6 @@ public interface ShopGoodsSkuMapper { ...@@ -32,10 +31,6 @@ public interface ShopGoodsSkuMapper {
*/ */
public List<ShopGoodsSku> selectShopGoodsSkuList(ShopGoodsSku shopGoodsSku); public List<ShopGoodsSku> selectShopGoodsSkuList(ShopGoodsSku shopGoodsSku);
Integer getSellinSkuCount(@Param("shopId") Long shopId, @Param("goodsId") Long goodsId);
Integer getSelloutSkuCount(@Param("shopId") Long shopId, @Param("goodsId") Long goodsId);
SkuCountVo getSkuCount(@Param("shopId") Long shopId, @Param("goodsId") Long goodsId);
/** /**
* 新增从店铺到sku关联 * 新增从店铺到sku关联
* *
......
...@@ -10,7 +10,6 @@ import com.soss.common.enums.SkuDeleteState; ...@@ -10,7 +10,6 @@ import com.soss.common.enums.SkuDeleteState;
import com.soss.common.exception.ServiceException; import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils; import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*; import com.soss.system.domain.*;
import com.soss.system.domain.vo.SkuCountVo;
import com.soss.system.domain.vo.orderTaking.*; import com.soss.system.domain.vo.orderTaking.*;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl; import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.mapper.*; import com.soss.system.mapper.*;
...@@ -58,6 +57,8 @@ public class ShopServiceImpl implements IShopService { ...@@ -58,6 +57,8 @@ public class ShopServiceImpl implements IShopService {
private JiGuangPushServiceImpl jiGuangPushService; private JiGuangPushServiceImpl jiGuangPushService;
@Autowired @Autowired
private GoodsTagMapper goodsTagMapper; private GoodsTagMapper goodsTagMapper;
@Autowired
private ShopGoodsServiceImpl shopGoodsService;
/** /**
* 查询店铺 * 查询店铺
...@@ -280,11 +281,22 @@ public class ShopServiceImpl implements IShopService { ...@@ -280,11 +281,22 @@ public class ShopServiceImpl implements IShopService {
} }
} }
SkuCountVo skuCountVo = shopGoodsSkuMapper.getSkuCount(shopId, goods.getId()); List<Spec> specs = shopGoodsService.getShopGoodsSpecs(shopId, goods.getId());
if (skuCountVo != null) { if (CollectionUtils.isEmpty(specs)) {
goods.setSelloutCount(skuCountVo.getSellout()); goods.setSelloutCount(0);
goods.setSkuCount(skuCountVo.getSellin() + skuCountVo.getSellout()); goods.setSkuCount(0);
} }
specs.forEach(spec -> {
if (CollectionUtils.isEmpty(spec.getSpecRules())) {
return;
}
spec.getSpecRules().forEach(rule -> {
goods.setSkuCount(goods.getSkuCount() + 1);
if (rule.getState() == 0) {
goods.setSelloutCount(goods.getSelloutCount() + 1);
}
});
});
ShopRecommend shopRecommend = new ShopRecommend(); ShopRecommend shopRecommend = new ShopRecommend();
shopRecommend.setShopId(String.valueOf(shopId)); shopRecommend.setShopId(String.valueOf(shopId));
......
...@@ -33,22 +33,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -33,22 +33,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if> <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
</where> </where>
</select> </select>
<select id="getSelloutSkuCount" resultType="Integer">
select count(1) from shop_goods_sku where shop_id=#{shopId} and goods_id=#{goodsId} and `state`!=1
</select>
<select id="getSellinSkuCount" resultType="Integer">
select count(1) from shop_goods_sku where shop_id=#{shopId} and goods_id=#{goodsId} and `state`=1
</select>
<select id="getSkuCount" resultType="SkuCountVo">
select
sum(case when `state`=1 then 1 else 0 end) as sellin,
sum(case when `state`!=1 then 1 else 0 end) as sellout
from shop_goods_sku
where shop_id=#{shopId} and goods_id=#{goodsId}
</select>
<select id="selectShopGoodsSkuById" parameterType="String" resultMap="ShopGoodsSkuResult"> <select id="selectShopGoodsSkuById" parameterType="String" resultMap="ShopGoodsSkuResult">
<include refid="selectShopGoodsSkuVo"/> <include refid="selectShopGoodsSkuVo"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment