diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SaleExample.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SaleExample.java index b9f5299e..0ea81c78 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SaleExample.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SaleExample.java @@ -1090,6 +1090,11 @@ public class SaleExample { return (Criteria) this; } + public Criteria andStatusEqualTo1(String value) { + addCriterion("t.status =", value, "status"); + return (Criteria) this; + } + public Criteria andStatusNotEqualTo(String value) { addCriterion("status <>", value, "status"); return (Criteria) this; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesCalculateServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesCalculateServiceImpl.java index 00542062..9185f389 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesCalculateServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesCalculateServiceImpl.java @@ -64,34 +64,55 @@ public class SalesCalculateServiceImpl implements SalesCalculateService { Date currentDate = DateUtil.parseYYYYMMDDDate(DateUtils.formatDate(new Date(),"yyyy-MM-dd")); + BigDecimal totalAmount1 = new BigDecimal(0); + BigDecimal totalAmount2 = new BigDecimal(0); + int totalCount1 = 0; + int totalCount2 = 0; + int totalJCount1 = 0; + int totalJCount2 = 0; + //获取当日门店销售总额 销售笔数 销售总件数 SaleExample saleExample = new SaleExample(); saleExample.createCriteria() .andCreateTimeGreaterThanOrEqualTo(currentDate) - //.andStatusEqualTo("5") + .andStatusEqualTo("5") .andShopIdEqualTo(shopId); SaleAllVO saleAllVO1 = saleMapper.saleSumAndCount(saleExample); + if(!ObjectUtils.isEmpty(saleAllVO1)){ + totalAmount1 = saleAllVO1.getTotalAmount(); + totalCount1 = saleAllVO1.getTotalCount(); + totalJCount1 = saleAllVO1.getTotalJCount(); + } ReturnSaleExample returnSaleExample = new ReturnSaleExample(); returnSaleExample.createCriteria() .andCreateTimeGreaterThanOrEqualTo(currentDate) - //.andStatusEqualTo("5") + .andStatusEqualTo("5") .andShopIdEqualTo(shopId); SaleAllVO returnAllVO1 = returnSaleMapper.saleSumAndCount(returnSaleExample); + if(!ObjectUtils.isEmpty(returnAllVO1)){ + totalAmount2 = returnAllVO1.getTotalAmount(); + totalCount2 = returnAllVO1.getTotalCount(); + totalJCount2 = returnAllVO1.getTotalJCount(); + } - saleAllVO.setTotalAmount(saleAllVO1.getTotalAmount().subtract(returnAllVO1.getTotalAmount())); - saleAllVO.setTotalCount(saleAllVO1.getTotalCount()-returnAllVO1.getTotalCount()); - saleAllVO.setTotalJCount(saleAllVO1.getTotalJCount()-returnAllVO1.getTotalJCount()); + saleAllVO.setTotalAmount(totalAmount1.subtract(totalAmount2)); + saleAllVO.setTotalCount(totalCount1-totalCount2); + saleAllVO.setTotalJCount(totalJCount1-totalJCount2); //获取门店单笔最高金额 SaleExample saleExample1 = new SaleExample(); saleExample1.createCriteria() .andCreateTimeGreaterThanOrEqualTo1(currentDate) - //.andStatusEqualTo("5") + .andStatusEqualTo1("5") .andShopIdEqualTo1(shopId); SaleAllVO saleAllVO2 = saleMapper.saleMaxAmount(saleExample1); - saleAllVO.setOneHighPrice(saleAllVO2.getOneHighPrice()); + if(!ObjectUtils.isEmpty(saleAllVO2)){ + saleAllVO.setOneHighPrice(saleAllVO2.getOneHighPrice()); + }else{ + saleAllVO.setOneHighPrice(new BigDecimal(0)); + } //获取当日门店利润(当日总营收-当日总成本-(退货总营收-退货总成本)) QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -120,12 +141,17 @@ public class SalesCalculateServiceImpl implements SalesCalculateService { QueryWrapper querySaleWrapper = new QueryWrapper<>(); querySaleWrapper.select("count(1)") .eq("shop_id",shopId) - //.eq("status","5") + .eq("status","5") .ge("create_time",currentDate) .groupBy("user_id"); List countCus = saleService.listObjs(querySaleWrapper); - int countCustomer = ((Long) countCus.get(0)).intValue(); - saleAllVO.setTotalCCount(countCustomer); + if(!ObjectUtils.isEmpty(countCus) && countCus.size()>0){ + int countCustomer = ((Long) countCus.get(0)).intValue(); + saleAllVO.setTotalCCount(countCustomer); + }else{ + saleAllVO.setTotalCCount(0); + } + return saleAllVO; }