From 753c4aede53b07041841d9aa94859b59e366bd5d Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 14 八月 2023 18:47:39 +0800
Subject: [PATCH] Merge branch '1.1' of http://120.76.84.145:10101/gitblit/r/java/SuperSaveDriving

---
 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java |  176 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 145 insertions(+), 31 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 c1e2a4a..db6993f 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
@@ -1,13 +1,15 @@
 package com.supersavedriving.driver.modular.system.api;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.supersavedriving.driver.modular.system.model.Driver;
 import com.supersavedriving.driver.modular.system.model.DriverBank;
 import com.supersavedriving.driver.modular.system.model.Edition;
 import com.supersavedriving.driver.modular.system.model.JoiningRequirements;
 import com.supersavedriving.driver.modular.system.service.*;
-import com.supersavedriving.driver.modular.system.util.MallBook.model.Register;
-import com.supersavedriving.driver.modular.system.util.MallBook.util.TrhRequest;
+import com.supersavedriving.driver.modular.system.util.MallBook.model.InterfaceResponse;
+import com.supersavedriving.driver.modular.system.util.MallBook.util.RSASignature;
 import com.supersavedriving.driver.modular.system.util.PayMoneyUtil;
 import com.supersavedriving.driver.modular.system.util.huawei.OBSUtil;
 import com.supersavedriving.driver.modular.system.util.huawei.SMSUtil;
@@ -25,10 +27,7 @@
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.BeanUtils;
 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 org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
@@ -391,7 +390,7 @@
     @ResponseBody
     @PostMapping("/api/driver/queryDriverInfo")
 //    @ServiceLog(name = "获取司机个人信息", url = "/api/driver/queryDriverInfo")
-    @ApiOperation(value = "获取司机个人信息", tags = {"司机端-个人中心"}, notes = "")
+    @ApiOperation(value = "获取司机个人信息【1.1】", tags = {"司机端-个人中心"}, notes = "")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
     })
@@ -491,8 +490,8 @@
 
     @ResponseBody
     @PostMapping("/api/driver/queryCommissionList")
