1.联调
This commit is contained in:
parent
56030b9d41
commit
eaa2f4d6a4
|
@ -163,40 +163,40 @@ public class AppController extends BaseController
|
||||||
return success(etFeeRuleService.selectEtFeeRuleByRuleId(ruleId));
|
return success(etFeeRuleService.selectEtFeeRuleByRuleId(ruleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 获取计费规则 多少分钟内 里程数
|
// * 获取计费规则 多少分钟内 里程数
|
||||||
*/
|
// */
|
||||||
@GetMapping(value = "/fee/rule")
|
// @GetMapping(value = "/fee/rule")
|
||||||
public AjaxResult getRule()
|
// public AjaxResult getRule()
|
||||||
{
|
// {
|
||||||
String appointmentServiceFee = sysConfigService.selectConfigByKey("appointment.service.fee");//预约服务费
|
// String appointmentServiceFee = sysConfigService.selectConfigByKey("appointment.service.fee");//预约服务费
|
||||||
String dispatchFee = sysConfigService.selectConfigByKey("dispatch.fee");//调度费
|
// String dispatchFee = sysConfigService.selectConfigByKey("dispatch.fee");//调度费
|
||||||
String vehicleManagementFee = sysConfigService.selectConfigByKey("vehicle.management.fee");//车辆管理费
|
// String vehicleManagementFee = sysConfigService.selectConfigByKey("vehicle.management.fee");//车辆管理费
|
||||||
String startingPrice = sysConfigService.selectConfigByKey("starting.price");//起步价
|
// String startingPrice = sysConfigService.selectConfigByKey("starting.price");//起步价
|
||||||
String startingHowManyMinutes = sysConfigService.selectConfigByKey("starting.how.many.minutes");//多少分钟内按起步价
|
// String startingHowManyMinutes = sysConfigService.selectConfigByKey("starting.how.many.minutes");//多少分钟内按起步价
|
||||||
String timeFee = sysConfigService.selectConfigByKey("time.fee");//时长费
|
// String timeFee = sysConfigService.selectConfigByKey("time.fee");//时长费
|
||||||
String timeMinutes = sysConfigService.selectConfigByKey("time.minutes");//时长分钟
|
// String timeMinutes = sysConfigService.selectConfigByKey("time.minutes");//时长分钟
|
||||||
String timeoutMinutes = sysConfigService.selectConfigByKey("timeout.minutes");//预约超时保留分钟
|
// String timeoutMinutes = sysConfigService.selectConfigByKey("timeout.minutes");//预约超时保留分钟
|
||||||
String deposit = sysConfigService.selectConfigByKey("deposit");//押金
|
// String deposit = sysConfigService.selectConfigByKey("deposit");//押金
|
||||||
String isMeal = sysConfigService.selectConfigByKey("is.meal");//是否有套餐 是否有套餐:0-没有套餐;1-有套餐
|
// String isMeal = sysConfigService.selectConfigByKey("is.meal");//是否有套餐 是否有套餐:0-没有套餐;1-有套餐
|
||||||
String cappingFee = sysConfigService.selectConfigByKey("order.capping.fee");//24小时内封顶费用
|
// String cappingFee = sysConfigService.selectConfigByKey("order.capping.fee");//24小时内封顶费用
|
||||||
String forceParkingArea = sysConfigService.selectConfigByKey("force.parking.area");//是否强制在停车区内还车
|
// String forceParkingArea = sysConfigService.selectConfigByKey("force.parking.area");//是否强制在停车区内还车
|
||||||
FeeRuleVo build = FeeRuleVo.builder()
|
// FeeRuleVo build = FeeRuleVo.builder()
|
||||||
.appointmentServiceFee(appointmentServiceFee)
|
// .appointmentServiceFee(appointmentServiceFee)
|
||||||
.dispatchFee(dispatchFee)
|
// .dispatchFee(dispatchFee)
|
||||||
.vehicleManagementFee(vehicleManagementFee)
|
// .vehicleManagementFee(vehicleManagementFee)
|
||||||
.startingPrice(startingPrice)
|
// .startingPrice(startingPrice)
|
||||||
.startingHowManyMinutes(startingHowManyMinutes)
|
// .startingHowManyMinutes(startingHowManyMinutes)
|
||||||
.timeFee(timeFee)
|
// .timeFee(timeFee)
|
||||||
.timeMinutes(timeMinutes)
|
// .timeMinutes(timeMinutes)
|
||||||
.timeoutMinutes(timeoutMinutes)
|
// .timeoutMinutes(timeoutMinutes)
|
||||||
.deposit(deposit)
|
// .deposit(deposit)
|
||||||
.isMeal(isMeal)
|
// .isMeal(isMeal)
|
||||||
.cappingFee(cappingFee)
|
// .cappingFee(cappingFee)
|
||||||
.forceParkingArea(forceParkingArea)
|
// .forceParkingArea(forceParkingArea)
|
||||||
.build();
|
// .build();
|
||||||
return success(build);
|
// return success(build);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -188,7 +188,8 @@ wx:
|
||||||
# apiV3密钥 嵛山岛 yusandaowenlvyusandaowenlvyusand
|
# apiV3密钥 嵛山岛 yusandaowenlvyusandaowenlvyusand
|
||||||
apiV3Key: 49819e0f0abdb2df3246f7b27f264d75
|
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
|
privateKeyPath: D:/wxpay/apiclient_key.pem
|
||||||
# 证书序列号 7DDDDEED9A8DF3DD8363E49D636D3F551FFC8A19
|
# 证书序列号 7DDDDEED9A8DF3DD8363E49D636D3F551FFC8A19
|
||||||
|
|
|
@ -163,8 +163,8 @@ public class EtOrder extends BaseEntity
|
||||||
* 值为3,则 表示在第三个计费周期内,最终结算费用为:(封顶金额*(周期-1))+骑行费用*/
|
* 值为3,则 表示在第三个计费周期内,最终结算费用为:(封顶金额*(周期-1))+骑行费用*/
|
||||||
private Integer cycle;
|
private Integer cycle;
|
||||||
|
|
||||||
/** 是否预约 */
|
// /** 是否预约 */
|
||||||
private Boolean isAppointment;
|
// private Boolean isAppointment;
|
||||||
|
|
||||||
/** 还车类型:type:1-正常还车;2-辅助还车 */
|
/** 还车类型:type:1-正常还车;2-辅助还车 */
|
||||||
private String returnType;
|
private String returnType;
|
||||||
|
|
|
@ -19,10 +19,9 @@ public class AttachVo {
|
||||||
public 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.type = type;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.isAppointment = isAppointment;
|
|
||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,6 @@ public class EtOrderVo {
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
private String mark;
|
private String mark;
|
||||||
|
|
||||||
/** 是否预约 */
|
// /** 是否预约 */
|
||||||
private Boolean isAppointment;
|
// private Boolean isAppointment;
|
||||||
}
|
}
|
||||||
|
|
|
@ -436,6 +436,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
*/
|
*/
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public OrderResponse snSwitch(EtOrderVo orderVo) {
|
public OrderResponse snSwitch(EtOrderVo orderVo) {
|
||||||
OrderResponse response = new OrderResponse();
|
OrderResponse response = new OrderResponse();
|
||||||
String orderNo = "";
|
String orderNo = "";
|
||||||
|
@ -465,14 +466,16 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
EtOrder order = etOrderService.selectEtOrderByOrderNo(finalOrderNo);
|
EtOrder order = etOrderService.selectEtOrderByOrderNo(finalOrderNo);
|
||||||
if(ObjectUtil.isNotNull(order)){//有订单号:可能是套餐也可能是有预约
|
if(ObjectUtil.isNotNull(order)){//有订单号:可能是套餐也可能是有预约
|
||||||
if(ObjectUtil.isNotNull(order.getRuleId())){//套餐
|
if(ObjectUtil.isNotNull(order.getRuleId())){//套餐
|
||||||
log.info("【扫码/编号开锁骑行】---有订单号,是套餐订单");
|
log.info("【扫码/编号开锁骑行】---预约扫码骑行");
|
||||||
order.setSn(asDevice.getSn());
|
order.setSn(asDevice.getSn());
|
||||||
}else{
|
}else{
|
||||||
log.info("【扫码/编号开锁骑行】---有订单号,有预约正常订单");
|
throw new ServiceException("ruleId未传");
|
||||||
order.setAppointmentEndTime(DateUtils.getNowDate());
|
|
||||||
}
|
}
|
||||||
order.setStatus(ServiceConstants.ORDER_STATUS_RIDING);
|
order.setStatus(ServiceConstants.ORDER_STATUS_RIDING);
|
||||||
order.setUnlockTime(DateUtils.getNowDate());
|
order.setUnlockTime(DateUtils.getNowDate());
|
||||||
|
order.setAppointmentEndTime(DateUtils.getNowDate());
|
||||||
|
//计算预约费
|
||||||
|
calculateAppointmentFee(order);
|
||||||
int update = etOrderService.updateEtOrder(order);
|
int update = etOrderService.updateEtOrder(order);
|
||||||
if(update==0){
|
if(update==0){
|
||||||
log.info("【扫码/编号开锁骑行】更新订单失败");
|
log.info("【扫码/编号开锁骑行】更新订单失败");
|
||||||
|
@ -508,7 +511,6 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
@Override
|
@Override
|
||||||
public Boolean unlocking(String sn) {
|
public Boolean unlocking(String sn) {
|
||||||
AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn);
|
AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn);
|
||||||
/** TODO 响铃寻车*/
|
|
||||||
/** 1.获取token*/
|
/** 1.获取token*/
|
||||||
String token = Token.getToken();
|
String token = Token.getToken();
|
||||||
Boolean execute = transactionTemplate.execute(e -> {
|
Boolean execute = transactionTemplate.execute(e -> {
|
||||||
|
@ -777,32 +779,17 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
OrderResponse orderResponse = new OrderResponse();
|
OrderResponse orderResponse = new OrderResponse();
|
||||||
String orderNo = IdUtils.randomUUID2();
|
String orderNo = IdUtils.randomUUID2();
|
||||||
AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(appointmentVo.getSn());
|
AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(appointmentVo.getSn());
|
||||||
//如果是套餐 则预约功能相当于临时锁车
|
//如果是正常计费模式,则按正常的订单走
|
||||||
if(ObjectUtil.isNotNull(appointmentVo.getRuleId())){
|
EtOrder order = etOrderService.createOrder(appointmentVo, orderNo);
|
||||||
//临时锁车并更新车辆状态
|
int i = etOrderService.insertEtOrder(order);
|
||||||
// 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);
|
|
||||||
if(i==0){
|
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("【车辆预约】:更新车辆状态失败");
|
throw new ServiceException("【车辆预约】:更新车辆状态失败");
|
||||||
}
|
}
|
||||||
return orderResponse;
|
return orderResponse;
|
||||||
|
@ -821,25 +808,20 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
OrderResponse orderResponse = new OrderResponse();
|
OrderResponse orderResponse = new OrderResponse();
|
||||||
String orderNo = appointmentVo.getOrderNo();
|
String orderNo = appointmentVo.getOrderNo();
|
||||||
EtOrder order = etOrderService.selectEtOrderByOrderNo(orderNo);
|
EtOrder order = etOrderService.selectEtOrderByOrderNo(orderNo);
|
||||||
//如果是套餐 则取消预约相当于开锁
|
//1.发送开锁命令并更新车辆状态
|
||||||
if(ObjectUtil.isNotNull(appointmentVo.getRuleId())){
|
String token = Token.getToken();
|
||||||
//1.发送开锁命令并更新车辆状态
|
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_CLOSE,"取消预约关锁");
|
||||||
String token = Token.getToken();
|
/** 5.记录行程*/
|
||||||
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"取消预约开锁");
|
int tripLog = tripLogService.tripLog(order.getOrderNo(),order.getSn(),ServiceConstants.TRIP_LOG_TYPE_UNLOCK_RIDE);
|
||||||
order.setSn("");
|
if(tripLog==0){
|
||||||
//TODO 记录行程
|
log.info("【套餐取消预约】记录行程失败");
|
||||||
/** 5.记录行程*/
|
throw new ServiceException("【套餐取消预约】记录行程失败");
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
//更新订单状态 status 为 ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT 记录预约结束时间,计算并更新预约费
|
||||||
|
order.setAppointmentEndTime(DateUtils.getNowDate());
|
||||||
|
//计算预约费
|
||||||
|
calculateAppointmentFee(order);
|
||||||
|
order.setTotalFee(order.getAppointmentFee());
|
||||||
order.setStatus(ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT);
|
order.setStatus(ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT);
|
||||||
int i = etOrderService.updateEtOrder(order);
|
int i = etOrderService.updateEtOrder(order);
|
||||||
if(i==0){
|
if(i==0){
|
||||||
|
@ -912,10 +894,10 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
order.setStatus(ServiceConstants.ORDER_STATUS_RIDING_END);
|
order.setStatus(ServiceConstants.ORDER_STATUS_RIDING_END);
|
||||||
order.setReturnTime(DateUtils.getNowDate());
|
order.setReturnTime(DateUtils.getNowDate());
|
||||||
String token = Token.getToken();
|
String token = Token.getToken();
|
||||||
/** 2. 车辆远程关锁*/
|
|
||||||
sendCommand(order.getSn(), token,IotConstants.COMMAND_CLOSE,"还车关锁");
|
|
||||||
/** 4. 更新车辆状态*/
|
|
||||||
AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn());
|
AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn());
|
||||||
|
/** 2. 车辆远程关锁*/
|
||||||
|
// sendCommand(device.getMac(), token,IotConstants.COMMAND_CLOSE,"还车关锁");
|
||||||
|
/** 4. 更新车辆状态*/
|
||||||
device.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
|
device.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
|
||||||
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
||||||
int deviceUpdate = asDeviceMapper.updateAsDevice(device);
|
int deviceUpdate = asDeviceMapper.updateAsDevice(device);
|
||||||
|
@ -924,11 +906,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
throw new ServiceException("【还车关锁】更新车辆状态失败");
|
throw new ServiceException("【还车关锁】更新车辆状态失败");
|
||||||
}
|
}
|
||||||
/** 3. 计算订单费用,保存订单总金额*/
|
/** 3. 计算订单费用,保存订单总金额*/
|
||||||
if(ObjectUtil.isNotNull(order.getRuleId())){//套餐订单
|
order = calculateOrderFee(order);
|
||||||
order.setSn("");
|
|
||||||
}else{
|
|
||||||
order = calculateOrderFee(order);
|
|
||||||
}
|
|
||||||
int i = etOrderService.updateEtOrder(order);
|
int i = etOrderService.updateEtOrder(order);
|
||||||
if(i==0){
|
if(i==0){
|
||||||
throw new ServiceException("更新订单状态失败");
|
throw new ServiceException("更新订单状态失败");
|
||||||
|
@ -952,12 +930,12 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
private EtOrder calculateOrderFee(EtOrder order) {
|
private EtOrder calculateOrderFee(EtOrder order) {
|
||||||
String type = order.getType();
|
String type = order.getType();
|
||||||
if(type.equals("1")){//骑行订单,正常骑行(包含预约费),计时收费,根据开锁时间、起步价和起步时长、时长费和时长分钟等参数,如果有预约,还要加上预约费计算费用,还要判断封顶费用(根据开锁时间)
|
if(type.equals("1")){//骑行订单,正常骑行(包含预约费),计时收费,根据开锁时间、起步价和起步时长、时长费和时长分钟等参数,如果有预约,还要加上预约费计算费用,还要判断封顶费用(根据开锁时间)
|
||||||
/** 预约费*/
|
// /** 预约费*/
|
||||||
Date appointmentStartTime = order.getAppointmentStartTime();
|
// Date appointmentStartTime = order.getAppointmentStartTime();
|
||||||
if(ObjectUtils.isNotEmpty(appointmentStartTime)){
|
// if(ObjectUtils.isNotEmpty(appointmentStartTime)){
|
||||||
//有预约,根据开始时间和结束时间计算费用 预约费 = (预约结束时间 - 开始时间) * 预约服务费
|
// //有预约,根据开始时间和结束时间计算费用 预约费 = (预约结束时间 - 开始时间) * 预约服务费
|
||||||
calculateAppointmentFee(order);
|
// calculateAppointmentFee(order);
|
||||||
}
|
// }
|
||||||
Long ruleId = order.getRuleId();
|
Long ruleId = order.getRuleId();
|
||||||
EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleId(ruleId);
|
EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleId(ruleId);
|
||||||
String rentalUnit = rule.getRentalUnit();//租赁单位
|
String rentalUnit = rule.getRentalUnit();//租赁单位
|
||||||
|
@ -1152,6 +1130,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
// 将毫秒差转换为小时
|
// 将毫秒差转换为小时
|
||||||
long hours = TimeUnit.MILLISECONDS.toHours(diffInMillies);
|
long hours = TimeUnit.MILLISECONDS.toHours(diffInMillies);
|
||||||
|
|
||||||
|
if(hours==0){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
// 计算出在第几个计费周期中
|
// 计算出在第几个计费周期中
|
||||||
BigDecimal cycle = BigDecimal.valueOf(hours).divide(new BigDecimal(chargingCycleValue), 0, RoundingMode.CEILING);
|
BigDecimal cycle = BigDecimal.valueOf(hours).divide(new BigDecimal(chargingCycleValue), 0, RoundingMode.CEILING);
|
||||||
return cycle.intValue();
|
return cycle.intValue();
|
||||||
|
|
|
@ -12,10 +12,12 @@ import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.bean.BeanUtils;
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
||||||
import com.ruoyi.common.utils.bean.BeanValidators;
|
import com.ruoyi.common.utils.bean.BeanValidators;
|
||||||
import com.ruoyi.common.utils.verify.VerifyIdentityUtil;
|
import com.ruoyi.common.utils.verify.VerifyIdentityUtil;
|
||||||
|
import com.ruoyi.system.domain.EtOperatingArea;
|
||||||
import com.ruoyi.system.domain.EtOrder;
|
import com.ruoyi.system.domain.EtOrder;
|
||||||
import com.ruoyi.system.domain.vo.AuthenticationVo;
|
import com.ruoyi.system.domain.vo.AuthenticationVo;
|
||||||
import com.ruoyi.system.mapper.AsUserMapper;
|
import com.ruoyi.system.mapper.AsUserMapper;
|
||||||
import com.ruoyi.system.service.IAsUserService;
|
import com.ruoyi.system.service.IAsUserService;
|
||||||
|
import com.ruoyi.system.service.IEtOperatingAreaService;
|
||||||
import com.ruoyi.system.service.IEtOrderService;
|
import com.ruoyi.system.service.IEtOrderService;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -53,7 +55,7 @@ public class AsUserServiceImpl implements IAsUserService
|
||||||
private IEtOrderService etOrderService;
|
private IEtOrderService etOrderService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysConfigService sysConfigService;
|
private IEtOperatingAreaService etOperatingAreaService;
|
||||||
|
|
||||||
@Value("${et.verifyUrl}")
|
@Value("${et.verifyUrl}")
|
||||||
private String verifyUrl;
|
private String verifyUrl;
|
||||||
|
@ -432,13 +434,13 @@ public class AsUserServiceImpl implements IAsUserService
|
||||||
public Boolean checkIsDeposit(Long userId) {
|
public Boolean checkIsDeposit(Long userId) {
|
||||||
AsUser asUser = asUserMapper.selectUserById(userId);
|
AsUser asUser = asUserMapper.selectUserById(userId);
|
||||||
BigDecimal balance = asUser.getBalance();
|
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)){
|
if(ObjectUtil.isNull(balance)){
|
||||||
log.info("用户【{}】余额为空",userId);
|
log.info("用户【{}】余额为空",userId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BigDecimal bigDecimal = new BigDecimal(deposit);
|
if(balance.compareTo(BigDecimal.ZERO)==0 || balance.compareTo(deposit)<0){//余额为0或者押金和余额不相等
|
||||||
if(balance.compareTo(BigDecimal.ZERO)==0 || balance.compareTo(bigDecimal)<0){//余额为0或者押金和余额不相等
|
|
||||||
log.info("用户【{}】余额为0或者押金小于余额不相等",userId);
|
log.info("用户【{}】余额为0或者押金小于余额不相等",userId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class CallbackServiceImpl implements CallbackService {
|
||||||
// 1-骑行支付 关锁
|
// 1-骑行支付 关锁
|
||||||
order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
||||||
order.setMark("骑行支付");
|
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.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);//还车后车辆正常运营
|
||||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ public class CallbackServiceImpl implements CallbackService {
|
||||||
order.setAppointmentStartTime(DateUtils.getNowDate());
|
order.setAppointmentStartTime(DateUtils.getNowDate());
|
||||||
order.setMark("套餐预约支付");
|
order.setMark("套餐预约支付");
|
||||||
/** 2.发送命令*/
|
/** 2.发送命令*/
|
||||||
asDeviceService.sendCommand(order.getSn(), iotToken,IotConstants.COMMAND_CLOSE,"套餐预约");
|
asDeviceService.sendCommand(asDevice.getMac(), iotToken,IotConstants.COMMAND_CLOSE,"套餐预约");
|
||||||
/** 3.更新车辆状态*/
|
/** 3.更新车辆状态*/
|
||||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_APPOINTMENT);//预约中
|
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_APPOINTMENT);//预约中
|
||||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
||||||
|
@ -209,7 +209,7 @@ public class CallbackServiceImpl implements CallbackService {
|
||||||
order.setMark("套餐骑行支付");
|
order.setMark("套餐骑行支付");
|
||||||
order.setStatus(ServiceConstants.ORDER_STATUS_RIDING);//骑行中
|
order.setStatus(ServiceConstants.ORDER_STATUS_RIDING);//骑行中
|
||||||
/** 2.发送命令*/
|
/** 2.发送命令*/
|
||||||
asDeviceService.sendCommand(order.getSn(), iotToken,IotConstants.COMMAND_OPEN,"套餐开锁");
|
asDeviceService.sendCommand(asDevice.getMac(), iotToken,IotConstants.COMMAND_OPEN,"套餐开锁");
|
||||||
/** 3.更新车辆状态*/
|
/** 3.更新车辆状态*/
|
||||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
||||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
|
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
|
||||||
|
|
|
@ -387,13 +387,13 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
/** 1.获取token*/
|
/** 1.获取token*/
|
||||||
String token = Token.getToken();
|
String token = Token.getToken();
|
||||||
AsDevice asDevice = asDeviceService.selectAsDeviceBySn(order.getSn());
|
AsDevice asDevice = asDeviceService.selectAsDeviceBySn(order.getSn());
|
||||||
if(order.getIsAppointment()){//购买完套餐后 预约车辆
|
// if(order.getIsAppointment()){//购买完套餐后 预约车辆
|
||||||
etOrder.setStatus(ServiceConstants.ORDER_STATUS_IN_APPOINTMENT);
|
etOrder.setStatus(ServiceConstants.ORDER_STATUS_IN_APPOINTMENT);
|
||||||
etOrder.setAppointmentStartTime(DateUtils.getNowDate());
|
etOrder.setAppointmentStartTime(DateUtils.getNowDate());
|
||||||
//校验 userI,sn,ruleId,type 3 isAppointment
|
//校验 userI,sn,ruleId,type 3 isAppointment
|
||||||
Boolean execute = transactionTemplate.execute(e -> {
|
Boolean execute = transactionTemplate.execute(e -> {
|
||||||
/** 2.发送命令*/
|
/** 2.发送命令*/
|
||||||
deviceService.sendCommand(order.getSn(), token, IotConstants.COMMAND_CLOSE,"套餐预约");
|
deviceService.sendCommand(asDevice.getMac(), token, IotConstants.COMMAND_CLOSE,"套餐预约");
|
||||||
/** 3.更新车辆状态*/
|
/** 3.更新车辆状态*/
|
||||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_TEMPORARILY_LOCK);//临时锁车
|
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_TEMPORARILY_LOCK);//临时锁车
|
||||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
||||||
|
@ -406,24 +406,24 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
});
|
});
|
||||||
if(!execute)throw new ServiceException("套餐预约失败");
|
if(!execute)throw new ServiceException("套餐预约失败");
|
||||||
}else{//购买完套餐后 立即开锁骑行
|
// }else{//购买完套餐后 立即开锁骑行
|
||||||
etOrder.setStatus(ServiceConstants.ORDER_STATUS_RIDING);
|
// etOrder.setStatus(ServiceConstants.ORDER_STATUS_RIDING);
|
||||||
Boolean execute = transactionTemplate.execute(e -> {
|
// Boolean execute = transactionTemplate.execute(e -> {
|
||||||
/** 2.发送命令*/
|
// /** 2.发送命令*/
|
||||||
deviceService.sendCommand(order.getSn(), token,IotConstants.COMMAND_OPEN,"套餐开锁");
|
// deviceService.sendCommand(order.getSn(), token,IotConstants.COMMAND_OPEN,"套餐开锁");
|
||||||
/** 3.更新车辆状态*/
|
// /** 3.更新车辆状态*/
|
||||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
// asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
||||||
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING_STR);
|
// asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING_STR);
|
||||||
int device = asDeviceService.updateAsDevice(asDevice);
|
// int device = asDeviceService.updateAsDevice(asDevice);
|
||||||
if(device==0){
|
// if(device==0){
|
||||||
log.info("【套餐开锁】更新车辆状态失败");
|
// log.info("【套餐开锁】更新车辆状态失败");
|
||||||
return Boolean.FALSE;
|
// return Boolean.FALSE;
|
||||||
}
|
// }
|
||||||
log.info("套餐开锁成功");
|
// log.info("套餐开锁成功");
|
||||||
return Boolean.TRUE;
|
// return Boolean.TRUE;
|
||||||
});
|
// });
|
||||||
if(!execute)throw new ServiceException("套餐开锁失败");
|
// if(!execute)throw new ServiceException("套餐开锁失败");
|
||||||
}
|
// }
|
||||||
int i = etOrderMapper.insertEtOrder(etOrder);
|
int i = etOrderMapper.insertEtOrder(etOrder);
|
||||||
if(i == 0){
|
if(i == 0){
|
||||||
throw new ServiceException("订单生成失败");
|
throw new ServiceException("订单生成失败");
|
||||||
|
@ -479,6 +479,7 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
etOrder.setUserName(user.getUserName());
|
etOrder.setUserName(user.getUserName());
|
||||||
etOrder.setMark(order.getMark());
|
etOrder.setMark(order.getMark());
|
||||||
etOrder.setCreateTime(DateUtils.getNowDate());
|
etOrder.setCreateTime(DateUtils.getNowDate());
|
||||||
|
etOrder.setRuleId(order.getRuleId());
|
||||||
/** 订单类型 1骑行 2预约 3套餐 4押金 根据类型不同下单的参数也不同,不同的参数有: 金额、类型、rule_id(套餐id)*/
|
/** 订单类型 1骑行 2预约 3套餐 4押金 根据类型不同下单的参数也不同,不同的参数有: 金额、类型、rule_id(套餐id)*/
|
||||||
String type = order.getType();
|
String type = order.getType();
|
||||||
if(type.equals("1")){//骑行订单,正常骑行(包含预约费),计时收费,根据开锁时间、起步价和起步时长、时长费和时长分钟等参数,如果有预约,还要加上预约费计算费用
|
if(type.equals("1")){//骑行订单,正常骑行(包含预约费),计时收费,根据开锁时间、起步价和起步时长、时长费和时长分钟等参数,如果有预约,还要加上预约费计算费用
|
||||||
|
@ -491,20 +492,11 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
etOrder.setType(ServiceConstants.ORDER_TYPE_RIDING);
|
etOrder.setType(ServiceConstants.ORDER_TYPE_RIDING);
|
||||||
etOrder.setStatus(ServiceConstants.ORDER_STATUS_IN_APPOINTMENT);//预约中
|
etOrder.setStatus(ServiceConstants.ORDER_STATUS_IN_APPOINTMENT);//预约中
|
||||||
etOrder.setAppointmentStartTime(DateUtils.getNowDate());//预约开始时间
|
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")){//押金,创建初始订单,根据计费规则,结算费用,
|
}else if(order.getType().equals("4")){//押金,创建初始订单,根据计费规则,结算费用,
|
||||||
etOrder.setType(ServiceConstants.ORDER_TYPE_DEPOSIT);
|
etOrder.setType(ServiceConstants.ORDER_TYPE_DEPOSIT);
|
||||||
// etOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(user.getAreaId());
|
||||||
String deposit = sysConfigService.selectConfigByKey("deposit");//押金
|
BigDecimal deposit = new BigDecimal(area.getDeposit());
|
||||||
etOrder.setTotalFee(new BigDecimal(deposit));
|
etOrder.setTotalFee(deposit);
|
||||||
}else {
|
}else {
|
||||||
throw new ServiceException("订单类型错误");
|
throw new ServiceException("订单类型错误");
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class WxPayService implements IWxPayService {
|
||||||
String description = type.equals(ServiceConstants.ORDER_TYPE_RIDING) ? "骑行订单-"+billNo : "押金充值-"+billNo;
|
String description = type.equals(ServiceConstants.ORDER_TYPE_RIDING) ? "骑行订单-"+billNo : "押金充值-"+billNo;
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
log.info("【预下单】获取登录用户信息:"+JSON.toJSONString(loginUser));
|
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.setDescription(description);
|
||||||
request.setNotifyUrl(wxPayConfig.getNotifyUrl());
|
request.setNotifyUrl(wxPayConfig.getNotifyUrl());
|
||||||
request.setPayer(getPayer(user.getWxopenid()));
|
request.setPayer(getPayer(user.getWxopenid()));
|
||||||
|
|
|
@ -31,15 +31,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="role" column="role" />
|
<result property="role" column="role" />
|
||||||
<result property="isSign" column="is_sign" />
|
<result property="isSign" column="is_sign" />
|
||||||
<result property="sysUserId" column="sys_user_id" />
|
<result property="sysUserId" column="sys_user_id" />
|
||||||
|
<result property="areaId" column="area_id" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectUserVo">
|
<sql id="selectUserVo">
|
||||||
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
|
from et_user u
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectUserList" parameterType="AsUser" resultMap="AsUserResult">
|
<select id="selectUserList" parameterType="AsUser" resultMap="AsUserResult">
|
||||||
select u.user_id, u.nick_name, u.user_name, u.real_name,u.email, u.avatar, u.phonenumber, u.balance, 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 from et_user u
|
select u.user_id, u.nick_name, u.user_name, u.real_name,u.email, u.avatar, u.phonenumber, u.balance,
|
||||||
|
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
|
||||||
where u.del_flag = '0'
|
where u.del_flag = '0'
|
||||||
<if test="userId != null and userId != 0">
|
<if test="userId != null and userId != 0">
|
||||||
AND u.user_id = #{userId}
|
AND u.user_id = #{userId}
|
||||||
|
@ -157,6 +163,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="role != null and role != ''">role,</if>
|
<if test="role != null and role != ''">role,</if>
|
||||||
<if test="isSign != null and isSign != ''">is_sign,</if>
|
<if test="isSign != null and isSign != ''">is_sign,</if>
|
||||||
<if test="sysUserId != null and sysUserId != ''">sys_user_id,</if>
|
<if test="sysUserId != null and sysUserId != ''">sys_user_id,</if>
|
||||||
|
<if test="areaId != null">area_id,</if>
|
||||||
create_time
|
create_time
|
||||||
)values(
|
)values(
|
||||||
<if test="userId != null and userId != ''">#{userId},</if>
|
<if test="userId != null and userId != ''">#{userId},</if>
|
||||||
|
@ -177,6 +184,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="role != null and role != ''">#{role},</if>
|
<if test="role != null and role != ''">#{role},</if>
|
||||||
<if test="isSign != null and isSign != ''">#{isSign},</if>
|
<if test="isSign != null and isSign != ''">#{isSign},</if>
|
||||||
<if test="sysUserId != null and sysUserId != ''">#{sysUserId},</if>
|
<if test="sysUserId != null and sysUserId != ''">#{sysUserId},</if>
|
||||||
|
<if test="areaId != null">#{areaId},</if>
|
||||||
sysdate()
|
sysdate()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
@ -203,6 +211,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="role != null">role = #{role},</if>
|
<if test="role != null">role = #{role},</if>
|
||||||
<if test="isSign != null">is_sign = #{isSign},</if>
|
<if test="isSign != null">is_sign = #{isSign},</if>
|
||||||
<if test="sysUserId != null">sys_user_id = #{sysUserId},</if>
|
<if test="sysUserId != null">sys_user_id = #{sysUserId},</if>
|
||||||
|
<if test="areaId != null">area_id = #{areaId},</if>
|
||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
</set>
|
</set>
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
|
|
|
@ -135,13 +135,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<where>
|
<where>
|
||||||
<if test="orderNo != null and orderNo != ''"> and order_no != #{orderNo}</if>
|
<if test="orderNo != null and orderNo != ''"> and order_no != #{orderNo}</if>
|
||||||
and user_id = #{userId} and status !=4 and type = 1
|
and user_id = #{userId} and status !=4 and type = 1
|
||||||
and rule_end_time > NOW()
|
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="checkIsUnique" resultType="Integer" parameterType="Long">
|
<select id="checkIsUnique" resultType="Integer" parameterType="Long">
|
||||||
select count(1) from et_order
|
select count(1) from et_order
|
||||||
where user_id = #{userId} and status = 0
|
where user_id = #{userId} and status = 0 and type=1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTotalIncome" resultType="java.lang.String">
|
<select id="getTotalIncome" resultType="java.lang.String">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user