1. 联调
This commit is contained in:
parent
6383feb843
commit
59c3ff74c8
|
@ -144,6 +144,10 @@ public class AppVerifyController extends BaseController
|
||||||
if(order.getRuleId()==null){
|
if(order.getRuleId()==null){
|
||||||
return error("=============================================ruleId未传!!!=============================================");
|
return error("=============================================ruleId未传!!!=============================================");
|
||||||
}
|
}
|
||||||
|
//设备是否在线
|
||||||
|
if(!asDeviceService.isOnline(order.getSn())){
|
||||||
|
return error("设备不在线");
|
||||||
|
}
|
||||||
//实名判断
|
//实名判断
|
||||||
if(!asUserService.checkIsAuthentication(order.getUserId())){
|
if(!asUserService.checkIsAuthentication(order.getUserId())){
|
||||||
return error("您还未实名,请先实名");
|
return error("您还未实名,请先实名");
|
||||||
|
@ -291,6 +295,10 @@ public class AppVerifyController extends BaseController
|
||||||
public AjaxResult deviceAppointment(EtOrderVo appointmentVo)
|
public AjaxResult deviceAppointment(EtOrderVo appointmentVo)
|
||||||
{
|
{
|
||||||
logger.info("【车辆预约信息】:{}", JSON.toJSON(appointmentVo));
|
logger.info("【车辆预约信息】:{}", JSON.toJSON(appointmentVo));
|
||||||
|
//设备是否在线
|
||||||
|
if(!asDeviceService.isOnline(appointmentVo.getSn())){
|
||||||
|
return error("设备不在线");
|
||||||
|
}
|
||||||
//运营时间判断
|
//运营时间判断
|
||||||
if(!asDeviceService.isOperatingTime(appointmentVo.getSn())){
|
if(!asDeviceService.isOperatingTime(appointmentVo.getSn())){
|
||||||
return error("不在营业时间内,不得骑行");
|
return error("不在营业时间内,不得骑行");
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.ruoyi.common.utils.onenet;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ResponseVo {
|
||||||
|
|
||||||
|
@JsonProperty("data")
|
||||||
|
private Object data;
|
||||||
|
|
||||||
|
@JsonProperty("request_id")
|
||||||
|
private String requestId;
|
||||||
|
|
||||||
|
@JsonProperty("msg")
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
@JsonProperty("code")
|
||||||
|
private int code;
|
||||||
|
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ruoyi.common.utils.onenet.ResponseVo;
|
||||||
import com.ruoyi.system.domain.AsDevice;
|
import com.ruoyi.system.domain.AsDevice;
|
||||||
import com.ruoyi.system.domain.EtOperatingArea;
|
import com.ruoyi.system.domain.EtOperatingArea;
|
||||||
import com.ruoyi.system.domain.EtOrder;
|
|
||||||
import com.ruoyi.system.domain.response.OrderResponse;
|
import com.ruoyi.system.domain.response.OrderResponse;
|
||||||
import com.ruoyi.system.domain.vo.DeviceNumVo;
|
import com.ruoyi.system.domain.vo.DeviceNumVo;
|
||||||
import com.ruoyi.system.domain.vo.EtOrderVo;
|
import com.ruoyi.system.domain.vo.EtOrderVo;
|
||||||
|
@ -127,6 +127,11 @@ public interface IAsDeviceService extends IService<AsDevice>
|
||||||
*/
|
*/
|
||||||
public void sendCommand(String mac, String token,String command,String type);
|
public void sendCommand(String mac, String token,String command,String type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送命令(带响应)
|
||||||
|
*/
|
||||||
|
public ResponseVo sendCommandWithResp(String mac, String token, String command, String type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响铃寻车
|
* 响铃寻车
|
||||||
*/
|
*/
|
||||||
|
@ -236,6 +241,11 @@ public interface IAsDeviceService extends IService<AsDevice>
|
||||||
|
|
||||||
int updateLocation(AsDevice device);
|
int updateLocation(AsDevice device);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否在线
|
||||||
|
*/
|
||||||
|
boolean isOnline(String sn);
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 是否靠近运营区边界
|
// * 是否靠近运营区边界
|
||||||
// */
|
// */
|
||||||
|
|
|
@ -17,6 +17,7 @@ import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.http.HttpUtils;
|
import com.ruoyi.common.utils.http.HttpUtils;
|
||||||
import com.ruoyi.common.utils.map.GeoUtils;
|
import com.ruoyi.common.utils.map.GeoUtils;
|
||||||
import com.ruoyi.common.utils.onenet.IotUtil;
|
import com.ruoyi.common.utils.onenet.IotUtil;
|
||||||
|
import com.ruoyi.common.utils.onenet.ResponseVo;
|
||||||
import com.ruoyi.common.utils.onenet.Token;
|
import com.ruoyi.common.utils.onenet.Token;
|
||||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||||
import com.ruoyi.system.domain.*;
|
import com.ruoyi.system.domain.*;
|
||||||
|
@ -633,6 +634,16 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
/** 发送命令*/
|
||||||
|
public ResponseVo sendCommandWithResp(String mac, String token,String command,String type) {
|
||||||
|
String param = "device_name=" + mac + "&product_id=" + productId +"&timeout=" + timeout;
|
||||||
|
String sendUrl = iotUrl+ IotConstants.ADDS_COMMAND + "?"+param;
|
||||||
|
String result = HttpUtils.sendPostWithToken(sendUrl, command, token);
|
||||||
|
log.info("【"+type+"】===>IOT请求调用结果:【{}】",result);
|
||||||
|
return JSON.parseObject(result,ResponseVo.class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响铃寻车
|
* 响铃寻车
|
||||||
* @param sn
|
* @param sn
|
||||||
|
@ -798,7 +809,14 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
//定时取消预约
|
//定时取消预约
|
||||||
scheduledExecutorService.schedule(() -> {
|
scheduledExecutorService.schedule(() -> {
|
||||||
log.error("【车辆超时预约】系统自动取消");
|
log.error("【车辆超时预约】系统自动取消");
|
||||||
//订单更新最后预约时间,并结束订单,做超出预约时间标记
|
EtOrder order1 = etOrderService.selectEtOrderByOrderNo(order.getOrderNo());
|
||||||
|
log.info("【定时取消预约】重新获取订单信息:{}",JSON.toJSON(order1));
|
||||||
|
if(order1.getPaid().equals(ServiceConstants.ORDER_PAY_STATUS_PAID)){//已支付订单,跳过
|
||||||
|
log.error("【车辆超时预约】订单已支付,跳过");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.error("【车辆超时预约】订单未支付,系统自动处理");
|
||||||
|
//未支付 订单更新最后预约时间,并结束订单,做超出预约时间标记
|
||||||
order.setStatus(ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT);
|
order.setStatus(ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT);
|
||||||
order.setAppointmentEndTime(new Date());
|
order.setAppointmentEndTime(new Date());
|
||||||
order.setAppointmentTimeout("1");
|
order.setAppointmentTimeout("1");
|
||||||
|
@ -1333,6 +1351,19 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
return asDeviceMapper.update(null,wrapper);
|
return asDeviceMapper.update(null,wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否在线
|
||||||
|
*/
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public boolean isOnline(String sn) {
|
||||||
|
ResponseVo responseVo = sendCommandWithResp(asDeviceMapper.selectAsDeviceBySn(sn).getMac(), Token.getToken(), "111", "是否在线");
|
||||||
|
if(responseVo.getCode() == 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否靠近边界
|
* 判断是否靠近边界
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.ruoyi.common.constant.CacheConstants;
|
import com.ruoyi.common.constant.CacheConstants;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.constant.IotConstants;
|
|
||||||
import com.ruoyi.common.constant.ServiceConstants;
|
import com.ruoyi.common.constant.ServiceConstants;
|
||||||
import com.ruoyi.common.core.domain.entity.AsUser;
|
import com.ruoyi.common.core.domain.entity.AsUser;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
@ -16,7 +15,7 @@ import com.ruoyi.common.pay.wx.domain.NotifyEventType;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.http.HttpUtils;
|
import com.ruoyi.common.utils.http.HttpUtils;
|
||||||
import com.ruoyi.common.utils.onenet.Token;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import com.ruoyi.system.domain.*;
|
import com.ruoyi.system.domain.*;
|
||||||
import com.ruoyi.system.domain.vo.AttachVo;
|
import com.ruoyi.system.domain.vo.AttachVo;
|
||||||
import com.ruoyi.system.mapper.AsDeviceMapper;
|
import com.ruoyi.system.mapper.AsDeviceMapper;
|
||||||
|
@ -40,14 +39,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -165,7 +162,7 @@ public class CallbackServiceImpl implements CallbackService {
|
||||||
if(autoRefundDeposit!=null && autoRefundDeposit>0){
|
if(autoRefundDeposit!=null && autoRefundDeposit>0){
|
||||||
//创建一个定时器,计算出退还时间后,执行退款操作
|
//创建一个定时器,计算出退还时间后,执行退款操作
|
||||||
// 往后推autoRefundDeposit小时执行
|
// 往后推autoRefundDeposit小时执行
|
||||||
scheduledExecutorService.schedule(() -> {
|
// scheduledExecutorService.schedule(() -> {
|
||||||
logger.info("【微信支付回调】退还押金定时任务开始");
|
logger.info("【微信支付回调】退还押金定时任务开始");
|
||||||
// 退款
|
// 退款
|
||||||
Long userId = order.getUserId();
|
Long userId = order.getUserId();
|
||||||
|
@ -182,12 +179,13 @@ public class CallbackServiceImpl implements CallbackService {
|
||||||
.max(Comparator.comparing(EtOrder::getPayTime));
|
.max(Comparator.comparing(EtOrder::getPayTime));
|
||||||
if (latestOrder.isPresent()) {
|
if (latestOrder.isPresent()) {
|
||||||
EtOrder newestOrder = latestOrder.get();
|
EtOrder newestOrder = latestOrder.get();
|
||||||
|
logger.info("【微信支付回调】最后一次押金充值记录 : " + JSON.toJSONString(newestOrder));
|
||||||
// 处理找到的最新支付时间的订单
|
// 处理找到的最新支付时间的订单
|
||||||
String deposit = area.getDeposit();
|
String deposit = area.getDeposit();
|
||||||
if(newestOrder.getTotalFee().compareTo(new BigDecimal(deposit))!=0){
|
if(newestOrder.getTotalFee().compareTo(new BigDecimal(deposit))!=0){
|
||||||
throw new ServiceException("押金充值记录与当前运营区的押金不同");
|
throw new ServiceException("押金充值记录与当前运营区的押金不同");
|
||||||
}
|
}
|
||||||
Refund refund = wxPayService.refund(newestOrder,autoRefundDeposit+"个小时后自动退款", newestOrder.getTotalFee());
|
Refund refund = wxPayService.refund(newestOrder,autoRefundDeposit+"个小时后自动退押金", newestOrder.getTotalFee());
|
||||||
EtRefund refund1= orderService.createRefund(etOrder, newestOrder.getTotalFee(), null, null, null, null, refund,ServiceConstants.REFUND_TYPE_DEPOSIT);
|
EtRefund refund1= orderService.createRefund(etOrder, newestOrder.getTotalFee(), null, null, null, null, refund,ServiceConstants.REFUND_TYPE_DEPOSIT);
|
||||||
int i = etRefundService.insertEtRefund(refund1);
|
int i = etRefundService.insertEtRefund(refund1);
|
||||||
if(i>0){
|
if(i>0){
|
||||||
|
@ -195,10 +193,19 @@ public class CallbackServiceImpl implements CallbackService {
|
||||||
}
|
}
|
||||||
// 新增资金流水记录
|
// 新增资金流水记录
|
||||||
capitalFlowRecords(newestOrder,ServiceConstants.FLOW_TYPE_DISBURSE,ServiceConstants.ORDER_TYPE_DEPOSIT_REFUND);
|
capitalFlowRecords(newestOrder,ServiceConstants.FLOW_TYPE_DISBURSE,ServiceConstants.ORDER_TYPE_DEPOSIT_REFUND);
|
||||||
|
|
||||||
|
// 更新用户信息,清除缓存
|
||||||
|
asUser.setBalance(asUser.getBalance().subtract(newestOrder.getTotalFee()));
|
||||||
|
int updateUser = userService.updateUser(asUser);
|
||||||
|
Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
||||||
|
redisCache.deleteObject(keys);
|
||||||
|
if(updateUser>0){
|
||||||
|
logger.info("【微信支付回调】退还押金,更新用户余额成功!");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceException("没有找到押金充值记录");
|
throw new ServiceException("没有找到押金充值记录");
|
||||||
}
|
}
|
||||||
}, autoRefundDeposit, TimeUnit.HOURS);
|
// }, autoRefundDeposit, TimeUnit.HOURS);
|
||||||
}
|
}
|
||||||
logger.info("=================【微信支付回调】开始请求分账==================");
|
logger.info("=================【微信支付回调】开始请求分账==================");
|
||||||
logger.info("区域对象====="+JSON.toJSONString(area));
|
logger.info("区域对象====="+JSON.toJSONString(area));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user