订单统计付款人数bug处理

This commit is contained in:
Chopper 2022-09-02 19:09:17 +08:00
parent 43022a9838
commit b3c537d034
2 changed files with 32 additions and 10 deletions

View File

@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -41,7 +42,6 @@ public interface StoreFlowStatisticsMapper extends BaseMapper<StoreFlow> {
List<CategoryStatisticsDataVO> getCateGoryStatisticsData(@Param(Constants.WRAPPER) Wrapper<CategoryStatisticsDataVO> queryWrapper); List<CategoryStatisticsDataVO> getCateGoryStatisticsData(@Param(Constants.WRAPPER) Wrapper<CategoryStatisticsDataVO> queryWrapper);
/** /**
* 店铺统计列表 * 店铺统计列表
* *
@ -52,4 +52,30 @@ public interface StoreFlowStatisticsMapper extends BaseMapper<StoreFlow> {
@Select("SELECT store_id AS storeId,store_name AS storeName,SUM(final_price) AS price,SUM(num) AS num FROM li_store_flow ${ew.customSqlSegment}") @Select("SELECT store_id AS storeId,store_name AS storeName,SUM(final_price) AS price,SUM(num) AS num FROM li_store_flow ${ew.customSqlSegment}")
List<StoreStatisticsDataVO> getStoreStatisticsData(IPage<GoodsStatisticsDataVO> page, @Param(Constants.WRAPPER) Wrapper<GoodsStatisticsDataVO> queryWrapper); List<StoreStatisticsDataVO> getStoreStatisticsData(IPage<GoodsStatisticsDataVO> page, @Param(Constants.WRAPPER) Wrapper<GoodsStatisticsDataVO> queryWrapper);
/**
* 店铺统计付款人数
*
* @param storeId 店铺id
* @param startTime 开始时间
* @param endTime 结束时间
* @return 付款人数
*/
@Select("SELECT count(0) AS num FROM (SELECT count(0) FROM li_store_flow " +
" where store_id = ${storeId} and flow_type='PAY' and create_time >=${startTime} and create_time < ${endTime}" +
" GROUP BY member_id) t")
Long countPayers(String storeId, Date startTime, Date endTime);
/**
* 统计付款人数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @return 付款人数
*/
@Select("SELECT count(0) AS num FROM (SELECT count(0) FROM li_store_flow " +
" where flow_type='PAY' and create_time >=${startTime} and create_time < ${endTime}" +
" GROUP BY member_id) t")
Long countPayers(Date startTime, Date endTime);
} }

View File

@ -40,6 +40,7 @@ public class StoreFlowStatisticsServiceImpl extends ServiceImpl<StoreFlowStatist
@Autowired @Autowired
private OrderStatisticsService orderStatisticsService; private OrderStatisticsService orderStatisticsService;
@Override @Override
public List<GoodsStatisticsDataVO> getGoodsStatisticsData(GoodsStatisticsQueryParam goodsStatisticsQueryParam, Integer num) { public List<GoodsStatisticsDataVO> getGoodsStatisticsData(GoodsStatisticsQueryParam goodsStatisticsQueryParam, Integer num) {
//获取查询条件 //获取查询条件
@ -159,18 +160,13 @@ public class StoreFlowStatisticsServiceImpl extends ServiceImpl<StoreFlowStatist
orderOverviewVO.setPaymentOrderNum(payment != null && payment.containsKey("num") ? (Long) payment.get("num") : 0L); orderOverviewVO.setPaymentOrderNum(payment != null && payment.containsKey("num") ? (Long) payment.get("num") : 0L);
orderOverviewVO.setPaymentAmount(payment != null && payment.containsKey("price") ? (Double) payment.get("price") : 0D); orderOverviewVO.setPaymentAmount(payment != null && payment.containsKey("price") ? (Double) payment.get("price") : 0D);
//付款人数
queryWrapper = Wrappers.query();
queryWrapper.between("create_time", dates[0], dates[1]);
//如果有店铺id传入则查询店铺 //如果有店铺id传入则查询店铺
if (StringUtils.isNotEmpty(statisticsQueryParam.getStoreId())) { if (StringUtils.isNotEmpty(statisticsQueryParam.getStoreId())) {
queryWrapper.eq("store_id", statisticsQueryParam.getStoreId()); orderOverviewVO.setPaymentsNum(baseMapper.countPayers(statisticsQueryParam.getStoreId(), dates[0], dates[1]));
} else {
orderOverviewVO.setPaymentsNum(baseMapper.countPayers(dates[0], dates[1]));
} }
queryWrapper.select("COUNT(0) AS num");
queryWrapper.groupBy("member_id");
Map paymentMemberNum = this.getMap(queryWrapper);
orderOverviewVO.setPaymentsNum(paymentMemberNum != null && paymentMemberNum.containsKey("num") ? (Long) paymentMemberNum.get("num") : 0L);
} }
/** /**