| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | @Autowired |
| | | private IRechargeRecordService rechargeRecordService; |
| | | |
| | | @Autowired |
| | | private IOrderService orderService; |
| | | |
| | | @Autowired |
| | | private ICompanyFundFlowService companyFundFlowService; |
| | | |
| | | @Value("${wx.appletsAppid}") |
| | | private String appletsAppid; |
| | | |
| | |
| | | */ |
| | | public Order getOrderPrice(Integer type, Double distance, Integer waitTime, Order order, String city){ |
| | | order = getOrderInitialPrice(order); |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5)); |
| | | Integer driverId = order.getDriverId(); |
| | | Driver driver = driverService.selectById(driverId); |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5).eq("companyId",driver.getBranchOfficeId())); |
| | | if(null == systemConfig){ |
| | | if(type == 1){//预估金额 |
| | | order.setEstimatedPrice(0D); |
| | |
| | | Double num7 = extraCost.getDouble("num7");//恶劣天气超出公里 |
| | | Double num8 = extraCost.getDouble("num8");//恶劣天气超出公里单价 X/公里 |
| | | Double num9 = extraCost.getDouble("num9");//恶劣天气最高收取金额 |
| | | Double num10 = extraCost.getDouble("num10");//节假日收费 |
| | | // Double num11 = extraCost.getDouble("num11");//恶劣天气最高收取金额 |
| | | // Double num12 = extraCost.getDouble("num12");//恶劣天气最高收取金额 |
| | | |
| | | //等待费用 |
| | | if(waitTime.compareTo(num1 * 60) >= 0){ |
| | |
| | | } |
| | | |
| | | //恶劣天气 |
| | | systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8)); |
| | | systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8).eq("companyId",driver.getBranchOfficeId())); |
| | | if(null != systemConfig){ |
| | | JSONObject jsonObject1 = JSON.parseObject(systemConfig.getContent()); |
| | | Integer num11 = jsonObject1.getInteger("num1");//开启恶劣天气计价 |
| | | if(1 == num11){ |
| | | boolean badWeather = WeatherUtil.isBadWeather(city); |
| | | if(badWeather){ |
| | | // boolean badWeather = WeatherUtil.isBadWeather(city); |
| | | // if(badWeather){ |
| | | order.setBadWeatherDistance(num5);//恶劣天气公里 |
| | | order.setBadWeatherPrice(num6);//恶劣天气费 |
| | | if(distance.compareTo(num7) > 0){ |
| | |
| | | order.setOverBadWeatherPrice(subtract.doubleValue());//恶劣天气超出公里费 |
| | | } |
| | | } |
| | | } |
| | | // } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //节假日 |
| | | systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 9).eq("companyId",driver.getBranchOfficeId())); |
| | | if(null != systemConfig){ |
| | | JSONObject jsonObject1 = JSON.parseObject(systemConfig.getContent()); |
| | | Integer num11 = jsonObject1.getInteger("num1");//开启恶劣天气计价 |
| | | if(1 == num11){ |
| | | BigDecimal bigDecimal = new BigDecimal(num10); |
| | | order.setHolidayPrice(bigDecimal.doubleValue()); |
| | | } |
| | | } |
| | | |
| | | |
| | | //计算总金额 |
| | | BigDecimal bigDecimal = new BigDecimal(order.getStartPrice() + order.getOverDrivePrice() + order.getLongDistancePrice() + order.getOverLongDistancePrice() + |
| | | order.getWaitTimePrice() + order.getOutWaitTimePrice() + order.getBadWeatherPrice() + order.getOverBadWeatherPrice() - order.getDiscountAmount()).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | order.getWaitTimePrice() + order.getOutWaitTimePrice() + order.getBadWeatherPrice() + order.getOverBadWeatherPrice()+order.getHolidayPrice() - order.getDiscountAmount()).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | |
| | | if(type == 1){//预估价 |
| | | order.setEstimatedPrice(bigDecimal.doubleValue()); |
| | |
| | | order.setCouponId(null);//优惠券 |
| | | order.setDiscountAmount(0D);//折扣优惠金额 |
| | | order.setDiscount(0D);//折扣 |
| | | order.setHolidayPrice(0D); |
| | | return order; |
| | | } |
| | | |
| | |
| | | if(null != order){ |
| | | return ResultUtil.error("您还有正在进行的订单"); |
| | | } |
| | | |
| | | String value = redisUtil.getValue("USER" + uid); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | redisUtil.setStrValue("USER" + uid, System.currentTimeMillis() + "", 60); |
| | | }else{ |
| | | Long s = System.currentTimeMillis() - Long.valueOf(value); |
| | | if(s.compareTo(60000L) < 0){//1分钟 |
| | | return ResultUtil.error("数据处理中"); |
| | | } |
| | | redisUtil.setStrValue("USER" + uid, System.currentTimeMillis() + "", 60); |
| | | } |
| | | |
| | | |
| | | String startAddress = travelOrder.getStartAddress(); |
| | | startAddress = startAddress.replaceAll("& #40;", "("); |
| | |
| | | continue; |
| | | } |
| | | Driver driver1 = driverService.selectById(youTuiDriver.getDriverId()); |
| | | if(driver1.getServerStatus() == 2 || driver1.getOpenOrderQRCode() == 1){ |
| | | int count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", youTuiDriver.getDriverId()).eq("status", 1).in("state", Arrays.asList(102, 103, 104, 105, 201, 401))); |
| | | if(driver1.getServerStatus() == 2 || driver1.getOpenOrderQRCode() == 1 || count > 0){ |
| | | continue; |
| | | } |
| | | DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId()).eq("status", 1)); |
| | |
| | | } |
| | | DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId()).eq("status", 1)); |
| | | if(null == driverWork){ |
| | | continue; |
| | | } |
| | | int count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", driver1.getId()).eq("status", 1).in("state", Arrays.asList(102, 103, 104, 105, 201, 401))); |
| | | if(count > 0){ |
| | | continue; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public ResultUtil editOrderEndAddress(Integer uid, EditOrderEndAddress editOrderEndAddress) throws Exception { |
| | | Order order = this.selectById(editOrderEndAddress.getOrderId()); |
| | | |
| | | String endAddress = editOrderEndAddress.getEndAddress(); |
| | | endAddress = endAddress.replaceAll("& #40;", "("); |
| | | endAddress = endAddress.replaceAll("& #41;", ")"); |
| | | editOrderEndAddress.setEndAddress(endAddress); |
| | | |
| | | order.setEndAddress(editOrderEndAddress.getEndAddress()); |
| | | order.setEndLat(editOrderEndAddress.getEndLat().toString()); |
| | | order.setEndLng(editOrderEndAddress.getEndLng().toString()); |
| | |
| | | orderPriceWarpper.setDiscountedPrice(order.getDiscountedPrice()); |
| | | orderPriceWarpper.setBadWeatherPrice(order.getBadWeatherPrice()); |
| | | orderPriceWarpper.setPayMoney(order.getPayMoney()); |
| | | orderPriceWarpper.setOrderMoney(order.getOrderMoney()); |
| | | if(order.getState() < 107){ |
| | | orderPriceWarpper.setPayMoney(order.getOrderMoney()); |
| | | } |
| | |
| | | orderPriceWarpper.setCouponId(coupon.getId()); |
| | | } |
| | | if(payType == 1 && null == couponId && appUser.getHavDiscount() == 1 && balance.compareTo(orderMoney) >= 0){//使用余额抵扣 |
| | | orderPriceWarpper.setDiscount(9D); |
| | | orderPriceWarpper.setDiscountAmount(new BigDecimal(orderMoney * 0.1).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | orderMoney = new BigDecimal(orderMoney * 0.9).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | orderPriceWarpper.setDiscount(9.5D); |
| | | orderPriceWarpper.setDiscountAmount(new BigDecimal(orderMoney * 0.05).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | orderMoney = new BigDecimal(orderMoney * 0.95).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | if(null != couponId){ |
| | | UserToCoupon userToCoupon = userToCouponService.selectById(couponId); |
| | |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | |
| | | //补贴中分账 |
| | | Double balance = revenueService.queryCompanyBalance();//平台账户余额 |
| | | Double discountedPrice = order.getDiscountedPrice(); |
| | | List<RechargeRecord> rechargeRecords = rechargeRecordService.selectList(new EntityWrapper<RechargeRecord>().eq("type", 4).eq("payStatus", 2).gt("surplusDividedAmount", 0).orderBy("createTime")); |
| | | for (RechargeRecord rechargeRecord : rechargeRecords) { |
| | |
| | | } |
| | | } |
| | | |
| | | CompanyFundFlow companyFundFlow = new CompanyFundFlow(); |
| | | companyFundFlow.setBalance(new BigDecimal(balance)); |
| | | companyFundFlow.setObjectType(1); |
| | | companyFundFlow.setType(5); |
| | | companyFundFlow.setMoney(new BigDecimal(order.getDiscountedPrice())); |
| | | companyFundFlow.setCreateTime(new Date()); |
| | | companyFundFlowService.insert(companyFundFlow); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | //处理代理商抽佣 |
| | | if(num3 > 0 && null != driver){ |
| | | Double balance = revenueService.queryAgentBalance(driver.getAgentId()); |
| | | Revenue revenue = new Revenue(); |
| | | revenue.setType(1); |
| | | revenue.setUserType(3); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | CompanyFundFlow companyFundFlow = new CompanyFundFlow(); |
| | | companyFundFlow.setType(3); |
| | | companyFundFlow.setObjectType(2); |
| | | companyFundFlow.setObjectId(driver.getAgentId()); |
| | | companyFundFlow.setBalance(new BigDecimal(balance)); |
| | | companyFundFlow.setMoney(new BigDecimal(num3)); |
| | | companyFundFlow.setCreateTime(new Date()); |
| | | companyFundFlowService.insert(companyFundFlow); |
| | | } |
| | | } |
| | | } |
| | |
| | | revenue.setUserType(2); |
| | | revenue.setUserId(driver.getId()); |
| | | revenue.setOrderId(order.getId()); |
| | | revenue.setAmount(order.getPayMoney() + order.getDiscountedPrice() + order.getDiscountAmount()); |
| | | revenue.setAmount(order.getPayMoney() + order.getDiscountedPrice());//todo 折扣司机承担 |
| | | revenue.setCreateTime(new Date()); |
| | | revenueService.insert(revenue); |
| | | |
| | |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | |
| | | //补贴中分账 |
| | | Double balance = revenueService.queryCompanyBalance(); |
| | | Double discountedPrice = order.getDiscountedPrice(); |
| | | List<RechargeRecord> rechargeRecords1 = rechargeRecordService.selectList(new EntityWrapper<RechargeRecord>().eq("type", 4).eq("payStatus", 2).gt("surplusDividedAmount", 0).orderBy("createTime")); |
| | | for (RechargeRecord rechargeRecord : rechargeRecords1) { |
| | |
| | | } |
| | | } |
| | | } |
| | | CompanyFundFlow companyFundFlow = new CompanyFundFlow(); |
| | | companyFundFlow.setBalance(new BigDecimal(balance)); |
| | | companyFundFlow.setObjectType(1); |
| | | companyFundFlow.setType(5); |
| | | companyFundFlow.setMoney(new BigDecimal(order.getDiscountedPrice())); |
| | | companyFundFlow.setCreateTime(new Date()); |
| | | companyFundFlowService.insert(companyFundFlow); |
| | | |
| | | } |
| | | // TODO: 2023/6/25 折扣优惠由司机承担 |
| | |
| | | driverService.updateById(driver); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | //补贴中分账 |
| | | Double balance = revenueService.queryCompanyBalance(); |
| | | Double discountedPrice = order.getDiscountedPrice(); |
| | | List<RechargeRecord> rechargeRecords = rechargeRecordService.selectList(new EntityWrapper<RechargeRecord>().eq("type", 4).eq("payStatus", 2).gt("surplusDividedAmount", 0).orderBy("createTime")); |
| | | for (RechargeRecord rechargeRecord : rechargeRecords) { |
| | |
| | | } |
| | | } |
| | | |
| | | CompanyFundFlow companyFundFlow = new CompanyFundFlow(); |
| | | companyFundFlow.setBalance(new BigDecimal(balance)); |
| | | companyFundFlow.setObjectType(1); |
| | | companyFundFlow.setType(5); |
| | | companyFundFlow.setMoney(new BigDecimal(order.getDiscountedPrice())); |
| | | companyFundFlow.setCreateTime(new Date()); |
| | | companyFundFlowService.insert(companyFundFlow); |
| | | |
| | | } |
| | | } |
| | | |