Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -206,11 +206,8 @@ public class StockServiceImpl implements StockService {
|
||||
TbProductStockDetail stockDetail = new TbProductStockDetail();
|
||||
stockDetail.setCreatedAt(System.currentTimeMillis());
|
||||
stockDetail.setUpdatedAt(System.currentTimeMillis());
|
||||
stockDetail.setSourcePath("NORMAL");
|
||||
stockDetail.setType("一次性入库覆盖库存");
|
||||
stockDetail.setSubType(1);
|
||||
stockDetail.setSourcePath("SHOP");
|
||||
stockDetail.setRemark("一次性入库覆盖库存");
|
||||
|
||||
if ("sku".equals(productIdStr)) {
|
||||
Optional<TbProductSku> byId = skuRepository.findById(Double.valueOf(row.getCell(2).toString()).intValue());
|
||||
if (byId.isPresent()) {
|
||||
@@ -230,8 +227,17 @@ public class StockServiceImpl implements StockService {
|
||||
stockDetail.setProductId(product.getId().toString());
|
||||
stockDetail.setProductName(product.getName());
|
||||
stockDetail.setUnitName(shopUnit.getName());
|
||||
stockDetail.setLeftNumber(0);
|
||||
stockDetail.setStockNumber(aDouble);
|
||||
stockDetail.setLeftNumber(product.getStockNumber());//原库存
|
||||
BigDecimal subtract = new BigDecimal(aDouble).subtract(new BigDecimal(product.getStockNumber()));
|
||||
if (subtract.compareTo(BigDecimal.ZERO) > 0) {
|
||||
stockDetail.setSubType(1);
|
||||
stockDetail.setType("盘点入库");
|
||||
stockDetail.setStockNumber(subtract.doubleValue());
|
||||
}else {
|
||||
stockDetail.setSubType(-1);
|
||||
stockDetail.setType("盘点出库");
|
||||
stockDetail.setStockNumber(subtract.doubleValue());
|
||||
}
|
||||
stockDetails.add(stockDetail);
|
||||
|
||||
list.add(new StockV2Vo(
|
||||
@@ -261,8 +267,19 @@ public class StockServiceImpl implements StockService {
|
||||
stockDetail.setProductId(product.getId().toString());
|
||||
stockDetail.setProductName(product.getName());
|
||||
stockDetail.setUnitName(shopUnit.getName());
|
||||
stockDetail.setLeftNumber(0);
|
||||
stockDetail.setStockNumber(aDouble);
|
||||
// stockDetail.setLeftNumber(0);
|
||||
// stockDetail.setStockNumber(aDouble);
|
||||
stockDetail.setLeftNumber(product.getStockNumber());//原库存
|
||||
BigDecimal subtract = new BigDecimal(aDouble).subtract(new BigDecimal(product.getStockNumber()));
|
||||
if (subtract.compareTo(BigDecimal.ZERO) > 0) {
|
||||
stockDetail.setSubType(1);
|
||||
stockDetail.setType("盘点入库");
|
||||
stockDetail.setStockNumber(subtract.doubleValue());
|
||||
}else {
|
||||
stockDetail.setSubType(-1);
|
||||
stockDetail.setType("盘点出库");
|
||||
stockDetail.setStockNumber(subtract.doubleValue());
|
||||
}
|
||||
stockDetails.add(stockDetail);
|
||||
|
||||
list.add(new StockV2Vo(
|
||||
@@ -338,12 +355,12 @@ public class StockServiceImpl implements StockService {
|
||||
TbProduct product = new TbProduct();
|
||||
for (StockUpdateValueVO updateValueVO : updateValueVOs) {
|
||||
if (!updateValueVO.isSku()) {
|
||||
if (product == null) {
|
||||
if (product.getId()!=null) {
|
||||
product = tbProductRepository.getById(Integer.valueOf(updateValueVO.getId()));
|
||||
}
|
||||
productUp(updateValueVO, product);
|
||||
} else {
|
||||
if (product == null) {
|
||||
if (product.getId()!=null) {
|
||||
product = tbProductRepository.selectBySkuId(Integer.valueOf(updateValueVO.getId()));
|
||||
}
|
||||
productSkuUp(updateValueVO, product);
|
||||
@@ -383,6 +400,13 @@ public class StockServiceImpl implements StockService {
|
||||
tbProductRepository.upLowPrice(product.getId(),new BigDecimal(updateValueVO.getValue()));
|
||||
tbProductSkuRepository.upSalePrice(product.getId(),new BigDecimal(updateValueVO.getValue()));
|
||||
break;
|
||||
case "refundStock"://商品 暂停销售
|
||||
if (!"0".equals(updateValueVO.getValue()) && !"1".equals(updateValueVO.getValue())) {
|
||||
throw new BadRequestException("无效值");
|
||||
}
|
||||
sqlQuery.append(" set is_refund_stock = ").append(updateValueVO.getValue());
|
||||
description.append(" 修改为" + ("0".equals(updateValueVO.getValue()) ? "退款不退回库存":"退款退回库存"));
|
||||
break;
|
||||
// case "stock"://库存开关
|
||||
// if (!"0".equals(updateValueVO.getValue()) && !"1".equals(updateValueVO.getValue())) {
|
||||
// throw new BadRequestException("无效值");
|
||||
|
||||
@@ -1,35 +1,22 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.service.impl.productimpl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.product.StockCountDTO;
|
||||
import cn.ysk.cashier.dto.product.*;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbProducSkutMapper;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
|
||||
import cn.ysk.cashier.repository.order.StockCountRepository;
|
||||
import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
|
||||
import cn.ysk.cashier.repository.product.ProductStockCountRepository;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import cn.ysk.cashier.vo.TbProductStockCountVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import cn.ysk.cashier.repository.product.TbProductStockDetailRepository;
|
||||
import cn.ysk.cashier.service.product.TbProductStockDetailService;
|
||||
import cn.ysk.cashier.dto.product.TbProductStockDetailDto;
|
||||
import cn.ysk.cashier.dto.product.TbProductStockDetailQueryCriteria;
|
||||
import cn.ysk.cashier.mapper.product.TbProductStockDetailMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -38,6 +25,8 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import javax.persistence.EntityManager;
|
||||
@@ -58,6 +47,7 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
||||
private final TbProductStockDetailMapper tbProductStockDetailMapper;
|
||||
|
||||
private final StockCountRepository stockCountRepository;
|
||||
private final ProductStockCountRepository stockRepository;
|
||||
private final EntityManager entityManager;
|
||||
private final TbOrderInfoRepository tbOrderInfoRepository;
|
||||
private final TbProducSkutMapper skutMapper;
|
||||
@@ -72,6 +62,33 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryPage(TbProductStockDetailQueryCriteria criteria){
|
||||
if(StringUtils.isBlank(criteria.getColumn())){
|
||||
throw new BadRequestException("必填参数未填写");
|
||||
}
|
||||
switch (criteria.getColumn()){
|
||||
case "addCountNumber":
|
||||
criteria.setType(Arrays.asList("供应商入库", "盘点入库", "其他入库", "退单"));
|
||||
break;
|
||||
case "addNumber":
|
||||
criteria.setType(Arrays.asList("供应商入库", "盘点入库", "其他入库"));
|
||||
break;
|
||||
case "refundNumber":
|
||||
criteria.setType(Arrays.asList("退单"));
|
||||
break;
|
||||
case "subCountNumber":
|
||||
criteria.setType(Arrays.asList("供应商出库","其他出库","盘点出库","售出记录","报损"));
|
||||
break;
|
||||
case "subNumber":
|
||||
criteria.setType(Arrays.asList("供应商出库","其他出库","盘点出库","售出记录"));
|
||||
break;
|
||||
case "saleNumber":
|
||||
criteria.setType(Arrays.asList("售出记录"));
|
||||
break;
|
||||
case "lossNumber":
|
||||
criteria.setType(Arrays.asList("报损"));
|
||||
break;
|
||||
}
|
||||
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
|
||||
|
||||
@@ -98,6 +115,39 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbProductStockCountVo stockCount(TbProductStockCountQueryCriteria criteria) throws ParseException {
|
||||
if (criteria.getStartTime() == null || criteria.getEndTime() == null) {
|
||||
criteria.setEndTime(new Date());//
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
criteria.setStartTime(sdf.parse("2024-01-01"));//创建2024年1月1日的Date对象
|
||||
}
|
||||
return stockRepository.stockCount(criteria.getShopId().toString(), criteria.getProductName(),
|
||||
criteria.getCategoryId(), criteria.getStartTime().getTime(), criteria.getEndTime().getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> stockList(TbProductStockCountQueryCriteria criteria) throws ParseException {
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
|
||||
if (criteria.getStartTime() == null || criteria.getEndTime() == null) {
|
||||
criteria.setEndTime(new Date());//
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
criteria.setStartTime(sdf.parse("2024-01-01"));//创建2024年1月1日的Date对象
|
||||
}
|
||||
Page<TbProductStockListDto> tbProductStockCountDtos = stockRepository.stock2(
|
||||
criteria.getShopId().toString(),
|
||||
criteria.getProductName(),
|
||||
criteria.getCategoryId(),
|
||||
criteria.getStartTime().getTime(), criteria.getEndTime().getTime(), pageable);
|
||||
if (!tbProductStockCountDtos.isEmpty()) {
|
||||
tbProductStockCountDtos.getContent().parallelStream().forEach(s->{
|
||||
s.setCountNumber(s.getStockNumber().add(s.getSubCountNumber()));
|
||||
});
|
||||
}
|
||||
return PageUtil.toPage(tbProductStockCountDtos);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TbProductStockDetailDto> queryAll(TbProductStockDetailQueryCriteria criteria){
|
||||
|
||||
@@ -259,24 +259,6 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
|
||||
BigDecimal totalCostPrice;
|
||||
productStockDetail.setType(resources.getType());
|
||||
switch (resources.getType()) {
|
||||
case "sale":
|
||||
productStockDetail.setStockNumber((double) -productListDto.getNumber());
|
||||
productStockDetail.setSubType(-1);
|
||||
break;
|
||||
//后台出库
|
||||
case "refund":
|
||||
productStockDetail.setStockNumber((double) -productListDto.getNumber());
|
||||
productStockDetail.setSubType(1);
|
||||
totalCostPrice = productListDto.getCostPrice().multiply(BigDecimal.valueOf(productListDto.getNumber()));
|
||||
productStockDetail.setCostAmount(totalCostPrice);
|
||||
productStockDetail.setType("供应商出库");
|
||||
|
||||
// 获取增加后的库存
|
||||
double refundStockNum = getStockNum(product, tbProductSku, productListDto.getNumber(), false);
|
||||
setProSpecInfo(product, tbProductSku, refundStockNum,
|
||||
productListDto.getCostPrice(), isDistribute);
|
||||
|
||||
break;
|
||||
case "reject":
|
||||
productStockDetail.setStockNumber((double) -productListDto.getNumber());
|
||||
productStockDetail.setSubType(-1);
|
||||
@@ -517,7 +499,8 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
|
||||
: productSku.getStockNumber().intValue() - stockRecordMsg.getNumber());
|
||||
productStockDetail.setRecordId(stockOperate.getId().toString());
|
||||
productStockDetail.setStockSnap(JSONObject.toJSONString(snapItem));
|
||||
productStockDetail.setSourcePath("NORMAL");
|
||||
productStockDetail.setSourcePath("CASHIER");
|
||||
productStockDetail.setRemark(stockRecordMsg.getRemark());
|
||||
productStockDetailRepository.save(productStockDetail);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,15 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.service.product;
|
||||
|
||||
import cn.ysk.cashier.dto.product.TbProductStockCountQueryCriteria;
|
||||
import cn.ysk.cashier.dto.rabbit.StockRecordMsg;
|
||||
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
|
||||
import cn.ysk.cashier.dto.product.TbProductStockDetailDto;
|
||||
import cn.ysk.cashier.dto.product.TbProductStockDetailQueryCriteria;
|
||||
import cn.ysk.cashier.vo.TbProductStockCountVo;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
@@ -45,6 +33,8 @@ public interface TbProductStockDetailService {
|
||||
Map<String,Object> queryAll(TbProductStockDetailQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
Map<String,Object> queryPage(TbProductStockDetailQueryCriteria criteria);
|
||||
TbProductStockCountVo stockCount(TbProductStockCountQueryCriteria criteria) throws ParseException;
|
||||
Map<String,Object> stockList(TbProductStockCountQueryCriteria criteria) throws ParseException;
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
|
||||
Reference in New Issue
Block a user