Compare commits

...

3 Commits

Author SHA1 Message Date
a9a4a36b8a 1. 优化 2024-08-05 22:22:13 +08:00
6bff182276 1. 禁行区不上电 2024-08-03 21:23:26 +08:00
293c3e580b 1. 关闭无订单关锁 2024-08-03 17:33:37 +08:00
6 changed files with 59 additions and 45 deletions

View File

@ -79,8 +79,6 @@ public class ReceiveController {
private final Object lock = new Object();
private boolean lockCommandSent = false; // 添加标志变量
/**
* 功能描述第三方平台数据接收<p>
@ -265,16 +263,18 @@ public class ReceiveController {
// 判断该车辆是否在进行中的订单,并且车辆的锁状态是关状态是骑行中
Boolean inOrderBySn = etOrderService.isInOrderBySn(device.getSn());
if (inOrderBySn && ServiceConstants.VEHICLE_STATUS_IN_USING.equals(device.getStatus()) && ServiceConstants.LOCK_STATUS_CLOSE.equals(device.getLockStatus())) { // 有正在骑行的订单给车辆上电
log.info("返回营运区上电,有正在骑行的订单,给车辆上电--SN" + device.getSn());
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "返回营运区上电",null,null);
// 更新车辆状态和锁状态
/** 3.更新车辆状态*/
device.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
device.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
device.setIsAdminUnlocking("0");
int i1 = asDeviceService.updateAsDevice(device);
if(i1>1){
log.info("【返回营运区上电】更新车辆状态成功");
if(!noRidingArea){
log.info("返回营运区上电,有正在骑行的订单,给车辆上电--SN" + device.getSn());
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "返回营运区上电",null,null);
// 更新车辆状态和锁状态
/** 3.更新车辆状态*/
device.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
device.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
device.setIsAdminUnlocking("0");
int i1 = asDeviceService.updateAsDevice(device);
if(i1>1){
log.info("【返回营运区上电】更新车辆状态成功");
}
}
}
}
@ -299,16 +299,9 @@ public class ReceiveController {
// 优化轨迹如果获取到的定位与最后一个定位相同则不添加
optimizeRoute(jsonArray, newPoint,lon,lat,etOrder);
// 重置关锁命令发送标志
lockCommandSent = false;
}else{
//当前无订单并且不是管理员开锁的情况下直接关锁
if(!isAdminUnlocking.equals("1")){
if (!lockCommandSent) { // 如果未发送过关锁命令
log.info("当前无订单,并且不是管理员开锁的情况下,直接关锁--------" + logEntry.getDevName());
asDeviceService.sendCommand(asDevice.getMac(), Token.getToken(), IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "无订单关锁", null, null, msg);
lockCommandSent = true; // 设置标志为已发送
}
if(ServiceConstants.LOCK_STATUS_CLOSE.equals(device.getLockStatus())){
asDeviceService.sendCommand(asDevice.getMac(), Token.getToken(), IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "车辆锁同步关锁", null, null, msg);
}
}
}

View File

