package com.stylefeng.guns.modular.api; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService; import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics; 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.model.Driver; import com.stylefeng.guns.modular.system.model.OfflineTravelPayment; import com.stylefeng.guns.modular.system.model.OrderEvaluate; import com.stylefeng.guns.modular.system.model.UserInfo; import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.util.*; import com.stylefeng.guns.modular.system.util.LiuZhouBank.PayUtil; import com.stylefeng.guns.modular.system.util.LiuZhouBank.ResultNotification; import com.stylefeng.guns.modular.system.warpper.*; import com.stylefeng.guns.modular.taxi.model.OrderTaxi; import com.stylefeng.guns.modular.taxi.model.PaymentRecord; import com.stylefeng.guns.modular.taxi.model.TransactionDetails; import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService; import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.*; /** * 订单控制器(综合) */ @Api @RestController @RequestMapping("") public class OrderController { @Autowired private IOrderTaxiService orderTaxiService; @Autowired private IUserInfoService userInfoService; @Autowired private IOrderPositionService orderPositionService; @Autowired private PushUtil pushUtil; @Autowired private IOrderService orderService; @Autowired private IDriverService driverService; @Autowired private WeChatUtil weChatUtil; @Autowired private IOrderPrivateCarService orderPrivateCarService; @Autowired private IComplaintService complaintService; @Autowired private IOrderEvaluateService orderEvaluateService; @Autowired private IOrderCrossCityService orderCrossCityService; @Autowired private ICBCPayUtil icbcPayUtil; @Autowired private IOrderLogisticsService orderLogisticsService; @Autowired private IOrderCharteredCarService orderCharteredCarService; @Autowired private PushMinistryOfTransportUtil pushMinistryOfTransportUtil; @Autowired private ITransactionDetailsService transactionDetailsService; @Autowired private IOrderCancelService orderCancelService; @Autowired private IOfflineTravelPaymentService offlineTravelPaymentService; @Autowired private PayMoneyUtil payMoneyUtil; @Autowired private IPaymentRecordService paymentRecordService; @Value("${callbackPath}") private String callbackPath; @Value("${pushMinistryOfTransport}") private boolean pushMinistryOfTransport; /** * 获取正在进行中的订单 * @param request * @return */ @ResponseBody @PostMapping("/api/order/queryServingOrder") @ApiOperation(value = "获取正在进行中的订单", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryServingOrder(HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List data = new ArrayList<>(); List orderPrivateCars = orderPrivateCarService.queryOrder(uid, 1, 2, 3, 4, 5, 6, 7, 11, 12); for(OrderPrivateCar orderPrivateCar : orderPrivateCars){ if(orderPrivateCar.getState() == 11){ orderPrivateCar.setState(orderPrivateCar.getOldState()); } OrderStatusWarpper orderStatusWarpper = new OrderStatusWarpper(); orderStatusWarpper.setOrderId(orderPrivateCar.getId()); orderStatusWarpper.setOrderType(1); orderStatusWarpper.setState(orderPrivateCar.getState()); data.add(orderStatusWarpper); } List list = orderTaxiService.queryOrder(uid, 1, 2, 3, 4, 5, 6, 7, 11, 12); for(OrderTaxi orderTaxi : list){ if(orderTaxi.getState() == 11){ orderTaxi.setState(orderTaxi.getOldState()); } OrderStatusWarpper orderStatusWarpper = new OrderStatusWarpper(); orderStatusWarpper.setOrderId(orderTaxi.getId()); orderStatusWarpper.setOrderType(2); orderStatusWarpper.setState(orderTaxi.getState()); data.add(orderStatusWarpper); } List orderCrossCities = orderCrossCityService.queryOrder(uid, 1, 2, 3, 4, 5, 6, 7, 11, 12); for(OrderCrossCity orderCrossCity : orderCrossCities){ if(orderCrossCity.getState() == 11){ orderCrossCity.setState(orderCrossCity.getOldState()); } OrderStatusWarpper orderStatusWarpper = new OrderStatusWarpper(); orderStatusWarpper.setOrderId(orderCrossCity.getId()); orderStatusWarpper.setOrderType(3); orderStatusWarpper.setState(orderCrossCity.getState()); data.add(orderStatusWarpper); } return ResultUtil.success(data); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取个人中心订单列表 * @param type * @param pageNum * @param size * @param request * @return */ @ResponseBody @PostMapping("/api/order/queryMyOrderList") @ApiOperation(value = "获取个人中心订单列表", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城出行,4=小件物流,5=包车)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(value = "页码(首页1)", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryMyOrderList(Integer type, Integer pageNum, Integer size, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List> list = null; switch (type){ case 1: list = orderPrivateCarService.queryMyOrderList(uid, pageNum, size); break; case 2: list = orderTaxiService.queryMyOrderList(uid, pageNum, size); break; case 3: list = orderCrossCityService.queryMyOrderList(uid, pageNum, size); break; case 4: list = orderLogisticsService.queryMyOrderList(uid, pageNum, size); break; case 5: list = orderCharteredCarService.queryMyOrderList(uid, pageNum, size); break; } return ResultUtil.success(OrderWarpper.getOrderWarpper(list)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取消费记录 * @param pageNum * @param size * @param request * @return */ @ResponseBody @PostMapping("/api/order/queryMyTravelRecord") @ApiOperation(value = "获取消费记录", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "页码(首页1)", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryMyTravelRecord(Integer pageNum, Integer size, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } Integer page = pageNum; pageNum = (pageNum - 1) * size; List> maps = orderCancelService.queryCancel(uid, 2); List> list = orderPrivateCarService.queryMyTravelRecord(uid);//专车 List> list1 = orderTaxiService.queryMyTravelRecord(uid);//出租车 List> list2 = orderCrossCityService.queryMyTravelRecord(uid);//跨城车 List> list3 = orderLogisticsService.queryMyTravelRecord(uid);//小件物流 List transactionDetails = transactionDetailsService.selectList(new EntityWrapper().eq("state", 1) .eq("type", 1).eq("userType", 1).eq("userId", uid)); List> list4 = new ArrayList<>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); for(TransactionDetails transactionDetails1 : transactionDetails){ Map map = new HashMap<>(); map.put("money", transactionDetails1.getMoney()); map.put("time", sdf.format(transactionDetails1.getInsertTime())); map.put("name", transactionDetails1.getOrderType() == 3 ? "跨城订单取消退款" : transactionDetails1.getOrderType() == 4 ? "小件物流订单取消退款" : ""); map.put("insertTime", Double.valueOf(transactionDetails1.getInsertTime().getTime() / 1000).intValue()); list4.add(map); } list.addAll(maps); list.addAll(list1); list.addAll(list2); list.addAll(list3); list.addAll(list4); List orderWarpper = TravelRecordWarpper.getTravelRecordWarpper(list); //分页 if(orderWarpper.size() >= page * size){ orderWarpper = orderWarpper.subList(pageNum, pageNum + size); }else if(pageNum < orderWarpper.size() && orderWarpper.size() < page * size){ orderWarpper = orderWarpper.subList(pageNum, orderWarpper.size()); }else{ orderWarpper = new ArrayList<>(); } return ResultUtil.success(orderWarpper); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 发票页获取订单列表 * @param type * @param orderType * @param startTime * @param endTime * @param startMoney * @param endMoney * @param pageNum * @param size * @param request * @return */ @ResponseBody @PostMapping("/api/order/queryInvoiceOrder") @ApiOperation(value = "发票页获取订单列表", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单开票状态(1=未开票,2=其他)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城出行,4=同城小件物流,5=跨城小件物流)", name = "orderType", required = false, dataType = "int"), @ApiImplicitParam(value = "开始日期", name = "startTime", required = false, dataType = "string"), @ApiImplicitParam(value = "结束日期", name = "endTime", required = false, dataType = "string"), @ApiImplicitParam(value = "开始金额", name = "startMoney", required = false, dataType = "double"), @ApiImplicitParam(value = "结束金额", name = "endMoney", required = false, dataType = "double"), @ApiImplicitParam(value = "页码(首页1)", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil> queryInvoiceOrder(Integer type, Integer orderType, Date startTime, Date endTime, Double startMoney, Double endMoney, Integer pageNum, Integer size, HttpServletRequest request){ Integer page = pageNum; pageNum = (pageNum - 1) * size; try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List> list = new ArrayList<>(); if(null != orderType){ switch (orderType){ case 1://专车 list = orderPrivateCarService.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid); break; case 2://出租车 list = orderTaxiService.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid); break; case 3://跨城 list = orderCrossCityService.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid); break; case 4://同城小件物流 list = orderLogisticsService.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid, orderType); break; case 5://跨城小件物流 list = orderLogisticsService.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid, orderType); break; } }else{ //专车 List> maps = orderPrivateCarService.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid); list.addAll(maps); //出租车 List> list1 = orderTaxiService.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid); list.addAll(list1); //跨城 List> list2 = orderCrossCityService.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid); list.addAll(list2); //同城小件物流 List> list3 = orderLogisticsService.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid, orderType); list.addAll(list3); //跨城小件物流 List> list4 = orderLogisticsService.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid, orderType); list.addAll(list4); } //分页 if(list.size() >= page * size){ list = list.subList(pageNum, pageNum + size); }else if(pageNum < list.size() && list.size() < page * size){ list = list.subList(pageNum, list.size()); }else{ list = new ArrayList<>(); } return ResultUtil.success(OrderWarpper.getOrderWarpper(list)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 继续等待推单操作 * @param id * @return */ @ResponseBody @PostMapping("/api/taxi/pushOrderTaxi") @ApiOperation(value = "继续等待推单操作", tags = {"用户端-出租车", "用户端-专车"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "id", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil pushOrderTaxi(Integer id, Integer orderType){ try { switch (orderType){ case 1: return orderPrivateCarService.pushOrderPrivateCar(id); case 2: return orderTaxiService.pushOrderTaxi(id); } return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取服务中的详情数据 * @param orderId * @param orderType * @return */ @ResponseBody @PostMapping("/api/order/queryOrderInfo") @ApiOperation(value = "获取服务中的详情数据", tags = {"用户端-服务中"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryOrderInfo(Integer orderId, Integer orderType){ try { Map map = null; switch (orderType){ case 1://专车 map = orderPrivateCarService.queryOrderInfo(orderId); break; case 2://出租车 map = orderTaxiService.queryOrderInfo(orderId); break; case 3://跨城 map = orderCrossCityService.queryOrderInfo(orderId); break; } if(map.get("telX") != null){ map.put("driverPhone", map.get("telX")); } return ResultUtil.success(OrderInfoWarpper.getOrderInfoWarpper(map)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取服务中的详情数据 * @param orderId * @param orderType * @return */ @ResponseBody @PostMapping("/base/order/queryOrderInfo_") @ApiOperation(value = "获取服务中的详情数据", tags = {"分享专用", "智慧屏"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际)", name = "orderType", required = true, dataType = "int"), }) public ResultUtil queryOrderInfo_(Integer orderId, Integer orderType){ try { Map map = null; switch (orderType){ case 1://专车 map = orderPrivateCarService.queryOrderInfo(orderId); break; case 2://出租车 map = orderTaxiService.queryOrderInfo(orderId); break; case 3://跨城 map = orderCrossCityService.queryOrderInfo(orderId); break; } if(null != map.get("telX")){ map.put("driverPhone", map.get("telX")); } return ResultUtil.success(OrderInfoWarpper.getOrderInfoWarpper(map)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取订单取消支付页面详情 * @param orderId * @param orderType * @return */ @ResponseBody @PostMapping("/api/order/queryCancelPage") @ApiOperation(value = "获取订单取消支付页面详情", tags = {"用户端-服务中"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryCancelPage(Integer orderId, Integer orderType){ try { Map map = null; switch (orderType) { case 1://专车 map = orderPrivateCarService.queryOrderInfo(orderId); ResultUtil res = orderPrivateCarService.queryCancleAmount(orderId); map.put("cancelPayMoney", res.getData().getAmount()); break; case 2://出租车 map = orderTaxiService.queryOrderInfo(orderId); ResultUtil re = orderTaxiService.queryCancleAmount(orderId); map.put("cancelPayMoney", re.getData().getAmount()); break; case 3://跨城 map = orderCrossCityService.queryOrderInfo(orderId); ResultUtil r = orderCrossCityService.queryCancleAmount(orderId); map.put("cancelPayMoney", r.getData().getAmount()); break; } return ResultUtil.success(OrderInfoWarpper.getOrderInfoWarpper(map)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取订单轨迹坐标 * @param orderId * @param orderType * @return */ @ResponseBody @PostMapping("/api/order/queryTrack") @ApiOperation(value = "获取订单轨迹坐标", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryTrack(Integer orderId, Integer orderType){ try { List> list = orderPositionService.queryTrack(orderId, orderType); return ResultUtil.success(list); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取订单轨迹坐标 * @param orderId * @param orderType * @return */ @ResponseBody @PostMapping("/base/order/queryTrack_") @ApiOperation(value = "获取订单轨迹坐标", tags = {"分享专用"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际)", name = "orderType", required = true, dataType = "int"), }) public ResultUtil queryTrack_(Integer orderId, Integer orderType){ try { List> list = orderPositionService.queryTrack(orderId, orderType); return ResultUtil.success(list); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 发送订单状态 * @param id * @param orderType * @return */ @ResponseBody @PostMapping("/base/order/sendOrderState") public ResultUtil cancelOrder(Integer id, Integer orderType){ try { Integer driverId = null; Integer userId = null; Integer state = 0; switch (orderType){ case 1: OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(id); driverId = orderPrivateCar.getDriverId(); userId = orderPrivateCar.getUserId(); state = orderPrivateCar.getState(); if(null != driverId){ pushUtil.pushOrderState(2, driverId, id, orderType, state, 0); } break; case 2: OrderTaxi orderTaxi = orderTaxiService.selectById(id); driverId = orderTaxi.getDriverId(); userId = orderTaxi.getUserId(); state = orderTaxi.getState(); if(null != driverId){ pushUtil.pushOrderState(2, driverId, id, orderType, state, 0); } break; case 3: OrderCrossCity orderCrossCity = orderCrossCityService.selectById(id); driverId = orderCrossCity.getDriverId(); userId = orderCrossCity.getUserId(); state = orderCrossCity.getState(); if(orderCrossCity.getPayMoney() == null && state == 10){//支付的情况才推送取消 break; }else{ pushUtil.pushOrderState(2, driverId, id, orderType, state, 0); } break; case 4: OrderLogistics orderLogistics = orderLogisticsService.selectById(id); driverId = orderLogistics.getDriverId(); userId = orderLogistics.getUserId(); state = orderLogistics.getState(); if(orderLogistics.getPayMoney() == null && state == 10){//支付的情况才推送取消 break; }else{ pushUtil.pushOrderState(2, driverId, id, orderType, state, 0); } break; case 5: OrderLogistics orderLogistics1 = orderLogisticsService.selectById(id); driverId = orderLogistics1.getDriverId(); userId = orderLogistics1.getUserId(); state = orderLogistics1.getState(); if(orderLogistics1.getPayMoney() == null && state == 10){//支付的情况才推送取消 break; }else{ pushUtil.pushOrderState(2, driverId, id, orderType, state, 0); } break; } pushUtil.pushOrderState(1, userId, id, orderType, state, 0); return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * APP调用微信小程序支付 * @param orderId * @param orderType * @param type * @param content * @return */ @ResponseBody @PostMapping("/base/order/weChatPay") @ApiOperation(value = "APP调用微信小程序支付", tags = {"用户端-服务中"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(value = "业务类型(1=订单完成支付,2=订单取消支付,3=司机端改派支付,4=余额充值,5=小件物流差价支付)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(value = "端口类型(1=用户端,2=司机端)", name = "userType", required = true, dataType = "int"), @ApiImplicitParam(value = "用户id", name = "uid", required = true, dataType = "int"), @ApiImplicitParam(value = "附加参数{\"key\":\"value\"}", name = "content", required = true, dataType = "string") }) public ResultUtil weChatPay(Integer orderId, Integer orderType, Integer type, Integer userType, Integer uid, String content){ try { return orderService.weChatPay(orderId, orderType, type, userType, uid, content); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/order/queryUserOpenId") @ApiOperation(value = "获取用户的微信openid", tags = {"用户端-服务中"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "端口类型(1=用户端,2=司机端)", name = "userType", required = true, dataType = "int"), @ApiImplicitParam(value = "用户id", name = "uid", required = true, dataType = "int") }) public ResultUtil queryUserOpenId(Integer uid, Integer userType){ if(userType == 2){ Driver driver = driverService.selectById(uid); return ResultUtil.success(driver.getAppletsOpenId()); } if(userType == 1){ UserInfo userInfo = userInfoService.selectById(uid); return ResultUtil.success(userInfo.getAppletsOpenId()); } return ResultUtil.success(); } @ResponseBody @PostMapping("/base/order/getWeChatOpenId") @ApiOperation(value = "用户授权获取小程序openid", tags = {"用户端-服务中"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "端口类型(1=用户端,2=司机端)", name = "userType", required = true, dataType = "int"), @ApiImplicitParam(value = "用户id", name = "uid", required = true, dataType = "int"), @ApiImplicitParam(value = "小程序授权临时凭证", name = "jscode", required = true, dataType = "string"), }) public ResultUtil getWeChatOpenId(Integer uid, Integer userType, String jscode){ Map map = weChatUtil.code2Session(jscode); if(userType == 2){ Driver driver = driverService.selectById(uid); driver.setAppletsOpenId(map.get("openid")); driverService.updateById(driver); } if(userType == 1){ UserInfo userInfo = userInfoService.selectById(uid); userInfo.setAppletsOpenId(map.get("openid")); userInfoService.updateById(userInfo); } return ResultUtil.success(); } /** * 获取预计行驶时间 * @param slon * @param slat * @param elon * @param elat * @return */ @ResponseBody @PostMapping("/base/taxi/queryExpectedTime") @ApiOperation(value = "选择地点和终点后获取预计行驶时长", tags = {"用户端-出租车", "用户端-专车"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "起点经度", name = "slon", required = true, dataType = "double"), @ApiImplicitParam(value = "起点纬度", name = "slat", required = true, dataType = "double"), @ApiImplicitParam(value = "终点经度", name = "elon", required = true, dataType = "double"), @ApiImplicitParam(value = "终点纬度", name = "elat", required = true, dataType = "double") }) public ResultUtil queryExpectedTime(Double slon, Double slat, Double elon, Double elat){ try { return orderService.queryExpectedTime(slon, slat, elon, elat); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取取消订单需要支付的费用金额 * @param id * @return */ @ResponseBody @PostMapping("/api/taxi/queryCancleAmount") @ApiOperation(value = "获取取消订单需要支付的费用金额", tags = {"用户端-出租车", "用户端-专车"}, notes = "返回金额为0则不需要支付") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "id", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryCancleAmount(Integer id, Integer orderType){ try { switch (orderType){ case 1: return orderPrivateCarService.queryCancleAmount(id); case 2: return orderTaxiService.queryCancleAmount(id); case 3: return orderCrossCityService.queryCancleAmount(id); } return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 添加取消记录 * @param id * @param reason * @param remark * @param request * @return */ @ResponseBody @PostMapping("/api/taxi/addCancle") @ApiOperation(value = "添加取消记录", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "id", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(value = "取消原因", name = "reason", required = true, dataType = "string"), @ApiImplicitParam(value = "备注", name = "remark", required = false, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil addCancle(Integer id, Integer orderType, String reason, String remark, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } switch (orderType){ case 1: return orderPrivateCarService.addCancle(id, reason, remark, uid); case 2: return orderTaxiService.addCancle(id, reason, remark, uid); case 3: return orderCrossCityService.addCancle(id, reason, remark, uid); case 4: return orderLogisticsService.addCancle(id, reason, remark, uid); case 5: return orderLogisticsService.addCancle(id, reason, remark, uid); case 6: return orderCharteredCarService.addCancle(id, reason, remark, uid); } return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 添加取消记录 * @param id * @param reason * @param remark * @return */ @ResponseBody @PostMapping("/base/taxi/addCancle1") @ApiOperation(value = "添加取消记录", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城", "智慧屏"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "id", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(value = "取消原因", name = "reason", required = true, dataType = "string"), @ApiImplicitParam(value = "备注", name = "remark", required = false, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil addCancle1(Integer id, Integer orderType, String reason, String remark){ try { switch (orderType){ case 1: return orderPrivateCarService.addCancle(id, reason, remark, null); case 2: return orderTaxiService.addCancle(id, reason, remark, null); case 3: return orderCrossCityService.addCancle(id, reason, remark, null); case 4: return orderLogisticsService.addCancle(id, reason, remark, null); case 5: return orderLogisticsService.addCancle(id, reason, remark, null); case 6: return orderCharteredCarService.addCancle(id, reason, remark, null); } return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 取消操作支付 * @param id * @param payType * @return */ @ResponseBody @PostMapping("/api/taxi/cancleOrderTaxi") @ApiOperation(value = "取消操作支付", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "id", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(value = "支付方式(1=微信,2=支付宝,3=余额)", name = "payType", required = true, dataType = "int"), @ApiImplicitParam(value = "取消单id(取消操作返回)", name = "cancleId", required = false, dataType = "int"), @ApiImplicitParam(value = "支付端(1=用户APP端,2=司机APP端,3=用户小程序端)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil cancleOrderTaxi(Integer id, Integer orderType, Integer payType, Integer cancleId, Integer type, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } switch (orderType){ case 1: return orderPrivateCarService.cancleOrderPrivateCar(id, payType, cancleId, type); case 2: return orderTaxiService.cancleOrderTaxi(id, payType, cancleId, type); case 3: return orderCrossCityService.cancleOrderCrossCity(id, payType, cancleId, type); } return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 投诉操作 * @param driverId * @param reason * @param description * @param request * @return */ @ResponseBody @PostMapping("/api/taxi/complaintService") @ApiOperation(value = "添加投诉操作", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "司机id", name = "driverId", required = true, dataType = "int"), @ApiImplicitParam(value = "投诉原因", name = "reason", required = true, dataType = "String"), @ApiImplicitParam(value = "投诉描述", name = "description", required = true, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil complaintService(Integer driverId, String reason, String description, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } complaintService.saveData(driverId, reason, description, uid); return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 支付页面获取可用优惠券数量和余额 * @param orderId * @param request * @return */ @ResponseBody @PostMapping("/api/taxi/queryBalance") @ApiOperation(value = "支付页面获取可用优惠券数量和余额", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城"}, notes = "balance=余额,coupon=优惠券") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryBalance(Integer orderId, Integer orderType, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } Map map = new HashMap<>(); switch (orderType){ case 1: map = orderPrivateCarService.queryBalance(orderId, uid); break; case 2: map = orderTaxiService.queryBalance(orderId, uid); break; case 3: map = orderCrossCityService.queryBalance(orderId, uid); break; case 4: map = orderLogisticsService.queryBalance(orderId, uid); break; case 5: map = orderLogisticsService.queryBalance(orderId, uid); break; } return ResultUtil.success(map); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取支付页面的优惠券列表 * @param orderId * @param pageNum * @param size * @param request * @return */ @ResponseBody @PostMapping("/api/taxi/queryCoupon") @ApiOperation(value = "获取支付页面的优惠券列表", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryCoupon(Integer orderId, Integer orderType, Integer pageNum, Integer size, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } List> list = new ArrayList<>(); switch (orderType){ case 1: list = orderPrivateCarService.queryCoupon(orderId, uid, pageNum, size); break; case 2: list = orderTaxiService.queryCoupon(orderId, uid, pageNum, size); break; case 3: list = orderCrossCityService.queryCoupon(orderId, uid, pageNum, size); break; } return ResultUtil.success(CouponWarpper.getCouponWarppers(list)); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 订单完成支付订单操作 * @param payType * @param orderId * @param request * @return */ @ResponseBody @PostMapping("/api/taxi/payTaxiOrder") @ApiOperation(value = "订单完成支付订单操作", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城", "用户端-小件物流"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "支付方式(1=微信,2=支付宝,3=余额)", name = "payType", required = true, dataType = "int"), @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城,4=小件物流)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(value = "优惠券id", name = "couponId", required = false, dataType = "int"), @ApiImplicitParam(value = "支付端(1=用户APP端,2=司机APP端,3=用户小程序端)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil payTaxiOrder(Integer payType, Integer orderId, Integer orderType, Integer couponId, Integer type, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } switch (orderType){ case 1: return orderPrivateCarService.payPrivateCarOrder(payType, orderId, couponId, type); case 2: return orderTaxiService.payTaxiOrder(payType, orderId, couponId, type); case 3: return orderCrossCityService.payCrossCityOrder(payType, orderId, couponId, type); case 4: return orderLogisticsService.payLogisticsOrder(payType, orderId, type); case 5: return orderLogisticsService.payLogisticsOrder(payType, orderId, type); } return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 订单完成后添加评价操作 * @param orderId * @param fraction * @param content * @return */ @ResponseBody @PostMapping("/api/taxi/orderEvaluate") @ApiOperation(value = "订单完成后添加评价操作", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(value = "评分", name = "fraction", required = true, dataType = "int"), @ApiImplicitParam(value = "评价内容", name = "content", required = false, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil orderEvaluate(Integer orderId, Integer orderType, Integer fraction, String content){ try { ResultUtil resultUtil = orderEvaluateService.saveData(orderId, orderType, fraction, content); if(resultUtil.getCode() == 200){ switch (orderType){ case 1: OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); orderPrivateCar.setState(9); orderPrivateCarService.updateById(orderPrivateCar); new Thread(new Runnable() { @Override public void run() { if(pushMinistryOfTransport){//上传数据 pushMinistryOfTransportUtil.ratedPassenger(Integer.valueOf(resultUtil.getData().toString())); pushMinistryOfTransportUtil.ratedDriver(orderPrivateCar.getDriverId()); } } }).start(); break; case 2: OrderTaxi orderTaxi = orderTaxiService.selectById(orderId); orderTaxi.setState(9); orderTaxiService.updateById(orderTaxi); break; case 3: OrderCrossCity orderCrossCity = orderCrossCityService.selectById(orderId); orderCrossCity.setState(9); orderCrossCityService.updateById(orderCrossCity); break; } } return resultUtil.getCode() == 200 ? ResultUtil.success() : resultUtil; }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 评论成功后获取红包金额 * @param orderId * @return */ @ResponseBody @PostMapping("/api/taxi/queryRedMoney") @ApiOperation(value = "评论成功后获取红包金额", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryRedMoney(Integer orderId, Integer orderType){ try { switch (orderType){ case 1: return orderPrivateCarService.queryRedMoney(orderId); case 2: return orderTaxiService.queryRedMoney(orderId); case 3: return orderCrossCityService.queryRedMoney(orderId); } return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 分享成功后添加红包操作 * @param orderId * @return */ @ResponseBody @PostMapping("/api/taxi/shareRedEnvelope") @ApiOperation(value = "分享成功后添加红包操作", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil shareRedEnvelope(Integer orderId, Integer orderType){ try { switch (orderType){ case 1: return orderPrivateCarService.shareRedEnvelope(orderId); case 2: return orderTaxiService.shareRedEnvelope(orderId); case 3: return orderCrossCityService.shareRedEnvelope(orderId); } return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 取消订单微信回调 * @param request */ @ResponseBody @PostMapping("/base/wxCancelOrderTaxi") public void wxCancelOrderTaxi(HttpServletRequest request, HttpServletResponse response){ try { Map map = payMoneyUtil.weixinpayCallback(request); if(null != map){ String out_trade_no = map.get("out_trade_no"); String transaction_id = map.get("transaction_id"); String substring = out_trade_no.substring(17); Integer type = Integer.valueOf(substring.substring(0, 1)); Integer id = Integer.valueOf(substring.substring(1)); switch (type){ case 1: orderPrivateCarService.payCancelOrderPrivateCar(id, transaction_id, 1); break; case 2: orderTaxiService.payCancelOrderTaxi(id, transaction_id, 1); break; case 3: orderCrossCityService.payCancelOrderCrossCity(id, transaction_id, 1); break; } String result = map.get("result"); PrintWriter out = response.getWriter(); out.print(result); out.flush(); out.close(); } }catch (Exception e){ e.printStackTrace(); } } /** * 取消订单支付宝回调 * @param request */ @ResponseBody @PostMapping("/base/aliCancelOrderTaxi") public void aliCancelOrderTaxi(HttpServletRequest request, HttpServletResponse response){ try { Map map = payMoneyUtil.alipayCallback(request); if(null != map){ String out_trade_no = map.get("out_trade_no"); String trade_no = map.get("trade_no"); String substring = out_trade_no.substring(17); Integer type = Integer.valueOf(substring.substring(0, 1)); Integer id = Integer.valueOf(substring.substring(1)); switch (type){ case 1: orderPrivateCarService.payCancelOrderPrivateCar(id, trade_no, 2); break; case 2: orderTaxiService.payCancelOrderTaxi(id, trade_no, 2); break; case 3: orderCrossCityService.payCancelOrderCrossCity(id, trade_no, 2); break; } PrintWriter out = response.getWriter(); out.print("success"); out.flush(); out.close(); } }catch (Exception e){ e.printStackTrace(); } } /** * 完成订单微信支付回调 * @param request */ @ResponseBody @PostMapping("/base/wxPayOrderTaxi") public void wxPayOrderTaxi(HttpServletRequest request, HttpServletResponse response){ try { Map map = payMoneyUtil.weixinpayCallback(request); if(null != map){ String out_trade_no = map.get("out_trade_no"); String transaction_id = map.get("transaction_id"); String substring = out_trade_no.substring(17); Integer type = Integer.valueOf(substring.substring(0, 1)); Integer id = Integer.valueOf(substring.substring(1)); switch (type){ case 1: orderPrivateCarService.payOrderPrivateCarCallback(id, transaction_id, 1); break; case 2: orderTaxiService.payOrderTaxiCallback(id, transaction_id, 1); break; case 3: orderCrossCityService.payOrderCrossCityCallback(id, transaction_id, 1); break; case 4: orderLogisticsService.payOrderLogisticsCallback(id, transaction_id, 1); break; case 5: orderLogisticsService.payOrderLogisticsCallback(id, transaction_id, 1); break; } String result = map.get("result"); PrintWriter out = response.getWriter(); out.print(result); out.flush(); out.close(); } }catch (Exception e){ e.printStackTrace(); } } /** * 完成订单支付宝支付回调 * @param request */ @ResponseBody @PostMapping("/base/aliPayOrderTaxi") public void aliPayOrderTaxi(HttpServletRequest request, HttpServletResponse response){ try { Map map = payMoneyUtil.alipayCallback(request); if(null != map){ String out_trade_no = map.get("out_trade_no"); String trade_no = map.get("trade_no"); String substring = out_trade_no.substring(17); Integer type = Integer.valueOf(substring.substring(0, 1)); Integer id = Integer.valueOf(substring.substring(1)); switch (type){ case 1: orderPrivateCarService.payOrderPrivateCarCallback(id, trade_no, 2); break; case 2: orderTaxiService.payOrderTaxiCallback(id, trade_no, 2); break; case 3: orderCrossCityService.payOrderCrossCityCallback(id, trade_no, 2); break; case 4: orderLogisticsService.payOrderLogisticsCallback(id, trade_no, 2); break; case 5: orderLogisticsService.payOrderLogisticsCallback(id, trade_no, 2); break; } PrintWriter out = response.getWriter(); out.print("success"); out.flush(); out.close(); } }catch (Exception e){ e.printStackTrace(); } } /** * 小件物流差价微信支付回调 * @param request */ @ResponseBody @PostMapping("/base/wxPayOrderLogisticsSpread") public void wxPayOrderLogisticsSpread(HttpServletRequest request, HttpServletResponse response){ try { Map map = payMoneyUtil.weixinpayCallback(request); if(null != map){ String out_trade_no = map.get("out_trade_no"); String transaction_id = map.get("transaction_id"); String substring = out_trade_no.substring(17); Integer type = Integer.valueOf(substring.substring(0, 1)); Integer id = Integer.valueOf(substring.substring(1)); orderLogisticsService.payOrderLogisticsSpreadCallback(id, transaction_id, 1); String result = map.get("result"); PrintWriter out = response.getWriter(); out.print(result); out.flush(); out.close(); } }catch (Exception e){ e.printStackTrace(); } } /** * 小件物流差价支付宝支付回调 * @param request */ @ResponseBody @PostMapping("/base/aliPayOrderLogisticsSpread") public void aliPayOrderLogisticsSpread(HttpServletRequest request, HttpServletResponse response){ try { Map map = payMoneyUtil.alipayCallback(request); if(null != map){ String out_trade_no = map.get("out_trade_no"); String trade_no = map.get("trade_no"); String substring = out_trade_no.substring(17); Integer type = Integer.valueOf(substring.substring(0, 1)); Integer id = Integer.valueOf(substring.substring(1)); orderLogisticsService.payOrderLogisticsSpreadCallback(id, trade_no, 2); PrintWriter out = response.getWriter(); out.print("success"); out.flush(); out.close(); } }catch (Exception e){ e.printStackTrace(); } } @ResponseBody @PostMapping("/base/order/queryDriverInfo") @ApiOperation(value = "获取司机信息", tags = {"线下收款"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "司机id", name = "driverId", required = true, dataType = "int"), }) public ResultUtil> queryDriverInfo(Integer driverId){ try { Driver driver = driverService.selectById(driverId); String phone = AESUtil.decrypt(driver.getPhone()); Map map = new HashMap<>(); map.put("name", driver.getName()); map.put("phone", phone.substring(0, 3) + "****" + phone.substring(7)); map.put("headImg", driver.getHeadImgUrl()); return ResultUtil.success(map); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/order/driverQrCodePaymentCollection") @ApiOperation(value = "扫码司机收款码调起支付", tags = {"线下收款"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "司机id", name = "driverId", required = true, dataType = "int"), @ApiImplicitParam(value = "支付金额", name = "money", required = true, dataType = "double"), @ApiImplicitParam(value = "支付方式(1=微信,2=支付宝)", name = "payType", required = true, dataType = "int"), }) public ResultUtil> driverQrCodePaymentCollection(Integer driverId, Double money, Integer payType){ try { return orderService.driverQrCodePaymentCollection(driverId, money, payType); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/order/queryDriverQrCodePaymentStatus") @ApiOperation(value = "获取线下收款支付状态", tags = {"线下收款"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "支付id", name = "id", required = true, dataType = "string"), }) public ResultUtil queryDriverQrCodePaymentStatus(String id){ try { OfflineTravelPayment offlineTravelPayment = offlineTravelPaymentService.selectOne(new EntityWrapper().eq("orderId", id)); if(null != offlineTravelPayment){ return ResultUtil.success(offlineTravelPayment.getStatus()); } }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } return ResultUtil.success(0); } @ResponseBody @PostMapping("/base/order/queryDriverByOrderNum") @ApiOperation(value = "根据订单编号获取司机信息", tags = {"线下收款"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "支付id", name = "id", required = true, dataType = "string"), }) public ResultUtil> queryDriverByOrderNum(String id){ try { OfflineTravelPayment offlineTravelPayment = offlineTravelPaymentService.selectOne(new EntityWrapper().eq("orderId", id)); if(null == offlineTravelPayment){ return ResultUtil.error("订单编号无效"); } return queryDriverInfo(offlineTravelPayment.getDriverId()); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/order/evaluateDriver") @ApiOperation(value = "支付完成后的评价操作", tags = {"线下收款"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "司机id", name = "driverId", required = true, dataType = "int"), @ApiImplicitParam(value = "评分", name = "score", required = true, dataType = "double"), @ApiImplicitParam(value = "评价内容", name = "content", required = true, dataType = "string"), }) public ResultUtil evaluateDriver(Integer driverId, Integer score, String content){ try { OrderEvaluate orderEvaluate = new OrderEvaluate(); orderEvaluate.setDriverId(driverId); orderEvaluate.setFraction(score); orderEvaluate.setContent(content); orderEvaluate.setInsertTime(new Date()); orderEvaluateService.insert(orderEvaluate); return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 扫码司机收款码支付回调 * @param request * @param response */ @ResponseBody @PostMapping("/base/offlineTravelPaymentCallback") public void offlineTravelPaymentCallback(HttpServletRequest request, HttpServletResponse response){ try { System.err.println("线下收款开始回调-------------------"); ResultNotification resultNotification = PayUtil.payResultNotification(request); System.err.println("支付回调:" + JSON.toJSONString(resultNotification)); if(null != resultNotification){ if("000000".equals(resultNotification.getReturnCode())){ if("00".equals(resultNotification.getResultCode())){ String chnlSeq = resultNotification.getChnlSeq(); String txnSeq = resultNotification.getTxnSeq(); OfflineTravelPayment offlineTravelPayment = offlineTravelPaymentService.selectOne(new EntityWrapper().eq("orderId", chnlSeq)); if(null != offlineTravelPayment && offlineTravelPayment.getStatus() == 1){ offlineTravelPayment.setStatus(2); offlineTravelPayment.setPayTime(new Date()); offlineTravelPayment.setPayNumber(txnSeq); offlineTravelPaymentService.updateById(offlineTravelPayment); PrintWriter out = response.getWriter(); out.print(resultNotification.getResponseStr()); out.flush(); out.close(); } }else{ System.err.println(resultNotification.getResultMsg()); } }else{ System.err.println(resultNotification.getReturnMessage()); } } }catch (Exception e){ e.printStackTrace(); } } /** * 微信支付退款回调 * @param request * @param response */ @ResponseBody @PostMapping("/base/wxRefundCallback") public void wxRefundCallback(HttpServletRequest request, HttpServletResponse response){ try { Map map = payMoneyUtil.wxRefundCallback(request); if(null != map){ String out_refund_no = map.get("out_refund_no"); String refund_id = map.get("refund_id"); String result = map.get("result"); String substring = out_refund_no.substring(17); Integer type = Integer.valueOf(substring.substring(0, 1)); Integer id = Integer.valueOf(substring.substring(1)); PaymentRecord paymentRecord = paymentRecordService.selectById(id); if(paymentRecord.getRefundState() == 2){ return; } if(type == 3){ paymentRecord.setRefundCode(refund_id); paymentRecord.setRefundState(2); paymentRecordService.updateById(paymentRecord); OrderCrossCity orderCrossCity = orderCrossCityService.selectById(paymentRecord.getOrderId()); transactionDetailsService.saveData(orderCrossCity.getUserId(), "跨城订单取消退款", orderCrossCity.getPayMoney(), 1, 1, 1, 3, id); } if(type == 4 || type == 5){ paymentRecord.setRefundCode(refund_id); paymentRecord.setRefundState(2); paymentRecordService.updateById(paymentRecord); OrderLogistics orderLogistics = orderLogisticsService.selectById(paymentRecord.getOrderId()); transactionDetailsService.saveData(orderLogistics.getUserId(), "小件物流取消退款", orderLogistics.getPayMoney(), 1, 1, 1, orderLogistics.getType(), orderLogistics.getId()); } PrintWriter out = response.getWriter(); out.print(result); out.flush(); out.close(); } }catch (Exception e){ e.printStackTrace(); } } /** * 管理后台取消订单回退支付金额 * @param orderId * @param orderType * @return */ @ResponseBody @PostMapping("/base/order/cancelOrderRollbackAmount") public String cancelOrderRollbackAmount(Integer orderId, Integer orderType){ try { switch (orderType){ case 3: OrderCrossCity orderCrossCity = orderCrossCityService.selectById(orderId); if(orderCrossCity.getPayType() == 3){//余额支付 UserInfo userInfo = userInfoService.selectById(orderCrossCity.getUserId()); userInfo.setBalance(userInfo.getBalance() + orderCrossCity.getPayMoney()); userInfoService.updateById(userInfo); //添加交易明细 transactionDetailsService.saveData(orderCrossCity.getUserId(), "跨城订单取消退款", orderCrossCity.getPayMoney(), 1, 1, 1, 3, orderId); }else{ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); List paymentRecords = paymentRecordService.selectList(new EntityWrapper().eq("category", 1).eq("orderId", orderId) .eq("orderType", orderType).eq("state", 2).isNull("refundState")); for (PaymentRecord paymentRecord : paymentRecords) { String out_trade_no = sdf.format(new Date()) + orderType + paymentRecord.getId(); if(paymentRecord.getPayType() == 1){//微信 payMoneyUtil.wxRefund(paymentRecord.getCode(), out_trade_no, paymentRecord.getAmount().toString(), paymentRecord.getAmount().toString(), callbackPath + "/base/wxRefundCallback"); } if(paymentRecord.getPayType() == 2){//支付宝 Map map = payMoneyUtil.aliRefund(paymentRecord.getCode(), paymentRecord.getAmount().toString()); String code = map.get("code"); if(!"10000".equals(code)){ return JSON.toJSONString(ResultUtil.error(map.get("msg"))); } paymentRecord.setRefundState(2); paymentRecord.setRefundCode(map.get("trade_no")); paymentRecordService.updateById(paymentRecord); //添加交易明细 transactionDetailsService.saveData(orderCrossCity.getUserId(), "跨城订单取消退款", orderCrossCity.getPayMoney(), 1, 1, 1, 3, orderId); } } } break; case 4: OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId); if(orderLogistics.getPayType() == 3){//余额支付 UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId()); userInfo.setBalance(userInfo.getBalance() + orderLogistics.getPayMoney()); userInfoService.updateById(userInfo); //添加交易明细 transactionDetailsService.saveData(orderLogistics.getUserId(), "小件物流取消退款", orderLogistics.getPayMoney(), 1, 1, 1, orderLogistics.getType(), orderLogistics.getId()); }else{ //调用回退接口 List paymentRecords = paymentRecordService.selectList(new EntityWrapper().eq("category", 1).eq("orderId", orderId) .eq("orderType", orderType).eq("state", 2).isNull("refundState")); for (PaymentRecord paymentRecord : paymentRecords) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); String out_trade_no = sdf.format(new Date()) + orderLogistics.getType() + paymentRecord.getId(); if(paymentRecord.getPayType() == 1){//微信 Map map = payMoneyUtil.wxRefund(paymentRecord.getCode(), out_trade_no, paymentRecord.getAmount().toString(), paymentRecord.getAmount().toString(), callbackPath + "/base/wxRefundCallback"); String return_code = map.get("return_code"); if(!"SUCCESS".equals(return_code)){ return JSON.toJSONString(ResultUtil.error(map.get("return_msg"))); } } if(paymentRecord.getPayType() == 2){//支付宝 Map map = payMoneyUtil.aliRefund(paymentRecord.getCode(), paymentRecord.getAmount().toString()); String code = map.get("code"); if(!"10000".equals(code)){ return JSON.toJSONString(ResultUtil.error(map.get("msg"))); } paymentRecord.setRefundState(2); paymentRecord.setRefundCode(map.get("trade_no")); paymentRecordService.updateById(paymentRecord); //添加交易明细 transactionDetailsService.saveData(orderLogistics.getUserId(), "小件物流取消退款", orderLogistics.getPayMoney(), 1, 1, 1, orderLogistics.getType(), orderLogistics.getId()); } } } break; case 5: OrderLogistics orderLogistics1 = orderLogisticsService.selectById(orderId); if(orderLogistics1.getPayType() == 3){//余额支付 UserInfo userInfo = userInfoService.selectById(orderLogistics1.getUserId()); userInfo.setBalance(userInfo.getBalance() + orderLogistics1.getPayMoney()); userInfoService.updateById(userInfo); //添加交易明细 transactionDetailsService.saveData(orderLogistics1.getUserId(), "小件物流取消退款", orderLogistics1.getPayMoney(), 1, 1, 1, orderLogistics1.getType(), orderLogistics1.getId()); }else{ //调用回退接口 List paymentRecords = paymentRecordService.selectList(new EntityWrapper().eq("category", 1).eq("orderId", orderId) .eq("orderType", orderType).eq("state", 2).isNull("refundState")); for (PaymentRecord paymentRecord : paymentRecords) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); String out_trade_no = sdf.format(new Date()) + orderLogistics1.getType() + paymentRecord.getId(); if(paymentRecord.getPayType() == 1){//微信 Map map = payMoneyUtil.wxRefund(paymentRecord.getCode(), out_trade_no, paymentRecord.getAmount().toString(), paymentRecord.getAmount().toString(), callbackPath + "/base/wxRefundCallback"); String return_code = map.get("return_code"); if(!"SUCCESS".equals(return_code)){ return JSON.toJSONString(ResultUtil.error(map.get("return_msg"))); } } if(paymentRecord.getPayType() == 2){//支付宝 Map map = payMoneyUtil.aliRefund(paymentRecord.getCode(), paymentRecord.getAmount().toString()); String code = map.get("code"); if(!"10000".equals(code)){ return JSON.toJSONString(ResultUtil.error(map.get("msg"))); } paymentRecord.setRefundState(2); paymentRecord.setRefundCode(map.get("trade_no")); paymentRecordService.updateById(paymentRecord); //添加交易明细 transactionDetailsService.saveData(orderLogistics1.getUserId(), "小件物流取消退款", orderLogistics1.getPayMoney(), 1, 1, 1, orderLogistics1.getType(), orderLogistics1.getId()); } } } break; } }catch (Exception e){ e.printStackTrace(); return JSON.toJSONString(ResultUtil.runErr()); } return JSON.toJSONString(ResultUtil.success()); } @ResponseBody @PostMapping("/base/orderPrivateCar/directCallCar") @ApiOperation(value = "智慧屏一键叫车", tags = {"智慧屏"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "下单手机号", name = "phone", required = true, dataType = "string"), @ApiImplicitParam(value = "下单地点经度", name = "placementLon", required = true, dataType = "string"), @ApiImplicitParam(value = "下单地点纬度", name = "placementLat", required = true, dataType = "string"), @ApiImplicitParam(value = "起点经度", name = "startLon", required = true, dataType = "string"), @ApiImplicitParam(value = "起点纬度", name = "startLat", required = true, dataType = "string"), @ApiImplicitParam(value = "起点地址", name = "startAddress", required = true, dataType = "string"), @ApiImplicitParam(value = "设备号", name = "deviceCode", required = true, dataType = "string"), }) public ResultUtil directCallCar(String phone, String placementLon, String placementLat, String startLon, String startLat, String startAddress, String deviceCode){ try { return orderPrivateCarService.directCallCar(phone, placementLon, placementLat, startLon, startLat, startAddress, deviceCode); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/orderPrivateCar/querySmartScreenOrder") @ApiOperation(value = "获取智慧屏订单列表", tags = {"智慧屏"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "设备号", name = "deviceCode", required = true, dataType = "string"), @ApiImplicitParam(value = "经纬度(103.2222,30.23554)", name = "lonLat", required = true, dataType = "string"), }) public ResultUtil> querySmartScreenOrder(String deviceCode, String lonLat){ try { List orderVos = orderPrivateCarService.querySmartScreenOrder(deviceCode, lonLat); return ResultUtil.success(orderVos); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } }