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;
import com.soss.system.domain.GoodsSku;
import com.soss.system.domain.ShopGoodsSku;
import com.soss.system.domain.vo.SkuCountVo;
import com.soss.system.domain.vo.orderTaking.SkuVo;
import org.apache.ibatis.annotations.Param;
......@@ -33,6 +34,7 @@ public interface ShopGoodsSkuMapper {
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关联
......
......@@ -10,6 +10,7 @@ import com.soss.common.enums.SkuDeleteState;
import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*;
import com.soss.system.domain.vo.SkuCountVo;
import com.soss.system.domain.vo.orderTaking.*;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.mapper.*;
......@@ -279,10 +280,11 @@ public class ShopServiceImpl implements IShopService {
}
}
Integer selloutCount = shopGoodsSkuMapper.getSelloutSkuCount(shopId, goods.getId());
Integer sellinCount = shopGoodsSkuMapper.getSellinSkuCount(shopId, goods.getId());
goods.setSelloutCount(selloutCount);
goods.setSkuCount(sellinCount + selloutCount);
SkuCountVo skuCountVo = shopGoodsSkuMapper.getSkuCount(shopId, goods.getId());
if (skuCountVo != null) {
goods.setSelloutCount(skuCountVo.getSellout());
goods.setSkuCount(skuCountVo.getSellin() + skuCountVo.getSellout());
}
ShopRecommend shopRecommend = new ShopRecommend();
shopRecommend.setShopId(String.valueOf(shopId));
......
......@@ -42,6 +42,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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">
<include refid="selectShopGoodsSkuVo"/>
where id = #{id}
......
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