@ -13,12 +13,14 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.EtCapitalFlow;
import com.ruoyi.system.domain.EtWithdraw;
import com.ruoyi.system.service.IEtCapitalFlowService;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;
/**
@ -37,6 +39,9 @@ public class EtCapitalFlowController extends BaseController
@Autowired
private ISysDeptService deptService;
@Autowired
private ISysConfigService sysConfigService;
/**
* 查询资金流水列表
*/
@ -117,6 +122,11 @@ public class EtCapitalFlowController extends BaseController
if(ObjectUtil.isNull(deptId)){
deptId = getDeptId();
}
String minimumWithdrawalAmount = sysConfigService.selectConfigByKey("minimum.withdrawal.amount");//最低提现金额
BigDecimal minimum = new BigDecimal(minimumWithdrawalAmount);
if(etWithdraw.getAmount().compareTo(minimum) < 0){
throw new RuntimeException("最低提现金额不能小于"+minimum);
}
SysDept sysDept = deptService.selectDeptById(deptId);
String method = etWithdraw.getMethod();
if(method.equals(ServiceConstants.WITHDRAW_METHOD_WX)){

View File

@ -180,6 +180,9 @@ public class AsDevice extends BaseEntityPlus implements Serializable {
/** 是否是管理员开锁0-否1-是(用于控制运营区外是否断电判断) */
private String isAdminUnlocking;
// /** 是否已经发送过无订单关锁命令0-否1-是 */
// private String isLocked;
/** 正在进行中的订单 */
@TableField(exist = false)
private List<EtOrder> etOrders;

View File

@ -82,6 +82,10 @@ public class EtOrder extends BaseEntity
@TableField(exist = false)
private EtRefund etRefund;
/** 退款对象 */
@TableField(exist = false)
private List<EtRefund> etRefunds;
/** 设备sn编码 */
@Excel(name = "设备sn编码")
private String sn;

View File

@ -1584,9 +1584,11 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
device.setLastTime(DateUtils.getNowDate());
}
}else{
ResponseVo responseVo = sendCommandWithResp(device.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "辅助还车关锁",orderNo);
if(responseVo.getCode()!=0){
log.info("【还车关锁】远程关锁失败");
if(ObjectUtil.isNotNull(device)){
ResponseVo responseVo = sendCommandWithResp(device.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "辅助还车关锁",orderNo);
if(responseVo.getCode()!=0){
log.info("【还车关锁】远程关锁失败");
}
}
}
/** 4. 更新车辆状态*/

View File

@ -143,7 +143,7 @@ public class EtOrderServiceImpl implements IEtOrderService
// 退款记录
List<EtRefund> refunds = etRefundService.selectEtRefundByOrderNo(order.getOrderNo());
if(ObjectUtils.isNotEmpty(refunds) && refunds.size() > 0){
order.setEtRefund(refunds.get(0));
order.setEtRefunds(refunds);
}
return order;
}
@ -441,26 +441,28 @@ public class EtOrderServiceImpl implements IEtOrderService
if(updateEtOrder1 == 0){
throw new ServiceException("押金抵扣失败,更新押金订单失败");
}
/** 退款剩余押金*/
Refund refund = wxPayService.refund(depositOrder, "押金抵扣退款",afterDeductionFee,IdUtils.getOrderNo("ref"));
/** 2.记录退款表 创建退款对象*/
depositOrder.setReason("押金抵扣退款");
EtRefund refund1= createRefund(depositOrder, afterDeductionFee, null, null, null, null, refund.getOutRefundNo(),ServiceConstants.REFUND_TYPE_DEPOSIT);
int i = etRefundService.insertEtRefund(refund1);
if(i == 0){
log.info("【押金抵扣】保存退款对象失败");
throw new ServiceException("【押金抵扣】,保存退款对象失败");
}
/** 更新用户余额*/
AsUser asUser = asUserService.selectUserById(depositOrder.getUserId());
if(asUser!=null){
// 更新用户并更新缓存
asUser.setBalance(BigDecimal.ZERO);
if (asUserService.updateUserProfile(asUser) > 0)
{
log.info("【押金抵扣成功】更新用户信息成功:"+ JSON.toJSON(asUser));
}else{
throw new ServiceException("【押金抵扣】,更新用户信息失败");
if(afterDeductionFee.compareTo(BigDecimal.ZERO) > 0){
/** 退款剩余押金*/
Refund refund = wxPayService.refund(depositOrder, "押金抵扣退款",afterDeductionFee,IdUtils.getOrderNo("ref"));
/** 2.记录退款表 创建退款对象*/
depositOrder.setReason("押金抵扣退款");
EtRefund refund1= createRefund(depositOrder, afterDeductionFee, null, null, null, null, refund.getOutRefundNo(),ServiceConstants.REFUND_TYPE_DEPOSIT);
int i = etRefundService.insertEtRefund(refund1);
if(i == 0){
log.info("【押金抵扣】保存退款对象失败");
throw new ServiceException("【押金抵扣】,保存退款对象失败");
}
/** 更新用户余额*/
AsUser asUser = asUserService.selectUserById(depositOrder.getUserId());
if(asUser!=null){
// 更新用户并更新缓存
asUser.setBalance(BigDecimal.ZERO);
if (asUserService.updateUserProfile(asUser) > 0)
{
log.info("【押金抵扣成功】更新用户信息成功:"+ JSON.toJSON(asUser));
}else{
throw new ServiceException("【押金抵扣】,更新用户信息失败");
}
}
}
return 1;