新增银行卡
parent
2652f15c8c
commit
a4efbc1400
45
pom.xml
45
pom.xml
|
@ -36,6 +36,39 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<!--七牛云-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.qiniu</groupId>
|
||||||
|
<artifactId>qiniu-java-sdk</artifactId>
|
||||||
|
<version>7.13.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!--七牛云第三方插件库-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>3.14.2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.8.5</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.qiniu</groupId>
|
||||||
|
<artifactId>happy-dns-java</artifactId>
|
||||||
|
<version>0.1.6</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.12</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
@ -209,6 +242,18 @@
|
||||||
<artifactId>health-api-mybasic</artifactId>
|
<artifactId>health-api-mybasic</artifactId>
|
||||||
<version>3.6.6</version>
|
<version>3.6.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- 银行卡依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-lang</groupId>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 银行卡依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>tea-openapi</artifactId>
|
||||||
|
<version>0.0.7</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.ruoyi.mybasic.common.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行卡请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BankConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行卡Id
|
||||||
|
*/
|
||||||
|
private long id;
|
||||||
|
/**
|
||||||
|
* 当前用户UserID
|
||||||
|
*/
|
||||||
|
private long userId;
|
||||||
|
/**
|
||||||
|
* 类型 比如(储蓄卡)
|
||||||
|
*/
|
||||||
|
private String cardType;
|
||||||
|
/**
|
||||||
|
* 银行名称
|
||||||
|
*/
|
||||||
|
private String bankName;
|
||||||
|
/**
|
||||||
|
* 银行卡 卡号
|
||||||
|
*/
|
||||||
|
private String cardNo;
|
||||||
|
/**
|
||||||
|
* 银行ID
|
||||||
|
*/
|
||||||
|
private Integer bankId;
|
||||||
|
/**
|
||||||
|
* 银行代码
|
||||||
|
*/
|
||||||
|
private String bankCode;
|
||||||
|
/**
|
||||||
|
* 绑定时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ruoyi.mybasic.common.domain;
|
package com.ruoyi.mybasic.common.domain;
|
||||||
import com.alibaba.druid.sql.visitor.functions.Char;
|
import com.alibaba.druid.sql.visitor.functions.Char;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -27,6 +29,8 @@ public class MoneyLog {
|
||||||
/**
|
/**
|
||||||
* 操作时间
|
* 操作时间
|
||||||
*/
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
/**
|
/**
|
||||||
* 详情
|
* 详情
|
||||||
|
@ -51,6 +55,8 @@ public class MoneyLog {
|
||||||
/**
|
/**
|
||||||
* 修改时间
|
* 修改时间
|
||||||
*/
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ruoyi.mybasic.common.domain;
|
package com.ruoyi.mybasic.common.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -30,5 +32,7 @@ public class RechargeLog {
|
||||||
/**
|
/**
|
||||||
* 充值时间
|
* 充值时间
|
||||||
*/
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.ruoyi.mybasic.common.domain.emal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Http请求方式 用于银行卡
|
||||||
|
*/
|
||||||
|
public enum Method {
|
||||||
|
GET,
|
||||||
|
POST_FORM,
|
||||||
|
POST_STRING,
|
||||||
|
POST_BYTES,
|
||||||
|
PUT_FROM,
|
||||||
|
PUT_STRING,
|
||||||
|
PUT_BYTES,
|
||||||
|
DELETE;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.ruoyi.mybasic.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 七牛云
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ConfigurationProperties(value = "qi-niu-yun")
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties
|
||||||
|
public class QiNiuYunConfig {
|
||||||
|
private String accessKey;
|
||||||
|
private String secretKey;
|
||||||
|
private String bucket;
|
||||||
|
private String hostName;
|
||||||
|
}
|
|
@ -0,0 +1,203 @@
|
||||||
|
package com.ruoyi.mybasic.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.mybasic.common.domain.BankConfig;
|
||||||
|
import com.ruoyi.mybasic.service.MessageService;
|
||||||
|
import com.ruoyi.mybasic.util.HttpUtils;
|
||||||
|
import com.ruoyi.mybasic.util.UploadUtil;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行卡上传
|
||||||
|
* @author swh
|
||||||
|
*/
|
||||||
|
@RequestMapping("/message")
|
||||||
|
@RestController
|
||||||
|
public class MessageController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageService messageService;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UploadUtil uploadUtil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行卡api
|
||||||
|
*/
|
||||||
|
@PostMapping("/upload")
|
||||||
|
public void upload(@RequestParam("file") MultipartFile file) throws Exception {
|
||||||
|
//上传文件方法
|
||||||
|
if (null == file){
|
||||||
|
throw new ServiceException("银行卡照片为空");
|
||||||
|
}
|
||||||
|
String upload = uploadUtil.upload(file);
|
||||||
|
|
||||||
|
String host = "https://vbkocr.market.alicloudapi.com";
|
||||||
|
String path = "/lundear/bkocr";
|
||||||
|
String method = "POST";
|
||||||
|
String appcode = "ded4e72aaf8f48499dcd2ef13f8eaae9";
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||||
|
headers.put("Authorization", "APPCODE " + appcode);
|
||||||
|
//根据API的要求,定义相对应的Content-Type
|
||||||
|
headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||||
|
Map<String, String> querys = new HashMap<String, String>();
|
||||||
|
Map<String, String> bodys = new HashMap<String, String>();
|
||||||
|
bodys.put("url", upload);
|
||||||
|
// querys.put("image", upload);
|
||||||
|
System.out.println(bodys);
|
||||||
|
|
||||||
|
BankConfig bankConfig = new BankConfig();
|
||||||
|
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* 重要提示如下:
|
||||||
|
* HttpUtils请从
|
||||||
|
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
|
||||||
|
* 下载
|
||||||
|
*
|
||||||
|
* 相应的依赖请参照
|
||||||
|
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
|
||||||
|
*/
|
||||||
|
HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
|
||||||
|
System.out.println(response.toString());
|
||||||
|
|
||||||
|
//获取response的body
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(EntityUtils.toString(response.getEntity()));
|
||||||
|
System.out.println("jsonObject数据为:" + jsonObject);
|
||||||
|
|
||||||
|
//查询当前人银行卡的当前银行卡 根据银行卡号进行循环查询 是否已经绑定
|
||||||
|
List<Integer> bankCardNo = messageService.listBankCardNo(SecurityUtils.getUserId());
|
||||||
|
boolean hasNullElement = false;
|
||||||
|
for (Integer integer : bankCardNo) {
|
||||||
|
if (integer != null && integer != 0){
|
||||||
|
hasNullElement = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasNullElement){
|
||||||
|
throw new ServiceException("已经添加过此银行卡!换一张");
|
||||||
|
}else{
|
||||||
|
|
||||||
|
bankConfig.setBankCode(jsonObject.getString("bank_code"));
|
||||||
|
bankConfig.setBankId(jsonObject.getInteger("bank_id"));
|
||||||
|
bankConfig.setBankName(jsonObject.getString("bank_name"));
|
||||||
|
bankConfig.setCardNo(jsonObject.getString("card_no"));
|
||||||
|
bankConfig.setBankCode(jsonObject.getString("bank_code"));
|
||||||
|
bankConfig.setCardType(jsonObject.getString("card_type"));
|
||||||
|
bankConfig.setUserId(SecurityUtils.getUserId());
|
||||||
|
|
||||||
|
BankConfig bankConfig1 = JSONObject.parseObject(jsonObject.getString("bankConfig"), BankConfig.class);
|
||||||
|
//绑定银行卡 添加到银行卡表中
|
||||||
|
messageService.addBank(bankConfig1);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 识别银行卡信息
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
|
||||||
|
// public static ResponseCard getBank(String images) throws IOException {
|
||||||
|
// String host = "https://dfbankcard.market.alicloudapi.com";
|
||||||
|
// String path = "/ocr/bankcard";
|
||||||
|
// String method = "POST";
|
||||||
|
// String appcode = "ded4e72aaf8f48499dcd2ef13f8eaae9";
|
||||||
|
// Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
// //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||||
|
// headers.put("Authorization", "APPCODE " + appcode);
|
||||||
|
// //根据API的要求,定义相对应的Content-Type
|
||||||
|
// headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||||
|
// Map<String, String> querys = new HashMap<String, String>();
|
||||||
|
// Map<String, String> bodys = new HashMap<String, String>();
|
||||||
|
// bodys.put("image_url", images);
|
||||||
|
// ResponseCard responseCard = new ResponseCard();
|
||||||
|
// try {
|
||||||
|
// /**
|
||||||
|
// * 重要提示如下:
|
||||||
|
// * HttpUtils请从
|
||||||
|
// * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
|
||||||
|
// * 下载
|
||||||
|
// *
|
||||||
|
// * 相应的依赖请参照
|
||||||
|
// * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
|
||||||
|
// */
|
||||||
|
// HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
|
||||||
|
// //使用这个才能获取信息
|
||||||
|
// JSONObject jsonObject = JSONObject.parseObject(EntityUtils.toString(response.getEntity()));
|
||||||
|
// System.out.println("jsonObject数据为:"+jsonObject);
|
||||||
|
// responseCard.setRequestId(jsonObject.getString("request_id"));
|
||||||
|
// responseCard.setStatus(jsonObject.getString("status"));
|
||||||
|
// BankCard result = JSONObject.parseObject(jsonObject.getString("result"), BankCard.class);
|
||||||
|
// responseCard.setBankCard(result);
|
||||||
|
// System.out.println("responseCard数据为:"+responseCard);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// return responseCard;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
// Config config = new Config()
|
||||||
|
// .setAccessKeyId("你的AccessKeyId")
|
||||||
|
// .setAccessKeySecret("你的AccessKeySecret");
|
||||||
|
// OcrBankCard ocrBankCard = new OcrBankCard(config);
|
||||||
|
// try {
|
||||||
|
// CommonResponse response = ocrBankCard.ocrBankCard("要识别的银行卡图片的URL");
|
||||||
|
// System.out.println(response.getData());
|
||||||
|
// } catch (TeaException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public Boolean bindUserBank(MultipartFile bankImage) throws IOException {
|
||||||
|
// Long userId = SecurityUtils.getUserId();
|
||||||
|
// byte[] bytes = bankImage.getBytes();
|
||||||
|
// String bank = Base64.getEncoder().encodeToString(bytes);
|
||||||
|
// Map map = forestClientInterface.helloForestBank(bank);
|
||||||
|
// System.out.println(map);
|
||||||
|
// Map resultMap = (Map) map.get("result");
|
||||||
|
// String cardNumber = (String) resultMap.get("card_number");
|
||||||
|
// String bankName = (String) resultMap.get("bank_name");
|
||||||
|
// String bankIdentificationNumber = (String) resultMap.get("bank_identification_number");
|
||||||
|
// String cardName = (String) resultMap.get("card_name");
|
||||||
|
// String cardType = (String) resultMap.get("card_type");
|
||||||
|
// BankCard bankCard = new BankCard();
|
||||||
|
// bankCard.setUserId(userId);
|
||||||
|
// bankCard.setBankNumber(cardNumber);
|
||||||
|
// bankCard.setBankName(bankName);
|
||||||
|
// bankCard.setBankType(cardType);
|
||||||
|
// bankCard.setCardName(cardName);
|
||||||
|
// System.out.println(bankCard);
|
||||||
|
// return sysBankCardMapper.insertBankCard(bankCard)>0;
|
||||||
|
// @Post(value = "https://dfbankcard.market.alicloudapi.com/ocr/bankcard",
|
||||||
|
// headers = {"Authorization:APPCODE b491bc5d56bb4fa59171e19aaab030bb","Content-Type:application/x-www-form-urlencoded; charset=UTF-8"})
|
||||||
|
// Map helloForestBank(@DataParam("image") String image);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.mybasic.api.domain.Purse;
|
||||||
import com.ruoyi.mybasic.api.domain.UserMoneyLogs;
|
import com.ruoyi.mybasic.api.domain.UserMoneyLogs;
|
||||||
import com.ruoyi.mybasic.common.domain.MoneyWithdraw;
|
import com.ruoyi.mybasic.common.domain.MoneyWithdraw;
|
||||||
import com.ruoyi.mybasic.common.domain.RechargeLog;
|
import com.ruoyi.mybasic.common.domain.RechargeLog;
|
||||||
|
@ -61,9 +62,9 @@ public class PurseControllerTwo {
|
||||||
* 根据userId查询钱包表
|
* 根据userId查询钱包表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/purseObject")
|
@GetMapping("/purseObject")
|
||||||
public R<PurseResponse> purseObject(){
|
public R<Purse> purseObject(){
|
||||||
PurseResponse purseResponseR = purseServiceTwo.purseObject();
|
Purse purse = purseServiceTwo.purseObject();
|
||||||
return R.ok(purseResponseR);
|
return R.ok(purse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,8 +77,8 @@ public class PurseControllerTwo {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getBalance")
|
@GetMapping("/getBalance")
|
||||||
public R<Integer> getBalance(){
|
public R<Integer> getBalance(){
|
||||||
PurseResponse purseResponseR = purseServiceTwo.purseObject();
|
Purse purse = purseServiceTwo.purseObject();
|
||||||
return R.ok(purseResponseR.getBalanceFee());
|
return R.ok(purse.getBalanceFee());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -216,7 +217,7 @@ public class PurseControllerTwo {
|
||||||
@PostMapping("/withdrawPurse")//完成
|
@PostMapping("/withdrawPurse")//完成
|
||||||
public void withdrawPurse(AliPay aliPay){
|
public void withdrawPurse(AliPay aliPay){
|
||||||
|
|
||||||
PurseResponse purseResponse = purseServiceTwo.purseObject();
|
Purse purseResponse = purseServiceTwo.purseObject();
|
||||||
//获取当前用户的余额
|
//获取当前用户的余额
|
||||||
int balanceFee = purseResponse.getBalanceFee();
|
int balanceFee = purseResponse.getBalanceFee();
|
||||||
//获取前台输入的金额
|
//获取前台输入的金额
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ruoyi.mybasic.mapper;
|
package com.ruoyi.mybasic.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ruoyi.mybasic.api.domain.Purse;
|
||||||
import com.ruoyi.mybasic.api.domain.UserMoneyLogs;
|
import com.ruoyi.mybasic.api.domain.UserMoneyLogs;
|
||||||
import com.ruoyi.mybasic.common.domain.request.InvitationRecordRequest;
|
import com.ruoyi.mybasic.common.domain.request.InvitationRecordRequest;
|
||||||
import com.ruoyi.mybasic.common.domain.request.PurseRequest;
|
import com.ruoyi.mybasic.common.domain.request.PurseRequest;
|
||||||
|
@ -44,5 +45,5 @@ public interface InvitationMapper {
|
||||||
* @param purseResponse
|
* @param purseResponse
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int updateUserMoney(PurseResponse purseResponse);
|
int updateUserMoney(Purse purseResponse);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.ruoyi.mybasic.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.mybasic.common.domain.BankConfig;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行卡验证
|
||||||
|
*/
|
||||||
|
public interface MessageMapper {
|
||||||
|
void addBank(BankConfig bankConfig);
|
||||||
|
|
||||||
|
//查询当前人银行卡的当前银行卡 根据银行卡号进行循环查询 是否已经绑定
|
||||||
|
List<Integer> listBankCardNo(@Param("userId") Long userId);
|
||||||
|
}
|
|
@ -17,7 +17,7 @@ import java.util.List;
|
||||||
public interface PurseMapperTwo{
|
public interface PurseMapperTwo{
|
||||||
|
|
||||||
//根据当前登录人的userId获取到钱包的对象
|
//根据当前登录人的userId获取到钱包的对象
|
||||||
PurseResponse purseObject(@Param("userId") Long userId);
|
Purse purseObject(@Param("userId") Long userId);
|
||||||
|
|
||||||
//添加记录表
|
//添加记录表
|
||||||
void addMoneyLogs(UserMoneyLogs userMoneyLogs);
|
void addMoneyLogs(UserMoneyLogs userMoneyLogs);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.mybasic.service.Impl;
|
package com.ruoyi.mybasic.service.Impl;
|
||||||
|
|
||||||
|
import com.ruoyi.mybasic.api.domain.Purse;
|
||||||
import com.ruoyi.mybasic.api.domain.UserMoneyLogs;
|
import com.ruoyi.mybasic.api.domain.UserMoneyLogs;
|
||||||
import com.ruoyi.mybasic.common.domain.request.RequestInvitationRecord;
|
import com.ruoyi.mybasic.common.domain.request.RequestInvitationRecord;
|
||||||
import com.ruoyi.mybasic.common.domain.response.PurseResponse;
|
import com.ruoyi.mybasic.common.domain.response.PurseResponse;
|
||||||
|
@ -104,7 +105,7 @@ public class InvitationServiceImpl implements InvitationService {
|
||||||
Integer status = userMoneyLogs.getStatus();
|
Integer status = userMoneyLogs.getStatus();
|
||||||
|
|
||||||
//查询钱包当前信息
|
//查询钱包当前信息
|
||||||
PurseResponse purseResponse = purseServiceTwo.purseObject();
|
Purse purseResponse = purseServiceTwo.purseObject();
|
||||||
purseResponse.setUpdateTime(new Date());
|
purseResponse.setUpdateTime(new Date());
|
||||||
if (status == 1){
|
if (status == 1){
|
||||||
//判断余额是否充足
|
//判断余额是否充足
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.ruoyi.mybasic.service.Impl;
|
||||||
|
|
||||||
|
import com.ruoyi.mybasic.common.domain.BankConfig;
|
||||||
|
import com.ruoyi.mybasic.mapper.MessageMapper;
|
||||||
|
import com.ruoyi.mybasic.service.MessageService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行卡实现层
|
||||||
|
* @author swh
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class MessageServiceImpl implements MessageService {
|
||||||
|
|
||||||
|
/** @noinspection SpringJavaInjectionPointsAutowiringInspection*/
|
||||||
|
@Autowired
|
||||||
|
private MessageMapper messageMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定银行卡 添加到银行卡表中
|
||||||
|
* @param bankConfig
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addBank(BankConfig bankConfig) {
|
||||||
|
messageMapper.addBank(bankConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当前人银行卡的当前银行卡 根据银行卡号进行循环查询 是否已经绑定
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Integer> listBankCardNo(Long userId) {
|
||||||
|
|
||||||
|
return messageMapper.listBankCardNo(userId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,7 +39,7 @@ public class PurseServiceTwoImpl implements PurseServiceTwo {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PurseResponse purseObject() {
|
public Purse purseObject() {
|
||||||
//获取当前用户id
|
//获取当前用户id
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
return purseMapperTwo.purseObject(userId);
|
return purseMapperTwo.purseObject(userId);
|
||||||
|
@ -81,7 +81,7 @@ public class PurseServiceTwoImpl implements PurseServiceTwo {
|
||||||
public void purseBalanceChange(UserMoneyLogs userMoneyLogs) {
|
public void purseBalanceChange(UserMoneyLogs userMoneyLogs) {
|
||||||
|
|
||||||
//获取当前用户的余额
|
//获取当前用户的余额
|
||||||
PurseResponse purseResponse = this.purseObject();
|
Purse purseResponse = this.purseObject();
|
||||||
//当前用户的余额
|
//当前用户的余额
|
||||||
int balanceFee = purseResponse.getBalanceFee();
|
int balanceFee = purseResponse.getBalanceFee();
|
||||||
//获取到状态是收入还是支出 1:支出 2 收入
|
//获取到状态是收入还是支出 1:支出 2 收入
|
||||||
|
@ -108,7 +108,7 @@ public class PurseServiceTwoImpl implements PurseServiceTwo {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addPurse(Long userId) {
|
public void addPurse(Long userId) {
|
||||||
PurseResponse purseResponse = purseMapperTwo.purseObject(userId);
|
Purse purseResponse = purseMapperTwo.purseObject(userId);
|
||||||
if (purseResponse != null ){
|
if (purseResponse != null ){
|
||||||
throw new ServiceException("已有该用户,请重新创建");
|
throw new ServiceException("已有该用户,请重新创建");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.ruoyi.mybasic.service;
|
||||||
|
|
||||||
|
import com.ruoyi.mybasic.common.domain.BankConfig;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行卡
|
||||||
|
* @author swh
|
||||||
|
*/
|
||||||
|
public interface MessageService {
|
||||||
|
|
||||||
|
//绑定银行卡 添加信息到 数据库中
|
||||||
|
void addBank(BankConfig bankConfig);
|
||||||
|
|
||||||
|
//查询当前人银行卡的当前银行卡 根据银行卡号进行循环查询 是否已经绑定
|
||||||
|
List<Integer> listBankCardNo(@Param("userId") Long userId);
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ruoyi.mybasic.service;
|
package com.ruoyi.mybasic.service;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.mybasic.api.domain.Purse;
|
||||||
import com.ruoyi.mybasic.api.domain.UserMoneyLogs;
|
import com.ruoyi.mybasic.api.domain.UserMoneyLogs;
|
||||||
import com.ruoyi.mybasic.common.domain.MoneyLog;
|
import com.ruoyi.mybasic.common.domain.MoneyLog;
|
||||||
import com.ruoyi.mybasic.common.domain.MoneyWithdraw;
|
import com.ruoyi.mybasic.common.domain.MoneyWithdraw;
|
||||||
|
@ -15,7 +16,7 @@ import java.util.List;
|
||||||
* 钱包持久层-->新
|
* 钱包持久层-->新
|
||||||
*/
|
*/
|
||||||
public interface PurseServiceTwo {
|
public interface PurseServiceTwo {
|
||||||
PurseResponse purseObject();
|
Purse purseObject();
|
||||||
|
|
||||||
void addPurse(Long userId);
|
void addPurse(Long userId);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,314 @@
|
||||||
|
package com.ruoyi.mybasic.util;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.NameValuePair;
|
||||||
|
import org.apache.http.client.HttpClient;
|
||||||
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
|
import org.apache.http.client.methods.HttpDelete;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.client.methods.HttpPut;
|
||||||
|
import org.apache.http.conn.ClientConnectionManager;
|
||||||
|
import org.apache.http.conn.scheme.Scheme;
|
||||||
|
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||||
|
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||||
|
import org.apache.http.entity.ByteArrayEntity;
|
||||||
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.TrustManager;
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class HttpUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doGet(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpGet request = new HttpGet(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* post form
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param bodys
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPost(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
Map<String, String> bodys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bodys != null) {
|
||||||
|
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
|
||||||
|
|
||||||
|
for (String key : bodys.keySet()) {
|
||||||
|
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
|
||||||
|
}
|
||||||
|
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
|
||||||
|
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
|
||||||
|
request.setEntity(formEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post String
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPost(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
String body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(body)) {
|
||||||
|
request.setEntity(new StringEntity(body, "utf-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post stream
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPost(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
byte[] body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body != null) {
|
||||||
|
request.setEntity(new ByteArrayEntity(body));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put String
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPut(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
String body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(body)) {
|
||||||
|
request.setEntity(new StringEntity(body, "utf-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put stream
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPut(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
byte[] body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body != null) {
|
||||||
|
request.setEntity(new ByteArrayEntity(body));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doDelete(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
|
||||||
|
StringBuilder sbUrl = new StringBuilder();
|
||||||
|
sbUrl.append(host);
|
||||||
|
if (!StringUtils.isBlank(path)) {
|
||||||
|
sbUrl.append(path);
|
||||||
|
}
|
||||||
|
if (null != querys) {
|
||||||
|
StringBuilder sbQuery = new StringBuilder();
|
||||||
|
for (Map.Entry<String, String> query : querys.entrySet()) {
|
||||||
|
if (0 < sbQuery.length()) {
|
||||||
|
sbQuery.append("&");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
|
||||||
|
sbQuery.append(query.getValue());
|
||||||
|
}
|
||||||
|
if (!StringUtils.isBlank(query.getKey())) {
|
||||||
|
sbQuery.append(query.getKey());
|
||||||
|
if (!StringUtils.isBlank(query.getValue())) {
|
||||||
|
sbQuery.append("=");
|
||||||
|
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (0 < sbQuery.length()) {
|
||||||
|
sbUrl.append("?").append(sbQuery);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sbUrl.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HttpClient wrapClient(String host) {
|
||||||
|
HttpClient httpClient = new DefaultHttpClient();
|
||||||
|
if (host.startsWith("https://")) {
|
||||||
|
sslClient(httpClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sslClient(HttpClient httpClient) {
|
||||||
|
try {
|
||||||
|
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||||
|
X509TrustManager tm = new X509TrustManager() {
|
||||||
|
@Override
|
||||||
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void checkClientTrusted(X509Certificate[] xcs, String str) {
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void checkServerTrusted(X509Certificate[] xcs, String str) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ctx.init(null, new TrustManager[] { tm }, null);
|
||||||
|
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
|
||||||
|
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||||
|
ClientConnectionManager ccm = httpClient.getConnectionManager();
|
||||||
|
SchemeRegistry registry = ccm.getSchemeRegistry();
|
||||||
|
registry.register(new Scheme("https", 443, ssf));
|
||||||
|
} catch (KeyManagementException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
} catch (NoSuchAlgorithmException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.ruoyi.mybasic.util;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.qiniu.common.QiniuException;
|
||||||
|
import com.qiniu.http.Response;
|
||||||
|
import com.qiniu.storage.Configuration;
|
||||||
|
import com.qiniu.storage.Region;
|
||||||
|
import com.qiniu.storage.UploadManager;
|
||||||
|
import com.qiniu.storage.model.DefaultPutRet;
|
||||||
|
import com.qiniu.util.Auth;
|
||||||
|
import com.ruoyi.mybasic.config.QiNiuYunConfig;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 七牛云文件上传工具类
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class UploadUtil {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private QiNiuYunConfig qiNiuYunConfig;
|
||||||
|
|
||||||
|
|
||||||
|
public String upload(MultipartFile file){
|
||||||
|
//文件后缀名
|
||||||
|
String suffix = file.getOriginalFilename().substring(
|
||||||
|
file.getOriginalFilename().lastIndexOf(".")
|
||||||
|
);
|
||||||
|
//根据时间戳定义新文件名 并拼接后缀
|
||||||
|
String fileName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"))+suffix;
|
||||||
|
|
||||||
|
//构造一个带指定 Region 对象的配置类
|
||||||
|
Configuration cfg = new Configuration(Region.huadongZheJiang2());
|
||||||
|
cfg.resumableUploadAPIVersion = Configuration.ResumableUploadAPIVersion.V2;// 指定分片上传版本
|
||||||
|
cfg.resumableUploadMaxConcurrentTaskCount = 2;
|
||||||
|
|
||||||
|
//...其他参数参考类注释
|
||||||
|
UploadManager uploadManager = new UploadManager(cfg);
|
||||||
|
//...生成上传凭证,然后准备上传
|
||||||
|
String accessKey = qiNiuYunConfig.getAccessKey();
|
||||||
|
String secretKey = qiNiuYunConfig.getSecretKey();
|
||||||
|
String bucket = qiNiuYunConfig.getBucket();
|
||||||
|
//默认不指定key的情况下,以文件内容的hash值作为文件名
|
||||||
|
String key = fileName;
|
||||||
|
|
||||||
|
Auth auth = Auth.create(accessKey, secretKey);
|
||||||
|
String upToken = auth.uploadToken(bucket);
|
||||||
|
try {
|
||||||
|
Response response = uploadManager.put(file.getBytes(), key, upToken);
|
||||||
|
//解析上传成功的结果
|
||||||
|
DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
|
||||||
|
System.out.println(putRet.key); //文件名 利用时间戳
|
||||||
|
System.out.println(putRet.hash);
|
||||||
|
return qiNiuYunConfig.getHostName()+putRet.key;
|
||||||
|
} catch (QiniuException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
if (ex.response != null) {
|
||||||
|
System.err.println(ex.response);
|
||||||
|
try {
|
||||||
|
String body = ex.response.toString();
|
||||||
|
System.err.println(body);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("文件解析异常");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,17 @@
|
||||||
# Tomcat
|
# Tomcat
|
||||||
server:
|
server:
|
||||||
port: 9001
|
port: 9090
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
max-file-size: 100MB
|
||||||
|
max-request-size: 128MB
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: health-mybasic
|
name: health-mybasicTwo
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
active: dev
|
active: dev
|
||||||
|
@ -36,6 +41,19 @@ spring:
|
||||||
alipay.notifyUrl: http://vhzkca.natappfree.cc/alipay/notify
|
alipay.notifyUrl: http://vhzkca.natappfree.cc/alipay/notify
|
||||||
alipay.returnUrl: http://localhost:9001/purse
|
alipay.returnUrl: http://localhost:9001/purse
|
||||||
|
|
||||||
|
# 七牛云
|
||||||
|
# Tomcat设置最大传输文件为100MB
|
||||||
|
|
||||||
|
|
||||||
|
# 密钥
|
||||||
|
qi-niu-yun:
|
||||||
|
access-key: Jh_cfiuScoP26TjMeGSzXJWRYI6ClKASz_R2dn1C
|
||||||
|
secret-key: EEGZt0ObiO3dxcb_WDE1hPCsu_au1rSJ7mAHka_-
|
||||||
|
# 空间名称
|
||||||
|
bucket: test-2102
|
||||||
|
# 域名
|
||||||
|
host-name: http://s2lnqk3yo.bkt.clouddn.com/
|
||||||
|
|
||||||
#沙箱配置
|
#沙箱配置
|
||||||
# alipay.appId: 9021000130611735
|
# alipay.appId: 9021000130611735
|
||||||
# alipay.appPrivateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDM7+9TRvFFs0acZNRvgKrTUnig4k1Th/Pl02VRI4aTNpQIHpiTcViytaIr9ByioCNzmE5D3hMMp4arN3MiXnH9c+R9holwDtjbQyDC9QLRwZVMRnduXdZ42h2+5jhbt34wKXp61t3rFW9X9gA2iPJYbV6LRmyX+iuhfGtk5YPrTu307D79E6p7n7h+UBxaS0w0u5pm2eoiKFml3hRRhuY6IqEOo87gg7psjpj+KEV81cpDpvlICYRfVq425PWA+wTKVPsV2YGK0V6da3qbo17bNeBU6vIOUaDDkfflCZG2wSdRKzmrVrrr2i+lzuC3pxNimFDavvaRBdF1RzdvmeHBAgMBAAECggEAIEloxhD2MAn3hOopwctenl5u3MHqds+DcGDmpGrZZ9YAamsPlKMV20ncW9pgrIpYK30CT5TsIWE/STg6Ll78zHZ2uAP7ISllpt2jirN5FzzNXa/4Xu3vvSh36TxyApkdC09tmW7ClafR2+TI0c6vh5jrfTvCHgtu1kk4zjOOngKPxRielI7qcSyO0GGlNPYIXZO7X9De/lqNsAu0e8j8DbAWhOx/0EZ7zpZEBTVyZe2s7Lbq1lEWqn07vYjKWCoAp9O1IEll/9963U5yfV+rMj47lP+k5x/oa6HVd5TxeUeOX2vd/HZitxBeq4lPt5cqHciLWnPgvv68VrviB5pmZQKBgQD/orVuGXdcw3zOBHnzqOclC05sZH2UO6CrJERn82gKCgdx5wQwE1WwqgI0S+oGVpO6wgAM/1g6vT8U6EgovMbdmjZ+Adf657EHLEBOYee34PrVLRcc+uMbFTTwM7E31l+SUIcYLXw2zqu2/QXv7/4K6cWx0cIhCse3NvWc6oRb4wKBgQDNOrlwlYV316ZZp5II5EmqKMEvAx+Lf/4SqPBdj0BDCtZGqM0ADMUCBb0mATnRebalgGqPbIWgIDKrHXUOy2Kr5ARIRERp3oV1csXFAwIgxMncyOKJqGAHZBLeQFkLP6PEL7gniIGAIsIT5ecu5EzuEUQNHxLSVD7c5BZTmK+FCwKBgACNy7LXX0jWK5kOrWz3urh708msVhFSJ8D3LSbEgj8zUlzO0VWBVTgyxhpy56jn2x4WeYWNsBVAf7h94FomPpAQW3neaydiBSIs2F7TG3tsg16e4GPxrzhJzXmPwxyJ3F8myYQl5RUBUaHt3mtsq7I+W21NNQx5R4GAHvweDfddAoGAPetS2bnzC+ZfhTs+nzopU5J6PrHliZQzVvPrmX7H97JEVgtF1pcDtYl/uQCzrhTX23U0MVOfuWEdiG0ZzT3l5lCkTh1yurJtd7MKIle3A6X79YYSe0/2sSQrYSzu8KrhwSZYnGzeDYfvIEvEBWzSHR3Od1sBtb2/Pav/ZHdztWMCgYEA7/DECBPTvQaXLWYZO96UQ7y1WCelmfCa0XbRvwL/i3DB5/aK0d8eSDUVQ9aXTmegRMcXrvGgf3YmLteipUpwUq0i6KNM/ynDbx3W0LtG53+BOsFSnVkNsN53GZJ6C+ZoxmPcouCWdaxdjPoJFF1pPv1lb8Ia5qnhHaoMjLYoSpQ=
|
# alipay.appPrivateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDM7+9TRvFFs0acZNRvgKrTUnig4k1Th/Pl02VRI4aTNpQIHpiTcViytaIr9ByioCNzmE5D3hMMp4arN3MiXnH9c+R9holwDtjbQyDC9QLRwZVMRnduXdZ42h2+5jhbt34wKXp61t3rFW9X9gA2iPJYbV6LRmyX+iuhfGtk5YPrTu307D79E6p7n7h+UBxaS0w0u5pm2eoiKFml3hRRhuY6IqEOo87gg7psjpj+KEV81cpDpvlICYRfVq425PWA+wTKVPsV2YGK0V6da3qbo17bNeBU6vIOUaDDkfflCZG2wSdRKzmrVrrr2i+lzuC3pxNimFDavvaRBdF1RzdvmeHBAgMBAAECggEAIEloxhD2MAn3hOopwctenl5u3MHqds+DcGDmpGrZZ9YAamsPlKMV20ncW9pgrIpYK30CT5TsIWE/STg6Ll78zHZ2uAP7ISllpt2jirN5FzzNXa/4Xu3vvSh36TxyApkdC09tmW7ClafR2+TI0c6vh5jrfTvCHgtu1kk4zjOOngKPxRielI7qcSyO0GGlNPYIXZO7X9De/lqNsAu0e8j8DbAWhOx/0EZ7zpZEBTVyZe2s7Lbq1lEWqn07vYjKWCoAp9O1IEll/9963U5yfV+rMj47lP+k5x/oa6HVd5TxeUeOX2vd/HZitxBeq4lPt5cqHciLWnPgvv68VrviB5pmZQKBgQD/orVuGXdcw3zOBHnzqOclC05sZH2UO6CrJERn82gKCgdx5wQwE1WwqgI0S+oGVpO6wgAM/1g6vT8U6EgovMbdmjZ+Adf657EHLEBOYee34PrVLRcc+uMbFTTwM7E31l+SUIcYLXw2zqu2/QXv7/4K6cWx0cIhCse3NvWc6oRb4wKBgQDNOrlwlYV316ZZp5II5EmqKMEvAx+Lf/4SqPBdj0BDCtZGqM0ADMUCBb0mATnRebalgGqPbIWgIDKrHXUOy2Kr5ARIRERp3oV1csXFAwIgxMncyOKJqGAHZBLeQFkLP6PEL7gniIGAIsIT5ecu5EzuEUQNHxLSVD7c5BZTmK+FCwKBgACNy7LXX0jWK5kOrWz3urh708msVhFSJ8D3LSbEgj8zUlzO0VWBVTgyxhpy56jn2x4WeYWNsBVAf7h94FomPpAQW3neaydiBSIs2F7TG3tsg16e4GPxrzhJzXmPwxyJ3F8myYQl5RUBUaHt3mtsq7I+W21NNQx5R4GAHvweDfddAoGAPetS2bnzC+ZfhTs+nzopU5J6PrHliZQzVvPrmX7H97JEVgtF1pcDtYl/uQCzrhTX23U0MVOfuWEdiG0ZzT3l5lCkTh1yurJtd7MKIle3A6X79YYSe0/2sSQrYSzu8KrhwSZYnGzeDYfvIEvEBWzSHR3Od1sBtb2/Pav/ZHdztWMCgYEA7/DECBPTvQaXLWYZO96UQ7y1WCelmfCa0XbRvwL/i3DB5/aK0d8eSDUVQ9aXTmegRMcXrvGgf3YmLteipUpwUq0i6KNM/ynDbx3W0LtG53+BOsFSnVkNsN53GZJ6C+ZoxmPcouCWdaxdjPoJFF1pPv1lb8Ia5qnhHaoMjLYoSpQ=
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.mybasic.mapper.MessageMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 绑定银行卡 添加到银行卡表中-->
|
||||||
|
<insert id="addBank">
|
||||||
|
insert into t_bank
|
||||||
|
(
|
||||||
|
<if test="userId != null ">
|
||||||
|
user_id,
|
||||||
|
</if>
|
||||||
|
<if test="cardType != null and cardType != '' ">
|
||||||
|
card_type,
|
||||||
|
</if>
|
||||||
|
<if test="bankName != null and bankName != '' ">
|
||||||
|
bank_name,
|
||||||
|
</if>
|
||||||
|
<if test="cardNo != null and cardNo != ''">
|
||||||
|
card_no,
|
||||||
|
</if>
|
||||||
|
<if test="bankId != null ">
|
||||||
|
bank_id,
|
||||||
|
</if>
|
||||||
|
<if test="bankCode != null and bankCode != ''">
|
||||||
|
bank_code,
|
||||||
|
</if>
|
||||||
|
create_time
|
||||||
|
)
|
||||||
|
values
|
||||||
|
(
|
||||||
|
<if test="userId != null ">
|
||||||
|
#{userId},
|
||||||
|
</if>
|
||||||
|
<if test="cardType != null and cardType != '' ">
|
||||||
|
#{cardType},
|
||||||
|
</if>
|
||||||
|
<if test="bankName != null and bankName != '' ">
|
||||||
|
#{bankName},
|
||||||
|
</if>
|
||||||
|
<if test="cardNo != null and cardNo != ''">
|
||||||
|
#{cardNo},
|
||||||
|
</if>
|
||||||
|
<if test="bankId != null ">
|
||||||
|
#{bankId},
|
||||||
|
</if>
|
||||||
|
<if test="bankCode != null and bankCode != ''">
|
||||||
|
#{bankCode},
|
||||||
|
</if>
|
||||||
|
now()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
<!-- 查询当前人银行卡的当前银行卡 根据银行卡号进行循环查询 是否已经绑定-->
|
||||||
|
<select id="listBankCardNo" resultType="java.lang.Integer">
|
||||||
|
SELECT t_bankTwo.card_no from t_bankTwo where user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -99,7 +99,7 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="purseObject" resultType="com.ruoyi.mybasic.common.domain.response.PurseResponse">
|
<select id="purseObject" resultType="com.ruoyi.mybasic.api.domain.Purse">
|
||||||
select * from t_purse where user_id = #{userId}
|
select * from t_purse where user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue