Authored by Lixiaodi

商品管理

... ... @@ -60,4 +60,8 @@ public interface ProductMapper {
@Param("sellerUid") Integer sellerUid,
@Param("hasStock") Integer hasStock,
@Param("skup") Integer skup);
int updateStatusByPrimaryKey(@Param("id") Integer id,
@Param("shelveStatus") Integer shelveStatus);
}
\ No newline at end of file
... ...
... ... @@ -157,4 +157,15 @@
and sp.skup = #{skup}
</if>
</sql>
<update id="updateStatusByPrimaryKey">
update product set
edit_time = unix_timestamp(),
update_time = unix_timestamp(),
shelve_status = #{shelveStatus,jdbcType=INTEGER}
<if test="shelveStatus != null and shelveStatus == 1">
,shelve_time = unix_timestamp()
</if>
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -50,9 +50,22 @@ public class ProductController {
return productService.getSkuList(bo);
}
@RequestMapping(value = "/detailList")
public ApiResponse<PageResponseBO<ProductResponceBo>> detailList(ProductRequestBo bo) {
@RequestMapping(value = "/skupList")
public ApiResponse<PageResponseBO<ProductResponceBo>> skupList(ProductRequestBo bo) {
LOGGER.info("product.detailList param = {}", bo);
return productService.getSkupDetailList(bo);
}
@RequestMapping(value = "/changeProductShelfStatus")
public ApiResponse<Void> changeProductShelfStatus(ProductRequestBo bo) {
LOGGER.info("product.changeProductShelfStatus param = {}", bo);
return productService.changeProductStatus(bo);
}
@RequestMapping(value = "/cancelSaleSkup")
public ApiResponse<Void> cancelSaleSkup(ProductRequestBo bo) {
LOGGER.info("product.detailList param = {}", bo);
return productService.cancelSaleSkup(bo);
}
}
... ...
... ... @@ -18,5 +18,7 @@ public interface IProductService {
ApiResponse<PageResponseBO<ProductResponceBo>> getSkupDetailList(ProductRequestBo bo);
ApiResponse<PageResponseBO<ProductResponceBo>> cancelSaleSkup(ProductRequestBo bo);
ApiResponse<Void> cancelSaleSkup(ProductRequestBo bo);
ApiResponse<Void> changeProductStatus(ProductRequestBo bo);
}
... ...
... ... @@ -10,7 +10,6 @@ import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
... ... @@ -471,7 +470,7 @@ public static void main(String[] args) {
}
@Override
public ApiResponse<PageResponseBO<ProductResponceBo>> cancelSaleSkup(ProductRequestBo bo) {
public ApiResponse<Void> cancelSaleSkup(ProductRequestBo bo) {
StoragePrice sp = storagePriceMapper.selectBySkup(bo.getSkup());
if (sp == null) {
return new ApiResponse<>(400, "SKUP不存在");
... ... @@ -487,5 +486,25 @@ public static void main(String[] args) {
return new ApiResponse<>(400, "SKUP取消失败,状态已变更!");
}
@Override
public ApiResponse<Void> changeProductStatus(ProductRequestBo bo) {
Product product = productMapper.selectByPrimaryKey(bo.getId());
if (product == null) {
return new ApiResponse<>(400, "商品不存在");
}
if (product.getDelStatus() == null || product.getDelStatus() != 0) {
return new ApiResponse<>(400, "商品已删除");
}
if ((product.getShelveStatus() == null || product.getShelveStatus() == 1) && bo.getStatus()==1) {
return new ApiResponse<>(400, "商品不能上架");
}
if ((product.getShelveStatus() == null || product.getShelveStatus() != 1) && bo.getStatus()==0) {
return new ApiResponse<>(400, "商品不能下架");
}
int n = productMapper.updateStatusByPrimaryKey(bo.getId(), bo.getShelveStatus());
if (n == 1) {
return new ApiResponse<>(400, "操作成功");
}
return new ApiResponse<>(400, "操作失败!");
}
}
... ...