diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java index 8c08bc5..e95ccfe 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java @@ -601,4 +601,14 @@ public class AppController extends BaseController return success(token); } + /** + * 修复押金抵扣资金流水 + */ + @GetMapping(value = "/repair/deduction") + public AjaxResult repairDeduction(Long areaId) + { + logger.info("【修复押金抵扣请求】:区域id={}",areaId); + return toAjax(etOrderService.repairDeduction(areaId)); + } + } diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java index 3ec1a65..e84de05 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java @@ -1076,6 +1076,25 @@ public class AppVerifyController extends BaseController logger.info("没有orderNo参数:【orderNo={}】",orderNo); return error("请传orderNo号参数"+"【orderNo="+orderNo+"】"); } + //运营时间判断 + if(!asDeviceService.isOperatingTime(newSn)){ + return error("不在营业时间内,不得骑行"); + } + //非正常状态不得骑行 + AsDevice newDevice = asDeviceMapper.selectAsDeviceBySn(newSn); + String status = newDevice.getStatus(); + if(!ServiceConstants.VEHICLE_STATUS_NORMAL.equals(status)){ + return error(CommonUtil.format(status)); + } + // 当前有骑行中的订单 + EtOrder currentOrder = etOrderService.getCurrentOrder(newDevice.getSn()); + if(ObjectUtil.isNotNull(currentOrder)){ + return error("当前车辆有骑行中的订单,请换车"); + } + //低电量不得骑行判断 + if(asDeviceService.isLowBattery(newDevice.getSn())){ + return error("低电量不得骑行"); + } logger.info("【换车开锁请求】:orderNo={},newSn ={}",orderNo,newSn); Boolean aBoolean =etOrderService.changeVehicleLockUnlocking(orderNo,newSn,isBluetooth,lon,lat,voltage); return success(aBoolean); diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java index 6aa3f0f..505a696 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java @@ -289,5 +289,7 @@ public interface EtOrderMapper // BigDecimal getPlatformServiceFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("areaId") Long areaId); - Integer getAppCount(); +// Integer getAppCount(); + + List selectDeductionList(Long areaId); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java index 38d6b77..d6a1ef2 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java @@ -199,6 +199,11 @@ public interface IEtOrderService */ int deduction(EtOrder etOrder); + /** + * 修复押金抵扣 + */ + int repairDeduction(Long areaId); + /** * 还车审核通过 */ 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 e7e884b..f1e6d94 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 @@ -38,6 +38,8 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * 订单Service业务层处理 @@ -464,6 +466,41 @@ public class EtOrderServiceImpl implements IEtOrderService 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; + } + + /** + * 修复押金抵扣 + * 1. 查询所有押金抵扣的订单 + * 2. 如果是骑行费大于押金,则按押金计算, + * 如果骑行费小于押金,则按骑行费计算 + * 3. 增加一条资金流水记录 + */ + @Override + @Transactional + public int repairDeduction(Long areaId) { + List orders = etOrderMapper.selectDeductionList(areaId); + for (EtOrder order : orders) { + // 找出所有骑行费大于押金的订单,把骑行费改成押金 + if(order.getMark().contains("大于")){ + String input = order.getMark(); + // 正则表达式,匹配“押金”后的金额 + String regex = "押金【(\\d+\\.\\d+)】"; + // 编译正则表达式 + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(input); + // 查找匹配项 + if (matcher.find()) { + // 提取金额 + String depositAmount = matcher.group(1); + order.setPayFee(new BigDecimal(depositAmount)); + } + } + /** 押金抵扣后生成资金流水记录 */ + callbackService.capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ); } return 1; } diff --git a/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml b/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml index c46f9e8..0348351 100644 --- a/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml @@ -109,7 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" COALESCE(SUM(CASE WHEN f.type = '2' THEN handling_charge ELSE 0 END), 0) AS net_fee from et_capital_flow f LEFT JOIN et_order o on o.order_no = f.order_no - where f.area_id != 14 and f.bus_type != '5' and f.bus_type != '6' + where f.bus_type != '5' and f.bus_type != '6' and o.sn = #{sn} AND date_format(f.create_time,'%y%m%d') >= date_format(#{timeStart},'%y%m%d') diff --git a/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml b/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml index 7ad6bd6..9df4fbe 100644 --- a/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml @@ -127,6 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and o.type = #{type} and o.status = #{status} and o.paid = #{paid} + and o.pay_type = #{payType} AND date_format(o.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') @@ -597,6 +598,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND o.is_test = '0' + + insert into et_order