Merge remote-tracking branch 'origin/zs2' into dev
This commit is contained in:
@@ -38,7 +38,6 @@ public class DataCache {
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public void init(){
|
||||
// log.info("加载店铺信息");
|
||||
shopInfo();
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
|
||||
import com.chaozhanggui.system.cashierservice.service.ProductService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@@ -21,6 +25,23 @@ public class ProductController {
|
||||
private ProductService productService;
|
||||
|
||||
|
||||
@PutMapping("/productStatus")
|
||||
public Result productStatus(
|
||||
@Valid @RequestBody ProductStatusDTO productStatusDTO
|
||||
) {
|
||||
productService.updateState(productStatusDTO);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping("/productStock")
|
||||
public Result productStock(
|
||||
@Valid @RequestBody ProductStockDTO productStockDTO
|
||||
) {
|
||||
productService.updateStock(productStockDTO);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "queryCommodityInfo")
|
||||
public Result queryCommodityInfo(
|
||||
@RequestHeader("token") String token,
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs;
|
||||
import com.chaozhanggui.system.cashierservice.entity.po.ProConsSkuInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -53,4 +54,24 @@ public interface TbProductMapper {
|
||||
|
||||
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id}")
|
||||
int decrStockUnCheck(String id, int num);
|
||||
|
||||
@Select("select * from tb_product product where product.id=#{productId} and product.shop_id=#{shopId} and product.is_del=0")
|
||||
TbProduct selectByShopIdAndId(@Param("productId") Integer productId, @Param("shopId") Integer shopId);
|
||||
|
||||
@Update("update tb_product_sku set is_grounding=#{isGrounding} where product_id=#{productId}")
|
||||
int updateGroundingByProId(@Param("productId") Integer productId, @Param("isGrounding") int isGrounding);
|
||||
|
||||
@Update("update tb_product_sku set is_grounding=#{status} where id=#{skuId}")
|
||||
int updateGrounding(@Param("skuId") Integer skuId, @Param("status") int status);
|
||||
|
||||
@Update("update tb_product set is_pause_sale=#{state} where id=#{id} and shop_id=#{shopId}")
|
||||
int pauseSale(@Param("id") Integer id, @Param("shopId") Integer shopId, @Param("state") Integer state);
|
||||
|
||||
@Update("update tb_product_sku set is_pause_sale=#{state} where product_id=#{id} and shop_id=#{shopId}")
|
||||
int pauseSkuSale(@Param("id") Integer proId, @Param("shopId") Integer shopId, @Param("state") Integer state);
|
||||
|
||||
|
||||
|
||||
@Update("update tb_product set stock_number=#{stock} where id=#{productId} and shop_id=#{shopId}")
|
||||
int updateStock(@Param("shopId") Integer shopId, @Param("productId") Integer productId, @Param("stock") Integer stock);
|
||||
}
|
||||
|
||||
@@ -55,5 +55,11 @@ public interface TbProductSkuMapper {
|
||||
List<TbProductSku> selectByProductCheckGrounding(@Param("id") Integer id);
|
||||
|
||||
@Select("select * from tb_product_sku where is_grounding=1 and is_del=0 and product_id=#{id}")
|
||||
List<TbProductSku> selectGroundingByProId(Integer id);
|
||||
List<TbProductSku> selectGroundingByProId(@Param("id") Integer id);
|
||||
|
||||
@Update("update tb_product_sku set is_pause_sale=#{state} where id=#{skuId} and shop_id=#{shopId}")
|
||||
int pauseSale(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId, @Param("state") Integer state);
|
||||
|
||||
@Update("update tb_product_sku set stock_number=#{stock} where product_id=#{skuId} and shop_id=#{shopId}")
|
||||
int updateStock(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId, @Param("stock") Integer stock);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class ProductStatusDTO {
|
||||
@NotNull
|
||||
private Integer productId;
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
@NotNull
|
||||
@Range(min = 0, max = 1)
|
||||
private Integer state;
|
||||
// 0上下架 1售罄
|
||||
@Range(min = 0, max = 1)
|
||||
@NotNull
|
||||
private Integer type;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class ProductStockDTO {
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
@NotNull
|
||||
private Integer productId;
|
||||
@NotNull
|
||||
@Min(0)
|
||||
private Integer stock;
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.bean.ShopWxMsgTypeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.util.*;
|
||||
@@ -123,7 +122,7 @@ public class ConsMsgConsumer {
|
||||
log.info("耗材名称: {}, conwarning:{},stockNumber:{}",tbConsInfo.getConName(),
|
||||
tbConsInfo.getConWarning(),tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()));
|
||||
if (N.egt(tbConsInfo.getConWarning(), tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()))) {
|
||||
List<TbShopOpenId> tbUserShopMsgs = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.CONSUMABLES_MSG.getType());
|
||||
List<TbUserShopMsg> tbUserShopMsgs = tbUserShopMsgMapper.selectAllByShopId(tbConsInfo.getShopId());
|
||||
log.info("待推送openId列表: {}", tbUserShopMsgs);
|
||||
if (Objects.nonNull(tbUserShopMsgs) && tbUserShopMsgs.size()>0) {
|
||||
tbUserShopMsgs.parallelStream().forEach(tbUserShopMsg->{
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.interceptor.LimitSubmitAspect;
|
||||
@@ -222,4 +224,28 @@ public class ProductService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateState(ProductStatusDTO productStatusDTO) {
|
||||
TbProduct product = tbProductMapper.selectByShopIdAndId(productStatusDTO.getProductId(), productStatusDTO.getShopId());
|
||||
if (productStatusDTO.getType().equals(0)) {
|
||||
tbProductMapper.updateGroundingByProId(product.getId(), productStatusDTO.getState());
|
||||
}else {
|
||||
tbProductMapper.pauseSale(productStatusDTO.getProductId(), productStatusDTO.getShopId(), productStatusDTO.getState());
|
||||
tbProductMapper.pauseSkuSale(productStatusDTO.getProductId(), productStatusDTO.getShopId(), productStatusDTO.getState());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStock(ProductStockDTO productStockDTO) {
|
||||
TbProduct product = tbProductMapper.selectByShopIdAndId(productStockDTO.getProductId(), productStockDTO.getShopId());
|
||||
if (product == null) {
|
||||
throw new MsgException("商品不存在");
|
||||
}
|
||||
|
||||
if (product.getIsDistribute() != 1 && product.getTypeEnum().equals("sku")) {
|
||||
throw new MsgException("多规格非共享商品暂不支持修改库存");
|
||||
}else {
|
||||
tbProductSkuMapper.updateStock(productStockDTO.getProductId(), productStockDTO.getShopId(), productStockDTO.getStock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user