diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java index 6e2c5c687..fba58fcae 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PayController.java @@ -343,8 +343,8 @@ public class PayController extends BaseController { public void adapayCallback(HttpServletRequest request) { try { orderService.adapayCallback(request); - String type = request.getParameter("type"); - logger.info("1汇付回调type:{}", type); + // String type = request.getParameter("type"); + logger.info("1汇付回调type:{}", request.getParameter("type")); } catch (Exception e) { logger.error("1汇付支付回调失败 error", e); } diff --git a/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java b/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java index c1a1882cc..68dc5be68 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java @@ -1090,9 +1090,6 @@ public class OrderService { memberTransactionRecordService.insertSelective(record); if (StringUtils.equals(scenarioType, ScenarioEnum.ORDER.getValue())) { // 1-订单支付 - // JSONObject json = new JSONObject(); - // json.put("paymentId", paymentId); - // json.put("amount", amount); PaymentInfo paymentInfo = new PaymentInfo(); paymentInfo.setPaymentId(paymentId); paymentInfo.setAmount(amount.toString()); @@ -1110,7 +1107,13 @@ public class OrderService { orderPayRecordService.batchInsert(Lists.newArrayList(orderPayRecord)); // 更新冻结金额 支付成功后全部冻结 - memberAdapayRecordService.updateFreezeAmount(paymentId, amount); + CompletableFuture.runAsync(() -> { + try { + memberAdapayRecordService.updateFreezeAmount(paymentId, amount); + } catch (Exception e) { + log.error("更新冻结金额 支付成功后全部冻结error", e); + } + }); // 支付订单成功 PayOrderSuccessCallbackDTO callbackDTO = PayOrderSuccessCallbackDTO.builder() diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index c4b53b0e8..f8f69c0f1 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -16,7 +16,6 @@ import com.huifu.adapay.model.Payment; import com.huifu.adapay.model.PaymentReverse; import com.huifu.adapay.model.Refund; import com.jsowell.JsowellApplication; -import com.jsowell.adapay.common.AdaPayment; import com.jsowell.adapay.config.AbstractAdapayConfig; import com.jsowell.adapay.dto.*; import com.jsowell.adapay.factory.AdapayConfigFactory; @@ -25,6 +24,7 @@ import com.jsowell.adapay.response.*; import com.jsowell.adapay.service.AdapayService; import com.jsowell.adapay.vo.AdapayCorpMemberVO; import com.jsowell.adapay.vo.DrawCashDetailVO; +import com.jsowell.adapay.vo.PaymentInfo; import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.entity.SysDictData; @@ -380,11 +380,29 @@ public class SpringBootTestController { @Test public void queryPaymentByOrderNoTest() { - String orderNo = "C44903356969"; - String wechatAppId = "wxbb3e0d474569481d"; + String orderNo = "C84678771377_20240325162218"; + String wechatAppId = wechatAppId1; try { - List adaPayments = adapayService.queryPaymentByOrderNo(orderNo, wechatAppId); - System.out.println(JSON.toJSONString(adaPayments)); + // List adaPayments = adapayService.queryPaymentsByOrderNo(orderNo, wechatAppId); + // System.out.println(JSON.toJSONString(adaPayments)); + + Set paymentInfoSet = Sets.newHashSet(); + + List paymentInfos = adapayService.queryPaymentInfosByOrderNo(orderNo, wechatAppId); + paymentInfoSet.addAll(paymentInfos); + System.out.println("1111:" + JSON.toJSONString(paymentInfos)); + + List orderPayRecordList = orderPayRecordService.getOrderPayRecordList("C84678771377"); + if (CollectionUtils.isNotEmpty(orderPayRecordList)) { + for (OrderPayRecord orderPayRecord : orderPayRecordList) { + List paymentInfos2 = orderPayRecordService.parseDeductionRecord(orderPayRecord.getDeductionRecord()); + paymentInfoSet.addAll(paymentInfos2); + System.out.println("2222:" + JSON.toJSONString(paymentInfos2)); + } + } + + System.out.println("set:" + JSON.toJSONString(paymentInfoSet)); + } catch (BaseAdaPayException e) { throw new RuntimeException(e); } diff --git a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java index 5b8c3f4d4..e05850ce0 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java +++ b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java @@ -39,8 +39,12 @@ public class CacheConstants { // 保存order_monitor_data public static final String INSERT_ORDER_MONITOR_DATA = "insert_order_monitor_data:"; + // 需要推送的站点id public static final String PUSH_STATION_CONNECTOR = "push_station_connector"; + // 订单的微信支付参数 + public static final String ORDER_WECHAT_PAY_PARAMETERS = "order_wechat_pay_parameters:"; + // 支付确认列表 public static final String PAYMENT_CONFIRM_LIST = "payment_confirm_list:"; diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPartyApiEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPartyApiEnum.java new file mode 100644 index 000000000..1a57ff360 --- /dev/null +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPartyApiEnum.java @@ -0,0 +1,35 @@ +package com.jsowell.common.enums.thirdparty; + +public enum ThirdPartyApiEnum { + NOTIFICATION_STATION_STATUS("notification_stationStatus", "设备状态变化推送"), + NOTIFICATION_CHARGE_ORDER_INFO("notification_charge_order_info", "推送充电订单信息"), + NOTIFICATION_START_CHARGE_RESULT("notification_start_charge_result", "推送启动充电结果"), + NOTIFICATION_EQUIP_CHARGE_STATUS("notification_equip_charge_status", "推送充电状态"), + NOTIFICATION_STOP_CHARGE_RESULT("notification_stop_charge_result", "推送停止充电结果"), + CHECK_CHARGE_ORDERS("check_charge_orders", "推送订单对账结果信息"), + ; + private String value; + + private String label; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + ThirdPartyApiEnum(String value, String label) { + this.value = value; + this.label = label; + } +} diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/ykc/OrderPayRecordEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/ykc/OrderPayRecordEnum.java index b15b61afc..654a7298f 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/ykc/OrderPayRecordEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/ykc/OrderPayRecordEnum.java @@ -6,8 +6,8 @@ package com.jsowell.common.enums.ykc; * 后端数据库 */ public enum OrderPayRecordEnum { - PRINCIPAL_BALANCE_PAYMENT("1", "本金余额支付"), - GIFT_BALANCE_PAYMENT("2", "赠送余额支付"), + PRINCIPAL_BALANCE_PAYMENT("1", "本金支付"), + GIFT_BALANCE_PAYMENT("2", "赠金支付"), WHITELIST_PAYMENT("3", "白名单支付"), WECHATPAY_PAYMENT("4", "微信支付"), ALIPAY_PAYMENT("5", "支付宝支付"), diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayService.java b/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayService.java index a9021bf49..9a39ec49e 100644 --- a/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayService.java +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayService.java @@ -40,6 +40,7 @@ import com.jsowell.pile.dto.PayOrderDTO; import com.jsowell.pile.service.*; import com.jsowell.pile.vo.base.MerchantInfoVO; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cglib.beans.BeanMap; @@ -88,10 +89,10 @@ public class AdapayService { // log.info("===============使用汇付支付-获取支付参数"); // 相同参数重复请求,返回同一个支付对象 String redisKey = CacheConstants.ADAPAY_ORDER_PARAM + dto.getOrderCode(); - Map cacheObject = redisCache.getCacheObject(redisKey); - if (cacheObject != null) { + Map resultMap = redisCache.getCacheObject(redisKey); + if (resultMap != null) { // 表示已经获取到支付参数了,后续再有支付请求就拒绝 - return cacheObject; + return resultMap; } // 获取支付配置 @@ -115,11 +116,8 @@ public class AdapayService { String delayMode = pileMerchantInfoService.getDelayModeByWechatAppId(dto.getWechatAppId()); String payMode = MerchantDelayModeEnum.getAdapayPayMode(delayMode); CreateAdaPaymentParam createAdaPaymentParam = new CreateAdaPaymentParam(); - // 请求订单号 + // 请求订单号, 防止请求订单号重复,结尾拼接时间 String orderNo = dto.getOrderCode() + "_" + DateUtils.dateTimeNow(); - // if (ScenarioEnum.OCCUPY.getValue().equals(type)) { - // orderNo = orderNo + "_" + DateUtils.dateTimeNow(); - // } createAdaPaymentParam.setOrder_no(orderNo); createAdaPaymentParam.setPay_amt(amount); createAdaPaymentParam.setApp_id(config.getAdapayAppId()); @@ -151,18 +149,21 @@ public class AdapayService { } JSONObject expend = JSONObject.parseObject(response.get("expend").toString()); JSONObject pay_info = expend.getJSONObject("pay_info"); - Map resultMap = JSONObject.parseObject(pay_info.toJSONString(), new TypeReference>() { - }); - if (resultMap != null) { - // 请求参数放入缓存,15分钟以内返回同一个支付参数 - redisCache.setCacheObject(redisKey, resultMap, 15, TimeUnit.MINUTES); - } - return resultMap; + resultMap = JSONObject.parseObject(pay_info.toJSONString(), new TypeReference>() {}); } } catch (BaseAdaPayException e) { - log.error("汇付-获取支付对象发生异常", e); + log.error("汇付-获取支付对象发生异常, orderCode:{}", dto.getOrderCode(), e); } - return null; + + // 放缓存 + if (resultMap != null) { + // 请求参数放入缓存,15分钟以内返回同一个支付参数 + redisCache.setCacheObject(redisKey, resultMap, 15, TimeUnit.MINUTES); + + // 请求订单号放redis + redisCache.setCacheObject(CacheConstants.ORDER_WECHAT_PAY_PARAMETERS + dto.getOrderCode(), orderNo, 30, TimeUnit.MINUTES); + } + return resultMap; } /** @@ -1192,10 +1193,29 @@ public class AdapayService { return resultList; } + /** + * 根据请求号,查询支付信息列表 + */ + public List queryPaymentInfosByOrderNo(String orderNo, String wechatAppId) throws BaseAdaPayException { + List resultList = Lists.newArrayList(); + List adaPayments = queryPaymentsByOrderNo(orderNo, wechatAppId); + if (CollectionUtils.isEmpty(adaPayments)) { + return resultList; + } + for (AdaPayment adaPayment : adaPayments) { + PaymentInfo paymentInfo = PaymentInfo.builder() + .paymentId(adaPayment.getId()) + .amount(adaPayment.getPay_amt()) + .build(); + resultList.add(paymentInfo); + } + return resultList; + } + /** * 查询支付列表 */ - public List queryPaymentByOrderNo(String orderNo, String wechatAppId) throws BaseAdaPayException { + public List queryPaymentsByOrderNo(String orderNo, String wechatAppId) throws BaseAdaPayException { List resultList = Lists.newArrayList(); AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId); if (config == null) { @@ -1215,13 +1235,13 @@ public class AdapayService { queryListParam.put("page_size", pageSize); queryListParam.put("order_no", orderNo); - System.out.println("查询支付对象列表请求参数:" + JSON.toJSONString(queryListParam)); + // System.out.println("查询支付对象列表请求参数:" + JSON.toJSONString(queryListParam)); Map paymentListResult = Payment.queryList(queryListParam, wechatAppId); if (paymentListResult == null) { break; } String jsonString = JSON.toJSONString(paymentListResult); - System.out.println("查询支付对象列表result:" + jsonString); + // System.out.println("查询支付对象列表result:" + jsonString); JSONObject jsonObject = JSON.parseObject(jsonString); List list = jsonObject.getList("payments", AdaPayment.class, JSONReader.Feature.FieldBased); diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/vo/PaymentInfo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/vo/PaymentInfo.java index dfc869bc1..6f8672be1 100644 --- a/jsowell-pile/src/main/java/com/jsowell/adapay/vo/PaymentInfo.java +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/vo/PaymentInfo.java @@ -1,14 +1,34 @@ package com.jsowell.adapay.vo; -import lombok.Getter; -import lombok.Setter; +import lombok.*; +import java.util.Objects; + +/** + * 付款信息对象 + */ @Getter @Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder public class PaymentInfo { // 支付id private String paymentId; // 金额 private String amount; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PaymentInfo that = (PaymentInfo) o; + return paymentId.equals(that.paymentId); + } + + @Override + public int hashCode() { + return Objects.hash(paymentId); + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderPayRecordService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderPayRecordService.java index 42b8b6dd6..ffdf0389f 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderPayRecordService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderPayRecordService.java @@ -31,6 +31,8 @@ public interface OrderPayRecordService{ List getOrderPayRecordList(String orderCode); + List queryPaymentInfosByOrderCode(String orderCode); + List selectOrderPayInfoList(String orderCode); List parseDeductionRecord(String deductionRecord); diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java index 689f600f9..41ca31a75 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java @@ -1,7 +1,10 @@ package com.jsowell.pile.service; +import com.jsowell.pile.thirdparty.ConnectorInfo; +import com.jsowell.pile.thirdparty.EquipmentInfo; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.pile.domain.PileBasicInfo; +import com.jsowell.pile.domain.PileStationInfo; import com.jsowell.pile.dto.IndexQueryDTO; import com.jsowell.pile.dto.QueryPileDTO; import com.jsowell.pile.dto.ReplaceMerchantStationDTO; @@ -190,4 +193,8 @@ public interface PileBasicInfoService { * 获取最新建一条桩的信息 */ PileBasicInfo getMaxNumPileInfo(); + + List getPileList(PileStationInfo pileStationInfo); + + List getConnectorList(PileBasicInfo pileBasicInfo); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartyStationRelationService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartyStationRelationService.java index d4afd8826..c339538d7 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartyStationRelationService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartyStationRelationService.java @@ -12,6 +12,8 @@ import java.util.List; * @date 2023-06-06 */ public interface ThirdPartyStationRelationService { + // 保存到数据库 + int insertInfo2DataBase(String thirdPartyType, String stationId); /** * 查询站点、第三方推送平台配置对应 * diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberWalletInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberWalletInfoServiceImpl.java index 7cad90f05..fd147ac53 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberWalletInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberWalletInfoServiceImpl.java @@ -97,7 +97,7 @@ public class MemberWalletInfoServiceImpl implements MemberWalletInfoService { MemberWalletVO memberWalletVO = memberWalletInfoMapper.selectMemberWalletInfo(walletCode); // 累计消费金额 = 累计充值 + 累计赠送 - 本金余额 - 赠送金余额 BigDecimal accumulatedConsumptionAmount = memberWalletVO.getAccumulatedRechargeAmount() - .add(memberWalletVO.getAccumulatedRechargeAmount()) + .add(memberWalletVO.getAccumulatedRechargeGift()) .subtract(memberWalletVO.getPrincipalBalance()) .subtract(memberWalletVO.getGiftBalance()); memberWalletVO.setAccumulatedConsumptionAmount(accumulatedConsumptionAmount); diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java index e4cf1aba1..a1e45a1fd 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject; import com.fasterxml.jackson.core.JsonProcessingException; 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.jsowell.adapay.dto.QueryConfirmReverseDTO; import com.jsowell.adapay.dto.QueryPaymentConfirmDTO; @@ -1907,7 +1908,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { .orderBasicInfo(orderBasicInfo) .orderDetail(orderDetail) .build(); - pileTransactionService.doCreateOrder(createOrderTransactionDTO); + pileTransactionService.doCreateOrder(createOrderTransactionDTO); // 保存异常订单到订单主表 } /** @@ -2029,7 +2030,8 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { public List getUnpaidOrderListOver15Min() { Date now = DateUtils.addMinute(new Date(), -15); String nowString = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, now); - return orderBasicInfoMapper.getUnpaidOrderListOver15Min(nowString); + List list = orderBasicInfoMapper.getUnpaidOrderListOver15Min(nowString); + return CollectionUtils.isNotEmpty(list) ? list : Lists.newArrayList(); } /** @@ -2047,18 +2049,19 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { public int close15MinutesOfUnpaidOrders() { List orderList = getUnpaidOrderListOver15Min(); if (CollectionUtils.isNotEmpty(orderList)) { - List orderIdList = orderList.stream() - .map(x -> String.valueOf(x.getId())) - .collect(Collectors.toList()); - // 修改订单状态 - updateOrderStatusById(orderIdList, OrderStatusEnum.ORDER_CLOSE_TIMEOUT.getValue()); - for (OrderBasicInfo orderBasicInfo : orderList) { this.cleanCacheByOrderCode(orderBasicInfo.getOrderCode(), orderBasicInfo.getTransactionCode()); // 通过订单号查询汇付有没有支付单 checkUnpaidOrder(orderBasicInfo); } + + // 订单id集合 + List orderIdList = orderList.stream() + .map(x -> String.valueOf(x.getId())) + .collect(Collectors.toList()); + // 根据orderIdList修改订单状态 + updateOrderStatusById(orderIdList, OrderStatusEnum.ORDER_CLOSE_TIMEOUT.getValue()); } return orderList.size(); } @@ -2075,59 +2078,40 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { String merchantId = orderBasicInfo.getMerchantId(); String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(merchantId); String delayMode = pileMerchantInfoService.getDelayModeByWechatAppId(wechatAppId); - // List adaPayments = null; - // try { - // adaPayments = adapayService.queryPaymentByOrderNo(orderCode, wechatAppId); - // } catch (BaseAdaPayException e) { - // throw new RuntimeException(e); - // } - - // if (CollectionUtils.isEmpty(adaPayments)) { - // return; - // } + // 订单总金额 BigDecimal orderAmount = orderBasicInfo.getOrderAmount() == null ? BigDecimal.ZERO : orderBasicInfo.getOrderAmount(); if (orderAmount.compareTo(BigDecimal.ZERO) > 0) { return; } // 如果超时关闭的订单,存在支付信息,都退款处理 - List orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderCode); - logger.info("校验未支付订单orderCode:{}, 支付信息:{}", orderCode, JSON.toJSONString(orderPayRecordList)); - if (CollectionUtils.isNotEmpty(orderPayRecordList)) { - for (OrderPayRecord orderPayRecord : orderPayRecordList) { - List paymentInfos = orderPayRecordService.parseDeductionRecord(orderPayRecord.getDeductionRecord()); - for (PaymentInfo paymentInfo : paymentInfos) { - String paymentId = paymentInfo.getPaymentId(); - BigDecimal payAmt = new BigDecimal(paymentInfo.getAmount()); - if (MerchantDelayModeEnum.DELAY.getMode().equals(delayMode)) { - // 延时分账商户,创建交易撤销请求 - adapayService.createPaymentReverseRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode); - } else { - // 实时分账商户,创建交易退款请求 - adapayService.createRefundRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode); - } + Set paymentInfoSet = Sets.newHashSet(); + List paymentInfos1 = orderPayRecordService.queryPaymentInfosByOrderCode(orderCode); + paymentInfoSet.addAll(paymentInfos1); + try { + String redisKey = CacheConstants.ORDER_WECHAT_PAY_PARAMETERS + orderCode; + String orderNo = redisCache.getCacheObject(redisKey); + if (StringUtils.isNotBlank(orderNo)) { + List paymentInfos2 = adapayService.queryPaymentInfosByOrderNo(orderNo, wechatAppId); + paymentInfoSet.addAll(paymentInfos2); + } + } catch (BaseAdaPayException e) { + throw new RuntimeException(e); + } + if (CollectionUtils.isNotEmpty(paymentInfoSet)) { + for (PaymentInfo paymentInfo : paymentInfoSet) { + String paymentId = paymentInfo.getPaymentId(); + BigDecimal payAmt = new BigDecimal(paymentInfo.getAmount()); + if (MerchantDelayModeEnum.DELAY.getMode().equals(delayMode)) { + // 延时分账商户,创建交易撤销请求 + adapayService.createPaymentReverseRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode); + } else { + // 实时分账商户,创建交易退款请求 + adapayService.createRefundRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode); } } } - - // 退款 - // for (AdaPayment adaPayment : adaPayments) { - // String status = adaPayment.getStatus(); - // if (!AdapayStatusEnum.SUCCEEDED.getValue().equals(status)) { - // // 不是交易完成状态,就跳过 - // continue; - // } - // String paymentId = adaPayment.getId(); - // BigDecimal payAmt = new BigDecimal(adaPayment.getPay_amt()); - // if (MerchantDelayModeEnum.DELAY.getMode().equals(delayMode)) { - // // 延时分账商户,创建交易撤销请求 - // adapayService.createPaymentReverseRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode); - // } else { - // // 实时分账商户,创建交易退款请求 - // adapayService.createRefundRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode); - // } - // } } /** @@ -2593,7 +2577,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { .orderBasicInfo(orderBasicInfo) .orderDetail(orderDetail) .build(); - pileTransactionService.doCreateOrder(createOrderTransactionDTO); + pileTransactionService.doCreateOrder(createOrderTransactionDTO); // 联联平台生成订单 // 组装结果集 Map resultMap = Maps.newHashMap(); @@ -3083,7 +3067,10 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { orderInfo.setPayMode(dto.getPayMode()); orderInfo.setPayStatus(OrderPayStatusEnum.paid.getValue()); BigDecimal orderPayAmount = orderInfo.getPayAmount() == null ? BigDecimal.ZERO : orderInfo.getPayAmount(); - orderInfo.setPayAmount(orderPayAmount.add(payAmount)); + // 2024年3月25日12点26分 发现重复记录的情况 + if(orderPayAmount.compareTo(payAmount) != 0) { + orderInfo.setPayAmount(orderPayAmount.add(payAmount)); + } orderInfo.setPayTime(new Date()); if (sendStartCharging) { @@ -3515,7 +3502,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { .pileConnectorCode(dto.getPileSn() + dto.getConnectorCode()) .startMode(dto.getStartMode()) .payStatus(Constants.ZERO) - .payAmount(dto.getChargeAmount()) // 支付完成后填入支付金额 + // .payAmount(dto.getChargeAmount()) // 支付完成后填入支付金额 .payMode(dto.getPayMode()) .plateNumber(plateNumber) .orderAmount(BigDecimal.ZERO) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderPayRecordServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderPayRecordServiceImpl.java index b42f5ff48..9208f243e 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderPayRecordServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderPayRecordServiceImpl.java @@ -78,6 +78,19 @@ public class OrderPayRecordServiceImpl implements OrderPayRecordService { return orderPayRecordMapper.getOrderPayRecordList(orderCode); } + @Override + public List queryPaymentInfosByOrderCode(String orderCode) { + List resultList = Lists.newArrayList(); + List orderPayRecordList = getOrderPayRecordList(orderCode); + if (CollectionUtils.isNotEmpty(orderPayRecordList)) { + for (OrderPayRecord orderPayRecord : orderPayRecordList) { + List paymentInfos = this.parseDeductionRecord(orderPayRecord.getDeductionRecord()); + resultList.addAll(paymentInfos); + } + } + return resultList; + } + /** * 查询订单支付信息 * 加缓存 @@ -119,33 +132,18 @@ public class OrderPayRecordServiceImpl implements OrderPayRecordService { || StringUtils.equals(payMode, OrderPayRecordEnum.GIFT_BALANCE_PAYMENT.getValue())) { // 使用余额支付 payInfo.setPayMode(OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue()); - payInfo.setPayModeDesc(OrderPayModeEnum.PAYMENT_OF_BALANCE.getLabel()); + String payModeDesc = null; + if (StringUtils.isNotBlank(OrderPayRecordEnum.getPayModeDescription(payMode))) { + payModeDesc = OrderPayRecordEnum.getPayModeDescription(payMode); + } else { + payModeDesc = OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue(); + } + payInfo.setPayModeDesc(payModeDesc); } else if (StringUtils.equals(payMode, OrderPayRecordEnum.WECHATPAY_PAYMENT.getValue())) { // 使用微信支付 payInfo.setPayMode(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue()); payInfo.setPayModeDesc(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getLabel()); - // 判断是微信支付还是汇付支付 - // MemberTransactionRecord record = memberTransactionRecordService.selectByOrderCode(orderCode, ActionTypeEnum.FORWARD.getValue()); - // if (record != null) { - // String paymentInstitutions = record.getPaymentInstitutions(); - // if (StringUtils.equals(paymentInstitutions, PaymentInstitutionsEnum.WECHAT_PAY.getValue())) { - // // 查微信支付回调记录 - // WxpayCallbackRecord wxpayCallbackRecord = wxpayCallbackRecordService.selectByOrderCode(orderCode); - // if (wxpayCallbackRecord != null) { - // payInfo.setOutTradeNo(wxpayCallbackRecord.getOutTradeNo()); - // payInfo.setTransactionId(wxpayCallbackRecord.getTransactionId()); - // } - // } else if (StringUtils.equals(paymentInstitutions, PaymentInstitutionsEnum.ADAPAY.getValue())) { - // // 查询汇付支付回调 - // AdapayCallbackRecord adapayCallbackRecord = adapayCallbackRecordService.selectByOrderCode(orderCode); - // if (adapayCallbackRecord != null) { - // payInfo.setOutTradeNo(adapayCallbackRecord.getPaymentId()); - // payInfo.setTransactionId(adapayCallbackRecord.getOutTransId()); - // } - // } - // } - // 判断是微信支付还是汇付支付 String paymentInstitutions = orderPayRecord.getAcquirer(); if (StringUtils.equals(paymentInstitutions, PaymentInstitutionsEnum.WECHAT_PAY.getValue())) { @@ -173,7 +171,7 @@ public class OrderPayRecordServiceImpl implements OrderPayRecordService { payRecordList.add(payInfo); } redisCache.setCacheList(redisKey, payRecordList); - redisCache.expire(redisKey, CacheConstants.cache_expire_time_10d); + redisCache.expire(redisKey, CacheConstants.cache_expire_time_1d); return payRecordList; } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java index 17076973b..f2ad75f73 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java @@ -4,21 +4,22 @@ import com.alibaba.fastjson2.JSON; import com.google.common.collect.Lists; import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; +import com.jsowell.pile.thirdparty.ConnectorInfo; +import com.jsowell.pile.thirdparty.EquipmentInfo; import com.jsowell.common.core.domain.vo.AuthorizedDeptVO; import com.jsowell.common.core.domain.ykc.GroundLockData; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.enums.DelFlagEnum; +import com.jsowell.common.enums.lianlian.LianLianPileStatusEnum; import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; import com.jsowell.common.enums.ykc.PileConnectorStatusEnum; +import com.jsowell.common.enums.ykc.PileStatusEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.*; -import com.jsowell.pile.domain.PileBasicInfo; -import com.jsowell.pile.domain.PileConnectorInfo; -import com.jsowell.pile.domain.PileModelInfo; -import com.jsowell.pile.domain.PileSimInfo; +import com.jsowell.pile.domain.*; import com.jsowell.pile.dto.IndexQueryDTO; import com.jsowell.pile.dto.QueryPileDTO; import com.jsowell.pile.dto.ReplaceMerchantStationDTO; @@ -927,4 +928,97 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService { public PileBasicInfo getMaxNumPileInfo() { return pileBasicInfoMapper.getMaxNumPileInfo(); } + + /** + * 获取桩列表信息 + * + * @param pileStationInfo + * @return + */ + @Override + public List getPileList(PileStationInfo pileStationInfo) { + List resultList = new ArrayList<>(); + // 通过站点id查询桩基本信息 + List list = this.getPileListByStationId(String.valueOf(pileStationInfo.getId())); + // MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfo(String.valueOf(pileStationInfo.getMerchantId())); + // 封装成联联平台对象 + for (PileBasicInfo pileBasicInfo : list) { + EquipmentInfo equipmentInfo = new EquipmentInfo(); + String pileSn = pileBasicInfo.getSn(); + + equipmentInfo.setEquipmentID(pileSn); + equipmentInfo.setManufacturerID(Constants.OPERATORID_LIANLIAN); + equipmentInfo.setConstructionTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileBasicInfo.getCreateTime())); + + PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn); + equipmentInfo.setEquipmentType(Integer.valueOf(modelInfo.getSpeedType())); + + // Map pileStatus = pileConnectorInfoService.getPileStatus(Lists.newArrayList(pileBasicInfo.getSn())); + Map pileStatusMap = pileConnectorInfoService.getPileStatus(Lists.newArrayList(pileSn)); + String pileStatus = pileStatusMap.get(pileSn); + if (StringUtils.equals(PileStatusEnum.ON_LINE.getValue(), pileStatus)) { + // 1-在线 + pileStatus = LianLianPileStatusEnum.NORMAL.getCode(); + } else if (StringUtils.equals(PileStatusEnum.OFF_LINE.getValue(), pileStatus)) { + // 2-离线 + pileStatus = LianLianPileStatusEnum.CLOSE_OFFLINE.getCode(); + } else if (StringUtils.equals(PileStatusEnum.FAULT.getValue(), pileStatus)) { + // 3-故障 + pileStatus = LianLianPileStatusEnum.UNDER_MAINTENANCE.getCode(); + } + equipmentInfo.setEquipmentStatus(Integer.valueOf(pileStatus)); + equipmentInfo.setEquipmentPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)); + equipmentInfo.setNewNationalStandard(1); + equipmentInfo.setVinFlag(1); + + List connectorList = getConnectorList(pileBasicInfo); + equipmentInfo.setConnectorInfos(connectorList); + + resultList.add(equipmentInfo); + } + return resultList; + } + + /** + * 获取枪口列表 + * + * @param pileBasicInfo + * @return + */ + @Override + public List getConnectorList(PileBasicInfo pileBasicInfo) { + List resultList = new ArrayList<>(); + + List list = pileConnectorInfoService.selectPileConnectorInfoList(pileBasicInfo.getSn()); + for (PileConnectorInfo pileConnectorInfo : list) { + ConnectorInfo connectorInfo = new ConnectorInfo(); + + connectorInfo.setConnectorID(pileConnectorInfo.getPileConnectorCode()); + String pileSn = pileConnectorInfo.getPileSn(); + PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn); + int connectorType = StringUtils.equals("1", modelInfo.getSpeedType()) ? 4 : 3; + + connectorInfo.setConnectorType(connectorType); + // 车位号 + if (StringUtils.isNotBlank(pileConnectorInfo.getParkNo())) { + connectorInfo.setParkNo(pileConnectorInfo.getParkNo()); + } + connectorInfo.setVoltageUpperLimits(Integer.valueOf(modelInfo.getRatedVoltage())); + connectorInfo.setVoltageLowerLimits(Integer.valueOf(modelInfo.getRatedVoltage())); + + connectorInfo.setCurrent(Integer.valueOf(modelInfo.getRatedCurrent())); + if (!StringUtils.equals(modelInfo.getConnectorNum(), "1")) { + // 如果不是单枪,则枪口功率需要除以枪口数量 + String ratedPowerStr = modelInfo.getRatedPower(); + BigDecimal ratedPower = new BigDecimal(ratedPowerStr); + connectorInfo.setPower(ratedPower.divide(new BigDecimal(modelInfo.getConnectorNum()), 1, BigDecimal.ROUND_HALF_UP)); + }else { + connectorInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)); + } + + resultList.add(connectorInfo); + } + + return resultList; + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java index ce5e568e2..bdee87381 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java @@ -26,7 +26,6 @@ import com.jsowell.pile.mapper.PileBasicInfoMapper; import com.jsowell.pile.mapper.PileConnectorInfoMapper; import com.jsowell.pile.service.*; import com.jsowell.pile.vo.base.ConnectorInfoVO; -import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileDetailVO; import com.jsowell.pile.vo.web.PileModelInfoVO; @@ -145,8 +144,7 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService { } if (StringUtils.isNotBlank(pileConnectorCode)) { - // 删除充电桩枪口状态缓存 - keys.add(CacheConstants.PILE_CONNECTOR_STATUS_KEY + pileConnectorCode); + keys.add(CacheConstants.PILE_CONNECTOR_STATUS_KEY + pileConnectorCode); // 删除充电桩枪口状态缓存 } // 批量删除 @@ -584,7 +582,7 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService { if (StringUtils.isBlank(pileConnectorCode) || StringUtils.isBlank(status)) { return num; } - String redisKey = CacheConstants.PILE_CONNECTOR_STATUS_KEY + pileConnectorCode; + String redisKey = CacheConstants.PILE_CONNECTOR_STATUS_KEY + pileConnectorCode; // 获取缓存 String redisStatus = redisCache.getCacheObject(redisKey); // log.info("更新枪口状态-枪口编号:{}, redisKey:{}, 缓存状态:{}, 传来的状态:{}, 状态描述:{}", pileConnectorCode, redisKey, // redisStatus, status, PileConnectorDataBaseStatusEnum.getStatusDescription(status)); @@ -706,10 +704,10 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService { if (CollectionUtils.isNotEmpty(connectorList)) { // 批量查询redis中的枪口状态 - List redisKeyList = connectorList.stream() - .map(x -> CacheConstants.PILE_CONNECTOR_STATUS_KEY + x.getPileConnectorCode()) - .collect(Collectors.toList()); - List statusList = redisCache.multiGet(redisKeyList); + // List redisKeyList = connectorList.stream() + // .map(x -> CacheConstants.PILE_CONNECTOR_STATUS_KEY + x.getPileConnectorCode()) + // .collect(Collectors.toList()); + // List statusList = redisCache.multiGet(redisKeyList); for (ConnectorInfoVO connectorVO : connectorList) { String redisKey = CacheConstants.PILE_CONNECTOR_STATUS_KEY + connectorVO.getPileConnectorCode(); diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyStationRelationServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyStationRelationServiceImpl.java index 88088f74d..db143bc03 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyStationRelationServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyStationRelationServiceImpl.java @@ -1,6 +1,9 @@ package com.jsowell.pile.service.impl; +import com.jsowell.common.constant.Constants; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.util.SecurityUtils; +import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.ThirdPartyStationRelation; import com.jsowell.pile.mapper.ThirdPartyStationRelationMapper; import com.jsowell.pile.service.ThirdPartyStationRelationService; @@ -21,6 +24,25 @@ public class ThirdPartyStationRelationServiceImpl implements ThirdPartyStationRe @Autowired private ThirdPartyStationRelationMapper thirdPartyStationRelationMapper; + @Override + public int insertInfo2DataBase(String thirdPartyType, String stationId) { + if (StringUtils.isBlank(thirdPartyType) || StringUtils.isBlank(stationId)) { + return 0; + } + ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); + relation.setStationId(Long.parseLong(stationId)); + relation.setThirdPartyType(thirdPartyType); + if (StringUtils.equals(thirdPartyType, ThirdPlatformTypeEnum.HUA_WEI.getCode())) { + relation.setStartMode(Constants.ONE); + } + ThirdPartyStationRelationVO vo = this.selectRelationInfo(relation); + if (vo != null) { + return 0; + } + // 新增数据库 + return this.insertThirdPartyStationRelation(relation); + } + /** * 查询站点、第三方推送平台配置对应 * diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/domain/ConnectorInfo.java b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ConnectorInfo.java similarity index 97% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/domain/ConnectorInfo.java rename to jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ConnectorInfo.java index f32bd8bae..3ad310b00 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/domain/ConnectorInfo.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ConnectorInfo.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.lianlian.domain; +package com.jsowell.pile.thirdparty; import com.alibaba.fastjson2.annotation.JSONField; import lombok.AllArgsConstructor; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/domain/EquipmentInfo.java b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/EquipmentInfo.java similarity index 97% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/domain/EquipmentInfo.java rename to jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/EquipmentInfo.java index d2ed499ac..d40c0a1d9 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/domain/EquipmentInfo.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/EquipmentInfo.java @@ -1,4 +1,4 @@ -package com.jsowell.thirdparty.lianlian.domain; +package com.jsowell.pile.thirdparty; import com.alibaba.fastjson2.annotation.JSONField; import lombok.AllArgsConstructor; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/domain/StationInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/domain/StationInfo.java index d0395cab0..c31f7c913 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/domain/StationInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/domain/StationInfo.java @@ -2,6 +2,7 @@ package com.jsowell.thirdparty.lianlian.domain; import com.alibaba.fastjson2.annotation.JSONField; +import com.jsowell.pile.thirdparty.EquipmentInfo; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -12,6 +13,7 @@ import java.util.List; /** * 充电站信息 + * 第三方平台使用 */ @Builder @AllArgsConstructor diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java index 055323280..805f471d5 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java @@ -18,8 +18,6 @@ public interface LianLianService { * 根据充电站id,推送充电站信息 * @param dto */ - // String pushStationInfo(PushStationInfoDTO dto); - String pushStationInfoV2(PushStationInfoDTO dto); /** diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java index 1de86e16c..36fc025f7 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java @@ -9,6 +9,8 @@ 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.pile.thirdparty.ConnectorInfo; +import com.jsowell.pile.thirdparty.EquipmentInfo; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.common.enums.lianlian.LianLianPileStatusEnum; import com.jsowell.common.enums.lianlian.PayChannelEnum; @@ -256,11 +258,6 @@ public class LianLianServiceImpl implements LianLianService { // } public String pushStationInfoV2(PushStationInfoDTO dto) { - // String OperatorID = "987654321"; - // String SigSecret = "1234567890abcdef"; // 签名秘钥 - // String DataSecret = "1234567890abcdef"; // 消息密钥 - // String DataSecretIV = "1234567890abcdef"; // 消息密钥初始化向量 - // String token = "c548f9276c1c4ea8b88b1f7b1eb7cf07"; //QueryToken类查询接口获取到的token // 通过id查询站点相关信息 PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(dto.getStationId()); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformLogic.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformLogic.java index f200a09b3..49e5ac916 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformLogic.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/AbsInterfaceWithPlatformLogic.java @@ -39,12 +39,18 @@ import java.util.*; public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean { protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Autowired + protected PileMerchantInfoService pileMerchantInfoService; + @Autowired protected PileStationInfoService pileStationInfoService; @Autowired protected ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; + @Autowired + protected ThirdPartySettingInfoService thirdPartySettingInfoService; + @Autowired protected PileBillingTemplateService pileBillingTemplateService; @@ -54,9 +60,6 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean @Autowired protected PileConnectorInfoService pileConnectorInfoService; - @Autowired - protected ThirdPartyStationRelationService relationService; - @Autowired protected PileModelInfoService pileModelInfoService; @@ -80,34 +83,40 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean // =================================================================================== // /** - * 查询运营商信息 supervise_query_operator_info + * 查询运营商信息 query_operator_info + * supervise_query_operator_info * @param dto 查询运营商信息DTO + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryOperatorInfo(QueryOperatorInfoDTO dto); /** - * 6.2 查询充电站信息 query_stations_info + * 查询充电站信息 query_stations_info * 此接口用于查询对接平台的充电站的信息 * @param dto 查询站点信息dto + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryStationsInfo(QueryStationInfoDTO dto); /** - * 6.5 设备接口状态查询 query_station_status + * 设备接口状态查询 query_station_status * * @param dto 查询站点信息dto + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryStationStatus(QueryStationInfoDTO dto); /** - * 查询统计信息 + * 查询统计信息 query_station_stats * * @param dto 查询站点信息dto + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryStationStats(QueryStationInfoDTO dto); /** * 查询充电电量信息 query_order_info + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryOrderInfo(String orderCode); @@ -115,6 +124,7 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean * 请求设备认证 query_equip_auth * 业务信息交换 * @param dto 联联平台请求设备认证 + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryEquipAuth(QueryEquipmentDTO dto); @@ -122,6 +132,7 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean * 请求启动充电 query_start_charge * * @param dto 请求启动充电DTO + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryStartCharge(QueryStartChargeDTO dto); @@ -129,6 +140,7 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean * 查询充电状态 query_equip_charge_status * * @param dto 查询充电状态DTO + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryEquipChargeStatus(QueryEquipChargeStatusDTO dto); @@ -136,21 +148,25 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean * 请求停止充电 query_stop_charge * * @param dto 请求启动充电DTO + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryStopCharge(QueryStartChargeDTO dto); /** * 充电站内充电桩空闲状态查询 query_free_pile_number + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryFreePileNumber(NXJTQueryStationInfoDTO dto); /** * 某车牌号消费记录查询 query_orders_info_by_Plate_number + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryOrdersInfoByPlateNumber(NXJTQueryStationInfoDTO dto); /** * 某段时间内消费记录查询 query_orders_info + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryOrdersInfo(NXJTQueryStationInfoDTO dto); @@ -158,6 +174,7 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean * 查询业务策略信息结果 * 请求计费策略 request_equip_business_policy * @param dto 请求启动充电DTO + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map queryEquipBusinessPolicy(QueryStartChargeDTO dto); @@ -171,12 +188,14 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean /** * VIN码充电 insert_start_charge * 华为平台 + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map insertStartCharge(QueryStationInfoDTO dto); /** * 下发计费策略响应 notification_deliver_equip_business_policy_result * 华为平台 + * @exception UnsupportedOperationException 未实现异常 */ public abstract Map notificationDeliverEquipBusinessPolicyResult(QueryStationInfoDTO dto); @@ -189,6 +208,7 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean * 充电站信息变化推送 notification_stationInfo * 新站需要推送。当站点信息发生变化时,推送新的信息通知到市级平台 * @param stationId 充电站id + * @exception UnsupportedOperationException 未实现异常 */ public abstract String notificationStationInfo(String stationId); @@ -197,6 +217,7 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean * 推送充电设备接口状态信息 supervise_notification_station_status * @param pileConnectorCode 充电枪口编号 * @param status 枪口状态 + * @exception UnsupportedOperationException 未实现异常 */ public abstract String notificationStationStatus(String pileConnectorCode, String status); @@ -204,16 +225,19 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean * 设备充电中状态变化推送 notification_connector_charge_status * @param pileConnectorCode 充电枪口编号 * @param status 枪口状态 + * @exception UnsupportedOperationException 未实现异常 */ - public abstract String notificationConnectorChargeStatus(String pileConnectorCode, String status); + public abstract String notificationConnectorChargeStatus(String orderCode); /** * 订单信息推送 notification_orderInfo + * @exception UnsupportedOperationException 未实现异常 */ public abstract String notificationOrderInfo(String orderCode); /** * 站点费率变化推送 notification_stationFee + * @exception UnsupportedOperationException 未实现异常 */ public abstract String notificationStationFee(String stationId); @@ -224,17 +248,20 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean * TODO 华为平台文档中的接口,检查一下是否和订单信息推送notification_orderInfo一致 * TODO 内蒙古平台文档中的接口,检查一下是否和订单信息推送notification_orderInfo一致 * @param orderCode 订单编号 + * @exception UnsupportedOperationException 未实现异常 */ public abstract String notificationChargeOrderInfo(String orderCode); /** * 告警信息推送 notification_alarmInfo + * @exception UnsupportedOperationException 未实现异常 */ public abstract String notificationAlarmInfo(); /** * 推送启动充电结果 notification_start_charge_result * @param orderCode 订单编号 + * @exception UnsupportedOperationException 未实现异常 */ public abstract String notificationStartChargeResult(String orderCode); @@ -242,28 +269,33 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean * 推送充电状态 notification_equip_charge_status * 推送充电状态信息 supervise_notification_equip_charge_status * @param orderCode 订单编号 + * @exception UnsupportedOperationException 未实现异常 */ - public abstract String notificationEquipChargeStatus(String orderCode); + public abstract String notificationEquipChargeStatus(String orderCode) throws UnsupportedOperationException; /** * 推送停止充电结果 notification_stop_charge_result * @param orderCode 订单编号 + * @exception UnsupportedOperationException 未实现异常 */ public abstract String notificationStopChargeResult(String orderCode); /** * 华为平台 * 平台充电设备编码同步 notification_operation_system_info + * @exception UnsupportedOperationException 未实现异常 */ public abstract String notificationOperationSystemInfo(String orderCode); /** * 推送充换电站用能统计信息 supervise_notification_operation_stats_info + * @exception UnsupportedOperationException 未实现异常 */ public abstract String notificationOperationStatsInfo(String stationId); /** * 推送充电站历史充电订单信息 supervise_notification_charge_order_info_history + * @exception UnsupportedOperationException 未实现异常 */ public abstract String notificationChargeOrderInfoHistory(String stationId); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/InterfaceWithPlatformLogicFactory.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/InterfaceWithPlatformLogicFactory.java index 66e0e1b46..8eb834bea 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/InterfaceWithPlatformLogicFactory.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/InterfaceWithPlatformLogicFactory.java @@ -16,22 +16,22 @@ public class InterfaceWithPlatformLogicFactory { /** * 注册 - * @param str - * @param handler + * @param code 平台code {@link com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum} + * @param handler 处理逻辑类 */ - public static void register(String str, AbsInterfaceWithPlatformLogic handler) { - if (StringUtils.isBlank(str) || Objects.isNull(handler)) { + public static void register(String code, AbsInterfaceWithPlatformLogic handler) { + if (StringUtils.isBlank(code) || Objects.isNull(handler)) { return; } - platformMap.put(str, handler); + platformMap.put(code, handler); } /** * 获取 - * @param name - * @return + * @param code 平台code {@link com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum} + * @return 处理逻辑类 */ - public static AbsInterfaceWithPlatformLogic getPlatformLogic(String name) { - return platformMap.get(name); + public static AbsInterfaceWithPlatformLogic getPlatformLogic(String code) { + return platformMap.get(code); } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformLogic.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformLogic.java index 4d03f65d5..6dc5f68f4 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformLogic.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/hainan/service/HaiNanPlatformLogic.java @@ -80,7 +80,8 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map queryOperatorInfo(QueryOperatorInfoDTO dto) { - return null; + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -89,7 +90,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic { public Map queryStationsInfo(QueryStationInfoDTO dto) { // 查询出要查询的充电站id并set进 dto 的stationIds if (StringUtils.isNotBlank(dto.getThirdPlatformType())) { - List xdtList = relationService.selectThirdPartyStationRelationList(dto.getThirdPlatformType()); + List xdtList = thirdPartyStationRelationService.selectThirdPartyStationRelationList(dto.getThirdPlatformType()); if (CollectionUtils.isNotEmpty(xdtList)) { List stationList = xdtList.stream() .map(x -> String.valueOf(x.getStationId())) @@ -284,8 +285,9 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic { * @param status 枪口状态 */ @Override - public String notificationConnectorChargeStatus(String pileConnectorCode, String status) { - return null; + public String notificationConnectorChargeStatus(String orderCode) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -295,7 +297,8 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public String notificationOrderInfo(String orderCode) { - return null; + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -305,7 +308,8 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public String notificationStationFee(String stationId) { - return null; + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -361,7 +365,8 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public String notificationAlarmInfo() { - return null; + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -456,7 +461,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic { } /** - * 查询统计信息 + * 查询统计信息 query_station_stats * * @param dto */ @@ -561,7 +566,8 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map queryOrderInfo(String orderCode) { - return null; + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -572,7 +578,8 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public String notificationStationInfo(String stationId) { - return null; + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); } /** diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformLogic.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformLogic.java new file mode 100644 index 000000000..8f9efdf81 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/lianlian/service/LianLianPlatformLogic.java @@ -0,0 +1,988 @@ +package com.jsowell.thirdparty.platform.lianlian.service; + +import cn.hutool.core.util.PageUtil; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +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.ykc.RealTimeMonitorData; +import com.jsowell.common.enums.lianlian.PayChannelEnum; +import com.jsowell.common.enums.lianlian.StationPaymentEnum; +import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +import com.jsowell.common.enums.ykc.OrderPayModeEnum; +import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; +import com.jsowell.common.util.DateUtils; +import com.jsowell.common.util.PageUtils; +import com.jsowell.common.util.StringUtils; +import com.jsowell.pile.domain.*; +import com.jsowell.pile.dto.*; +import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO; +import com.jsowell.pile.thirdparty.EquipmentInfo; +import com.jsowell.pile.vo.base.*; +import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO; +import com.jsowell.pile.vo.lianlian.PushStationFeeVO; +import com.jsowell.pile.vo.uniapp.BillingPriceVO; +import com.jsowell.pile.vo.web.PileStationVO; +import com.jsowell.thirdparty.lianlian.domain.*; +import com.jsowell.thirdparty.lianlian.util.Cryptos; +import com.jsowell.thirdparty.lianlian.util.Encodes; +import com.jsowell.thirdparty.lianlian.util.GBSignUtils; +import com.jsowell.thirdparty.lianlian.util.HttpRequestUtil; +import com.jsowell.thirdparty.platform.AbsInterfaceWithPlatformLogic; +import com.jsowell.thirdparty.platform.InterfaceWithPlatformLogicFactory; +import org.apache.commons.collections4.CollectionUtils; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class LianLianPlatformLogic extends AbsInterfaceWithPlatformLogic { + // 平台类型 + private final String platformType = ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getCode(); + + @Override + public void afterPropertiesSet() throws Exception { + InterfaceWithPlatformLogicFactory.register(platformType, this); + } + + /** + * 查询运营商信息 query_operator_info + * supervise_query_operator_info + * + * @param dto 查询运营商信息DTO + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryOperatorInfo(QueryOperatorInfoDTO dto) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 查询充电站信息 query_stations_info + * 此接口用于查询对接平台的充电站的信息 + * + * @param dto 查询站点信息dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryStationsInfo(QueryStationInfoDTO dto) { + List resultList = new ArrayList<>(); + int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo(); + int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize(); + + PageUtils.startPage(pageNo, pageSize); + List stationInfos = pileStationInfoService.getStationInfosByThirdParty(dto); + if (CollectionUtils.isEmpty(stationInfos)) { + // 未查到数据 + return null; + } + ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); + if (configInfo == null) { + return null; + } + PageInfo pageInfo = new PageInfo<>(stationInfos); + for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) { + StationInfo stationInfo = new StationInfo(); + stationInfo.setStationID(String.valueOf(pileStationInfo.getId())); + // MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfo(String.valueOf(pileStationInfo.getMerchantId())); + stationInfo.setOperatorID(Constants.OPERATORID_LIANLIAN); // 组织机构代码 + stationInfo.setEquipmentOwnerID(String.valueOf(pileStationInfo.getMerchantId())); + stationInfo.setStationName(pileStationInfo.getStationName()); + stationInfo.setIsAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())); + stationInfo.setIsPublicParkingLot(Integer.valueOf(pileStationInfo.getPublicParking())); + stationInfo.setCountryCode(pileStationInfo.getCountryCode()); + stationInfo.setAreaCode(pileStationInfo.getAreaCode()); + stationInfo.setAddress(pileStationInfo.getAddress()); + stationInfo.setServiceTel(pileStationInfo.getStationTel()); + stationInfo.setStationType(Integer.valueOf(pileStationInfo.getStationType())); + stationInfo.setParkNums(Integer.valueOf(pileStationInfo.getParkNums())); + stationInfo.setStationLng(new BigDecimal(pileStationInfo.getStationLng())); + stationInfo.setStationLat(new BigDecimal(pileStationInfo.getStationLat())); + stationInfo.setConstruction(Integer.valueOf(pileStationInfo.getConstruction())); + stationInfo.setOpenAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay())); + // stationInfo.setMinElectricityPrice(pileStationInfo); // 最低充电电费率 + // stationInfo.setElectricityFee(); // 电费 xx元/度 + // stationInfo.setServiceFee(); // 服务费 xx元/度 + stationInfo.setParkFree(Integer.valueOf(pileStationInfo.getParkFree())); + stationInfo.setPayment(pileStationInfo.getPayment()); + stationInfo.setSupportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())); + // stationInfo.setParkFeeType(pileStationInfo); // 停车收费类型 + stationInfo.setToiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())); + stationInfo.setStoreFlag(Integer.valueOf(pileStationInfo.getStoreFlag())); + stationInfo.setRestaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag())); + stationInfo.setLoungeFlag(Integer.valueOf(pileStationInfo.getLoungeFlag())); + stationInfo.setCanopyFlag(Integer.valueOf(pileStationInfo.getCanopyFlag())); + stationInfo.setPrinterFlag(Integer.valueOf(pileStationInfo.getPrinterFlag())); + stationInfo.setBarrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag())); + stationInfo.setParkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag())); + + List pileList = pileBasicInfoService.getPileList(pileStationInfo); + if (CollectionUtils.isNotEmpty(pileList)) { + stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表 + } + + resultList.add(stationInfo); + } + Map map = new LinkedHashMap<>(); + map.put("PageNo", pageInfo.getPageNum()); + map.put("PageCount", pageInfo.getPages()); + map.put("ItemSize", resultList.size()); + map.put("StationInfos", resultList); + + // 加密 + Map resultMap = Maps.newLinkedHashMap(); + // 加密数据 + byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(map).getBytes(), + configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); + String encryptData = Encodes.encodeBase64(encryptText); + + resultMap.put("Data", encryptData); + // 生成sig + String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); + resultMap.put("Sig", resultSign); + + return resultMap; + } + + /** + * 设备接口状态查询 query_station_status + * + * @param dto 查询站点信息dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryStationStatus(QueryStationInfoDTO dto) { + List stationIds = dto.getStationIds(); + List StationStatusInfos = new ArrayList<>(); + List ConnectorStatusInfos = new ArrayList<>(); + ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); + if (configInfo == null) { + return null; + } + ConnectorStatusInfo connectorStatusInfo; + for (String stationId : stationIds) { + StationStatusInfo stationStatusInfo= new StationStatusInfo(); + stationStatusInfo.setStationId(stationId); + // 根据站点id查询 + List list = pileConnectorInfoService.getConnectorListForLianLian(Long.parseLong(stationId)); + for (ConnectorInfoVO connectorInfoVO : list) { + + String connectorStatus = connectorInfoVO.getConnectorStatus(); + if (StringUtils.equals(connectorStatus, PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue())) { + // 充电中 + ConnectorChargeStatusInfo info = new ConnectorChargeStatusInfo(); + OrderBasicInfo orderBasicInfo = orderBasicInfoService.queryChargingByPileConnectorCode(connectorInfoVO.getPileConnectorCode()); + if (orderBasicInfo == null) { + continue; + } + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode()); + if(CollectionUtils.isNotEmpty(chargingRealTimeData)) { + RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0); + + info.setStartChargeSeq(orderBasicInfo.getOrderCode()); + info.setConnectorID(orderBasicInfo.getPileConnectorCode()); + info.setConnectorStatus(Integer.valueOf(connectorInfoVO.getConnectorStatus())); + info.setCurrentA(new BigDecimal(realTimeMonitorData.getOutputCurrent())); + info.setVoltageA(new BigDecimal(realTimeMonitorData.getOutputVoltage())); + info.setSoc(new BigDecimal(realTimeMonitorData.getSOC())); + info.setStartTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())); + info.setEndTime(DateUtils.getDateTime()); // 本次采样时间 + info.setTotalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())); // 累计充电量 + // info.setElecMoney(); // 累计电费 + // info.setSeviceMoney(); // 累计服务费 + info.setTotalMoney(new BigDecimal(realTimeMonitorData.getChargingAmount())); + + ConnectorStatusInfos.add(info); + } + } else { + // 其他 + connectorStatusInfo = new ConnectorStatusInfo(); + connectorStatusInfo.setConnectorID(connectorInfoVO.getPileConnectorCode()); + connectorStatusInfo.setStatus(Integer.parseInt(connectorInfoVO.getConnectorStatus())); + + ConnectorStatusInfos.add(connectorStatusInfo); + } + } + stationStatusInfo.setConnectorStatusInfos(ConnectorStatusInfos); + StationStatusInfos.add(stationStatusInfo); + } + // 将 StationStatusInfos 分页 + int pageNum = 1; + int pageSize = 10; + List collect = StationStatusInfos.stream() + .skip((pageNum - 1) * pageSize) + .limit(pageSize) + .collect(Collectors.toList()); + + int total = StationStatusInfos.size(); + int pages = PageUtil.totalPage(total, pageSize); + + Map map = new LinkedHashMap<>(); + map.put("Total", total); + map.put("StationStatusInfos", collect); + + // 加密 + Map resultMap = Maps.newLinkedHashMap(); + // 加密数据 + byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(map).getBytes(), + configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); + String encryptData = Encodes.encodeBase64(encryptText); + + resultMap.put("Data", encryptData); + // 生成sig + String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); + resultMap.put("Sig", resultSign); + + return resultMap; + } + + /** + * 查询统计信息 query_station_stats + * + * @param dto 查询站点信息dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryStationStats(QueryStationInfoDTO dto) { + ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); + if (configInfo == null) { + return null; + } + // 根据站点id 查出这段时间的充电量 + List list = orderBasicInfoService.getAccumulativeInfoForLianLian(dto); + if (CollectionUtils.isEmpty(list)) { + return null; + } + + // 根据充电桩编号分组 key=充电桩编号 + Map> pileMap = list.stream() + .collect(Collectors.groupingBy(AccumulativeInfoVO::getPileSn)); + + // 存放所有充电桩设备 + List equipmentStatsInfoList = Lists.newArrayList(); + // 站点用电量 + BigDecimal stationElectricity = BigDecimal.ZERO; + // 用于记录枪口用电量 在循环每个枪口的时候初始化 + BigDecimal pileElec; + for (String pileSn : pileMap.keySet()) { + // 该充电桩下 所有枪口的用电数据 + List accumulativeInfoVOS = pileMap.get(pileSn); + if (CollectionUtils.isEmpty(accumulativeInfoVOS)) { + continue; + } + + // 存放充电桩用电量 + pileElec = BigDecimal.ZERO; + + // key=枪口编号 value 该枪口的用电数据 + Map> collect = accumulativeInfoVOS.stream() + .collect(Collectors.groupingBy(AccumulativeInfoVO::getPileConnectorCode)); + + List connectorStatsInfos = Lists.newArrayList(); + for (Map.Entry> entry : collect.entrySet()) { + String pileConnectorCode = entry.getKey(); + List value = entry.getValue(); + // 枪口用电量求和 + BigDecimal connectorElec = value.stream() + .map(AccumulativeInfoVO::getConnectorElectricity) + .map(BigDecimal::new) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + connectorStatsInfos.add( + ConnectorStatsInfo.builder() + .connectorID(pileConnectorCode) + .connectorElectricity(connectorElec) + .build() + ); + // 充电桩电量为枪口用电量累计 + pileElec = pileElec.add(connectorElec); + } + + EquipmentStatsInfo build = EquipmentStatsInfo.builder() + .equipmentID(pileSn) + .equipmentElectricity(pileElec) + .connectorStatsInfos(connectorStatsInfos) + .build(); + equipmentStatsInfoList.add(build); + + // 所有充电桩用电量之和 + stationElectricity = stationElectricity.add(pileElec); + } + + StationStatsInfo stationStatsInfo = StationStatsInfo.builder() + .stationID(dto.getStationID()) + .startTime(dto.getStartTime()) + .endTime(dto.getEndTime()) + .stationElectricity(stationElectricity) + .equipmentStatsInfos(equipmentStatsInfoList) // 设备列表 + .build(); + + Map map = new LinkedHashMap<>(); + map.put("StationStats", stationStatsInfo); + + // 加密 + Map resultMap = Maps.newLinkedHashMap(); + // 加密数据 + byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(map).getBytes(), + configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); + String encryptData = Encodes.encodeBase64(encryptText); + + resultMap.put("Data", encryptData); + // 生成sig + String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); + resultMap.put("Sig", resultSign); + + return resultMap; + } + + /** + * 查询充电电量信息 query_order_info + * + * @param orderCode + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryOrderInfo(String orderCode) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 请求设备认证 query_equip_auth + * 业务信息交换 + * + * @param dto 联联平台请求设备认证 + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryEquipAuth(QueryEquipmentDTO dto) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 请求启动充电 query_start_charge + * + * @param dto 请求启动充电DTO + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryStartCharge(QueryStartChargeDTO dto) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 查询充电状态 query_equip_charge_status + * + * @param dto 查询充电状态DTO + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryEquipChargeStatus(QueryEquipChargeStatusDTO dto) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 请求停止充电 query_stop_charge + * + * @param dto 请求启动充电DTO + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryStopCharge(QueryStartChargeDTO dto) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 充电站内充电桩空闲状态查询 query_free_pile_number + * + * @param dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryFreePileNumber(NXJTQueryStationInfoDTO dto) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 某车牌号消费记录查询 query_orders_info_by_Plate_number + * + * @param dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryOrdersInfoByPlateNumber(NXJTQueryStationInfoDTO dto) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 某段时间内消费记录查询 query_orders_info + * + * @param dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryOrdersInfo(NXJTQueryStationInfoDTO dto) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 查询业务策略信息结果 + * 请求计费策略 request_equip_business_policy + * + * @param dto 请求启动充电DTO + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryEquipBusinessPolicy(QueryStartChargeDTO dto) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * VIN码充电 insert_start_charge + * 华为平台 + * + * @param dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map insertStartCharge(QueryStationInfoDTO dto) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 下发计费策略响应 notification_deliver_equip_business_policy_result + * 华为平台 + * + * @param dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map notificationDeliverEquipBusinessPolicyResult(QueryStationInfoDTO dto) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 充电站信息变化推送 notification_stationInfo + * 新站需要推送。当站点信息发生变化时,推送新的信息通知到市级平台 + * + * @param stationId 充电站id + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationStationInfo(String stationId) { + // 通过id查询站点相关信息 + PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId)); + // 通过第三方配置类型查询相关配置信息 + ThirdPartySettingInfo settingInfo = new ThirdPartySettingInfo(); + settingInfo.setType(platformType); + ThirdPartySettingInfo thirdPartySettingInfo = thirdPartySettingInfoService.selectSettingInfo(settingInfo); + + String operatorId = thirdPartySettingInfo.getOperatorId(); + String operatorSecret = thirdPartySettingInfo.getOperatorSecret(); + String signSecret = thirdPartySettingInfo.getSignSecret(); + String dataSecret = thirdPartySettingInfo.getDataSecret(); + String dataSecretIv = thirdPartySettingInfo.getDataSecretIv(); + String urlAddress = thirdPartySettingInfo.getUrlAddress(); + + // 组装联联平台所需要的数据格式 + StationInfo info = StationInfo.builder() + .stationID("LC" + stationId) + .operatorID(operatorId) + .stationName(pileStationInfo.getStationName()) + .isAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())) + .isPublicParkingLot(Integer.valueOf(pileStationInfo.getPublicParking())) + .countryCode(pileStationInfo.getCountryCode()) + .address(pileStationInfo.getAddress()) + .serviceTel(pileStationInfo.getStationTel()) + .stationType(Integer.valueOf(pileStationInfo.getStationType())) + .stationStatus(Integer.valueOf(pileStationInfo.getStationStatus())) + .parkNums(Integer.valueOf(pileStationInfo.getParkNums())) + .stationLng(new BigDecimal(pileStationInfo.getStationLng())) + .stationLat(new BigDecimal(pileStationInfo.getStationLat())) + .construction(Integer.valueOf(pileStationInfo.getConstruction())) + .openAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay())) + .minElectricityPrice(new BigDecimal(Constants.ZERO)) + .electricityFee(Constants.ZERO) + .serviceFee(Constants.ZERO) + .parkFree(Integer.valueOf(pileStationInfo.getParkFree())) + .supportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())) + .parkFeeType(0) + .toiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())) + .storeFlag(Integer.valueOf(pileStationInfo.getStoreFlag())) + .restaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag())) + .loungeFlag(Integer.valueOf(pileStationInfo.getLoungeFlag())) + .canopyFlag(Integer.valueOf(pileStationInfo.getCanopyFlag())) + .printerFlag(Integer.valueOf(pileStationInfo.getPrinterFlag())) + .barrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag())) + .parkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag())) + .build(); + String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213 + // 根据逗号分组 + String[] split = StringUtils.split(areaCode, ","); + // 只取最后一部分 330213 + String subAreaCode = split[split.length - 1]; + info.setAreaCode(subAreaCode); + // 截取运营商组织机构代码(去除最后一位后的最后九位) + String organizationCode = ""; + if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getCode(), platformType)) { + // 联联平台先使用自己运营商的组织机构代码 + organizationCode = Constants.OPERATORID_LIANLIAN; + info.setEquipmentOwnerID(organizationCode); + }else { + MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(pileStationInfo.getMerchantId())); + organizationCode = merchantInfo.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + info.setEquipmentOwnerID(equipmentOwnerId); + } + } + if (StringUtils.equals("36", String.valueOf(pileStationInfo.getMerchantId()))) { + // 远大 + info.setEquipmentOwnerID(Constants.OPERATORID_YUAN_DA); + } + if (StringUtils.equals("35", String.valueOf(pileStationInfo.getMerchantId()))) { + // 如果是希晓运营商,则把equipmentOwnerID换成希晓 + info.setEquipmentOwnerID(Constants.OPERATORID_XI_XIAO); + } + String payment = StationPaymentEnum.getPaymentByCode(pileStationInfo.getPayment()); + info.setPayment(payment); + if (StringUtils.isNotBlank(pileStationInfo.getParkingNumber())) { + info.setIsPublicParkingLot(1); + info.setParkingLotNumber(pileStationInfo.getParkingNumber()); + } + // 户号 + if (StringUtils.isNotBlank(pileStationInfo.getAccountNumber())) { + info.setAccountNumber(pileStationInfo.getAccountNumber()); + } + + // 容量 + if (StringUtils.isNotBlank(String.valueOf(pileStationInfo.getCapacity()))) { + info.setCapacity(pileStationInfo.getCapacity().setScale(4, BigDecimal.ROUND_HALF_UP)); + } + List pileList = pileBasicInfoService.getPileList(pileStationInfo); + if (CollectionUtils.isNotEmpty(pileList)) { + info.setEquipmentInfos(pileList); // 充电设备信息列表 + } + + // 调用联联平台接口 + String url = urlAddress + "notification_stationInfo"; + + String jsonStr = JSON.toJSONString(info); + JSONObject data = new JSONObject(); + data.put("StationInfo", jsonStr); + + String jsonString = JSON.toJSONString(data); + System.out.println("jsonString : " + jsonString); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret + , dataSecretIv, operatorId, signSecret); + + // 新增数据库 + thirdPartyStationRelationService.insertInfo2DataBase(platformType, stationId); + return platformType + ":" + result; + } + + /** + * 设备状态变化推送 notification_stationStatus + * 推送充电设备接口状态信息 supervise_notification_station_status + * + * @param pileConnectorCode 充电枪口编号 + * @param status 枪口状态 + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationStationStatus(String pileConnectorCode, String status) { + // 查出该桩所属哪个站点 + String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + PileStationVO stationVO = pileStationInfoService.getStationInfoByPileSn(pileSn); + // 通过站点id查询相关配置信息 + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(stationVO.getId()); + if (relationInfo == null) { + return null; + } + String operatorId = relationInfo.getOperatorId(); + String operatorSecret = relationInfo.getOperatorSecret(); + String signSecret = relationInfo.getSignSecret(); + String dataSecret = relationInfo.getDataSecret(); + String dataSecretIv = relationInfo.getDataSecretIv(); + String urlAddress = relationInfo.getUrlAddress(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue(); + ConnectorStatusInfo info = ConnectorStatusInfo.builder() + .connectorID(pileConnectorCode) + .status(Integer.parseInt(status)) + .build(); + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ConnectorStatusInfo", info); + String jsonString = JSON.toJSONString(json); + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 设备充电中状态变化推送 notification_connector_charge_status + * + * @param orderCode 订单编号 + */ + @Override + public String notificationConnectorChargeStatus(String orderCode) { + // 通过订单号查询信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // 根据枪口号查询充电实时状态 + // OrderBasicInfo orderBasicInfo = orderBasicInfoService.queryChargingByPileConnectorCode(orderInfo.getPileConnectorCode()); + List list = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode()); + RealTimeMonitorData realTimeMonitorData = list.get(0); + // 拼装联联参数 + ConnectorChargeStatusInfo info = ConnectorChargeStatusInfo.builder() + .startChargeSeq(orderCode) + .connectorID(orderInfo.getPileConnectorCode()) + .connectorStatus(Integer.valueOf(realTimeMonitorData.getConnectorStatus())) + .currentA(new BigDecimal(realTimeMonitorData.getOutputCurrent())) + .voltageA(new BigDecimal(realTimeMonitorData.getOutputVoltage())) + .soc(new BigDecimal(realTimeMonitorData.getSOC())) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) + .endTime(DateUtils.getDateTime()) + .totalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())) + .elecMoney(new BigDecimal("0")) // TODO + .seviceMoney(new BigDecimal("0")) // TODO + .totalMoney(new BigDecimal(realTimeMonitorData.getChargingAmount()).setScale(2, BigDecimal.ROUND_HALF_UP)) + .build(); + + // 通过站点id查询相关配置信息 + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderInfo.getStationId()); + if (relationInfo == null) { + return null; + } + String operatorId = relationInfo.getOperatorId(); + String operatorSecret = relationInfo.getOperatorSecret(); + String signSecret = relationInfo.getSignSecret(); + String dataSecret = relationInfo.getDataSecret(); + String dataSecretIv = relationInfo.getDataSecretIv(); + String urlAddress = relationInfo.getUrlAddress(); + + String url = urlAddress + "notification_connector_charge_status"; + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + JSONObject json = new JSONObject(); + json.put("ConnectorChargeStatusInfo", info); + String jsonString = JSON.toJSONString(json); + // 发送请求 + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 订单信息推送 notification_orderInfo + * + * @param orderCode + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationOrderInfo(String orderCode) { + + // 根据订单号查询出信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + + // 通过站点id查询相关配置信息 + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderBasicInfo.getStationId()); + if (relationInfo == null) { + return null; + } + String operatorId = relationInfo.getOperatorId(); + String operatorSecret = relationInfo.getOperatorSecret(); + String signSecret = relationInfo.getSignSecret(); + String dataSecret = relationInfo.getDataSecret(); + String dataSecretIv = relationInfo.getDataSecretIv(); + String urlAddress = relationInfo.getUrlAddress(); + + String url = urlAddress + "notification_orderInfo"; + + // 拼装成联联平台所需格式对象 + OrderInfo orderInfo = OrderInfo.builder() + .operatorID(operatorId) + .equipmentOwnerID(Constants.OPERATORID_LIANLIAN) + .stationID("LC" + orderBasicInfo.getStationId()) + .equipmentID(orderBasicInfo.getPileSn()) + .connectorID(orderBasicInfo.getPileConnectorCode()) + .startChargeSeq(orderCode) + .userChargeType(Constants.one) + .money(new BigDecimal(String.valueOf(orderBasicInfo.getOrderAmount())).setScale(2, BigDecimal.ROUND_HALF_UP)) + .electMoney(new BigDecimal(String.valueOf(orderDetail.getTotalElectricityAmount())).setScale(2, BigDecimal.ROUND_HALF_UP)) + .serviceMoney(new BigDecimal(String.valueOf(orderDetail.getTotalServiceAmount())).setScale(2, BigDecimal.ROUND_HALF_UP)) + .elect(new BigDecimal(String.valueOf(orderDetail.getTotalUsedElectricity())).setScale(2, BigDecimal.ROUND_HALF_UP)) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())) + .endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime())) + .paymentAmount(orderBasicInfo.getPayAmount()) + // .payChannel() + .stopReason(0) + // .chargeDetails() + .build(); + if (StringUtils.equals("35", orderBasicInfo.getMerchantId())) { + orderInfo.setEquipmentOwnerID(Constants.OPERATORID_XI_XIAO); + } + // 支付方式 + if (StringUtils.equals(orderBasicInfo.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) { + // 微信支付 + orderInfo.setPayChannel(Integer.valueOf(PayChannelEnum.WEXIN_PAY.getCode())); + } else if (StringUtils.equals(orderBasicInfo.getPayMode(), OrderPayModeEnum.PAYMENT_OF_ALIPAY.getValue())) { + // 支付宝支付 + orderInfo.setPayChannel(Integer.valueOf(PayChannelEnum.ALI_PAY.getCode())); + } else { + // 其他 + orderInfo.setPayChannel(Integer.valueOf(PayChannelEnum.OTHER.getCode())); + } + // 订单详情 + ChargeDetail detail; + + List billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); + // 先将list按照 尖、峰、平、谷 时段排序 + // List collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList()); + // 再循环该list,拼装对应的充电价格、费率 + List chargeDetails = new ArrayList<>(); + for (BillingPriceVO billingPriceVO : billingList) { + detail = new ChargeDetail(); + if (StringUtils.equals(billingPriceVO.getTimeType(), "1")) { + // 尖时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getSharpUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getSharpElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getSharpServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), "2")) { + // 峰时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getPeakUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getPeakElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getPeakServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), "3")) { + // 平时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getFlatUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getFlatElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getFlatServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), "4")) { + // 谷时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getValleyUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getValleyElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getValleyServicePrice()); + } + chargeDetails.add(detail); + } + orderInfo.setChargeDetails(chargeDetails); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("OrderInfo", orderInfo); + String jsonString = JSON.toJSONString(json); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 站点费率变化推送 notification_stationFee + * + * @param stationId + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationStationFee(String stationId) { + PushStationFeeVO vo = new PushStationFeeVO(); + List chargeFeeDetailList = new ArrayList<>(); + PushStationFeeVO.ChargeFeeDetail chargeFeeDetail = null; + // 根据站点 id 查询出正在使用的计费模板详情 + List billingPriceVOList = pileBillingTemplateService.queryBillingPrice(stationId); + // 查询设备列表 + List pileDetailVOS = pileBasicInfoService.queryPileDetailList(Lists.newArrayList(stationId)); + vo.setOperatorId(Constants.OPERATORID_LIANLIAN); + vo.setStationId(stationId); + for (PileInfoVO pileInfoVO : pileDetailVOS) { + for (BillingPriceVO billingPriceVO : billingPriceVOList) { + chargeFeeDetail = new PushStationFeeVO.ChargeFeeDetail(); + + chargeFeeDetail.setEquipmentType(Integer.parseInt(pileInfoVO.getSpeedType())); + String startTime = billingPriceVO.getStartTime(); + String endTime = billingPriceVO.getEndTime(); + + chargeFeeDetail.setStartTime(startTime); + chargeFeeDetail.setEndTime(endTime); + chargeFeeDetail.setElectricityFee(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(2, BigDecimal.ROUND_DOWN)); + chargeFeeDetail.setServiceFee(new BigDecimal(billingPriceVO.getServicePrice()).setScale(2, BigDecimal.ROUND_DOWN)); + + chargeFeeDetailList.add(chargeFeeDetail); + } + } + vo.setChargeFeeDetail(chargeFeeDetailList); + + // 通过站点id查询相关配置信息 + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(stationId); + if (relationInfo == null) { + return null; + } + String operatorId = relationInfo.getOperatorId(); + String operatorSecret = relationInfo.getOperatorSecret(); + String signSecret = relationInfo.getSignSecret(); + String dataSecret = relationInfo.getDataSecret(); + String dataSecretIv = relationInfo.getDataSecretIv(); + String urlAddress = relationInfo.getUrlAddress(); + + String url = urlAddress + "notification_stationFee"; + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + JSONObject json = new JSONObject(); + json.put("StationFee", vo); + String jsonString = JSON.toJSONString(json); + // 发送请求 + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 充电订单推送 notification_charge_order_info + * TODO 海南一张网文档中的接口,检查一下是否和订单信息推送notification_orderInfo一致 + * TODO 甬城泊车平台文档中的接口,检查一下是否和订单信息推送notification_orderInfo一致 + * TODO 华为平台文档中的接口,检查一下是否和订单信息推送notification_orderInfo一致 + * TODO 内蒙古平台文档中的接口,检查一下是否和订单信息推送notification_orderInfo一致 + * + * @param orderCode 订单编号 + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationChargeOrderInfo(String orderCode) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 告警信息推送 notification_alarmInfo + * + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationAlarmInfo() { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 推送启动充电结果 notification_start_charge_result + * + * @param orderCode 订单编号 + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationStartChargeResult(String orderCode) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 推送充电状态 notification_equip_charge_status + * 推送充电状态信息 supervise_notification_equip_charge_status + * + * @param orderCode 订单编号 + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationEquipChargeStatus(String orderCode) throws UnsupportedOperationException { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 推送停止充电结果 notification_stop_charge_result + * + * @param orderCode 订单编号 + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationStopChargeResult(String orderCode) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 华为平台 + * 平台充电设备编码同步 notification_operation_system_info + * + * @param orderCode + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationOperationSystemInfo(String orderCode) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 推送充换电站用能统计信息 supervise_notification_operation_stats_info + * + * @param stationId + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationOperationStatsInfo(String stationId) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 推送充电站历史充电订单信息 supervise_notification_charge_order_info_history + * + * @param stationId + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationChargeOrderInfoHistory(String stationId) { + //方法未实现,抛出异常 + throw new UnsupportedOperationException("This method is not yet implemented"); + } + +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformLogic.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformLogic.java index ee9e89fd0..48f268227 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformLogic.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/neimenggu/service/NeiMengGuPlatformLogic.java @@ -25,7 +25,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map queryOperatorInfo(QueryOperatorInfoDTO dto) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -35,7 +35,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map queryStationsInfo(QueryStationInfoDTO dto) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -46,18 +46,17 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public String notificationStationStatus(String pileConnectorCode, String status) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** * 设备充电中状态变化推送 notification_connector_charge_status * - * @param pileConnectorCode 充电枪口编号 - * @param status 枪口状态 + * @param orderCode 订单号 */ @Override - public String notificationConnectorChargeStatus(String pileConnectorCode, String status) { - return null; + public String notificationConnectorChargeStatus(String orderCode) { + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -67,7 +66,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public String notificationOrderInfo(String orderCode) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -77,7 +76,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public String notificationStationFee(String stationId) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -87,7 +86,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public String notificationChargeOrderInfo(String orderCode) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -95,7 +94,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public String notificationAlarmInfo() { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -105,17 +104,17 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map queryStationStatus(QueryStationInfoDTO dto) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** - * 查询统计信息 + * 查询统计信息 query_station_stats * * @param dto */ @Override public Map queryStationStats(QueryStationInfoDTO dto) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -125,7 +124,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map queryOrderInfo(String orderCode) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -136,7 +135,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map queryEquipAuth(QueryEquipmentDTO dto) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -146,7 +145,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map queryEquipBusinessPolicy(QueryStartChargeDTO dto) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -157,7 +156,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map insertStartCharge(QueryStationInfoDTO dto) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -168,7 +167,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map notificationDeliverEquipBusinessPolicyResult(QueryStationInfoDTO dto) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -179,7 +178,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public String notificationStationInfo(String stationId) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -189,7 +188,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map queryStartCharge(QueryStartChargeDTO dto) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -199,7 +198,18 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public String notificationStartChargeResult(String orderCode) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + /** + * 推送充电状态 notification_equip_charge_status + * 推送充电状态信息 supervise_notification_equip_charge_status + * + * @param orderCode 订单编号 + */ + @Override + public String notificationEquipChargeStatus(String orderCode) { + throw new UnsupportedOperationException("This method is not yet implemented"); } /** @@ -209,20 +219,11 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map queryEquipChargeStatus(QueryEquipChargeStatusDTO dto) { - return null; - } - - /** - * 推送充电状态 - * - * @param orderCode - */ - @Override - public String notificationEquipChargeStatus(String orderCode) { - //方法未实现,抛出异常 throw new UnsupportedOperationException("This method is not yet implemented"); } + + /** * 请求停止充电 * @@ -230,7 +231,7 @@ public class NeiMengGuPlatformLogic extends AbsInterfaceWithPlatformLogic { */ @Override public Map queryStopCharge(QueryStartChargeDTO dto) { - return null; + throw new UnsupportedOperationException("This method is not yet implemented"); } /** diff --git a/jsowell-ui/src/views/member/merchantVIP/index.vue b/jsowell-ui/src/views/member/merchantVIP/index.vue index ec95d546e..f1dc745ab 100644 --- a/jsowell-ui/src/views/member/merchantVIP/index.vue +++ b/jsowell-ui/src/views/member/merchantVIP/index.vue @@ -187,9 +187,10 @@ - +