押金不足时先退押金,再充值
This commit is contained in:
		
							parent
							
								
									9ab83f4607
								
							
						
					
					
						commit
						ef093e84c3
					
				|  | @ -242,11 +242,11 @@ public class AppVerifyController extends BaseController | ||||||
|             return error("当前车辆有骑行中的订单,请换车"); |             return error("当前车辆有骑行中的订单,请换车"); | ||||||
|         } |         } | ||||||
|         //根据余额和充值记录判断是否有充值过押金,没有充值过押金,提示充值押金 |         //根据余额和充值记录判断是否有充值过押金,没有充值过押金,提示充值押金 | ||||||
|         if(!asUserService.checkIsDeposit(order.getUserId())){ |         if(!asUserService.checkIsDeposit(order.getUserId(),area.getAreaId())){ | ||||||
|             return error("您还未充值押金,请先充值押金"); |             return error("您还未充值押金,请先充值押金"); | ||||||
|         } |         } | ||||||
|         logger.info("【扫码/编号开锁骑行】请求:{}", JSON.toJSON(order)); |         logger.info("【扫码/编号开锁骑行】请求:{}", JSON.toJSON(order)); | ||||||
|         if(etOrderService.isInOrder(order.getUserId(),order.getOrderNo()).size()>0){ |         if(!etOrderService.isInOrder(order.getUserId(), order.getOrderNo()).isEmpty()){ | ||||||
|             return error("您有未完成的订单,请先完成订单"); |             return error("您有未完成的订单,请先完成订单"); | ||||||
|         } |         } | ||||||
|         //低电量不得骑行判断 |         //低电量不得骑行判断 | ||||||
|  | @ -368,7 +368,7 @@ public class AppVerifyController extends BaseController | ||||||
|         etOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END); |         etOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END); | ||||||
|         etOrder.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID); |         etOrder.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID); | ||||||
|         List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(etOrder); |         List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(etOrder); | ||||||
|         if(etOrders.size()==0){ |         if(etOrders.isEmpty()){ | ||||||
|             throw new ServiceException("提现失败,未找到押金订单"); |             throw new ServiceException("提现失败,未找到押金订单"); | ||||||
|         } |         } | ||||||
|         List<EtOrder> inOrder = etOrderService.isInOrder(etOrder.getUserId(), null); |         List<EtOrder> inOrder = etOrderService.isInOrder(etOrder.getUserId(), null); | ||||||
|  | @ -428,48 +428,48 @@ public class AppVerifyController extends BaseController | ||||||
|         return etOrderService.withdraw(etOrder1,etOrder1.getTotalFee()); |         return etOrderService.withdraw(etOrder1,etOrder1.getTotalFee()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** | //    /** | ||||||
|      * 车辆预约 | //     * 车辆预约 | ||||||
|      */ | //     */ | ||||||
|     @Log(title = "车辆预约", businessType = BusinessType.APPOINTMENT) | //    @Log(title = "车辆预约", businessType = BusinessType.APPOINTMENT) | ||||||
|     @PostMapping("/device/appointment") | //    @PostMapping("/device/appointment") | ||||||
|     public AjaxResult deviceAppointment(EtOrderVo appointmentVo) | //    public AjaxResult deviceAppointment(EtOrderVo appointmentVo) | ||||||
|     { | //    { | ||||||
|         logger.info("【车辆预约信息】:{}", JSON.toJSON(appointmentVo)); | //        logger.info("【车辆预约信息】:{}", JSON.toJSON(appointmentVo)); | ||||||
|         AsDevice asDevice = asDeviceService.selectAsDeviceBySn(appointmentVo.getSn()); | //        AsDevice asDevice = asDeviceService.selectAsDeviceBySn(appointmentVo.getSn()); | ||||||
|         //设备是否在线 | //        //设备是否在线 | ||||||
|         if(!asDeviceService.isOnline(appointmentVo.getSn())){ | //        if(!asDeviceService.isOnline(appointmentVo.getSn())){ | ||||||
|             return error("设备不在线"); | //            return error("设备不在线"); | ||||||
|         } | //        } | ||||||
|         EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId()); | //        EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId()); | ||||||
|         //实名判断 | //        //实名判断 | ||||||
|         if(area.getAuthentication().equals(ServiceConstants.IS_AUTHENTICATION_YES) && !asUserService.checkIsAuthentication(appointmentVo.getUserId())){ | //        if(area.getAuthentication().equals(ServiceConstants.IS_AUTHENTICATION_YES) && !asUserService.checkIsAuthentication(appointmentVo.getUserId())){ | ||||||
|             return error("您还未实名,请先实名"); | //            return error("您还未实名,请先实名"); | ||||||
|         } | //        } | ||||||
|         //运营时间判断 | //        //运营时间判断 | ||||||
|         if(!asDeviceService.isOperatingTime(appointmentVo.getSn())){ | //        if(!asDeviceService.isOperatingTime(appointmentVo.getSn())){ | ||||||
|             return error("不在营业时间内,不得骑行"); | //            return error("不在营业时间内,不得骑行"); | ||||||
|         } | //        } | ||||||
|         if(etOrderService.isInOrder(appointmentVo.getUserId(),appointmentVo.getOrderNo()).size()>0){ | //        if(etOrderService.isInOrder(appointmentVo.getUserId(),appointmentVo.getOrderNo()).size()>0){ | ||||||
|             throw new ServiceException("您有未完成的订单,请先完成订单"); | //            throw new ServiceException("您有未完成的订单,请先完成订单"); | ||||||
|         } | //        } | ||||||
|         //根据余额和充值记录判断是否有充值过押金,没有充值过押金,提示充值押金 | //        //根据余额和充值记录判断是否有充值过押金,没有充值过押金,提示充值押金 | ||||||
|         if(!asUserService.checkIsDeposit(appointmentVo.getUserId())){ | //        if(!asUserService.checkIsDeposit(appointmentVo.getUserId())){ | ||||||
|             throw new ServiceException("您还未充值押金,请先充值押金"); | //            throw new ServiceException("您还未充值押金,请先充值押金"); | ||||||
|         } | //        } | ||||||
|         //检验预约订单只能有一个 | //        //检验预约订单只能有一个 | ||||||
|         if(etOrderService.checkIsUnique(appointmentVo.getUserId())){ | //        if(etOrderService.checkIsUnique(appointmentVo.getUserId())){ | ||||||
|             throw new ServiceException("您有预约中的订单,请务重复操作"); | //            throw new ServiceException("您有预约中的订单,请务重复操作"); | ||||||
|         } | //        } | ||||||
|         appointmentVo.setType("2"); | //        appointmentVo.setType("2"); | ||||||
|         String status = asDevice.getStatus(); | //        String status = asDevice.getStatus(); | ||||||
|         if(!ServiceConstants.VEHICLE_STATUS_NORMAL.equals(status)){ | //        if(!ServiceConstants.VEHICLE_STATUS_NORMAL.equals(status)){ | ||||||
|             //根据状态值返回不同的提示 | //            //根据状态值返回不同的提示 | ||||||
|             return error(CommonUtil.format(status)); | //            return error(CommonUtil.format(status)); | ||||||
|         } | //        } | ||||||
|         OrderResponse orderResponse = asDeviceService.deviceAppointment(appointmentVo); | //        OrderResponse orderResponse = asDeviceService.deviceAppointment(appointmentVo); | ||||||
|         return success(orderResponse); | //        return success(orderResponse); | ||||||
|     } | //    } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -866,7 +866,7 @@ public class AppVerifyController extends BaseController | ||||||
|     @GetMapping(value = "/checkIsDeposit") |     @GetMapping(value = "/checkIsDeposit") | ||||||
|     public AjaxResult checkIsDeposit(Long userId) |     public AjaxResult checkIsDeposit(Long userId) | ||||||
|     { |     { | ||||||
|         Boolean aBoolean = asUserService.checkIsDeposit(userId); |         Boolean aBoolean = asUserService.checkIsDeposit(userId,null); | ||||||
|         return AjaxResult.success("操作成功",aBoolean); |         return AjaxResult.success("操作成功",aBoolean); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -199,7 +199,7 @@ public interface IAsUserService | ||||||
|      * 检测用户是否有充值过押金 |      * 检测用户是否有充值过押金 | ||||||
|      * @param userId |      * @param userId | ||||||
|      */ |      */ | ||||||
|     public Boolean checkIsDeposit(Long userId); |     public Boolean checkIsDeposit(Long userId,Long areaId); | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * 新增用户 |      * 新增用户 | ||||||
|  |  | ||||||
|  | @ -889,6 +889,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i | ||||||
|             /** 2.发送命令*/ |             /** 2.发送命令*/ | ||||||
|             ResponseVo responseVo = sendCommandWithResp(asDevice.getMac(), token, IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "编号开锁", finalOrderNo); |             ResponseVo responseVo = sendCommandWithResp(asDevice.getMac(), token, IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "编号开锁", finalOrderNo); | ||||||
|             if(responseVo.getCode() != 0){ |             if(responseVo.getCode() != 0){ | ||||||
|  |                 // todo asDevice.getMac() | ||||||
|  |                 log.info("【扫码/编号开锁骑行】发送开锁命令失败,通过api重新查询状态"); | ||||||
|  | 
 | ||||||
|                 throw new ServiceException("【扫码/编号开锁骑行】发送开锁命令失败"); |                 throw new ServiceException("【扫码/编号开锁骑行】发送开锁命令失败"); | ||||||
|             } |             } | ||||||
|         }else{ |         }else{ | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| package com.ruoyi.system.service.impl; | package com.ruoyi.system.service.impl; | ||||||
| 
 | 
 | ||||||
| import cn.hutool.core.util.ObjectUtil; | import cn.hutool.core.util.ObjectUtil; | ||||||
|  | import com.alibaba.fastjson2.JSON; | ||||||
| import com.ruoyi.common.annotation.DataScope; | import com.ruoyi.common.annotation.DataScope; | ||||||
| import com.ruoyi.common.constant.CacheConstants; | import com.ruoyi.common.constant.CacheConstants; | ||||||
| import com.ruoyi.common.constant.ServiceConstants; | import com.ruoyi.common.constant.ServiceConstants; | ||||||
|  | @ -8,25 +9,27 @@ import com.ruoyi.common.constant.UserConstants; | ||||||
| import com.ruoyi.common.core.domain.entity.AsUser; | import com.ruoyi.common.core.domain.entity.AsUser; | ||||||
| import com.ruoyi.common.core.domain.entity.EtOrderDto; | import com.ruoyi.common.core.domain.entity.EtOrderDto; | ||||||
| import com.ruoyi.common.core.domain.entity.SysUser; | import com.ruoyi.common.core.domain.entity.SysUser; | ||||||
|  | import com.ruoyi.common.core.domain.model.LoginUser; | ||||||
| import com.ruoyi.common.core.domain.vo.LabelVo; | import com.ruoyi.common.core.domain.vo.LabelVo; | ||||||
| import com.ruoyi.common.core.redis.RedisCache; | import com.ruoyi.common.core.redis.RedisCache; | ||||||
| import com.ruoyi.common.exception.ServiceException; | import com.ruoyi.common.exception.ServiceException; | ||||||
|  | import com.ruoyi.common.utils.DateUtils; | ||||||
| import com.ruoyi.common.utils.SecurityUtils; | import com.ruoyi.common.utils.SecurityUtils; | ||||||
| import com.ruoyi.common.utils.StringUtils; | 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.spring.SpringUtils; | import com.ruoyi.common.utils.spring.SpringUtils; | ||||||
|  | import com.ruoyi.common.utils.uuid.IdUtils; | ||||||
| import com.ruoyi.common.utils.verify.VerifyIdentityUtil; | import com.ruoyi.common.utils.verify.VerifyIdentityUtil; | ||||||
|  | import com.ruoyi.system.domain.EtOnlineLog; | ||||||
| import com.ruoyi.system.domain.EtOperatingArea; | import com.ruoyi.system.domain.EtOperatingArea; | ||||||
| import com.ruoyi.system.domain.EtOrder; | import com.ruoyi.system.domain.EtOrder; | ||||||
|  | import com.ruoyi.system.domain.EtRefund; | ||||||
| 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.mapper.EtOrderMapper; | import com.ruoyi.system.mapper.EtOrderMapper; | ||||||
| import com.ruoyi.system.mapper.SysUserMapper; | import com.ruoyi.system.mapper.SysUserMapper; | ||||||
| import com.ruoyi.system.service.IAsUserService; | import com.ruoyi.system.service.*; | ||||||
| import com.ruoyi.system.service.IEtOperatingAreaService; |  | ||||||
| import com.ruoyi.system.service.IEtOrderService; |  | ||||||
| import com.ruoyi.system.service.ISysConfigService; |  | ||||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  | @ -39,6 +42,8 @@ import javax.validation.Validator; | ||||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | import java.util.concurrent.ScheduledExecutorService; | ||||||
|  | import java.util.concurrent.TimeUnit; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * 用户 业务层处理 |  * 用户 业务层处理 | ||||||
|  | @ -80,6 +85,20 @@ public class AsUserServiceImpl implements IAsUserService | ||||||
|     @Value("${et.appcode}") |     @Value("${et.appcode}") | ||||||
|     private String appcode; |     private String appcode; | ||||||
| 
 | 
 | ||||||
|  |     @Autowired | ||||||
|  |     private IWxPayService wxPayService; | ||||||
|  | 
 | ||||||
|  |     @Autowired | ||||||
|  |     private IEtRefundService etRefundService; | ||||||
|  | 
 | ||||||
|  |     @Autowired | ||||||
|  |     private ScheduledExecutorService scheduledExecutorService; | ||||||
|  | 
 | ||||||
|  |     @Autowired | ||||||
|  |     private IAsUserService asUserService; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * 根据条件分页查询用户列表 |      * 根据条件分页查询用户列表 | ||||||
|      * |      * | ||||||
|  | @ -463,35 +482,64 @@ public class AsUserServiceImpl implements IAsUserService | ||||||
|      * @param userId |      * @param userId | ||||||
|      */ |      */ | ||||||
|     @Override |     @Override | ||||||
|     public Boolean checkIsDeposit(Long userId) { |     public Boolean checkIsDeposit(Long userId,Long areaId) { | ||||||
|         AsUser asUser = asUserMapper.selectUserById(userId); |         AsUser asUser = asUserMapper.selectUserById(userId); | ||||||
|         BigDecimal balance = asUser.getBalance(); |         BigDecimal balance = asUser.getBalance(); | ||||||
| //        EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(Long.parseLong(asUser.getAreaId())); |         EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId); | ||||||
| //        BigDecimal deposit = new BigDecimal(area.getDeposit()); |         BigDecimal deposit = new BigDecimal(area.getDeposit()); | ||||||
| //        if(deposit.compareTo(BigDecimal.ZERO)==0){//押金为0直接返回true |         if(balance.compareTo(deposit)<0){ | ||||||
| //            log.info("运营区【{}】押金为0",area.getAreaName()); |  | ||||||
| //            return true; |  | ||||||
| //        } |  | ||||||
|         if(ObjectUtil.isNull(balance)){ |  | ||||||
|             log.info("用户【{}】余额为空",userId); |  | ||||||
|             return false; |  | ||||||
|         } |  | ||||||
|             if(balance.compareTo(BigDecimal.ZERO)==0){//余额为0 |             if(balance.compareTo(BigDecimal.ZERO)==0){//余额为0 | ||||||
|                 log.info("用户【{}】余额为0",userId); |                 log.info("用户【{}】余额为0",userId); | ||||||
|                 return false; |                 return false; | ||||||
|  |             }else{ | ||||||
|  |                 //余额小于押金且不等于0,先退款,再返回false,让他重新充值 | ||||||
|  |                 log.info("用户【{}】余额小于押金,先退款,再返回false,重新充值",userId); | ||||||
|  |                 refundRemainingDeposit(userId); | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         if(ObjectUtil.isNull(balance)){ | ||||||
|  |             log.info("用户【{}】余额为空",userId); | ||||||
|  |             return false; | ||||||
|         } |         } | ||||||
|         // 判断是否有押金充值记录 |         // 判断是否有押金充值记录 | ||||||
|         EtOrder etOrder = new EtOrder(); |         EtOrder etOrder = new EtOrder(); | ||||||
|         etOrder.setType(ServiceConstants.ORDER_TYPE_DEPOSIT); |         etOrder.setType(ServiceConstants.ORDER_TYPE_DEPOSIT); | ||||||
|         etOrder.setUserId(userId); |         etOrder.setUserId(userId); | ||||||
|         etOrder.setPaid("1"); |         etOrder.setPaid("1"); | ||||||
|         if(etOrderMapper.selectEtOrderList(etOrder).size()<1){//没有充值押金记录 |         if(etOrderMapper.selectEtOrderList(etOrder).isEmpty()){//没有充值押金记录 | ||||||
|             log.info("用户【{}】没有充值押金记录",userId); |             log.info("用户【{}】没有充值押金记录",userId); | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /* 异步处理退剩余押金*/ | ||||||
|  |     private void refundRemainingDeposit(Long userId) { | ||||||
|  |         scheduledExecutorService.schedule(() -> { | ||||||
|  |             String outRefundNo = IdUtils.getOrderNo("ref"); | ||||||
|  |             EtOrder etOrder1 = etOrderService.getDepositOrder(userId); | ||||||
|  |             BigDecimal deposit = etOrder1.getPayFee(); | ||||||
|  |             log.info("【押金不足,先退剩余押金】用户【{}】,退款金额【{}】,退款单号【{}】",userId,deposit,outRefundNo); | ||||||
|  |             /** 2.记录退款表  创建退款对象*/ | ||||||
|  |             etOrder1.setReason("押金不足,先退剩余押金"); | ||||||
|  |             EtRefund refund1= etOrderService.createRefund(etOrder1, deposit, null, null, null, null, outRefundNo,ServiceConstants.REFUND_TYPE_DEPOSIT); | ||||||
|  |             int i = etRefundService.insertEtRefund(refund1); | ||||||
|  |             if(i>0){ | ||||||
|  |                 log.info("【押金不足,退剩余押金】保存退款对象成功"); | ||||||
|  |                 // 更新用户 | ||||||
|  |                 AsUser currentUser = new AsUser(); | ||||||
|  |                 currentUser.setUserId(userId); | ||||||
|  |                 currentUser.setBalance(BigDecimal.ZERO); | ||||||
|  |                 if (asUserMapper.updateUser(currentUser) > 0) | ||||||
|  |                 { | ||||||
|  |                     log.info("【押金不足,退剩余押金】更新用户信息成功:{}", JSON.toJSON(currentUser)); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             wxPayService.refund(etOrder1, "押金不足,先退剩余押金", deposit,outRefundNo); | ||||||
|  |         }, 0, TimeUnit.SECONDS); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * 新增用户 |      * 新增用户 | ||||||
|      */ |      */ | ||||||
|  |  | ||||||
|  | @ -618,7 +618,7 @@ public class CallbackServiceImpl implements CallbackService { | ||||||
|                 etOrder.setType(ServiceConstants.ORDER_TYPE_DEPOSIT); |                 etOrder.setType(ServiceConstants.ORDER_TYPE_DEPOSIT); | ||||||
|                 etOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END); |                 etOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END); | ||||||
|                 List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(etOrder); |                 List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(etOrder); | ||||||
|                 if (etOrders.size() == 0 || ObjectUtil.isNull(etOrders) ) { |                 if (etOrders.isEmpty() || ObjectUtil.isNull(etOrders) ) { | ||||||
|                     throw new ServiceException("押金充值记录不存在"); |                     throw new ServiceException("押金充值记录不存在"); | ||||||
|                 } |                 } | ||||||
|                 Optional<EtOrder> latestOrder = etOrders.stream() |                 Optional<EtOrder> latestOrder = etOrders.stream() | ||||||
|  |  | ||||||
|  | @ -896,7 +896,7 @@ public class EtOrderServiceImpl implements IEtOrderService | ||||||
|         depositOrder.setType(ServiceConstants.ORDER_TYPE_DEPOSIT); |         depositOrder.setType(ServiceConstants.ORDER_TYPE_DEPOSIT); | ||||||
|         depositOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END); |         depositOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END); | ||||||
|         List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(depositOrder); |         List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(depositOrder); | ||||||
|         if (etOrders.size() == 0 || ObjectUtil.isNull(etOrders) ) { |         if (etOrders.isEmpty() || ObjectUtil.isNull(etOrders) ) { | ||||||
|             throw new ServiceException("押金充值记录不存在"); |             throw new ServiceException("押金充值记录不存在"); | ||||||
|         } |         } | ||||||
|         Optional<EtOrder> latestOrder = etOrders.stream() |         Optional<EtOrder> latestOrder = etOrders.stream() | ||||||
|  | @ -1448,25 +1448,25 @@ public class EtOrderServiceImpl implements IEtOrderService | ||||||
|         return etOrder; |         return etOrder; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private void verify(EtOrderVo order, Long userId) { | //    private void verify(EtOrderVo order, Long userId) { | ||||||
|         if(etOrderService.isInOrder(userId,null).size()>0){ | //        if(etOrderService.isInOrder(userId,null).size()>0){ | ||||||
|            throw new ServiceException("您有未完成的订单,请先完成订单"); | //           throw new ServiceException("您有未完成的订单,请先完成订单"); | ||||||
|         } | //        } | ||||||
|         //根据余额和充值记录判断是否有充值过押金,没有充值过押金,提示充值押金 | //        //根据余额和充值记录判断是否有充值过押金,没有充值过押金,提示充值押金 | ||||||
|         if(!asUserService.checkIsDeposit(userId)){ | //        if(!asUserService.checkIsDeposit(userId)){ | ||||||
|             throw new ServiceException("您还未充值押金,请先充值押金"); | //            throw new ServiceException("您还未充值押金,请先充值押金"); | ||||||
|         } | //        } | ||||||
|         //检验预约订单只能有一个 | //        //检验预约订单只能有一个 | ||||||
|         if(etOrderService.checkIsUnique(userId)){ | //        if(etOrderService.checkIsUnique(userId)){ | ||||||
|             throw new ServiceException("您有预约中的订单,请务重复操作"); | //            throw new ServiceException("您有预约中的订单,请务重复操作"); | ||||||
|         } | //        } | ||||||
|         AsDevice asDevice = asDeviceService.selectAsDeviceBySn(order.getSn()); | //        AsDevice asDevice = asDeviceService.selectAsDeviceBySn(order.getSn()); | ||||||
|         String status = asDevice.getStatus(); | //        String status = asDevice.getStatus(); | ||||||
|         if(!ServiceConstants.VEHICLE_STATUS_NORMAL.equals(status)){ | //        if(!ServiceConstants.VEHICLE_STATUS_NORMAL.equals(status)){ | ||||||
|             //根据状态值返回不同的提示 | //            //根据状态值返回不同的提示 | ||||||
|             throw new ServiceException(CommonUtil.format(status)); | //            throw new ServiceException(CommonUtil.format(status)); | ||||||
|         } | //        } | ||||||
|     } | //    } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * 检验预约订单只能有一个 |      * 检验预约订单只能有一个 | ||||||
|  | @ -1557,22 +1557,22 @@ public class EtOrderServiceImpl implements IEtOrderService | ||||||
|             /** 总收入*/ |             /** 总收入*/ | ||||||
|             BigDecimal totalAmount = defaultIfNull(etCapitalFlowMapper.getTotalAmount(timeStart, timeEnd, null, aLong),BigDecimal.ZERO);// 骑行订单收入 |             BigDecimal totalAmount = defaultIfNull(etCapitalFlowMapper.getTotalAmount(timeStart, timeEnd, null, aLong),BigDecimal.ZERO);// 骑行订单收入 | ||||||
|             BigDecimal deductionAmount = defaultIfNull(etCapitalFlowMapper.getDeductionAmount(timeStart, timeEnd, null, aLong),BigDecimal.ZERO);// 押金抵扣金额 |             BigDecimal deductionAmount = defaultIfNull(etCapitalFlowMapper.getDeductionAmount(timeStart, timeEnd, null, aLong),BigDecimal.ZERO);// 押金抵扣金额 | ||||||
|             BigDecimal depositAmount = defaultIfNull(etOrderMapper.getDepositAmount(timeStart, timeEnd,  aLong,null),BigDecimal.ZERO);// 押金收入  25123 |             BigDecimal depositAmount = defaultIfNull(etOrderMapper.getDepositAmount(timeStart, timeEnd,  aLong,3L),BigDecimal.ZERO);// 押金收入  25123 | ||||||
|             BigDecimal totalFlowAmount = totalAmount.add(depositAmount).add(deductionAmount);// 总流水 |             BigDecimal totalFlowAmount = totalAmount.add(depositAmount).add(deductionAmount);// 总流水 | ||||||
|             income.setTotalFlowAmount(totalFlowAmount); |             income.setTotalFlowAmount(totalFlowAmount); | ||||||
|             income.setDeductionAmount(deductionAmount); |             income.setDeductionAmount(deductionAmount); | ||||||
|             income.setOrderPaid(totalAmount.add(deductionAmount).add(deductionAmount));//订单支付 |             income.setOrderPaid(totalAmount.add(deductionAmount).add(deductionAmount));//订单支付 | ||||||
|             income.setDepositPaid(depositAmount); |             income.setDepositPaid(depositAmount);//押金收入 | ||||||
| 
 | 
 | ||||||
|             /** 总支出*/ |             /** 总支出*/ | ||||||
|             BigDecimal refundFee = defaultIfNull(etOrderMapper.getRefundFee(timeStart, timeEnd, null, aLong,null), BigDecimal.ZERO);//订单退款 |             BigDecimal refundFee = defaultIfNull(etOrderMapper.getRefundFee(timeStart, timeEnd, null, aLong,null), BigDecimal.ZERO);//订单退款 | ||||||
|             BigDecimal depositRefundFee = defaultIfNull(etOrderMapper.getDepositRefundFee(timeStart, timeEnd, null, aLong,null), BigDecimal.ZERO);//押金退款 24795 |             BigDecimal depositRefundFee = defaultIfNull(etOrderMapper.getDepositRefundFee(timeStart, timeEnd, null, aLong,3L), BigDecimal.ZERO);//押金退款 24795 | ||||||
|             BigDecimal serviceFee = defaultIfNull(etCapitalFlowMapper.getHandlingFee(timeStart, timeEnd, null, aLong,null,null),BigDecimal.ZERO);//手续费,扣除掉退款部分的 |             BigDecimal serviceFee = defaultIfNull(etCapitalFlowMapper.getHandlingFee(timeStart, timeEnd, null, aLong,null,null),BigDecimal.ZERO);//手续费,扣除掉退款部分的 | ||||||
|             BigDecimal platformServiceFee = defaultIfNull(etCapitalFlowMapper.getServiceFee(timeStart, timeEnd, null,aLong,null,null),BigDecimal.ZERO);//平台服务费 ,扣除掉退款部分的 |             BigDecimal platformServiceFee = defaultIfNull(etCapitalFlowMapper.getServiceFee(timeStart, timeEnd, null,aLong,null,null),BigDecimal.ZERO);//平台服务费 ,扣除掉退款部分的 | ||||||
|             BigDecimal totalExpenditure = defaultIfNull(refundFee.add(depositRefundFee).add(serviceFee).add(platformServiceFee), BigDecimal.ZERO); |             BigDecimal totalExpenditure = defaultIfNull(refundFee.add(depositRefundFee).add(serviceFee).add(platformServiceFee), BigDecimal.ZERO); | ||||||
| 
 | 
 | ||||||
|             income.setOrderRefund(refundFee); |             income.setOrderRefund(refundFee); | ||||||
|             income.setDepositRefund(depositRefundFee); |             income.setDepositRefund(depositRefundFee);//押金退款 | ||||||
|             income.setHandlingFee(serviceFee); |             income.setHandlingFee(serviceFee); | ||||||
|             income.setPlatformServiceFee(platformServiceFee); |             income.setPlatformServiceFee(platformServiceFee); | ||||||
|             income.setTotalExpenditure(totalExpenditure); |             income.setTotalExpenditure(totalExpenditure); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user