1. 调整

This commit is contained in:
邱贞招 2024-08-15 20:34:29 +08:00
parent 37f9e8eae1
commit 666628f3e0
8 changed files with 61 additions and 61 deletions

View File

@ -113,6 +113,7 @@ public class ReceiveController {
BodyObj obj = Util.resolveBody(body, false); BodyObj obj = Util.resolveBody(body, false);
log.info("receive方法解析对象: body Object --- " + JSON.toJSONString(obj)); log.info("receive方法解析对象: body Object --- " + JSON.toJSONString(obj));
log.info("接收到receive方法时间: " + System.currentTimeMillis()); log.info("接收到receive方法时间: " + System.currentTimeMillis());
/** */
// 起一个异步线程处理数据 // 起一个异步线程处理数据
scheduledExecutorService.schedule(() -> { scheduledExecutorService.schedule(() -> {
new Thread(() -> { new Thread(() -> {
@ -246,44 +247,19 @@ public class ReceiveController {
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY2, "距离禁行区30米内",null,null); asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY2, "距离禁行区30米内",null,null);
} }
} }
/** 3. 判断是否在运营区外 /** 3.超出运营区外断电*/
* a. 判断是否在缩短后的运营区边界内 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")){
* 不靠近判断是否在运营区外
*
**/
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){ // 是否在超出运营区边界多少米内
//在20米范围内发报警 //在20米范围内发报警
log.info("超出运营区"+exceedDistance+"米内发送警告命令--SN" + device.getSn()); log.info("超出运营区30米内发送警告命令--SN" + device.getSn());
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "超出运营区"+exceedDistance+"米内",null,null); asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "超出运营区30米内",null,null);
}else{ }else{
// 超出运营区外断电 //超出运营区外断电
String areaOutOutage = area.getAreaOutOutage(); String areaOutOutage = area.getAreaOutOutage();
if (areaOutOutage.equals("1")) { // 超出营运区断电 if (areaOutOutage.equals("1") && value.getStatus() != 3 && !isAdminUnlocking.equals("1")) { // 超出营运区断电
log.info("超出营运区断电命令--SN" + device.getSn()); log.info("超出营运区断电命令--SN" + device.getSn());
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "超出营运区断电",null,null); asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "超出营运区断电",null,null);
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
@ -294,7 +270,8 @@ public class ReceiveController {
} }
} }
}else{ }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 (inOrderBySn && ServiceConstants.VEHICLE_STATUS_IN_USING.equals(device.getStatus()) && ServiceConstants.LOCK_STATUS_CLOSE.equals(device.getLockStatus())) { // 有正在骑行的订单给车辆上电
if(!noRidingArea){ if(!noRidingArea){
log.info("返回营运区上电,有正在骑行的订单,给车辆上电--SN" + device.getSn()); log.info("返回营运区上电,有正在骑行的订单,给车辆上电--SN" + device.getSn());

View File

@ -146,7 +146,7 @@ public class SysLoginController
/**通过手机号找到用户名*/ /**通过手机号找到用户名*/
String phone = loginBody.getPhone(); 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); ajax.put(Constants.TOKEN, token);
return ajax; return ajax;
} }

View File

@ -47,6 +47,19 @@ public class LoginBody
*/ */
private String areaId; private String areaId;
/**
* openid
*/
private String openid;
public String getOpenid() {
return openid;
}
public void setOpenid(String openid) {
this.openid = openid;
}
public String getAreaId() { public String getAreaId() {
return areaId; return areaId;
} }

View File