-//    @ServiceLog(name = "获取佣金记录", url = "/api/driver/queryCommissionList")
-    @ApiOperation(value = "获取佣金记录", tags = {"司机端-个人中心"}, notes = "")
+//    @ServiceLog(name = "获取收入记录", url = "/api/driver/queryCommissionList")
+    @ApiOperation(value = "获取收入记录", tags = {"司机端-个人中心"}, notes = "")
     @ApiImplicitParams({
             @ApiImplicitParam(value = "日期", name = "time", required = true, dataType = "string"),
             @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
@@ -588,15 +587,16 @@
     @ResponseBody
     @PostMapping("/api/driver/withdrawCash")
 //    @ServiceLog(name = "司机提现操作", url = "/api/driver/withdrawCash")
-    @ApiOperation(value = "司机提现操作", tags = {"司机端-个人中心"}, notes = "")
+    @ApiOperation(value = "司机提现操作【1.1】", tags = {"司机端-个人中心"}, notes = "")
     @ApiImplicitParams({
             @ApiImplicitParam(value = "类型(1=余额提现,2=佣金提现)", name = "type", required = true, dataType = "int"),
+            @ApiImplicitParam(value = "银行卡id", name = "bankId", required = true, dataType = "int"),
             @ApiImplicitParam(value = "提现金额", name = "money", required = true, dataType = "double"),
             @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
     })
-    public ResponseWarpper withdrawCash(Integer type, Double money){
-        if(null == type){
-            return ResponseWarpper.success(ResultUtil.paranErr("type"));
+    public ResponseWarpper withdrawCash(Integer type, Integer bankId, Double money){
+        if(null == bankId){
+            return ResponseWarpper.success(ResultUtil.paranErr("bankId"));
         }
         if(null == money){
             return ResponseWarpper.success(ResultUtil.paranErr("money"));
@@ -606,7 +606,7 @@
             if(null == uid){
                 return ResponseWarpper.tokenErr();
             }
-            ResultUtil resultUtil = cashWithdrawalService.withdrawCash(uid, type, money);
+            ResultUtil resultUtil = cashWithdrawalService.withdrawCash(uid, type, bankId, money);
             return ResponseWarpper.success(resultUtil);
         }catch (Exception e){
             e.printStackTrace();
@@ -621,7 +621,7 @@
     @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 = "类型(3=充值,8=保险,9=订单信息费)", 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.....")
@@ -675,26 +675,65 @@
     }
 
 
+
+    @ResponseBody
+    @PostMapping("/base/driver/balanceRecharge1")
+//    @ServiceLog(name = "账户余额充值(跳小程序支付)", url = "/api/driver/balanceRecharge")
+    @ApiOperation(value = "账户余额充值(跳小程序支付)", tags = {"司机端-个人中心"}, notes = "")
+    @ApiImplicitParams({
+            @ApiImplicitParam(value = "小程序code", name = "jscode", required = true, dataType = "string"),
+            @ApiImplicitParam(value = "司机id", name = "driverId", required = true, dataType = "int"),
+            @ApiImplicitParam(value = "充值金额", name = "amount", required = true, dataType = "double"),
+            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
+    })
+    public ResponseWarpper balanceRecharge1(String jscode, Integer driverId, Double amount){
+        if(null == jscode){
+            return ResponseWarpper.success(ResultUtil.paranErr("jscode"));
+        }
+        if(null == driverId){
+            return ResponseWarpper.success(ResultUtil.paranErr("driverId"));
+        }
+        if(null == amount){
+            return ResponseWarpper.success(ResultUtil.paranErr("amount"));
+        }
+        try {
+            ResultUtil resultUtil = driverService.balanceRecharge1(driverId, jscode, 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){
+    public void balanceRechargeCallback(@RequestBody InterfaceResponse interfaceResponse, 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);
+            // 验签
+            boolean verify = RSASignature.validate(interfaceResponse.content(), interfaceResponse.getSign());
+            if (verify) {//验签成功业务处理逻辑
+                if(!"0000".equals(interfaceResponse.getCode())){
+                    System.err.println("充值回调异常:" + interfaceResponse.getMsg());
+                    return;
+                }
+                JSONObject jsonObject = JSON.parseObject(interfaceResponse.getResult());
+                String merOrderId = jsonObject.getString("merOrderId");
+                String out_trade_no = jsonObject.getString("parameter1");
+                driverService.balanceRechargeCallback(out_trade_no, merOrderId);
+                response.setStatus(200);
                 PrintWriter out = response.getWriter();
-                out.print(result);
+                out.print("OK");
                 out.flush();
                 out.close();
+            } else {//验签失败业务处理逻辑
+                System.err.println("支付回调验签失败");
             }
         }catch (Exception e){
             e.printStackTrace();
@@ -841,6 +880,7 @@
             }
             ResultUtil resultUtil = ResultUtil.success();
             phone = phone.indexOf("+86") < 0 ? "+86" + phone : phone;
+            phone = phone.indexOf("+") < 0 ? "+" + phone : phone;
             String value = redisUtil.getValue(phone);
             if(ToolUtil.isEmpty(value) || !value.equals(code)){
                 resultUtil = ResultUtil.error("验证码无效");
@@ -902,7 +942,7 @@
     @ResponseBody
     @PostMapping("/api/driver/microenterprise")
 //    @ServiceLog(name = "绑定商户", url = "/api/driver/microenterprise")
-    @ApiOperation(value = "绑定商户", tags = {"司机端-个人中心"}, notes = "")
+    @ApiOperation(value = "绑定商户【1.1】", tags = {"司机端-个人中心"}, notes = "")
     @ApiImplicitParams({
             @ApiImplicitParam(value = "姓名", name = "name", required = true, dataType = "String"),
             @ApiImplicitParam(value = "身份证号码", name = "IDCode", required = true, dataType = "String"),
@@ -915,7 +955,7 @@
             if(null == uid){
                 return ResponseWarpper.tokenErr();
             }
-            ResultUtil resultUtil = driverService.microenterprise(uid, name, IDCode, phone);
+            ResultUtil resultUtil = driverService.microenterprise(uid, name, IDCode, phone, "/base/driver/microenterpriseCallback");
             return ResponseWarpper.success(resultUtil);
         }catch (Exception e){
             e.printStackTrace();
@@ -924,12 +964,46 @@
     }
 
 
+    /**
+     * 注册商户回调
+     */
+    @ResponseBody
+    @PostMapping("/base/driver/microenterpriseCallback")
+    public void microenterpriseCallback(@RequestBody InterfaceResponse interfaceResponse, HttpServletResponse response){
+        try {
+            if("0000".equals(interfaceResponse.getCode())) {
+                JSONObject jsonObject = JSON.parseObject(interfaceResponse.getResult());
+                String status = jsonObject.getString("status");
+                String parameter1 = jsonObject.getString("parameter1");
+                Driver driver = driverService.selectById(parameter1);
+                if ("2".equals(status)) {
+                    System.err.println("注册代理商子商户失败");
+                }
+                if ("0".equals(status)) {
+                    System.err.println("注册代理商子商户处理中");
+                }
+                if ("1".equals(status)) {
+                    String userId = jsonObject.getString("userId");
+                    driver.setMerchantNumber(userId);
+                    driverService.updateById(driver);
+                    response.setStatus(200);
+                    PrintWriter out = response.getWriter();
+                    out.print("OK");
+                    out.flush();
+                    out.close();
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
 
 
     @ResponseBody
     @PostMapping("/api/driver/queryBank")
 //    @ServiceLog(name = "获取绑定的银行卡", url = "/api/driver/queryBank")
-    @ApiOperation(value = "获取绑定的银行卡", tags = {"司机端-个人中心"}, notes = "")
+    @ApiOperation(value = "获取绑定的银行卡【1.1】", tags = {"司机端-个人中心"}, notes = "")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
     })
@@ -940,7 +1014,7 @@
                 return ResponseWarpper.tokenErr();
             }
             DriverBank driverId = driverBankService.selectOne(new EntityWrapper<DriverBank>().eq("driverId", uid));
-            return ResponseWarpper.success(driverId);
+            return ResponseWarpper.success(null == driverId ? new DriverBank() : driverId);
         }catch (Exception e){
             e.printStackTrace();
             return new ResponseWarpper(500, e.getMessage());
@@ -951,7 +1025,7 @@
     @ResponseBody
     @PostMapping("/api/driver/addDriverBank")
 //    @ServiceLog(name = "绑定银行卡", url = "/api/driver/addDriverBank")
-    @ApiOperation(value = "绑定银行卡", tags = {"司机端-个人中心"}, notes = "")
+    @ApiOperation(value = "绑定银行卡【1.1】", tags = {"司机端-个人中心"}, notes = "")
     @ApiImplicitParams({
             @ApiImplicitParam(value = "姓名", name = "name", required = true, dataType = "String"),
             @ApiImplicitParam(value = "身份证号码", name = "IDCode", required = true, dataType = "String"),
@@ -977,7 +1051,7 @@
     @ResponseBody
     @PostMapping("/api/driver/delDriverBank")
 //    @ServiceLog(name = "解绑银行卡", url = "/api/driver/delDriverBank")
-    @ApiOperation(value = "解绑银行卡", tags = {"司机端-个人中心"}, notes = "")
+    @ApiOperation(value = "解绑银行卡【1.1】", tags = {"司机端-个人中心"}, notes = "")
     @ApiImplicitParams({
             @ApiImplicitParam(value = "银行卡id", name = "id", required = true, dataType = "int"),
             @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
@@ -995,4 +1069,44 @@
             return new ResponseWarpper(500, e.getMessage());
         }
     }
+
+
+    /**
+     * 提现分账的回调
+     */
+    @ResponseBody
+    @PostMapping("/base/driver/withdrawCashFZCallback")
+    public void withdrawCashFZCallback(@RequestBody InterfaceResponse interfaceResponse, HttpServletResponse response){
+        try {
+            cashWithdrawalService.withdrawCashFZCallback(interfaceResponse);
+            response.setStatus(200);
+            PrintWriter out = response.getWriter();
+            out.print("OK");
+            out.flush();
+            out.close();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+
+
+
+    /**
+     * 提现确认收货后的结算回调
+     */
+    @ResponseBody
+    @PostMapping("/base/driver/withdrawCashCallback")
+    public void withdrawCashCallback(@RequestBody InterfaceResponse interfaceResponse, HttpServletResponse response){
+        try {
+            cashWithdrawalService.withdrawCashCallback(interfaceResponse);
+            response.setStatus(200);
+            PrintWriter out = response.getWriter();
+            out.print("OK");
+            out.flush();
+            out.close();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
 }

--
Gitblit v1.7.1