From 666628f3e0c333e04d75424467aa9c80d8b75516 Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Thu, 15 Aug 2024 20:34:29 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/receive/ReceiveController.java | 49 +++++-------------- .../controller/system/SysLoginController.java | 2 +- .../common/core/domain/model/LoginBody.java | 13 +++++ .../web/service/SysLoginService.java | 4 +- .../service/impl/CallbackServiceImpl.java | 4 +- .../service/impl/EtOrderServiceImpl.java | 38 +++++++------- .../system/service/impl/WxPayService.java | 10 ++-- .../java/com/ruoyi/system/task/EtTask.java | 2 +- 8 files changed, 61 insertions(+), 61 deletions(-) diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java index dc05566..927e057 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java @@ -113,6 +113,7 @@ public class ReceiveController { BodyObj obj = Util.resolveBody(body, false); log.info("receive方法解析对象: body Object --- " + JSON.toJSONString(obj)); log.info("接收到receive方法时间: " + System.currentTimeMillis()); + /** */ // 起一个异步线程处理数据 scheduledExecutorService.schedule(() -> { new Thread(() -> { @@ -246,44 +247,19 @@ public class ReceiveController { asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY2, "距离禁行区30米内",null,null); } } - /** 3. 判断是否在运营区外 - * a. 判断是否在缩短后的运营区边界内 - * 如果在,走 返回营运区上电 逻辑 - * 如果不在, - * 判断是否靠近运营区边界 - * 靠近,播报 - * 不靠近,判断是否在运营区外 - * - **/ - String nearBoundaryDistanceConfig = sysConfigService.selectConfigByKey("near.boundary.distance");// 靠近运营区边界时的播报距离 - log.info("靠近运营区边界时的播报距离==================:" + nearBoundaryDistanceConfig); - double nearBoundaryDistance = Double.parseDouble(nearBoundaryDistanceConfig); - String exceedArea = sysConfigService.selectConfigByKey("exceed.area.distance");// 超出运营区外断电距离 - log.info("超出运营区外断电距离================:" + exceedArea); - int exceedDistance = Integer.parseInt(exceedArea); - - // 创建多边形对象 - Geometry polygon = GeoUtils.fromWkt(area.getBoundary()); - - // 判断该车辆是否在进行中的订单,并且车辆的锁状态是关,状态是骑行中 - Boolean inOrderBySn = etOrderService.isInOrderBySn(device.getSn()); - // 是否在缩短后的运营区边界内 - boolean inPolygonWithTolerance = GeoUtils.isInPolygonWithShorten(lon.toString(), lat.toString(), polygon, nearBoundaryDistance); - if(!inPolygonWithTolerance && !isAdminUnlocking.equals("1") && inOrderBySn){//如果正在骑行中,并且不是管理员开锁,并且在不缩短后的运营区域内 没有在缩短后的运营区边界内 - boolean inPolygonWithTolerance1 = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), polygon, 0);// 是否在运营区内 - boolean isNearBoundary = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), polygon, exceedDistance ); - if(inPolygonWithTolerance1){//是否在运营区边界内 - // 在靠近运营区边界时发警报 - log.info("靠近运营区边界发警告命令--SN:" + device.getSn()); - asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY2, "靠近运营区边界", null, null); - }else if(isNearBoundary){ // 是否在超出运营区边界多少米内 + /** 3.超出运营区外断电*/ + boolean isAreaZone = asDeviceService.isAreaZone(device.getSn(), area); + if(!isAreaZone){ + //是否在30米范围内 + boolean inPolygon = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), GeoUtils.fromWkt(area.getBoundary()), 60); + if(inPolygon && !isAdminUnlocking.equals("1")){ //在20米范围内,发报警 - log.info("超出运营区"+exceedDistance+"米内发送警告命令--SN:" + device.getSn()); - asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "超出运营区"+exceedDistance+"米内",null,null); + log.info("超出运营区30米内发送警告命令--SN:" + device.getSn()); + asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "超出运营区30米内",null,null); }else{ - // 超出运营区外断电 + //超出运营区外断电 String areaOutOutage = area.getAreaOutOutage(); - if (areaOutOutage.equals("1")) { // 超出营运区断电 + if (areaOutOutage.equals("1") && value.getStatus() != 3 && !isAdminUnlocking.equals("1")) { // 超出营运区断电 log.info("超出营运区断电命令--SN:" + device.getSn()); asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "超出营运区断电",null,null); device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); @@ -294,7 +270,8 @@ public class ReceiveController { } } }else{ - // 在运营区域内 + // 判断该车辆是否在进行中的订单,并且车辆的锁状态是关,状态是骑行中 + Boolean inOrderBySn = etOrderService.isInOrderBySn(device.getSn()); if (inOrderBySn && ServiceConstants.VEHICLE_STATUS_IN_USING.equals(device.getStatus()) && ServiceConstants.LOCK_STATUS_CLOSE.equals(device.getLockStatus())) { // 有正在骑行的订单,给车辆上电 if(!noRidingArea){ log.info("返回营运区上电,有正在骑行的订单,给车辆上电--SN:" + device.getSn()); diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index 7642af3..ac1bae9 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -146,7 +146,7 @@ public class SysLoginController /**通过手机号找到用户名*/ String phone = loginBody.getPhone(); // 生成令牌 - String token = loginService.appCodeLogin(phone, loginBody.getPhoneCode(),loginBody.getPassword(), loginBody.getUuid(), loginBody.getAreaId()); + String token = loginService.appCodeLogin(phone, loginBody.getPhoneCode(),loginBody.getPassword(), loginBody.getUuid(), loginBody.getAreaId(), loginBody.getOpenid()); ajax.put(Constants.TOKEN, token); return ajax; } diff --git a/electripper-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java b/electripper-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java index 56ff295..548764b 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java +++ b/electripper-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java @@ -47,6 +47,19 @@ public class LoginBody */ private String areaId; + /** + * openid + */ + private String openid; + + public String getOpenid() { + return openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } + public String getAreaId() { return areaId; } diff --git a/electripper-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/electripper-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index cd5d297..bfa26a3 100644 --- a/electripper-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/electripper-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -359,7 +359,7 @@ public class SysLoginService return openId; } - public String appCodeLogin(String username, String code, String password, String uuid,String areaId) { + public String appCodeLogin(String username, String code, String password, String uuid,String areaId,String openid) { AsUser user = asUserService.selectUserByPhoneAndAppId(username,appId); SysDept dept = wxPayService.getDeptObjByAreaId(Long.parseLong(areaId)); log.info("【微信登录/wxlogin】获取到运营商对象:【{}】", JSON.toJSON(dept)); @@ -370,6 +370,7 @@ public class SysLoginService asUser.setPhonenumber(username); asUser.setLoginIp(IpUtils.getIpAddr()); asUser.setLoginDate(DateUtils.getNowDate()); + asUser.setWxopenid(openid); asUser.setCreateTime(DateUtils.getNowDate()); asUser.setAreaId(areaId); if(dept.getIsUsePlatformApp().equals("true")){ @@ -383,6 +384,7 @@ public class SysLoginService int i = asUserService.insertUser(asUser); user = asUser; }else{ + user.setWxopenid(openid); if(dept.getIsUsePlatformApp().equals("true")){ user.setAppName("创享电动车"); user.setAppId(dept.getAppid()); diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java index 48d11f6..cf8a794 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java @@ -729,13 +729,13 @@ public class CallbackServiceImpl implements CallbackService { logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============合伙人分账partnerDividend=====================:"+partnerDividend); if(type.equals(ServiceConstants.FLOW_TYPE_INCOME)){ capitalFlow.setPartnerDividend(partnerDividend); - capitalFlow.setOperatorDividend(BigDecimal.ZERO); + capitalFlow.setOperatorDividend(order.getPayFee()); capitalFlow.setOperatorBalance(user.getBalance().add(partnerDividend)); userMapper.changeUserBalance(partnerDividend,user.getUserId()); logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============收入=====================:"); }else{ capitalFlow.setPartnerDividend(partnerDividend.negate()); - capitalFlow.setOperatorDividend(BigDecimal.ZERO); + capitalFlow.setOperatorDividend(order.getPayFee()); capitalFlow.setOperatorBalance(user.getBalance().subtract(partnerDividend)); userMapper.changeUserBalance(partnerDividend.negate(),user.getUserId()); logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============支出=====================:"); diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java index 83d1311..749f756 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java @@ -452,21 +452,21 @@ public class EtOrderServiceImpl implements IEtOrderService 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("【押金抵扣】,更新用户信息失败"); - } - } - /** 押金抵扣后生成资金流水记录 */ - callbackService.capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ); } + /** 更新用户余额*/ + 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("【押金抵扣】,更新用户信息失败"); + } + } + /** 押金抵扣后生成资金流水记录 */ + callbackService.capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ); return 1; } @@ -1503,9 +1503,13 @@ public class EtOrderServiceImpl implements IEtOrderService if(ServiceConstants.ORDER_PAY_STATUS_NON_PAYMENT.equals(etOrder1.getPaid())){ throw new ServiceException("订单未支付,不能退款"); } - if(dividendDetailService.isDividendComputedByOrderNo(etOrder.getOrderNo())){ - throw new ServiceException("订单【{}】已经分账,不能退款"); - } + // 根据分账明细退款 +// if(dividendDetailService.isDividendComputedByOrderNo(etOrder.getOrderNo())){ +// throw new ServiceException("订单【{}】已经分账,不能退款"); +// } + // 根据分账明细查询 + List etDividendDetails = dividendDetailService.selectEtDividendDetailByOrderNo(etOrder.getOrderNo()); +// boolean dividendComputedByOrderNo = dividendDetailService.isDividendComputedByOrderNo(etOrder.getOrderNo()); SysDept sysDept = wxPayService.getDeptObjByAreaId(etOrder1.getAreaId()); BigDecimal subtract = sysDept.getBalance().subtract(etOrder1.getTotalFee()); if(subtract.compareTo(BigDecimal.ZERO) <= 0 && sysDept.getSeparateAccount().equals("N")){ diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java index cfecb4e..d50ab9d 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java @@ -1,15 +1,14 @@ package com.ruoyi.system.service.impl; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.common.constant.ServiceConstants; import com.ruoyi.common.core.domain.entity.AsUser; import com.ruoyi.common.core.domain.entity.SysDept; -import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.redis.RedisLock; import com.ruoyi.common.exception.ServiceException; -import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.domain.EtAreaDept; import com.ruoyi.system.domain.EtOrder; @@ -106,7 +105,12 @@ public class WxPayService implements IWxPayService { // 获取JSAPI所需参数 PrepayRequest request = new PrepayRequest(); request.setAmount(getAmount(order.getPayFee())); - String outTradeNo = IdUtils.getOrderNo("wx"); + String outTradeNo; + if(StrUtil.isBlank(order.getOutTradeNo())){ + outTradeNo = IdUtils.getOrderNo("wx"); + }else{ + outTradeNo = order.getOutTradeNo(); + } order.setOutTradeNo(outTradeNo); order.setLocking("1"); int updateEtOrder = etOrderService.updateEtOrder(order); diff --git a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java index 05e054f..37cfdc9 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java +++ b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java @@ -99,7 +99,7 @@ public class EtTask { log.info("=========================启动业务处理========================="); log.info("=========================开始========================="); /** 1.启动时判断是否有未取消预约的订单*/ - uncancelledAppointmentHandle(); +// uncancelledAppointmentHandle(); /** 2.判断已完成的订单未退还押金的(根据et_refund表中的refund_result结果判断是否已经退款) */ /** ①找出所有已完成的订单 status=4 type = 1 r.refund_result IS NULL