mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
计算站点订单日报
This commit is contained in:
@@ -56,7 +56,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -137,6 +139,9 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
@Autowired
|
||||
private IMemberTransactionRecordService memberTransactionRecordService;
|
||||
|
||||
@Autowired
|
||||
private ISettleOrderReportService settleOrderReportService;
|
||||
|
||||
/**
|
||||
* 条件查询订单基本信息
|
||||
*
|
||||
@@ -1841,12 +1846,62 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
// 查询站点前一天完成的订单
|
||||
QueryOrderDTO dto = new QueryOrderDTO();
|
||||
dto.setStationId(stationId);
|
||||
LocalDate yesterday = LocalDate.now().plusDays(-1);
|
||||
dto.setStartTime(DateUtils.formatDateTime(LocalDateTime.of(yesterday, LocalTime.MIN)));
|
||||
dto.setEndTime(DateUtils.formatDateTime(LocalDateTime.of(yesterday, LocalTime.MAX)));
|
||||
List<OrderListVO> orderListVOS = orderBasicInfoMapper.selectOrderBasicInfoList(dto);
|
||||
if (CollectionUtils.isEmpty(orderListVOS)) {
|
||||
return;
|
||||
}
|
||||
// 统计出日报信息
|
||||
|
||||
BigDecimal useElectricity = BigDecimal.ZERO;
|
||||
int chargeNum = 0;
|
||||
long chargeTime = 0L;
|
||||
BigDecimal totalElectricityAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalServiceAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalOrderAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalVirtualAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalSettleAmount = BigDecimal.ZERO;
|
||||
for (OrderListVO vo : orderListVOS) {
|
||||
BigDecimal chargingDegree = new BigDecimal(vo.getChargingDegree());
|
||||
if (chargingDegree.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
// 只统计用电量大于0的
|
||||
continue;
|
||||
}
|
||||
// 充电度数
|
||||
useElectricity = useElectricity.add(chargingDegree);
|
||||
// 充电次数
|
||||
chargeNum += chargeNum;
|
||||
// 充电时间
|
||||
long l = DateUtils.intervalTime(vo.getChargeStartTime(), vo.getChargeEndTime());
|
||||
chargeTime += l;
|
||||
// 电费金额
|
||||
totalElectricityAmount = totalElectricityAmount.add(vo.getTotalElectricityAmount());
|
||||
// 服务费金额
|
||||
totalServiceAmount = totalServiceAmount.add(vo.getTotalServiceAmount());
|
||||
// 订单金额
|
||||
totalOrderAmount = totalOrderAmount.add(new BigDecimal(vo.getOrderAmount()));
|
||||
// 虚拟金额
|
||||
totalVirtualAmount = totalVirtualAmount.add(new BigDecimal(vo.getVirtualAmount()));
|
||||
// 结算金额
|
||||
totalSettleAmount = totalSettleAmount.add(new BigDecimal(vo.getSettleAmount()));
|
||||
}
|
||||
// 保存到数据库
|
||||
SettleOrderReport settleOrderReport = new SettleOrderReport();
|
||||
settleOrderReport.setMerchantId("");
|
||||
settleOrderReport.setStationId(stationId);
|
||||
settleOrderReport.setUseElectricity(useElectricity);
|
||||
settleOrderReport.setChargeNum(chargeNum + "");
|
||||
settleOrderReport.setChargeTime(chargeTime + "");
|
||||
settleOrderReport.setElectricityAmount(totalElectricityAmount);
|
||||
settleOrderReport.setServiceAmount(totalServiceAmount);
|
||||
settleOrderReport.setTotalAmount(totalOrderAmount);
|
||||
settleOrderReport.setVirtualAmount(totalVirtualAmount);
|
||||
settleOrderReport.setTradeDate(yesterday.toString());
|
||||
// 计算手续费 = 结算金额 * 0.55%
|
||||
BigDecimal tradeFee = totalSettleAmount.multiply(new BigDecimal("0.0055"));
|
||||
settleOrderReport.setTradeFee(tradeFee);
|
||||
settleOrderReport.setTradeAmount(totalSettleAmount.subtract(tradeFee));
|
||||
settleOrderReportService.insertSettleOrderReport(settleOrderReport);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +145,32 @@ public class WechatPayServiceImpl implements WechatPayService {
|
||||
return amLong.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String s = "{\n" +
|
||||
" \"mchid\": \"1632405339\",\n" +
|
||||
" \"appid\": \"wxbb3e0d474569481d\",\n" +
|
||||
" \"out_trade_no\": \"823422832569454592\",\n" +
|
||||
" \"transaction_id\": \"4200001841202305301676160680\",\n" +
|
||||
" \"trade_type\": \"JSAPI\",\n" +
|
||||
" \"trade_state\": \"SUCCESS\",\n" +
|
||||
" \"trade_state_desc\": \"支付成功\",\n" +
|
||||
" \"bank_type\": \"OTHERS\",\n" +
|
||||
" \"attach\": \"{\\\"memberId\\\":\\\"82507801\\\",\\\"orderCode\\\":\\\"C27473779928\\\",\\\"type\\\":\\\"order\\\"}\",\n" +
|
||||
" \"success_time\": \"2023-05-30T15:15:20+08:00\",\n" +
|
||||
" \"payer\": {\n" +
|
||||
" \"openid\": \"o4REX5FPLsLOxM2x9ig2MHuuHPqU\"\n" +
|
||||
" },\n" +
|
||||
" \"amount\": {\n" +
|
||||
" \"total\": 5000,\n" +
|
||||
" \"payer_total\": 5000,\n" +
|
||||
" \"currency\": \"CNY\",\n" +
|
||||
" \"payer_currency\": \"CNY\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
WechatPayNotifyResource wechatPayNotifyResource = JSON.parseObject(s, WechatPayNotifyResource.class);
|
||||
System.out.println(wechatPayNotifyResource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付回调
|
||||
* @param request
|
||||
|
||||
@@ -6,6 +6,8 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 后管订单列表页面
|
||||
*
|
||||
@@ -184,4 +186,14 @@ public class OrderListVO {
|
||||
* 支付机构
|
||||
*/
|
||||
private String paymentInstitutions;
|
||||
|
||||
/**
|
||||
* 电费金额
|
||||
*/
|
||||
private BigDecimal totalElectricityAmount;
|
||||
|
||||
/**
|
||||
* 服务费金额
|
||||
*/
|
||||
private BigDecimal totalServiceAmount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user