|
|
@@ -275,8 +275,8 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
@Autowired
|
|
|
private FloorsService floorsService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ProductDetailDao productDetailDao;
|
|
|
+ @Autowired
|
|
|
+ private ProductDetailDao productDetailDao;
|
|
|
|
|
|
@Autowired
|
|
|
private OrderDetailService orderDetailService;
|
|
|
@@ -331,8 +331,8 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
throw new IllegalOperatorException("商品信息Goods不能为空");
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(goods.getSpec())) {
|
|
|
- String spec = com.uas.platform.b2c.fa.payment.utils.StringUtils.cutOutStringIgnoreEncode(goods.getSpec().toString(), UploadConstant.SPEC_MAX_BYTE);
|
|
|
- goods.setSpec(spec);
|
|
|
+ String spec = com.uas.platform.b2c.fa.payment.utils.StringUtils.cutOutStringIgnoreEncode(goods.getSpec().toString(), UploadConstant.SPEC_MAX_BYTE);
|
|
|
+ goods.setSpec(spec);
|
|
|
}
|
|
|
if (goods.getCurrencyName() == null) {
|
|
|
throw new IllegalOperatorException("必须选择一种币别");
|
|
|
@@ -550,24 +550,24 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
Double reserve = goods.getReserve() - number;
|
|
|
|
|
|
- goods.setReserve(reserve);
|
|
|
- // 检查是否小于最小发货量
|
|
|
- if (reserve.doubleValue() < goods.getMinBuyQty().doubleValue()) {
|
|
|
- goods.setStatus(Status.UNAVAILABLE.value());
|
|
|
- }
|
|
|
- goodsDao.modifyReserve(goods.getBatchCode(), goods.getUuid(), goods.getReserve(), goods.getStatus().intValue());
|
|
|
- // 每次批次保存同时保存一遍历史信息
|
|
|
- GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.DeductReserve.getPhrase(), false);
|
|
|
- goodsHistoryService.save(goodsHistory);
|
|
|
- // 更新器件属性的库存
|
|
|
- updateComponentTradeInfos(goods.getUuid());
|
|
|
-
|
|
|
- // 扣除库存时,同步产品推荐的信息
|
|
|
- if (Status.UNAVAILABLE.value() == goods.getStatus()) {
|
|
|
+ goods.setReserve(reserve);
|
|
|
+ // 检查是否小于最小发货量
|
|
|
+ if (reserve.doubleValue() < goods.getMinBuyQty().doubleValue()) {
|
|
|
+ goods.setStatus(Status.UNAVAILABLE.value());
|
|
|
+ }
|
|
|
+ goodsDao.modifyReserve(goods.getBatchCode(), goods.getUuid(), goods.getReserve(), goods.getStatus().intValue());
|
|
|
+ // 每次批次保存同时保存一遍历史信息
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.DeductReserve.getPhrase(), false);
|
|
|
+ goodsHistoryService.save(goodsHistory);
|
|
|
+ // 更新器件属性的库存
|
|
|
+ updateComponentTradeInfos(goods.getUuid());
|
|
|
+
|
|
|
+ // 扣除库存时,同步产品推荐的信息
|
|
|
+ if (Status.UNAVAILABLE.value() == goods.getStatus()) {
|
|
|
recommendProductService.updateRecommendProductInfo(goods);
|
|
|
- }
|
|
|
- return ResultMap.success(null);
|
|
|
- }
|
|
|
+ }
|
|
|
+ return ResultMap.success(null);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 释放库存
|
|
|
@@ -752,37 +752,37 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return backGoods;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public Goods publish(Goods goods, String deviceInfo, Product product) {
|
|
|
- ProductDetail productDetail = productDetailDao.findByProductId(product.getId());
|
|
|
- if (productDetail == null) {
|
|
|
- productDetail = new ProductDetail();
|
|
|
- } else if (product.getErpReserve() != null) {
|
|
|
- ProductDetail newProductDetail = productService.findByProductId(product.getId());
|
|
|
- if (product.getErpReserve() < goods.getReserve() + newProductDetail.getB2cReserve()) {
|
|
|
- throw new IllegalOperatorException("本次上架数量和已上架数量之和不可超过ERP空闲库存数量");
|
|
|
- }
|
|
|
- }
|
|
|
- productDetail.convertFromGoods(goods, product);
|
|
|
- productDetailDao.save(productDetail);
|
|
|
- Goods saveGoods = publish(goods, deviceInfo);
|
|
|
- return saveGoods;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public List<Goods> publish(List<Goods> goodses, String deviceInfo) {
|
|
|
- Set<String> uuids = new HashSet<String>();
|
|
|
- List<Goods> list = new ArrayList<Goods>();
|
|
|
- System.out.println("执行了publishByBatch-------start");
|
|
|
- publishByBatch(goodses, uuids, list);
|
|
|
- System.out.println("执行了publishByBatch-----end");
|
|
|
- for (String uuid : uuids) {
|
|
|
- updateComponentTradeInfos(uuid);
|
|
|
- }
|
|
|
- return list;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Goods publish(Goods goods, String deviceInfo, Product product) {
|
|
|
+ ProductDetail productDetail = productDetailDao.findByProductId(product.getId());
|
|
|
+ if (productDetail == null) {
|
|
|
+ productDetail = new ProductDetail();
|
|
|
+ } else if (product.getErpReserve() != null) {
|
|
|
+ ProductDetail newProductDetail = productService.findByProductId(product.getId());
|
|
|
+ if (product.getErpReserve() < goods.getReserve() + newProductDetail.getB2cReserve()) {
|
|
|
+ throw new IllegalOperatorException("本次上架数量和已上架数量之和不可超过ERP空闲库存数量");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ productDetail.convertFromGoods(goods, product);
|
|
|
+ productDetailDao.save(productDetail);
|
|
|
+ Goods saveGoods = publish(goods, deviceInfo);
|
|
|
+ return saveGoods;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public List<Goods> publish(List<Goods> goodses, String deviceInfo) {
|
|
|
+ Set<String> uuids = new HashSet<String>();
|
|
|
+ List<Goods> list = new ArrayList<Goods>();
|
|
|
+ System.out.println("执行了publishByBatch-------start");
|
|
|
+ publishByBatch(goodses, uuids, list);
|
|
|
+ System.out.println("执行了publishByBatch-----end");
|
|
|
+ for (String uuid : uuids) {
|
|
|
+ updateComponentTradeInfos(uuid);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 批量更新库存信息 辅助方法
|
|
|
@@ -933,37 +933,37 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
public void updateComponentTradeInfos(final String uuid) {
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 导入Excel发布产品
|
|
|
- *
|
|
|
- * @author hejq
|
|
|
- */
|
|
|
- @Override
|
|
|
- public ModelMap publishByWorkbook(Workbook workbook) {
|
|
|
- ModelMap modelMap = new ModelMap();
|
|
|
- List<String> alters = new ArrayList<String>();
|
|
|
- List<Goods> goodses = new ArrayList<Goods>();
|
|
|
- Sheet sheet = workbook.getSheetAt(0);
|
|
|
- int rowNum = sheet.getLastRowNum();
|
|
|
- if(rowNum > 2000) {
|
|
|
- throw new IllegalOperatorException
|
|
|
- ("信息超过2000条,请拆分成2000条以内");
|
|
|
- }
|
|
|
- Row headerRow = sheet.getRow(0);
|
|
|
- try {
|
|
|
- if (headerRow != null) {
|
|
|
- for (int r = 1; r <= rowNum; r++) {
|
|
|
- Row row = sheet.getRow(r);
|
|
|
- if (row != null && row.getCell(3) != null) {
|
|
|
- Goods goods = new Goods();
|
|
|
- if (row.getCell(3) == null) {
|
|
|
- throw new IllegalOperatorException("请上传从第一步操作中下载的发布模板");
|
|
|
- }
|
|
|
- String uuid = row.getCell(3).getStringCellValue();
|
|
|
- if (StringUtils.isEmpty(uuid)) {
|
|
|
- throw new IllegalOperatorException("请上传从商城下载的批量发布模板");
|
|
|
- }
|
|
|
- goods.setUuid(uuid);
|
|
|
+ /**
|
|
|
+ * 导入Excel发布产品
|
|
|
+ *
|
|
|
+ * @author hejq
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ModelMap publishByWorkbook(Workbook workbook) {
|
|
|
+ ModelMap modelMap = new ModelMap();
|
|
|
+ List<String> alters = new ArrayList<String>();
|
|
|
+ List<Goods> goodses = new ArrayList<Goods>();
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ int rowNum = sheet.getLastRowNum();
|
|
|
+ if(rowNum > 2000) {
|
|
|
+ throw new IllegalOperatorException
|
|
|
+ ("信息超过2000条,请拆分成2000条以内");
|
|
|
+ }
|
|
|
+ Row headerRow = sheet.getRow(0);
|
|
|
+ try {
|
|
|
+ if (headerRow != null) {
|
|
|
+ for (int r = 1; r <= rowNum; r++) {
|
|
|
+ Row row = sheet.getRow(r);
|
|
|
+ if (row != null && row.getCell(3) != null) {
|
|
|
+ Goods goods = new Goods();
|
|
|
+ if (row.getCell(3) == null) {
|
|
|
+ throw new IllegalOperatorException("请上传从第一步操作中下载的发布模板");
|
|
|
+ }
|
|
|
+ String uuid = row.getCell(3).getStringCellValue();
|
|
|
+ if (StringUtils.isEmpty(uuid)) {
|
|
|
+ throw new IllegalOperatorException("请上传从商城下载的批量发布模板");
|
|
|
+ }
|
|
|
+ goods.setUuid(uuid);
|
|
|
|
|
|
// 产品uuid
|
|
|
String cmpCode = row.getCell(2).getStringCellValue();
|
|
|
@@ -1574,16 +1574,16 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
List<GoodsBrowsingHistory> browsingHistories = browsingHistoryService.updateGoodsBrowsingHistoryByGoods(nowGoods);
|
|
|
updateGoodsRelateInfo(orders, cartList, browsingHistories, null, history, nowGoods);
|
|
|
|
|
|
- //更新店铺推荐的信息
|
|
|
- if(isChangeSaleType) { // 如果切换了销售方式
|
|
|
- Set<String> uuids = new HashSet<>();
|
|
|
- uuids.add(nowGoods.getBatchCode());
|
|
|
- recommendProductService.deleteProductsWhenSellerUpdateReserve(storeuuid, uuids);
|
|
|
- } else {
|
|
|
+ //更新店铺推荐的信息
|
|
|
+ if(isChangeSaleType) { // 如果切换了销售方式
|
|
|
+ Set<String> uuids = new HashSet<>();
|
|
|
+ uuids.add(nowGoods.getBatchCode());
|
|
|
+ recommendProductService.deleteProductsWhenSellerUpdateReserve(storeuuid, uuids);
|
|
|
+ } else {
|
|
|
recommendProductService.updateRecommendProductInfo(nowGoods);
|
|
|
}
|
|
|
- return nowGoods;
|
|
|
- }
|
|
|
+ return nowGoods;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 用户更新在售产品的信息, 设置店铺名称
|
|
|
@@ -2368,17 +2368,17 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return ResultMap.success(commodity);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ResultMap offShelfGoodsByProvider(String batchCodes, String downMsg, Boolean isERP) {
|
|
|
- if (StringUtils.isEmpty(batchCodes)) {
|
|
|
- return new ResultMap(CodeType.NO_INFO.code(), "待下架批次号字符串不能为空");
|
|
|
- }
|
|
|
- String[] batchCodeArr = batchCodes.split(",");
|
|
|
- if (batchCodeArr.length == 0) {
|
|
|
- return new ResultMap(CodeType.NO_INFO.code(), "待下架批次号不能为空");
|
|
|
- }
|
|
|
- Set<String> uuids = new HashSet<>();
|
|
|
- List<String> batchCodeList = new ArrayList<>();
|
|
|
+ @Override
|
|
|
+ public ResultMap offShelfGoodsByProvider(String batchCodes, String downMsg, Boolean isERP) {
|
|
|
+ if (StringUtils.isEmpty(batchCodes)) {
|
|
|
+ return new ResultMap(CodeType.NO_INFO.code(), "待下架批次号字符串不能为空");
|
|
|
+ }
|
|
|
+ String[] batchCodeArr = batchCodes.split(",");
|
|
|
+ if (batchCodeArr.length == 0) {
|
|
|
+ return new ResultMap(CodeType.NO_INFO.code(), "待下架批次号不能为空");
|
|
|
+ }
|
|
|
+ Set<String> uuids = new HashSet<>();
|
|
|
+ List<String> batchCodeList = new ArrayList<>();
|
|
|
|
|
|
List<Goods> list = new ArrayList<>();
|
|
|
for (String batchCode : batchCodeArr) {
|
|
|
@@ -2490,11 +2490,11 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsHistoryService.save(goodsHist);
|
|
|
|
|
|
Goods updateGoods = goodsDao.save(goods);
|
|
|
- //下架对应的批次 目前确定下架之后不做删除动作。
|
|
|
- // goodsDao.deleteByBatchCode(goods.getBatchCode());
|
|
|
- // 需要替换首页的信息。
|
|
|
- return ResultMap.success(updateGoods);
|
|
|
- }
|
|
|
+ //下架对应的批次 目前确定下架之后不做删除动作。
|
|
|
+ // goodsDao.deleteByBatchCode(goods.getBatchCode());
|
|
|
+ // 需要替换首页的信息。
|
|
|
+ return ResultMap.success(updateGoods);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public Page<Goods> findGoodsPage(final PageInfo info) {
|
|
|
@@ -3012,7 +3012,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
uuids.add(goods.getUuid());
|
|
|
}
|
|
|
|
|
|
- goodsDao.save(goodsUpdate);
|
|
|
+ goodsDao.save(goodsUpdate);
|
|
|
goodsHistoryDao.save(histories);
|
|
|
for (String uuid : uuids) {
|
|
|
updateComponentTradeInfos(uuid);
|
|
|
@@ -3058,29 +3058,29 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return ResultMap.success(goods);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 更新库存的相关信息
|
|
|
- *
|
|
|
- * @param orders 订单
|
|
|
- * @param carts 购物车信息
|
|
|
- * @param browsingHistoryList 浏览历史
|
|
|
- * @param product 产品
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Transactional
|
|
|
- @Override
|
|
|
- public ResultMap updateGoodsRelateInfo(List<Order> orders, List<Cart> carts, List<GoodsBrowsingHistory> browsingHistoryList, Product product, GoodsHistory goodsHistory, Goods goods) {
|
|
|
- goodsDao.save(goods);
|
|
|
- orderDao.save(orders);
|
|
|
- orderService.save(orders);
|
|
|
- cartService.saveCart(carts);
|
|
|
- browsingHistoryService.saveGoodsBrowsingHistoryList(browsingHistoryList);
|
|
|
- goodsHistoryService.save(goodsHistory);
|
|
|
- return ResultMap.success(null);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void addVisitCount(String batchCode) {
|
|
|
+ /**
|
|
|
+ * 更新库存的相关信息
|
|
|
+ *
|
|
|
+ * @param orders 订单
|
|
|
+ * @param carts 购物车信息
|
|
|
+ * @param browsingHistoryList 浏览历史
|
|
|
+ * @param product 产品
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public ResultMap updateGoodsRelateInfo(List<Order> orders, List<Cart> carts, List<GoodsBrowsingHistory> browsingHistoryList, Product product, GoodsHistory goodsHistory, Goods goods) {
|
|
|
+ goodsDao.save(goods);
|
|
|
+ orderDao.save(orders);
|
|
|
+ orderService.save(orders);
|
|
|
+ cartService.saveCart(carts);
|
|
|
+ browsingHistoryService.saveGoodsBrowsingHistoryList(browsingHistoryList);
|
|
|
+ goodsHistoryService.save(goodsHistory);
|
|
|
+ return ResultMap.success(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addVisitCount(String batchCode) {
|
|
|
goodsDao.addVisitCount(batchCode);
|
|
|
}
|
|
|
|
|
|
@@ -3508,22 +3508,16 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return String.valueOf(goodses.size());
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Page<Goods> getPageDataOfBackground(final PageInfo info, GoodsFilter goodsFilter) {
|
|
|
- if (info == null) {
|
|
|
- throw new IllegalOperatorException("分页参数丢失");
|
|
|
- }
|
|
|
- if (goodsFilter != null) {
|
|
|
- convertPageInfo(info, goodsFilter);
|
|
|
- }
|
|
|
- Page<Goods> page = goodsDao.findAll(new Specification<Goods>() {
|
|
|
- @Override
|
|
|
- public Predicate toPredicate(Root<Goods> root, CriteriaQuery<?> query,
|
|
|
- CriteriaBuilder builder) {
|
|
|
- query.where(info.getPredicates(root, query, builder));
|
|
|
- return null;
|
|
|
- }
|
|
|
- }, info);
|
|
|
+ @Override
|
|
|
+ public Page<Goods> getPageDataOfBackground(final PageInfo info, GoodsFilter goodsFilter) {
|
|
|
+ if (info == null) {
|
|
|
+ throw new IllegalOperatorException("分页参数丢失");
|
|
|
+ }
|
|
|
+ if (goodsFilter != null) {
|
|
|
+ convertPageInfo(info, goodsFilter);
|
|
|
+ }
|
|
|
+ Page<Goods> page = goodsDao.findAll((Root<Goods> root, CriteriaQuery<?> query, CriteriaBuilder builder)
|
|
|
+ -> query.where(info.getPredicates(root, query, builder)).getRestriction(), info);
|
|
|
List<Goods> goodsList = page.getContent();
|
|
|
for (Goods goods : goodsList) {
|
|
|
if (sysConf.getStoreid().equals(goods.getStoreid())) {
|
|
|
@@ -3534,8 +3528,8 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goods.setFrozen(getFrozenCount(goods.getBatchCode()));
|
|
|
goods.setMaxPriceIndex(goods.getPrices().size() - 1);
|
|
|
}
|
|
|
- return page;
|
|
|
- }
|
|
|
+ return page;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 根据店铺id查找店铺所属企业enUU
|
|
|
@@ -3630,27 +3624,32 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return stock;
|
|
|
}
|
|
|
|
|
|
- private void convertPageInfo(PageInfo info, GoodsFilter goodsFilter) {
|
|
|
+ /**
|
|
|
+ * 封装分页过滤条件
|
|
|
+ *
|
|
|
+ * @param info 分页信息
|
|
|
+ * @param goodsFilter 筛选条件
|
|
|
+ */
|
|
|
+ private void convertPageInfo(PageInfo info, GoodsFilter goodsFilter) {
|
|
|
if (!StringUtils.isEmpty(goodsFilter.getStartTime())) {
|
|
|
java.sql.Date startDate = new java.sql.Date(goodsFilter.getStartTime());
|
|
|
info.expression(PredicateUtils.gte("createdDate", startDate, true));
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(goodsFilter.getEndTime())) {
|
|
|
// 截止日期是到当天23:59:59,java.sql.Date精确到天,这里采用加一天小于的方法设置截止日期判断
|
|
|
- Integer addend = 60 * 60 * 24 * 1000;
|
|
|
- java.sql.Date endDate = new java.sql.Date(goodsFilter.getEndTime() + addend);
|
|
|
+ java.sql.Date endDate = new java.sql.Date(goodsFilter.getEndTime() + IntegerConstant.ONE_DAY_MILLISECONDS);
|
|
|
info.expression(PredicateUtils.lt("createdDate", endDate, true));
|
|
|
}
|
|
|
- if (!StringUtils.isEmpty(goodsFilter.getCode())) {
|
|
|
- info.filter("code", goodsFilter.getCode());
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(goodsFilter.getBrand())) {
|
|
|
- SimpleExpression[] brandExpression = new SimpleExpression[2];
|
|
|
- brandExpression[0] = PredicateUtils.like("brandNameCn", goodsFilter.getBrand(), false, true);
|
|
|
- brandExpression[1] = PredicateUtils.like("brandNameEn", goodsFilter.getBrand(), false, true);
|
|
|
- info.expression(PredicateUtils.or((CriterionExpression[]) brandExpression));
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(goodsFilter.getStore())) {
|
|
|
+ if (!StringUtils.isEmpty(goodsFilter.getCode())) {
|
|
|
+ info.filter("code", goodsFilter.getCode());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(goodsFilter.getBrand())) {
|
|
|
+ SimpleExpression[] brandExpression = new SimpleExpression[2];
|
|
|
+ brandExpression[0] = PredicateUtils.like("brandNameCn", goodsFilter.getBrand(), false, true);
|
|
|
+ brandExpression[1] = PredicateUtils.like("brandNameEn", goodsFilter.getBrand(), false, true);
|
|
|
+ info.expression(PredicateUtils.or((CriterionExpression[]) brandExpression));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(goodsFilter.getStore())) {
|
|
|
if (RegexConstant.onlyHaveNumber(goodsFilter.getStore())) {
|
|
|
SimpleExpression[] storeExpression = new SimpleExpression[2];
|
|
|
storeExpression[0] = PredicateUtils.eq("enUU", goodsFilter.getStore(), true);
|
|
|
@@ -3659,8 +3658,8 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
} else {
|
|
|
info.filter("storeName", goodsFilter.getStore());
|
|
|
}
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(goodsFilter.getKindUuid())) {
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(goodsFilter.getKindUuid())) {
|
|
|
// 如果包含多个叶子类目ID,则获取所有的叶子类目对应的商品信息
|
|
|
if (goodsFilter.getKindUuid().contains(SplitChar.COMMA)) {
|
|
|
String[] kindIds = goodsFilter.getKindUuid().split(SplitChar.COMMA);
|
|
|
@@ -3669,21 +3668,21 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
info.expression(PredicateUtils.eq("kindUuid", goodsFilter.getKindUuid(), false));
|
|
|
}
|
|
|
}
|
|
|
- if (!StringUtils.isEmpty(goodsFilter.getCurrency())) {
|
|
|
- info.expression(PredicateUtils.eq("currencyName", goodsFilter.getCurrency(), false));
|
|
|
- }
|
|
|
- if (goodsFilter.getSaleSelf() != null) {
|
|
|
- if (goodsFilter.getSaleSelf()) {
|
|
|
- info.expression(PredicateUtils.ne("storeid", sysConf.getStoreid(), false));
|
|
|
- } else {
|
|
|
- info.expression(PredicateUtils.eq("storeid", sysConf.getStoreid(), false));
|
|
|
- }
|
|
|
- }
|
|
|
- if (goodsFilter.getBreakUp() != null) {
|
|
|
+ if (!StringUtils.isEmpty(goodsFilter.getCurrency())) {
|
|
|
+ info.expression(PredicateUtils.eq("currencyName", goodsFilter.getCurrency(), false));
|
|
|
+ }
|
|
|
+ if (goodsFilter.getSaleSelf() != null) {
|
|
|
+ if (goodsFilter.getSaleSelf()) {
|
|
|
+ info.expression(PredicateUtils.ne("storeid", sysConf.getStoreid(), false));
|
|
|
+ } else {
|
|
|
+ info.expression(PredicateUtils.eq("storeid", sysConf.getStoreid(), false));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (goodsFilter.getBreakUp() != null) {
|
|
|
int breakUp = goodsFilter.getBreakUp() ? 1 : 0;
|
|
|
- info.filter("breakUp", breakUp, false);
|
|
|
- }
|
|
|
- if (goodsFilter.getHaveImg() != null) {
|
|
|
+ info.filter("breakUp", breakUp, false);
|
|
|
+ }
|
|
|
+ if (goodsFilter.getHaveImg() != null) {
|
|
|
if (goodsFilter.getHaveImg()) {
|
|
|
info.expression(PredicateUtils.isNotNull("img"));
|
|
|
} else {
|
|
|
@@ -3712,7 +3711,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
statusSet.add(goodsFilter.getSaleStatus());
|
|
|
}
|
|
|
}
|
|
|
- if (goodsFilter.getSaleNum() != null && 603 != goodsFilter.getSaleNum()) {
|
|
|
+ if (goodsFilter.getSaleNum() != null && Status.HAS_NO_INVENTORY.value() != goodsFilter.getSaleNum()) {
|
|
|
statusSet.add(goodsFilter.getSaleNum());
|
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(statusSet)) {
|
|
|
@@ -3724,10 +3723,10 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
info.expression(PredicateUtils.or((CriterionExpression[]) statusExpression));
|
|
|
}
|
|
|
}
|
|
|
- if (goodsFilter.getSaleNum() != null && 603 == goodsFilter.getSaleNum()) {
|
|
|
+ if (goodsFilter.getSaleNum() != null && Status.HAS_NO_INVENTORY.value() == goodsFilter.getSaleNum()) {
|
|
|
info.expression(PredicateUtils.eq("reserve", 0, true));
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public Map<String, List<Goods>> getCmsPcb() {
|
|
|
@@ -4064,14 +4063,12 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
*/
|
|
|
@Override
|
|
|
public com.uas.sso.support.Page<BrandCount> getBrandProductsCount(Pageable pageable, Date startTime, Date endTime) {
|
|
|
- java.sql.Date startDate = assignStartDate(startTime);
|
|
|
- java.sql.Date endDate = assignEndDate(endTime);
|
|
|
StringBuffer sql = new StringBuffer("select pr_brand as brand, count(1) as count from products where pr_brand is not null ");
|
|
|
- if (null != startDate) {
|
|
|
- sql.append(" and pr_create_time >= '").append(startDate).append("' ");
|
|
|
+ if (null != startTime) {
|
|
|
+ sql.append(" and pr_create_time >= '").append(new java.sql.Date(startTime.getTime())).append("' ");
|
|
|
}
|
|
|
- if (null != endDate) {
|
|
|
- sql.append(" and pr_create_time < '").append(endDate).append("' ");
|
|
|
+ if (null != endTime) {
|
|
|
+ sql.append(" and pr_create_time < '").append(new java.sql.Date(endTime.getTime() + IntegerConstant.ONE_DAY_MILLISECONDS) ).append("' ");
|
|
|
}
|
|
|
sql.append("group by pr_brand");
|
|
|
StringBuffer countSql = new StringBuffer("select count(1) from (").append(sql).append(") as a");
|
|
|
@@ -4083,43 +4080,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return new com.uas.sso.support.Page<>(pageable.getPageNumber(), pageable.getPageSize(), brandCountList, count);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 设置开始时间
|
|
|
- *
|
|
|
- * @param startTime 前端传入开始时间
|
|
|
- * @return java.sql.Date
|
|
|
- */
|
|
|
- private java.sql.Date assignStartDate(Date startTime) {
|
|
|
- java.sql.Date startDate;
|
|
|
- if (null == startTime) {
|
|
|
- startDate = null;
|
|
|
- } else {
|
|
|
- startDate = new java.sql.Date(startTime.getTime());
|
|
|
- }
|
|
|
- return startDate;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 设置截止时间
|
|
|
- * 截止时间+1是取到截止时间的23:59:59数据,
|
|
|
- * java.sql.Date 精确到天,所以采用+1天小于来过滤
|
|
|
- *
|
|
|
- * @param endTime 前端传入截止时间
|
|
|
- * @return java.sql.Date
|
|
|
- */
|
|
|
- private java.sql.Date assignEndDate(Date endTime) {
|
|
|
- java.sql.Date endDate;
|
|
|
- // 截止时间+1天
|
|
|
- if (null == endTime) {
|
|
|
- endDate = null;
|
|
|
- } else {
|
|
|
- endDate = new java.sql.Date(endTime.getTime());
|
|
|
- Integer addend = 60 * 60 * 24 * 1000;
|
|
|
- endDate = new java.sql.Date(endDate.getTime() + addend);
|
|
|
- }
|
|
|
- return endDate;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 通过分页参数获取类目数量
|
|
|
*
|
|
|
@@ -4130,14 +4090,12 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
*/
|
|
|
@Override
|
|
|
public com.uas.sso.support.Page<KindHierarchicalCount> getKindProductsCount(Pageable pageable, Date startTime, Date endTime) {
|
|
|
- java.sql.Date startDate = assignStartDate(startTime);
|
|
|
- java.sql.Date endDate = assignEndDate(endTime);
|
|
|
StringBuffer sql = new StringBuffer("select pr_kind as thirdKind, pr_kindid as kindId, count(1) as count from products where pr_kind is not null ");
|
|
|
- if (null != startDate) {
|
|
|
- sql.append(" and pr_create_time >= '").append(startDate).append("' ");
|
|
|
+ if (null != startTime) {
|
|
|
+ sql.append(" and pr_create_time >= '").append(new java.sql.Date(startTime.getTime())).append("' ");
|
|
|
}
|
|
|
- if (null != endDate) {
|
|
|
- sql.append(" and pr_create_time < '").append(endDate).append("' ");
|
|
|
+ if (null != endTime) {
|
|
|
+ sql.append(" and pr_create_time < '").append(new java.sql.Date(endTime.getTime() + IntegerConstant.ONE_DAY_MILLISECONDS)).append("' ");
|
|
|
}
|
|
|
sql.append("group by pr_kind, pr_kindid");
|
|
|
StringBuffer countSql = new StringBuffer("select count(1) from (").append(sql).append(") as a");
|