| | |
| | | Object objects = null; |
| | | this.initVerification(orders); |
| | | orders.setCreateTime(new Date()); |
| | | orders.setUpdateTime(orders.getUpdateTime()); |
| | | orders.setPayStatus(Constants.ZERO); |
| | | orders.setDeleted(Constants.ZERO); |
| | | orders.setReleaseMemberId(orders.getMember().getId()); |
| | | //查询手续费 |
| | | Category platformCategory = categoryMapper.selectOne(new QueryWrapper<Category>().lambda().eq(Category::getType,Constants.THREE).eq(Category::getName,orders.getType()).eq(Category::getDeleted,Constants.ZERO).last("limit 1 ")); |
| | | if(Objects.isNull(platformCategory)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未设置平台配置信息"); |
| | | } |
| | | orders.setPlatformRata(new BigDecimal(platformCategory.getDetail()).divide(new BigDecimal("100"))); |
| | | //订单编号 |
| | | orders.setCode(this.getNextCode(orders.getType())); |
| | | Category category = categoryMapper.selectOne(new QueryWrapper<Category>().lambda() |
| | |
| | | multifileMapper.insert(multifileList); |
| | | } |
| | | //更新用户发单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getReceiveNum," (receive_num + 1 )").eq(Member::getId,orders.getMember().getId())); |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().setSql(" receive_num = ( receive_num + 1 )").eq(Member::getId,orders.getMember().getId())); |
| | | |
| | | //创建操作日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPLOAD; |
| | |
| | | || Objects.isNull(orders.getLat()) |
| | | || Objects.isNull(orders.getLgt()) |
| | | || Objects.isNull(orders.getCategoryId()) |
| | | || Objects.isNull(orders.getTotalDays()) |
| | | || (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Objects.isNull(orders.getWorkType())) |
| | | || Objects.isNull(orders.getPriceNum1()) |
| | | || Objects.isNull(orders.getEstimatedAccount()) |
| | |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | if((Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.ZERO )) |
| | | || (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.TWO) |
| | | &&Constants.equalsInteger(orders.getCarType(),Constants.TWO)) |
| | | || Constants.equalsInteger(orders.getType(),Constants.ONE) |
| | | if( (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.TWO) && |
| | | ( Constants.equalsInteger(orders.getCarType(),Constants.ZERO) || Constants.equalsInteger(orders.getCarType(),Constants.ONE) )) |
| | | || (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.ONE)) |
| | | ){ |
| | | orders.setPriceNum2(Constants.ONE); |
| | | } |
| | | if(Objects.isNull(orders.getPriceNum2())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | }else{ |
| | | orders.setPriceNum2(Constants.ONE); |
| | | } |
| | | orders.setTotalDays(DateUtil.daysBetweenDates(orders.getEndDate(),orders.getStartDate())+1); |
| | | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | if(Constants.equalsInteger(orders.getWorkType(),Constants.TWO) |
| | | && Objects.isNull(orders.getCarType())){ |
| | | && ( Objects.isNull(orders.getCarType()) ) ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | }else if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ |
| | |
| | | |
| | | if(Constants.equalsInteger(orders.getCarType(),Constants.ZERO)){ |
| | | if(Objects.nonNull(orders.getPriceNum2())) { |
| | | orders.setOrderContent(orders.getOrderContent() + " | 用车" + orders.getPriceNum2() + "天"); |
| | | orders.setOrderContent(orders.getOrderContent() + " | 用车" + orders.getPriceNum1() + "天"); |
| | | } |
| | | }else{ |
| | | if(Objects.nonNull(orders.getPriceNum2())) { |
| | | orders.setOrderContent(orders.getOrderContent() + " | 用车" + orders.getPriceNum2() + "次"); |
| | | orders.setOrderContent(orders.getOrderContent() + " | 用车" + orders.getPriceNum1() + "次"); |
| | | } |
| | | } |
| | | }else{ |
| | |
| | | orders.setStatus(Constants.ordersStatus.accept.getKey()); |
| | | ordersMapper.updateById(orders); |
| | | //更新接单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getPublishNum," (publish_num + 1 )").eq(Member::getId,member.getId())); |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().setSql(" publish_num = (publish_num + 1 )").eq(Member::getId,member.getId())); |
| | | |
| | | //创建操作日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.RECEIVE; |
| | |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.accept.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){ |
| | | if(!Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getIsUpdate(),Constants.ONE)){ |
| | |
| | | if(Objects.isNull(updOrderDataDTO) |
| | | || Objects.isNull(updOrderDataDTO.getOrderId()) |
| | | || Objects.isNull(updOrderDataDTO.getStartDate()) |
| | | || Objects.isNull(updOrderDataDTO.getEndDate()) |
| | | || Objects.isNull(updOrderDataDTO.getTotalDays())){ |
| | | || Objects.isNull(updOrderDataDTO.getEndDate())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | Orders orders = ordersMapper.selectById(updOrderDataDTO.getOrderId()); |
| | |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.accept.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getReleaseMemberId(),updOrderDataDTO.getMember().getId())){ |
| | | if(!Constants.equalsInteger(orders.getReleaseMemberId(),updOrderDataDTO.getMember().getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getIsUpdate(),Constants.ONE)){ |
| | |
| | | |
| | | public Long getTotal(Orders orders){ |
| | | if( |
| | | (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.ZERO )) || |
| | | (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.TWO) |
| | | &&Constants.equalsInteger(orders.getCarType(),Constants.TWO)) |
| | | (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.ZERO )) |
| | | || Constants.equalsInteger(orders.getType(),Constants.ONE) |
| | | ){ |
| | | orders.setPriceNum2(Constants.ONE); |
| | |
| | | if(!Constants.equalsInteger(orders.getIsUpdate(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单修改状态已流转,无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getAcceptMemberId(),confirmUpdOrderDTO.getMember().getId())){ |
| | | if(!Constants.equalsInteger(orders.getAcceptMemberId(),confirmUpdOrderDTO.getMember().getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | if( Constants.equalsInteger(confirmUpdOrderDTO.getStatus(),Constants.ONE)){ |
| | |
| | | || Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.accept.getKey()))){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){ |
| | | if(!Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | //待支付用餐订单/待接单订单进行取消 |
| | |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.accept.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getAcceptMemberId(),member.getId())){ |
| | | if(!Constants.equalsInteger(orders.getAcceptMemberId(),member.getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | //判断是否可修改 已取消次数 与 时间限制 |
| | |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.doing.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getReleaseMemberId(),doneOrderDTO.getMember().getId())){ |
| | | if(!Constants.equalsInteger(orders.getReleaseMemberId(),doneOrderDTO.getMember().getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | orders.setPayAccount(doneOrderDTO.getAmount()); |
| | | Object object = null; |
| | | //用餐订单 |
| | | if(!Constants.equalsInteger(orders.getType(),Constants.TWO)){ |
| | |
| | | //接单方 我的订单 |
| | | queryWrapper.eq(Orders::getAcceptMemberId,model.getMember().getId()); |
| | | }else{ |
| | | queryWrapper.eq(Orders::getStatus,Constants.ordersStatus.wait.getKey()); |
| | | //接单大厅 |
| | | queryWrapper.and(i-> |
| | | queryWrapper.and(Constants.equalsInteger(model.getMember().getWorkerIdentity(),Constants.TWO)||Constants.equalsInteger(model.getMember().getDriverIdentity(),Constants.TWO)||Constants.equalsInteger(model.getMember().getChefIdentity(),Constants.TWO),i-> |
| | | i.eq(Constants.equalsInteger(model.getMember().getWorkerIdentity(),Constants.TWO),Orders::getType,Constants.ZERO) |
| | | .or() |
| | | .eq(Constants.equalsInteger(model.getMember().getDriverIdentity(),Constants.TWO),Orders::getType,Constants.ONE) |
| | | .or() |
| | | .eq(Constants.equalsInteger(model.getMember().getChefIdentity(),Constants.TWO),Orders::getType,Constants.TWO) |
| | | ); |
| | | queryWrapper.eq(Orders::getStatus,Constants.ONE); |
| | | |
| | | queryWrapper.apply(!(Constants.equalsInteger(model.getMember().getWorkerIdentity(),Constants.TWO)||Constants.equalsInteger(model.getMember().getDriverIdentity(),Constants.TWO)||Constants.equalsInteger(model.getMember().getChefIdentity(),Constants.TWO))," 1 = 2 " |
| | | ); |
| | | |
| | | } |
| | | } |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | |
| | | |
| | | //定位距离 |
| | | public void getDistance(Member member,Orders orders){ |
| | | |
| | | try{ |
| | | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | if(Objects.nonNull(member.getWorkerIdentityModel())&&Objects.nonNull(member.getWorkerIdentityModel().getLgt()) |
| | | &&Objects.nonNull(member.getWorkerIdentityModel().getLat())){ |
| | |
| | | ) |
| | | ); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | orders.setDistance(0L); |
| | | } |
| | | } |
| | | |
| | |
| | | if(!Constants.equalsInteger(type,Constants.ZERO)){ |
| | | prefix = (Constants.equalsInteger(type,Constants.ONE)?"YH-":"DC-"); |
| | | } |
| | | prefix = DateUtil.getDate(new Date(),"yyyyMMddHHmmss") +"-"; |
| | | prefix = prefix + DateUtil.getCurrDateTimeShort() +"-"; |
| | | |
| | | Integer countNum = (Integer) redisTemplate.opsForValue().get(Constants.RedisKeys.ORDER_CODE);//RedisUtil.getObject(redisTemplate, Constants.RedisKeys.ORDER_CODE, Integer.class); |
| | | countNum = Constants.formatIntegerNum(countNum)+1; |
| | |
| | | ); |
| | | |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda() |
| | | .set(Member::getScore," ( total_score +" + Constants.FOUR + " ) / (score_order_num + 1 )") |
| | | .set(Member::getTotalScore," total_score +" + Constants.FOUR) |
| | | .set(Member::getScoreOrderNum," score_order_num + 1 " ).eq(Member::getId,orders.getAcceptMemberId()) |
| | | .setSql(" score = ( ( total_score +" + Constants.FOUR + " ) / (score_order_num + 1 ) ) ") |
| | | .setSql(" total_score = ( total_score +" + Constants.FOUR + ")") |
| | | .setSql(" score_order_num = ( score_order_num + 1 ) " ).eq(Member::getId,orders.getAcceptMemberId()) |
| | | ); |
| | | |
| | | //日志存储 |