日售出销量统计 前一天的
This commit is contained in:
@@ -1,18 +1,3 @@
|
||||
/*
|
||||
* 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.quartz.rest;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
package cn.ysk.cashier.quartz.task;
|
||||
|
||||
import cn.ysk.cashier.dto.product.StockCountDTO;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
|
||||
import cn.ysk.cashier.repository.order.StockCountRepository;
|
||||
import cn.ysk.cashier.repository.order.TbCashierCartRepository;
|
||||
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
|
||||
import cn.ysk.cashier.service.order.TbCashierCartService;
|
||||
import cn.ysk.cashier.service.shop.TbShopStorageService;
|
||||
import cn.ysk.cashier.utils.CacheKey;
|
||||
import cn.ysk.cashier.utils.DateUtil;
|
||||
import cn.ysk.cashier.utils.QueryHelp;
|
||||
import cn.ysk.cashier.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -32,12 +36,15 @@ public class TestTask {
|
||||
private TbShopStorageService storageService;
|
||||
@Autowired
|
||||
private TbCashierCartRepository cartService;
|
||||
@Autowired
|
||||
private StockCountRepository stockCountRepository;
|
||||
|
||||
@Autowired
|
||||
private TbProductSkuRepository skuRepository;
|
||||
@Autowired
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
private final TbCashierCartService tbCashierCartService;
|
||||
|
||||
public TestTask(TbCashierCartService tbCashierCartService) {
|
||||
@@ -87,4 +94,32 @@ public class TestTask {
|
||||
redisUtils.del(keysArray);
|
||||
log.info("购物车清楚记录开始结束");
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void countStock(){
|
||||
log.info("记录当日库存损耗开始");
|
||||
List<StockCountDTO> stockCountDTOS = stockCountRepository.countStock(DateUtil.getStrTime(DateUtil.getBeginDayOfYesterday()), DateUtil.getStrTime(DateUtil.getEndDayOfYesterday()));
|
||||
System.out.println(stockCountDTOS);
|
||||
stockCountDTOS.forEach(s->{
|
||||
TbProductStockDetail productStockDetail = new TbProductStockDetail();
|
||||
productStockDetail.setCreatedAt(System.currentTimeMillis());
|
||||
productStockDetail.setUpdatedAt(System.currentTimeMillis());
|
||||
productStockDetail.setShopId(s.getShopId().toString());
|
||||
productStockDetail.setProductId(s.getProId().toString());
|
||||
productStockDetail.setProductName(s.getProName());
|
||||
// productStockDetail.setSkuId(s.getSkuId().toString());
|
||||
productStockDetail.setIsStock(s.getIsStock());//是否开启库存
|
||||
productStockDetail.setLeftNumber(s.getStockNumber()+s.getStockCount());//原库存
|
||||
// productStockDetail.setSpecSnap(s.getSkuName());
|
||||
productStockDetail.setUnitName(s.getUnitName());
|
||||
productStockDetail.setStockNumber(-Double.valueOf(s.getStockCount()));
|
||||
productStockDetail.setSourcePath("NORMAL");
|
||||
productStockDetail.setType("other-out");
|
||||
productStockDetail.setRemark(DateUtil.getYMDTime(DateUtil.getBeginDayOfYesterday())+"日统计库存");
|
||||
productStockDetail.setSubType(-1);
|
||||
productStockDetail.setType(DateUtil.getYMDTime(DateUtil.getBeginDayOfYesterday())+"日售出记录");
|
||||
entityManager.persist(productStockDetail);
|
||||
});
|
||||
log.info("记录当日库存损耗结束");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user