| | |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Autowired |
| | | private ITOrderTaxiService tOrderTaxiService; |
| | | @Autowired |
| | | private ITPubTransactionDetailsService pubTransactionDetailsService; |
| | | |
| | | @Autowired |
| | | private ITOrderPositionService tOrderPositionService; |
| | |
| | | public String tOrderTaxiUpdate(@PathVariable Integer tOrderTaxiId, Model model) { |
| | | Map<String, Object> tOrderTaxi = tOrderTaxiService.getTaxiOrderDetailById(tOrderTaxiId); |
| | | model.addAttribute("item",tOrderTaxi); |
| | | // 查询司机扣款 |
| | | List<TPubTransactionDetails> tPubTransactionDetails = pubTransactionDetailsService.selectList(new EntityWrapper<TPubTransactionDetails>() |
| | | .eq("userId", tOrderTaxi.get("driverId")) |
| | | .eq("orderId", tOrderTaxi.get("id")) |
| | | .eq("type", 1) |
| | | .eq("userType", 2)); |
| | | if(CollectionUtils.isEmpty(tPubTransactionDetails)){ |
| | | model.addAttribute("companyMoney",""); |
| | | model.addAttribute("driverMoney",""); |
| | | }else { |
| | | TPubTransactionDetails pubTransactionDetailCompany = tPubTransactionDetails.stream().filter(e -> e.getOrderType().equals(6)).findFirst().orElse(null); |
| | | if(Objects.nonNull(pubTransactionDetailCompany)){ |
| | | model.addAttribute("companyMoney",pubTransactionDetailCompany.getMoney()); |
| | | }else { |
| | | model.addAttribute("companyMoney",""); |
| | | } |
| | | TPubTransactionDetails pubTransactionDetailDriver = tPubTransactionDetails.stream().filter(e -> e.getOrderType().equals(2)).findFirst().orElse(null); |
| | | if(Objects.nonNull(pubTransactionDetailCompany)){ |
| | | model.addAttribute("driverMoney",pubTransactionDetailDriver.getMoney()); |
| | | }else { |
| | | model.addAttribute("driverMoney",""); |
| | | } |
| | | } |
| | | if(tOrderTaxi.get("payManner").equals("1")){ |
| | | model.addAttribute("payMannerStr","线上收款"); |
| | | }else { |
| | | model.addAttribute("payMannerStr","计费打表"); |
| | | } |
| | | LogObjectHolder.me().set(tOrderTaxi); |
| | | return PREFIX + "tOrderTaxi_edit.html"; |
| | | } |
| | |
| | | tOrderTaxi.setSubstitute(0); |
| | | tOrderTaxi.setOrderSource(5); |
| | | tOrderTaxi.setIsDelete(1); |
| | | tOrderTaxi.setPayManner(3); |
| | | tOrderTaxiService.insert(tOrderTaxi); |
| | | if(tOrderTaxi.getState() == 1){ |
| | | //推送司机抢单 |
| | |
| | | TSysPushOrder pushOrder = pushOrderService.querys(i, 2, query.getId()).get(0); |
| | | //获取空闲司机 |
| | | List<TDriver> list = driverService.queryIdleDriver(2, orderTaxi.getStartLon(), orderTaxi.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | System.out.println("空闲司机1"+list); |
| | | if(list.size() > 0){ |
| | | double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数 |
| | | System.out.println("空闲司机2"+driverProportion); |
| | | |
| | | int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取) |
| | | System.out.println("空闲司机3"+lastIndex); |
| | | lastIndex = lastIndex == 0 ? list.size() : lastIndex; |
| | | list = list.subList(0, lastIndex);//获取空闲司机中占比数据 |
| | | System.out.println("空闲司机4"+list); |
| | | for(TDriver driver : list){//开始进行推送 |
| | | //查询是否在限制推单范围内 |
| | | boolean bo = false; |
| | | System.out.println("integers"+integers); |
| | | for(Integer integer : integers){ |
| | | System.out.println("距离"+integer); |
| | | if(integer.compareTo(driver.getId()) == 0){ |
| | | bo = true; |
| | | break; |
| | |
| | | if(bo){ |
| | | continue; |
| | | } |
| | | System.out.println("推送1"); |
| | | pushUtil.pushOrderState(2, driver.getId(), orderTaxi.getId(), 2, orderTaxi.getState(), pushOrder.getPushTime()); |
| | | System.out.println("推送2"); |
| | | } |
| | | } |
| | | Thread.sleep(pushOrder.getPushTime() * 1000);//设置等待时间 |