|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.math.RoundingMode; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.concurrent.TimeUnit; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | orders.setStatus(Constants.ordersStatus.wait.getKey()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setOriginPriceNum1(orders.getPriceNum1()); | 
|---|
|  |  |  | orders.setOriginPriceNum2(orders.getPriceNum2()); | 
|---|
|  |  |  | orders.setOriginEstimatedAccount(orders.getOriginEstimatedAccount()); | 
|---|
|  |  |  | orders.setConfirmOtherFee(0l); | 
|---|
|  |  |  | ordersMapper.insert(orders); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderReleaseVO.setId(orders.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单已修改,待接单方确认,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(model.getType(),Constants.TWO)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getStatus(),Constants.ZERO)||Constants.equalsInteger(model.getStatus(),Constants.ONE)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getStatus(),Constants.ZERO) | 
|---|
|  |  |  | ||Constants.equalsInteger(model.getStatus(),Constants.ONE)){ | 
|---|
|  |  |  | this.updateById(orders); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(model.getStatus(),Constants.TWO)){ | 
|---|
|  |  |  | this.updOrderData(orders,model); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileMapper.insert(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setOriginPriceNum1(orders.getPriceNum1()); | 
|---|
|  |  |  | orders.setOriginPriceNum2(orders.getPriceNum2()); | 
|---|
|  |  |  | orders.setOriginEstimatedAccount(orders.getOriginEstimatedAccount()); | 
|---|
|  |  |  | orders.setConfirmOtherFee(0l); | 
|---|
|  |  |  | ordersMapper.updateById(orders); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | .set(Orders::getIsUpdateTime,new Date()) | 
|---|
|  |  |  | .set(Orders::getUpdateTime,new Date()) | 
|---|
|  |  |  | .set(Orders::getEstimatedAccount,total) | 
|---|
|  |  |  | .set(Orders::getOriginEstimatedAccount,total) | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //创建操作日志 | 
|---|
|  |  |  | 
|---|
|  |  |  | return bigDecimalPrice.divide(new BigDecimal("1"),0,BigDecimal.ROUND_HALF_UP).longValue();//orders.getPrice() * orders.getPriceNum1() * orders.getPriceNum2(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 接单方确认订单费用 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void  confirmFee(ConfirmFeeOrderDTO confirmUpdOrderDTO){ | 
|---|
|  |  |  | if(Objects.isNull(confirmUpdOrderDTO) | 
|---|
|  |  |  | || Objects.isNull(confirmUpdOrderDTO.getOrderId()) | 
|---|
|  |  |  | || Objects.isNull(confirmUpdOrderDTO.getPriceNum1())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Orders orders = ordersMapper.selectById(confirmUpdOrderDTO.getOrderId()); | 
|---|
|  |  |  | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getAcceptMemberId(),confirmUpdOrderDTO.getMember().getId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.doing.getKey())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //类型:0=用工;1=运货;2=订餐 | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | //用工类型:0=采摘工;1=分拣工;2=包装工;(用工订单) | 
|---|
|  |  |  | if(Constants.equalsInteger(orders.getWorkType(),Constants.ONE)){ | 
|---|
|  |  |  | //1=分拣工 | 
|---|
|  |  |  | if( Objects.isNull(confirmUpdOrderDTO.getPriceNum2())){//必须有用工数量(人) | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if(Constants.equalsInteger(orders.getWorkType(),Constants.TWO)){ | 
|---|
|  |  |  | //包装工 用车类型(用工包装/运货使用):0=天;1=次/小时;2=重量 | 
|---|
|  |  |  | if( !Constants.equalsInteger(orders.getCarType(),Constants.TWO) | 
|---|
|  |  |  | && Objects.isNull(confirmUpdOrderDTO.getPriceNum2())){ | 
|---|
|  |  |  | //不是按重量计费的,必须有用工数量(人) | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else  if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ | 
|---|
|  |  |  | //运货订单 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该订单不支持该操作,请返回刷新重试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orders.setPriceNum1(confirmUpdOrderDTO.getPriceNum1()); | 
|---|
|  |  |  | orders.setPriceNum2(confirmUpdOrderDTO.getPriceNum2()); | 
|---|
|  |  |  | Long totalFee = this.getTotal(orders);//重新计算费用 | 
|---|
|  |  |  | Long payFee = totalFee+Constants.formatLongNum(confirmUpdOrderDTO.getConfirmOtherFee());//重新计算费用 | 
|---|
|  |  |  | BigDecimal recFee = new BigDecimal(payFee).multiply((new BigDecimal(1).subtract(Constants.formatBigDecimal(orders.getPlatformRata())))).setScale(0, RoundingMode.HALF_UP) ; | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda() | 
|---|
|  |  |  | .set(Orders::getPriceNum1,confirmUpdOrderDTO.getPriceNum1()) | 
|---|
|  |  |  | .set(Orders::getPriceNum2,confirmUpdOrderDTO.getPriceNum2()) | 
|---|
|  |  |  | .set(Orders::getConfirmFeeRemark,confirmUpdOrderDTO.getConfirmFeeRemark()) | 
|---|
|  |  |  | .set(Orders::getConfirmOtherFee,confirmUpdOrderDTO.getConfirmOtherFee()) | 
|---|
|  |  |  | .set(Orders::getEstimatedAccount,totalFee) | 
|---|
|  |  |  | .set(Orders::getStatus,Constants.ordersStatus.feeconfirm.getKey()) | 
|---|
|  |  |  | .set(Orders::getPayAccount,payFee) | 
|---|
|  |  |  | .set(Orders::getReceiveAccount,recFee.longValue()) | 
|---|
|  |  |  | .set(Orders::getUpdateTime,new Date()) | 
|---|
|  |  |  | .eq(Orders::getId,orders.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //记录同意修改的日志 | 
|---|
|  |  |  | Constants.OrdersLog ordersLog = Constants.OrdersLog.FEE_CONFIRM; | 
|---|
|  |  |  | this.saveOrderLog(orders,ordersLog, | 
|---|
|  |  |  | ordersLog.getInfo(),confirmUpdOrderDTO.getMember().getId(),null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 接单方处理订单修改 | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(orders.getType(),Constants.TWO)){ | 
|---|
|  |  |  | orders.setPayAccount(doneOrderDTO.getAmount()); | 
|---|
|  |  |  | //提成金额 | 
|---|
|  |  |  | Long tcje = Long.valueOf(new BigDecimal(orders.getPayAccount().toString()).multiply(orders.getPlatformRata()).intValue()); | 
|---|
|  |  |  | Long tcje =  (new BigDecimal(orders.getPayAccount().toString()).multiply(Constants.formatBigDecimal(orders.getPlatformRata())).setScale(0,RoundingMode.HALF_UP).longValue()); | 
|---|
|  |  |  | orders.setReceiveAccount(orders.getPayAccount() - tcje); | 
|---|
|  |  |  | orders.setOutTradeNo(UUID.randomUUID().toString().replace("-","")); | 
|---|
|  |  |  | ordersMapper.updateById(orders); | 
|---|
|  |  |  | 
|---|
|  |  |  | Member releaseMember = memberMapper.selectById(orders.getReleaseMemberId()); | 
|---|
|  |  |  | //自动派单 | 
|---|
|  |  |  | Orders model = ordersMapper.selectById(orders.getId()); | 
|---|
|  |  |  | if(!Constants.equalsInteger(model.getStatus(),Constants.ONE)){ | 
|---|
|  |  |  | if(!Constants.equalsInteger(model.getStatus(),Constants.ONE) || Constants.equalsInteger(model.getId(),model.getReleaseMemberId())){ | 
|---|
|  |  |  | //如果订单已删除 并且非发布方 | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ordersMapper.update(new UpdateWrapper<Orders>().lambda().eq(Orders::getId,model.getId()) | 
|---|