mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
手动结算订单
This commit is contained in:
@@ -6,7 +6,9 @@ import com.github.pagehelper.PageInfo;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.jsowell.common.constant.Constants;
|
import com.jsowell.common.constant.Constants;
|
||||||
|
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
||||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||||
|
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||||
import com.jsowell.common.core.page.PageResponse;
|
import com.jsowell.common.core.page.PageResponse;
|
||||||
import com.jsowell.common.enums.MemberWalletEnum;
|
import com.jsowell.common.enums.MemberWalletEnum;
|
||||||
import com.jsowell.common.enums.ykc.ActionTypeEnum;
|
import com.jsowell.common.enums.ykc.ActionTypeEnum;
|
||||||
@@ -20,12 +22,10 @@ import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
|||||||
import com.jsowell.common.enums.ykc.ScenarioEnum;
|
import com.jsowell.common.enums.ykc.ScenarioEnum;
|
||||||
import com.jsowell.common.exception.BusinessException;
|
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.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.common.util.bean.BeanUtils;
|
import com.jsowell.common.util.bean.BeanUtils;
|
||||||
import com.jsowell.common.util.id.IdUtils;
|
import com.jsowell.common.util.id.IdUtils;
|
||||||
import com.jsowell.netty.command.ykc.PublishPileBillingTemplateCommand;
|
|
||||||
import com.jsowell.netty.command.ykc.StartChargingCommand;
|
|
||||||
import com.jsowell.netty.service.yunkuaichong.YKCPushCommandService;
|
|
||||||
import com.jsowell.pile.domain.MemberTransactionRecord;
|
import com.jsowell.pile.domain.MemberTransactionRecord;
|
||||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||||
import com.jsowell.pile.domain.OrderDetail;
|
import com.jsowell.pile.domain.OrderDetail;
|
||||||
@@ -72,7 +72,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@@ -85,11 +84,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class OrderService {
|
public class OrderService {
|
||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TransactionService pileTransactionService;
|
private TransactionService pileTransactionService;
|
||||||
|
|
||||||
@@ -102,9 +98,6 @@ public class OrderService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PileRemoteService pileRemoteService;
|
private PileRemoteService pileRemoteService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private YKCPushCommandService ykcPushCommandService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileService pileService;
|
private PileService pileService;
|
||||||
|
|
||||||
@@ -299,20 +292,11 @@ public class OrderService {
|
|||||||
// 发送启动充电指令前,再次下发计费模板
|
// 发送启动充电指令前,再次下发计费模板
|
||||||
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
|
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
|
||||||
if (billingTemplateVO != null) {
|
if (billingTemplateVO != null) {
|
||||||
PublishPileBillingTemplateCommand templateCommand = new PublishPileBillingTemplateCommand();
|
pileRemoteService.publishPileBillingTemplate(pileSn, billingTemplateVO);
|
||||||
templateCommand.setBillingTemplateVO(billingTemplateVO);
|
|
||||||
templateCommand.setPileSn(pileSn);
|
|
||||||
ykcPushCommandService.pushPublishPileBillingTemplate(templateCommand);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送启动指令
|
// 发送启动指令
|
||||||
StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
pileRemoteService.remoteStartCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), payAmount);
|
||||||
.pileSn(pileSn)
|
|
||||||
.connectorCode(orderInfo.getConnectorCode())
|
|
||||||
.transactionCode(orderInfo.getTransactionCode())
|
|
||||||
.chargeAmount(payAmount)
|
|
||||||
.build();
|
|
||||||
ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -831,4 +815,49 @@ public class OrderService {
|
|||||||
public void closeStartFailedOrder(QueryOrderDTO dto) {
|
public void closeStartFailedOrder(QueryOrderDTO dto) {
|
||||||
orderBasicInfoService.closeStartFailedOrder(dto.getStartTime(), dto.getEndTime());
|
orderBasicInfoService.closeStartFailedOrder(dto.getStartTime(), dto.getEndTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人工结算订单
|
||||||
|
* @param dto
|
||||||
|
*/
|
||||||
|
public void manualSettlementOrder(QueryOrderDTO dto) {
|
||||||
|
// 查询订单
|
||||||
|
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||||
|
if (orderBasicInfo == null) {
|
||||||
|
log.info("人工结算订单-根据订单号:{}, 查询为null", dto.getOrderCode());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 当前登录用户,是否可以结算该订单
|
||||||
|
AuthorizedDeptVO authorizedMap = SecurityUtils.getAuthorizedMap();
|
||||||
|
if (authorizedMap == null) {
|
||||||
|
log.info("人工结算订单-当前登录管理员无权限");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> stationDeptIds = authorizedMap.getStationDeptIds();
|
||||||
|
if (CollectionUtils.isEmpty(stationDeptIds)) {
|
||||||
|
// 运营商管理员
|
||||||
|
List<String> merchantDeptIds = authorizedMap.getMerchantDeptIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取最后一次实时数据
|
||||||
|
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode());
|
||||||
|
if (CollectionUtils.isEmpty(chargingRealTimeData)) {
|
||||||
|
log.info("人工结算订单-根据订单号:{},查不到充电桩上传的实时数据,无法进行结算", dto.getOrderCode());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0);
|
||||||
|
|
||||||
|
// 组装交易记录数据
|
||||||
|
TransactionRecordsData data = new TransactionRecordsData();
|
||||||
|
data.setConsumptionAmount(realTimeMonitorData.getChargingAmount()); // 总消费金额
|
||||||
|
data.setTotalElectricity(realTimeMonitorData.getChargingDegree()); // 总用电量
|
||||||
|
data.setStopReasonMsg("人工结算订单,操作人:" + SecurityUtils.getUsername()); // 停止原因
|
||||||
|
|
||||||
|
// 结算订单
|
||||||
|
orderBasicInfoService.settleOrder(data, orderBasicInfo);
|
||||||
|
|
||||||
|
// 发送停止充电指令
|
||||||
|
pileRemoteService.remoteStopCharging(orderBasicInfo.getPileSn(), orderBasicInfo.getConnectorCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.jsowell.netty.command.ykc.IssueQRCodeCommand;
|
|||||||
import com.jsowell.netty.command.ykc.ProofreadTimeCommand;
|
import com.jsowell.netty.command.ykc.ProofreadTimeCommand;
|
||||||
import com.jsowell.netty.command.ykc.PublishPileBillingTemplateCommand;
|
import com.jsowell.netty.command.ykc.PublishPileBillingTemplateCommand;
|
||||||
import com.jsowell.netty.command.ykc.RebootCommand;
|
import com.jsowell.netty.command.ykc.RebootCommand;
|
||||||
|
import com.jsowell.netty.command.ykc.StartChargingCommand;
|
||||||
import com.jsowell.netty.command.ykc.StopChargingCommand;
|
import com.jsowell.netty.command.ykc.StopChargingCommand;
|
||||||
import com.jsowell.netty.command.ykc.UpdateFileCommand;
|
import com.jsowell.netty.command.ykc.UpdateFileCommand;
|
||||||
import com.jsowell.netty.service.yunkuaichong.YKCPushCommandService;
|
import com.jsowell.netty.service.yunkuaichong.YKCPushCommandService;
|
||||||
@@ -23,6 +24,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -71,21 +73,21 @@ public class PileRemoteService {
|
|||||||
*
|
*
|
||||||
* @param pileSn 充电桩sn
|
* @param pileSn 充电桩sn
|
||||||
*/
|
*/
|
||||||
// public void remoteStartCharging(String orderCode, String pileSn, String connectorCode, BigDecimal accountBalance) {
|
public void remoteStartCharging(String pileSn, String connectorCode, String transactionCode, BigDecimal accountBalance) {
|
||||||
// // String s = "550314127823050120180619144446808800000000000101000000100000057300000000D14B0A54A0860100";
|
// String s = "550314127823050120180619144446808800000000000101000000100000057300000000D14B0A54A0860100";
|
||||||
// if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
||||||
// log.warn("远程启动充电, 充电桩编号和枪口号不能为空");
|
log.warn("远程启动充电, 充电桩编号和枪口号不能为空");
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// log.info("=====平台下发指令=====: 远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
|
log.info("=====平台下发指令=====: 远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
|
||||||
// StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
||||||
// .pileSn(pileSn)
|
.pileSn(pileSn)
|
||||||
// .connectorCode(connectorCode)
|
.connectorCode(connectorCode)
|
||||||
// .orderCode(orderCode)
|
.transactionCode(transactionCode)
|
||||||
// .chargeAmount(accountBalance)
|
.chargeAmount(accountBalance)
|
||||||
// .build();
|
.build();
|
||||||
// ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 远程停止充电
|
* 远程停止充电
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.jsowell.common.core.controller.BaseController;
|
|||||||
import com.jsowell.common.core.domain.AjaxResult;
|
import com.jsowell.common.core.domain.AjaxResult;
|
||||||
import com.jsowell.common.core.page.TableDataInfo;
|
import com.jsowell.common.core.page.TableDataInfo;
|
||||||
import com.jsowell.common.enums.BusinessType;
|
import com.jsowell.common.enums.BusinessType;
|
||||||
|
import com.jsowell.common.response.RestApiResponse;
|
||||||
import com.jsowell.common.util.poi.ExcelUtil;
|
import com.jsowell.common.util.poi.ExcelUtil;
|
||||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||||
@@ -101,4 +102,15 @@ public class OrderBasicInfoController extends BaseController {
|
|||||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
return toAjax(orderBasicInfoService.deleteOrderBasicInfoByIds(ids));
|
return toAjax(orderBasicInfoService.deleteOrderBasicInfoByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人工结算订单
|
||||||
|
* http://localhost:8080/order/manualSettlementOrder
|
||||||
|
*/
|
||||||
|
@PostMapping("/manualSettlementOrder")
|
||||||
|
public RestApiResponse<?> manualSettlementOrder(@RequestBody QueryOrderDTO dto) {
|
||||||
|
orderService.manualSettlementOrder(dto);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import java.util.List;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class AuthorizedDeptVO {
|
public class AuthorizedDeptVO {
|
||||||
|
private String roleKey;
|
||||||
// 有权限的运营商
|
// 有权限的运营商
|
||||||
private List<String> merchantDeptIds;
|
private List<String> merchantDeptIds;
|
||||||
// 有权限的站点
|
// 有权限的站点
|
||||||
|
|||||||
@@ -569,28 +569,36 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
try {
|
try {
|
||||||
orderDetail.setTotalUsedElectricity(new BigDecimal(data.getTotalElectricity())); // 总用电量
|
orderDetail.setTotalUsedElectricity(new BigDecimal(data.getTotalElectricity())); // 总用电量
|
||||||
orderDetail.setTotalOrderAmount(orderAmount); // 订单总金额
|
orderDetail.setTotalOrderAmount(orderAmount); // 订单总金额
|
||||||
orderDetail.setSharpUsedElectricity(new BigDecimal(data.getSharpUsedElectricity())); // 尖时段用电量
|
if (data.getSharpUsedElectricity() != null) {
|
||||||
|
orderDetail.setSharpUsedElectricity(new BigDecimal(data.getSharpUsedElectricity())); // 尖时段用电量
|
||||||
|
}
|
||||||
if (data.getSharpPrice() != null) {
|
if (data.getSharpPrice() != null) {
|
||||||
orderDetail.setSharpPrice(new BigDecimal(data.getSharpPrice()));
|
orderDetail.setSharpPrice(new BigDecimal(data.getSharpPrice()));
|
||||||
}
|
}
|
||||||
if (data.getSharpAmount() != null) {
|
if (data.getSharpAmount() != null) {
|
||||||
orderDetail.setSharpAmount(new BigDecimal(data.getSharpAmount()));
|
orderDetail.setSharpAmount(new BigDecimal(data.getSharpAmount()));
|
||||||
}
|
}
|
||||||
orderDetail.setPeakUsedElectricity(new BigDecimal(data.getPeakUsedElectricity())); // 峰时段用电量
|
if (data.getPeakUsedElectricity() != null) {
|
||||||
|
orderDetail.setPeakUsedElectricity(new BigDecimal(data.getPeakUsedElectricity())); // 峰时段用电量
|
||||||
|
}
|
||||||
if (data.getPeakPrice() != null) {
|
if (data.getPeakPrice() != null) {
|
||||||
orderDetail.setPeakPrice(new BigDecimal(data.getPeakPrice()));
|
orderDetail.setPeakPrice(new BigDecimal(data.getPeakPrice()));
|
||||||
}
|
}
|
||||||
if (data.getPeakAmount() != null) {
|
if (data.getPeakAmount() != null) {
|
||||||
orderDetail.setPeakAmount(new BigDecimal(data.getPeakAmount()));
|
orderDetail.setPeakAmount(new BigDecimal(data.getPeakAmount()));
|
||||||
}
|
}
|
||||||
orderDetail.setFlatUsedElectricity(new BigDecimal(data.getFlatUsedElectricity())); // 平时段用电量
|
if (data.getFlatUsedElectricity() != null) {
|
||||||
|
orderDetail.setFlatUsedElectricity(new BigDecimal(data.getFlatUsedElectricity())); // 平时段用电量
|
||||||
|
}
|
||||||
if (data.getFlatPrice() != null) {
|
if (data.getFlatPrice() != null) {
|
||||||
orderDetail.setFlatPrice(new BigDecimal(data.getFlatPrice()));
|
orderDetail.setFlatPrice(new BigDecimal(data.getFlatPrice()));
|
||||||
}
|
}
|
||||||
if (data.getFlatAmount() != null) {
|
if (data.getFlatAmount() != null) {
|
||||||
orderDetail.setFlatAmount(new BigDecimal(data.getFlatAmount()));
|
orderDetail.setFlatAmount(new BigDecimal(data.getFlatAmount()));
|
||||||
}
|
}
|
||||||
orderDetail.setValleyUsedElectricity(new BigDecimal(data.getValleyUsedElectricity())); // 谷时段用电量
|
if (data.getValleyUsedElectricity() != null) {
|
||||||
|
orderDetail.setValleyUsedElectricity(new BigDecimal(data.getValleyUsedElectricity())); // 谷时段用电量
|
||||||
|
}
|
||||||
if (data.getValleyPrice() != null) {
|
if (data.getValleyPrice() != null) {
|
||||||
orderDetail.setValleyPrice(new BigDecimal(data.getValleyPrice()));
|
orderDetail.setValleyPrice(new BigDecimal(data.getValleyPrice()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user