mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
Merge branch 'dev-new' into dev-new-rabbitmq
# Conflicts: # jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/TempController.java # jsowell-admin/src/test/java/SpringBootTestController.java
This commit is contained in:
117
jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GanSuController.java
vendored
Normal file
117
jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GanSuController.java
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
package com.jsowell.api.thirdparty;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
|
||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 甘肃省平台Controller
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2024/11/9 13:22:05
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/gansu")
|
||||
public class GanSuController extends ThirdPartyBaseController{
|
||||
private final String platformName = "甘肃省平台";
|
||||
|
||||
@Autowired
|
||||
@Qualifier("ganSuPlatformServiceImpl")
|
||||
private ThirdPartyPlatformService platformLogic;
|
||||
|
||||
/**
|
||||
* getToken
|
||||
*/
|
||||
@PostMapping("/v1/query_token")
|
||||
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||
// logger.info("{}-请求令牌 params:{}", platformName, JSON.toJSONString(dto));
|
||||
try {
|
||||
Map<String, String> map = platformLogic.queryToken(dto);
|
||||
logger.info("{}-请求令牌, params:{}, result:{}", platformName, JSON.toJSONString(dto), JSON.toJSONString(map));
|
||||
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-获取token接口, 异常, params:{}", platformName, JSON.toJSONString(dto), e);
|
||||
return CommonResult.failed("获取token发生异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电站信息
|
||||
* query_stations_info
|
||||
*/
|
||||
@PostMapping("/v1/query_stations_info")
|
||||
public CommonResult<?> query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("{}-查询充电站信息 params:{}", platformName, JSON.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
if (!verifyToken(request.getHeader("Authorization"))) {
|
||||
// 校验失败
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
||||
}
|
||||
|
||||
// 校验签名
|
||||
if (!verifySignature(dto)) {
|
||||
// 签名错误
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
|
||||
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryStationsInfo(queryStationInfoDTO);
|
||||
|
||||
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("{}-查询充电站信息 error:", platformName, e);
|
||||
}
|
||||
return CommonResult.failed("查询充电站信息发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电站状态信息
|
||||
* query_station_status
|
||||
*/
|
||||
@PostMapping("/v1/query_station_status")
|
||||
public CommonResult<?> queryStationStatus(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("{}-查询充电站状态信息 params:{}", platformName, JSON.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
if (!verifyToken(request.getHeader("Authorization"))) {
|
||||
// 校验失败
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
||||
}
|
||||
|
||||
// 校验签名
|
||||
if (!verifySignature(dto)) {
|
||||
// 签名错误
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
|
||||
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryStationStatus(queryStationInfoDTO);
|
||||
|
||||
return CommonResult.success(0, "查询充电站状态信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-查询充电站状态信息 error:", platformName, e);
|
||||
}
|
||||
return CommonResult.failed("查询充电站状态信息发生异常");
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class NeiMengGuController extends ThirdPartyBaseController {
|
||||
*/
|
||||
@PostMapping("/v1/supervise_query_stations_info")
|
||||
public CommonResult<?> queryStationsInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||
logger.info("{}-查询运营商信息 params:{}", platformName, JSON.toJSONString(dto));
|
||||
logger.info("{}-查询充换电站信息 params:{}", platformName, JSON.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
boolean verifyToken = verifyToken(request.getHeader("Authorization"));
|
||||
@@ -105,7 +105,6 @@ public class NeiMengGuController extends ThirdPartyBaseController {
|
||||
// 校验失败
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
||||
}
|
||||
|
||||
// 校验签名
|
||||
if (!verifySignature(dto)) {
|
||||
// 签名错误
|
||||
@@ -113,11 +112,11 @@ public class NeiMengGuController extends ThirdPartyBaseController {
|
||||
}
|
||||
QueryStationInfoDTO paramDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
|
||||
Map<String, String> map = platformLogic.queryStationsInfo(paramDTO);
|
||||
logger.info("{}-查询运营商信息 result:{}", platformName, JSON.toJSONString(map));
|
||||
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||
logger.info("{}-查询充换电站信息 result:{}", platformName, JSON.toJSONString(map));
|
||||
return CommonResult.success(0, "成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-查询运营商信息 异常", platformName, e);
|
||||
return CommonResult.failed("查询运营商信息发生异常");
|
||||
logger.error("{}-查询充换电站信息 异常", platformName, e);
|
||||
return CommonResult.failed("查询充换电站信息发生异常");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Map;
|
||||
@RequestMapping("/suzhou")
|
||||
public class SuZhouPlatformController extends ThirdPartyBaseController{
|
||||
|
||||
private final String platformName = "苏州省平台";
|
||||
private final String platformName = "苏州市平台";
|
||||
|
||||
@Autowired
|
||||
@Qualifier("suZhouPlatformServiceImpl")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.api.uniapp.customer;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.jsowell.adapay.dto.BalancePaymentRequestDTO;
|
||||
import com.jsowell.adapay.service.AdapayService;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
@@ -596,4 +597,56 @@ public class TempController extends BaseController {
|
||||
rabbitTemplate.convertAndSend(dto.getExchange(), dto.getRoutingKey(), dto.getData());
|
||||
return new RestApiResponse<>();
|
||||
}
|
||||
|
||||
/* 计算订单耗电量
|
||||
* dto.setStationId("657");
|
||||
* dto.setStartTime("2024-10-23 00:00:00");
|
||||
* dto.setEndTime("2024-11-07 23:59:59");
|
||||
*/
|
||||
@PostMapping("/calculateOrderElectricity")
|
||||
public RestApiResponse<?> calculateOrderElectricity(@RequestBody QueryOrderDTO dto) {
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
tempService.calculateOrderElectricity(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (Exception e) {
|
||||
logger.error("计算订单耗电量error", e);
|
||||
response = new RestApiResponse<>();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验订单是否为并充订单
|
||||
* https://localhost:8080/temp/checkCombinedChargingOrder
|
||||
*/
|
||||
@PostMapping("/checkCombinedChargingOrder")
|
||||
public RestApiResponse<?> checkCombinedChargingOrder(@RequestBody QueryOrderDTO dto) {
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
Map<String, List<String>> map = tempService.checkCombinedChargingOrder(dto.getOrderCodeList());
|
||||
response = new RestApiResponse<>(map);
|
||||
} catch (Exception e) {
|
||||
logger.error("校验订单是否为并充订单error", e);
|
||||
response = new RestApiResponse<>();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 并充订单数据修正
|
||||
* https://localhost:8080/temp/correctCombinedChargingOrder
|
||||
*/
|
||||
@PostMapping("/correctCombinedChargingOrder")
|
||||
public RestApiResponse<?> correctCombinedChargingOrder(@RequestBody QueryOrderDTO dto) {
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
List<String> list = tempService.correctCombinedChargingOrder(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("correctOrderCodeList", list));
|
||||
} catch (Exception e) {
|
||||
logger.error("校验订单是否为并充订单error", e);
|
||||
response = new RestApiResponse<>();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -13,15 +14,18 @@ import com.jsowell.adapay.response.QueryPaymentConfirmDetailResponse;
|
||||
import com.jsowell.adapay.service.AdapayService;
|
||||
import com.jsowell.adapay.vo.OrderSplitResult;
|
||||
import com.jsowell.adapay.vo.PaymentInfo;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.adapay.AdapayStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.*;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.*;
|
||||
import com.jsowell.pile.dto.ApplyRefundDTO;
|
||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||
import com.jsowell.pile.dto.SettleOrderReportDTO;
|
||||
import com.jsowell.pile.mapper.OrderBasicInfoMapper;
|
||||
import com.jsowell.pile.mapper.PileMsgRecordMapper;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.web.ClearingBillVO;
|
||||
import com.jsowell.pile.vo.web.OrderListVO;
|
||||
@@ -31,11 +35,13 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -77,6 +83,37 @@ public class TempService {
|
||||
@Autowired
|
||||
private MemberAdapayRecordService memberAdapayRecordService;
|
||||
|
||||
@Autowired
|
||||
private PileMsgRecordMapper pileMsgRecordMapper;
|
||||
|
||||
@Autowired
|
||||
private OrderDetailService orderDetailService;
|
||||
|
||||
@Autowired
|
||||
private OrderMonitorDataService orderMonitorDataService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 计算订单耗电量
|
||||
* 内蒙古站点
|
||||
*/
|
||||
public void calculateOrderElectricity(QueryOrderDTO dto) {
|
||||
// 根据站点id查询充电桩列表
|
||||
// List<String> pileSnList = Lists.newArrayList("88240000006708", "88240000006709", "88240000006713", "88240000006714");
|
||||
// 查询充电桩的订单列表
|
||||
List<OrderListVO> orderListVOS = orderBasicInfoService.selectOrderBasicInfoList(dto);
|
||||
logger.info("查询订单列表:{}", JSON.toJSONString(orderListVOS));
|
||||
// 根据充电桩编号,查询报文
|
||||
for (OrderListVO orderVO : orderListVOS) {
|
||||
String pileSn = orderVO.getPileSn();
|
||||
List<PileMsgRecord> pileFeedList = pileMsgRecordMapper.getPileFeedList(pileSn);
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动接口执行订单分账逻辑
|
||||
*/
|
||||
@@ -551,4 +588,127 @@ public class TempService {
|
||||
}
|
||||
logger.info("{} - {} 期间,共有{}笔支付单存在剩余金额, 共计:{},list:{}", dto.getStartTime(), dto.getEndTime(), paymentIdList.size(), total, JSON.toJSONString(paymentIdList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验是否为并充订单
|
||||
*/
|
||||
public Map<String, List<String>> checkCombinedChargingOrder(List<String> orderCodeList) throws BaseAdaPayException {
|
||||
Map<String, List<String>> resultMap = Maps.newHashMap();
|
||||
List<String> combinedChargingOrderList = Lists.newArrayList();
|
||||
List<String> notCombinedChargingOrderList = Lists.newArrayList();
|
||||
List<String> noDataOrderList = Lists.newArrayList();
|
||||
for (String orderCode : orderCodeList) {
|
||||
// 查询orderMonitorData
|
||||
OrderMonitorData orderMonitorData = orderMonitorDataService.selectByOrderCode(orderCode);
|
||||
if (orderMonitorData == null) {
|
||||
logger.info("订单:{}不存在", orderCode);
|
||||
noDataOrderList.add(orderCode);
|
||||
continue;
|
||||
}
|
||||
JSONArray jsonArray = JSONArray.parseArray(orderMonitorData.getMonitorData());
|
||||
List<BigDecimal> orderOutputCurrentList = Lists.newArrayList();
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String outputCurrent = jsonObject.getString("outputCurrent");
|
||||
orderOutputCurrentList.add(new BigDecimal(outputCurrent));
|
||||
}
|
||||
// 如果orderOutputCurrentList中任意一值大于250,判定为并充订单
|
||||
if (orderOutputCurrentList.stream().anyMatch(current -> current.compareTo(new BigDecimal("250")) > 0)) {
|
||||
combinedChargingOrderList.add(orderCode);
|
||||
} else {
|
||||
notCombinedChargingOrderList.add(orderCode);
|
||||
}
|
||||
}
|
||||
resultMap.put("combinedChargingOrderList", combinedChargingOrderList);
|
||||
resultMap.put("notCombinedChargingOrderList", notCombinedChargingOrderList);
|
||||
resultMap.put("noDataOrderList", noDataOrderList);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修正并充订单数据
|
||||
* @param dto
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<String> correctCombinedChargingOrder(QueryOrderDTO dto) {
|
||||
List<String> orderCodeList = dto.getOrderCodeList();
|
||||
logger.info("修正并充订单数据工具,订单号:{}", JSON.toJSONString(orderCodeList));
|
||||
// 查询临时表,不要重复修正
|
||||
String redisKey = "correct_combined_charging_order";
|
||||
List<String> redisResult = redisCache.getCacheList(redisKey);
|
||||
if (CollectionUtils.isNotEmpty(redisResult)) {
|
||||
logger.info("修正并充订单数据工具, 已修正订单:{}", JSON.toJSONString(redisResult));
|
||||
// 过滤掉已修正的订单
|
||||
orderCodeList.removeAll(redisResult);
|
||||
logger.info("修正并充订单数据工具. 过滤掉已修正的订单剩余:{}", JSON.toJSONString(orderCodeList));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(orderCodeList)) {
|
||||
logger.info("修正并充订单数据工具, 无需要修正的订单");
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
BigDecimal multiple = new BigDecimal("2");
|
||||
// 查询订单主表数据
|
||||
List<OrderBasicInfo> orderBasicInfos = orderBasicInfoService.queryOrderList(orderCodeList);
|
||||
for (OrderBasicInfo orderBasicInfo : orderBasicInfos) {
|
||||
orderBasicInfo.setOrderAmount(orderBasicInfo.getOrderAmount().multiply(multiple));
|
||||
orderBasicInfo.setVirtualAmount(orderBasicInfo.getVirtualAmount().multiply(multiple));
|
||||
orderBasicInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
}
|
||||
// 查询订单详情数据
|
||||
List<OrderDetail> orderDetailList = orderBasicInfoService.getOrderDetailList(orderCodeList);
|
||||
for (OrderDetail orderDetail : orderDetailList) {
|
||||
// 订单总用电量
|
||||
orderDetail.setTotalUsedElectricity(orderDetail.getTotalUsedElectricity().multiply(multiple));
|
||||
// 订单总电费金额
|
||||
orderDetail.setTotalElectricityAmount(orderDetail.getTotalElectricityAmount().multiply(multiple));
|
||||
// 订单总服务费金额
|
||||
orderDetail.setTotalServiceAmount(orderDetail.getTotalServiceAmount().multiply(multiple));
|
||||
// 订单总金额
|
||||
orderDetail.setTotalOrderAmount(orderDetail.getTotalOrderAmount().multiply(multiple));
|
||||
// 尖时段
|
||||
if (orderDetail.getSharpUsedElectricity() != null && orderDetail.getSharpUsedElectricity().compareTo(BigDecimal.ZERO) > 0) {
|
||||
orderDetail.setSharpUsedElectricity(orderDetail.getSharpUsedElectricity().multiply(multiple));
|
||||
// orderDetail.setSharpAmount(orderDetail.getSharpAmount().multiply(multiple));
|
||||
orderDetail.setSharpAmount(orderDetail.getSharpPrice().multiply(orderDetail.getSharpUsedElectricity()));
|
||||
}
|
||||
// 峰时段
|
||||
if (orderDetail.getPeakUsedElectricity() != null && orderDetail.getPeakUsedElectricity().compareTo(BigDecimal.ZERO) > 0) {
|
||||
orderDetail.setPeakUsedElectricity(orderDetail.getPeakUsedElectricity().multiply(multiple));
|
||||
// orderDetail.setPeakAmount(orderDetail.getPeakAmount().multiply(multiple));
|
||||
orderDetail.setPeakAmount(orderDetail.getPeakPrice().multiply(orderDetail.getPeakUsedElectricity()));
|
||||
}
|
||||
// 平时段
|
||||
if (orderDetail.getFlatUsedElectricity() != null && orderDetail.getFlatUsedElectricity().compareTo(BigDecimal.ZERO) > 0) {
|
||||
orderDetail.setFlatUsedElectricity(orderDetail.getFlatUsedElectricity().multiply(multiple));
|
||||
// orderDetail.setFlatAmount(orderDetail.getFlatAmount().multiply(multiple));
|
||||
orderDetail.setFlatAmount(orderDetail.getFlatPrice().multiply(orderDetail.getFlatUsedElectricity()));
|
||||
}
|
||||
// 谷时段
|
||||
if (orderDetail.getValleyUsedElectricity() != null && orderDetail.getValleyUsedElectricity().compareTo(BigDecimal.ZERO) > 0) {
|
||||
orderDetail.setValleyUsedElectricity(orderDetail.getValleyUsedElectricity().multiply(multiple));
|
||||
// orderDetail.setValleyAmount(orderDetail.getValleyAmount().multiply(multiple));
|
||||
orderDetail.setValleyAmount(orderDetail.getValleyPrice().multiply(orderDetail.getValleyUsedElectricity()));
|
||||
}
|
||||
orderDetail.setUpdateTime(DateUtils.getNowDate());
|
||||
}
|
||||
// 更新数据库
|
||||
int updateCount = 0;
|
||||
if (CollectionUtils.isNotEmpty(orderBasicInfos)) {
|
||||
updateCount = orderBasicInfoService.updateBatch(orderBasicInfos);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(orderDetailList)) {
|
||||
orderDetailService.updateBatch(orderDetailList);
|
||||
}
|
||||
|
||||
if (orderCodeList.size() == updateCount) {
|
||||
logger.info("修正并充订单数据工具, 修正成功, 订单号:{}", JSON.toJSONString(orderCodeList));
|
||||
Map<String, List<String>> redisMap = Maps.newHashMap();
|
||||
redisMap.put(redisKey, orderCodeList);
|
||||
redisCache.batchSetCacheList(redisMap, 300, TimeUnit.DAYS);
|
||||
}
|
||||
|
||||
return orderCodeList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
437
jsowell-admin/src/test/java/PaymentTestController.java
Normal file
437
jsowell-admin/src/test/java/PaymentTestController.java
Normal file
@@ -0,0 +1,437 @@
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||
import com.huifu.adapay.model.PaymentReverse;
|
||||
import com.huifu.adapay.model.Refund;
|
||||
import com.jsowell.JsowellApplication;
|
||||
import com.jsowell.adapay.dto.QueryConfirmReverseDTO;
|
||||
import com.jsowell.adapay.dto.QueryPaymentConfirmDTO;
|
||||
import com.jsowell.adapay.operation.PaymentReverseOperation;
|
||||
import com.jsowell.adapay.response.ConfirmReverseResponse;
|
||||
import com.jsowell.adapay.response.PaymentReverseResponse;
|
||||
import com.jsowell.adapay.response.QueryPaymentConfirmDetailResponse;
|
||||
import com.jsowell.adapay.service.AdapayService;
|
||||
import com.jsowell.common.enums.ykc.ScenarioEnum;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 专用处理汇付支付相关
|
||||
*/
|
||||
@ActiveProfiles("pre")
|
||||
@SpringBootTest(classes = JsowellApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class PaymentTestController {
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
String wechatAppId1 = "wxbb3e0d474569481d"; // 万车充
|
||||
|
||||
String wechatAppId2 = "wx20abc5210391649c"; // 嘉佳充电
|
||||
|
||||
@Autowired
|
||||
private AdapayService adapayService;
|
||||
|
||||
public List<String> getPaymentIdList() {
|
||||
List<String> resultList = Lists.newArrayList();
|
||||
// List<String> paymentIdList1 = getPaymentIdList1();
|
||||
List<String> paymentIdListForFile = getPaymentIdListForFile();
|
||||
resultList.addAll(paymentIdListForFile);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从文件中读取paymentId
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public List<String> getPaymentIdListForFile() {
|
||||
List<String> list =new ArrayList<String>();
|
||||
try {
|
||||
String path = "src/test/resources/payment_ids";
|
||||
FileReader fileReader =new FileReader(path);
|
||||
BufferedReader bufferedReader =new BufferedReader(fileReader);
|
||||
String str=null;
|
||||
while((str=bufferedReader.readLine())!=null) {
|
||||
if(str.trim().length()>2) {
|
||||
list.add(str);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
// System.out.println(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list1 = Lists.newArrayList(
|
||||
"C84866578627",
|
||||
"C69407733440",
|
||||
"C46698893183",
|
||||
"C23481086913",
|
||||
"C46631353044",
|
||||
"C82315862441",
|
||||
"C48515444163",
|
||||
"C88894523461",
|
||||
"C63539142496",
|
||||
"C88227376749",
|
||||
"C69808468000",
|
||||
"C29756635462",
|
||||
"C48171513017",
|
||||
"C82929694510",
|
||||
"C42286214889",
|
||||
"C40531240168",
|
||||
"C42818195903",
|
||||
"C44772182853",
|
||||
"C63995701102",
|
||||
"C84653836282",
|
||||
"C82929004110",
|
||||
"C42248888826",
|
||||
"C42871512014",
|
||||
"C61630741271",
|
||||
"C44120948533",
|
||||
"C86510728306",
|
||||
"C23698728789",
|
||||
"C40725164803",
|
||||
"C46426468297",
|
||||
"C80876734677",
|
||||
"C65208404269",
|
||||
"C48131292456",
|
||||
"C27264263390",
|
||||
"C42620874381",
|
||||
"C27264478506",
|
||||
"C82758563554",
|
||||
"C44588350706",
|
||||
"C86153980315",
|
||||
"C86782182478",
|
||||
"C42077527679",
|
||||
"C80606430852",
|
||||
"C21377880382",
|
||||
"C63590496985",
|
||||
"C25745398205",
|
||||
"C63136978056",
|
||||
"C21983806615",
|
||||
"C42016184953",
|
||||
"C27458903931",
|
||||
"C40590975531",
|
||||
"C44987731257",
|
||||
"C63554143992",
|
||||
"C46468609277",
|
||||
"C23483139052",
|
||||
"C67759764676",
|
||||
"C65286550984",
|
||||
"C44772583755",
|
||||
"C65037735356",
|
||||
"C23065540340",
|
||||
"C82330428460",
|
||||
"C40136408323",
|
||||
"C65896968515",
|
||||
"C80093965053",
|
||||
"C23029064125",
|
||||
"C46291260090",
|
||||
"C40915419435",
|
||||
"C69234709266",
|
||||
"C61064626771",
|
||||
"C84216893653",
|
||||
"C69869670458",
|
||||
"C44755242724",
|
||||
"C63706872923",
|
||||
"C61047783388",
|
||||
"C80663278468",
|
||||
"C46232390797",
|
||||
"C44561702210",
|
||||
"C61404525849",
|
||||
"C80813608253"
|
||||
);
|
||||
List<String> list2 = Lists.newArrayList(
|
||||
"C69407733440",
|
||||
"C84866578627",
|
||||
"C46698893183",
|
||||
"C46631353044",
|
||||
"C23481086913",
|
||||
"C88894523461",
|
||||
"C48515444163",
|
||||
"C82315862441",
|
||||
"C48171513017",
|
||||
"C29756635462",
|
||||
"C69808468000",
|
||||
"C88227376749",
|
||||
"C63539142496",
|
||||
"C42818195903",
|
||||
"C40531240168",
|
||||
"C42286214889",
|
||||
"C82929694510",
|
||||
"C63995701102",
|
||||
"C44772182853",
|
||||
"C84653836282",
|
||||
"C42871512014",
|
||||
"C42248888826",
|
||||
"C82929004110",
|
||||
"C44120948533",
|
||||
"C61630741271",
|
||||
"C23698728789",
|
||||
"C86510728306",
|
||||
"C80876734677",
|
||||
"C46426468297",
|
||||
"C40725164803",
|
||||
"C48131292456",
|
||||
"C65208404269",
|
||||
"C82758563554",
|
||||
"C27264263390",
|
||||
"C27264478506",
|
||||
"C42620874381",
|
||||
"C25745398205",
|
||||
"C86153980315",
|
||||
"C63590496985",
|
||||
"C21377880382",
|
||||
"C80606430852",
|
||||
"C44588350706",
|
||||
"C42077527679",
|
||||
"C86782182478",
|
||||
"C40590975531",
|
||||
"C27458903931",
|
||||
"C42016184953",
|
||||
"C21983806615",
|
||||
"C63136978056",
|
||||
"C44772583755",
|
||||
"C46468609277",
|
||||
"C65286550984",
|
||||
"C63554143992",
|
||||
"C67759764676",
|
||||
"C44987731257",
|
||||
"C23483139052",
|
||||
"C23065540340",
|
||||
"C65037735356",
|
||||
"C80093965053",
|
||||
"C65896968515",
|
||||
"C82330428460",
|
||||
"C40136408323",
|
||||
"C23029064125",
|
||||
"C63706872923",
|
||||
"C40915419435",
|
||||
"C44755242724",
|
||||
"C69869670458",
|
||||
"C84216893653",
|
||||
"C61064626771",
|
||||
"C69234709266",
|
||||
"C46291260090",
|
||||
"C80813608253",
|
||||
"C61404525849",
|
||||
"C61047783388",
|
||||
"C44561702210",
|
||||
"C46232390797",
|
||||
"C80663278468");
|
||||
Sets.SetView<String> difference = Sets.intersection(Sets.newHashSet(list1), Sets.newHashSet(list2));
|
||||
System.out.println(difference);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分账信息
|
||||
* @throws BaseAdaPayException
|
||||
*/
|
||||
@Test
|
||||
public void queryCreateConfirmReverse() throws BaseAdaPayException {
|
||||
List<String> paymentIdList = getPaymentIdList(); // 查询分账信息
|
||||
|
||||
List<String> unSplitList = Lists.newArrayList(); // 未分帐
|
||||
List<String> splitList = Lists.newArrayList(); // 已分帐
|
||||
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
List<String> selfList = Lists.newArrayList();
|
||||
|
||||
Map<String, BigDecimal> map = Maps.newHashMap();
|
||||
for (String paymentId : paymentIdList) {
|
||||
if (StringUtils.isBlank(paymentId)) {
|
||||
continue;
|
||||
}
|
||||
// 查询支付确认id
|
||||
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
|
||||
dto.setPaymentId(paymentId);
|
||||
dto.setWechatAppId(wechatAppId1);
|
||||
// 查询分账信息
|
||||
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(dto);
|
||||
if (response != null) {
|
||||
List<QueryPaymentConfirmDetailResponse.PaymentConfirmInfo> confirms = response.getPaymentConfirms();
|
||||
if (CollectionUtils.isEmpty(confirms)) {
|
||||
unSplitList.add(paymentId);
|
||||
} else {
|
||||
splitList.add(paymentId);
|
||||
for (QueryPaymentConfirmDetailResponse.PaymentConfirmInfo confirm : confirms) {
|
||||
if (queryConfirmReverseStatus(confirm)) {
|
||||
System.out.println("支付确认id:" + confirm.getId() + "撤销了。。。");
|
||||
continue;
|
||||
}
|
||||
JSONObject jsonObject = JSON.parseObject(confirm.getDescription());
|
||||
String adapayMemberId = jsonObject.getString("adapayMemberId");
|
||||
BigDecimal confirmedAmt = new BigDecimal(confirm.getConfirmedAmt());
|
||||
|
||||
total = total.add(confirmedAmt);
|
||||
|
||||
// 放map
|
||||
map.merge(adapayMemberId, confirmedAmt, BigDecimal::add);
|
||||
|
||||
if (StringUtils.equals(adapayMemberId, "0")) {
|
||||
selfList.add(paymentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unSplitList.add(paymentId);
|
||||
}
|
||||
}
|
||||
System.out.println("=================未分账:" + JSON.toJSONString(unSplitList) + ", 数量:" + unSplitList.size());
|
||||
System.out.println("=================已分账:" + JSON.toJSONString(map) + ", 总分账:" + total + ", 数量:" + splitList.size());
|
||||
System.out.println("=================自己:" + JSON.toJSONString(selfList) + ", 数量:" + selfList.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询支付撤销状态
|
||||
* @param confirm
|
||||
* @return
|
||||
* @throws BaseAdaPayException
|
||||
*/
|
||||
private boolean queryConfirmReverseStatus(QueryPaymentConfirmDetailResponse.PaymentConfirmInfo confirm) throws BaseAdaPayException {
|
||||
boolean result = false;
|
||||
QueryConfirmReverseDTO dto = QueryConfirmReverseDTO.builder()
|
||||
.paymentConfirmId(confirm.getId())
|
||||
.wechatAppId(wechatAppId1)
|
||||
.build();
|
||||
ConfirmReverseResponse confirmReverseResponse = adapayService.queryConfirmReverse(dto);
|
||||
if (confirmReverseResponse.isSuccess()) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量支付确认撤销
|
||||
* @throws BaseAdaPayException
|
||||
*/
|
||||
@Test
|
||||
public void testCreateConfirmReverse() throws BaseAdaPayException {
|
||||
List<String> list = getPaymentIdList(); // 批量支付确认撤销
|
||||
for (String paymentId : list) {
|
||||
// 查询支付确认id
|
||||
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
|
||||
dto.setPaymentId(paymentId);
|
||||
dto.setWechatAppId(wechatAppId1);
|
||||
QueryPaymentConfirmDetailResponse response = adapayService.queryPaymentConfirmList(dto);
|
||||
if (response != null) {
|
||||
List<QueryPaymentConfirmDetailResponse.PaymentConfirmInfo> confirms = response.getPaymentConfirms();
|
||||
System.out.println("支付id:" + paymentId + ", 确认信息:" + JSON.toJSONString(confirms));
|
||||
if (CollectionUtils.isNotEmpty(confirms)) {
|
||||
for (QueryPaymentConfirmDetailResponse.PaymentConfirmInfo confirm : confirms) {
|
||||
adapayService.createConfirmReverse(confirm.getId(), wechatAppId1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询退款信息
|
||||
*/
|
||||
@Test
|
||||
public void queryRefundTest() {
|
||||
List<String> list = getPaymentIdList(); // 查询退款信息
|
||||
for (String paymentId : list) {
|
||||
Map<String, Object> refundParams = Maps.newHashMap();
|
||||
refundParams.put("payment_id", paymentId);
|
||||
try {
|
||||
Map<String, Object> refund = Refund.query(refundParams, wechatAppId2);
|
||||
System.out.println("支付id:" + paymentId + ", 退款信息:" + JSON.toJSONString(refund));
|
||||
System.out.println();
|
||||
} catch (BaseAdaPayException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询支付撤销信息
|
||||
*/
|
||||
@Test
|
||||
public void queryPaymentReverseTest() {
|
||||
List<String> list = getPaymentIdList(); // 查询支付撤销信息
|
||||
for (String paymentId : list) {
|
||||
try {
|
||||
Map<String, Object> reverse = Maps.newHashMap();
|
||||
reverse.put("payment_id", paymentId);
|
||||
reverse.put("app_id", wechatAppId2);
|
||||
Map<String, Object> response = PaymentReverse.queryList(reverse, wechatAppId2);
|
||||
System.out.printf("支付id: %s, 支付撤销信息: %s%n", paymentId, JSON.toJSONString(response));
|
||||
System.out.println();
|
||||
} catch (BaseAdaPayException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 延迟分账未确认调撤销调撤销接口退款/部分退
|
||||
*/
|
||||
@Test
|
||||
public void createPaymentReverseRequestTest() {
|
||||
String paymentId = "002212024102215301510694702317666226176";
|
||||
BigDecimal refundAmount = new BigDecimal("15.42");
|
||||
String memberId = "42833137";
|
||||
String orderCode = "C21960272918";
|
||||
|
||||
// 延迟分账未确认调撤销调撤销接口退款
|
||||
PaymentReverseOperation operation = new PaymentReverseOperation();
|
||||
operation.setPaymentId(paymentId);
|
||||
operation.setReverseAmt(refundAmount);
|
||||
operation.setMerchantKey(wechatAppId1);
|
||||
operation.setMemberId(memberId);
|
||||
operation.setScenarioType(ScenarioEnum.ORDER.getValue());
|
||||
operation.setOrderCode(orderCode);
|
||||
PaymentReverseResponse response = adapayService.createPaymentReverseRequest(operation);
|
||||
System.out.println(JSON.toJSONString(response));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createBalancePaymentRequestTest() {
|
||||
String outMemberId = "ACM42875164"; // 出账memberId
|
||||
String inMemberId = "0"; // 入账memberId
|
||||
String transAmt = "798.20"; // 金额
|
||||
String title = "提取余额到自己账户"; // 标题
|
||||
String desc = "2024年7月31日08点55分,售后需求:客户重新添加结算账户, 原账户余额无法提取, 由现下打款给客户"; // 描述
|
||||
String wechatAppId = wechatAppId1; // 万车充id
|
||||
adapayService.createBalancePaymentRequest(outMemberId, inMemberId, transAmt, title, desc, wechatAppId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void createBalancePaymentRequestTest2() {
|
||||
String outMemberId = "0"; // 出账memberId
|
||||
String inMemberId = "ACM25158725"; // 入账memberId
|
||||
String transAmt = "42.7"; // 金额
|
||||
String title = "订单金额补分账"; // 标题
|
||||
String desc = "补C69401257710,C86364369573结算金额"; // 描述
|
||||
String wechatAppId = wechatAppId1; // 万车充id
|
||||
adapayService.createBalancePaymentRequest(outMemberId, inMemberId, transAmt, title, desc, wechatAppId);
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,7 @@ import com.jsowell.thirdparty.common.NotificationService;
|
||||
import com.jsowell.thirdparty.huawei.HuaWeiService;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
import com.jsowell.thirdparty.lutongyunting.service.LTYTService;
|
||||
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
|
||||
import com.jsowell.thirdparty.platform.util.Cryptos;
|
||||
import com.jsowell.thirdparty.platform.util.Encodes;
|
||||
import com.jsowell.thirdparty.platform.util.GBSignUtils;
|
||||
@@ -93,6 +94,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
@@ -273,6 +275,9 @@ public class SpringBootTestController {
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Qualifier("zhongDianLianPlatformServiceImpl")
|
||||
private ThirdPartyPlatformService platformLogic;
|
||||
|
||||
@Test
|
||||
public void sendRabbitMqTest() {
|
||||
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
|
||||
@@ -310,6 +315,14 @@ public class SpringBootTestController {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryStationStatus() {
|
||||
QueryStationInfoDTO dto = new QueryStationInfoDTO();
|
||||
dto.setStationIds(Lists.newArrayList("19"));
|
||||
Map<String, String> map = platformLogic.queryStationStatus(dto);
|
||||
System.out.println(map);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void batchSelectConnectorList() {
|
||||
ArrayList<String> stationIds = Lists.newArrayList("19", "2", "14");
|
||||
@@ -511,15 +524,15 @@ public class SpringBootTestController {
|
||||
|
||||
@Test
|
||||
public void queryBillingPriceTest() {
|
||||
String stationId = "19";
|
||||
String stationId = "1";
|
||||
// List<BillingPriceVO> billingPriceVOS = pileBillingTemplateService.queryBillingPriceOld(stationId);
|
||||
// System.out.println("老版:" + JSON.toJSONString(billingPriceVOS));
|
||||
//
|
||||
// List<BillingPriceVO> billingPriceVOS1 = pileBillingTemplateService.queryBillingPrice(stationId);
|
||||
// System.out.println("新版:" + JSON.toJSONString(billingPriceVOS1));
|
||||
List<BillingPriceVO> billingPriceVOS1 = pileBillingTemplateService.queryBillingPrice(stationId);
|
||||
System.out.println("新版:" + JSON.toJSONString(billingPriceVOS1));
|
||||
|
||||
CurrentTimePriceDetails currentTimePriceDetails = pileBillingTemplateService.getCurrentTimePriceDetails(stationId);
|
||||
System.out.println("currentTimePriceDetails:" + JSON.toJSONString(currentTimePriceDetails));
|
||||
// CurrentTimePriceDetails currentTimePriceDetails = pileBillingTemplateService.getCurrentTimePriceDetails(stationId);
|
||||
// System.out.println("currentTimePriceDetails:" + JSON.toJSONString(currentTimePriceDetails));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -571,75 +584,6 @@ public class SpringBootTestController {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDiscount() {
|
||||
OrderBasicInfo orderBasicInfo = new OrderBasicInfo();
|
||||
orderBasicInfo.setMemberId("12345678");
|
||||
orderBasicInfo.setMerchantId("1");
|
||||
orderBasicInfo.setStationId("19");
|
||||
orderBasicInfo.setPayAmount(new BigDecimal("200"));
|
||||
|
||||
OrderDetail orderDetail = new OrderDetail();
|
||||
orderDetail.setTotalElectricityAmount(new BigDecimal("3"));
|
||||
orderDetail.setTotalServiceAmount(new BigDecimal("0.18"));
|
||||
|
||||
|
||||
String memberId = orderBasicInfo.getMemberId(); // 会员id
|
||||
String merchantId = orderBasicInfo.getMerchantId(); // 运营商id
|
||||
String stationId = orderBasicInfo.getStationId(); // 站点id
|
||||
|
||||
// 电费折扣金额
|
||||
BigDecimal discountElectricityAmount = BigDecimal.ZERO;
|
||||
// 服务费折扣金额
|
||||
BigDecimal discountServiceAmount = BigDecimal.ZERO;
|
||||
|
||||
BigDecimal afterServiceAmountDiscount = BigDecimal.ZERO;
|
||||
BigDecimal afterElectricityAmountDiscount = BigDecimal.ZERO;
|
||||
|
||||
// 查询会员在此站点会员折扣
|
||||
MemberDiscountVO memberDiscountVO = memberGroupService.queryMemberDiscount(merchantId, stationId, memberId);
|
||||
if (memberDiscountVO != null) {
|
||||
BigDecimal discount = memberDiscountVO.getDiscount(); // 折扣率
|
||||
String groupType = memberDiscountVO.getGroupType(); // 类型(1-服务费折扣,2-电费折扣 ,3-电费和服务费一起折扣)
|
||||
BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount(); // 电费
|
||||
BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount(); // 服务费
|
||||
|
||||
afterServiceAmountDiscount = totalServiceAmount;
|
||||
afterElectricityAmountDiscount = totalElectricityAmount;
|
||||
if (Constants.ONE.equals(groupType)) {
|
||||
afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(4, RoundingMode.DOWN);
|
||||
discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount);
|
||||
} else if (Constants.TWO.equals(groupType)) {
|
||||
afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(4, RoundingMode.DOWN);
|
||||
discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount);
|
||||
} else {
|
||||
// BigDecimal afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(2, RoundingMode.DOWN);
|
||||
// discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount);
|
||||
// BigDecimal afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(2, RoundingMode.DOWN);
|
||||
// discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount);
|
||||
afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(4, RoundingMode.DOWN);
|
||||
afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(4, RoundingMode.DOWN);
|
||||
|
||||
discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount);
|
||||
discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount);
|
||||
}
|
||||
}
|
||||
// 订单折扣金额
|
||||
BigDecimal discountAmount = discountServiceAmount.add(discountElectricityAmount);
|
||||
orderBasicInfo.setDiscountAmount(discountAmount);
|
||||
// 更新退款金额 = 退款金额 - 折扣金额
|
||||
// BigDecimal refundAmount = orderBasicInfo.getRefundAmount().subtract(discountAmount);
|
||||
|
||||
// 总消费金额 = 折扣后电费 + 折扣后服务费
|
||||
BigDecimal totalConsumeAmount = afterServiceAmountDiscount.add(afterElectricityAmountDiscount);
|
||||
// 更新退款金额
|
||||
BigDecimal refundAmount = orderBasicInfo.getPayAmount().subtract(totalConsumeAmount).setScale(2, RoundingMode.DOWN);
|
||||
orderBasicInfo.setRefundAmount(refundAmount);
|
||||
|
||||
orderDetail.setDiscountElectricityAmount(discountElectricityAmount);
|
||||
orderDetail.setDiscountServiceAmount(discountServiceAmount);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryPaymentByOrderNoTest() {
|
||||
String orderNo = "C88850447008_20240415083226";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user