@ -359,7 +359,7 @@ public class SysLoginService
return openId; 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); AsUser user = asUserService.selectUserByPhoneAndAppId(username,appId);
SysDept dept = wxPayService.getDeptObjByAreaId(Long.parseLong(areaId)); SysDept dept = wxPayService.getDeptObjByAreaId(Long.parseLong(areaId));
log.info("【微信登录/wxlogin】获取到运营商对象【{}】", JSON.toJSON(dept)); log.info("【微信登录/wxlogin】获取到运营商对象【{}】", JSON.toJSON(dept));
@ -370,6 +370,7 @@ public class SysLoginService
asUser.setPhonenumber(username); asUser.setPhonenumber(username);
asUser.setLoginIp(IpUtils.getIpAddr()); asUser.setLoginIp(IpUtils.getIpAddr());
asUser.setLoginDate(DateUtils.getNowDate()); asUser.setLoginDate(DateUtils.getNowDate());
asUser.setWxopenid(openid);
asUser.setCreateTime(DateUtils.getNowDate()); asUser.setCreateTime(DateUtils.getNowDate());
asUser.setAreaId(areaId); asUser.setAreaId(areaId);
if(dept.getIsUsePlatformApp().equals("true")){ if(dept.getIsUsePlatformApp().equals("true")){
@ -383,6 +384,7 @@ public class SysLoginService
int i = asUserService.insertUser(asUser); int i = asUserService.insertUser(asUser);
user = asUser; user = asUser;
}else{ }else{
user.setWxopenid(openid);
if(dept.getIsUsePlatformApp().equals("true")){ if(dept.getIsUsePlatformApp().equals("true")){
user.setAppName("创享电动车"); user.setAppName("创享电动车");
user.setAppId(dept.getAppid()); user.setAppId(dept.getAppid());

View File

@ -729,13 +729,13 @@ public class CallbackServiceImpl implements CallbackService {
logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============合伙人分账partnerDividend====================="+partnerDividend); logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============合伙人分账partnerDividend====================="+partnerDividend);
if(type.equals(ServiceConstants.FLOW_TYPE_INCOME)){ if(type.equals(ServiceConstants.FLOW_TYPE_INCOME)){
capitalFlow.setPartnerDividend(partnerDividend); capitalFlow.setPartnerDividend(partnerDividend);
capitalFlow.setOperatorDividend(BigDecimal.ZERO); capitalFlow.setOperatorDividend(order.getPayFee());
capitalFlow.setOperatorBalance(user.getBalance().add(partnerDividend)); capitalFlow.setOperatorBalance(user.getBalance().add(partnerDividend));
userMapper.changeUserBalance(partnerDividend,user.getUserId()); userMapper.changeUserBalance(partnerDividend,user.getUserId());
logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============收入====================="); logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============收入=====================");
}else{ }else{
capitalFlow.setPartnerDividend(partnerDividend.negate()); capitalFlow.setPartnerDividend(partnerDividend.negate());
capitalFlow.setOperatorDividend(BigDecimal.ZERO); capitalFlow.setOperatorDividend(order.getPayFee());
capitalFlow.setOperatorBalance(user.getBalance().subtract(partnerDividend)); capitalFlow.setOperatorBalance(user.getBalance().subtract(partnerDividend));
userMapper.changeUserBalance(partnerDividend.negate(),user.getUserId()); userMapper.changeUserBalance(partnerDividend.negate(),user.getUserId());
logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============支出====================="); logger.info("【微信支付回调(合伙人)--保存资金流水记录】 ==============支出=====================");

View File

@ -452,21 +452,21 @@ public class EtOrderServiceImpl implements IEtOrderService
log.info("【押金抵扣】保存退款对象失败"); log.info("【押金抵扣】保存退款对象失败");
throw new ServiceException("【押金抵扣】,保存退款对象失败"); 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; return 1;
} }
@ -1503,9 +1503,13 @@ public class EtOrderServiceImpl implements IEtOrderService
if(ServiceConstants.ORDER_PAY_STATUS_NON_PAYMENT.equals(etOrder1.getPaid())){ if(ServiceConstants.ORDER_PAY_STATUS_NON_PAYMENT.equals(etOrder1.getPaid())){
throw new ServiceException("订单未支付,不能退款"); throw new ServiceException("订单未支付,不能退款");
} }
if(dividendDetailService.isDividendComputedByOrderNo(etOrder.getOrderNo())){ // 根据分账明细退款
throw new ServiceException("订单【{}】已经分账,不能退款"); // if(dividendDetailService.isDividendComputedByOrderNo(etOrder.getOrderNo())){
} // throw new ServiceException("订单【{}】已经分账,不能退款");
// }
// 根据分账明细查询
List<EtDividendDetail> etDividendDetails = dividendDetailService.selectEtDividendDetailByOrderNo(etOrder.getOrderNo());
// boolean dividendComputedByOrderNo = dividendDetailService.isDividendComputedByOrderNo(etOrder.getOrderNo());
SysDept sysDept = wxPayService.getDeptObjByAreaId(etOrder1.getAreaId()); SysDept sysDept = wxPayService.getDeptObjByAreaId(etOrder1.getAreaId());
BigDecimal subtract = sysDept.getBalance().subtract(etOrder1.getTotalFee()); BigDecimal subtract = sysDept.getBalance().subtract(etOrder1.getTotalFee());
if(subtract.compareTo(BigDecimal.ZERO) <= 0 && sysDept.getSeparateAccount().equals("N")){ if(subtract.compareTo(BigDecimal.ZERO) <= 0 && sysDept.getSeparateAccount().equals("N")){

View File

@ -1,15 +1,14 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.SysDept; 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.core.redis.RedisLock;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.domain.EtAreaDept; import com.ruoyi.system.domain.EtAreaDept;
import com.ruoyi.system.domain.EtOrder; import com.ruoyi.system.domain.EtOrder;
@ -106,7 +105,12 @@ public class WxPayService implements IWxPayService {
// 获取JSAPI所需参数 // 获取JSAPI所需参数
PrepayRequest request = new PrepayRequest(); PrepayRequest request = new PrepayRequest();
request.setAmount(getAmount(order.getPayFee())); 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.setOutTradeNo(outTradeNo);
order.setLocking("1"); order.setLocking("1");
int updateEtOrder = etOrderService.updateEtOrder(order); int updateEtOrder = etOrderService.updateEtOrder(order);

View File

@ -99,7 +99,7 @@ public class EtTask {
log.info("=========================启动业务处理========================="); log.info("=========================启动业务处理=========================");
log.info("=========================开始========================="); log.info("=========================开始=========================");
/** 1.启动时判断是否有未取消预约的订单*/ /** 1.启动时判断是否有未取消预约的订单*/
uncancelledAppointmentHandle(); // uncancelledAppointmentHandle();
/** 2.判断已完成的订单未退还押金的(根据et_refund表中的refund_result结果判断是否已经退款) */ /** 2.判断已完成的订单未退还押金的(根据et_refund表中的refund_result结果判断是否已经退款) */
/** 找出所有已完成的订单 status=4 type = 1 r.refund_result IS NULL /** 找出所有已完成的订单 status=4 type = 1 r.refund_result IS NULL