Authored by kun

Merge remote-tracking branch 'origin/master'

@@ -60,4 +60,8 @@ public interface ProductMapper { @@ -60,4 +60,8 @@ public interface ProductMapper {
60 @Param("sellerUid") Integer sellerUid, 60 @Param("sellerUid") Integer sellerUid,
61 @Param("hasStock") Integer hasStock, 61 @Param("hasStock") Integer hasStock,
62 @Param("skup") Integer skup); 62 @Param("skup") Integer skup);
  63 +
  64 + int updateStatusByPrimaryKey(@Param("id") Integer id,
  65 + @Param("shelveStatus") Integer shelveStatus);
  66 +
63 } 67 }
@@ -157,4 +157,15 @@ @@ -157,4 +157,15 @@
157 and sp.skup = #{skup} 157 and sp.skup = #{skup}
158 </if> 158 </if>
159 </sql> 159 </sql>
  160 + <update id="updateStatusByPrimaryKey">
  161 + update product set
  162 + edit_time = unix_timestamp(),
  163 + update_time = unix_timestamp(),
  164 + shelve_status = #{shelveStatus,jdbcType=INTEGER}
  165 + <if test="shelveStatus != null and shelveStatus == 1">
  166 + ,shelve_time = unix_timestamp()
  167 + </if>
  168 + where id = #{id,jdbcType=INTEGER}
  169 + </update>
  170 +
160 </mapper> 171 </mapper>
@@ -50,9 +50,22 @@ public class ProductController { @@ -50,9 +50,22 @@ public class ProductController {
50 return productService.getSkuList(bo); 50 return productService.getSkuList(bo);
51 } 51 }
52 52
53 - @RequestMapping(value = "/detailList")  
54 - public ApiResponse<PageResponseBO<ProductResponceBo>> detailList(ProductRequestBo bo) { 53 + @RequestMapping(value = "/skupList")
  54 + public ApiResponse<PageResponseBO<ProductResponceBo>> skupList(ProductRequestBo bo) {
55 LOGGER.info("product.detailList param = {}", bo); 55 LOGGER.info("product.detailList param = {}", bo);
56 return productService.getSkupDetailList(bo); 56 return productService.getSkupDetailList(bo);
57 } 57 }
  58 +
  59 + @RequestMapping(value = "/changeProductShelfStatus")
  60 + public ApiResponse<Void> changeProductShelfStatus(ProductRequestBo bo) {
  61 + LOGGER.info("product.changeProductShelfStatus param = {}", bo);
  62 + return productService.changeProductStatus(bo);
  63 + }
  64 +
  65 + @RequestMapping(value = "/cancelSaleSkup")
  66 + public ApiResponse<Void> cancelSaleSkup(ProductRequestBo bo) {
  67 + LOGGER.info("product.detailList param = {}", bo);
  68 + return productService.cancelSaleSkup(bo);
  69 + }
  70 +
58 } 71 }
@@ -18,5 +18,7 @@ public interface IProductService { @@ -18,5 +18,7 @@ public interface IProductService {
18 18
19 ApiResponse<PageResponseBO<ProductResponceBo>> getSkupDetailList(ProductRequestBo bo); 19 ApiResponse<PageResponseBO<ProductResponceBo>> getSkupDetailList(ProductRequestBo bo);
20 20
21 - ApiResponse<PageResponseBO<ProductResponceBo>> cancelSaleSkup(ProductRequestBo bo); 21 + ApiResponse<Void> cancelSaleSkup(ProductRequestBo bo);
  22 +
  23 + ApiResponse<Void> changeProductStatus(ProductRequestBo bo);
22 } 24 }
@@ -10,7 +10,6 @@ import java.util.Map; @@ -10,7 +10,6 @@ import java.util.Map;
10 10
11 import org.apache.commons.collections.CollectionUtils; 11 import org.apache.commons.collections.CollectionUtils;
12 import org.apache.commons.lang3.StringUtils; 12 import org.apache.commons.lang3.StringUtils;
13 -import org.apache.ibatis.annotations.Param;  
14 import org.slf4j.Logger; 13 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory; 14 import org.slf4j.LoggerFactory;
16 import org.springframework.beans.BeanUtils; 15 import org.springframework.beans.BeanUtils;
@@ -471,7 +470,7 @@ public static void main(String[] args) { @@ -471,7 +470,7 @@ public static void main(String[] args) {
471 } 470 }
472 471
473 @Override 472 @Override
474 - public ApiResponse<PageResponseBO<ProductResponceBo>> cancelSaleSkup(ProductRequestBo bo) { 473 + public ApiResponse<Void> cancelSaleSkup(ProductRequestBo bo) {
475 StoragePrice sp = storagePriceMapper.selectBySkup(bo.getSkup()); 474 StoragePrice sp = storagePriceMapper.selectBySkup(bo.getSkup());
476 if (sp == null) { 475 if (sp == null) {
477 return new ApiResponse<>(400, "SKUP不存在"); 476 return new ApiResponse<>(400, "SKUP不存在");
@@ -487,5 +486,25 @@ public static void main(String[] args) { @@ -487,5 +486,25 @@ public static void main(String[] args) {
487 return new ApiResponse<>(400, "SKUP取消失败,状态已变更!"); 486 return new ApiResponse<>(400, "SKUP取消失败,状态已变更!");
488 } 487 }
489 488
490 - 489 + @Override
  490 + public ApiResponse<Void> changeProductStatus(ProductRequestBo bo) {
  491 + Product product = productMapper.selectByPrimaryKey(bo.getId());
  492 + if (product == null) {
  493 + return new ApiResponse<>(400, "商品不存在");
  494 + }
  495 + if (product.getDelStatus() == null || product.getDelStatus() != 0) {
  496 + return new ApiResponse<>(400, "商品已删除");
  497 + }
  498 + if ((product.getShelveStatus() == null || product.getShelveStatus() == 1) && bo.getStatus()==1) {
  499 + return new ApiResponse<>(400, "商品不能上架");
  500 + }
  501 + if ((product.getShelveStatus() == null || product.getShelveStatus() != 1) && bo.getStatus()==0) {
  502 + return new ApiResponse<>(400, "商品不能下架");
  503 + }
  504 + int n = productMapper.updateStatusByPrimaryKey(bo.getId(), bo.getShelveStatus());
  505 + if (n == 1) {
  506 + return new ApiResponse<>(400, "操作成功");
  507 + }
  508 + return new ApiResponse<>(400, "操作失败!");
  509 + }
491 } 510 }