package com.stylefeng.guns.modular.api; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.google.api.client.http.UrlEncodedParser; import com.stylefeng.guns.core.util.MD5Util; 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.dao.UserActivityDiscount1Mapper; import com.stylefeng.guns.modular.system.model.*; import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.util.*; import com.stylefeng.guns.modular.system.util.Tingg.model.*; 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.apache.commons.lang.StringEscapeUtils; import org.apache.http.client.utils.URLEncodedUtils; import org.bouncycastle.util.encoders.UrlBase64Encoder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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 javax.servlet.http.HttpServletResponse; import java.io.*; import java.math.BigDecimal; import java.math.RoundingMode; import java.net.URLDecoder; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.*; /** * 订单控制器(综合) */ @Api @CrossOrigin @RestController @RequestMapping("") public class OrderController { private Logger log = LoggerFactory.getLogger(OrderController.class); @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 IOrderLogisticsService orderLogisticsService; @Autowired private IOrderCharteredCarService orderCharteredCarService; @Autowired private ITransactionDetailsService transactionDetailsService; @Autowired private IPaymentRecordService paymentRecordService; @Autowired private IOrderCancelService orderCancelService; @Autowired private PayMoneyUtil payMoneyUtil; @Autowired private IRedEnvelopePaymentSettingsService redEnvelopePaymentSettingsService; @Value("${filePath}") private String filePath; @Autowired private IUserRedPacketRecordService userRedPacketRecordService; @Resource private UserActivityDiscount1Mapper userActivityDiscount1Mapper; @Resource private RedisUtil redisUtil; /** * 获取正在sudo rm -rf的订单 * @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(Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } UserInfo userInfo = userInfoService.selectById(uid); userInfo.setLanguage(language); userInfoService.updateById(userInfo); 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()); orderStatusWarpper.setTripId(orderPrivateCar.getTripId()); 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()); // orderStatusWarpper.setTripId(orderTaxi.getTripId()); 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()); // orderStatusWarpper.setTripId(orderPrivateCar.getTripId()); data.add(orderStatusWarpper); } List orderLogistics = orderLogisticsService.selectList(new EntityWrapper().eq("userId", uid) .in("state", Arrays.asList(1, 2, 3, 4, 5, 6, 7, 11, 12)).eq("isDelete", 1)); for(OrderLogistics orderLogistics1 : orderLogistics){ if(orderLogistics1.getState() == 11){ orderLogistics1.setState(orderLogistics1.getOldState()); } OrderStatusWarpper orderStatusWarpper = new OrderStatusWarpper(); orderStatusWarpper.setOrderId(orderLogistics1.getId()); orderStatusWarpper.setOrderType(4); orderStatusWarpper.setState(orderLogistics1.getState()); orderStatusWarpper.setTripId(orderLogistics1.getTripId()); 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, Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } UserInfo userInfo = userInfoService.selectById(uid); userInfo.setLanguage(language); userInfoService.updateById(userInfo); List> list = null; switch (type){ case 1: list = orderPrivateCarService.queryMyOrderList(language, uid, pageNum, size); break; case 2: list = orderTaxiService.queryMyOrderList(language, uid, pageNum, size); break; case 3: list = orderCrossCityService.queryMyOrderList(language, uid, pageNum, size); break; case 4: list = orderLogisticsService.queryMyOrderList(uid, pageNum, size, language); break; case 5: list = orderCharteredCarService.queryMyOrderList(language, 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 = "获取消费记录【2.0】", 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, Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } String name = language == 1 ? "打车" : language == 2 ? "Ride" : "Course"; pageNum = (pageNum - 1) * size; List> maps = orderCancelService.queryCancel(language, uid, 2); for (Map map : maps) { Integer orderType = Integer.valueOf(map.get("orderType").toString()); if(1 == orderType){ map.put("name", language == 1 ? "打车订单取消" : language == 2 ? "Ride order cancelled" : "Commande de course annulée"); } if(4 == orderType){ map.put("name", language == 1 ? "包裹订单取消" : language == 2 ? "Delivery order cancelled" : "Commande de livraison annulée"); } } List> list = orderPrivateCarService.queryMyTravelRecord(language, uid);//专车 for (Map map : list) { map.put("name", name); } name = language == 1 ? "包裹" : language == 2 ? "Delivery" : "Livraison"; List> list3 = orderLogisticsService.queryMyTravelRecord(language, uid);//小件物流 for (Map map : list3) { map.put("name", name); } // List transactionDetails = transactionDetailsService.selectList(new EntityWrapper().eq("state", 1) // .eq("type", 1).eq("userType", 1).eq("userId", uid).eq("orderType", 3).like("remark", "%跨城订单取消退款%")); // 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", DateUtil.conversionFormat(language, sdf.format(transactionDetails1.getInsertTime()))); // map.put("name", "跨城订单取消退款"); // map.put("insertTime", Double.valueOf(transactionDetails1.getInsertTime().getTime() / 1000).intValue()); // list4.add(map); // } list.addAll(maps); list.addAll(list3); // list.addAll(list4); List orderWarpper = TravelRecordListWarpper.getTravelRecordWarpper(list); double sum = orderWarpper.stream().mapToDouble(TravelRecordListWarpper::getMoney).sum(); //分页 if(orderWarpper.size() >= (pageNum + 1) * size){ orderWarpper = orderWarpper.subList(pageNum, pageNum + size); }else if(pageNum < orderWarpper.size() && orderWarpper.size() < (pageNum + 1) * size){ orderWarpper = orderWarpper.subList(pageNum, orderWarpper.size()); }else{ orderWarpper = new ArrayList<>(); } orderWarpper.forEach(s->{ s.setTotal(sum); }); 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 language, Integer type, Integer orderType, Date startTime, Date endTime, Double startMoney, Double endMoney, Integer pageNum, Integer size, HttpServletRequest request){ 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(language, 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(language, 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(language, 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(language, 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() >= (pageNum + 1) * size){ list = list.subList(pageNum, pageNum + size); }else if(pageNum < list.size() && list.size() < (pageNum + 1) * 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(value = "语言类型(1=简体中文,2=英语,3=法语)", name = "language", required = false, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil pushOrderTaxi(Integer id, Integer orderType, Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } switch (orderType){ case 1: return orderPrivateCarService.pushOrderPrivateCar(uid, id, language); 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 = "获取服务中的详情数据【2.0】", 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(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryOrderInfo(Integer orderId, Integer orderType, Integer language){ try { Map map = null; switch (orderType){ case 1://专车 map = orderPrivateCarService.queryOrderInfo(language, orderId); break; case 2://出租车 map = orderTaxiService.queryOrderInfo(language, orderId); break; case 3://跨城 map = orderCrossCityService.queryOrderInfo(language, orderId); break; case 4://同城小件 map = orderLogisticsService.queryOrderInfo(language, orderId); break; case 5://跨城小件 map = orderLogisticsService.queryOrderInfo(language, orderId); break; } if(map.get("telX") != null){ map.put("driverPhone", map.get("telX")); } OrderInfoWarpper orderInfoWarpper = OrderInfoWarpper.getOrderInfoWarpper(map); File file = new File(filePath + orderId + "_" + orderType + ".txt"); if(file.exists()){ //读取文件(字符流) BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8")); //循环取出数据 String str = null; StringBuffer sb = new StringBuffer(); while ((str = in.readLine()) != null) { sb.append(str); } List list = JSONArray.parseArray(sb.toString(), OrderPosition.class); orderInfoWarpper.setOrderPositionList(list); } return ResultUtil.success(orderInfoWarpper); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取服务中的详情数据 * @param orderId * @param orderType * @return */ @ResponseBody @PostMapping("/base/order/queryOrderInfo_") @ApiOperation(value = "获取服务中的详情数据【1.0】", 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"), }) public ResultUtil queryOrderInfo_(Integer orderId, Integer orderType, Integer language){ try { Map map = null; switch (orderType){ case 1://专车 map = orderPrivateCarService.queryOrderInfo(language, orderId); break; case 2://出租车 map = orderTaxiService.queryOrderInfo(language, orderId); break; case 3://跨城 map = orderCrossCityService.queryOrderInfo(language, orderId); break; case 4://同城小件 map = orderLogisticsService.queryOrderInfo(language, orderId); break; case 5://跨城小件 map = orderLogisticsService.queryOrderInfo(language, orderId); break; } if(null != map.get("telX")){ map.put("driverPhone", map.get("telX")); } OrderInfoWarpper orderInfoWarpper = OrderInfoWarpper.getOrderInfoWarpper(map); // String driverName = orderInfoWarpper.getDriverName(); // if(language == 2){ // driverName = "Master " + driverName.replace("师傅", ""); // } // if(language == 3){ // driverName = "Maître " + driverName.replace("师傅", ""); // } // orderInfoWarpper.setDriverName(driverName); return ResultUtil.success(orderInfoWarpper); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取订单取消支付页面详情 * @param orderId * @param orderType * @。,; */ @ResponseBody @PostMapping("/api/order/queryCancelPage") @ApiOperation(value = "获取订单取消支付页面详情", tags = {"用户端-服务中"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=同城小件物流)", 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, Integer language){ try { Map map = null; switch (orderType) { case 1://专车 map = orderPrivateCarService.queryOrderInfo(language, orderId); ResultUtil res = orderPrivateCarService.queryCancleAmount(orderId, language); map.put("cancelPayMoney", res.getData().getAmount()); break; case 2://出租车 map = orderTaxiService.queryOrderInfo(language, orderId); ResultUtil re = orderTaxiService.queryCancleAmount(orderId); map.put("cancelPayMoney", re.getData().getAmount()); break; case 3://跨城 map = orderCrossCityService.queryOrderInfo(language, orderId); ResultUtil r = orderCrossCityService.queryCancleAmount(orderId); map.put("cancelPayMoney", r.getData().getAmount()); break; case 4://同城小件物流 map = orderLogisticsService.queryOrderInfo(language, orderId); ResultUtil r1 = orderLogisticsService.queryCancleAmount(orderId, language); map.put("cancelPayMoney", r1.getData().getAmount()); break; } OrderInfoWarpper orderInfoWarpper = OrderInfoWarpper.getOrderInfoWarpper(map); return ResultUtil.success(orderInfoWarpper); }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, String from){ 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, "", from); } 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, "", from); } 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, "", from); } 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, "", from); } 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, "", from); } break; } pushUtil.pushOrderState(1, userId, id, orderType, state, 0, "", from); 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, Integer language){ try { return orderService.weChatPay(orderId, orderType, type, userType, uid, content, language); }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, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); return orderService.queryExpectedTime(uid, 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=跨城, 4=同城小件物流)", 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, Integer language){ try { switch (orderType){ case 1: return orderPrivateCarService.queryCancleAmount(id, language); case 2: return orderTaxiService.queryCancleAmount(id); case 3: return orderCrossCityService.queryCancleAmount(id); case 4: return orderLogisticsService.queryCancleAmount(id, language); } 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 = "添加取消记录【2.0】", 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 = "lon", required = true, dataType = "Double"), @ApiImplicitParam(value = "当前纬度", name = "lat", required = true, dataType = "Double"), @ApiImplicitParam(value = "详细地址", name = "address", required = true, dataType = "string"), @ApiImplicitParam(value = "备注", name = "remark", required = false, dataType = "string"), @ApiImplicitParam(value = "语言类型(1=简体中文,2=英语,3=法语)", name = "language", required = false, dataType = "int"), @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, Double lon, Double lat, String address, Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } if(ToolUtil.isNotEmpty(reason)){ reason = reason.replaceAll("& #40;", "(") .replaceAll("& #41;", ")") .replaceAll("& #40;", "(") .replaceAll("& #41;", ")") .replaceAll("& #39;", "'") .replaceAll("& lt;", "<") .replaceAll("& gt;", ">"); } if(ToolUtil.isNotEmpty(remark)){ remark = remark.replaceAll("& #40;", "(") .replaceAll("& #41;", ")") .replaceAll("& #40;", "(") .replaceAll("& #41;", ")") .replaceAll("& #39;", "'") .replaceAll("& lt;", "<") .replaceAll("& gt;", ">"); } switch (orderType){ case 1: return orderPrivateCarService.addCancle(id, reason, remark, uid, lon, lat, address, language); // 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, lon, lat, address, language); // 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 request * @return */ @ResponseBody @PostMapping("/base/orderCancelRefundCallback") public PayoutCallbackResponse orderCancelRefundCallback(@RequestBody PayoutCallbackRequest request){ try { System.err.println("转账回调>>>>" + JSON.toJSONString(request)); PayoutCallbackResponse payoutCallbackResponse = new PayoutCallbackResponse(); AuthStatus authStatus = new AuthStatus(); authStatus.setAuthStatusCode(131); authStatus.setAuthStatusDescription("Authentication was successful"); payoutCallbackResponse.setAuthStatus(authStatus); Results results = new Results(); PayoutPacket packet = request.getPayload().getPacket(); String statusCode = packet.getStatusCode(); String beepTransactionID = packet.getBeepTransactionID(); String payerTransactionID = packet.getPayerTransactionID(); String id = payerTransactionID.substring(17); OrderCancel orderCancel = orderCancelService.selectById(id); OrderLogistics orderLogistics = orderLogisticsService.selectById(orderCancel.getOrderId()); PaymentRecord query = paymentRecordService.query(1, orderLogistics.getUserId(), 1, orderLogistics.getId(), orderLogistics.getType(), 1, 2); transactionDetailsService.saveData(orderLogistics.getUserId(), "包裹取消退款", query.getAmount(), 1, 1, 1, 4, orderLogistics.getId()); results.setBeepTransactionID(beepTransactionID); results.setPayerTransactionID(payerTransactionID); results.setStatusCode("188"); results.setStatusDescription("Response was received"); payoutCallbackResponse.setResults(results); return payoutCallbackResponse; }catch (Exception e){ e.printStackTrace(); return null; } } /** * 取消操作支付 * @param id * @param payType * @return */ @ResponseBody @PostMapping("/api/taxi/cancleOrderTaxi") @ApiOperation(value = "取消操作支付【1.1】", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城", "用户端-小件物流"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "id", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城,4=同城小件物流)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(value = "支付方式(1=手机支付,2=银行卡支付,3=余额)", name = "payType", required = true, dataType = "int"), @ApiImplicitParam(value = "银行卡id", name = "bankCardId", required = false, 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 bankCardId, Integer cancleId, Integer type, Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } String format = String.format("uid=%s&id=%s&orderType=%s&payType=%s&type=%s", uid, id, orderType, payType, type); String key = MD5Util.encrypt(format); String value = redisUtil.getValue(key); if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); } redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); switch (orderType){ case 1: return orderPrivateCarService.cancleOrderPrivateCar(id, payType, bankCardId, cancleId, type, language); // case 2: // return orderTaxiService.cancleOrderTaxi(id, payType, cancleId, type); // case 3: // return orderCrossCityService.cancleOrderCrossCity(id, payType, cancleId, type); case 4: return orderLogisticsService.cancleOrderPrivateCar(id, payType, bankCardId, cancleId, type, language); } 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 = "添加投诉操作【2.0】", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城", "用户端-小件物流"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)", name = "orderType", required = true, dataType = "int"), @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(value = "语言类型(1=简体中文,2=英语,3=法语)", name = "language", required = false, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil complaintService(Integer orderId, Integer orderType, Integer driverId, String reason, String description, Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } complaintService.saveData(orderId, orderType, driverId, reason, description, uid, language); 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=跨城,4=同城小件,5=跨城小件)", 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<>(); Double payMoney = 0D; Integer companyId = null; switch (orderType){ case 1: map = orderPrivateCarService.queryBalance(orderId, uid); OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); companyId = orderPrivateCar.getCompanyId(); payMoney = orderPrivateCar.getOrderMoney(); UserActivityDiscount1 query = userActivityDiscount1Mapper.query(orderPrivateCar.getCompanyId()); if(null != query){ Integer orderNum=orderPrivateCarService.selectCount(new EntityWrapper().eq("userId",orderPrivateCar.getUserId()).eq("activityId",query.getId()).last(" and to_days(getoffTime) = to_days(now())")); if(query.getDistance()*1000>orderPrivateCar.getMileage() && query.getOrderNum()>orderNum){ Double special = query.getSpecial(); orderPrivateCar.setDiscount(special); Double orderMoney = orderPrivateCar.getOrderMoney(); double v = new BigDecimal(orderMoney).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); if(orderMoney.compareTo(v) > 0){ payMoney = v; } } } break; // case 2: // map = orderTaxiService.queryBalance(orderId, uid); // break; // case 3: // map = orderCrossCityService.queryBalance(orderId, uid); // break; case 4: map = orderLogisticsService.queryBalance(orderId, uid); OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId); companyId = orderLogistics.getCompanyId(); payMoney = orderLogistics.getOrderMoney(); UserActivityDiscount1 query2 = userActivityDiscount1Mapper.query(orderLogistics.getCompanyId()); if(null != query2){ Integer orderNum=orderLogisticsService.selectCount(new EntityWrapper().eq("userId",orderLogistics.getUserId()).eq("activityId",query2.getId()).last(" and to_days(getoffTime) = to_days(now())")); if(query2.getDistance()*1000>orderLogistics.getMileage() && query2.getOrderNum()>orderNum){ Double special = query2.getLogistics(); orderLogistics.setDiscount(special); Double orderMoney = orderLogistics.getOrderMoney(); double v = new BigDecimal(orderMoney).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); if(orderMoney.compareTo(v) > 0){ payMoney = v; } } } break; // case 5: // map = orderLogisticsService.queryBalance(orderId, uid); // break; } List userRedPacketRecords = userRedPacketRecordService.selectList(new EntityWrapper() .eq("companyId", companyId).eq("state", 1).eq("userId", uid)); Double aDouble = 0D; if(userRedPacketRecords.size() > 0){ aDouble = userRedPacketRecords.stream().mapToDouble(UserRedPacketRecord::getRemainingAmount).sum(); } map.put("redTotal", aDouble); RedEnvelopePaymentSettings redEnvelopePaymentSettings = redEnvelopePaymentSettingsService.getRedEnvelopePaymentSettings(); if(null == redEnvelopePaymentSettings){ map.put("deductionAmount", 0D); }else{ Double deductionAmount = new BigDecimal(payMoney).multiply(redEnvelopePaymentSettings.getDeductionRatio().divide(new BigDecimal(100))).doubleValue(); map.put("deductionAmount", aDouble.compareTo(deductionAmount) >= 0 ? deductionAmount : aDouble); } 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=跨城,4=小件物流)", 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 language, 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(language, 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; case 4: list = orderLogisticsService.queryCoupon(language,orderId, uid, pageNum, size); break; // case 5: // list = orderLogisticsService.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 = "订单完成支付订单操作【2.0】", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城", "用户端-小件物流"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "支付方式(1=手机支付,2=银行卡支付,3=余额,4=线下支付)", name = "payType", required = true, dataType = "int"), @ApiImplicitParam(value = "银行卡id", name = "bankCardId", required = false, dataType = "int"), @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城,4=同城小件物流,5=跨城小件物流)", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(value = "优惠券id", name = "couponId", required = false, dataType = "int"), @ApiImplicitParam(value = "是否红包抵扣(0=否,1=是)", name = "redDeduction", 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 bankCardId, Integer orderId, Integer orderType, Integer couponId, Integer redDeduction, Integer type, Integer language, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } System.err.println("支付接口请求参数:payType=" + payType + "&bankCardId=" + bankCardId + "&orderId=" + orderId + "&orderType=" + orderType + "&couponId=" + couponId + "&redDeduction=" + redDeduction + "&type=" + type + "&language=" + language); String format = String.format("uid=%s&payType=%s&orderId=%s&orderType=%s", uid, payType, orderId, orderType); String key = MD5Util.encrypt(format); String value = redisUtil.getValue(key); if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); } redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); switch (orderType){ case 1: return orderPrivateCarService.payPrivateCarOrder(payType, bankCardId, orderId, couponId, redDeduction, type, language); // case 2: // return orderTaxiService.payTaxiOrder(payType, orderId, couponId, type); // case 3: // return orderCrossCityService.payCrossCityOrder(payType, orderId, couponId, type); case 4: return orderLogisticsService.payLogisticsOrder(payType, bankCardId, orderId,couponId, redDeduction, type, language); // case 5: // return orderLogisticsService.payLogisticsOrder(payType, orderId, type, language); } 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 = "订单完成后添加评价操作【2.0】", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城", "用户端-小件物流"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城,4=小件物流)", 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, Integer language){ try { ResultUtil resultUtil = orderEvaluateService.saveData(orderId, orderType, fraction, content, language); if(resultUtil.getCode() == 200){ switch (orderType){ case 1: OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); orderPrivateCar.setState(9); orderPrivateCarService.updateById(orderPrivateCar); 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; case 4: OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId); orderLogistics.setState(9); orderLogisticsService.updateById(orderLogistics); 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=跨城,4=小件物流)", 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); case 4: return orderLogisticsService.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(value = "语言", name = "language", 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, Integer language){ try { switch (orderType){ case 1: return orderPrivateCarService.shareRedEnvelope(orderId, language); case 2: return orderTaxiService.shareRedEnvelope(orderId); case 3: return orderCrossCityService.shareRedEnvelope(orderId); case 4: return orderLogisticsService.shareRedEnvelope(orderId, language); } return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 取消订单微信回调 * @param callbackRequest */ @ResponseBody @PostMapping("/base/wxCancelOrderTaxi") public CallbackResponse wxCancelOrderTaxi(@RequestBody CallbackRequest callbackRequest){ log.info("取消订单支付回调结果:{}", JSON.toJSONString(callbackRequest)); CallbackResponse callbackResponse = new CallbackResponse(); try { /** * 指示服务是否成功或付费的总体请求代码。。 * 177-部分付费请求 * 178-表明请求已全额支付 * 179-表示请求已部分支付但已过期。 * 129-请求已过期,未付款。 * 180.商户拒绝请求 * 183-商户接受请求,我们可以结算资金 * 188-商户收到请求。 */ String request_status_code = callbackRequest.getRequest_status_code(); String out_trade_no = callbackRequest.getMerchant_transaction_id(); if("177".equals(request_status_code) || "178".equals(request_status_code)){ Payments payments = callbackRequest.getPayments().get(0); String order_id = payments.getPayer_transaction_id(); if(ToolUtil.isNotEmpty(out_trade_no)){ Integer type = Integer.valueOf(out_trade_no.substring(17, 18)); Integer language = Integer.valueOf(out_trade_no.substring(18, 19)); Integer id = Integer.valueOf(out_trade_no.substring(19)); switch (type){ case 1: orderPrivateCarService.payCancelOrderPrivateCar(id, order_id, language); break; // case 2: // orderTaxiService.payCancelOrderTaxi(id, order_id, 1); // break; // case 3: // orderCrossCityService.payCancelOrderCrossCity(id, order_id, 1); // break; case 4: orderLogisticsService.payCancelOrderPrivateCar(id, order_id, language); break; } callbackResponse.setCheckout_request_id(order_id); callbackResponse.setMerchant_transaction_id(out_trade_no); callbackResponse.setStatus_code("183"); callbackResponse.setStatus_description("Payment processed successfully"); callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16)); } }else{ callbackResponse.setCheckout_request_id(UUIDUtil.getRandomCode(16)); callbackResponse.setMerchant_transaction_id(out_trade_no); callbackResponse.setStatus_code("180"); callbackResponse.setStatus_description("means payment rejected."); callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16)); } }catch (Exception e){ e.printStackTrace(); } log.info("取消订单支付回调处理结束:{}", JSON.toJSONString(callbackResponse)); return callbackResponse; } /** * 取消订单支付宝回调 * @param request */ @ResponseBody @PostMapping("/base/aliCancelOrderTaxi") public void aliCancelOrderTaxi(HttpServletRequest request, HttpServletResponse response){ try { // Map map = payMoneyUtil.alipayCallback(request);//icbcPayUtil.payCallback(request); // if(null != map){ // String out_trade_no = map.get("out_trade_no"); // String order_id = map.get("trade_no"); // if(ToolUtil.isNotEmpty(out_trade_no)){ // String[] split = out_trade_no.split("_"); // Integer id = Integer.valueOf(split[0]); // Integer type = Integer.valueOf(split[1]); // switch (type){ // case 1: // orderPrivateCarService.payCancelOrderPrivateCar(id, order_id, 2); // break; // case 2: // orderTaxiService.payCancelOrderTaxi(id, order_id, 2); // break; // case 3: // orderCrossCityService.payCancelOrderCrossCity(id, order_id, 2); // break; // } // } // response.setContentType("text/html;charset=UTF-8"); // PrintWriter out; // out = response.getWriter(); // out.println("success"); // 请不要修改或删除 // } }catch (Exception e){ e.printStackTrace(); } } /** * 完成订单微信支付回调 * @param */ @ResponseBody @PostMapping("/base/wxPayOrderTaxi") public CallbackResponse wxPayOrderTaxi(@RequestBody CallbackRequest callbackRequest){ log.info("订单完成支付回调结果:{}", JSON.toJSONString(callbackRequest)); CallbackResponse callbackResponse = new CallbackResponse(); try { /** * 指示服务是否成功或付费的总体请求代码。。 * 177-部分付费请求 * 178-表明请求已全额支付 * 179-表示请求已部分支付但已过期。 * 129-请求已过期,未付款。 * 180.商户拒绝请求 * 183-商户接受请求,我们可以结算资金 * 188-商户收到请求。 */ String request_status_code = callbackRequest.getRequest_status_code(); String out_trade_no = callbackRequest.getMerchant_transaction_id(); if("177".equals(request_status_code) || "178".equals(request_status_code)){ Payments payments = callbackRequest.getPayments().get(0); String order_id = payments.getPayer_transaction_id(); if(ToolUtil.isNotEmpty(out_trade_no)){ Integer orderType = Integer.valueOf(out_trade_no.substring(17, 18)); Integer language = Integer.valueOf(out_trade_no.substring(18, 19)); Integer id = Integer.valueOf(out_trade_no.substring(19)); switch (orderType){ case 1: orderPrivateCarService.payOrderPrivateCarCallback(id, order_id, language); break; // case 2: // orderTaxiService.payOrderTaxiCallback(id, order_id, 1); // break; // case 3: // orderCrossCityService.payOrderCrossCityCallback(id, order_id, 1); // break; case 4: orderLogisticsService.payOrderLogisticsCallback(id, order_id, language); break; // case 5: // orderLogisticsService.payOrderLogisticsCallback(id, order_id, 1, language); // break; } callbackResponse.setCheckout_request_id(order_id); callbackResponse.setMerchant_transaction_id(out_trade_no); callbackResponse.setStatus_code("183"); callbackResponse.setStatus_description("Payment processed successfully"); callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16)); } }else{ callbackResponse.setCheckout_request_id(UUIDUtil.getRandomCode(16)); callbackResponse.setMerchant_transaction_id(out_trade_no); callbackResponse.setStatus_code("180"); callbackResponse.setStatus_description("means payment rejected."); callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16)); } }catch (Exception e){ e.printStackTrace(); } log.info("订单完成支付回调处理结束:{}", JSON.toJSONString(callbackResponse)); return callbackResponse; } /** * 完成订单支付宝支付回调 * @param request */ @ResponseBody @PostMapping("/base/aliPayOrderTaxi") public void aliPayOrderTaxi(HttpServletRequest request, HttpServletResponse response){ try { Map map = payMoneyUtil.alipayCallback(request);//icbcPayUtil.payCallback(request); if(null != map){ String out_trade_no = map.get("out_trade_no"); String order_id = map.get("trade_no"); if(ToolUtil.isNotEmpty(out_trade_no)){ String[] split = out_trade_no.split("_"); Integer id = Integer.valueOf(split[0]); Integer type = Integer.valueOf(split[1]); Integer language = Integer.valueOf(split[2]); switch (type){ // case 1: // orderPrivateCarService.payOrderPrivateCarCallback(id, order_id, 2, language); // break; // case 2: // orderTaxiService.payOrderTaxiCallback(id, order_id, 2); // break; // case 3: // orderCrossCityService.payOrderCrossCityCallback(id, order_id, 2); // break; // case 4: // orderLogisticsService.payOrderLogisticsCallback(id, order_id, 2, language); // break; // case 5: // orderLogisticsService.payOrderLogisticsCallback(id, order_id, 2, language); // break; } response.setContentType("text/html;charset=UTF-8"); PrintWriter out; out = response.getWriter(); out.println("success"); // 请不要修改或删除 } } }catch (Exception e){ e.printStackTrace(); } } /** * 小件物流差价微信支付回调 */ @ResponseBody @PostMapping("/base/wxPayOrderLogisticsSpread") public CallbackResponse wxPayOrderLogisticsSpread(@RequestBody CallbackRequest callbackRequest){ CallbackResponse callbackResponse = new CallbackResponse(); try { /** * 指示服务是否成功或付费的总体请求代码。。 * 177-部分付费请求 * 178-表明请求已全额支付 * 179-表示请求已部分支付但已过期。 * 129-请求已过期,未付款。 * 180.商户拒绝请求 * 183-商户接受请求,我们可以结算资金 * 188-商户收到请求。 */ String request_status_code = callbackRequest.getRequest_status_code(); String out_trade_no = callbackRequest.getMerchant_transaction_id(); if("177".equals(request_status_code) || "178".equals(request_status_code)){ Payments payments = callbackRequest.getPayments().get(0); String order_id = payments.getPayer_transaction_id(); if(ToolUtil.isNotEmpty(out_trade_no)){ Integer orderType = Integer.valueOf(out_trade_no.substring(17, 18)); Integer language = Integer.valueOf(out_trade_no.substring(18, 19)); Integer id = Integer.valueOf(out_trade_no.substring(19)); orderLogisticsService.payOrderLogisticsSpreadCallback(id, order_id, language); callbackResponse.setCheckout_request_id(order_id); callbackResponse.setMerchant_transaction_id(out_trade_no); callbackResponse.setStatus_code("183"); callbackResponse.setStatus_description("Payment processed successfully"); callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16)); } }else{ callbackResponse.setCheckout_request_id(UUIDUtil.getRandomCode(16)); callbackResponse.setMerchant_transaction_id(out_trade_no); callbackResponse.setStatus_code("180"); callbackResponse.setStatus_description("means payment rejected."); callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16)); } }catch (Exception e){ e.printStackTrace(); } return callbackResponse; } /** * 小件物流差价支付宝支付回调 * @param request */ @ResponseBody @PostMapping("/base/aliPayOrderLogisticsSpread") public void aliPayOrderLogisticsSpread(HttpServletRequest request, HttpServletResponse response){ try { // Map map = payMoneyUtil.alipayCallback(request);//icbcPayUtil.payCallback(request); // if(null != map){ // String out_trade_no = map.get("out_trade_no"); // String order_id = map.get("trade_no"); // String s = null;//icbcPayUtil.queryTransaction("", order_id); // if(!s.equals("") && !s.equals("2")){ // //icbcPayUtil.answer(response);//回调应答 // } // if(ToolUtil.isNotEmpty(out_trade_no) && ToolUtil.isNotEmpty(order_id) && s.equals("0")){ // String[] split = out_trade_no.split(","); // Integer id = Integer.valueOf(split[0]); // Integer type = Integer.valueOf(split[1]); // orderLogisticsService.payOrderLogisticsSpreadCallback(id, order_id, 2); // } // // } }catch (Exception e){ e.printStackTrace(); } } @ResponseBody @PostMapping("/base/IGO/tinggPayoutCallback") public PayoutCallbackResponse tinggPayoutCallback(@RequestBody PayoutCallbackRequest request){ System.err.println("转账回调>>>>" + JSON.toJSONString(request)); PayoutCallbackResponse payoutCallbackResponse = new PayoutCallbackResponse(); AuthStatus authStatus = new AuthStatus(); authStatus.setAuthStatusCode(131); authStatus.setAuthStatusDescription("Authentication was successful"); payoutCallbackResponse.setAuthStatus(authStatus); Results results = new Results(); PayoutPacket packet = request.getPayload().getPacket(); String beepTransactionID = packet.getBeepTransactionID(); String payerTransactionID = packet.getPayerTransactionID(); results.setBeepTransactionID(beepTransactionID); results.setPayerTransactionID(payerTransactionID); results.setStatusCode("188"); results.setStatusDescription("Response was received"); payoutCallbackResponse.setResults(results); return payoutCallbackResponse; } @ResponseBody @PostMapping("/api/taxi/updateEndAddress") @ApiOperation(value = "修改目的地【2.0】", tags = {"用户端-专车", "用户端-小件物流"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(value = "终点经度", name = "endLon", required = true, dataType = "String"), @ApiImplicitParam(value = "终点纬度", name = "endLat", required = true, dataType = "String"), @ApiImplicitParam(value = "终点地址", name = "endAddress", required = true, dataType = "String"), @ApiImplicitParam(value = "语言", name = "language", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil updateEndAddress(Integer orderId, Integer orderType, String endLon, String endLat, String endAddress){ switch (orderType){ case 1: orderPrivateCarService.updateEndAddress(orderId, endLon, endLat, endAddress); break; case 4: orderLogisticsService.updateEndAddress(orderId, endLon, endLat, endAddress); break; } return ResultUtil.success(); } @ResponseBody @PostMapping("/api/taxi/redEnvelopeDeductionAmount") @ApiOperation(value = "获取支付页红包抵扣金额【2.0】", tags = {"用户端-专车", "用户端-小件物流"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "订单类型", name = "orderType", required = true, dataType = "int"), @ApiImplicitParam(value = "语言", name = "language", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil redEnvelopeDeductionAmount(Integer orderId, Integer orderType, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } Double payMoney = 0D; Integer companyId = 1; switch (orderType){ case 1: OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); companyId = orderPrivateCar.getCompanyId(); Double orderMoney = orderPrivateCar.getOrderMoney(); if(null == orderMoney){ orderMoney = 0D; } UserActivityDiscount1 query2 = userActivityDiscount1Mapper.query(orderPrivateCar.getCompanyId()); if(null != query2){ Integer orderNum=orderPrivateCarService.selectCount(new EntityWrapper().eq("userId", uid).eq("activityId",query2.getId()).last(" and to_days(getoffTime) = to_days(now())")); if(query2.getDistance()*1000>orderPrivateCar.getMileage() && query2.getOrderNum()>orderNum){ Double special = query2.getSpecial(); if(null != special){ double v = new BigDecimal(orderMoney).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); payMoney = v; } } } break; case 4: OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId); companyId = orderLogistics.getCompanyId(); Double orderMoney1 = orderLogistics.getOrderMoney(); if(null == orderMoney1){ orderMoney1 = 0D; } UserActivityDiscount1 query1 = userActivityDiscount1Mapper.query(orderLogistics.getCompanyId()); if(null != query1){ Integer orderNum=orderLogisticsService.selectCount(new EntityWrapper().eq("userId", uid).eq("activityId",query1.getId()).last(" and to_days(getoffTime) = to_days(now())")); if(query1.getDistance()*1000>orderLogistics.getMileage() && query1.getOrderNum()>orderNum){ Double special = query1.getLogistics(); if(null != special){ double v = new BigDecimal(orderMoney1).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); payMoney = v; } } } break; } List userRedPacketRecords = userRedPacketRecordService.selectList(new EntityWrapper().eq("userId", uid) .eq("state", 1).eq("companyId", companyId).gt("remainingAmount", 0).orderBy("insertTime", false)); Map map = new HashMap<>(); map.put("redTotal", userRedPacketRecords.stream().mapToDouble(UserRedPacketRecord::getRemainingAmount).sum()); RedEnvelopePaymentSettings redEnvelopePaymentSettings = redEnvelopePaymentSettingsService.getRedEnvelopePaymentSettings(); if(null == redEnvelopePaymentSettings){ map.put("deductionAmount", 0D); return ResultUtil.success(map); } Double deductionAmount = new BigDecimal(payMoney).multiply(redEnvelopePaymentSettings.getDeductionRatio().divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); map.put("deductionAmount", deductionAmount); return ResultUtil.success(map); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/api/order/getNewTripId") @ApiOperation(value = "获取google预定tripid【2.0】", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil getNewTripId(HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } String randomCode = UUIDUtil.getRandomCode(); redisUtil.setStrValue("trip" + uid, randomCode); log.warn("生成tripId:{} {}", System.currentTimeMillis(), randomCode); return ResultUtil.success(randomCode); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } }