| @@ -142,4 +142,15 @@ public class AliBusinessCircleOrderController extends BaseController { | |||
| return new ResultData(aliStatistics); | |||
| } | |||
| @GetMapping("exportStatisticsData") | |||
| @SystemControllerLog(description = "导出数据") | |||
| public void exportStatisticsData(@ModelAttribute AliBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::exportStatisticsData"); | |||
| if (null == circleOrder) { | |||
| circleOrder = new AliBusinessCircleOrder(); | |||
| } | |||
| circleOrder.updateTenantInfo(getTenantInfo()); | |||
| aliBusinessCircleOrderService.exportStatisticsData(circleOrder, request, response); | |||
| } | |||
| } | |||
| @@ -138,4 +138,15 @@ public class WxBusinessCircleOrderController extends BaseController { | |||
| return new ResultData(aliStatistics); | |||
| } | |||
| @GetMapping("exportStatisticsData") | |||
| @SystemControllerLog(description = "导出数据") | |||
| public void exportStatisticsData(@ModelAttribute WxBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::exportStatisticsData"); | |||
| if (null == circleOrder) { | |||
| circleOrder = new WxBusinessCircleOrder(); | |||
| } | |||
| circleOrder.updateTenantInfo(getTenantInfo()); | |||
| wxBusinessCircleOrderService.exportStatisticsData(circleOrder, request, response); | |||
| } | |||
| } | |||
| @@ -1,18 +1,40 @@ | |||
| package com.iformall.domain.vo; | |||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import lombok.Data; | |||
| import java.io.Serializable; | |||
| import java.math.BigDecimal; | |||
| @Data | |||
| public class AlipayOrWxStatistics implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Excel(name = "商户名称", width = 20, orderNum = "2") | |||
| private String merchantName;//商户名称 | |||
| private Integer payAmount;//支付总金额 | |||
| @Excel(name = "支付金额(元)", width = 20, orderNum = "3") | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="用户实际付款金额,单位(元)",name="payAmountStr") | |||
| private String payAmountStr; | |||
| public String getPayAmountStr() { | |||
| return payAmount != null ? new BigDecimal(payAmount).divide(new BigDecimal(100)).toPlainString(): payAmountStr; | |||
| } | |||
| private Integer refundAmount;//退款总金额 | |||
| @Excel(name = "退款金额(元)", width = 20, orderNum = "4") | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(元)",name="refundAmountStr") | |||
| private String refundAmountStr; | |||
| public String getRefundAmountStr() { | |||
| return refundAmount != null ? new BigDecimal(refundAmount).divide(new BigDecimal(100)).toPlainString(): refundAmountStr; | |||
| } | |||
| @Excel(name = "支付积分", width = 20, orderNum = "5") | |||
| private Integer payPoints;//支付添加总积分 | |||
| @Excel(name = "退款积分", width = 20, orderNum = "6") | |||
| private Integer refundPoints;//支付退款扣减总积分 | |||
| @Excel(name = "商户ID", width = 20, orderNum = "1") | |||
| private Long merchantId; | |||
| } | |||
| @@ -62,4 +62,6 @@ public interface AliBusinessCircleOrderService { | |||
| PageInfo<AlipayOrWxStatistics> aliPayList(AliBusinessCircleOrder circleOrder, Integer pageNum, Integer pageSize); | |||
| AlipayOrWxStatistics aliStatistics(AliBusinessCircleOrder circleOrder); | |||
| void exportStatisticsData(AliBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response); | |||
| } | |||
| @@ -95,4 +95,5 @@ public interface WxBusinessCircleOrderService { | |||
| AlipayOrWxStatistics wxStatistics(WxBusinessCircleOrder circleOrder); | |||
| void exportStatisticsData(WxBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response); | |||
| } | |||
| @@ -423,7 +423,7 @@ public class AliBusinessCircleOrderServiceImpl implements AliBusinessCircleOrder | |||
| statistics.setMerchantName(merchantNamesMap.get(statistics.getMerchantId())); | |||
| } | |||
| if(StringUtils.isBlank(statistics.getMerchantName())){ | |||
| statistics.setMerchantName("其他"); | |||
| statistics.setMerchantName("未知门店"); | |||
| } | |||
| if(statisticsMap != null){ | |||
| AlipayOrWxStatistics refundstatistics = statisticsMap.get(statistics.getMerchantId()); | |||
| @@ -456,4 +456,54 @@ public class AliBusinessCircleOrderServiceImpl implements AliBusinessCircleOrder | |||
| return aliStatistics; | |||
| } | |||
| @Override | |||
| public void exportStatisticsData(AliBusinessCircleOrder record, HttpServletRequest request, HttpServletResponse response) { | |||
| if (StringUtils.isNotEmpty(record.getMerchantName())) { | |||
| List<Long> ids = wxMerchantService.selectByMerchantIds(record.getMerchantName()); | |||
| if (!CollectionUtils.isEmpty(ids)) { | |||
| record.setMerchantIds(ids); | |||
| }else{ | |||
| ids.add(-999l); | |||
| record.setMerchantIds(ids); | |||
| } | |||
| } | |||
| List<AlipayOrWxStatistics> aliStatistics = aliBusinessCircleOrderMapper.aliPayList(record); | |||
| List<Long> list = aliStatistics.parallelStream().filter(s -> s.getMerchantId() != null) | |||
| .map(AlipayOrWxStatistics::getMerchantId).collect(Collectors.toList()); | |||
| Map<Long, AlipayOrWxStatistics> statisticsMap = null; | |||
| Map<Long, String> merchantNamesMap = null; | |||
| if(CollectionUtils.isNotEmpty(list)){ | |||
| //查询退款数据 | |||
| record.setMerchantIds(list); | |||
| List<AlipayOrWxStatistics> alipayOrWxStatistics = aliBusinessCircleOrderMapper.aliRefundList(record); | |||
| if (CollectionUtils.isNotEmpty(alipayOrWxStatistics)) { | |||
| statisticsMap = alipayOrWxStatistics.stream().collect(Collectors.toMap(AlipayOrWxStatistics::getMerchantId, s -> s)); | |||
| } | |||
| WxMerchant wxMerchant = new WxMerchant(); | |||
| wxMerchant.setIds(list); | |||
| merchantNamesMap = wxMerchantService.getIdAndNamesMap(wxMerchant); | |||
| } | |||
| for (AlipayOrWxStatistics statistics:aliStatistics) { | |||
| if(merchantNamesMap != null){ | |||
| statistics.setMerchantName(merchantNamesMap.get(statistics.getMerchantId())); | |||
| } | |||
| if(StringUtils.isBlank(statistics.getMerchantName())){ | |||
| statistics.setMerchantName("未知门店"); | |||
| } | |||
| if(statisticsMap != null){ | |||
| AlipayOrWxStatistics refundstatistics = statisticsMap.get(statistics.getMerchantId()); | |||
| if(refundstatistics != null){ | |||
| statistics.setRefundAmount(refundstatistics.getRefundAmount()); | |||
| statistics.setRefundPoints(refundstatistics.getRefundPoints()); | |||
| } | |||
| } | |||
| } | |||
| excelService.exportExcel(aliStatistics, null, "支付宝商圈统计", AlipayOrWxStatistics.class, "支付宝商圈统计.xlsx", response, false); | |||
| } | |||
| } | |||
| @@ -598,7 +598,7 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe | |||
| statistics.setMerchantName(merchantNamesMap.get(statistics.getMerchantId())); | |||
| } | |||
| if(StringUtils.isBlank(statistics.getMerchantName())){ | |||
| statistics.setMerchantName("其他"); | |||
| statistics.setMerchantName("未知门店"); | |||
| } | |||
| if(statisticsMap != null){ | |||
| AlipayOrWxStatistics refundstatistics = statisticsMap.get(statistics.getMerchantId()); | |||
| @@ -632,5 +632,55 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe | |||
| return aliStatistics; | |||
| } | |||
| @Override | |||
| public void exportStatisticsData(WxBusinessCircleOrder record, HttpServletRequest request, HttpServletResponse response) { | |||
| if (StringUtils.isNotEmpty(record.getMerchantName())) { | |||
| List<Long> ids = wxMerchantService.selectByMerchantIds(record.getMerchantName()); | |||
| if (!CollectionUtils.isEmpty(ids)) { | |||
| record.setMerchantIds(ids); | |||
| }else{ | |||
| ids.add(-999l); | |||
| record.setMerchantIds(ids); | |||
| } | |||
| } | |||
| List<AlipayOrWxStatistics> wxStatistics = wxBusinessCircleOrderMapper.wxPayList(record); | |||
| List<Long> list = wxStatistics.parallelStream().filter(s -> s.getMerchantId() != null) | |||
| .map(AlipayOrWxStatistics::getMerchantId).collect(Collectors.toList()); | |||
| Map<Long, AlipayOrWxStatistics> statisticsMap = null; | |||
| Map<Long, String> merchantNamesMap = null; | |||
| if(CollectionUtils.isNotEmpty(list)){ | |||
| //查询退款数据 | |||
| record.setMerchantIds(list); | |||
| List<AlipayOrWxStatistics> wxpayOrWxStatistics = wxBusinessCircleOrderMapper.wxRefundList(record); | |||
| if (CollectionUtils.isNotEmpty(wxpayOrWxStatistics)) { | |||
| statisticsMap = wxpayOrWxStatistics.stream().collect(Collectors.toMap(AlipayOrWxStatistics::getMerchantId, s -> s)); | |||
| } | |||
| WxMerchant wxMerchant = new WxMerchant(); | |||
| wxMerchant.setIds(list); | |||
| merchantNamesMap = wxMerchantService.getIdAndNamesMap(wxMerchant); | |||
| } | |||
| for (AlipayOrWxStatistics statistics:wxStatistics) { | |||
| if(merchantNamesMap != null){ | |||
| statistics.setMerchantName(merchantNamesMap.get(statistics.getMerchantId())); | |||
| } | |||
| if(StringUtils.isBlank(statistics.getMerchantName())){ | |||
| statistics.setMerchantName("未知门店"); | |||
| } | |||
| if(statisticsMap != null){ | |||
| AlipayOrWxStatistics refundstatistics = statisticsMap.get(statistics.getMerchantId()); | |||
| if(refundstatistics != null){ | |||
| statistics.setRefundAmount(refundstatistics.getRefundAmount()); | |||
| statistics.setRefundPoints(refundstatistics.getRefundPoints()); | |||
| } | |||
| } | |||
| } | |||
| excelService.exportExcel(wxStatistics, null, "微信商圈统计", AlipayOrWxStatistics.class, "微信商圈统计.xlsx", response, false); | |||
| } | |||
| } | |||