|
|
@@ -1,27 +1,25 @@
|
|
|
package com.zsElectric.boot.business.service.impl;
|
|
|
|
|
|
-import cn.binarywang.wx.miniapp.bean.shop.WxMaShopCouponInfo;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.zsElectric.boot.business.mapper.*;
|
|
|
import com.zsElectric.boot.business.model.entity.*;
|
|
|
import com.zsElectric.boot.business.model.form.applet.AppInvokeChargeForm;
|
|
|
-import com.zsElectric.boot.business.model.query.UserOrderInfoQuery;
|
|
|
+import com.zsElectric.boot.business.model.form.applet.AppStopChargeForm;
|
|
|
import com.zsElectric.boot.business.model.query.applet.AppChargeOrderInfoQuery;
|
|
|
-import com.zsElectric.boot.business.model.vo.UserOrderInfoVO;
|
|
|
-import com.zsElectric.boot.business.model.vo.applet.AppInvokeChargeVO;
|
|
|
+import com.zsElectric.boot.business.model.vo.applet.AppChargeVO;
|
|
|
import com.zsElectric.boot.business.model.vo.applet.AppUserInfoVO;
|
|
|
import com.zsElectric.boot.charging.dto.StartChargingRequestDTO;
|
|
|
import com.zsElectric.boot.charging.dto.StartChargingResponseVO;
|
|
|
import com.zsElectric.boot.charging.service.ChargingBusinessService;
|
|
|
import com.zsElectric.boot.charging.vo.EquipmentAuthResponseVO;
|
|
|
+import com.zsElectric.boot.charging.vo.StopChargingOperationResponseVO;
|
|
|
import com.zsElectric.boot.common.constant.ConnectivityConstants;
|
|
|
import com.zsElectric.boot.common.constant.SystemConstants;
|
|
|
-import com.zsElectric.boot.common.util.electric.ApiToken;
|
|
|
import com.zsElectric.boot.core.exception.BusinessException;
|
|
|
import com.zsElectric.boot.security.util.SecurityUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
@@ -33,7 +31,6 @@ import com.zsElectric.boot.business.model.vo.ChargeOrderInfoVO;
|
|
|
import com.zsElectric.boot.business.converter.ChargeOrderInfoConverter;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@@ -48,6 +45,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
* @author zsElectric
|
|
|
* @since 2025-12-17 19:13
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
public class ChargeOrderInfoServiceImpl extends ServiceImpl<ChargeOrderInfoMapper, ChargeOrderInfo> implements ChargeOrderInfoService {
|
|
|
@@ -149,10 +147,12 @@ public class ChargeOrderInfoServiceImpl extends ServiceImpl<ChargeOrderInfoMappe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public AppInvokeChargeVO invokeCharge(AppInvokeChargeForm formData) {
|
|
|
+ public AppChargeVO invokeCharge(AppInvokeChargeForm formData) {
|
|
|
+
|
|
|
+ log.info("启动充电开始,用户ID:{},设备认证流水号:{},充电桩编号:{}", SecurityUtils.getUserId(), formData.getEquipAuthSeq(), formData.getEquipmentId());
|
|
|
|
|
|
try {
|
|
|
- AppInvokeChargeVO appInvokeChargeVO = new AppInvokeChargeVO();
|
|
|
+ AppChargeVO appInvokeChargeVO = new AppChargeVO();
|
|
|
|
|
|
//必要校验
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
@@ -236,6 +236,32 @@ public class ChargeOrderInfoServiceImpl extends ServiceImpl<ChargeOrderInfoMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public AppChargeVO stopCharge(AppStopChargeForm formData) {
|
|
|
+ try {
|
|
|
+ AppChargeVO appInvokeChargeVO = new AppChargeVO();
|
|
|
+
|
|
|
+ //订单
|
|
|
+ ChargeOrderInfo chargeOrderInfo = this.getById(formData.getChargeOrderId());
|
|
|
+ if(ObjectUtil.isEmpty(chargeOrderInfo)){
|
|
|
+ throw new BusinessException("订单不存在");
|
|
|
+ }
|
|
|
+ StopChargingOperationResponseVO stopChargingOperationResponseVO = chargingBusinessService.stopCharging(chargeOrderInfo.getStartChargeSeq(), chargeOrderInfo.getConnectorId());
|
|
|
+
|
|
|
+ if (!Objects.equals(stopChargingOperationResponseVO.getSuccStat(), SystemConstants.STATUS_ZERO)) {
|
|
|
+ throw new BusinessException("停止充电失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存订单
|
|
|
+ this.save(chargeOrderInfo);
|
|
|
+
|
|
|
+ appInvokeChargeVO.setChargeOrderNo(chargeOrderInfo.getChargeOrderNo());
|
|
|
+ return appInvokeChargeVO;
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BusinessException("停止充电失败,系统错误,请联系客服处理!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 创建商户订单号
|
|
|
* 要求 32个字符内,只能是数字、大小写字母_-|*且在同一个商户号下唯一
|