库存警戒值
This commit is contained in:
parent
869d14f158
commit
ca3b16c677
|
|
@ -415,13 +415,6 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
if (resources.getCategoryId() == null) {
|
||||
throw new BadRequestException("必填内容未填写");
|
||||
}
|
||||
// if (resources.getIsShowMall() == 1) {
|
||||
// for (TbProductSku sku : resources.getSkuList()) {
|
||||
// if (sku.getStockNumber() <= 0) {
|
||||
// throw new BadRequestException("上架区域包括小程序时,库存数量必须大于0。");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
product.setCategoryId(String.valueOf(resources.getCategoryId()));
|
||||
}
|
||||
if (product.getUnitId() == null) {
|
||||
|
|
@ -465,16 +458,6 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
tbProductRepository.save(save);
|
||||
//sku
|
||||
if (resources.getSkuList() != null) {
|
||||
Integer warnLine = 0;
|
||||
List<TbProduct> productList = tbProductRepository.selectByShopId(resources.getShopId());
|
||||
if (!productList.isEmpty()) {
|
||||
TbProduct p = productList.get(0);
|
||||
List<TbProductSku> productSkus = tbProductSkuRepository.searchSku(p.getId().toString());
|
||||
if (!productSkus.isEmpty()) {
|
||||
warnLine = productSkus.get(0).getWarnLine();
|
||||
}
|
||||
}
|
||||
|
||||
List<TbProductSku> skuList = new ArrayList<>();
|
||||
for (TbProductSku sku : resources.getSkuList()) {
|
||||
sku.setProductId(String.valueOf(save.getId()));
|
||||
|
|
@ -482,13 +465,8 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
sku.setCreatedAt(Instant.now().toEpochMilli());
|
||||
sku.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
sku.setIsGrounding(1);
|
||||
sku.setWarnLine(warnLine);
|
||||
skuList.add(sku);
|
||||
}
|
||||
List<TbProductSku> tbProductSkus = tbProductSkuRepository.saveAll(skuList);
|
||||
Map<Integer, Double> idStockMap = tbProductSkus.stream()
|
||||
.collect(Collectors.toMap(TbProductSku::getId, TbProductSku::getStockNumber));
|
||||
redisUtils.redisUp(1, save.getShopId(), idStockMap);
|
||||
}
|
||||
//保存到sku_result
|
||||
if ("sku".equals(resources.getTypeEnum())) {
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ import cn.ysk.cashier.system.domain.Dept;
|
|||
import cn.ysk.cashier.system.domain.Job;
|
||||
import cn.ysk.cashier.system.domain.Role;
|
||||
import cn.ysk.cashier.system.domain.User;
|
||||
import cn.ysk.cashier.system.enums.ParamsEnum;
|
||||
//import cn.ysk.cashier.system.enums.ParamsEnum;
|
||||
import cn.ysk.cashier.system.repository.UserRepository;
|
||||
import cn.ysk.cashier.system.service.ParamsService;
|
||||
//import cn.ysk.cashier.system.service.ParamsService;
|
||||
import cn.ysk.cashier.system.service.UserService;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
|
@ -62,7 +62,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
|||
|
||||
private final UserCacheManager userCacheManager;
|
||||
private final TokenProvider tokenProvider;
|
||||
private final ParamsService paramsService;
|
||||
// private final ParamsService paramsService;
|
||||
|
||||
private final TbMerchantRegisterRepository merchantRegisterRepository;
|
||||
|
||||
|
|
@ -97,8 +97,8 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
|||
tbShopInfo.setSmallQrcode(smallQrcode);
|
||||
tbShopInfoRepository.save(tbShopInfo);
|
||||
}
|
||||
String baseUrl = paramsService.getValue(ParamsEnum.SHOP_ORDER_PAY_BASE_URL.name());
|
||||
tbShopInfo.setPaymentQrcode(baseUrl+"?shopId="+id);
|
||||
// String baseUrl = paramsService.getValue(ParamsEnum.SHOP_ORDER_PAY_BASE_URL.name());
|
||||
// tbShopInfo.setPaymentQrcode(baseUrl+"?shopId="+id);
|
||||
ValidationUtil.isNull(tbShopInfo.getId(),"TbShopInfo","id",id);
|
||||
return tbShopInfoMapper.toDto(tbShopInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -747,7 +747,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
*/
|
||||
private void checkWarnLineAndSendMsg(TbProductSku productSku, TbProduct product, Integer shopId, Integer num) {
|
||||
TbShopInfo shopInfo = shopInfoRepository.getById(shopId);
|
||||
if (productSku.getWarnLine() == null) {
|
||||
if (product.getWarnLine() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -755,28 +755,12 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
return;
|
||||
}
|
||||
|
||||
if (productSku.getStockNumber() == null) {
|
||||
productSku.setStockNumber((double) 0);
|
||||
}
|
||||
|
||||
if (product.getStockNumber() == null) {
|
||||
product.setStockNumber(0);
|
||||
}
|
||||
if (
|
||||
(product.getIsDistribute() == 1 && product.getStockNumber() - num <= productSku.getWarnLine())
|
||||
|| (product.getIsDistribute() != 1) && productSku.getStockNumber() - num <= productSku.getWarnLine()
|
||||
) {
|
||||
|
||||
List<TbShopOpenId> openIdList = shopOpenIdMapper.selectList(new LambdaQueryWrapper<TbShopOpenId>()
|
||||
.eq(TbShopOpenId::getShopId, shopId)
|
||||
.eq(TbShopOpenId::getStatus, 1)
|
||||
.and((queryWrapper) -> queryWrapper.eq(TbShopOpenId::getType, ShopWxMsgTypeEnum.ALL_MSG.getType())
|
||||
.or().eq(TbShopOpenId::getType, ShopWxMsgTypeEnum.STOCK_MSG.getType()))
|
||||
.groupBy(TbShopOpenId::getOpenId)
|
||||
);
|
||||
|
||||
if (product.getStockNumber() - num <= product.getWarnLine()) {
|
||||
wxMsgUtils.aboardStockMsg(shopInfo.getShopName(), shopId, product.getName(),
|
||||
product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num));
|
||||
product.getStockNumber() - num);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,10 +90,6 @@ public interface TbProductService {
|
|||
*/
|
||||
void download(List<TbProductDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
void updateIsHot(Integer id,Integer isStock);
|
||||
|
||||
void updateIsStock(Integer proId, String shopId, Integer isStock);
|
||||
|
||||
/**
|
||||
* 增加库存
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue