update 启动预约订单

This commit is contained in:
2023-03-25 11:10:15 +08:00
parent a624d492ea
commit e5eafef8db
7 changed files with 74 additions and 10 deletions

View File

@@ -19,6 +19,7 @@ import com.jsowell.common.enums.ykc.PayModeEnum;
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.enums.ykc.ScenarioEnum; import com.jsowell.common.enums.ykc.ScenarioEnum;
import com.jsowell.common.enums.ykc.StartTypeEnum;
import com.jsowell.common.exception.BusinessException; import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.SecurityUtils; import com.jsowell.common.util.SecurityUtils;
@@ -287,8 +288,18 @@ public class OrderService {
orderInfo.setPayTime(new Date()); orderInfo.setPayTime(new Date());
orderBasicInfoService.updateOrderBasicInfo(orderInfo); orderBasicInfoService.updateOrderBasicInfo(orderInfo);
String pileSn = orderInfo.getPileSn(); if (StringUtils.equals(orderInfo.getStartType(), StartTypeEnum.NOW.getValue())) {
startCharging(orderInfo);
}
}
/**
* 启动充电
* @param orderInfo
*/
public void startCharging(OrderBasicInfo orderInfo) {
String pileSn = orderInfo.getPileSn();
// 发送启动充电指令前,再次下发计费模板 // 发送启动充电指令前,再次下发计费模板
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn); BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
if (billingTemplateVO != null) { if (billingTemplateVO != null) {
@@ -296,7 +307,7 @@ public class OrderService {
} }
// 发送启动指令 // 发送启动指令
pileRemoteService.remoteStartCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), payAmount); pileRemoteService.remoteStartCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), orderInfo.getPayAmount());
} }
/** /**

View File

@@ -13,6 +13,7 @@ import com.jsowell.pile.vo.web.OrderListVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@@ -29,7 +30,7 @@ public interface OrderBasicInfoMapper {
* @param id 订单主键 * @param id 订单主键
* @return 订单 * @return 订单
*/ */
public OrderBasicInfo selectOrderBasicInfoById(Long id); OrderBasicInfo selectOrderBasicInfoById(Long id);
/** /**
* 条件查询订单基础信息 * 条件查询订单基础信息
@@ -44,7 +45,7 @@ public interface OrderBasicInfoMapper {
* @param orderBasicInfo 订单 * @param orderBasicInfo 订单
* @return 订单集合 * @return 订单集合
*/ */
public List<OrderListVO> selectOrderBasicInfoList(QueryOrderDTO orderBasicInfo); List<OrderListVO> selectOrderBasicInfoList(QueryOrderDTO orderBasicInfo);
/** /**
* 新增订单 * 新增订单
@@ -52,7 +53,7 @@ public interface OrderBasicInfoMapper {
* @param orderBasicInfo 订单 * @param orderBasicInfo 订单
* @return 结果 * @return 结果
*/ */
public int insertOrderBasicInfo(OrderBasicInfo orderBasicInfo); int insertOrderBasicInfo(OrderBasicInfo orderBasicInfo);
/** /**
* 修改订单 * 修改订单
@@ -60,7 +61,7 @@ public interface OrderBasicInfoMapper {
* @param orderBasicInfo 订单 * @param orderBasicInfo 订单
* @return 结果 * @return 结果
*/ */
public int updateOrderBasicInfo(OrderBasicInfo orderBasicInfo); int updateOrderBasicInfo(OrderBasicInfo orderBasicInfo);
/** /**
* 批量删除订单 * 批量删除订单
@@ -68,7 +69,7 @@ public interface OrderBasicInfoMapper {
* @param ids 需要删除的数据主键集合 * @param ids 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int deleteOrderBasicInfoByIds(Long[] ids); int deleteOrderBasicInfoByIds(Long[] ids);
/** /**
* 批量删除订单详情 * 批量删除订单详情
@@ -76,7 +77,7 @@ public interface OrderBasicInfoMapper {
* @param ids 需要删除的数据主键集合 * @param ids 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int deleteOrderDetailByOrderCodes(Long[] ids); int deleteOrderDetailByOrderCodes(Long[] ids);
/** /**
* 批量新增订单详情 * 批量新增订单详情
@@ -84,7 +85,7 @@ public interface OrderBasicInfoMapper {
* @param orderDetailList 订单详情列表 * @param orderDetailList 订单详情列表
* @return 结果 * @return 结果
*/ */
public int batchOrderDetail(List<OrderDetail> orderDetailList); int batchOrderDetail(List<OrderDetail> orderDetailList);
/** /**
@@ -93,7 +94,7 @@ public interface OrderBasicInfoMapper {
* @param id 订单ID * @param id 订单ID
* @return 结果 * @return 结果
*/ */
public int deleteOrderDetailByOrderCode(Long id); int deleteOrderDetailByOrderCode(Long id);
/** /**
* 修改订单详情 * 修改订单详情
@@ -185,4 +186,5 @@ public interface OrderBasicInfoMapper {
*/ */
List<PersonPileConnectorSumInfoVO> getAccumulativeInfo(QueryPersonPileDTO dto); List<PersonPileConnectorSumInfoVO> getAccumulativeInfo(QueryPersonPileDTO dto);
List<OrderBasicInfo> getAppointmentOrder(LocalDateTime dateTime);
} }

