From 0d0da8f9d0aa740d4dc71c48ea611a16efc3d48a Mon Sep 17 00:00:00 2001 From: liujie <liujie> Date: 星期四, 10 八月 2023 09:33:21 +0800 Subject: [PATCH] 超省2.0 --- user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java | 337 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 320 insertions(+), 17 deletions(-) diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java index dd2ffa0..533f61c 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java @@ -1,12 +1,19 @@ package com.supersavedriving.user.modular.api; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.supersavedriving.user.core.common.annotion.ServiceLog; import com.supersavedriving.user.core.util.ToolUtil; -import com.supersavedriving.user.modular.system.model.AppUser; -import com.supersavedriving.user.modular.system.model.Order; -import com.supersavedriving.user.modular.system.service.IAppUserService; -import com.supersavedriving.user.modular.system.service.IOrderService; +import com.supersavedriving.user.modular.system.model.*; +import com.supersavedriving.user.modular.system.service.*; +import com.supersavedriving.user.modular.system.util.GaoDe.MapUtil; +import com.supersavedriving.user.modular.system.util.GaoDe.model.District; +import com.supersavedriving.user.modular.system.util.MallBook.model.InterfaceResponse; +import com.supersavedriving.user.modular.system.util.MallBook.model.Receive; +import com.supersavedriving.user.modular.system.util.MallBook.model.ReceiveUser; +import com.supersavedriving.user.modular.system.util.MallBook.util.RSASignature; +import com.supersavedriving.user.modular.system.util.MallBook.util.TrhRequest; import com.supersavedriving.user.modular.system.util.PayMoneyUtil; import com.supersavedriving.user.modular.system.util.ResultUtil; import com.supersavedriving.user.modular.system.warpper.*; @@ -22,9 +29,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -45,6 +50,69 @@ @Autowired private PayMoneyUtil payMoneyUtil; + @Autowired + private IBillService billService; + + @Autowired + private IRevenueService revenueService; + + @Autowired + private IDriverService driverService; + + @Autowired + private IBranchOfficeService branchOfficeService; + + @Autowired + private ISystemConfigService systemConfigService; + + + + + + @ResponseBody + @PostMapping("/api/order/queryServerPrice") +// @ServiceLog(name = "获取正在进行中的订单id", url = "/api/order/queryServerOrder") + @ApiOperation(value = "根据定位获取恶劣天气+节假日信息", tags = {"用户端-首页"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), + @ApiImplicitParam(value = "纬度", name = "lat", required = true, dataType = "String"), + @ApiImplicitParam(value = "经度", name = "lon", required = true, dataType = "String"), + }) + public ResponseWarpper<Integer> queryServerPrice(String lat,String lon){ + try { + Integer i =0; // 0为不能接单 1为恶劣天气 2为节假日 3为恶劣+节假日 + District geocode = MapUtil.geocode(lon, lat); + String districtCode = geocode.getDistrictCode(); + List<BranchOffice> districtCode1 = branchOfficeService.selectList(new EntityWrapper<BranchOffice>().eq("districtCode", districtCode)); + if(districtCode1.size()>0){ + BranchOffice branchOffice = districtCode1.get(0); + Integer id = branchOffice.getId(); + SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8).eq("companyId", id)); + SystemConfig systemConfig9 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 9).eq("companyId", id)); + if(systemConfig!=null && systemConfig9!=null){ + String content = systemConfig.getContent(); + JSONObject jsonObject = JSONObject.parseObject(content); + String num1 = jsonObject.get("num1").toString(); + String content9 = systemConfig9.getContent(); + JSONObject jsonObject9 = JSONObject.parseObject(content9); + String num9 = jsonObject9.get("num1").toString(); + if("1".equals(num1)){ + i=1; + } + if("1".equals(num9)){ + i=2; + } + if("1".equals(num1)&&"1".equals(num9)){ + i=3; + } + } + } + return ResponseWarpper.success(i); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } @@ -72,6 +140,7 @@ return new ResponseWarpper(500, e.getMessage()); } } + @@ -181,6 +250,28 @@ @ResponseBody + @PostMapping("/base/order/queryShareOrderInfo") +// @ServiceLog(name = "获取订单详情", url = "/base/order/queryShareOrderInfo") + @ApiOperation(value = "获取订单详情", tags = {"用户端-分享"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), + }) + public ResponseWarpper<OrderInfoWarpper> queryOrderInfo1(Long orderId){ + if(null == orderId){ + return ResponseWarpper.success(ResultUtil.paranErr("orderId")); + } + try { + OrderInfoWarpper orderInfoWarpper = orderService.queryOrderInfo(null, orderId); + return ResponseWarpper.success(orderInfoWarpper); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + + @ResponseBody @PostMapping("/api/order/editOrderEndAddress") // @ServiceLog(name = "修改终点", url = "/api/order/editOrderEndAddress") @ApiOperation(value = "修改终点", tags = {"用户端-首页"}, notes = "") @@ -204,8 +295,8 @@ @ResponseBody @PostMapping("/api/order/queryOrderPrice") -// @ServiceLog(name = "获取待支付页面订单费用明细", url = "/api/order/queryOrderPrice") - @ApiOperation(value = "获取待支付页面订单费用明细", tags = {"用户端-首页"}, notes = "") +// @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.....") @@ -319,19 +410,124 @@ @PostMapping("/base/order/orderPayCallback") public void orderPayCallback(HttpServletRequest request, HttpServletResponse response){ try { - Map<String, String> map = payMoneyUtil.weixinpayCallback(request); - if(null != map){ - String out_trade_no = map.get("out_trade_no"); - String transaction_id = map.get("transaction_id"); - String result = map.get("result"); - String orderId = out_trade_no.substring(17); - ResultUtil resultUtil = orderService.orderPayCallback(orderId, transaction_id); + String code = request.getParameter("code"); + String version = request.getParameter("version"); + String msg = request.getParameter("msg"); + String date = request.getParameter("date"); + String result = request.getParameter("result"); + String sign = request.getParameter("sign"); + InterfaceResponse interfaceResponse = new InterfaceResponse(); + interfaceResponse.setCode(code); + interfaceResponse.setVersion(version); + interfaceResponse.setMsg(msg); + interfaceResponse.setDate(date); + interfaceResponse.setResult(result); + interfaceResponse.setSign(sign); + // 验签 + boolean verify = RSASignature.validate(interfaceResponse.content(), interfaceResponse.getSign()); + if (verify) {//验签成功业务处理逻辑 + JSONObject jsonObject = JSON.parseObject(result); + String merOrderId = jsonObject.getString("merOrderId"); + String orderId = jsonObject.getString("parameter1"); + ResultUtil resultUtil = orderService.orderPayCallback(orderId, merOrderId); if(resultUtil.getCode() == 10000){ + response.setStatus(200); PrintWriter out = response.getWriter(); - out.print(result); + out.print("OK"); out.flush(); out.close(); } + } else {//验签失败业务处理逻辑 + System.err.println("支付回调验签失败"); + } + + +// Map<String, String> map = payMoneyUtil.weixinpayCallback(request); +// if(null != map){ +// String out_trade_no = map.get("out_trade_no"); +// String transaction_id = map.get("transaction_id"); +// String result = map.get("result"); +// String orderId = out_trade_no.substring(17); +// ResultUtil resultUtil = orderService.orderPayCallback(orderId, transaction_id); +// if(resultUtil.getCode() == 10000){ +// PrintWriter out = response.getWriter(); +// out.print(result); +// out.flush(); +// out.close(); +// } +// } + }catch (Exception e){ + e.printStackTrace(); + } + } + + + /** + * 异步分账回调 + */ + @ResponseBody + @PostMapping("/base/order/ledgerCallback") + public void ledgerCallback(HttpServletRequest request, HttpServletResponse response){ + try{ + String code = request.getParameter("code"); + String version = request.getParameter("version"); + String msg = request.getParameter("msg"); + String date = request.getParameter("date"); + String result = request.getParameter("result"); + String sign = request.getParameter("sign"); + InterfaceResponse interfaceResponse = new InterfaceResponse(); + interfaceResponse.setCode(code); + interfaceResponse.setVersion(version); + interfaceResponse.setMsg(msg); + interfaceResponse.setDate(date); + interfaceResponse.setResult(result); + interfaceResponse.setSign(sign); + // 验签 + boolean verify = RSASignature.validate(interfaceResponse.content(), interfaceResponse.getSign()); + if (verify) {//验签成功业务处理逻辑 + JSONObject jsonObject = JSON.parseObject(result); + String merOrderId = jsonObject.getString("merOrderId"); + String orderId = jsonObject.getString("parameter1"); + //确认收货 + new Timer().schedule(new TimerTask() { + @Override + public void run() { + Order order = orderService.selectById(orderId); + List<Revenue> revenues = revenueService.selectList(new EntityWrapper<Revenue>().eq("userType", 2).eq("orderId", order.getId())); + Receive receive = new Receive();//确认收货 + receive.setOriginalMerOrderId(merOrderId); + receive.setRcvAmount(String.valueOf(order.getPayMoney() * 100)); + List<ReceiveUser> splitList = new ArrayList<>(); + for (Revenue revenue : revenues) { + Driver driver = driverService.selectById(revenue.getUserId()); + ReceiveUser receiveUser = new ReceiveUser(); + receiveUser.setSplitUserId(driver.getMerchantNumber()); + receiveUser.setRcvSplitAmount(revenue.getAmount().toString()); + splitList.add(receiveUser); + } + receive.setSplitList(splitList); + TrhRequest<Receive> request1 = new TrhRequest(); + InterfaceResponse execute = request1.execute(receive, Receive.SERVICE_CODE); + if(!"0000".equals(execute.getResult())){ + System.err.println("确认收货" + execute.getMsg()); + } + JSONObject jsonObject = JSON.parseObject(execute.getResult()); + String status = jsonObject.getString("status"); + if("2".equals(status)){ + System.err.println("确认收货失败"); + } + if("0".equals(status)){ + System.err.println("确认收货处理中"); + } + } + }, 30000); + response.setStatus(200); + PrintWriter out = response.getWriter(); + out.print("OK"); + out.flush(); + out.close(); + } else {//验签失败业务处理逻辑 + System.err.println("支付回调验签失败"); } }catch (Exception e){ e.printStackTrace(); @@ -365,5 +561,112 @@ } } + @ResponseBody + @PostMapping("/api/order/queryMyOrder") +// @ServiceLog(name = "获取我的行程", url = "/api/order/queryMyOrder") + @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<OrderListWarpper>> queryMyOrder(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 = appUserService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.success(ResultUtil.tokenErr()); + } + List<OrderListWarpper> orderListWarppers = orderService.queryMyOrder(uid, pageNum, pageSize); + return ResponseWarpper.success(orderListWarppers); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + @ResponseBody + @PostMapping("/api/order/queryNotInvoiceOrder") +// @ServiceLog(name = "获取未开票订单列表", url = "/api/order/queryNotInvoiceOrder") + @ApiOperation(value = "获取未开票订单列表", tags = {"用户端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResponseWarpper<List<OrderListWarpper>> queryNotInvoiceOrder(NotInvoiceOrder notInvoiceOrder){ + try { + Integer uid = appUserService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.success(ResultUtil.tokenErr()); + } + List<OrderListWarpper> orderListWarppers = orderService.queryNotInvoiceOrder(uid, notInvoiceOrder); + return ResponseWarpper.success(orderListWarppers); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + + @ResponseBody + @PostMapping("/api/order/invoicing") +// @ServiceLog(name = "开票操作", url = "/api/order/invoicing") + @ApiOperation(value = "开票操作", tags = {"用户端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResponseWarpper invoicing(Invoicing invoicing){ + try { + Integer uid = appUserService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.success(ResultUtil.tokenErr()); + } + ResultUtil invoicing1 = billService.invoicing(uid, invoicing); + return ResponseWarpper.success(invoicing1); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + + @ResponseBody + @PostMapping("/api/order/queryBillList") +// @ServiceLog(name = "获取开票历史", url = "/api/order/queryBillList") + @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<BillWarpper>> queryBillList(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 = appUserService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.success(ResultUtil.tokenErr()); + } + List<BillWarpper> billWarppers = billService.queryBillList(uid, pageNum, pageSize); + return ResponseWarpper.success(billWarppers); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + } -- Gitblit v1.7.1