Authored by Lixiaodi

商品限制销售信息

@@ -20,4 +20,6 @@ public interface ProductLimitSaleMapper { @@ -20,4 +20,6 @@ public interface ProductLimitSaleMapper {
20 int updateByPrimaryKey(ProductLimitSale record); 20 int updateByPrimaryKey(ProductLimitSale record);
21 21
22 List<ProductLimitSale> selectByProductIdAndUid(@Param("productId")Integer productId, @Param("uid")Integer uid); 22 List<ProductLimitSale> selectByProductIdAndUid(@Param("productId")Integer productId, @Param("uid")Integer uid);
  23 +
  24 + ProductLimitSale selectOneByProductIdAndUid(@Param("productId")Integer productId, @Param("uid")Integer uid);
23 } 25 }
@@ -29,6 +29,13 @@ @@ -29,6 +29,13 @@
29 and uid = #{uid} 29 and uid = #{uid}
30 </if> 30 </if>
31 </select> 31 </select>
  32 +
  33 + <select id="selectOneByProductIdAndUid" resultMap="BaseResultMap" >
  34 + select *
  35 + from product_limit_sale
  36 + where del_status = 0 and product_id = #{productId} and uid = #{uid}
  37 + </select>
  38 +
32 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > 39 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
33 delete from product_limit_sale 40 delete from product_limit_sale
34 where id = #{id,jdbcType=INTEGER} 41 where id = #{id,jdbcType=INTEGER}
@@ -134,13 +134,13 @@ public class ProductController { @@ -134,13 +134,13 @@ public class ProductController {
134 @ApiOperation(name = "ufo.product.baseInfo", desc = "出售商品,卖家出售的价格区间") 134 @ApiOperation(name = "ufo.product.baseInfo", desc = "出售商品,卖家出售的价格区间")
135 @RequestMapping(params = "method=ufo.product.baseInfo") 135 @RequestMapping(params = "method=ufo.product.baseInfo")
136 @Cachable(expire = 180) 136 @Cachable(expire = 180)
137 - public ProductDetailResp queryProductBaseInfo(@RequestParam(value = "product_id") Integer productId) { 137 + public ProductDetailResp queryProductBaseInfo(@RequestParam(value = "product_id") Integer productId, @RequestParam(value = "uid") Integer uid) {
138 if (productId == null) { 138 if (productId == null) {
139 LOG.info("in method=ufo.product.baseInfo productId Is Null"); 139 LOG.info("in method=ufo.product.baseInfo productId Is Null");
140 return null; 140 return null;
141 } 141 }
142 - LOG.info("in method=ufo.product.baseInfo productId={}", productId);  
143 - return productService.queryProductBaseInfo(productId); 142 + LOG.info("in method=ufo.product.baseInfo productId={}, uid is {}", productId, uid);
  143 + return productService.queryProductBaseInfo(productId, uid);
144 } 144 }
145 145
146 146
@@ -40,7 +40,7 @@ public interface ProductService { @@ -40,7 +40,7 @@ public interface ProductService {
40 ProductSimpleResp queryPriceLimit(Integer productId); 40 ProductSimpleResp queryPriceLimit(Integer productId);
41 41
42 // 查询商品的基本信息 42 // 查询商品的基本信息
43 - ProductDetailResp queryProductBaseInfo(Integer productId); 43 + ProductDetailResp queryProductBaseInfo(Integer productId, Integer uid);
44 44
45 void batchCreateSkup(List<StoragePriceBo> skupBoList); 45 void batchCreateSkup(List<StoragePriceBo> skupBoList);
46 46
@@ -751,7 +751,7 @@ public class ProductServiceImpl implements ProductService { @@ -751,7 +751,7 @@ public class ProductServiceImpl implements ProductService {
751 751
752 752
753 // 查询商品的基本信息 753 // 查询商品的基本信息
754 - public ProductDetailResp queryProductBaseInfo(Integer productId) { 754 + public ProductDetailResp queryProductBaseInfo(Integer productId, Integer uid) {
755 Product product = productMapper.selectByPrimaryKey(productId); 755 Product product = productMapper.selectByPrimaryKey(productId);
756 if (null == product) { 756 if (null == product) {
757 return new ProductDetailResp(); 757 return new ProductDetailResp();
@@ -763,6 +763,18 @@ public class ProductServiceImpl implements ProductService { @@ -763,6 +763,18 @@ public class ProductServiceImpl implements ProductService {
763 productInfo.setSaleTime((product.getSaleTime() == null || product.getSaleTime().equals(0)) ? "0" : DateUtil.getDateString(product.getSaleTime(), DateUtil.YYYY_MM_DD_DOT)); 763 productInfo.setSaleTime((product.getSaleTime() == null || product.getSaleTime().equals(0)) ? "0" : DateUtil.getDateString(product.getSaleTime(), DateUtil.YYYY_MM_DD_DOT));
764 productInfo.setMinPrice(product.getMinPrice()); 764 productInfo.setMinPrice(product.getMinPrice());
765 productInfo.setMaxPrice(product.getMaxPrice()); 765 productInfo.setMaxPrice(product.getMaxPrice());
  766 + if (uid != null && uid > 0) {
  767 + boolean isLimit = !CollectionUtils.isEmpty(productLimitSaleMapper.selectByProductIdAndUid(productId, null));
  768 + if (isLimit) {
  769 + ProductLimitSale limitSale = productLimitSaleMapper.selectOneByProductIdAndUid(productId, uid);
  770 + if (limitSale != null) {
  771 + productInfo.setSellerServiceFeeRate(limitSale.getProfitRate());
  772 + } else {
  773 + LOGGER.error("该用户" + uid + ",没有商品" + productId + "的发布权限");
  774 + productInfo.setSellerCanPublish(false);
  775 + }
  776 + }
  777 + }
766 778
767 ProductDetailResp productDetailResp = new ProductDetailResp(); 779 ProductDetailResp productDetailResp = new ProductDetailResp();
768 productDetailResp.setProduct_info(productInfo); 780 productDetailResp.setProduct_info(productInfo);