Commit bc98754f by weijiguang

下单时校验订单中sku数量

parent 4556b8d9
package com.soss.system.domain.vo;
import lombok.Data;
@Data
public class SkuCountVo {
private Integer sellin = 0;
private Integer sellout = 0;
}
...@@ -2,6 +2,7 @@ package com.soss.system.mapper; ...@@ -2,6 +2,7 @@ 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;
...@@ -33,6 +34,7 @@ public interface ShopGoodsSkuMapper { ...@@ -33,6 +34,7 @@ public interface ShopGoodsSkuMapper {
Integer getSellinSkuCount(@Param("shopId") Long shopId, @Param("goodsId") Long goodsId); Integer getSellinSkuCount(@Param("shopId") Long shopId, @Param("goodsId") Long goodsId);
Integer getSelloutSkuCount(@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,6 +10,7 @@ import com.soss.common.enums.SkuDeleteState; ...@@ -10,6 +10,7 @@ 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.*;
...@@ -279,10 +280,11 @@ public class ShopServiceImpl implements IShopService { ...@@ -279,10 +280,11 @@ public class ShopServiceImpl implements IShopService {
} }
} }
Integer selloutCount = shopGoodsSkuMapper.getSelloutSkuCount(shopId, goods.getId()); SkuCountVo skuCountVo = shopGoodsSkuMapper.getSkuCount(shopId, goods.getId());
Integer sellinCount = shopGoodsSkuMapper.getSellinSkuCount(shopId, goods.getId()); if (skuCountVo != null) {
goods.setSelloutCount(selloutCount); goods.setSelloutCount(skuCountVo.getSellout());
goods.setSkuCount(sellinCount + selloutCount); goods.setSkuCount(skuCountVo.getSellin() + skuCountVo.getSellout());
}
ShopRecommend shopRecommend = new ShopRecommend(); ShopRecommend shopRecommend = new ShopRecommend();
shopRecommend.setShopId(String.valueOf(shopId)); shopRecommend.setShopId(String.valueOf(shopId));
......
...@@ -41,6 +41,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -41,6 +41,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getSellinSkuCount" resultType="Integer"> <select id="getSellinSkuCount" resultType="Integer">
select count(1) from shop_goods_sku where shop_id=#{shopId} and goods_id=#{goodsId} and `state`=1 select count(1) from shop_goods_sku where shop_id=#{shopId} and goods_id=#{goodsId} and `state`=1
</select> </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