| | |
| | | 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 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; |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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); |
| | | |
| | | } |
| | | } |
| | | |