1. 调整

This commit is contained in:
邱贞招 2024-09-03 08:53:47 +08:00
parent 59c308668a
commit 91da8794ed
2 changed files with 37 additions and 32 deletions

View File

@ -8,11 +8,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.constant.*;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.CommonUtil;
import com.ruoyi.common.utils.DateUtils;
@ -110,13 +108,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
private IEtOnlineLogService etOnlineLogService;
@Autowired
private IEtRefundService etRefundService;
@Resource
private IAsUserService asUserService;
@Autowired
private CallbackService callbackService;
private RedisCache redisCache;
@Autowired
private ISysConfigService sysConfigService;
@ -209,12 +201,22 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
if(ObjectUtil.isNotNull(model)){
asDevice.setModel(model.getModel());
}
// if(StrUtil.isNotBlank(asDevice.getLongitude()) && StrUtil.isNotBlank(asDevice.getLatitude())){
// asDevice.setLocation(CommonUtil.getAddressByGeo(asDevice.getLongitude() + ","+asDevice.getLatitude()));
// }
if(StrUtil.isNotBlank(asDevice.getVoltage())){
asDevice.setRemainingMileage(CommonUtil.getRemainingMileage(asDevice.getVoltage(),model.getFullVoltage(),model.getLowVoltage(),model.getFullEndurance()));
}
String msg = redisCache.getCacheObject(CacheConstants.CACHE_DEVICE_KEY + asDevice.getSn());
if(StrUtil.isNotBlank(msg)){
log.info("【根据sn号查询车辆实时信息】-========redis缓存中的数据" + msg);
LogEntry logEntry = JSONObject.parseObject(msg, LogEntry.class);
log.info("【根据sn号查询车辆实时信息】============logEntry转换后的对象: logEntry---【{}】" , JSON.toJSONString(logEntry));
LogEntry.LocationValue value = logEntry.getValue();
// 坐标转换 WGS84 GCJ02
double[] doubles = CommonUtil.coordinateConvert(value.getLon(),value.getLat());
BigDecimal lon = new BigDecimal(doubles[1]).setScale(8, RoundingMode.HALF_UP);
BigDecimal lat = new BigDecimal(doubles[0]).setScale(8, RoundingMode.HALF_UP);
asDevice.setLongitude(lon.toString());
asDevice.setLatitude(lat.toString());
}
//正在进行中的订单
EtOrder order = new EtOrder();
order.setSn(asDevice.getSn());

View File

@ -472,6 +472,7 @@ public class EtOrderServiceImpl implements IEtOrderService
log.info("【押金抵扣】订单【{}】,有outTradeNo = 【{}】", order.getOrderNo(),outTradeNo);
// 如果原来有outtradeno去查询一次查询是否支付过
Transaction transaction = wxPayService.queryOrderByOutTradeNo(outTradeNo);
try {
if (Transaction.TradeStateEnum.SUCCESS.equals(transaction.getTradeState())) {
// 订单已支付
order.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
@ -479,22 +480,24 @@ public class EtOrderServiceImpl implements IEtOrderService
order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
order.setPayType(ServiceConstants.PAY_TYPE_WX);
order.setMark("主动查询-骑行支付");
try {
int updateEtOrder = etOrderMapper.updateEtOrder(order);
int updateEtOrder = etOrderMapper.updateEtOrderByOrderNo(order);
if (updateEtOrder == 0) {
// 抛出自定义异常来标识订单更新失败
throw new ServiceException("押金抵扣失败,更新骑行订单失败");
}
} finally {
// 无论订单更新是否成功一定抛出异常来终止后续操作
throw new ServiceException("订单已支付,请勿操作");
}
return 1;
}else{
SysDept dept = wxPayService.getDeptObjByAreaId(order.getAreaId());
// 没有支付则关闭订单
boolean b = wxPayService.closeOrder(outTradeNo, dept);
log.info("【押金抵扣】订单【{}】,有outTradeNo = 【{}】,查询订单未支付,关闭订单:{}", order.getOrderNo(),outTradeNo,b);
}
} catch (ServiceException e) {
log.error("异常发生: {}", e.getMessage());
return -1; // -1 表示失败
} finally {
log.warn("订单已支付,请勿操作");
}
}
EtOrder depositOrder = getDepositOrder(order.getUserId());
BigDecimal deposit = depositOrder.getTotalFee();
@ -1924,7 +1927,7 @@ public class EtOrderServiceImpl implements IEtOrderService
Boolean execute = transactionTemplate.execute(e -> {
/** 2.发送命令*/
if(!"true".equals(isBluetooth)){
ResponseVo responseVo = asDeviceService.sendCommandWithResp(newDevice.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "换车开锁",orderNo);
ResponseVo responseVo = asDeviceService.sendCommandWithResp(newDevice.getMac(), token, IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "换车开锁",orderNo);
if(responseVo.getCode()!=0){
log.info("【换车开锁】远程关锁失败");
throw new ServiceException("换车开锁失败");