Compare commits

...

14 Commits

Author SHA1 Message Date
shaowenhao fd7f5f0b22 扫描银行卡迭代 2023-11-01 20:23:33 +08:00
ZhiShuo_Lou cb60060e51 身份证扫描信息添加(线上测试) 2023-11-01 17:09:14 +08:00
ZhiShuo_Lou 1ed5729d50 身份证扫描信息添加 2023-11-01 17:08:30 +08:00
shaowenhao 2801ad7ded 新增银行卡1 2023-11-01 13:43:33 +08:00
shaowenhao a4efbc1400 新增银行卡 2023-11-01 13:43:06 +08:00
shaowenhao 2652f15c8c 整合2 2023-10-31 09:02:12 +08:00
ZhiShuo_Lou 23407fcaf8 汇总整改 2023-10-30 21:02:55 +08:00
ZhiShuo_Lou 2c71b0424c 维护5 2023-10-30 20:53:33 +08:00
ZhiShuo_Lou 0e378f580d 维护4 2023-10-30 20:04:55 +08:00
ZhiShuo_Lou 6dba7de499 维护3 2023-10-30 19:50:39 +08:00
ZhiShuo_Lou 2e558364a1 维护2 2023-10-30 19:39:57 +08:00
ZhiShuo_Lou 2acb1a10cc 维护1 2023-10-30 19:35:49 +08:00
ZhiShuo_Lou 91d5ab4774 汇总2 2023-10-30 18:44:25 +08:00
ZhiShuo_Lou 537b038c00 汇总1 2023-10-30 14:49:34 +08:00
34 changed files with 1528 additions and 189 deletions

56
pom.xml
View File

@ -36,6 +36,39 @@
<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 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
@ -125,12 +158,6 @@
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>health-api-mybasic</artifactId>
<version>3.6.6</version>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>health-common-security</artifactId>
@ -210,6 +237,23 @@
<artifactId>health-common-redis</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>health-api-mybasic</artifactId>
<version>3.6.6</version>
</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>

View File

@ -207,7 +207,7 @@ public class User {
// 测试类
public static void main(String[] args) {
User user = new User("张三", "411623200307253418");
User user = new User("张三", "411623200107253418");
user.verifyIdCard();
}

View File

@ -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;
}

View File

@ -0,0 +1,73 @@
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;
/**
*
* @author Lou_Zs
*/
@Data
public class Card {
/**
*
*/
private Integer userId;
/**
*
*/
private String cardFace;
/**
*
*/
private String cardBack;
/**
*
*/
private String num;
/**
*
*/
private String name;
/**
*
*/
private String address;
/**
*
*/
private String sex;
/**
*
*/
private String birth;
/**
*
*/
private String nationality;
/**
*
*/
private String startDate;
/**
*
*/
private String endDate;
/**
*
*/
private String issue;
/**
*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date createTime;
}

View File

@ -1,6 +1,8 @@
package com.ruoyi.mybasic.common.domain;
import com.alibaba.druid.sql.visitor.functions.Char;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
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;
/**
*
@ -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;
}

View File

@ -1,6 +1,8 @@
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;
@ -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;
}

View File

@ -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;
}

View File

@ -1,6 +1,5 @@
package com.ruoyi.mybasic.common.domain.request;
import com.ruoyi.mybasic.common.domain.response.PurseResponse;
import lombok.Data;
/**

View File

@ -0,0 +1,54 @@
package com.ruoyi.mybasic.common.domain.response;
import lombok.Data;
/**
*
* @author Lou_Zs
*/
@Data
public class ResponseCard {
//<--正面-->
/**
*
*/
private String address;
/**
*
*/
private String name;
/**
*
*/
private String nationality;
/**
*
*/
private String num;
/**
*
*/
private String sex;
/**
*
*/
private String birth;
//<--正面-->
//<--反面-->
/**
*
*/
private String startDate;
/**
*
*/
private String endDate;
/**
*
*/
private String issue;
//<--反面-->
}

View File

@ -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;
}

View File

