|
|
@@ -3,6 +3,8 @@ package com.fs.hisStore.service.impl;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
@@ -16,6 +18,7 @@ import com.alibaba.fastjson.TypeReference;
|
|
|
import com.fs.common.annotation.DataScope;
|
|
|
import com.fs.common.config.FSSysConfig;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.exception.ServiceException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
@@ -899,32 +902,59 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
|
|
|
@Override
|
|
|
public FsStoreScanPaymentStatVo getScanPaymentStat(FsStoreScanPaymentStatParam param) {
|
|
|
- //验证类型是否错误
|
|
|
if (!StatTypeEnum.isValid(param.getStatType())) {
|
|
|
throw new ServiceException("操作失败,无效的统计类型!有效类型为:" + StatTypeEnum.getAllValidTypes());
|
|
|
}
|
|
|
|
|
|
StatTypeEnum statTypeEnum = param.toStatTypeEnum();
|
|
|
FsStoreScanPaymentStatVo paymentStatVo = null;
|
|
|
+ DateTimeFormatter formatter = null;
|
|
|
+
|
|
|
switch (statTypeEnum) {
|
|
|
- case DAY://日
|
|
|
+ case DAY:
|
|
|
paymentStatVo = fsStorePaymentMapper.getScanPaymentDayStat(param);
|
|
|
+ formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
break;
|
|
|
- case MONTH://月
|
|
|
+ case MONTH:
|
|
|
paymentStatVo = fsStorePaymentMapper.getScanPaymentMonthStat(param);
|
|
|
-
|
|
|
+ formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
break;
|
|
|
- case YEAR://年
|
|
|
+ case YEAR:
|
|
|
paymentStatVo = fsStorePaymentMapper.getScanPaymentYearStat(param);
|
|
|
+ formatter = DateTimeFormatter.ofPattern("yyyy");
|
|
|
break;
|
|
|
- case DATE://日期
|
|
|
- if(StringUtils.isEmpty(param.getStartDate())){
|
|
|
+ case DATE:
|
|
|
+ if (StringUtils.isEmpty(param.getStartDate())) {
|
|
|
throw new ServiceException("操作失败,开始日期不能为空!");
|
|
|
- }else if(StringUtils.isEmpty(param.getEndDate())){
|
|
|
- throw new ServiceException("操作失败,结日期不能为空!");
|
|
|
+ } else if (StringUtils.isEmpty(param.getEndDate())) {
|
|
|
+ throw new ServiceException("操作失败,结束日期不能为空!");
|
|
|
}
|
|
|
paymentStatVo = fsStorePaymentMapper.getScanPaymentDateStat(param);
|
|
|
break;
|
|
|
+ default:
|
|
|
+ throw new ServiceException("未支持的统计类型:" + statTypeEnum);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (paymentStatVo == null || statTypeEnum.getCode().equals(4) && paymentStatVo != null && paymentStatVo.getTotalSales() == null) {
|
|
|
+ paymentStatVo = new FsStoreScanPaymentStatVo();
|
|
|
+ paymentStatVo.setPayCount(0);
|
|
|
+ paymentStatVo.setTotalSales(BigDecimal.ZERO);
|
|
|
+ paymentStatVo.setTableDataInfo(new TableDataInfo());
|
|
|
+
|
|
|
+ String statPeriod;
|
|
|
+ switch (statTypeEnum) {
|
|
|
+ case DAY:
|
|
|
+ case MONTH:
|
|
|
+ case YEAR:
|
|
|
+ statPeriod = LocalDate.now().format(formatter);
|
|
|
+ break;
|
|
|
+ case DATE:
|
|
|
+ statPeriod = param.getStartDate() + "-" + param.getEndDate();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ statPeriod = "";
|
|
|
+ }
|
|
|
+ paymentStatVo.setStatPeriod(statPeriod);
|
|
|
}
|
|
|
|
|
|
return paymentStatVo;
|