From 12b75ea8869fa6e65b1bd53d4460328e73a66125 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期三, 22 三月 2023 22:35:20 +0800 Subject: [PATCH] 新增加司机端接口 --- driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 160 insertions(+), 0 deletions(-) diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java index da01988..3089742 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.supersavedriving.driver.modular.system.model.JoiningRequirements; import com.supersavedriving.driver.modular.system.service.*; +import com.supersavedriving.driver.modular.system.util.PayMoneyUtil; import com.supersavedriving.driver.modular.system.util.huawei.SMSUtil; import com.supersavedriving.driver.modular.system.warpper.*; import com.supersavedriving.driver.core.util.ToolUtil; @@ -23,7 +24,10 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -61,6 +65,12 @@ @Autowired private ICashWithdrawalService cashWithdrawalService; + + @Autowired + private ISystemConfigService systemConfigService; + + @Autowired + private PayMoneyUtil payMoneyUtil; @@ -569,4 +579,154 @@ return new ResponseWarpper(500, e.getMessage()); } } + + + @ResponseBody + @PostMapping("/api/driver/queryBalanceDetail") +// @ServiceLog(name = "获取司机钱包明细", url = "/api/driver/queryBalanceDetail") + @ApiOperation(value = "获取司机钱包明细", tags = {"司机端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "日期", name = "time", required = true, dataType = "string"), + @ApiImplicitParam(value = "类型(1=收入,3=充值,4=支出,7=优惠券,8=保险)", name = "type", 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<BalanceDetailWarpper>> queryBalanceDetail(String time, Integer type, 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<BalanceDetailWarpper> balanceDetailWarppers = accountChangeDetailService.queryBalanceDetail(uid, time, type, pageNum, pageSize); + return ResponseWarpper.success(balanceDetailWarppers); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + + + @ResponseBody + @PostMapping("/api/driver/balanceRecharge") +// @ServiceLog(name = "账户余额充值", url = "/api/driver/balanceRecharge") + @ApiOperation(value = "账户余额充值", tags = {"司机端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "充值金额", name = "amount", required = true, dataType = "double"), + @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 balanceRecharge(Double amount){ + if(null == amount){ + return ResponseWarpper.success(ResultUtil.paranErr("amount")); + } + try { + Integer uid = driverService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.tokenErr(); + } + ResultUtil resultUtil = driverService.balanceRecharge(uid, amount); + return ResponseWarpper.success(resultUtil); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + /** + * 账户余额充值支付回调 + * @param request + * @param response + */ + @ResponseBody + @PostMapping("/base/driver/balanceRechargeCallback") + public void balanceRechargeCallback(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); + driverService.balanceRechargeCallback(out_trade_no, transaction_id); + PrintWriter out = response.getWriter(); + out.print(result); + out.flush(); + out.close(); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + + + @ResponseBody + @PostMapping("/api/driver/queryPerformanceSummary") +// @ServiceLog(name = "获取业绩排行", url = "/api/driver/queryPerformanceSummary") + @ApiOperation(value = "获取业绩排行", tags = {"司机端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "数据类型(1=订单量,2=佣金,3=收入)", name = "type", required = true, dataType = "int"), + @ApiImplicitParam(value = "统计时间", name = "time", required = true, dataType = "String"), + @ApiImplicitParam(value = "统计时间类型(1=日,2=月,3=年)", name = "dayType", required = true, dataType = "int"), + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResponseWarpper queryPerformanceSummary(Integer type, String time, Integer dayType){ + if(null == type){ + return ResponseWarpper.success(ResultUtil.paranErr("type")); + } + if(ToolUtil.isEmpty(time)){ + return ResponseWarpper.success(ResultUtil.paranErr("time")); + } + if(null == dayType){ + return ResponseWarpper.success(ResultUtil.paranErr("dayType")); + } + try { + Integer uid = driverService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.tokenErr(); + } + PerformanceSummaryWarpper performanceSummaryWarpper = orderService.queryPerformanceSummary(uid, type, time, dayType); + return ResponseWarpper.success(performanceSummaryWarpper); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + @ResponseBody + @PostMapping("/api/driver/queryMyAchievement") +// @ServiceLog(name = "获取我的业绩", url = "/api/driver/queryMyAchievement") + @ApiOperation(value = "获取我的业绩", tags = {"司机端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "统计时间", name = "time", required = true, dataType = "String"), + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResponseWarpper<List<MyAchievementWarpper>> queryMyAchievement(String time){ + if(ToolUtil.isEmpty(time)){ + return ResponseWarpper.success(ResultUtil.paranErr("time")); + } + try { + Integer uid = driverService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.tokenErr(); + } + List<MyAchievementWarpper> list = orderService.queryMyAchievement(uid, time); + return ResponseWarpper.success(list); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + } -- Gitblit v1.7.1