| @@ -10,6 +10,7 @@ public class AlipayOrWxStatistics { | |||||
| private String merchantName;//商户名称 | private String merchantName;//商户名称 | ||||
| private Integer payAmount;//支付总金额 | private Integer payAmount;//支付总金额 | ||||
| private Integer refundAmount;//退款总金额 | private Integer refundAmount;//退款总金额 | ||||
| private Integer increasedPoints;//积分情况 | |||||
| private Integer payPoints;//支付总积分 | |||||
| private Integer refundPoints;//支付总积分 | |||||
| private Long merchantId; | private Long merchantId; | ||||
| } | } | ||||
| @@ -50,4 +50,7 @@ public interface AliBusinessCircleOrderMapper extends CommonMapper<AliBusinessCi | |||||
| Integer sumCircleRefundAmount(BusinessCircleBase circleOrder); | Integer sumCircleRefundAmount(BusinessCircleBase circleOrder); | ||||
| List<AlipayOrWxStatistics> aliPayList(AliBusinessCircleOrder record); | List<AlipayOrWxStatistics> aliPayList(AliBusinessCircleOrder record); | ||||
| List<AlipayOrWxStatistics> aliRefundList(AliBusinessCircleOrder record); | |||||
| } | } | ||||
| @@ -52,4 +52,6 @@ public interface WxBusinessCircleOrderMapper extends CommonMapper<WxBusinessCirc | |||||
| List<AlipayOrWxStatistics> wxPayList(WxBusinessCircleOrder record); | List<AlipayOrWxStatistics> wxPayList(WxBusinessCircleOrder record); | ||||
| List<AlipayOrWxStatistics> wxRefundList(WxBusinessCircleOrder record); | |||||
| } | } | ||||
| @@ -400,16 +400,28 @@ public class AliBusinessCircleOrderServiceImpl implements AliBusinessCircleOrder | |||||
| return pageInfo; | return pageInfo; | ||||
| } | } | ||||
| List<Long> list = pageInfo.getList().parallelStream().map(AlipayOrWxStatistics::getMerchantId).collect(Collectors.toList()); | List<Long> list = pageInfo.getList().parallelStream().map(AlipayOrWxStatistics::getMerchantId).collect(Collectors.toList()); | ||||
| record.setMerchantIds(list); | |||||
| //查询退款数据 | |||||
| List<AlipayOrWxStatistics> alipayOrWxStatistics = aliBusinessCircleOrderMapper.aliRefundList(record); | |||||
| Map<Long, AlipayOrWxStatistics> statisticsMap = null; | |||||
| if (CollectionUtils.isNotEmpty(alipayOrWxStatistics)) { | |||||
| statisticsMap = alipayOrWxStatistics.stream().collect(Collectors.toMap(AlipayOrWxStatistics::getMerchantId, s -> s)); | |||||
| } | |||||
| WxMerchant wxMerchant = new WxMerchant(); | WxMerchant wxMerchant = new WxMerchant(); | ||||
| wxMerchant.setIds(list); | wxMerchant.setIds(list); | ||||
| List<WxMerchant> wxMerchants = wxMerchantService.findList(wxMerchant); | |||||
| if (CollectionUtils.isEmpty(wxMerchants)) { | |||||
| return pageInfo; | |||||
| Map<Long, String> merchantNamesMap = wxMerchantService.getIdAndNamesMap(wxMerchant); | |||||
| for (AlipayOrWxStatistics statistics:pageInfo.getList()) { | |||||
| statistics.setMerchantName(merchantNamesMap.get(statistics.getMerchantId())); | |||||
| if(statisticsMap != null){ | |||||
| AlipayOrWxStatistics refundstatistics = statisticsMap.get(statistics.getMerchantId()); | |||||
| if(refundstatistics != null){ | |||||
| statistics.setRefundAmount(refundstatistics.getRefundAmount()); | |||||
| statistics.setRefundPoints(refundstatistics.getRefundPoints()); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| Map<Long, String> map = wxMerchants.parallelStream().collect(Collectors.toMap(WxMerchant::getId, WxMerchant::getName)); | |||||
| pageInfo.getList().forEach(x -> { | |||||
| x.setMerchantName(map.get(x.getMerchantId())); | |||||
| }); | |||||
| return pageInfo; | return pageInfo; | ||||
| } | } | ||||
| } | } | ||||
| @@ -575,16 +575,28 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe | |||||
| return pageInfo; | return pageInfo; | ||||
| } | } | ||||
| List<Long> list = pageInfo.getList().parallelStream().map(AlipayOrWxStatistics::getMerchantId).collect(Collectors.toList()); | List<Long> list = pageInfo.getList().parallelStream().map(AlipayOrWxStatistics::getMerchantId).collect(Collectors.toList()); | ||||
| record.setMerchantIds(list); | |||||
| //查询退款数据 | |||||
| List<AlipayOrWxStatistics> alipayOrWxStatistics = wxBusinessCircleOrderMapper.wxRefundList(record); | |||||
| Map<Long, AlipayOrWxStatistics> statisticsMap = null; | |||||
| if (CollectionUtils.isNotEmpty(alipayOrWxStatistics)) { | |||||
| statisticsMap = alipayOrWxStatistics.stream().collect(Collectors.toMap(AlipayOrWxStatistics::getMerchantId, s -> s)); | |||||
| } | |||||
| WxMerchant wxMerchant = new WxMerchant(); | WxMerchant wxMerchant = new WxMerchant(); | ||||
| wxMerchant.setIds(list); | wxMerchant.setIds(list); | ||||
| List<WxMerchant> wxMerchants = wxMerchantService.findList(wxMerchant); | |||||
| if (CollectionUtils.isEmpty(wxMerchants)) { | |||||
| return pageInfo; | |||||
| Map<Long, String> merchantNamesMap = wxMerchantService.getIdAndNamesMap(wxMerchant); | |||||
| for (AlipayOrWxStatistics statistics:pageInfo.getList()) { | |||||
| statistics.setMerchantName(merchantNamesMap.get(statistics.getMerchantId())); | |||||
| if(statisticsMap != null){ | |||||
| AlipayOrWxStatistics refundstatistics = statisticsMap.get(statistics.getMerchantId()); | |||||
| if(refundstatistics != null){ | |||||
| statistics.setRefundAmount(refundstatistics.getRefundAmount()); | |||||
| statistics.setRefundPoints(refundstatistics.getRefundPoints()); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| Map<Long, String> map = wxMerchants.parallelStream().collect(Collectors.toMap(WxMerchant::getId, WxMerchant::getName)); | |||||
| pageInfo.getList().forEach(x -> { | |||||
| x.setMerchantName(map.get(x.getMerchantId())); | |||||
| }); | |||||
| return pageInfo; | return pageInfo; | ||||
| } | } | ||||
| @@ -230,19 +230,46 @@ | |||||
| </select> | </select> | ||||
| <select id="aliPayList" parameterType="com.iformall.domain.po.AliBusinessCircleOrder" resultType="com.iformall.domain.vo.AlipayOrWxStatistics"> | <select id="aliPayList" parameterType="com.iformall.domain.po.AliBusinessCircleOrder" resultType="com.iformall.domain.vo.AlipayOrWxStatistics"> | ||||
| SELECT SUM(pay_amount) as 'payAmount', | |||||
| SUM(refund_amount) as 'refundAmount', | |||||
| merchant_id as 'merchantId', | |||||
| SUM(increased_points) as 'increasedPoints' | |||||
| SELECT merchant_id as 'merchantId', | |||||
| IFNULL(SUM(`pay_amount`),0) as 'payAmount', | |||||
| IFNULL(SUM(`increased_points`),0) as 'payPoints' | |||||
| FROM ali_business_circle_order | FROM ali_business_circle_order | ||||
| where is_refund = 0 | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != merchantIds and merchantIds.size > 0 "> | <if test=" null != merchantIds and merchantIds.size > 0 "> | ||||
| where merchant_id in | |||||
| and merchant_id in | |||||
| <foreach collection="merchantIds" index="index" item="id" open="(" separator="," close=")"> | <foreach collection="merchantIds" index="index" item="id" open="(" separator="," close=")"> | ||||
| #{id} | #{id} | ||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| GROUP BY merchant_id,is_refund | |||||
| GROUP BY merchant_id | |||||
| order by payAmount desc; | order by payAmount desc; | ||||
| </select> | </select> | ||||
| <select id="aliRefundList" parameterType="com.iformall.domain.po.AliBusinessCircleOrder" resultType="com.iformall.domain.vo.AlipayOrWxStatistics"> | |||||
| SELECT merchant_id as 'merchantId', | |||||
| IFNULL(SUM(`refund_amount`),0) as 'refundAmount', | |||||
| IFNULL(SUM(`increased_points`),0) as 'refundPoints' | |||||
| FROM ali_business_circle_order | |||||
| where is_refund = 1 | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != merchantIds and merchantIds.size > 0 "> | |||||
| and merchant_id in | |||||
| <foreach collection="merchantIds" index="index" item="id" open="(" separator="," close=")"> | |||||
| #{id} | |||||
| </foreach> | |||||
| </if> | |||||
| GROUP BY merchant_id | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -262,18 +262,46 @@ | |||||
| </select> | </select> | ||||
| <select id="wxPayList" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" resultType="com.iformall.domain.vo.AlipayOrWxStatistics"> | <select id="wxPayList" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" resultType="com.iformall.domain.vo.AlipayOrWxStatistics"> | ||||
| SELECT SUM(pay_amount) as 'payAmount', | |||||
| SUM(refund_amount) as 'refundAmount', | |||||
| merchant_id as 'merchantId', | |||||
| SUM(increased_points) as 'increasedPoints' | |||||
| SELECT merchant_id as 'merchantId', | |||||
| IFNULL(SUM(`pay_amount`),0) as 'payAmount', | |||||
| IFNULL(SUM(`increased_points`),0) as 'payPoints' | |||||
| FROM wx_business_circle_order | FROM wx_business_circle_order | ||||
| where is_refund = 0 | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != merchantIds and merchantIds.size > 0 "> | <if test=" null != merchantIds and merchantIds.size > 0 "> | ||||
| where merchant_id in | |||||
| and merchant_id in | |||||
| <foreach collection="merchantIds" index="index" item="id" open="(" separator="," close=")"> | <foreach collection="merchantIds" index="index" item="id" open="(" separator="," close=")"> | ||||
| #{id} | #{id} | ||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| GROUP BY merchant_id,is_refund | |||||
| GROUP BY merchant_id | |||||
| order by payAmount desc; | order by payAmount desc; | ||||
| </select> | </select> | ||||
| <select id="aliRefundList" parameterType="com.iformall.domain.po.AliBusinessCircleOrder" resultType="com.iformall.domain.vo.AlipayOrWxStatistics"> | |||||
| SELECT merchant_id as 'merchantId', | |||||
| IFNULL(SUM(`refund_amount`),0) as 'refundAmount', | |||||
| IFNULL(SUM(`increased_points`),0) as 'refundPoints' | |||||
| FROM wx_business_circle_order | |||||
| where is_refund = 1 | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != merchantIds and merchantIds.size > 0 "> | |||||
| and merchant_id in | |||||
| <foreach collection="merchantIds" index="index" item="id" open="(" separator="," close=")"> | |||||
| #{id} | |||||
| </foreach> | |||||
| </if> | |||||
| GROUP BY merchant_id | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||