This commit is contained in:
邱贞招 2025-01-03 13:52:04 +08:00
parent 64de90a7f6
commit fa7f3d2fb4
5 changed files with 31 additions and 10 deletions

View File

@ -261,7 +261,15 @@ public class AppVerifyController extends BaseController
if(asDeviceService.isLowBattery(order.getSn())){ if(asDeviceService.isLowBattery(order.getSn())){
return error("低电量不得骑行"); return error("低电量不得骑行");
} }
OrderResponse orderResponse =asDeviceService.snSwitch(order); OrderResponse orderResponse;
// 加锁
ServiceUtil.assertion(!redisLock.lock(RedisLockKey.SNSWITCH, order.getSn()), "当前车辆使用人数较多,请稍后再试!");
try {
orderResponse =asDeviceService.snSwitch(order);
} finally {
// 解锁
redisLock.unlock(RedisLockKey.SNSWITCH, order.getSn());
}
return success(orderResponse); return success(orderResponse);
} }
@ -705,9 +713,9 @@ public class AppVerifyController extends BaseController
* 所有车辆定位 * 所有车辆定位
*/ */
@GetMapping(value = "/allVehicleInfo") @GetMapping(value = "/allVehicleInfo")
public AjaxResult allVehicleInfo(String powerStart,String powerEnd, String status,String sort,String areaId,String onlineStatus) public AjaxResult allVehicleInfo(String powerStart,String powerEnd, String status,String sort,String areaId,String onlineStatus,String typeSort)
{ {
List<AsDevice> asDevices = asDeviceService.allVehicleInfo(powerStart,powerEnd,status,sort,areaId,onlineStatus); List<AsDevice> asDevices = asDeviceService.allVehicleInfo(powerStart,powerEnd,status,sort,areaId,onlineStatus,typeSort);
return success(asDevices); return success(asDevices);
} }

View File

@ -13,7 +13,8 @@ public enum RedisLockKey {
DEDUCTION("deduction", "押金抵扣"), DEDUCTION("deduction", "押金抵扣"),
EDITPRICE("editPrice", "改价"), EDITPRICE("editPrice", "改价"),
PAYCALLBACK("payCallback", "支付回调"); PAYCALLBACK("payCallback", "支付回调"),
SNSWITCH("snSwitch", "扫码开锁");
private final String key; private final String key;
private final String name; private final String name;

View File

@ -170,7 +170,7 @@ public interface IAsDeviceService extends IService<AsDevice>
/** /**
* 所有车辆定位 * 所有车辆定位
*/ */
List<AsDevice> allVehicleInfo(String powerStart, String powerEnd, String status,String sort,String areaId,String onlineStatus); List<AsDevice> allVehicleInfo(String powerStart, String powerEnd, String status,String sort,String areaId,String onlineStatus,String typeSort);
/** /**
* 查询车辆数量 * 查询车辆数量

View File

@ -719,7 +719,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
* 所有车辆定位 * 所有车辆定位
*/ */
@Override @Override
public List<AsDevice> allVehicleInfo(String powerStart, String powerEnd, String status,String sort,String areaId,String onlineStatus) { public List<AsDevice> allVehicleInfo(String powerStart, String powerEnd, String status,String sort,String areaId,String onlineStatus,String typeSort) {
QueryWrapper<AsDevice> wrapper = new QueryWrapper<>(); QueryWrapper<AsDevice> wrapper = new QueryWrapper<>();
if(StrUtil.isNotBlank(areaId)){ if(StrUtil.isNotBlank(areaId)){
wrapper.eq("area_id",areaId); wrapper.eq("area_id",areaId);
@ -737,9 +737,17 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
if(StrUtil.isNotBlank(onlineStatus)){ if(StrUtil.isNotBlank(onlineStatus)){
wrapper.in("online_status",onlineStatus); wrapper.in("online_status",onlineStatus);
} }
if(StrUtil.isNotBlank(sort)){ if(StrUtil.isNotBlank(typeSort)){
if(StrUtil.equals(typeSort,"1")){
wrapper.orderBy(true,!StrUtil.equals(sort, "desc"),"sn");
}else if(StrUtil.equals(typeSort,"2")){
wrapper.orderBy(true,!StrUtil.equals(sort, "desc"),"model_id");
}else if(StrUtil.equals(typeSort,"3")){
wrapper.orderBy(true,!StrUtil.equals(sort, "desc"),"vehicle_num");
}else{
wrapper.orderBy(true,!StrUtil.equals(sort, "desc"),"remaining_power"); wrapper.orderBy(true,!StrUtil.equals(sort, "desc"),"remaining_power");
} }
}
List<AsDevice> asDevices = asDeviceMapper.selectList(wrapper); List<AsDevice> asDevices = asDeviceMapper.selectList(wrapper);
for (AsDevice asDevice:asDevices){ for (AsDevice asDevice:asDevices){
Long modelId = asDevice.getModelId(); Long modelId = asDevice.getModelId();

View File

@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alipay.api.response.AlipayTradeRefundResponse; import com.alipay.api.response.AlipayTradeRefundResponse;
import com.aliyuncs.exceptions.ClientException;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.ServiceConstants; import com.ruoyi.common.constant.ServiceConstants;
@ -488,8 +489,11 @@ public class WxPayService implements IWxPayService {
request.setNotifyUrl(channelVO.getRefundNotifyUrl()); request.setNotifyUrl(channelVO.getRefundNotifyUrl());
log.info("【退款】请求微信参数:【{}】",JSON.toJSONString(request)); log.info("【退款】请求微信参数:【{}】",JSON.toJSONString(request));
RefundService refundService = getRefundService(channelVO); RefundService refundService = getRefundService(channelVO);
Refund refund = refundService.create(request); try {
log.info("【退款】微信返回结果:【{}】",JSON.toJSONString(refund)); refundService.create(request);
} catch (com.wechat.pay.java.core.exception.ServiceException e) {
throw new ServiceException("【退款】微信退款失败:" + e.getErrorMessage());
}
}else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){ }else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){
log.info("----------{}-------------","太米微信退款"); log.info("----------{}-------------","太米微信退款");
RefundAble refundAble = new RefundAble(); RefundAble refundAble = new RefundAble();