| | |
| | | |
| | | @Resource |
| | | private UserInfoMapper userInfoMapper; |
| | | |
| | | @Autowired |
| | | private ITransactionDetailsService transactionDetailsService; |
| | | @Autowired |
| | | private ICompanyService companyService; |
| | | |
| | |
| | | private IIncomeService incomeService; |
| | | @Autowired |
| | | private ISpecialAreaBillingService specialAreaBillingService; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | |
| | | }*/ |
| | | switch (state){ |
| | | case 3://出发前往预约点 |
| | | // 判断是否有其他未完成的单子 |
| | | List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.queryByState(orderPrivateCar.getUserId(), 1, 1, 3,4, 5,6); |
| | | if(!CollectionUtils.isEmpty(orderPrivateCars)){ |
| | | return ResultUtil.error("有未完成的服务订单"); |
| | | } |
| | | orderPrivateCar.setState(3); |
| | | orderPrivateCar.setSetOutTime(new Date()); |
| | | systemNoticeService.addSystemNotice(1, "司机已出发,请耐心等待", orderPrivateCar.getUserId()); |
| | |
| | | @Override |
| | | public ResultUtil confirmFees(Integer orderId, Integer type, Double parkingFee, Double crossingFee) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(Objects.nonNull(orderPrivateCar.getPriceAuditState()) && orderPrivateCar.getPriceAuditState() == 1){ |
| | | return ResultUtil.error("待平台审核中"); |
| | | } |
| | | if(orderPrivateCar.getState() != 5){ |
| | | return ResultUtil.error("异常操作,请刷新订单"); |
| | | } |
| | |
| | | if(orderNumber<=0){//判断是否是首单 |
| | | //判断是否免单 |
| | | UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | | if(userInfo.getFreeMoney().doubleValue()>0d){ |
| | | if(Objects.nonNull(userInfo.getFreeMoney()) && userInfo.getFreeMoney().doubleValue()>0d){ |
| | | if(orderPrivateCar.getOrderMoney()<=userInfo.getFreeMoney().doubleValue()){ |
| | | orderPrivateCar.setState(8); |
| | | orderPrivateCar.setIsFree(2); |
| | |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue()); |
| | | incomeService.saveData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | incomeService.saveDriverData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue(),driver.getBalance()); |
| | | }else{ |
| | | orderPrivateCar.setState(7); |
| | | orderPrivateCar.setOrderMoney(orderPrivateCar.getOrderMoney()-userInfo.getFreeMoney().doubleValue()); |
| | |
| | | orderPrivateCar.setState(7); |
| | | } |
| | | |
| | | if(orderPrivateCar.getPayMethod() == 0 && new BigDecimal(orderPrivateCar.getPaymentAdvanceMoney()).compareTo(BigDecimal.ZERO)>0 && new BigDecimal(orderPrivateCar.getPaymentAdvanceMoney()).compareTo(new BigDecimal(orderPrivateCar.getOrderMoney()))>-1) { |
| | | orderPrivateCar.setState(8); |
| | | // 退款情况 |
| | | if (new BigDecimal(orderPrivateCar.getPaymentAdvanceMoney()).compareTo(new BigDecimal(orderPrivateCar.getOrderMoney())) > 0) { |
| | | // 退款 |
| | | if (orderPrivateCar.getPayType() == 1 && orderPrivateCar.getOrderMoney() != 0) {//微信退款 |
| | | // 微信退款 |
| | | payMoneyUtil.wxRefund(orderPrivateCar.getTransactionId(), orderPrivateCar.getOrderNum(), String.valueOf(orderPrivateCar.getPaymentAdvanceMoney()), String.valueOf(new BigDecimal(orderPrivateCar.getPaymentAdvanceMoney()).subtract(new BigDecimal(orderPrivateCar.getOrderMoney()))), "/base/transferWXNotify"); |
| | | orderPrivateCar.setPayMoney(new BigDecimal(orderPrivateCar.getOrderMoney()).doubleValue()); |
| | | } |
| | | if (orderPrivateCar.getPayType() == 2 && orderPrivateCar.getOrderMoney() != 0) {//支付宝退款 |
| | | // 支付宝退款 |
| | | payMoneyUtil.aliRefund(orderPrivateCar.getTransactionId(), String.valueOf(new BigDecimal(orderPrivateCar.getPaymentAdvanceMoney()).subtract(new BigDecimal(orderPrivateCar.getOrderMoney())).multiply(new BigDecimal(100)))); |
| | | orderPrivateCar.setPayMoney(new BigDecimal(orderPrivateCar.getOrderMoney()).doubleValue()); |
| | | } |
| | | if (orderPrivateCar.getPayType() == 3 && orderPrivateCar.getOrderMoney() != 0) {//余额支付 |
| | | BigDecimal refundMoney = new BigDecimal(orderPrivateCar.getPaymentAdvanceMoney()).subtract(new BigDecimal(orderPrivateCar.getOrderMoney())); |
| | | // 余额退款 |
| | | UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | | userInfo.setBalance(new BigDecimal(userInfo.getBalance()).add(refundMoney).doubleValue()); |
| | | userInfoMapper.updateById(userInfo); |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(orderPrivateCar.getUserId(), "专车差价退款", refundMoney.doubleValue(), 2, 1, 1, 1, orderPrivateCar.getId()); |
| | | } |
| | | } else { |
| | | orderPrivateCar.setPayMoney(new BigDecimal(orderPrivateCar.getPaymentAdvanceMoney()).doubleValue()); |
| | | } |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderPrivateCar.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | if(c.compareTo(BigDecimal.ZERO)<1){ |
| | | c = BigDecimal.ZERO; |
| | | } |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderPrivateCar.getStartMoney() + orderPrivateCar.getMileageMoney() + orderPrivateCar.getWaitMoney() + orderPrivateCar.getDurationMoney() + orderPrivateCar.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue()); |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | incomeService.saveDriverData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue(), driver.getBalance()); |
| | | }else { |
| | | orderPrivateCar.setState(7); |
| | | } |
| | | |
| | | // Map<String, String> map = chinaMobileUtil.midAxbUnBindSend(orderPrivateCar.getBindId(),orderPrivateCar.getTelX()); |
| | | // if(String.valueOf(map.get("code")).equals("200")){ |
| | | // orderPrivateCar.setTelX(""); |
| | | // orderPrivateCar.setBindId(""); |
| | | // } |
| | | // 判断预估金额和订单金额差异是否大于3元 |
| | | if(BigDecimal.valueOf(orderPrivateCar.getOrderMoney()).subtract(orderPrivateCar.getEstimatedPrice()).abs().doubleValue() > 3){ |
| | | if(BigDecimal.valueOf(orderPrivateCar.getOrderMoney()).subtract(new BigDecimal(orderPrivateCar.getEstimatedPrice())).abs().doubleValue() > 3){ |
| | | orderPrivateCar.setIsException(1); |
| | | } |
| | | if(orderPrivateCar.getIsException() == 1){ |
| | | orderPrivateCar.setState(13); |
| | | } |
| | | // if(orderPrivateCar.getIsException() == 1){ |
| | | // orderPrivateCar.setState(13); |
| | | // } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | |
| | |
| | | map.put("couponMoney", orderPrivateCar.getCouponMoney());//优惠券抵扣金额 |
| | | map.put("discountMoney", orderPrivateCar.getDiscountMoney());//折扣抵扣金额 |
| | | map.put("discount", orderPrivateCar.getDiscount());//折扣 |
| | | if(Objects.isNull(orderPrivateCar.getEstimatedPrice())){ |
| | | orderPrivateCar.setEstimatedPrice(0D); |
| | | } |
| | | if(BigDecimal.valueOf(orderPrivateCar.getOrderMoney()).subtract(new BigDecimal(orderPrivateCar.getEstimatedPrice())).abs().doubleValue() > 3){ |
| | | orderPrivateCar.setIsException(1); |
| | | } |
| | | map.put("estimatedPrice", orderPrivateCar.getEstimatedPrice()); |
| | | map.put("isException", orderPrivateCar.getIsException());//是否异常 |
| | | return map; |
| | | } |
| | | |
| | |
| | | orderPrivateCar.setPriceType(priceType); |
| | | orderPrivateCar.setUpdatePrice(updatePrice); |
| | | orderPrivateCar.setPriceAuditState(1); |
| | | orderPrivateCar.setState(6); |
| | | this.updateById(orderPrivateCar); |
| | | // 推送新的价格给用户 |
| | | pushUtil.pushOrderMoney(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, updatePrice, 0); |
| | | pushUtil.pushOrderMoney(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, updatePrice, 0); |
| | | } |
| | | } |