From eaa2f4d6a4113c51f5ca6c9f5b9ce46f6507e2a3 Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Mon, 27 May 2024 19:32:10 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/app/AppController.java | 68 ++++++------ .../src/main/resources/application.yml | 3 +- .../java/com/ruoyi/system/domain/EtOrder.java | 4 +- .../com/ruoyi/system/domain/vo/AttachVo.java | 3 +- .../com/ruoyi/system/domain/vo/EtOrderVo.java | 4 +- .../service/impl/AsDeviceServiceImpl.java | 103 +++++++----------- .../service/impl/AsUserServiceImpl.java | 10 +- .../service/impl/CallbackServiceImpl.java | 6 +- .../service/impl/EtOrderServiceImpl.java | 56 ++++------ .../system/service/impl/WxPayService.java | 2 +- .../resources/mapper/system/AsUserMapper.xml | 13 ++- .../resources/mapper/system/EtOrderMapper.xml | 3 +- 12 files changed, 129 insertions(+), 146 deletions(-) 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 3637807..22d9e75 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 @@ -163,40 +163,40 @@ public class AppController extends BaseController return success(etFeeRuleService.selectEtFeeRuleByRuleId(ruleId)); } - /** - * 获取计费规则 多少分钟内 里程数 - */ - @GetMapping(value = "/fee/rule") - public AjaxResult getRule() - { - String appointmentServiceFee = sysConfigService.selectConfigByKey("appointment.service.fee");//预约服务费 - String dispatchFee = sysConfigService.selectConfigByKey("dispatch.fee");//调度费 - String vehicleManagementFee = sysConfigService.selectConfigByKey("vehicle.management.fee");//车辆管理费 - String startingPrice = sysConfigService.selectConfigByKey("starting.price");//起步价 - String startingHowManyMinutes = sysConfigService.selectConfigByKey("starting.how.many.minutes");//多少分钟内按起步价 - String timeFee = sysConfigService.selectConfigByKey("time.fee");//时长费 - String timeMinutes = sysConfigService.selectConfigByKey("time.minutes");//时长分钟 - String timeoutMinutes = sysConfigService.selectConfigByKey("timeout.minutes");//预约超时保留分钟 - String deposit = sysConfigService.selectConfigByKey("deposit");//押金 - String isMeal = sysConfigService.selectConfigByKey("is.meal");//是否有套餐 是否有套餐:0-没有套餐;1-有套餐 - String cappingFee = sysConfigService.selectConfigByKey("order.capping.fee");//24小时内封顶费用 - String forceParkingArea = sysConfigService.selectConfigByKey("force.parking.area");//是否强制在停车区内还车 - FeeRuleVo build = FeeRuleVo.builder() - .appointmentServiceFee(appointmentServiceFee) - .dispatchFee(dispatchFee) - .vehicleManagementFee(vehicleManagementFee) - .startingPrice(startingPrice) - .startingHowManyMinutes(startingHowManyMinutes) - .timeFee(timeFee) - .timeMinutes(timeMinutes) - .timeoutMinutes(timeoutMinutes) - .deposit(deposit) - .isMeal(isMeal) - .cappingFee(cappingFee) - .forceParkingArea(forceParkingArea) - .build(); - return success(build); - } +// /** +// * 获取计费规则 多少分钟内 里程数 +// */ +// @GetMapping(value = "/fee/rule") +// public AjaxResult getRule() +// { +// String appointmentServiceFee = sysConfigService.selectConfigByKey("appointment.service.fee");//预约服务费 +// String dispatchFee = sysConfigService.selectConfigByKey("dispatch.fee");//调度费 +// String vehicleManagementFee = sysConfigService.selectConfigByKey("vehicle.management.fee");//车辆管理费 +// String startingPrice = sysConfigService.selectConfigByKey("starting.price");//起步价 +// String startingHowManyMinutes = sysConfigService.selectConfigByKey("starting.how.many.minutes");//多少分钟内按起步价 +// String timeFee = sysConfigService.selectConfigByKey("time.fee");//时长费 +// String timeMinutes = sysConfigService.selectConfigByKey("time.minutes");//时长分钟 +// String timeoutMinutes = sysConfigService.selectConfigByKey("timeout.minutes");//预约超时保留分钟 +// String deposit = sysConfigService.selectConfigByKey("deposit");//押金 +// String isMeal = sysConfigService.selectConfigByKey("is.meal");//是否有套餐 是否有套餐:0-没有套餐;1-有套餐 +// String cappingFee = sysConfigService.selectConfigByKey("order.capping.fee");//24小时内封顶费用 +// String forceParkingArea = sysConfigService.selectConfigByKey("force.parking.area");//是否强制在停车区内还车 +// FeeRuleVo build = FeeRuleVo.builder() +// .appointmentServiceFee(appointmentServiceFee) +// .dispatchFee(dispatchFee) +// .vehicleManagementFee(vehicleManagementFee) +// .startingPrice(startingPrice) +// .startingHowManyMinutes(startingHowManyMinutes) +// .timeFee(timeFee) +// .timeMinutes(timeMinutes) +// .timeoutMinutes(timeoutMinutes) +// .deposit(deposit) +// .isMeal(isMeal) +// .cappingFee(cappingFee) +// .forceParkingArea(forceParkingArea) +// .build(); +// return success(build); +// } /** diff --git a/electripper-admin/src/main/resources/application.yml b/electripper-admin/src/main/resources/application.yml index 045b7e9..b779bc3 100644 --- a/electripper-admin/src/main/resources/application.yml +++ b/electripper-admin/src/main/resources/application.yml @@ -188,7 +188,8 @@ wx: # apiV3密钥 嵛山岛 yusandaowenlvyusandaowenlvyusand apiV3Key: 49819e0f0abdb2df3246f7b27f264d75 # 通知回调地址 - notifyUrl: https://dianche.chuantewulian.cn/prod-api/payment/callback/wechat/ +# notifyUrl: https://dianche.chuantewulian.cn/prod-api/payment/callback/wechat/ + notifyUrl: http://124.221.246.124:2289/payment/callback/wechat/ # 密钥所在位置 privateKeyPath: D:/wxpay/apiclient_key.pem # 证书序列号 7DDDDEED9A8DF3DD8363E49D636D3F551FFC8A19 diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/EtOrder.java b/electripper-system/src/main/java/com/ruoyi/system/domain/EtOrder.java index 3e4ec1a..31b1e78 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/EtOrder.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/EtOrder.java @@ -163,8 +163,8 @@ public class EtOrder extends BaseEntity * 值为3,则 表示在第三个计费周期内,最终结算费用为:(封顶金额*(周期-1))+骑行费用*/ private Integer cycle; - /** 是否预约 */ - private Boolean isAppointment; +// /** 是否预约 */ +// private Boolean isAppointment; /** 还车类型:type:1-正常还车;2-辅助还车 */ private String returnType; diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/AttachVo.java b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/AttachVo.java index 03bf405..3f4ae40 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/AttachVo.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/AttachVo.java @@ -19,10 +19,9 @@ public class AttachVo { public AttachVo() { } - public AttachVo(String type, Long userId, Boolean isAppointment, String token) { + public AttachVo(String type, Long userId, String token) { this.type = type; this.userId = userId; - this.isAppointment = isAppointment; this.token = token; } diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/EtOrderVo.java b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/EtOrderVo.java index 21db8c4..7b582ed 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/EtOrderVo.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/EtOrderVo.java @@ -31,6 +31,6 @@ public class EtOrderVo { /** 备注 */ private String mark; - /** 是否预约 */ - private Boolean isAppointment; +// /** 是否预约 */ +// private Boolean isAppointment; } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java index 225429d..325619e 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java @@ -436,6 +436,7 @@ public class AsDeviceServiceImpl extends ServiceImpl i */ @SneakyThrows @Override + @Transactional public OrderResponse snSwitch(EtOrderVo orderVo) { OrderResponse response = new OrderResponse(); String orderNo = ""; @@ -465,14 +466,16 @@ public class AsDeviceServiceImpl extends ServiceImpl i EtOrder order = etOrderService.selectEtOrderByOrderNo(finalOrderNo); if(ObjectUtil.isNotNull(order)){//有订单号:可能是套餐也可能是有预约 if(ObjectUtil.isNotNull(order.getRuleId())){//套餐 - log.info("【扫码/编号开锁骑行】---有订单号,是套餐订单"); + log.info("【扫码/编号开锁骑行】---预约扫码骑行"); order.setSn(asDevice.getSn()); }else{ - log.info("【扫码/编号开锁骑行】---有订单号,有预约正常订单"); - order.setAppointmentEndTime(DateUtils.getNowDate()); + throw new ServiceException("ruleId未传"); } order.setStatus(ServiceConstants.ORDER_STATUS_RIDING); order.setUnlockTime(DateUtils.getNowDate()); + order.setAppointmentEndTime(DateUtils.getNowDate()); + //计算预约费 + calculateAppointmentFee(order); int update = etOrderService.updateEtOrder(order); if(update==0){ log.info("【扫码/编号开锁骑行】更新订单失败"); @@ -508,7 +511,6 @@ public class AsDeviceServiceImpl extends ServiceImpl i @Override public Boolean unlocking(String sn) { AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn); - /** TODO 响铃寻车*/ /** 1.获取token*/ String token = Token.getToken(); Boolean execute = transactionTemplate.execute(e -> { @@ -777,32 +779,17 @@ public class AsDeviceServiceImpl extends ServiceImpl i OrderResponse orderResponse = new OrderResponse(); String orderNo = IdUtils.randomUUID2(); AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(appointmentVo.getSn()); - //如果是套餐 则预约功能相当于临时锁车 - if(ObjectUtil.isNotNull(appointmentVo.getRuleId())){ - //临时锁车并更新车辆状态 -// macSwitch(asDevice.getMac()); - EtOrder order = etOrderService.selectEtOrderByOrderNo(appointmentVo.getOrderNo()); - order.setStatus(ServiceConstants.ORDER_STATUS_IN_APPOINTMENT); - order.setSn(appointmentVo.getSn()); - int i = etOrderService.updateEtOrder(order); - if(i==0){ - throw new ServiceException("【车辆预约】:更新订单失败"); - } - orderResponse.setSessionId(IdUtils.randomUUIDByDigit(8)); - }else{ - //如果是正常计费模式,则按正常的订单走 - EtOrder order = etOrderService.createOrder(appointmentVo, orderNo); - int i = etOrderService.insertEtOrder(order); - if(i==0){ - throw new ServiceException("【车辆预约】:创建订单失败"); - } - orderResponse.setOrderNo(orderNo); - orderResponse.setSessionId(IdUtils.randomUUIDByDigit(8)); - return orderResponse; - } - asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_APPOINTMENT); - int i = asDeviceMapper.updateAsDevice(asDevice); + //如果是正常计费模式,则按正常的订单走 + EtOrder order = etOrderService.createOrder(appointmentVo, orderNo); + int i = etOrderService.insertEtOrder(order); if(i==0){ + throw new ServiceException("【车辆预约】:创建订单失败"); + } + orderResponse.setOrderNo(orderNo); + orderResponse.setSessionId(IdUtils.randomUUIDByDigit(8)); + asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_APPOINTMENT); + int u = asDeviceMapper.updateAsDevice(asDevice); + if(u==0){ throw new ServiceException("【车辆预约】:更新车辆状态失败"); } return orderResponse; @@ -821,25 +808,20 @@ public class AsDeviceServiceImpl extends ServiceImpl i OrderResponse orderResponse = new OrderResponse(); String orderNo = appointmentVo.getOrderNo(); EtOrder order = etOrderService.selectEtOrderByOrderNo(orderNo); - //如果是套餐 则取消预约相当于开锁 - if(ObjectUtil.isNotNull(appointmentVo.getRuleId())){ - //1.发送开锁命令并更新车辆状态 - String token = Token.getToken(); - sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"取消预约开锁"); - order.setSn(""); - //TODO 记录行程 - /** 5.记录行程*/ - int tripLog = tripLogService.tripLog(order.getOrderNo(),order.getSn(),ServiceConstants.TRIP_LOG_TYPE_UNLOCK_RIDE); - if(tripLog==0){ - log.info("【套餐取消预约】记录行程失败"); - throw new ServiceException("【套餐取消预约】记录行程失败"); - } - }else{ - //更新订单状态 status 为 ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT 记录预约结束时间,计算并更新预约费 - order.setAppointmentEndTime(DateUtils.getNowDate()); - //计算预约费 - calculateAppointmentFee(order); + //1.发送开锁命令并更新车辆状态 + String token = Token.getToken(); + sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_CLOSE,"取消预约关锁"); + /** 5.记录行程*/ + int tripLog = tripLogService.tripLog(order.getOrderNo(),order.getSn(),ServiceConstants.TRIP_LOG_TYPE_UNLOCK_RIDE); + if(tripLog==0){ + log.info("【套餐取消预约】记录行程失败"); + throw new ServiceException("【套餐取消预约】记录行程失败"); } + //更新订单状态 status 为 ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT 记录预约结束时间,计算并更新预约费 + order.setAppointmentEndTime(DateUtils.getNowDate()); + //计算预约费 + calculateAppointmentFee(order); + order.setTotalFee(order.getAppointmentFee()); order.setStatus(ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT); int i = etOrderService.updateEtOrder(order); if(i==0){ @@ -912,10 +894,10 @@ public class AsDeviceServiceImpl extends ServiceImpl i order.setStatus(ServiceConstants.ORDER_STATUS_RIDING_END); order.setReturnTime(DateUtils.getNowDate()); String token = Token.getToken(); - /** 2. 车辆远程关锁*/ - sendCommand(order.getSn(), token,IotConstants.COMMAND_CLOSE,"还车关锁"); - /** 4. 更新车辆状态*/ AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn()); + /** 2. 车辆远程关锁*/ +// sendCommand(device.getMac(), token,IotConstants.COMMAND_CLOSE,"还车关锁"); + /** 4. 更新车辆状态*/ device.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL); device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); int deviceUpdate = asDeviceMapper.updateAsDevice(device); @@ -924,11 +906,7 @@ public class AsDeviceServiceImpl extends ServiceImpl i throw new ServiceException("【还车关锁】更新车辆状态失败"); } /** 3. 计算订单费用,保存订单总金额*/ - if(ObjectUtil.isNotNull(order.getRuleId())){//套餐订单 - order.setSn(""); - }else{ - order = calculateOrderFee(order); - } + order = calculateOrderFee(order); int i = etOrderService.updateEtOrder(order); if(i==0){ throw new ServiceException("更新订单状态失败"); @@ -952,12 +930,12 @@ public class AsDeviceServiceImpl extends ServiceImpl i private EtOrder calculateOrderFee(EtOrder order) { String type = order.getType(); if(type.equals("1")){//骑行订单,正常骑行(包含预约费),计时收费,根据开锁时间、起步价和起步时长、时长费和时长分钟等参数,如果有预约,还要加上预约费计算费用,还要判断封顶费用(根据开锁时间) - /** 预约费*/ - Date appointmentStartTime = order.getAppointmentStartTime(); - if(ObjectUtils.isNotEmpty(appointmentStartTime)){ - //有预约,根据开始时间和结束时间计算费用 预约费 = (预约结束时间 - 开始时间) * 预约服务费 - calculateAppointmentFee(order); - } +// /** 预约费*/ +// Date appointmentStartTime = order.getAppointmentStartTime(); +// if(ObjectUtils.isNotEmpty(appointmentStartTime)){ +// //有预约,根据开始时间和结束时间计算费用 预约费 = (预约结束时间 - 开始时间) * 预约服务费 +// calculateAppointmentFee(order); +// } Long ruleId = order.getRuleId(); EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleId(ruleId); String rentalUnit = rule.getRentalUnit();//租赁单位 @@ -1152,6 +1130,9 @@ public class AsDeviceServiceImpl extends ServiceImpl i // 将毫秒差转换为小时 long hours = TimeUnit.MILLISECONDS.toHours(diffInMillies); + if(hours==0){ + return 1; + } // 计算出在第几个计费周期中 BigDecimal cycle = BigDecimal.valueOf(hours).divide(new BigDecimal(chargingCycleValue), 0, RoundingMode.CEILING); return cycle.intValue(); diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java index 7f4d7d4..4b41240 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java @@ -12,10 +12,12 @@ import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.common.utils.bean.BeanValidators; import com.ruoyi.common.utils.verify.VerifyIdentityUtil; +import com.ruoyi.system.domain.EtOperatingArea; import com.ruoyi.system.domain.EtOrder; import com.ruoyi.system.domain.vo.AuthenticationVo; import com.ruoyi.system.mapper.AsUserMapper; import com.ruoyi.system.service.IAsUserService; +import com.ruoyi.system.service.IEtOperatingAreaService; import com.ruoyi.system.service.IEtOrderService; import com.ruoyi.system.service.ISysConfigService; import org.slf4j.Logger; @@ -53,7 +55,7 @@ public class AsUserServiceImpl implements IAsUserService private IEtOrderService etOrderService; @Autowired - private ISysConfigService sysConfigService; + private IEtOperatingAreaService etOperatingAreaService; @Value("${et.verifyUrl}") private String verifyUrl; @@ -432,13 +434,13 @@ public class AsUserServiceImpl implements IAsUserService public Boolean checkIsDeposit(Long userId) { AsUser asUser = asUserMapper.selectUserById(userId); BigDecimal balance = asUser.getBalance(); - String deposit = sysConfigService.selectConfigByKey("deposit");//押金 + EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asUser.getAreaId()); + BigDecimal deposit = new BigDecimal(area.getDeposit()); if(ObjectUtil.isNull(balance)){ log.info("用户【{}】余额为空",userId); return false; } - BigDecimal bigDecimal = new BigDecimal(deposit); - if(balance.compareTo(BigDecimal.ZERO)==0 || balance.compareTo(bigDecimal)<0){//余额为0或者押金和余额不相等 + if(balance.compareTo(BigDecimal.ZERO)==0 || balance.compareTo(deposit)<0){//余额为0或者押金和余额不相等 log.info("用户【{}】余额为0或者押金小于余额不相等",userId); return false; } 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 f55cb77..3895680 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 @@ -130,7 +130,7 @@ public class CallbackServiceImpl implements CallbackService { // 1-骑行支付 关锁 order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END); order.setMark("骑行支付"); - asDeviceService.sendCommand(order.getSn(), iotToken, IotConstants.COMMAND_OPEN,"套餐开锁"); + asDeviceService.sendCommand(asDevice.getMac(), iotToken, IotConstants.COMMAND_OPEN,"套餐开锁"); asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);//还车后车辆正常运营 asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); @@ -200,7 +200,7 @@ public class CallbackServiceImpl implements CallbackService { order.setAppointmentStartTime(DateUtils.getNowDate()); order.setMark("套餐预约支付"); /** 2.发送命令*/ - asDeviceService.sendCommand(order.getSn(), iotToken,IotConstants.COMMAND_CLOSE,"套餐预约"); + asDeviceService.sendCommand(asDevice.getMac(), iotToken,IotConstants.COMMAND_CLOSE,"套餐预约"); /** 3.更新车辆状态*/ asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_APPOINTMENT);//预约中 asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); @@ -209,7 +209,7 @@ public class CallbackServiceImpl implements CallbackService { order.setMark("套餐骑行支付"); order.setStatus(ServiceConstants.ORDER_STATUS_RIDING);//骑行中 /** 2.发送命令*/ - asDeviceService.sendCommand(order.getSn(), iotToken,IotConstants.COMMAND_OPEN,"套餐开锁"); + asDeviceService.sendCommand(asDevice.getMac(), iotToken,IotConstants.COMMAND_OPEN,"套餐开锁"); /** 3.更新车辆状态*/ asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN); asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING); 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 773a446..471fc14 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 @@ -387,13 +387,13 @@ public class EtOrderServiceImpl implements IEtOrderService /** 1.获取token*/ String token = Token.getToken(); AsDevice asDevice = asDeviceService.selectAsDeviceBySn(order.getSn()); - if(order.getIsAppointment()){//购买完套餐后 预约车辆 +// if(order.getIsAppointment()){//购买完套餐后 预约车辆 etOrder.setStatus(ServiceConstants.ORDER_STATUS_IN_APPOINTMENT); etOrder.setAppointmentStartTime(DateUtils.getNowDate()); //校验 userI,sn,ruleId,type 3 isAppointment Boolean execute = transactionTemplate.execute(e -> { /** 2.发送命令*/ - deviceService.sendCommand(order.getSn(), token, IotConstants.COMMAND_CLOSE,"套餐预约"); + deviceService.sendCommand(asDevice.getMac(), token, IotConstants.COMMAND_CLOSE,"套餐预约"); /** 3.更新车辆状态*/ asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_TEMPORARILY_LOCK);//临时锁车 asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN); @@ -406,24 +406,24 @@ public class EtOrderServiceImpl implements IEtOrderService return Boolean.TRUE; }); if(!execute)throw new ServiceException("套餐预约失败"); - }else{//购买完套餐后 立即开锁骑行 - etOrder.setStatus(ServiceConstants.ORDER_STATUS_RIDING); - Boolean execute = transactionTemplate.execute(e -> { - /** 2.发送命令*/ - deviceService.sendCommand(order.getSn(), token,IotConstants.COMMAND_OPEN,"套餐开锁"); - /** 3.更新车辆状态*/ - asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN); - asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING_STR); - int device = asDeviceService.updateAsDevice(asDevice); - if(device==0){ - log.info("【套餐开锁】更新车辆状态失败"); - return Boolean.FALSE; - } - log.info("套餐开锁成功"); - return Boolean.TRUE; - }); - if(!execute)throw new ServiceException("套餐开锁失败"); - } +// }else{//购买完套餐后 立即开锁骑行 +// etOrder.setStatus(ServiceConstants.ORDER_STATUS_RIDING); +// Boolean execute = transactionTemplate.execute(e -> { +// /** 2.发送命令*/ +// deviceService.sendCommand(order.getSn(), token,IotConstants.COMMAND_OPEN,"套餐开锁"); +// /** 3.更新车辆状态*/ +// asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN); +// asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING_STR); +// int device = asDeviceService.updateAsDevice(asDevice); +// if(device==0){ +// log.info("【套餐开锁】更新车辆状态失败"); +// return Boolean.FALSE; +// } +// log.info("套餐开锁成功"); +// return Boolean.TRUE; +// }); +// if(!execute)throw new ServiceException("套餐开锁失败"); +// } int i = etOrderMapper.insertEtOrder(etOrder); if(i == 0){ throw new ServiceException("订单生成失败"); @@ -479,6 +479,7 @@ public class EtOrderServiceImpl implements IEtOrderService etOrder.setUserName(user.getUserName()); etOrder.setMark(order.getMark()); etOrder.setCreateTime(DateUtils.getNowDate()); + etOrder.setRuleId(order.getRuleId()); /** 订单类型 1骑行 2预约 3套餐 4押金 根据类型不同下单的参数也不同,不同的参数有: 金额、类型、rule_id(套餐id)*/ String type = order.getType(); if(type.equals("1")){//骑行订单,正常骑行(包含预约费),计时收费,根据开锁时间、起步价和起步时长、时长费和时长分钟等参数,如果有预约,还要加上预约费计算费用 @@ -491,20 +492,11 @@ public class EtOrderServiceImpl implements IEtOrderService etOrder.setType(ServiceConstants.ORDER_TYPE_RIDING); etOrder.setStatus(ServiceConstants.ORDER_STATUS_IN_APPOINTMENT);//预约中 etOrder.setAppointmentStartTime(DateUtils.getNowDate());//预约开始时间 - }else if(order.getType().equals("3")){//套餐,创建初始订单,根据计费规则id(rule_id)和支付时间,计算费用 在订单表中通过是否有rule_id字段,来判断是否是套餐订单 - setAreaInfo(order.getSn(), etOrder); - Long ruleId = order.getRuleId(); - EtFeeRule etFeeRule = etFeeRuleService.selectEtFeeRuleByRuleId(ruleId); - etOrder.setRuleId(ruleId); -// etOrder.setTotalFee(etFeeRule.getFee()); - etOrder.setType(ServiceConstants.ORDER_TYPE_RIDING); - etOrder.setStatus(ServiceConstants.ORDER_STATUS_RIDING); - etOrder.setIsAppointment(order.getIsAppointment()); }else if(order.getType().equals("4")){//押金,创建初始订单,根据计费规则,结算费用, etOrder.setType(ServiceConstants.ORDER_TYPE_DEPOSIT); -// etOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END); - String deposit = sysConfigService.selectConfigByKey("deposit");//押金 - etOrder.setTotalFee(new BigDecimal(deposit)); + EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(user.getAreaId()); + BigDecimal deposit = new BigDecimal(area.getDeposit()); + etOrder.setTotalFee(deposit); }else { throw new ServiceException("订单类型错误"); } 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 2f6ef47..fe85f4d 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 @@ -100,7 +100,7 @@ public class WxPayService implements IWxPayService { String description = type.equals(ServiceConstants.ORDER_TYPE_RIDING) ? "骑行订单-"+billNo : "押金充值-"+billNo; LoginUser loginUser = SecurityUtils.getLoginUser(); log.info("【预下单】获取登录用户信息:"+JSON.toJSONString(loginUser)); - request.setAttach(JSON.toJSONString(new AttachVo(payType,user.getUserId(),order.getIsAppointment(), loginUser.getToken()))); + request.setAttach(JSON.toJSONString(new AttachVo(payType,user.getUserId(), loginUser.getToken()))); request.setDescription(description); request.setNotifyUrl(wxPayConfig.getNotifyUrl()); request.setPayer(getPayer(user.getWxopenid())); diff --git a/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml b/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml index aed4d7e..8532057 100644 --- a/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml @@ -31,15 +31,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - select u.user_id, u.user_name, u.real_name, u.id_card, u.nick_name, u.email, u.avatar, u.phonenumber, u.balance, u.birthday, u.password, u.pay_password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.wxopenid,u.is_sign,u.role,u.sys_user_id + select u.user_id, u.user_name, u.real_name, u.id_card, u.nick_name, u.email, u.avatar, + u.phonenumber, u.balance, u.birthday, u.password, u.pay_password, u.sex, u.status, + u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.wxopenid, + u.is_sign,u.role,u.sys_user_id,u.area_id from et_user u