zhibing.pu
2024-08-02 77bca6b387f9349d072b8737e82b42fd7f723be0
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java
@@ -12,11 +12,8 @@
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.*;
import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.warpper.*;
import com.stylefeng.guns.modular.system.warpper.BalanceUsageRecord;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
@@ -28,10 +25,12 @@
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.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -810,7 +809,7 @@
                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));
@@ -1210,6 +1209,9 @@
                    switch (Integer.valueOf(String.valueOf(null != map.get("orderType") ? map.get("orderType") : 0))){
                        case 1:
                            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:
@@ -1220,6 +1222,9 @@
                            break;
                        case 4:
                            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:
@@ -1242,6 +1247,9 @@
                            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);//停车费
@@ -1251,6 +1259,9 @@
                            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);//停车费
@@ -1260,6 +1271,9 @@
                            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("parkMoney", orderLogistics != null ? orderLogistics.getParkMoney() : 0);//停车费
                            map1.put("tipMoney", 0);//小费
@@ -1268,6 +1282,9 @@
                            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.getOrderMoney() : 0);//行程费
                            map1.put("parkMoney", 0);//停车费
@@ -1298,7 +1315,10 @@
                            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<>();
                    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))){
@@ -1732,20 +1752,73 @@
    @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<String> getFleetEngineAuth(HttpServletRequest request){
    public ResultUtil<Map<String, Object>> getFleetEngineAuth(String vehicleId, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            String s = fleetEngineUtil.fleetEngineAuth(2, uid);
            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() {
                    Process process = null;
                    try {
                        process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName + ".mp3");
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                    if (process != null) {
                        process.destroy();
                    }
                }
            }, 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);
        }
    }
}