mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-13 03:39:55 +08:00
新增 根据汇付会员id查询分账汇总数据接口
This commit is contained in:
@@ -23,6 +23,7 @@ import com.jsowell.pile.service.PileMerchantInfoService;
|
|||||||
import com.jsowell.pile.service.PileStationInfoService;
|
import com.jsowell.pile.service.PileStationInfoService;
|
||||||
import com.jsowell.pile.util.UserUtils;
|
import com.jsowell.pile.util.UserUtils;
|
||||||
import com.jsowell.pile.vo.web.OrderListVO;
|
import com.jsowell.pile.vo.web.OrderListVO;
|
||||||
|
import com.jsowell.pile.vo.web.SplitConfigOrderVO;
|
||||||
import com.jsowell.pile.vo.web.SplitRecordInfoVO;
|
import com.jsowell.pile.vo.web.SplitRecordInfoVO;
|
||||||
import com.jsowell.service.OrderService;
|
import com.jsowell.service.OrderService;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@@ -251,4 +252,24 @@ public class OrderBasicInfoController extends BaseController {
|
|||||||
logger.info("查询订单分账数据 params:{}, result:{}", JSON.toJSONString(dto), response);
|
logger.info("查询订单分账数据 params:{}, result:{}", JSON.toJSONString(dto), response);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据汇付会员id查询分账汇总数据
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/queryMemberAggregateData")
|
||||||
|
public RestApiResponse<?> queryStationAggregateData(@RequestBody SplitConfigStationDTO dto) {
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
List<SplitConfigOrderVO> list = orderSplitRecordService.queryStationAggregateData(dto);
|
||||||
|
response = new RestApiResponse<>(list);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("查询站点汇总数据 error", e);
|
||||||
|
response = new RestApiResponse<>(e);
|
||||||
|
}
|
||||||
|
logger.info("查询站点汇总数据 params:{}, result:{}", JSON.toJSONString(dto), response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,8 @@ public class SplitConfigStationDTO {
|
|||||||
* 汇付会员ID
|
* 汇付会员ID
|
||||||
*/
|
*/
|
||||||
private String adapayMemberId;
|
private String adapayMemberId;
|
||||||
|
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
private String endTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ package com.jsowell.pile.mapper;
|
|||||||
|
|
||||||
import com.jsowell.pile.domain.OrderSplitRecord;
|
import com.jsowell.pile.domain.OrderSplitRecord;
|
||||||
import com.jsowell.pile.dto.QueryOrderSplitDTO;
|
import com.jsowell.pile.dto.QueryOrderSplitDTO;
|
||||||
|
import com.jsowell.pile.dto.SplitConfigStationDTO;
|
||||||
import com.jsowell.pile.vo.web.OrderSplitRecordVO;
|
import com.jsowell.pile.vo.web.OrderSplitRecordVO;
|
||||||
|
import com.jsowell.pile.vo.web.SplitConfigOrderVO;
|
||||||
|
import com.jsowell.pile.vo.web.SplitConfigStationVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -47,4 +50,13 @@ public interface OrderSplitRecordMapper {
|
|||||||
List<String> queryOrderCodesByParams(@Param("dto") QueryOrderSplitDTO dto);
|
List<String> queryOrderCodesByParams(@Param("dto") QueryOrderSplitDTO dto);
|
||||||
|
|
||||||
List<OrderSplitRecordVO> queryOrderSplitData(@Param("orderCodeList") List<String> orderCodeList);
|
List<OrderSplitRecordVO> queryOrderSplitData(@Param("orderCodeList") List<String> orderCodeList);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据汇付会员id查询分账汇总数据
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SplitConfigStationVO> queryStationAggregateData(SplitConfigStationDTO dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ import com.jsowell.adapay.response.PaymentConfirmResponse;
|
|||||||
import com.jsowell.common.core.page.PageResponse;
|
import com.jsowell.common.core.page.PageResponse;
|
||||||
import com.jsowell.pile.domain.OrderSplitRecord;
|
import com.jsowell.pile.domain.OrderSplitRecord;
|
||||||
import com.jsowell.pile.dto.QueryOrderSplitDTO;
|
import com.jsowell.pile.dto.QueryOrderSplitDTO;
|
||||||
|
import com.jsowell.pile.dto.SplitConfigStationDTO;
|
||||||
import com.jsowell.pile.dto.SplitOrderDTO;
|
import com.jsowell.pile.dto.SplitOrderDTO;
|
||||||
import com.jsowell.pile.vo.OrderInfoDetailVO;
|
import com.jsowell.pile.vo.OrderInfoDetailVO;
|
||||||
import com.jsowell.pile.vo.web.OrderSplitDailySummaryData;
|
import com.jsowell.pile.vo.web.*;
|
||||||
import com.jsowell.pile.vo.web.OrderSplitRecordVO;
|
|
||||||
import com.jsowell.pile.vo.web.SplitOrdersInfoVO;
|
|
||||||
import com.jsowell.pile.vo.web.SplitRecordInfoVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -78,5 +76,7 @@ public interface OrderSplitRecordService {
|
|||||||
* 根据汇付会员id查询时间段内订单分账记录
|
* 根据汇付会员id查询时间段内订单分账记录
|
||||||
*/
|
*/
|
||||||
List<OrderSplitRecord> queryOrderSplitRecordByMemberId(String adapayMemberId, String startTime, String endTime);
|
List<OrderSplitRecord> queryOrderSplitRecordByMemberId(String adapayMemberId, String startTime, String endTime);
|
||||||
|
|
||||||
|
List<SplitConfigOrderVO> queryStationAggregateData(SplitConfigStationDTO dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.jsowell.common.core.domain.model.LoginUser;
|
|||||||
import com.jsowell.common.core.page.PageResponse;
|
import com.jsowell.common.core.page.PageResponse;
|
||||||
import com.jsowell.common.enums.DelFlagEnum;
|
import com.jsowell.common.enums.DelFlagEnum;
|
||||||
import com.jsowell.common.enums.adapay.AdapayStatusEnum;
|
import com.jsowell.common.enums.adapay.AdapayStatusEnum;
|
||||||
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
import com.jsowell.common.util.SecurityUtils;
|
import com.jsowell.common.util.SecurityUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
@@ -19,6 +20,7 @@ import com.jsowell.pile.domain.AdapayMemberAccount;
|
|||||||
import com.jsowell.pile.domain.OrderSplitRecord;
|
import com.jsowell.pile.domain.OrderSplitRecord;
|
||||||
import com.jsowell.pile.domain.PileMerchantInfo;
|
import com.jsowell.pile.domain.PileMerchantInfo;
|
||||||
import com.jsowell.pile.dto.QueryOrderSplitDTO;
|
import com.jsowell.pile.dto.QueryOrderSplitDTO;
|
||||||
|
import com.jsowell.pile.dto.SplitConfigStationDTO;
|
||||||
import com.jsowell.pile.dto.SplitOrderDTO;
|
import com.jsowell.pile.dto.SplitOrderDTO;
|
||||||
import com.jsowell.pile.mapper.OrderSplitRecordMapper;
|
import com.jsowell.pile.mapper.OrderSplitRecordMapper;
|
||||||
import com.jsowell.pile.service.AdapayMemberAccountService;
|
import com.jsowell.pile.service.AdapayMemberAccountService;
|
||||||
@@ -347,6 +349,70 @@ public class OrderSplitRecordServiceImpl implements OrderSplitRecordService {
|
|||||||
return orderSplitRecordMapper.queryOrderSplitRecordByMemberId(adapayMemberId, startTime, endTime);
|
return orderSplitRecordMapper.queryOrderSplitRecordByMemberId(adapayMemberId, startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SplitConfigOrderVO> queryStationAggregateData(SplitConfigStationDTO dto) {
|
||||||
|
//获取该汇付id的所有分账信息
|
||||||
|
List<SplitConfigStationVO> lists=orderSplitRecordMapper.queryStationAggregateData(dto);
|
||||||
|
if(CollectionUtils.isEmpty(lists)){
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
//根据stationId分组
|
||||||
|
Map<String, List<SplitConfigStationVO>> collect = lists.stream()
|
||||||
|
.collect(Collectors.groupingBy(SplitConfigStationVO::getStationId));
|
||||||
|
|
||||||
|
//根据分组进行分账信息的汇总
|
||||||
|
List<SplitConfigOrderVO> resultList = Lists.newArrayList();
|
||||||
|
for (Map.Entry<String, List<SplitConfigStationVO>> entry : collect.entrySet()) {
|
||||||
|
String stationId = entry.getKey();
|
||||||
|
List<SplitConfigStationVO> splitConfigStationVOList = entry.getValue();
|
||||||
|
|
||||||
|
//计算时间范围
|
||||||
|
List<SplitConfigStationVO> sortedList = splitConfigStationVOList.stream()
|
||||||
|
.sorted(Comparator.comparing(SplitConfigStationVO::getTradeDate))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
String startTime = sortedList.get(0).getTradeDate();
|
||||||
|
String endTime = sortedList.get(sortedList.size() - 1).getTradeDate();
|
||||||
|
|
||||||
|
String timeRange = startTime + "至" + endTime;
|
||||||
|
|
||||||
|
//总的电费分账金额totalElectricitySplitAmount
|
||||||
|
BigDecimal totalElectricitySplitAmount =
|
||||||
|
splitConfigStationVOList.stream()
|
||||||
|
.map(SplitConfigStationVO::getElectricityAmount)
|
||||||
|
.filter(Objects::nonNull) //过滤掉null
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
//总的服务费分账金额totalServiceSplitAmount
|
||||||
|
BigDecimal totalServiceSplitAmount =
|
||||||
|
splitConfigStationVOList.stream()
|
||||||
|
.map(SplitConfigStationVO::getServiceAmount)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
//总手续费分账金额totalFeeAmount
|
||||||
|
BigDecimal totalFeeAmount =
|
||||||
|
splitConfigStationVOList.stream()
|
||||||
|
.map(SplitConfigStationVO::getFeeAmount)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
|
||||||
|
//总收入分账金额= 总电费分账金额 +总手续费分账金额 -总手续费分账金额
|
||||||
|
BigDecimal totalRevenueAmount = totalElectricitySplitAmount.add(totalServiceSplitAmount).subtract(totalFeeAmount);
|
||||||
|
SplitConfigOrderVO splitConfigOrderVO =
|
||||||
|
SplitConfigOrderVO.builder()
|
||||||
|
.stationId(stationId)
|
||||||
|
.stationName(splitConfigStationVOList.get(0).getStationName())
|
||||||
|
.orderCount(splitConfigStationVOList.size())
|
||||||
|
.timeRange(timeRange)
|
||||||
|
.totalElectricitySplitAmount(totalElectricitySplitAmount)
|
||||||
|
.totalServiceSplitAmount(totalServiceSplitAmount)
|
||||||
|
.totalFeeAmount(totalFeeAmount)
|
||||||
|
.totalRevenueAmount(totalRevenueAmount)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
resultList.add(splitConfigOrderVO);
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据merchantId, 查询从他人分账的金额
|
* 根据merchantId, 查询从他人分账的金额
|
||||||
* extra income
|
* extra income
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.jsowell.pile.vo.web;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class SplitConfigOrderVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 站点ID
|
||||||
|
*/
|
||||||
|
private String stationId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 站点名称
|
||||||
|
*/
|
||||||
|
private String stationName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间范围
|
||||||
|
*/
|
||||||
|
private String timeRange;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单数量
|
||||||
|
*/
|
||||||
|
private int orderCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总电费分账金额
|
||||||
|
*/
|
||||||
|
private BigDecimal totalElectricitySplitAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总服务费分账金额
|
||||||
|
*/
|
||||||
|
private BigDecimal totalServiceSplitAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总手续费分账金额
|
||||||
|
*/
|
||||||
|
private BigDecimal totalFeeAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总收入分账金额= 总电费分账金额 +总手续费分账金额 -总手续费分账金额
|
||||||
|
*/
|
||||||
|
private BigDecimal totalRevenueAmount;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ package com.jsowell.pile.vo.web;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class SplitConfigStationVO {
|
public class SplitConfigStationVO {
|
||||||
|
|
||||||
@@ -15,4 +17,12 @@ public class SplitConfigStationVO {
|
|||||||
*/
|
*/
|
||||||
private String stationName;
|
private String stationName;
|
||||||
|
|
||||||
|
private String tradeDate;
|
||||||
|
|
||||||
|
private BigDecimal electricityAmount;
|
||||||
|
|
||||||
|
private BigDecimal serviceAmount;
|
||||||
|
|
||||||
|
private BigDecimal feeAmount;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -836,4 +836,23 @@
|
|||||||
station_id = #{dto.stationId,jdbcType=VARCHAR}
|
station_id = #{dto.stationId,jdbcType=VARCHAR}
|
||||||
AND trade_date BETWEEN #{dto.startTime,jdbcType=VARCHAR} AND #{dto.endTime,jdbcType=VARCHAR}
|
AND trade_date BETWEEN #{dto.startTime,jdbcType=VARCHAR} AND #{dto.endTime,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="queryStationAggregateData" resultType="com.jsowell.pile.vo.web.SplitConfigStationVO">
|
||||||
|
SELECT
|
||||||
|
t2.station_id AS stationId,
|
||||||
|
t3.station_name AS stationName,
|
||||||
|
t1.electricity_amount AS electricityAmount,
|
||||||
|
t1.service_amount AS serviceAmount,
|
||||||
|
t1.fee_amount AS feeAmount,
|
||||||
|
t1.trade_date AS tradeDate
|
||||||
|
FROM
|
||||||
|
order_split_record t1
|
||||||
|
JOIN order_basic_info t2 ON t1.order_code = t2.order_code
|
||||||
|
JOIN pile_station_info t3 ON t1.station_id = t3.id
|
||||||
|
WHERE
|
||||||
|
t1.adapay_member_id = #{adapayMemberId}
|
||||||
|
AND t1.del_flag = '0'
|
||||||
|
AND t1.trade_date BETWEEN #{startTime,jdbcType=VARCHAR} AND #{endTime,jdbcType=VARCHAR};
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user