mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +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.Maps;
|
||||
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.TransactionRecordsData;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.enums.MemberWalletEnum;
|
||||
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.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.bean.BeanUtils;
|
||||
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.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.OrderDetail;
|
||||
@@ -72,7 +72,6 @@ import org.springframework.stereotype.Service;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -85,11 +84,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class OrderService {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Autowired
|
||||
private TransactionService pileTransactionService;
|
||||
|
||||
@@ -102,9 +98,6 @@ public class OrderService {
|
||||
@Autowired
|
||||
private PileRemoteService pileRemoteService;
|
||||
|
||||
@Autowired
|
||||
private YKCPushCommandService ykcPushCommandService;
|
||||
|
||||
@Autowired
|
||||
private PileService pileService;
|
||||
|
||||
@@ -299,20 +292,11 @@ public class OrderService {
|
||||
// 发送启动充电指令前,再次下发计费模板
|
||||
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
|
||||
if (billingTemplateVO != null) {
|
||||
PublishPileBillingTemplateCommand templateCommand = new PublishPileBillingTemplateCommand();
|
||||
templateCommand.setBillingTemplateVO(billingTemplateVO);
|
||||
templateCommand.setPileSn(pileSn);
|
||||
ykcPushCommandService.pushPublishPileBillingTemplate(templateCommand);
|
||||
pileRemoteService.publishPileBillingTemplate(pileSn, billingTemplateVO);
|
||||
}
|
||||
|
||||
// 发送启动指令
|
||||
StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
||||
.pileSn(pileSn)
|
||||
.connectorCode(orderInfo.getConnectorCode())
|
||||
.transactionCode(orderInfo.getTransactionCode())
|
||||
.chargeAmount(payAmount)
|
||||
.build();
|
||||
ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
||||
pileRemoteService.remoteStartCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), payAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -831,4 +815,49 @@ public class OrderService {
|
||||
public void closeStartFailedOrder(QueryOrderDTO dto) {
|
||||
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.PublishPileBillingTemplateCommand;
|
||||
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.UpdateFileCommand;
|
||||
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.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -71,21 +73,21 @@ public class PileRemoteService {
|
||||
*
|
||||
* @param pileSn 充电桩sn
|
||||
*/
|
||||
// public void remoteStartCharging(String orderCode, String pileSn, String connectorCode, BigDecimal accountBalance) {
|
||||
// // String s = "550314127823050120180619144446808800000000000101000000100000057300000000D14B0A54A0860100";
|
||||
// if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
||||
// log.warn("远程启动充电, 充电桩编号和枪口号不能为空");
|
||||
// return;
|
||||
// }
|
||||
// log.info("=====平台下发指令=====: 远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
|
||||
// StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
||||
// .pileSn(pileSn)
|
||||
// .connectorCode(connectorCode)
|
||||
// .orderCode(orderCode)
|
||||
// .chargeAmount(accountBalance)
|
||||
// .build();
|
||||
// ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
||||
// }
|
||||
public void remoteStartCharging(String pileSn, String connectorCode, String transactionCode, BigDecimal accountBalance) {
|
||||
// String s = "550314127823050120180619144446808800000000000101000000100000057300000000D14B0A54A0860100";
|
||||
if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
||||
log.warn("远程启动充电, 充电桩编号和枪口号不能为空");
|
||||
return;
|
||||
}
|
||||
log.info("=====平台下发指令=====: 远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
|
||||
StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
||||
.pileSn(pileSn)
|
||||
.connectorCode(connectorCode)
|
||||
.transactionCode(transactionCode)
|
||||
.chargeAmount(accountBalance)
|
||||
.build();
|
||||
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.page.TableDataInfo;
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.poi.ExcelUtil;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||
@@ -101,4 +102,15 @@ public class OrderBasicInfoController extends BaseController {
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(orderBasicInfoService.deleteOrderBasicInfoByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 人工结算订单
|
||||
* http://localhost:8080/order/manualSettlementOrder
|
||||
*/
|
||||
@PostMapping("/manualSettlementOrder")
|
||||
public RestApiResponse<?> manualSettlementOrder(@RequestBody QueryOrderDTO dto) {
|
||||
orderService.manualSettlementOrder(dto);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user