Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
SongZhang 2024-10-14 16:28:53 +08:00
commit 5e8e6661b9
3 changed files with 40 additions and 28 deletions

View File

@ -38,7 +38,7 @@ public interface TbShopCategoryRepository extends JpaRepository<TbShopCategory,
@Query("SELECT category FROM TbShopCategory category where category.tree IN :ids and category.id != category.tree")
List<TbShopCategory> findChildren(@Param("ids")List<Integer> ids);
@Query(" SELECT category FROM TbShopCategory category where category.shopId = :shopId")
@Query(" SELECT category FROM TbShopCategory category where category.shopId = :shopId and (category.pid is null or category.pid = '')")
Page<TbShopCategory> findAllBy(@Param("shopId") String shopId,Pageable pageable);

View File

@ -32,6 +32,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import javax.servlet.http.HttpServletResponse;
@Service
@ -243,10 +244,20 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
@Override
public void addSaleRecord(Integer orderId) {
// 先进行延迟
CompletableFuture<Void> delayFuture = CompletableFuture.runAsync(() -> {
try {
Thread.sleep(3000L);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
});
delayFuture.thenRun(() -> {
List<StockCountDTO> stockCountDTOS = stockCountRepository.countStockById(orderId);
log.info("查询到订单id: {}的所有库存数据: {}", orderId, stockCountDTOS);
stockCountDTOS.forEach(s -> {
//客座费不统计
if (s.getProId() > 0) {
if (s.getStockCount() > 0) {
TbProductStockDetail productStockDetail = new TbProductStockDetail();
@ -271,6 +282,7 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
skutMapper.incrRealSalesNumber(s.getSkuId().intValue(), s.getStockCount());
}
});
});
}
}

View File

@ -91,7 +91,7 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
.filter(d -> d.getTree()==null || d.getId().equals(d.getTree()))
.collect(Collectors.toList());
return PageUtil.toPage(result, page.getTotalElements()-children.size());
return PageUtil.toPage(result, page.getTotalElements());
}
// @Override