mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 19:45:09 +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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user