| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.mchange.util.FailSuppressedMessageLogger; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.system.dao.DriverActivityHistoryMapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.ALiSendSms; |
| | | import com.stylefeng.guns.modular.system.util.DateUtil; |
| | | import com.stylefeng.guns.modular.system.util.EmailUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil; |
| | | import com.stylefeng.guns.modular.system.warpper.*; |
| | | import com.stylefeng.guns.modular.system.warpper.BalanceUsageRecord; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class DriverController { |
| | | |
| | | private Logger log = LoggerFactory.getLogger(DriverController.class); |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | |
| | | |
| | | @Autowired |
| | | private TEmailService emailService; |
| | | |
| | | @Resource |
| | | private DriverActivityHistoryMapper driverActivityHistoryMapper; |
| | | |
| | | @Resource |
| | | private IBalanceUsageRecordService balanceUsageRecordService; |
| | | |
| | | @Autowired |
| | | private FleetEngineUtil fleetEngineUtil; |
| | | |
| | | @Autowired |
| | | private IOrderCancelService orderCancelService; |
| | | |
| | | |
| | | |
| | |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Map<String, Object> map = driverService.queryInfo(language, uid); |
| | | map.put("qrCodeIsOpen",driverService.getAppOpenInfo(1)==1); |
| | | map.put("qrCodeIsOpen", driverService.getAppOpenInfo(1)==1); |
| | | DriverInfoWarpper driverInfoWarpper = DriverInfoWarpper.getDriverInfoWarpper(map); |
| | | // Double money = driverService.getThisWeekMoney(uid); |
| | | // driverInfoWarpper.setLaveBusinessMoney(driverInfoWarpper.getLaveBusinessMoney()-(money==null?0d:money)); |
| | |
| | | List<Map<String, Object>> list = driverService.queryActivityIncome(language, uid, pageNum, size); |
| | | List<BaseWarpper> data = new ArrayList<>(); |
| | | for(Map<String, Object> map : list){ |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | baseWarpper.setDay(String.valueOf(null != map.get("time") ? map.get("time") : "")); |
| | | baseWarpper.setAmount(Double.valueOf(String.valueOf(null != map.get("money") ? map.get("money") : 0))); |
| | | baseWarpper.setName(language == 1 ? "活动奖励" : language == 2 ? "Activity reward" : "Récompenses pour événements"); |
| | | data.add(baseWarpper); |
| | | String incomeId = map.get("incomeId").toString(); |
| | | DriverActivityHistory driverActivityHistory = driverActivityHistoryMapper.selectById(incomeId); |
| | | if(null == driverActivityHistory){ |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | baseWarpper.setDay(String.valueOf(null != map.get("time") ? map.get("time") : "")); |
| | | baseWarpper.setAmount(Double.valueOf(String.valueOf(null != map.get("money") ? map.get("money") : 0))); |
| | | baseWarpper.setName(language == 1 ? "活动奖励" : language == 2 ? "Activity reward" : "Récompenses pour événements"); |
| | | data.add(baseWarpper); |
| | | }else{ |
| | | Integer type = driverActivityHistory.getType(); |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | baseWarpper.setDay(String.valueOf(null != map.get("time") ? map.get("time") : "")); |
| | | baseWarpper.setAmount(Double.valueOf(String.valueOf(null != map.get("money") ? map.get("money") : 0))); |
| | | switch (type){ |
| | | case 1: |
| | | baseWarpper.setName(language == 1 ? "邀请司机奖励(活动)" : language == 2 ? "Invite drivers and earn" : "Invitez des chauffeurs et gagnez de l’argent"); |
| | | break; |
| | | case 2: |
| | | baseWarpper.setName(language == 1 ? "邀请用户奖励(活动)" : language == 2 ? "Invite users and earn" : "Invitez des utilisateurs et gagnez de l’argent"); |
| | | break; |
| | | case 3: |
| | | baseWarpper.setName(language == 1 ? "在线时长奖励(活动)" : language == 2 ? "Online-duration reward activity" : "Activité de récompense en ligne"); |
| | | break; |
| | | case 4: |
| | | baseWarpper.setName(language == 1 ? "累计接单奖励(活动)" : language == 2 ? "Cumulative order activity" : "Activité cumulée des commandes"); |
| | | break; |
| | | } |
| | | data.add(baseWarpper); |
| | | } |
| | | } |
| | | return ResultUtil.success(data); |
| | | }catch (Exception e){ |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryTotalRevenue") |
| | | @ApiOperation(value = "获取收入明细", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiOperation(value = "获取收入明细【2.0】", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), |
| | |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<Map<String, Object>> list = driverService.queryTotalRevenue(language, uid, pageNum, size); |
| | | |
| | | List<BaseWarpper> data = new ArrayList<>(); |
| | | for(Map<String, Object> map : list){ |
| | | String type = map.get("type").toString(); |
| | |
| | | if("2".equals(type)){ |
| | | switch (Integer.valueOf(String.valueOf(null != map.get("orderType") ? map.get("orderType") : 0))){ |
| | | case 1: |
| | | baseWarpper.setName(language == 1 ? "打车" : language == 2 ? "Ride" : "Course"); |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(map.get("incomeId").toString()); |
| | | if(null == orderPrivateCar){ |
| | | continue; |
| | | } |
| | | baseWarpper.setName(language == 1 ? (orderPrivateCar.getCancelMidway() == 0 ? "" : "【途中取消】") + "打车" : language == 2 ? (orderPrivateCar.getCancelMidway() == 0 ? "" : "【Cancelled during the trip】") + "Ride" : (orderPrivateCar.getCancelMidway() == 0 ? "" : "【Annulé en cours de voyage】") + "Course"); |
| | | break; |
| | | case 2: |
| | | baseWarpper.setName(language == 1 ? "出租车" : language == 2 ? "taxi" : "taxi"); |
| | |
| | | baseWarpper.setName(language == 1 ? "城际出行" : language == 2 ? "Intercity travel" : "Mobilité entre villes"); |
| | | break; |
| | | case 4: |
| | | baseWarpper.setName(language == 1 ? "包裹" : language == 2 ? "Delivery" : "Livraison"); |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(map.get("incomeId").toString()); |
| | | if(null == orderLogistics){ |
| | | continue; |
| | | } |
| | | baseWarpper.setName(language == 1 ? (orderLogistics.getCancelMidway() == 0 ? "" : "【途中取消】") + "包裹" : language == 2 ? (orderLogistics.getCancelMidway() == 0 ? "" : "【Cancelled during the trip】") + "Delivery" : (orderLogistics.getCancelMidway() == 0 ? "" : "【Annulé en cours de voyage】") + "Livraison"); |
| | | break; |
| | | case 5: |
| | | baseWarpper.setName(language == 1 ? "跨城小件物流" : language == 2 ? "Cross-city small parts logistics" : "Logistique des petites pièces à travers la ville"); |
| | |
| | | break; |
| | | case 2: |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(map.get("incomeId").toString()); |
| | | if(null == orderTaxi){ |
| | | continue; |
| | | } |
| | | List<Income> incomes1 = incomeService.queryData(1, null, 2, orderTaxi.getId(), 2); |
| | | map1.put("travelMoney", orderTaxi != null ? orderTaxi.getTravelMoney() : 0);//行程费 |
| | | map1.put("parkMoney", orderTaxi != null ? orderTaxi.getParkMoney() : 0);//停车费 |
| | |
| | | break; |
| | | case 3: |
| | | OrderCrossCity orderCrossCity = orderCrossCityService.selectById(map.get("incomeId").toString()); |
| | | if(null == orderCrossCity){ |
| | | continue; |
| | | } |
| | | List<Income> incomes2 = incomeService.queryData(1, null, 2, orderCrossCity.getId(), 3); |
| | | map1.put("travelMoney", orderCrossCity != null ? orderCrossCity.getOrderMoney() : 0);//行程费 |
| | | map1.put("parkMoney", 0);//停车费 |
| | |
| | | break; |
| | | case 4: |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(map.get("incomeId").toString()); |
| | | if(null == orderLogistics){ |
| | | continue; |
| | | } |
| | | List<Income> incomes3 = incomeService.queryData(1, null, 2, orderLogistics.getId(), 4); |
| | | map1.put("travelMoney", orderLogistics != null ? orderLogistics.getTravelMoney() : 0);//行程费 |
| | | map1.put("parkMoney", 0);//停车费 |
| | | map1.put("tipMoney", orderLogistics != null ? orderLogistics.getTipMoney() : 0);//小费 |
| | | map1.put("roadTollMoney", 0);//过路费 |
| | | map1.put("travelMoney", orderLogistics != null ? orderLogistics.getOrderMoney() : 0);//行程费 |
| | | map1.put("parkMoney", orderLogistics != null ? orderLogistics.getParkMoney() : 0);//停车费 |
| | | map1.put("tipMoney", 0);//小费 |
| | | map1.put("roadTollMoney", orderLogistics != null ? orderLogistics.getRoadTollMoney() : 0);//过路费 |
| | | map1.put("rakeMoney", incomes3.size() > 0 ? incomes3.get(0).getMoney() : 0);//抽成 |
| | | break; |
| | | case 5: |
| | | OrderLogistics orderLogistics1 = orderLogisticsService.selectById(map.get("incomeId").toString()); |
| | | if(null == orderLogistics1){ |
| | | continue; |
| | | } |
| | | List<Income> incomes4 = incomeService.queryData(1, null, 2, orderLogistics1.getId(), 5); |
| | | map1.put("travelMoney", orderLogistics1 != null ? orderLogistics1.getTravelMoney() : 0);//行程费 |
| | | map1.put("parkMoney", 0);//停车费 |
| | | map1.put("tipMoney", orderLogistics1 != null ? orderLogistics1.getTipMoney() : 0);//小费 |
| | | map1.put("roadTollMoney", 0);//过路费 |
| | | map1.put("travelMoney", orderLogistics1 != null ? orderLogistics1.getOrderMoney() : 0);//行程费 |
| | | map1.put("parkMoney", orderLogistics1 != null ? orderLogistics1.getParkMoney() : 0);//停车费 |
| | | map1.put("tipMoney", 0);//小费 |
| | | map1.put("roadTollMoney", orderLogistics1 != null ? orderLogistics1.getRoadTollMoney() : 0);//过路费 |
| | | map1.put("rakeMoney", incomes4.size() > 0 ? incomes4.get(0).getMoney() : 0);//抽成 |
| | | break; |
| | | } |
| | |
| | | break; |
| | | } |
| | | baseWarpper.setName(language == 1 ? "取消订单费用" : language == 2 ? "Cancellation fee" : "Frais d'annulation"); |
| | | baseWarpper.setData(new Object()); |
| | | List<Income> incomes = incomeService.queryData(1, 1, 3, Integer.valueOf(map.get("incomeId").toString()), Integer.valueOf(map.get("orderType").toString())); |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | |
| | | OrderCancel orderCancel = orderCancelService.selectOne(new EntityWrapper<OrderCancel>().eq("orderType", map.get("orderType")) |
| | | .eq("orderId", map.get("incomeId")).eq("state", 2)); |
| | | map1.put("travelMoney", orderCancel.getMoney());//支付金额 |
| | | map1.put("rakeMoney", incomes.size() > 0 ? incomes.get(0).getMoney() : 0);//抽成 |
| | | baseWarpper.setData(map1); |
| | | } |
| | | if("5".equals(type)){ |
| | | switch (Integer.valueOf(String.valueOf(null != map.get("orderType") ? map.get("orderType") : 0))){ |
| | |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | List<ActivityWarpper> activityWarppers = driverService.queryMyActivity(uid, sdf.parse(time), language); |
| | | List<ActivityWarpper> activityWarppers = driverService.queryHistoryList(uid, sdf.parse(time), language); |
| | | return ResultUtil.success(activityWarppers); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryBalanceUsageRecord") |
| | | @ApiOperation(value = "获取余额使用记录【2.0】", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "体现类型(1=活动收入,2=业务收入)", name = "type", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<BalanceUsageRecord> queryBalanceUsageRecord(Integer language, Integer pageNum, Integer size, Integer type, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | BalanceUsageRecord balanceUsageRecord = new BalanceUsageRecord(); |
| | | balanceUsageRecord.setTotal(balanceUsageRecordService.queryBalanceUsageRecordSum(uid, type)); |
| | | balanceUsageRecord.setList(balanceUsageRecordService.queryBalanceUsageRecord(language, uid, type, pageNum, size)); |
| | | return ResultUtil.success(balanceUsageRecord); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/getFleetEngineAuth") |
| | | @ApiOperation(value = "获取google地图授权token", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "车辆id", name = "vehicleId", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<Map<String, Object>> getFleetEngineAuth(String vehicleId, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | if(!StringUtils.hasLength(vehicleId)){ |
| | | return ResultUtil.paranErr(); |
| | | } |
| | | Map<String, Object> s = fleetEngineUtil.fleetEngineAuth(2, vehicleId); |
| | | return ResultUtil.success(s); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/textToSpeech") |
| | | @ApiOperation(value = "获取语音播报文件地址", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "语言", name = "languageCode", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "内容", name = "text", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "文件名称", name = "fileName", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil textToSpeech(String languageCode, String text, String fileName){ |
| | | try { |
| | | String s = TextToSpeechUtil.create(languageCode, text, fileName + ".mp3"); |
| | | //定时任务删除语音文件 |
| | | new Timer().schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | // 使用Runtime执行命令 |
| | | Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName + ".mp3"); |
| | | // 读取命令的输出 |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | System.out.println(line); |
| | | } |
| | | // 等待命令执行完成 |
| | | process.waitFor(); |
| | | // 关闭流 |
| | | reader.close(); |
| | | } catch (IOException | InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }, 30000); |
| | | return ResultUtil.success(s); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 手动添加当日活动 |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/base/driver/addTodayActivity") |
| | | public void addTodayActivity(){ |
| | | try { |
| | | driverService.addTodayActivity(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 短信回调通知 |
| | | * @param request |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/sendCellulantMessageCallback") |
| | | public void sendCellulantMessageCallback(HttpServletRequest request){ |
| | | try { |
| | | StringBuilder sb = new StringBuilder(); |
| | | InputStream inputStream = request.getInputStream(); |
| | | String s; |
| | | BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); |
| | | while ((s = in.readLine()) != null) { |
| | | sb.append(s); |
| | | } |
| | | in.close(); |
| | | inputStream.close(); |
| | | log.info("短信通知回调:" + sb.toString()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |