|  |  |  | 
|---|
|  |  |  | private WithdrawalOrdersMapper withdrawalOrdersMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ReceiveWeightMapper receiveWeightMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WxMiniUtilService wxMiniUtilService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | 
|---|
|  |  |  | //用餐订单 | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.TWO)){ | 
|---|
|  |  |  | orders.setStatus(Constants.ordersStatus.waitPay.getKey()); | 
|---|
|  |  |  | orders.setOutTradeNo(UUID.randomUUID().toString().replace("-","")); | 
|---|
|  |  |  | //唤起支付业务 | 
|---|
|  |  |  | objects = this.getWxPayResponse(orders,orders.getMember().getOpenid()); | 
|---|
|  |  |  | orderReleaseVO.setObject(objects); | 
|---|
|  |  |  | 
|---|
|  |  |  | Payer payer = new Payer(); | 
|---|
|  |  |  | payer.setSubOpenid(openid); | 
|---|
|  |  |  | request.setPayer(payer); | 
|---|
|  |  |  | request.setOutTradeNo(orders.getCode()); | 
|---|
|  |  |  | request.setOutTradeNo(orders.getOutTradeNo()); | 
|---|
|  |  |  | request.setNotifyUrl(WxMiniConfig.wxProperties.getNotifyUrl());//这个回调url必须是https开头的 | 
|---|
|  |  |  | Amount amount = new Amount(); | 
|---|
|  |  |  | amount.setTotal(orders.getEstimatedAccount().intValue()); | 
|---|
|  |  |  | amount.setTotal(1);//orders.getEstimatedAccount().intValue()); | 
|---|
|  |  |  | request.setAmount(amount); | 
|---|
|  |  |  | //        PrepayResponse res = WxMiniConfig.wxPayService.prepay(request); | 
|---|
|  |  |  | // 跟之前下单示例一样,填充预下单参数 | 
|---|
|  |  |  | 
|---|
|  |  |  | || Objects.isNull(orders.getStartDate()) | 
|---|
|  |  |  | || Objects.isNull(orders.getEndDate()) | 
|---|
|  |  |  | || StringUtil.isBlank(orders.getLocation()) | 
|---|
|  |  |  | || (!Constants.equalsInteger(Constants.ONE,orders.getType())&&StringUtil.isBlank(orders.getLocationRemark())) | 
|---|
|  |  |  | || StringUtil.isBlank(orders.getLinkPhone()) | 
|---|
|  |  |  | || Objects.isNull(orders.getLat()) | 
|---|
|  |  |  | || Objects.isNull(orders.getLgt()) | 
|---|
|  |  |  | || Objects.isNull(orders.getCategoryId()) | 
|---|
|  |  |  | || (!Constants.equalsInteger(orders.getType(),Constants.TWO) && Objects.isNull(orders.getCategoryId())) | 
|---|
|  |  |  | || (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Objects.isNull(orders.getWorkType())) | 
|---|
|  |  |  | || Objects.isNull(orders.getPriceNum1()) | 
|---|
|  |  |  | || Objects.isNull(orders.getEstimatedAccount()) | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setStatusName(Constants.ordersStatus.getName(orders.getStatus())); | 
|---|
|  |  |  | this.getPriceUnit(orders); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getWorkType(),Constants.ZERO)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/斤"); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getWorkType(),Constants.ONE)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/人/天"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getCarType(),Constants.ZERO)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/人/天"); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getCarType(),Constants.ONE)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/人/小时"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orders.setPriceUnit("元/斤"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getCarType(),Constants.ZERO)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/天"); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getCarType(),Constants.ONE)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/次"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //附件信息 | 
|---|
|  |  |  | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda().eq(Multifile::getObjId,orders.getId()) | 
|---|
|  |  |  | .eq(Multifile::getIsdeleted,Constants.ZERO).eq(Multifile::getObjType,Constants.ONE).orderByAsc(Multifile::getId)); | 
|---|
|  |  |  | 
|---|
|  |  |  | return orders; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void getPriceUnit(Orders orders){ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getWorkType(),Constants.ZERO)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/斤"); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getWorkType(),Constants.ONE)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/人/天"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getCarType(),Constants.ZERO)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/人/天"); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getCarType(),Constants.ONE)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/人/小时"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orders.setPriceUnit("元/斤"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getCarType(),Constants.ZERO)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/天"); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getCarType(),Constants.ONE)){ | 
|---|
|  |  |  | orders.setPriceUnit("元/次"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Orders findOne(Orders orders) { | 
|---|
|  |  |  | QueryWrapper<Orders> wrapper = new QueryWrapper<>(orders); | 
|---|
|  |  |  | 
|---|
|  |  |  | if( | 
|---|
|  |  |  | (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.ZERO )) | 
|---|
|  |  |  | || Constants.equalsInteger(orders.getType(),Constants.ONE) | 
|---|
|  |  |  | || Constants.equalsInteger(orders.getType(),Constants.TWO) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | orders.setPriceNum2(Constants.ONE); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPD_DISAGREE; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),confirmUpdOrderDTO.getMember().getId(),null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TODO 发送不同意变更通知 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public Object doneOrder(DoneOrderDTO doneOrderDTO){ | 
|---|
|  |  |  | public OrderReleaseVO doneOrder(DoneOrderDTO doneOrderDTO){ | 
|---|
|  |  |  | if(Objects.isNull(doneOrderDTO)||Objects.isNull(doneOrderDTO.getOrderId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getReleaseMemberId(),doneOrderDTO.getMember().getId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setPayAccount(doneOrderDTO.getAmount()); | 
|---|
|  |  |  | OrderReleaseVO orderReleaseVO = new OrderReleaseVO(); | 
|---|
|  |  |  | orderReleaseVO.setId(orders.getId()); | 
|---|
|  |  |  | Object object = null; | 
|---|
|  |  |  | //用餐订单 | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getType(),Constants.TWO)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | //提成金额 | 
|---|
|  |  |  | Long tcje = Long.valueOf(new BigDecimal(orders.getPayAccount().toString()).multiply(orders.getPlatformRata()).intValue()); | 
|---|
|  |  |  | orders.setReceiveAccount(orders.getPayAccount() - tcje); | 
|---|
|  |  |  | orders.setOutTradeNo(UUID.randomUUID().toString().replace("-","")); | 
|---|
|  |  |  | ordersMapper.updateById(orders); | 
|---|
|  |  |  | //唤起支付业务 | 
|---|
|  |  |  | object = this.getWxPayResponse(orders,orders.getMember().getOpenid()); | 
|---|
|  |  |  | orderReleaseVO.setObject(object); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orders.setStatus(Constants.ordersStatus.done.getKey()); | 
|---|
|  |  |  | orders.setFinishTime(new Date()); | 
|---|
|  |  |  | ordersMapper.updateById(orders); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Member member = memberMapper.selectById(orders.getAcceptMemberId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //存储流水记录 | 
|---|
|  |  |  | MemberRevenue memberRevenue = new MemberRevenue(); | 
|---|
|  |  |  | memberRevenue.setCreateTime(new Date()); | 
|---|
|  |  |  | memberRevenue.setMemberId(orders.getAcceptMemberId()); | 
|---|
|  |  |  | memberRevenue.setType(orders.getType()); | 
|---|
|  |  |  | memberRevenue.setOptType(Constants.ONE); | 
|---|
|  |  |  | memberRevenue.setBeforeAmount(member.getAmount()); | 
|---|
|  |  |  | memberRevenue.setAmount(orders.getReceiveAccount()); | 
|---|
|  |  |  | memberRevenue.setAfterAmount(member.getAmount() + orders.getReceiveAccount()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | memberRevenue.setRemark(Constants.RevenueType.getInfo(memberRevenue.getType()) + "-" + | 
|---|
|  |  |  | (Constants.equalsInteger(orders.getWorkType(),Constants.ZERO)?"采摘工":(Constants.equalsInteger(orders.getWorkType(),Constants.ONE)?"分拣工":"包装工"))); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | memberRevenue.setRemark(Constants.RevenueType.getInfo(memberRevenue.getType())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | memberRevenue.setObjId(orders.getId()); | 
|---|
|  |  |  | memberRevenue.setObjType(Constants.ZERO); | 
|---|
|  |  |  | memberRevenue.setStatus(Constants.ZERO); | 
|---|
|  |  |  | memberRevenueMapper.insert(memberRevenue); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //日志存储 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.DONE; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),doneOrderDTO.getMember().getId(),null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return object; | 
|---|
|  |  |  | return orderReleaseVO; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public OrderReleaseVO reusePay(ReusePayDTO reusePayDTO){ | 
|---|
|  |  |  | if(Objects.isNull(reusePayDTO)||Objects.isNull(reusePayDTO.getOrderId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Orders orders = ordersMapper.selectById(reusePayDTO.getOrderId()); | 
|---|
|  |  |  | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getType(),Constants.TWO)&&Objects.isNull(reusePayDTO.getAmount())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(!((( Constants.equalsInteger(orders.getType(),Constants.TWO) && Constants.equalsInteger(orders.getStatus(),Constants.ZERO) ) | 
|---|
|  |  |  | || ( !Constants.equalsInteger(orders.getType(),Constants.TWO) && Constants.equalsInteger(orders.getStatus(),Constants.THREE) )) | 
|---|
|  |  |  | && Constants.equalsInteger(orders.getPayStatus(),Constants.ZERO) )){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | OrderReleaseVO orderReleaseVO = new OrderReleaseVO(); | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getType(),Constants.TWO)){ | 
|---|
|  |  |  | orders.setPayAccount(reusePayDTO.getAmount()); | 
|---|
|  |  |  | //提成金额 | 
|---|
|  |  |  | Long tcje = Long.valueOf(new BigDecimal(orders.getPayAccount().toString()).multiply(orders.getPlatformRata()).intValue()); | 
|---|
|  |  |  | orders.setReceiveAccount(orders.getPayAccount() - tcje); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setOutTradeNo(UUID.randomUUID().toString().replace("-","")); | 
|---|
|  |  |  | ordersMapper.updateById(orders); | 
|---|
|  |  |  | //唤起支付业务 | 
|---|
|  |  |  | Object object = this.getWxPayResponse(orders,orders.getMember().getOpenid()); | 
|---|
|  |  |  | orderReleaseVO.setObject(object); | 
|---|
|  |  |  | orderReleaseVO.setId(orders.getId()); | 
|---|
|  |  |  | return orderReleaseVO; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | .set(Orders::getCommentType,Constants.ZERO) | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | memberMapper.update(new UpdateWrapper<Member>().lambda() | 
|---|
|  |  |  | .set(Member::getScore," ( total_score +" + commentDTO.getLevel() + " ) / (score_order_num + 1 )") | 
|---|
|  |  |  | .set(Member::getTotalScore," total_score +" + commentDTO.getLevel()) | 
|---|
|  |  |  | .set(Member::getScoreOrderNum," score_order_num + 1 " ).eq(Member::getId,orders.getAcceptMemberId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //日志存储 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.COMMENT; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),orders.getAcceptMemberId(),null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | //处理支付完成逻辑 | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getUpdateTime,new Date()) | 
|---|
|  |  |  | .set(Orders::getStatus,Constants.ordersStatus.wait) | 
|---|
|  |  |  | .set(Orders::getStatus,Constants.ordersStatus.wait.getKey()) | 
|---|
|  |  |  | .set(Orders::getPayStatus,Constants.ONE) | 
|---|
|  |  |  | .set(Orders::getPayTime,new Date()) | 
|---|
|  |  |  | .set(Orders::getPayMethod,Constants.ZERO) | 
|---|
|  |  |  | 
|---|
|  |  |  | memberRevenue.setBeforeAmount(member.getAmount()); | 
|---|
|  |  |  | memberRevenue.setAmount(orders.getReceiveAccount()); | 
|---|
|  |  |  | memberRevenue.setAfterAmount(member.getAmount() + orders.getReceiveAccount()); | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | memberRevenue.setRemark(Constants.RevenueType.getInfo(memberRevenue.getType()) + "-" + | 
|---|
|  |  |  | (Constants.equalsInteger(orders.getWorkType(),Constants.ZERO)?"采摘工":(Constants.equalsInteger(orders.getWorkType(),Constants.ONE)?"分拣工":"包装工"))); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | memberRevenue.setRemark(Constants.RevenueType.getInfo(memberRevenue.getType())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | memberRevenue.setObjId(orders.getId()); | 
|---|
|  |  |  | memberRevenue.setObjType(Constants.ZERO); | 
|---|
|  |  |  | memberRevenue.setStatus(Constants.ZERO); | 
|---|
|  |  |  | 
|---|
|  |  |  | ordersLog.getInfo(),orders.getReleaseMemberId(),null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TODO 通知接单方 款项已到账 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return  ("处理成功!"); | 
|---|
|  |  |  | 
|---|
|  |  |  | MPJLambdaWrapper<Orders> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | Orders model = pageWrap.getModel(); | 
|---|
|  |  |  | if(Objects.isNull(model) | 
|---|
|  |  |  | || Objects.isNull(model.getQueryLat()) | 
|---|
|  |  |  | || Objects.isNull(model.getQueryLgt()) | 
|---|
|  |  |  | || Objects.isNull(model.getQueryMyOrderType()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BigDecimal chefLat = model.getQueryLat(); | 
|---|
|  |  |  | BigDecimal chefLgt = model.getQueryLgt(); | 
|---|
|  |  |  | BigDecimal driverLat = model.getQueryLat(); | 
|---|
|  |  |  | BigDecimal driverLgt = model.getQueryLgt(); | 
|---|
|  |  |  | BigDecimal workerLat = model.getQueryLat(); | 
|---|
|  |  |  | BigDecimal workerLgt = model.getQueryLgt(); | 
|---|
|  |  |  | IdentityInfo wokerIdentityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | .eq(IdentityInfo::getType,Constants.ZERO) | 
|---|
|  |  |  | .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.nonNull(wokerIdentityInfo)){ | 
|---|
|  |  |  | workerLat = wokerIdentityInfo.getLat(); | 
|---|
|  |  |  | workerLgt = wokerIdentityInfo.getLgt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | IdentityInfo driverIdentityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | .eq(IdentityInfo::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.nonNull(driverIdentityInfo)){ | 
|---|
|  |  |  | driverLat = driverIdentityInfo.getLat(); | 
|---|
|  |  |  | driverLgt = driverIdentityInfo.getLgt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | IdentityInfo chefIdentityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | .eq(IdentityInfo::getType,Constants.TWO) | 
|---|
|  |  |  | .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.nonNull(chefIdentityInfo)){ | 
|---|
|  |  |  | chefLat = chefIdentityInfo.getLat(); | 
|---|
|  |  |  | chefLgt = chefIdentityInfo.getLgt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | queryWrapper.selectAll(Orders.class) | 
|---|
|  |  |  | .select("c1.name",Orders::getCategoryName) | 
|---|
|  |  |  | .select("c2.name",Orders::getTransportTypeName) | 
|---|
|  |  |  | .leftJoin(" category c1 on t.category_id = c1.id  ") | 
|---|
|  |  |  | .leftJoin(" category c2 on t.TRANSPORT_TYPE_ID = c2.id  "); | 
|---|
|  |  |  | .leftJoin(" category c2 on t.TRANSPORT_TYPE_ID = c2.id  ") | 
|---|
|  |  |  | .select(" case when T.LGT IS NULL OR T.LAT IS NULL THEN 0 " + | 
|---|
|  |  |  | " when t.TYPE = 0 then CONVERT( ST_Distance_Sphere ( POINT ( t.LGT, t.LAT ), POINT ( "+workerLgt+", "+workerLat+" )) /1000,DECIMAL(15,2))  " + | 
|---|
|  |  |  | " when t.TYPE = 1 then   CONVERT( ST_Distance_Sphere ( POINT ( t.LGT, t.LAT ), POINT ( "+driverLgt+", "+driverLat+" )) /1000,DECIMAL(15,2)) " + | 
|---|
|  |  |  | " else  CONVERT( ST_Distance_Sphere ( POINT ( t.LGT, t.LAT ), POINT ( "+chefLgt+", "+chefLat+" )) /1000,DECIMAL(15,2)) end " , Orders::getDistance) | 
|---|
|  |  |  | .eq(Objects.nonNull(model.getType()),Orders::getType,model.getType()); | 
|---|
|  |  |  | if(Objects.nonNull(model.getQueryMyOrderType())){ | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getQueryMyOrderType(),Constants.ZERO)){ | 
|---|
|  |  |  | //发单方 我的订单 | 
|---|
|  |  |  | queryWrapper.eq(Orders::getReleaseMemberId,model.getMember().getId()); | 
|---|
|  |  |  | queryWrapper.eq(Objects.nonNull(model.getStatus()),Orders::getStatus,model.getStatus()); | 
|---|
|  |  |  | queryWrapper.orderByDesc(Orders::getCreateTime); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(model.getQueryMyOrderType(),Constants.ONE)){ | 
|---|
|  |  |  | //接单方 我的订单 | 
|---|
|  |  |  | queryWrapper.eq(Orders::getAcceptMemberId,model.getMember().getId()); | 
|---|
|  |  |  | queryWrapper.eq(Objects.nonNull(model.getStatus()),Orders::getStatus,model.getStatus()); | 
|---|
|  |  |  | queryWrapper.orderByDesc(Orders::getCreateTime); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //查询用户的接单权重 | 
|---|
|  |  |  | ReceiveWeight receiveWeight = receiveWeightMapper.selectOne(new QueryWrapper<ReceiveWeight>().lambda().eq(ReceiveWeight::getDeleted,Constants.ZERO).apply(" RECEIVE_MIN < "+model.getMember().getReceiveNum()+" and RECEIVE_MAX > " + model.getMember().getReceiveNum()).last(" limit 1 ")); | 
|---|
|  |  |  | if(Objects.nonNull(receiveWeight)){ | 
|---|
|  |  |  | queryWrapper.apply(" DATE_ADD(t.CREATE_TIME, INTERVAL "+receiveWeight.getDelayTime()+" MINUTE)  < now() "); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | queryWrapper.eq(Orders::getStatus,Constants.ordersStatus.wait.getKey()); | 
|---|
|  |  |  | //接单大厅 | 
|---|
|  |  |  | 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.apply(!(Constants.equalsInteger(model.getMember().getWorkerIdentity(),Constants.TWO)||Constants.equalsInteger(model.getMember().getDriverIdentity(),Constants.TWO)||Constants.equalsInteger(model.getMember().getChefIdentity(),Constants.TWO))," 1 = 2 " | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.ne(Orders::getReleaseMemberId,model.getMember().getId()); | 
|---|
|  |  |  | if(Objects.nonNull(model.getSortType())){ | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getSortType(),Constants.ZERO)){ | 
|---|
|  |  |  | queryWrapper.orderByDesc(Orders::getCreateTime); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(model.getSortType(),Constants.ONE)){ | 
|---|
|  |  |  | queryWrapper.orderByAsc(" distance  "); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | queryWrapper.orderByDesc(Orders::getEstimatedAccount); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
|---|
|  |  |  | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
|---|
|  |  |  | queryWrapper.orderByDesc(sortData.getProperty()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | queryWrapper.orderByAsc(sortData.getProperty()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | IPage<Orders> iPage = ordersMapper.selectJoinPage(page,Orders.class,queryWrapper); | 
|---|
|  |  |  | if(Objects.nonNull(model.getQueryMyOrderType())&&Constants.equalsInteger(model.getQueryMyOrderType(),Constants.TWO)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getMember().getUseIdentity(),Constants.ONE)){ | 
|---|
|  |  |  | model.getMember().setWorkerIdentityModel( | 
|---|
|  |  |  | identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | .eq(IdentityInfo::getType,Constants.ZERO) | 
|---|
|  |  |  | .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | model.getMember().setDriverIdentityModel( | 
|---|
|  |  |  | identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | .eq(IdentityInfo::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | model.getMember().setChefIdentityModel( | 
|---|
|  |  |  | identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | .eq(IdentityInfo::getType,Constants.TWO) | 
|---|
|  |  |  | .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (Orders orders:iPage.getRecords()) { | 
|---|
|  |  |  | this.getDistance(model.getMember(),orders); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (Orders orders:iPage.getRecords()) { | 
|---|
|  |  |  | this.getPriceUnit(orders); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if(Objects.nonNull(model.getQueryMyOrderType())&&Constants.equalsInteger(model.getQueryMyOrderType(),Constants.TWO)){ | 
|---|
|  |  |  | //            if(Constants.equalsInteger(model.getMember().getUseIdentity(),Constants.ONE)){ | 
|---|
|  |  |  | //                model.getMember().setWorkerIdentityModel( | 
|---|
|  |  |  | //                        identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | //                                .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | //                                .eq(IdentityInfo::getType,Constants.ZERO) | 
|---|
|  |  |  | //                                .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | //                                .last("limit 1") | 
|---|
|  |  |  | //                        ) | 
|---|
|  |  |  | //                ); | 
|---|
|  |  |  | //                model.getMember().setDriverIdentityModel( | 
|---|
|  |  |  | //                        identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | //                                .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | //                                .eq(IdentityInfo::getType,Constants.ONE) | 
|---|
|  |  |  | //                                .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | //                                .last("limit 1") | 
|---|
|  |  |  | //                        ) | 
|---|
|  |  |  | //                ); | 
|---|
|  |  |  | //                model.getMember().setChefIdentityModel( | 
|---|
|  |  |  | //                        identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() | 
|---|
|  |  |  | //                                .eq(IdentityInfo::getMemberId,model.getMember().getId()) | 
|---|
|  |  |  | //                                .eq(IdentityInfo::getType,Constants.TWO) | 
|---|
|  |  |  | //                                .eq(IdentityInfo::getAuditStatus,Constants.TWO) | 
|---|
|  |  |  | //                                .last("limit 1") | 
|---|
|  |  |  | //                        ) | 
|---|
|  |  |  | //                ); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            for (Orders orders:iPage.getRecords()) { | 
|---|
|  |  |  | //               this.getDistance(model.getMember(),orders); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | return PageData.from(iPage); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public Orders getDetail(Integer id,Integer userType) { | 
|---|
|  |  |  | Orders orders = ordersMapper.selectJoinOne(Orders.class,new MPJLambdaWrapper<Orders>() | 
|---|
|  |  |  | .selectAll(Orders.class) | 
|---|
|  |  |  | .select(" m1.name " , Orders::getReleaseName) | 
|---|
|  |  |  | .select(" m1.telephone " , Orders::getReleasePhone) | 
|---|
|  |  |  | .select(" case when i.AUTH_TYPE = 0 then i.LINK_NAME else i.COMPANY_NAME end " , Orders::getAcceptName) | 
|---|
|  |  |  | .select(" i.TELEPHONE " , Orders::getAcceptPhone) | 
|---|
|  |  |  | .select("c1.name",Orders::getCategoryName) | 
|---|
|  |  |  | .select("c2.name",Orders::getTransportTypeName) | 
|---|
|  |  |  | .select(" m2.SCORE " , Orders::getScore) | 
|---|
|  |  |  | .select(" m1.PUBLISH_NUM " , Orders::getPublishNum) | 
|---|
|  |  |  | .select(" m2.RECEIVE_NUM " , Orders::getReceiveNum) | 
|---|
|  |  |  | .select(" m1.COVER_IMAGE " , Orders::getReleaseCoverImage) | 
|---|
|  |  |  | .select(" m2.COVER_IMAGE " , Orders::getAcceptCoverImage) | 
|---|
|  |  |  | .leftJoin(" category c1 on t.category_id = c1.id  ") | 
|---|
|  |  |  | .leftJoin(" category c2 on t.TRANSPORT_TYPE_ID = c2.id  ") | 
|---|
|  |  |  | .leftJoin("member m1 on t.RELEASE_MEMBER_ID = m1.id ") | 
|---|
|  |  |  | .leftJoin("member m2 on t.ACCEPT_MEMBER_ID = m2.id ") | 
|---|
|  |  |  | .leftJoin("identity_info i on m2.id = i.MEMBER_ID and i.TYPE = t.type and i.AUDIT_STATUS = 2  ") | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .eq(Orders::getId,id) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.isNull(orders)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Objects.nonNull(userType)){ | 
|---|
|  |  |  | Member member = memberMapper.selectById( | 
|---|
|  |  |  | Constants.equalsInteger(userType,Constants.ZERO)?orders.getReleaseMemberId():orders.getAcceptMemberId() | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.nonNull(member)){ | 
|---|
|  |  |  | if(org.apache.commons.lang3.StringUtils.isNotBlank(member.getCoverImage())){ | 
|---|
|  |  |  | //头像信息 | 
|---|
|  |  |  | String path  = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.MEMBER_FILES).getCode(); | 
|---|
|  |  |  | member.setFullCoverImage(path + member.getCoverImage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setMember(member); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //头像信息 | 
|---|
|  |  |  | String coverPath  = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.MEMBER_FILES).getCode(); | 
|---|
|  |  |  | if(org.apache.commons.lang3.StringUtils.isNotBlank(orders.getReleaseCoverImage())){ | 
|---|
|  |  |  | orders.setReleaseCoverImage(coverPath + orders.getReleaseCoverImage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(org.apache.commons.lang3.StringUtils.isNotBlank(orders.getAcceptCoverImage())){ | 
|---|
|  |  |  | orders.setAcceptCoverImage(coverPath + orders.getAcceptCoverImage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda().eq(Multifile::getObjId,orders.getId()) | 
|---|
|  |  |  | .eq(Multifile::getIsdeleted,Constants.ZERO).eq(Multifile::getObjType,Constants.ONE).orderByAsc(Multifile::getId)); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setMultifileList(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orders.setStatusName(Constants.ordersStatus.getName(orders.getStatus())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return orders; | 
|---|
|  |  |  | } | 
|---|