@ -0,0 +1,48 @@
package com.ruoyi.mybasic.controller;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.mybasic.service.CardService;
import lombok.extern.log4j.Log4j2;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
/**
*
* @author Lou_Zs
*/
@RestController
@RequestMapping("/cardUpload")
@Log4j2
public class CardController {
@Autowired
private CardService cardService;
@Autowired
private HttpServletRequest request;
/**
*
* @param fileFace
* @param fileBack
* @return
*/
@PostMapping("/uploadCardFace")
public R uploadCardFace(@RequestParam("fileFace")MultipartFile fileFace,@RequestParam("fileBack")MultipartFile fileBack){
log.info("功能介绍:上传身份证,请求方式:{},请求路径:{},请求参数:{}",
request.getMethod(),request.getRequestURI(), JSONObject.toJSONString(fileFace+"-"+fileBack));
//上传身份证正面
cardService.uploadCardFace(fileFace,fileBack);
log.info("功能介绍:上传身份证,请求方式:{},请求路径:{},响应结果:{}",
request.getMethod(),request.getRequestURI(), JSONObject.toJSONString(R.ok()));
return R.ok();
}
}

View File

@ -0,0 +1,110 @@
package com.ruoyi.mybasic.controller;
import com.ruoyi.mybasic.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
/**
*
* @author swh
*/
@RequestMapping("/message")
@RestController
public class MessageController {
@Autowired
private MessageService messageService;
/**
* api
*/
@PostMapping("/upload")
public void upload(@RequestParam("file") MultipartFile file) throws Exception {
messageService.upload(file);
}
/**
*
* @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;
// }
// @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);
// }
}

View File

@ -5,6 +5,7 @@ import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.security.utils.SecurityUtils;
@ -15,6 +16,7 @@ import com.ruoyi.mybasic.common.domain.RechargeLog;
import com.ruoyi.mybasic.common.domain.ailPay.AliPay;
import com.ruoyi.mybasic.common.domain.ailPay.AliPayConfig;
import com.ruoyi.mybasic.common.domain.request.PurseRequest;
import com.ruoyi.mybasic.common.domain.response.PurseResponse;
import com.ruoyi.mybasic.service.PurseServiceTwo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -51,15 +53,6 @@ public class PurseControllerTwo {
@Autowired
private PurseServiceTwo purseServiceTwo;
/**
*
*
*/
@GetMapping("/purseList")
public R<List<PurseRequest>>purseList(){
List<PurseRequest> list = purseServiceTwo.purseListAll();
return R.ok(list);
}
/**
*
@ -74,6 +67,22 @@ public class PurseControllerTwo {
return R.ok(purse);
}
/**
*
*
*
* id securityUtils.getUserId()
* userId
*/
@GetMapping("/getBalance")
public R<Integer> getBalance(){
Purse purse = purseServiceTwo.purseObject();
return R.ok(purse.getBalanceFee());
}
/**
*
* : /
@ -184,7 +193,7 @@ public class PurseControllerTwo {
//支付成功 处理订单逻辑
String outTradeNo = params.get("out_trade_no");
//处理订单逻辑
//返回成功响应给支付宝
//fanhui成功响应给支付宝
return "success";
}
}
@ -207,9 +216,10 @@ public class PurseControllerTwo {
*/
@PostMapping("/withdrawPurse")//完成
public void withdrawPurse(AliPay aliPay){
Purse purse = purseServiceTwo.purseObject();
Purse purseResponse = purseServiceTwo.purseObject();
//获取当前用户的余额
int balanceFee = purse.getBalanceFee();
int balanceFee = purseResponse.getBalanceFee();
//获取前台输入的金额
double totalAmount = aliPay.getTotalAmount();
//判断需要提现的金额 * 100 跟当前H币的金额
@ -274,7 +284,7 @@ public class PurseControllerTwo {
// @GetMapping("/pay")
// @GetMapping("/pay")
// public void pay(AilPay ailPay , HttpServletResponse httpServletResponse) throws IOException, AlipayApiException {
// // 1. 创建Client通用SDK提供的Client负责调用支付宝的API
// AlipayClient alipayClient = new DefaultAlipayClient(GATEWAY_URL, alipayConfig.getAppId(),
@ -290,7 +300,7 @@ public class PurseControllerTwo {
// jsonObject.set("total_amount", 12); // 订单的总金额
// jsonObject.set("subject","测试"); // 支付的名称
// jsonObject.set("product_code", "FAST_INSTANT_TRADE_PAY"); // 固定配置
// jsonObject.set("", ailPay.getStatus());
//// jsonObject.set("", ailPay.getStatus());
// request.setBizContent(jsonObject.toString());
//
// JSONArray goodsDerail = new JSONArray();
@ -313,19 +323,19 @@ public class PurseControllerTwo {
// System.out.println("调用失败");
//
// }
//
// Long userId = SecurityUtils.getUserId();
// R<PurseResponse> purseResponseR = purseServiceTwo.purseObject(userId);
// double totalAmount = ailPay.getTotalAmount();
// purseResponseR.getData().setBalanceFee(totalAmount * 100);
// //创建一个新的对象
// PurseRequest purseRequest = new PurseRequest();
// //获取到当前的登录用户赋值
// purseRequest.setUserId(userId + "");
// //空余额 赋予新值
// purseRequest.setBalanceFee(totalAmount * 100);
// //修改余额
// purseServiceTwo.updPurseHBi(purseRequest);
//// //
//// Long userId = SecurityUtils.getUserId();
//// R<PurseResponse> purseResponseR = purseServiceTwo.purseObject(userId);
//// double totalAmount = ailPay.getTotalAmount();
////// purseResponseR.getData().setBalanceFee(totalAmount * 100);
//// //创建一个新的对象
//// PurseRequest purseRequest = new PurseRequest();
//// //获取到当前的登录用户赋值
//// purseRequest.setUserId(userId + "");
//// //空余额 赋予新值
//// purseRequest.setBalanceFee(totalAmount * 100);
//// //修改余额
//// purseServiceTwo.updPurseHBi(purseRequest);
//
//
// //执行请求,拿到响应的结果 ,返回给浏览器
@ -340,8 +350,8 @@ public class PurseControllerTwo {
// httpServletResponse.getWriter().flush();
// httpServletResponse.getWriter().close();
// }
//
//
// /**
// * 回调
// */

View File

@ -0,0 +1,25 @@
package com.ruoyi.mybasic.mapper;
import com.ruoyi.mybasic.common.domain.Card;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* mapper
*/
@Mapper
public interface CardMapper {
/**
* id
* @param userId
* @return
*/
Card findUserCard(@Param("userId") Long userId);
/**
*
* @param addCard
* @return
*/
int insertUserCard(Card addCard);
}

View File

@ -19,11 +19,6 @@ import java.util.List;
*/
@Mapper
public interface InvitationMapper {
List<InvitationRecordRequest> show(@Param("userId") String userId);
PurseRequest Inviteramount(long inviterId);
PurseRequest Inviteeamount(long inviteeId);
/**
*
@ -47,8 +42,8 @@ public interface InvitationMapper {
/**
*
* @param purse
* @param purseResponse
* @return
*/
int updateUserMoney(Purse purse);
int updateUserMoney(Purse purseResponse);
}

View File

@ -0,0 +1,19 @@
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;
import java.util.Map;
/**
*
*/
public interface MessageMapper {
void addBank(BankConfig bankConfig);
//查询当前人银行卡的当前银行卡 根据银行卡号进行循环查询 是否已经绑定
BankConfig selectBankId(@Param("bankId") Integer bankId);
}

View File

@ -33,11 +33,6 @@ public interface PurseMapperTwo{
//查询钱包里面的用户id
Integer purseUserId(@Param("userId") String userId);
void updPurseHBi(PurseRequest purseRequest);
List<PurseRequest> purseListAll();
void addPurseLogs(PurseRequest purseRequest);
void updWithdrawPurse(PurseRequest purseRequest);

View File

@ -0,0 +1,17 @@
package com.ruoyi.mybasic.service;
import org.springframework.web.multipart.MultipartFile;
/**
*
* @author Lou_Zs
*/
public interface CardService {
/**
*
* @param fileFace
* @param fileBack
*/
void uploadCardFace(MultipartFile fileFace, MultipartFile fileBack);
}

View File

@ -0,0 +1,133 @@
package com.ruoyi.mybasic.service.Impl;
import com.alibaba.druid.util.StringUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.mybasic.common.domain.Card;
import com.ruoyi.mybasic.common.domain.response.ResponseCard;
import com.ruoyi.mybasic.mapper.CardMapper;
import com.ruoyi.mybasic.service.CardService;
import com.ruoyi.mybasic.util.SdkCardUtils;
import com.ruoyi.mybasic.util.UploadUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date;
/**
*
* @author Lou_Zs
*/
@Service
public class CardServiceImpl implements CardService {
@Autowired
private CardMapper cardMapper;
@Autowired
private UploadUtil uploadUtil;
@Autowired
private SdkCardUtils sdkCardUtils;
/**
*
* @param fileFace
* @param fileBack
*/
@Override
public void uploadCardFace(MultipartFile fileFace, MultipartFile fileBack) {
//获取登入id
Long userId = SecurityUtils.getUserId();
Card card = cardMapper.findUserCard(userId);
if (null != card){
throw new RuntimeException("身份证信息已存在!");
}
//正面上传
String uploadFace = uploadUtil.upload(fileFace);
if (StringUtils.isEmpty(uploadFace)){
throw new RuntimeException("正面身份证信息上传失败");
}
//将图片文件读取并base64编码
String img_base64_face = sdkCardUtils.img_base64(uploadFace);
//反面上传
//将图片文件读取并base64编码
String uploadBack= uploadUtil.upload(fileBack);
if (StringUtils.isEmpty(uploadBack)){
throw new RuntimeException("反面身份证信息上传失败");
}
String img_base64_back = sdkCardUtils.img_base64(uploadBack);
//提取信息
//正
ResponseCard cardedFace = sdkCardUtils.cardFace(img_base64_face);
if (null == cardedFace){
throw new RuntimeException("正面身份证信息扫描失败");
}
//反
ResponseCard cardBack = sdkCardUtils.cardBack(img_base64_back);
if (null == cardBack){
throw new RuntimeException("反面身份证信息扫描失败");
}
//添加身份证信息
//正
Card addCard = new Card();
addCard.setUserId(Math.toIntExact(userId));
addCard.setCardFace(uploadFace);
addCard.setCardBack(uploadBack);
addCard.setNum(cardedFace.getNum());
addCard.setName(cardedFace.getName());
addCard.setAddress(cardedFace.getAddress());
addCard.setSex(cardedFace.getSex());
addCard.setBirth(cardedFace.getBirth());
addCard.setNationality(cardedFace.getNationality());
///反
addCard.setStartDate(cardBack.getStartDate());
addCard.setEndDate(cardBack.getEndDate());
addCard.setIssue(cardBack.getIssue());
addCard.setCreateTime(new Date());
//添加身份证信息
int i = cardMapper.insertUserCard(addCard);
if (i < 0){
throw new RuntimeException("身份证信息填充失败!");
}
}
// /**
// * 上传身份证正面
// * @param file
// */
// @Override
// public void uploadCardFace(MultipartFile file) {
// //获取当前登入人
// Long userId = SecurityUtils.getUserId();
// //上传文件
// String upload = uploadUtil.upload(file);
// if (StringUtils.isEmpty(upload)){
// throw new RuntimeException("图片上传失败!");
// }
// //查询用户是否存在身份证信息
// Card card = cardMapper.findUserCard(userId);
// if (null != card){
// //存在身份证信息
// if (card.getCardFace()!=null && !card.getCardFace().equals("")){
// //存在身份证正面信息
// throw new RuntimeException("身份证正面信息已存在!");
// }
// }
// if (null == card){
// //创建身份证信息表
// Card addCard = new Card();
// addCard.setUserId(Math.toIntExact(userId));
// addCard.setCardFace(upload);
// int i = cardMapper.insertCard(addCard);
// }
// //将图片文件读取并base64编码
// String img_base64 = sdkCardUtils.img_base64(upload);
// //读取身份证信息
// ResponseCard responseCard = sdkCardUtils.cardBack(img_base64);
// //添加身份证信息详情
//
// }
}

View File

@ -7,7 +7,6 @@ import com.ruoyi.mybasic.common.domain.response.PurseResponse;
import com.ruoyi.mybasic.mapper.InvitationMapper;
import com.ruoyi.mybasic.service.InvitationService;
import com.ruoyi.mybasic.service.PurseServiceTwo;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

View File

@ -0,0 +1,41 @@
package com.ruoyi.mybasic.service.Impl;
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.mapper.MessageMapper;
import com.ruoyi.mybasic.service.MessageService;
import com.ruoyi.mybasic.util.BankScan;
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;
@Autowired
private BankScan bankScan;
/**
*
* @param file
*/
@Override
public void upload(MultipartFile file) {
bankScan.BankScan(file);
}
}

View File

@ -1,7 +1,5 @@
package com.ruoyi.mybasic.service.Impl;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.mybasic.api.domain.Purse;
@ -33,15 +31,6 @@ public class PurseServiceTwoImpl implements PurseServiceTwo {
@Autowired
private PurseMapperTwo purseMapperTwo;
/**
*
* @return
*/
@Override
public List<PurseRequest> purseListAll() {
return purseMapperTwo.purseListAll();
}
/**
* userId
@ -69,31 +58,6 @@ public class PurseServiceTwoImpl implements PurseServiceTwo {
}
}
/**
*
* @param purseRequest
*/
@Override
public void addPurseLogs(PurseRequest purseRequest) {
purseMapperTwo.addPurseLogs(purseRequest);
}
/**
*
* : id
*
*
*
* apiid id ,
* api apiid
* id
*/
@Override
public void updWithdrawPurse(PurseRequest purseRequest) {
purseMapperTwo.updWithdrawPurse(purseRequest);
}
/**
*
@ -117,9 +81,9 @@ public class PurseServiceTwoImpl implements PurseServiceTwo {
public void purseBalanceChange(UserMoneyLogs userMoneyLogs) {
//获取当前用户的余额
Purse purse= this.purseObject();
Purse purseResponse = this.purseObject();
//当前用户的余额
int balanceFee = purse.getBalanceFee();
int balanceFee = purseResponse.getBalanceFee();
//获取到状态是收入还是支出 1支出 2 收入
int status = userMoneyLogs.getStatus();
//如果是支出 进行入参金额 和 原有金额 进行判断
@ -135,15 +99,6 @@ public class PurseServiceTwoImpl implements PurseServiceTwo {
purseMapperTwo.addMoneyLogs(userMoneyLogs);
}
/***
* H
* @param purseRequest
*/
@Override
public void updPurseHBi(PurseRequest purseRequest) {
purseMapperTwo.updPurseHBi(purseRequest);
}
/**
@ -153,8 +108,8 @@ public class PurseServiceTwoImpl implements PurseServiceTwo {
*/
@Override
public void addPurse(Long userId) {
Purse purse1 = purseMapperTwo.purseObject(userId);
if (purse1 != null ){
Purse purseResponse = purseMapperTwo.purseObject(userId);
if (purseResponse != null ){
throw new ServiceException("已有该用户,请重新创建");
}
//创建钱包对象

View File

@ -0,0 +1,17 @@
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 upload(MultipartFile file);
}

View File

@ -22,14 +22,6 @@ public interface PurseServiceTwo {
void purseBalanceChange(UserMoneyLogs userMoneyLogs);
void updPurseHBi(PurseRequest purseRequest);
List<PurseRequest> purseListAll();
void addPurseLogs(PurseRequest purseRequest);
void updWithdrawPurse(PurseRequest purseRequest);
void insertRechargeLog(RechargeLog rechargeLog);

View File

@ -1,47 +0,0 @@
//package com.ruoyi.mybasic.timer;
//
//import com.ruoyi.common.redis.service.RedisService;
//import com.ruoyi.common.security.utils.SecurityUtils;
//import com.ruoyi.mybasic.common.domain.response.PurseResponse;
//import com.ruoyi.mybasic.service.PurseServiceTwo;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
///**
// * 钱包余额定时器
// * @author Lou_Zs
// */
//@Component
//public class SysUserPurse {
//
// @Autowired
// private PurseServiceTwo purseServiceTwo;
// @Autowired
// private RedisService redisService;
//
// //常量
// public final static String PURSE_NAME = "PURSE";
//
//
// /**
// * 定时器每五分钟执行
// */
// @Scheduled(cron = "0 0/5 * * * ?")
// public void userPurse(){
// System.out.println("~~~~~~定时器开始扫描钱包余额~~~~~~");
// //获取用户的编号
// Long userId = SecurityUtils.getUserId();
//
// //根据用户编号查询用户钱包
// PurseResponse purseResponse = purseServiceTwo.purseObject(userId);
//
// if (null == purseResponse){
// throw new RuntimeException("查无此用户!");
// }
// //钱包余额
// Integer balanceFee = purseResponse.getBalanceFee();
// //将余额存入redis
// redisService.setCacheObject(userId + PURSE_NAME,balanceFee);
// }
//}

View File

@ -0,0 +1,112 @@
package com.ruoyi.mybasic.util;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.ruoyi.common.core.domain.R;
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.mapper.MessageMapper;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*/
@Component
public class BankScan {
/** @noinspection SpringJavaInjectionPointsAutowiringInspection*/
@Autowired
private MessageMapper messageMapper;
@Autowired
private UploadUtil uploadUtil;
public String BankScan(MultipartFile file){
OutputStream outputStream = null;
//上传文件方法
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);
System.out.println(bodys);
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:"+response.toString());
String string = EntityUtils.toString(response.getEntity());
JSONObject jsonObject = JSONObject.parseObject(string);
//获取response的body
// JSONObject jsonObject = JSONObject.parseObject(EntityUtils.toString(response.getEntity()));
System.out.println("jsonObject数据为:" + jsonObject);
bodys.clear();//用于清空bodys路径数据
System.out.println("上一个路径 数据清空");
BankConfig bankConfig = new BankConfig();
//查询当前人银行卡的当前银行卡 根据银行卡号进行循环查询 是否已经绑定
//转成字符串
BankConfig bankConfig1 = JSONObject.parseObject(jsonObject.getString("data"), BankConfig.class);
//判断银行卡的bankId 是不是唯一
BankConfig bankConfig2 = messageMapper.selectBankId(bankConfig1.getBankId());
if (bankConfig2 != null){
return "已经添加过此银行卡!换一张";
// throw new ServiceException("已经添加过此银行卡!换一张");
}
//存值
bankConfig.setBankCode(bankConfig1.getBankCode());
bankConfig.setCardType(bankConfig1.getCardType());
bankConfig.setCardNo(bankConfig1.getCardNo());
bankConfig.setBankName(bankConfig1.getBankName());
bankConfig.setBankId(bankConfig1.getBankId());
bankConfig.setUserId(SecurityUtils.getUserId());
//绑定银行卡 添加到银行卡表中
messageMapper.addBank(bankConfig);
System.out.println("添加成功");
} catch (Exception e) {
e.printStackTrace();
}
return "成功";
}
}

View File

@ -0,0 +1,317 @@
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);
}
}
}

View File

@ -0,0 +1,159 @@
package com.ruoyi.mybasic.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.mybasic.common.domain.response.ResponseCard;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Lou_Zs
*/
@Component
public class SdkCardUtils {
public String img_base64(String path) {
/**
* pathbase64url,
*/
String imgBase64="";
if (path.startsWith("http")){
imgBase64 = path;
}else {
try {
File file = new File(path);
byte[] content = new byte[(int) file.length()];
FileInputStream finputstream = new FileInputStream(file);
finputstream.read(content);
finputstream.close();
imgBase64 = new String(Base64.encodeBase64(content));
} catch (IOException e) {
e.printStackTrace();
return imgBase64;
}
}
return imgBase64;
}
public ResponseCard cardFace(String file) {
String host = "https://cardnumber.market.alicloudapi.com";
String path = "/rest/160601/ocr/ocr_idcard.json";
String appcode = "6b430f0ea246474c9245b8b35388f7a9";
String imgFile = file;
String method = "POST";
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/json; charset=UTF-8");
Map<String, String> querys = new HashMap<String, String>();
// 对图像进行base64编码
String imgBase64 = img_base64(imgFile);
//configure配置
JSONObject configObj = new JSONObject();
configObj.put("side", "face");
String config_str = configObj.toString();
// 拼装请求body的json字符串
JSONObject requestObj = new JSONObject();
requestObj.put("image", imgBase64);
if(configObj.size() > 0) {
requestObj.put("configure", config_str);
}
String bodys = requestObj.toString();
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);
int stat = response.getStatusLine().getStatusCode();
if(stat != 200){
System.out.println("Http code: " + stat);
System.out.println("http header error msg: "+ response.getFirstHeader("X-Ca-Error-Message"));
System.out.println("Http body error msg:" + EntityUtils.toString(response.getEntity()));
}
String res = EntityUtils.toString(response.getEntity());
ResponseCard responseCard = JSON.parseObject(res, ResponseCard.class);
return responseCard;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public ResponseCard cardBack(String file) {
String host = "https://cardnumber.market.alicloudapi.com";
String path = "/rest/160601/ocr/ocr_idcard.json";
String appcode = "6b430f0ea246474c9245b8b35388f7a9";
String imgFile = file;
String method = "POST";
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/json; charset=UTF-8");
Map<String, String> querys = new HashMap<String, String>();
// 对图像进行base64编码
String imgBase64 = img_base64(imgFile);
//configure配置
JSONObject configObj = new JSONObject();
configObj.put("side", "back");
String config_str = configObj.toString();
// 拼装请求body的json字符串
JSONObject requestObj = new JSONObject();
requestObj.put("image", imgBase64);
if(configObj.size() > 0) {
requestObj.put("configure", config_str);
}
String bodys = requestObj.toString();
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);
int stat = response.getStatusLine().getStatusCode();
if(stat != 200){
System.out.println("Http code: " + stat);
System.out.println("http header error msg: "+ response.getFirstHeader("X-Ca-Error-Message"));
System.out.println("Http body error msg:" + EntityUtils.toString(response.getEntity()));
}
String res = EntityUtils.toString(response.getEntity());
ResponseCard responseCard = JSON.parseObject(res, ResponseCard.class);
return responseCard;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -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;
}
}

View File

@ -1,12 +1,17 @@
# Tomcat
server:
port: 9090
port: 9001
# Spring
spring:
servlet:
multipart:
max-file-size: 100MB
max-request-size: 128MB
application:
# 应用名称
name: health-mybasicTwo
name: health-mybasic
profiles:
# 环境配置
active: dev
@ -36,6 +41,19 @@ spring:
alipay.notifyUrl: http://vhzkca.natappfree.cc/alipay/notify
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.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=

View File

@ -0,0 +1,46 @@
<?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.CardMapper">
<insert id="insertUserCard">
INSERT INTO
t_card (
user_id,
card_face,
card_back,
num,
name,
address,
sex,
birth,
nationality,
start_date,
end_date,
issue,
create_time)
VALUES
(
#{userId},
#{cardFace},
#{cardBack},
#{num},
#{name},
#{address},
#{sex},
#{birth},
#{nationality},
#{startDate},
#{endDate},
#{issue},
#{createTime}
)
</insert>
<select id="findUserCard" resultType="com.ruoyi.mybasic.common.domain.Card">
select * from t_card where user_id = #{userId}
</select>
</mapper>

View File

@ -2,29 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mybasic.mapper.InvitationMapper">
<select id="show" resultType="com.ruoyi.mybasic.common.domain.request.InvitationRecordRequest">
</select>
<select id="Inviteramount" resultType="com.ruoyi.mybasic.common.domain.request.PurseRequest">
SELECT
ir.inviter_id AS 邀请人,
ir.invitee_id AS 被邀请人
FROM
invitation_record ir
LEFT JOIN t_user USER ON ir.inviter_id = USER.id
</select>
<select id="Inviteeamount" resultType="com.ruoyi.mybasic.common.domain.request.PurseRequest">
SELECT
ir.inviter_id AS 邀请人,
ir.invitee_id AS 被邀请人
FROM
invitation_record ir
LEFT JOIN t_user USER ON ir.inviter_id = USER.id
</select>
<!-- 新增邀请记录-->
<insert id="insertInvitationRecord">
INSERT INTO invitation_record

View File

@ -0,0 +1,59 @@
<?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_bankTwo
(
<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="selectBankId" resultType="com.ruoyi.mybasic.common.domain.BankConfig">
select * from t_bankTwo where bank_id = #{bankId}
</select>
</mapper>

View File

@ -2,9 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mybasic.mapper.PurseMapperTwo">
<select id="purseObject" resultType="com.ruoyi.mybasic.common.domain.response.PurseResponse">
select * from t_purse where user_id = #{userId}
</select>
<insert id="addPurse">
insert into t_purse
@ -101,15 +99,11 @@
</select>
<update id="updPurseHBi">
update t_purse set balance_fee = (#{amount} * 100) where user_id = #{userId}
</update>
<select id="purseListAll" resultType="com.ruoyi.mybasic.common.domain.request.PurseRequest">
select * from t_purse
<select id="purseObject" resultType="com.ruoyi.mybasic.api.domain.Purse">
select * from t_purse where user_id = #{userId}
</select>
<!-- 添加充值收入支出记录表-->
<!-- 添加充值收入支出记录表-->
<insert id="addPurseLogs">
insert into t_money_logs
(