| | |
| | | package com.supersavedriving.driver.modular.system.api; |
| | | |
| | | import com.supersavedriving.driver.core.common.annotion.ServiceLog; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.supersavedriving.driver.modular.system.model.DivisionRecord; |
| | | import com.supersavedriving.driver.modular.system.model.Order; |
| | | import com.supersavedriving.driver.modular.system.model.RechargeRecord; |
| | | import com.supersavedriving.driver.modular.system.service.IDivisionRecordService; |
| | | import com.supersavedriving.driver.modular.system.service.IRechargeRecordService; |
| | | import com.supersavedriving.driver.modular.system.util.MallBook.model.InterfaceResponse; |
| | | import com.supersavedriving.driver.modular.system.util.MallBook.model.Receive; |
| | | import com.supersavedriving.driver.modular.system.util.MallBook.model.ReceiveUser; |
| | | import com.supersavedriving.driver.modular.system.util.MallBook.util.RSASignature; |
| | | import com.supersavedriving.driver.modular.system.util.MallBook.util.TrhRequest; |
| | | import com.supersavedriving.driver.modular.system.util.rongyun.RongYunUtil; |
| | | import com.supersavedriving.driver.modular.system.util.rongyun.model.CloudRecordingCallback; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.service.IDriverService; |
| | | import com.supersavedriving.driver.modular.system.service.IOrderService; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.AddOrderWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.HallOrderList; |
| | | import com.supersavedriving.driver.modular.system.warpper.OrderInfoWarpper; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 订单控制器 |
| | |
| | | @RequestMapping("") |
| | | public class OrderController { |
| | | |
| | | Logger logger = LoggerFactory.getLogger(OrderController.class); |
| | | |
| | | @Autowired |
| | | private IOrderService orderService; |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | @Autowired |
| | | private IRechargeRecordService rechargeRecordService; |
| | | |
| | | @Autowired |
| | | private IDivisionRecordService divisionRecordService; |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryDriverServerOrder") |
| | | @ServiceLog(name = "获取司机服务中的订单id", url = "/api/order/queryDriverServerOrder") |
| | | // @ServiceLog(name = "获取司机服务中的订单id", url = "/api/order/queryDriverServerOrder") |
| | | @ApiOperation(value = "获取司机服务中的订单id", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<Long> queryDriverServerOrder(HttpServletRequest request){ |
| | | public ResponseWarpper<Map<String, Object>> queryDriverServerOrder(){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | Long id = orderService.queryDriverServerOrder(uid); |
| | | return ResponseWarpper.success(id); |
| | | Map<String, Object> map = orderService.queryDriverServerOrder(uid); |
| | | return ResponseWarpper.success(map); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/driverAddOrder") |
| | | // @ServiceLog(name = "司机代客下单", url = "/api/order/driverAddOrder") |
| | | @ApiOperation(value = "司机代客下单", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<Integer> driverAddOrder(AddOrderWarpper addOrderWarpper){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.driverAddOrder(uid, addOrderWarpper); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryOrderHall") |
| | | // @ServiceLog(name = "司机获取大厅订单列表", url = "/api/order/queryOrderHall") |
| | | @ApiOperation(value = "司机获取大厅订单列表", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<List<HallOrderList>> queryOrderHall(Integer pageNum, Integer pageSize){ |
| | | if(null == pageNum){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("pageNum")); |
| | | } |
| | | if(null == pageSize){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("pageSize")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | List<HallOrderList> hallOrderLists = orderService.queryOrderHall(uid, pageNum, pageSize); |
| | | return ResponseWarpper.success(hallOrderLists); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/rejectionOrder") |
| | | // @ServiceLog(name = "司机拒绝接单", url = "/api/order/rejectionOrder") |
| | | @ApiOperation(value = "司机拒绝接单", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper rejectionOrder(Long orderId){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.rejectionOrder(uid, orderId); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/receiveOrder") |
| | | // @ServiceLog(name = "司机接单操作", url = "/api/order/receiveOrder") |
| | | @ApiOperation(value = "司机接单操作", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper receiveOrder(Long orderId){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.receiveOrder(uid, orderId); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryOrderInfo") |
| | | // @ServiceLog(name = "获取订单详情", url = "/api/order/queryOrderInfo") |
| | | @ApiOperation(value = "获取订单详情", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<OrderInfoWarpper> queryOrderInfo(Long orderId){ |
| | | if(null == orderId){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | OrderInfoWarpper orderInfoWarpper = orderService.queryOrderInfo(uid, orderId); |
| | | return ResponseWarpper.success(orderInfoWarpper); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/driverProcessOperations") |
| | | // @ServiceLog(name = "司机走订单流程", url = "/api/order/driverProcessOperations") |
| | | @ApiOperation(value = "司机走订单流程", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper driverProcessOperations(ProcessOperationsWarpper processOperationsWarpper){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.driverProcessOperations(uid, processOperationsWarpper); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/transferOrder") |
| | | // @ServiceLog(name = "司机转单操作", url = "/api/order/transferOrder") |
| | | @ApiOperation(value = "司机转单操作", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(value = "原因", name = "cause", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "phone", name = "phone", required = false, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper transferOrder(Long orderId, String cause,String phone){ |
| | | if(ToolUtil.isEmpty(orderId)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | if(ToolUtil.isEmpty(cause)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("cause")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.transferOrder(uid, orderId, cause,phone); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/driverAddOrder") |
| | | @ServiceLog(name = "司机代客下单", url = "/api/order/driverAddOrder") |
| | | @ApiOperation(value = "司机代客下单", tags = {"司机端-首页"}, notes = "") |
| | | @PostMapping("/api/order/setOrderEndAddress") |
| | | // @ServiceLog(name = "司机修改订单终点", url = "/api/order/setOrderEndAddress") |
| | | @ApiOperation(value = "司机修改订单终点", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper driverAddOrder(AddOrderWarpper addOrderWarpper, HttpServletRequest request){ |
| | | public ResponseWarpper setOrderEndAddress(OrderEndAddressWarpper orderEndAddressWarpper){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequset(request); |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.success(ResultUtil.tokenErr()); |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.driverAddOrder(uid, addOrderWarpper); |
| | | ResultUtil resultUtil = orderService.setOrderEndAddress(uid, orderEndAddressWarpper); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/cancelTransferOrder") |
| | | // @ServiceLog(name = "司机取消转单操作", url = "/api/order/cancelTransferOrder") |
| | | @ApiOperation(value = "司机取消转单操作", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper cancelTransferOrder(Long orderId){ |
| | | if(ToolUtil.isEmpty(orderId)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.cancelTransferOrder(uid, orderId); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/driverCancelOrder") |
| | | // @ServiceLog(name = "司机取消订单操作", url = "/api/order/driverCancelOrder") |
| | | @ApiOperation(value = "司机取消订单操作", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(value = "原因", name = "cause", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper driverCancelOrder(Long orderId, String cause){ |
| | | if(ToolUtil.isEmpty(orderId)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | if(ToolUtil.isEmpty(cause)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("cause")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.driverCancelOrder(uid, orderId, cause); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryOrderPrice") |
| | | // @ServiceLog(name = "获取订单费用明细", url = "/api/order/queryOrderPrice") |
| | | @ApiOperation(value = "获取订单费用明细", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<OrderPriceWarpper> queryOrderPrice(Long orderId){ |
| | | if(ToolUtil.isEmpty(orderId)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | OrderPriceWarpper orderPriceWarpper = orderService.queryOrderPrice(uid, orderId); |
| | | return ResponseWarpper.success(orderPriceWarpper); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/setOrderStatus") |
| | | // @ServiceLog(name = "服务完成后修改订单状态", url = "/api/order/setOrderStatus") |
| | | @ApiOperation(value = "服务完成后修改订单状态", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(value = "支付方式(1=线上,2=线下)", name = "payType", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "107(待支付),108(已完成)", name = "state", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper setOrderStatus(Long orderId, Integer payType, Integer state){ |
| | | if(ToolUtil.isEmpty(orderId)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | | if(ToolUtil.isEmpty(state)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("state")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.setOrderStatus(uid, orderId, payType, state); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 转账回调 |
| | | * @param execute |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/order/zhaunzhangCallback") |
| | | public void zhaunzhangCallback(@RequestBody InterfaceResponse execute, HttpServletResponse response){ |
| | | try { |
| | | if("0000".equals(execute.getCode())){ |
| | | JSONObject jsonObject = JSON.parseObject(execute.getResult()); |
| | | Integer status = jsonObject.getInteger("status");//0:待处理;1:成功;2:失败 |
| | | if(2 == status){ |
| | | System.err.println("转账失败"); |
| | | return; |
| | | } |
| | | String parameter1 = jsonObject.getString("parameter1"); |
| | | RechargeRecord rechargeRecord = rechargeRecordService.selectById(parameter1); |
| | | |
| | | |
| | | response.setStatus(200); |
| | | PrintWriter out = response.getWriter(); |
| | | out.print("OK"); |
| | | out.flush(); |
| | | out.close(); |
| | | }else{ |
| | | System.err.println("转账失败:" + execute.getMsg()); |
| | | return; |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryDriverOrderList") |
| | | // @ServiceLog(name = "获取司机订单列表", url = "/api/order/queryDriverOrderList") |
| | | @ApiOperation(value = "获取司机订单列表", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单状态(107=未支付,109=已完成,301=已取消)", name = "state", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper<List<DriverOrderListWarpper>> queryDriverOrderList(Integer state, Integer pageNum, Integer pageSize){ |
| | | if(null == pageNum){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("pageNum")); |
| | | } |
| | | if(null == pageSize){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("pageSize")); |
| | | } |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | List<DriverOrderListWarpper> driverOrderListWarppers = orderService.queryDriverOrderList(uid, state, pageNum, pageSize); |
| | | return ResponseWarpper.success(driverOrderListWarppers); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 服务录音回调 |
| | | * @param request |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/order/cloudRecordingCallback") |
| | | public void cloudRecordingCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | CloudRecordingCallback cloudRecordingCallback = RongYunUtil.cloudRecordingCallback(request); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | System.err.println(sdf.format(new Date()) + "-------------------云端录制状态回调!-------------------"); |
| | | System.err.println(JSON.toJSONString(cloudRecordingCallback)); |
| | | if(null == cloudRecordingCallback){ |
| | | System.err.println("云端录制状态回调解析出错!"); |
| | | return; |
| | | } |
| | | Integer type = cloudRecordingCallback.getType(); |
| | | if(4 == type){//文件上传 |
| | | String fileUrl = cloudRecordingCallback.getOutput().getFileUrl(); |
| | | String roomId = cloudRecordingCallback.getRoomId(); |
| | | Order order = orderService.selectById(roomId); |
| | | order.setRouteRecord(fileUrl); |
| | | orderService.updateById(order); |
| | | } |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | out.print("OK"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/openOrderQRCode") |
| | | // @ServiceLog(name = "打开下单二维码操作", url = "/api/order/openOrderQRCode") |
| | | @ApiOperation(value = "打开下单二维码操作", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper openOrderQRCode(){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = driverService.openOrderQRCode(uid); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/closeOrderQRCode") |
| | | // @ServiceLog(name = "关闭下单二维码操作", url = "/api/order/closeOrderQRCode") |
| | | @ApiOperation(value = "关闭下单二维码操作", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper closeOrderQRCode(){ |
| | | try { |
| | | Integer uid = driverService.getUserByRequest(); |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = driverService.closeOrderQRCode(uid); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 异步分账回调 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/order/ledgerCallback") |
| | | public void ledgerCallback(@RequestBody InterfaceResponse execute, HttpServletResponse response){ |
| | | try{ |
| | | // 验签 |
| | | boolean verify = RSASignature.validate(execute.content(), execute.getSign()); |
| | | if (verify) {//验签成功业务处理逻辑 |
| | | if("0000".equals(execute.getCode())){ |
| | | JSONObject jsonObject = JSON.parseObject(execute.getResult()); |
| | | Integer status = jsonObject.getInteger("status"); |
| | | if(2 == status){ |
| | | logger.warn("异步分账回调异常"); |
| | | return; |
| | | } |
| | | String merOrderId = jsonObject.getString("merOrderId"); |
| | | String divisionRecordId = jsonObject.getString("parameter1"); |
| | | DivisionRecord divisionRecord = divisionRecordService.selectById(divisionRecordId); |
| | | if(divisionRecord.getState() == 2){ |
| | | response.setStatus(200); |
| | | PrintWriter out = response.getWriter(); |
| | | out.print("OK"); |
| | | out.flush(); |
| | | out.close(); |
| | | return; |
| | | } |
| | | divisionRecord.setMerOrderId(merOrderId); |
| | | divisionRecord.setPayTime(new Date()); |
| | | divisionRecord.setState(2); |
| | | divisionRecordService.updateById(divisionRecord); |
| | | |
| | | //确认收货 |
| | | new Timer().schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | Receive receive = new Receive();//确认收货 |
| | | receive.setOriginalMerOrderId(merOrderId); |
| | | receive.setRcvAmount(new BigDecimal(divisionRecord.getAmount()).multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_EVEN).longValue() + ""); |
| | | List<ReceiveUser> splitList = new ArrayList<>(); |
| | | ReceiveUser receiveUser = new ReceiveUser(); |
| | | receiveUser.setSplitUserId(divisionRecord.getMerchantNumber()); |
| | | receiveUser.setRcvSplitAmount(new BigDecimal(divisionRecord.getAmount()).multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_EVEN).longValue() + ""); |
| | | splitList.add(receiveUser); |
| | | receive.setSplitList(splitList); |
| | | TrhRequest<Receive> request1 = new TrhRequest(); |
| | | InterfaceResponse execute = request1.execute(receive, Receive.SERVICE_CODE); |
| | | if(!"0000".equals(execute.getCode())){ |
| | | logger.warn("确认收货" + execute.getMsg()); |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(execute.getResult()); |
| | | String status = jsonObject.getString("status"); |
| | | if("2".equals(status)){ |
| | | logger.warn("确认收货失败"); |
| | | } |
| | | if("0".equals(status)){ |
| | | logger.warn("确认收货处理中"); |
| | | } |
| | | } |
| | | }, 60000); |
| | | response.setStatus(200); |
| | | PrintWriter out = response.getWriter(); |
| | | out.print("OK"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } else {//验签失败业务处理逻辑 |
| | | logger.warn("支付回调验签失败"); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |