liujie
6 天以前 9828db9febf4ad5cb0b79a72eedca6922b466104
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
@@ -15,6 +15,7 @@
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.dao.SystemPriceMapper;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.model.vo.UnPayOrderVO;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.*;
import com.stylefeng.guns.modular.system.util.qianyuntong.model.QYTPaymentCallback;
@@ -65,25 +66,28 @@
    @Autowired
    private IOrderService orderService;
    @Autowired
    private IDriverService driverService;
    @Autowired
    private WeChatUtil weChatUtil;
    @Autowired
    private IOrderPrivateCarService orderPrivateCarService;
    @Autowired
    private GDMapGeocodingUtil gdMapGeocodingUtil;
    @Autowired
    private IComplaintService complaintService;
    @Autowired
    private IOrderEvaluateService orderEvaluateService;
    @Autowired
    private IOrderCrossCityService orderCrossCityService;
    @Autowired
    private IOrderLogisticsService orderLogisticsService;
@@ -132,6 +136,10 @@
    @Resource
    private RedisTemplate<String, Object> redisTemplate;
    
    @Resource
    private ISystemPriceCityService systemPriceCityService;
    
    /**
     * 获取正在进行中的订单
@@ -451,6 +459,16 @@
                    map = orderCrossCityService.queryOrderInfo(orderId);
                    break;
            }
            if(map.get("companyId") != null){
                Company companyId = companyService.selectById(map.get("companyId").toString());
                map.put("companyName", companyId.getName());
            }else {
                String string = map.get("driverId").toString();
                Driver driver = driverService.selectById(string);
                Company company = companyService.selectById(driver.getCompanyId());
                map.put("companyName", company.getName());
            }
            if(map.get("telX") != null){
                map.put("driverPhone", map.get("telX"));
            }
@@ -508,18 +526,27 @@
                }
                OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
                if(orderPrivateCar.getState()>1){
                    Map<String, Object> query1 = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId());
                    System.out.println("参数:"+orderPrivateCar.getCompanyId()+"|"+orderPrivateCar.getServerCarModelId());
                    System.out.println("query1:"+query1);
                if(orderPrivateCar.getState()>1) {
                    Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString());
                    String provinceCode = geocode.get("provinceCode");
                    String cityCode = geocode.get("cityCode");
                    String districtCode = geocode.get("districtCode");
                    //获取匹配的城市价格配置
                    SystemPriceCity systemPriceCity = systemPriceCityService.queryOne(provinceCode, cityCode, districtCode);
                    if (null == systemPriceCity) {
                        return ResultUtil.error("请先配置价格规则");
                    }
                    Map<String, Object> query1 = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId(), systemPriceCity.getId());
                    System.out.println("参数:" + orderPrivateCar.getCompanyId() + "|" + orderPrivateCar.getServerCarModelId());
                    System.out.println("query1:" + query1);
                    //开始根据不同的方式计算金额
                    if(query1!=null){
                    JSONObject jsonObject = JSON.parseObject(query1.get("content").toString());//等待费
                    JSONObject contentPutOne = JSON.parseObject(query1.get("contentPutOne").toString());//一人拼成
                    JSONObject contentNotOne = JSON.parseObject(query1.get("contentNotOne").toString());//一人未拼成
                    JSONObject contentPutTwo = JSON.parseObject(query1.get("contentPutTwo").toString());//2人拼成
                    JSONObject contentNotTwo = JSON.parseObject(query1.get("contentNotTwo").toString());//2人未拼成
                    JSONObject contentPutThree = JSON.parseObject(query1.get("contentPutThree").toString());//3人拼成
                    if (query1 != null) {
                        JSONObject jsonObject = JSON.parseObject(query1.get("content").toString());//等待费
                        JSONObject contentPutOne = JSON.parseObject(query1.get("contentPutOne").toString());//一人拼成
                        JSONObject contentNotOne = JSON.parseObject(query1.get("contentNotOne").toString());//一人未拼成
                        JSONObject contentPutTwo = JSON.parseObject(query1.get("contentPutTwo").toString());//2人拼成
                        JSONObject contentNotTwo = JSON.parseObject(query1.get("contentNotTwo").toString());//2人未拼成
                        JSONObject contentPutThree = JSON.parseObject(query1.get("contentPutThree").toString());//3人拼成
                    JSONObject contentNotThree = JSON.parseObject(query1.get("contentNotThree").toString());//3人未拼成
                    JSONObject contentExclusive = JSON.parseObject(query1.get("contentExclusive").toString());//独享
                    JSONObject contentPrice = JSON.parseObject(query1.get("contentPrice").toString());//一口价
@@ -574,6 +601,41 @@
                orderInfoWarpper.setTime(arriveTime.substring(11,arriveTime.length()-3));
            }
            return ResultUtil.success(orderInfoWarpper);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
    @ResponseBody
    @PostMapping("/api/order/addAppeal")
    @ApiOperation(value = "发起申诉", tags = {"用户端-服务中"}, notes = "",response = OrderInfoWarpper.class)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "申诉描述", name = "abnormalIntro", required = true, dataType = "String"),
            @ApiImplicitParam(value = "申诉图片", name = "abnormalImg", required = true, dataType = "String"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<OrderInfoWarpper> addAppeal(Integer orderId, Integer orderType,String abnormalIntro, String abnormalImg, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            switch (orderType){
                case 1://专车
                     orderPrivateCarService.addAppeal(uid, orderId,abnormalIntro,abnormalImg);
                    break;
                case 2://出租车
                    orderTaxiService.addAppeal(uid,orderId,abnormalIntro,abnormalImg);
                    break;
                case 3://跨城
                     orderCrossCityService.addAppeal(uid,orderId,abnormalIntro,abnormalImg);
                    break;
            }
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
@@ -1987,8 +2049,8 @@
            e.printStackTrace();
        }
    }
    /**
     * 管理后台推单
     *
@@ -2011,8 +2073,8 @@
            return ResultUtil.runErr();
        }
    }
    /**
     * 黔云通支付回调通知
     *
@@ -2028,5 +2090,86 @@
        }
        return "success";
    }
    /**
     * 推广订单支付成功回调
     *
     * @param orderId
     * @return
     */
    private void promotion(Integer orderType,Integer orderId){
        switch (orderType){
            case 1:
                orderPrivateCarService.promotion(orderId);
                break;
            case 2:
                orderTaxiService.promotion(orderId);
                break;
            case 3:
                orderCrossCityService.promotion(orderId);
                break;
            default:
                    break;
        }
    }
    @ResponseBody
    @PostMapping("/api/get/unPayOrder")
    @ApiOperation(value = "获取未支付订单", tags = {"用户端-首页"}, notes = "")
    @ApiImplicitParams({
           @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城,4=小件物流,null=全部)", name = "orderType", required = false, dataType = "int"),
           @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil getUnPayOrder( Integer orderType,  HttpServletRequest request){
        try {
            // 从Redis中获取当前用户ID
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if (null == uid) {
                return ResultUtil.tokenErr();
            }
            List<UnPayOrderVO> unpaidOrders = new ArrayList<>();
            // 根据订单类型查询对应未支付订单
            if (orderType == null || orderType == 1) {
                // 查询未支付的专车订单
                List<UnPayOrderVO> privateCarOrders = orderPrivateCarService.getUnpayPrivateOrders(uid);
                unpaidOrders.addAll(privateCarOrders);
            }
            if (orderType == null || orderType == 2) {
                // 查询未支付的出租车订单
                List<UnPayOrderVO> taxiOrders = orderTaxiService.getUnpayTaxiOrders(uid);
                unpaidOrders.addAll(taxiOrders);
            }
            if (orderType == null || orderType == 3) {
                // 查询未支付的跨城订单
                List<UnPayOrderVO> crossCityOrders = orderCrossCityService.getUnpayCrossCityOrders(uid);
                unpaidOrders.addAll(crossCityOrders);
            }
            if (orderType == null || orderType == 4 || orderType == 5) {
                // 查询未支付的物流订单(包含类型4和5)
                List<UnPayOrderVO> logisticsOrders = orderLogisticsService.getUnpayLogisticsOrders(uid);
                unpaidOrders.addAll(logisticsOrders);
            }
            // 按创建时间倒序排序(最新的订单在前)
            unpaidOrders.sort(Comparator.comparing(UnPayOrderVO::getInsertTime).reversed());
            Map<String, Object> result = new HashMap<>();
            result.put("total", unpaidOrders.size());
            result.put("orders", unpaidOrders);
            return ResultUtil.success(result);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
}