View File

@@ -15,6 +15,7 @@ import com.jsowell.pile.vo.web.OrderListVO;
import com.jsowell.pile.vo.web.OrderTotalDataVO; import com.jsowell.pile.vo.web.OrderTotalDataVO;
import com.jsowell.wxpay.dto.WeChatRefundDTO; import com.jsowell.wxpay.dto.WeChatRefundDTO;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@@ -209,5 +210,10 @@ public interface IOrderBasicInfoService {
*/ */
void updateOrderStatusAsAbnormal(String pileSn); void updateOrderStatusAsAbnormal(String pileSn);
/**
* 预约订单启动
*/
void appointmentOrderStart();
List<OrderBasicInfo> getAppointmentOrder(LocalDateTime dateTime);
} }

View File

@@ -71,6 +71,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -1169,4 +1170,9 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
} }
} }
} }
@Override
public List<OrderBasicInfo> getAppointmentOrder(LocalDateTime dateTime) {
return orderBasicInfoMapper.getAppointmentOrder(dateTime);
}
} }

View File

@@ -868,4 +868,14 @@
AND t1.del_flag = '0' AND t1.del_flag = '0'
</select> </select>
<select id="getAppointmentOrder" resultMap="OrderBasicInfoResult">
select
<include refid="Base_Column_List"/>
from order_basic_info
where del_flag = '0'
and pay_status = '1'
and start_type = 'appointment'
and order_status = '0'
and settlement_time <![CDATA[ <= ]]> #{dateTime,jdbcType=TIMESTAMP}
</select>
</mapper> </mapper>

View File

@@ -41,6 +41,12 @@
<artifactId>jsowell-pile</artifactId> <artifactId>jsowell-pile</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.jsowell</groupId>
<artifactId>jsowell-admin</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -1,13 +1,18 @@
package com.jsowell.quartz.task; package com.jsowell.quartz.task;
import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.DateUtils;
import com.jsowell.pile.domain.OrderBasicInfo;
import com.jsowell.pile.service.IOrderBasicInfoService; import com.jsowell.pile.service.IOrderBasicInfoService;
import com.jsowell.service.OrderService;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
import java.util.List;
@Component("jsowellTask") @Component("jsowellTask")
public class JsowellTask { public class JsowellTask {
@@ -17,6 +22,9 @@ public class JsowellTask {
@Autowired @Autowired
private IOrderBasicInfoService orderBasicInfoService; private IOrderBasicInfoService orderBasicInfoService;
@Autowired
private OrderService orderService;
/** /**
* 关闭15分钟未支付的订单 * 关闭15分钟未支付的订单
* close15MinutesOfUnpaidOrders * close15MinutesOfUnpaidOrders
@@ -36,4 +44,19 @@ public class JsowellTask {
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date()); String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
orderBasicInfoService.closeStartFailedOrder(startTime, endTime); orderBasicInfoService.closeStartFailedOrder(startTime, endTime);
} }
/**
* 查询预约充电的订单并启动
*/
public void appointmentOrderStart() {
// 查询出 已支付 设置预约充电 未启动 的订单
LocalDateTime now = LocalDateTime.now();
List<OrderBasicInfo> list = orderBasicInfoService.getAppointmentOrder(now);
if (CollectionUtils.isEmpty(list)) {
return;
}
for (OrderBasicInfo order : list) {
orderService.startCharging(order);
}
}
} }