Pre Merge pull request !380 from 鲸落/master_zhp

This commit is contained in:
鲸落
2024-10-11 09:33:55 +00:00
committed by Gitee
160 changed files with 13236 additions and 2919 deletions

View File

@@ -13,6 +13,7 @@
<module>ruoyi-gen</module>
<module>ruoyi-job</module>
<module>ruoyi-file</module>
<module>ruoyi-btc</module>
</modules>
<artifactId>ruoyi-modules</artifactId>

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-modules</artifactId>
<version>3.6.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ruoyi-modules-btc</artifactId>
<description>
ruoyi-modules-btc三方业务服务
</description>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- SpringBoot Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- RuoYi Api System -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-api-system</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-redis</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-security</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,22 @@
package com.ruoyi.btc;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
* 三方调用服务
*
* @author ruoyi
*/
@EnableRyFeignClients
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
public class RuoYiBtcApplication
{
public static void main(String[] args)
{
SpringApplication.run(RuoYiBtcApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 三方业务服务模块启动成功 ლ(´ڡ`ლ)゙ \n");
}
}

View File

@@ -0,0 +1,16 @@
package com.ruoyi.btc.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "system")
@Data
public class Config {
/**
* 加密密钥
*/
private String AESkey;
}

View File

@@ -0,0 +1,43 @@
package com.ruoyi.btc.controller;
import com.ruoyi.btc.domain.ComPublicHalfDto;
import com.ruoyi.btc.service.ISysPublicAllService;
import com.ruoyi.btc.service.ISysPublicHalfService;
import com.ruoyi.common.core.web.domain.AjaxResult;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
/**
* 半流程API接口写这里
*
* @author z
*/
@RestController
@Slf4j
@RequestMapping("/all/api")
@RequiredArgsConstructor
public class PublicAllController {
private final ISysPublicAllService sysPublicAllService;
/**
* 通用半流程撞库
*/
@PostMapping("check")
public AjaxResult upload(@RequestBody ComPublicHalfDto comPublicHalfDto)
{
sysPublicAllService.check(comPublicHalfDto);
return null;
}
/**
* 通用半流程撞库
*/
@PostMapping("input")
public AjaxResult input(@RequestBody ComPublicHalfDto comPublicHalfDto)
{
sysPublicAllService.input(comPublicHalfDto);
return null;
}
}

View File

@@ -0,0 +1,50 @@
package com.ruoyi.btc.controller;
import com.ruoyi.btc.domain.ComPublicHalfDto;
import com.ruoyi.btc.service.ISysPublicHalfService;
import com.ruoyi.common.core.web.domain.AjaxResult;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
/**
* 半流程API接口写这里
*
* @author z
*/
@RestController
@Slf4j
@RequestMapping("/half/api")
@RequiredArgsConstructor
public class PublicHalfController{
private final ISysPublicHalfService sysPublicHalfService;
/**
* 通用半流程撞库
*/
@PostMapping("/check")
public AjaxResult upload(@RequestBody ComPublicHalfDto comPublicHalfDto)
{
return sysPublicHalfService.check(comPublicHalfDto);
}
/**
* 通用半流程撞库
*/
@PostMapping("/input")
public AjaxResult input(@RequestBody ComPublicHalfDto comPublicHalfDto)
{
return sysPublicHalfService.input(comPublicHalfDto);
}
/**
* 通用半流程撞库
*/
@GetMapping("/checkOrder")
public AjaxResult checkOrder(String phoneMd5,String channelSign)
{
return sysPublicHalfService.checkOrder(phoneMd5,channelSign);
}
}

View File

@@ -0,0 +1,13 @@
package com.ruoyi.btc.domain;
import lombok.Data;
@Data
public class ComPublicHalfDto {
//参数实体类
private String data;
//渠道标识
private String channelSignature;
}

View File

@@ -0,0 +1,51 @@
package com.ruoyi.btc.domain;
import lombok.Data;
@Data
public class CustomerInfoDto {
//手机号码Md5
private String phoneMd5;
//手机号
private String phone;
//性别 0 男 1 女
private Integer sex;
//手机号码Md5
private String nameMd5;
//姓名
private String name;
//年龄
private Integer age;
//手身份证md5
private String idCardMd5;
//身份证好
private String idCard;
//所在城市
private String city;
//所在城市代码
private Integer cityCode;
//本地社保
private Integer socialSecurity;
//本地公积金
private Integer accumulationFund;
//名下车产
private Integer car;
//名下房产
private Integer hourse;
//个人保险
private Integer guarantee;
//芝麻分
private Integer zhiMa;
//职业身份
private Integer career;
//信用卡1无 2有
private Integer creditCard;
//学历
private Integer education;
//月收入
private Integer monthlyIncome;
//ip地址
private String ip;
//渠道标识
private String channelSignature;
}

View File

@@ -0,0 +1,27 @@
package com.ruoyi.btc.service;
import com.ruoyi.btc.domain.ComPublicHalfDto;
import com.ruoyi.common.core.web.domain.AjaxResult;
/**
* 文件上传接口
*
* @author ruoyi
*/
public interface ISysPublicAllService
{
/**
* 半流程通用撞库接口
* @param comPublicHalfDto
*/
AjaxResult check(ComPublicHalfDto comPublicHalfDto);
/**
* 半流程通用进件
* @param comPublicHalfDto
*/
AjaxResult input(ComPublicHalfDto comPublicHalfDto);
}

View File

@@ -0,0 +1,33 @@
package com.ruoyi.btc.service;
import com.ruoyi.btc.domain.ComPublicHalfDto;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 文件上传接口
*
* @author ruoyi
*/
public interface ISysPublicHalfService
{
/**
* 半流程通用撞库接口
* @param comPublicHalfDto
*/
AjaxResult check(ComPublicHalfDto comPublicHalfDto);
/**
* 半流程通用进件
* @param comPublicHalfDto
*/
AjaxResult input(ComPublicHalfDto comPublicHalfDto);
/**
* 渠道查询订单是否成功
* @param
*/
AjaxResult checkOrder(String phoneMd5, String channelSign);
}

View File

@@ -0,0 +1,251 @@
package com.ruoyi.btc.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.btc.domain.ComPublicHalfDto;
import com.ruoyi.btc.domain.CustomerInfoDto;
import com.ruoyi.btc.service.ISysPublicAllService;
import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.GetSumDto;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.http.Channel;
import com.ruoyi.common.core.domain.http.Customer;
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
import com.ruoyi.common.core.domain.http.Merchant;
import com.ruoyi.common.core.utils.SecureUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.system.api.RemoteCustomerApplyLogService;
import com.ruoyi.system.api.RemoteCustomerService;
import com.ruoyi.system.api.RemoteMerchantService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* 本地文件存储
*
* @author ruoyi
*/
@Service
@RequiredArgsConstructor
public class SysPublicAllServiceImpl implements ISysPublicAllService
{
private final RemoteCustomerService remoteCustomerService;
private final RemoteMerchantService remoteMerchantService;
private final RemoteCustomerApplyLogService remoteCustomerApplyLogService;
private final RedisService redisService;
/**
* 半流程通用撞库
* @param comPublicHalfDto
*/
@Override
public AjaxResult check(ComPublicHalfDto comPublicHalfDto) {
//校验 IP地址是否正常 渠道标识是否存在 数据是否为空
if (StringUtils.isEmpty(comPublicHalfDto.getChannelSignature())){
return AjaxResult.error("渠道标识不能未空");
}
Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN + comPublicHalfDto.getChannelSignature());
if (channel==null||channel.getId()==null){
return AjaxResult.error("渠道不存在");
}
if (StringUtils.isEmpty(comPublicHalfDto.getData())){
return AjaxResult.error("加密数据不能为空");
}
//解密为customerInfoDto
String s = SecureUtils.AesUtil.AesDecode(comPublicHalfDto.getData(), comPublicHalfDto.getChannelSignature());
if (s==null){
return AjaxResult.error("解密异常");
}
CustomerInfoDto customerInfoDto = JSONObject.parseObject(s, CustomerInfoDto.class);
//校验数据必传参数是否未传
String checkData = checkData(customerInfoDto);
if (checkData!=null){
return AjaxResult.error(checkData);
}
//转化字段未数据库中资质字段 并保存 用户未实名状态 一并保存用户申请记录 未申请状态
Customer customer = new Customer();
BeanUtil.copyProperties(customerInfoDto,customer);
customer.setChannelId(channel.getId());
customer.setActurlName(customerInfoDto.getNameMd5());
customer.setFirstLoginTime(new Date());
customer.setLastLoginTime(new Date());
customer.setIsAuth(false);
customer.setStatus(2);
R<Customer> customerInfoByPhoneMd5 = remoteCustomerService.getCustomerInfoByPhoneMd5(customerInfoDto.getPhoneMd5(), SecurityConstants.INNER);
if (customerInfoByPhoneMd5.getCode()==200){
remoteCustomerService.updateByPhoneMd5(customer,SecurityConstants.INNER);
}else {
remoteCustomerService.add(customer,SecurityConstants.INNER);
}
//TODO 暂时不做 目前下游暂时不需要 匹配资质 造轮子 返回多个符合的商户
List<Merchant> merchants = matchMerchant(customer);
//结束返回上游结果
Map<String,Boolean> re = new HashMap<>();
if (merchants.size()>0){
re.put("data",true);
return AjaxResult.success(re);
}
re.put("data",false);
return AjaxResult.success(re);
}
/**
* 获取前筛符合的商户
* @param customer
*/
private List<Merchant> matchMerchant(Customer customer) {
R<List<Merchant>> listR = remoteMerchantService.merchantList(SecurityConstants.INNER);
if (listR.getCode()!=200){
return new ArrayList<>();
}
List<Merchant> merchants = new ArrayList<>();
for (Merchant merchant:listR.getData()) {
//限量判定
GetSumDto dto = new GetSumDto();
dto.setMerchantId(merchant.getId());
R<Integer> sum = remoteCustomerApplyLogService.sum(dto, SecurityConstants.INNER);
if (merchant.getLimitType()==1&&merchant.getLimitNum()<=sum.getData()){
continue;
}
if (customer.getAge()<merchant.getAgeLimitStart()||customer.getAge()>merchant.getAgeLimitEnd()){
continue;
}
if (merchant.getChannelLimitType()==1||merchant.getChannelLimitType()==2){
List<Long> list = Arrays.asList(merchant.getChannelLimit().split(",")).stream().map(val->Long.parseLong(val)).collect(Collectors.toList());
if (merchant.getChannelLimitType()==1&& !list.contains(customer.getChannelId())){
continue;
}
if (merchant.getChannelLimitType()==2&& list.contains(customer.getChannelId())){
continue;
}
}
merchants.add(merchant);
}
return merchants;
}
/**
* 校验参数
* @param customerInfoDto
*/
private String checkData(CustomerInfoDto customerInfoDto) {
if (customerInfoDto.getAge()==null){
return "年龄不能为空";
}
if (StringUtils.isEmpty(customerInfoDto.getPhoneMd5())){
return "手机号MD5不能为空";
}
if (StringUtils.isEmpty(customerInfoDto.getCity())){
return "城市不能为空";
}
if (customerInfoDto.getCityCode()==null){
return "城市编码不能为空";
}
if (customerInfoDto.getSocialSecurity()==null){
return "本地社保不能为空";
}
if (customerInfoDto.getAccumulationFund()==null){
return "本地公积金不能为空";
}
if (customerInfoDto.getCar()==null){
return "车产不能为空";
}
if (customerInfoDto.getHourse()==null){
return "房产不能为空";
}
if (customerInfoDto.getGuarantee()==null){
return "房产不能为空";
}
if (customerInfoDto.getZhiMa()==null){
return "芝麻分不能为空";
}
if (customerInfoDto.getCareer()==null){
return "职业不能为空";
}
if (customerInfoDto.getCreditCard()==null){
return "信用卡不能为空";
}
if (customerInfoDto.getEducation()==null){
return "学历不能为空";
}
if (customerInfoDto.getMonthlyIncome()==null){
return "月收入不能为空";
}
return null;
}
/**
* 半流程通用进件
* @param comPublicHalfDto
*/
@Override
public AjaxResult input(ComPublicHalfDto comPublicHalfDto) {
//校验 IP地址是否正常 渠道标识是否存在 数据是否为空
if (StringUtils.isEmpty(comPublicHalfDto.getChannelSignature())){
return AjaxResult.error("渠道标识不能未空");
}
Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN + comPublicHalfDto.getChannelSignature());
if (channel==null||channel.getId()==null){
return AjaxResult.error("渠道不存在");
}
if (StringUtils.isEmpty(comPublicHalfDto.getData())){
return AjaxResult.error("加密数据不能为空");
}
//解密为customerInfoDto
String s = SecureUtils.AesUtil.AesDecode(comPublicHalfDto.getData(), comPublicHalfDto.getChannelSignature());
if (s==null){
return AjaxResult.error("解密异常");
}
CustomerInfoDto customerInfoDto = JSONObject.parseObject(s, CustomerInfoDto.class);
//校验数据必传参数是否未传
String checkData = checkData(customerInfoDto);
//转化字段未数据库中资质字段 更新 用户实名状态 一并保存用户申请记录 已申请
if (checkData!=null){
return AjaxResult.error(checkData);
}
//转化字段未数据库中资质字段 并保存 用户未实名状态 一并保存用户申请记录 未申请状态
Customer customer = new Customer();
BeanUtil.copyProperties(customerInfoDto,customer);
customer.setChannelId(channel.getId());
customer.setActurlName(customerInfoDto.getName());
customer.setFirstLoginTime(new Date());
customer.setLastLoginTime(new Date());
customer.setIsAuth(true);
customer.setStatus(1);
R<Customer> customerInfoByPhoneMd5 = remoteCustomerService.getCustomerInfoByPhoneMd5(customerInfoDto.getPhoneMd5(), SecurityConstants.INNER);
if (customerInfoByPhoneMd5.getCode()==200){
remoteCustomerService.updateByPhoneMd5(customer,SecurityConstants.INNER);
}else {
return AjaxResult.error("今日未撞库");
}
//匹配资质 造轮子 返回多个符合的商户
List<Merchant> merchants = matchMerchant(customer);
//TODO 取排序第一的
//返回渠道绑定的注册页拼接token
Map<String,Object> result = new HashMap<>();
Map<String,Object> map = new HashMap<>();
//TODO 下游是H5承接不了上游全流程 暂时不做
CustomerApplyLog customerApplyLog = new CustomerApplyLog();
customerApplyLog.setCustomerId(customerInfoByPhoneMd5.getData().getId());
customerApplyLog.setChannelId(channel.getId());
customerApplyLog.setMerchantId(merchants.get(0).getId());
customerApplyLog.setOrderStatus(0l);
remoteCustomerApplyLogService.add(customerApplyLog);
//返回上游信息
return AjaxResult.success(result);
}
}

View File

@@ -0,0 +1,328 @@
package com.ruoyi.btc.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.btc.config.Config;
import com.ruoyi.btc.domain.ComPublicHalfDto;
import com.ruoyi.btc.domain.CustomerInfoDto;
import com.ruoyi.btc.service.ISysPublicHalfService;
import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.core.constant.RedisConstant;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.GetSumDto;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.http.Channel;
import com.ruoyi.common.core.domain.http.Customer;
import com.ruoyi.common.core.domain.http.Merchant;
import com.ruoyi.common.core.utils.EncryptUtil;
import com.ruoyi.common.core.utils.ProbitUtil;
import com.ruoyi.common.core.utils.SecureUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.system.api.RemoteCustomerApplyLogService;
import com.ruoyi.system.api.RemoteCustomerService;
import com.ruoyi.system.api.RemoteMerchantService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* 本地文件存储
*
* @author ruoyi
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class SysPublicHalfServiceImpl implements ISysPublicHalfService
{
private final RemoteCustomerService remoteCustomerService;
private final RemoteMerchantService remoteMerchantService;
private final RemoteCustomerApplyLogService remoteCustomerApplyLogService;
private final RedisService redisService;
private final Config config;
/**
* 半流程通用撞库
* @param comPublicHalfDto
*/
@Override
public AjaxResult check(ComPublicHalfDto comPublicHalfDto) {
//校验 IP地址是否正常 渠道标识是否存在 数据是否为空
if (StringUtils.isEmpty(comPublicHalfDto.getChannelSignature())){
return AjaxResult.error("渠道标识不能未空");
}
Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN + comPublicHalfDto.getChannelSignature());
if (channel==null||channel.getId()==null){
return AjaxResult.error("渠道不存在");
}
if (StringUtils.isEmpty(comPublicHalfDto.getData())){
return AjaxResult.error("加密数据不能为空");
}
//解密为customerInfoDto
String s = SecureUtils.AesUtil.AesDecode(comPublicHalfDto.getData(), comPublicHalfDto.getChannelSignature());
if (s==null){
return AjaxResult.error("解密异常");
}
CustomerInfoDto customerInfoDto = JSONObject.parseObject(s, CustomerInfoDto.class);
//撞库幂等性校验 暂时不加
// Boolean aBoolean = redisService.hasKey(RedisConstant.HIT_CHECK_CACHE+customerInfoDto.getPhoneMd5()+":"+comPublicHalfDto.getChannelSignature());
// if (aBoolean){
// return AjaxResult.error("手机号:"+customerInfoDto.getPhoneMd5()+"请勿重复撞库");
// }
// redisService.setCacheObject(RedisConstant.HIT_CHECK_CACHE+customerInfoDto.getPhoneMd5(),1,60*3l, TimeUnit.SECONDS);
log.info("渠道:{},撞库手机号:{}",channel.getChannelName(),customerInfoDto.getPhoneMd5());
//校验数据必传参数是否未传
String checkData = checkData(customerInfoDto);
if (checkData!=null){
return AjaxResult.error(checkData);
}
//转化字段未数据库中资质字段 并保存 用户未实名状态 一并保存用户申请记录 未申请状态
Customer customer = new Customer();
BeanUtil.copyProperties(customerInfoDto,customer);
customer.setChannelId(channel.getId());
customer.setActurlName(customerInfoDto.getNameMd5());
customer.setFirstLoginTime(new Date());
customer.setLastLoginTime(new Date());
customer.setIsAuth(false);
customer.setStatus(2);
customer.setPhoneMd5(customerInfoDto.getPhoneMd5());
R<Customer> customerInfoByPhoneMd5 = remoteCustomerService.getCustomerInfoByPhoneMd5(customerInfoDto.getPhoneMd5(), SecurityConstants.INNER);
log.info("渠道:{},是否查询到用户:{}",channel.getChannelName(),customerInfoByPhoneMd5.getCode());
if (customerInfoByPhoneMd5.getCode()==200){
remoteCustomerService.updateByPhoneMd5(customer,SecurityConstants.INNER);
}else {
remoteCustomerService.add(customer,SecurityConstants.INNER);
}
//TODO 暂时不做 目前下游暂时不需要 匹配资质 造轮子 返回多个符合的商户
List<Merchant> merchants = matchMerchant(customer);
//结束返回上游结果
Map<String,Boolean> re = new HashMap<>();
if (merchants.size()>0){
re.put("data",true);
return AjaxResult.success(re);
}
re.put("data",false);
return AjaxResult.success(re);
}
/**
* 获取前筛符合的商户
* @param customer
*/
private List<Merchant> matchMerchant(Customer customer) {
R<List<Merchant>> listR = remoteMerchantService.merchantList(SecurityConstants.INNER);
if (listR.getCode()!=200){
return new ArrayList<>();
}
List<Merchant> merchants = new ArrayList<>();
for (Merchant merchant:listR.getData()) {
//限量判定
GetSumDto dto = new GetSumDto();
dto.setMerchantId(merchant.getId());
R<Integer> sum = remoteCustomerApplyLogService.sum(dto, SecurityConstants.INNER);
if (merchant.getLimitType()==1&&merchant.getLimitNum()<=sum.getData()){
continue;
}
if (customer.getAge()<merchant.getAgeLimitStart()||customer.getAge()>merchant.getAgeLimitEnd()){
continue;
}
if (merchant.getChannelLimitType()==1||merchant.getChannelLimitType()==2){
List<Long> list = Arrays.asList(merchant.getChannelLimit().split(",")).stream().map(val->Long.parseLong(val)).collect(Collectors.toList());
if (merchant.getChannelLimitType()==1&& !list.contains(customer.getChannelId())){
continue;
}
if (merchant.getChannelLimitType()==2&& list.contains(customer.getChannelId())){
continue;
}
}
merchants.add(merchant);
}
return merchants;
}
/**
* 校验参数
* @param customerInfoDto
*/
private String checkData(CustomerInfoDto customerInfoDto) {
if (customerInfoDto.getAge()==null){
return "年龄不能为空";
}
if (StringUtils.isEmpty(customerInfoDto.getPhoneMd5())){
return "手机号MD5不能为空";
}
if (StringUtils.isEmpty(customerInfoDto.getCity())){
return "城市不能为空";
}
if (customerInfoDto.getCityCode()==null){
return "城市编码不能为空";
}
if (customerInfoDto.getSocialSecurity()==null){
return "本地社保不能为空";
}
if (customerInfoDto.getAccumulationFund()==null){
return "本地公积金不能为空";
}
if (customerInfoDto.getCar()==null){
return "车产不能为空";
}
if (customerInfoDto.getHourse()==null){
return "房产不能为空";
}
if (customerInfoDto.getGuarantee()==null){
return "房产不能为空";
}
if (customerInfoDto.getZhiMa()==null){
return "芝麻分不能为空";
}
if (customerInfoDto.getCareer()==null){
return "职业不能为空";
}
if (customerInfoDto.getCreditCard()==null){
return "信用卡不能为空";
}
if (customerInfoDto.getEducation()==null){
return "学历不能为空";
}
if (customerInfoDto.getMonthlyIncome()==null){
return "月收入不能为空";
}
return null;
}
/**
* 半流程通用进件
* @param comPublicHalfDto
*/
@Override
public AjaxResult input(ComPublicHalfDto comPublicHalfDto) {
//校验 IP地址是否正常 渠道标识是否存在 数据是否为空
if (StringUtils.isEmpty(comPublicHalfDto.getChannelSignature())){
return AjaxResult.error("渠道标识不能未空");
}
Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN + comPublicHalfDto.getChannelSignature());
if (channel==null||channel.getId()==null){
return AjaxResult.error("渠道不存在");
}
if (StringUtils.isEmpty(comPublicHalfDto.getData())){
return AjaxResult.error("加密数据不能为空");
}
//解密为customerInfoDto
String s = SecureUtils.AesUtil.AesDecode(comPublicHalfDto.getData(), comPublicHalfDto.getChannelSignature());
if (s==null){
return AjaxResult.error("解密异常");
}
CustomerInfoDto customerInfoDto = JSONObject.parseObject(s, CustomerInfoDto.class);
log.info("渠道:{},进件手机号:{}",channel.getChannelName(),customerInfoDto.getPhone());
//校验数据必传参数是否未传
String checkData = checkData(customerInfoDto);
//转化字段未数据库中资质字段 更新 用户实名状态 一并保存用户申请记录 已申请
if (checkData!=null){
return AjaxResult.error(checkData);
}
//转化字段未数据库中资质字段 并保存 用户未实名状态 一并保存用户申请记录 未申请状态
Customer customer = new Customer();
BeanUtil.copyProperties(customerInfoDto,customer);
customer.setChannelId(channel.getId());
customer.setActurlName(customerInfoDto.getName());
customer.setFirstLoginTime(new Date());
customer.setLastLoginTime(new Date());
customer.setIsAuth(true);
customer.setStatus(1);
R<Customer> customerInfoByPhoneMd5 = remoteCustomerService.getCustomerInfoByPhoneMd5(customerInfoDto.getPhoneMd5(), SecurityConstants.INNER);
if (customerInfoByPhoneMd5.getCode()==200){
customer.setPhone(EncryptUtil.AESencode(customer.getPhone(), config.getAESkey()));
customer.setIdCard(EncryptUtil.AESencode(customer.getIdCard(),config.getAESkey()));
customer.setActurlName(EncryptUtil.AESencode(customer.getActurlName(),config.getAESkey()));
remoteCustomerService.updateByPhoneMd5(customer,SecurityConstants.INNER);
}else {
remoteCustomerService.add(customer,SecurityConstants.INNER);
}
//匹配资质 造轮子 返回多个符合的商户
List<Merchant> merchants = matchMerchant(customer);
//TODO 取排序第一的
//返回渠道绑定的注册页拼接token
Map<String,Object> result = new HashMap<>();
Map<String,Object> map = new HashMap<>();
if (CollectionUtil.isEmpty(merchants)){
map.put("url","");
map.put("regist",false);
result.put("data",map);
return AjaxResult.success(result);
}
String url = channel.getHtmlLocation()+"?sign="+channel.getChannelSign() + "&token="+remoteCustomerService.getCustomerToken(customer.getPhone(),channel.getId() );
map.put("url",url);
map.put("regist",true);
result.put("data",map);
//CustomerApplyLog customerApplyLog = new CustomerApplyLog();
// customerApplyLog.setCustomerId(customerInfoByPhoneMd5.getData().getId());
// customerApplyLog.setChannelId(channel.getId());
// customerApplyLog.setOrderStatus(0l);
//+"&orderNo="+ LocalDateTimeUtils.getStringFromLocalDateTime()
//remoteCustomerApplyLogService.add(customerApplyLog);
//返回上游信息
return AjaxResult.success(result);
}
/**
* 渠道查询订单是否成功
* @param comPublicHalfDto
*/
@Override
public AjaxResult checkOrder(String phoneMd5, String channelSign) {
//根据手机号MD5渠道标识 查询是否成功
R<Customer> customerInfoByPhoneMd5 = remoteCustomerService.getCustomerInfoByPhoneMd5(phoneMd5, SecurityConstants.INNER);
Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_ID + customerInfoByPhoneMd5.getData().getChannelId());
R<Boolean> booleanR = remoteCustomerApplyLogService.customerApply(customerInfoByPhoneMd5.getData().getId(), SecurityConstants.INNER);
//失败直接失败
if (!booleanR.getData()){
return AjaxResult.success("用户未申请","false");
}
//成功抽奖 按扣量比抽
//成功数
double succ = channel.getScore()*0.01;
//扣量数
double socre = 1-(channel.getScore()*0.01);
List<Double> drow = new ArrayList<>();
drow.add(succ);
drow.add(socre);
int draw = ProbitUtil.draw(drow);
//返回是否成功
return draw==0?AjaxResult.success("用户已申请",true):AjaxResult.success("用户未申请","false");
}
public static void main(String[] args) {
CustomerInfoDto customerInfoDto = new CustomerInfoDto();
customerInfoDto.setPhoneMd5("331d17d1ca8a091410e3238fab16a863");
customerInfoDto.setPhone("15205600635");
customerInfoDto.setSex(0);
customerInfoDto.setNameMd5("331d17d1ca8a091410e3238fab16a863");
customerInfoDto.setName("朱三");
customerInfoDto.setAge(18);
customerInfoDto.setIdCardMd5("331d17d1ca8a091410e3238fab16a863");
customerInfoDto.setIdCard("341202199306023511");
customerInfoDto.setCity("重庆");
customerInfoDto.setCityCode(1000);
customerInfoDto.setSocialSecurity(1);
customerInfoDto.setAccumulationFund(1);
customerInfoDto.setCar(1);
customerInfoDto.setHourse(1);
customerInfoDto.setGuarantee(1);
customerInfoDto.setZhiMa(600);
customerInfoDto.setCareer(1);
customerInfoDto.setCreditCard(1);
customerInfoDto.setEducation(1);
customerInfoDto.setMonthlyIncome(5000);
System.out.println(JSONObject.toJSONString(customerInfoDto));
}
}

View File

@@ -0,0 +1,10 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ __ _ _
(_) / _|(_)| |
_ __ _ _ ___ _ _ _ ______ | |_ _ | | ___
| '__|| | | | / _ \ | | | || ||______|| _|| || | / _ \
| | | |_| || (_) || |_| || | | | | || || __/
|_| \__,_| \___/ \__, ||_| |_| |_||_| \___|
__/ |
|___/

View File

@@ -0,0 +1,27 @@
# Tomcat
server:
port: 9301
# Spring
spring:
application:
# 应用名称
name: ruoyi-btc
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 47.109.135.151:8848
namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a
config:
# 配置中心地址
server-addr: 47.109.135.151:8848
namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/ruoyi-file" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>

View File

@@ -15,15 +15,6 @@ public class RuoYiFileApplication
public static void main(String[] args)
{
SpringApplication.run(RuoYiFileApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 文件服务模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
System.out.println("(♥◠‿◠)ノ゙ 文件服务模块启动成功 ლ(´ڡ`ლ)゙ \n");
}
}

View File

@@ -1,82 +1,82 @@
package com.ruoyi.file.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.minio.MinioClient;
/**
* Minio 配置信息
*
* @author ruoyi
*/
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioConfig
{
/**
* 服务地址
*/
private String url;
/**
* 用户名
*/
private String accessKey;
/**
* 密码
*/
private String secretKey;
/**
* 存储桶名称
*/
private String bucketName;
public String getUrl()
{
return url;
}
public void setUrl(String url)
{
this.url = url;
}
public String getAccessKey()
{
return accessKey;
}
public void setAccessKey(String accessKey)
{
this.accessKey = accessKey;
}
public String getSecretKey()
{
return secretKey;
}
public void setSecretKey(String secretKey)
{
this.secretKey = secretKey;
}
public String getBucketName()
{
return bucketName;
}
public void setBucketName(String bucketName)
{
this.bucketName = bucketName;
}
@Bean
public MinioClient getMinioClient()
{
return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build();
}
}
package com.ruoyi.file.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.minio.MinioClient;
/**
* Minio 配置信息
*
* @author ruoyi
*/
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioConfig
{
/**
* 服务地址
*/
private String url;
/**
* 用户名
*/
private String accessKey;
/**
* 密码
*/
private String secretKey;
/**
* 存储桶名称
*/
private String bucketName;
public String getUrl()
{
return url;
}
public void setUrl(String url)
{
this.url = url;
}
public String getAccessKey()
{
return accessKey;
}
public void setAccessKey(String accessKey)
{
this.accessKey = accessKey;
}
public String getSecretKey()
{
return secretKey;
}
public void setSecretKey(String secretKey)
{
this.secretKey = secretKey;
}
public String getBucketName()
{
return bucketName;
}
public void setBucketName(String bucketName)
{
this.bucketName = bucketName;
}
@Bean
public MinioClient getMinioClient()
{
return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build();
}
}

View File

@@ -1,50 +1,50 @@
package com.ruoyi.file.config;
import java.io.File;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* 通用映射配置
*
* @author ruoyi
*/
@Configuration
public class ResourcesConfig implements WebMvcConfigurer
{
/**
* 上传文件存储在本地的根路径
*/
@Value("${file.path}")
private String localFilePath;
/**
* 资源映射路径 前缀
*/
@Value("${file.prefix}")
public String localFilePrefix;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
/** 本地文件上传路径 */
registry.addResourceHandler(localFilePrefix + "/**")
.addResourceLocations("file:" + localFilePath + File.separator);
}
/**
* 开启跨域
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
// 设置允许跨域的路由
registry.addMapping(localFilePrefix + "/**")
// 设置允许跨域请求的域名
.allowedOrigins("*")
// 设置允许的方法
.allowedMethods("GET");
}
package com.ruoyi.file.config;
import java.io.File;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* 通用映射配置
*
* @author ruoyi
*/
@Configuration
public class ResourcesConfig implements WebMvcConfigurer
{
/**
* 上传文件存储在本地的根路径
*/
@Value("${file.path}")
private String localFilePath;
/**
* 资源映射路径 前缀
*/
@Value("${file.prefix}")
public String localFilePrefix;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
/** 本地文件上传路径 */
registry.addResourceHandler(localFilePrefix + "/**")
.addResourceLocations("file:" + localFilePath + File.separator);
}
/**
* 开启跨域
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
// 设置允许跨域的路由
registry.addMapping(localFilePrefix + "/**")
// 设置允许跨域请求的域名
.allowedOrigins("*")
// 设置允许的方法
.allowedMethods("GET");
}
}

View File

@@ -1,48 +1,48 @@
package com.ruoyi.file.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.file.FileUtils;
import com.ruoyi.file.service.ISysFileService;
import com.ruoyi.system.api.domain.SysFile;
/**
* 文件请求处理
*
* @author ruoyi
*/
@RestController
public class SysFileController
{
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
@Autowired
private ISysFileService sysFileService;
/**
* 文件上传请求
*/
@PostMapping("upload")
public R<SysFile> upload(MultipartFile file)
{
try
{
// 上传并返回访问地址
String url = sysFileService.uploadFile(file);
SysFile sysFile = new SysFile();
sysFile.setName(FileUtils.getName(url));
sysFile.setUrl(url);
return R.ok(sysFile);
}
catch (Exception e)
{
log.error("上传文件失败", e);
return R.fail(e.getMessage());
}
}
package com.ruoyi.file.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.file.FileUtils;
import com.ruoyi.file.service.ISysFileService;
import com.ruoyi.system.api.domain.SysFile;
/**
* 文件请求处理
*
* @author ruoyi
*/
@RestController
public class SysFileController
{
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
@Autowired
private ISysFileService sysFileService;
/**
* 文件上传请求
*/
@PostMapping("upload")
public R<SysFile> upload(MultipartFile file)
{
try
{
// 上传并返回访问地址
String url = sysFileService.uploadFile(file);
SysFile sysFile = new SysFile();
sysFile.setName(FileUtils.getName(url));
sysFile.setUrl(url);
return R.ok(sysFile);
}
catch (Exception e)
{
log.error("上传文件失败", e);
return R.fail(e.getMessage());
}
}
}

View File

@@ -1,46 +1,46 @@
package com.ruoyi.file.service;
import java.io.InputStream;
import com.alibaba.nacos.common.utils.IoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import com.ruoyi.common.core.utils.file.FileTypeUtils;
/**
* FastDFS 文件存储
*
* @author ruoyi
*/
@Service
public class FastDfsSysFileServiceImpl implements ISysFileService
{
/**
* 域名或本机访问地址
*/
@Value("${fdfs.domain}")
public String domain;
@Autowired
private FastFileStorageClient storageClient;
/**
* FastDfs文件上传接口
*
* @param file 上传的文件
* @return 访问地址
* @throws Exception
*/
@Override
public String uploadFile(MultipartFile file) throws Exception
{
InputStream inputStream = file.getInputStream();
StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(),
FileTypeUtils.getExtension(file), null);
IoUtils.closeQuietly(inputStream);
return domain + "/" + storePath.getFullPath();
}
}
package com.ruoyi.file.service;
import java.io.InputStream;
import com.alibaba.nacos.common.utils.IoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import com.ruoyi.common.core.utils.file.FileTypeUtils;
/**
* FastDFS 文件存储
*
* @author ruoyi
*/
@Service
public class FastDfsSysFileServiceImpl implements ISysFileService
{
/**
* 域名或本机访问地址
*/
@Value("${fdfs.domain}")
public String domain;
@Autowired
private FastFileStorageClient storageClient;
/**
* FastDfs文件上传接口
*
* @param file 上传的文件
* @return 访问地址
* @throws Exception
*/
@Override
public String uploadFile(MultipartFile file) throws Exception
{
InputStream inputStream = file.getInputStream();
StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(),
FileTypeUtils.getExtension(file), null);
IoUtils.closeQuietly(inputStream);
return domain + "/" + storePath.getFullPath();
}
}

View File

@@ -1,20 +1,20 @@
package com.ruoyi.file.service;
import org.springframework.web.multipart.MultipartFile;
/**
* 文件上传接口
*
* @author ruoyi
*/
public interface ISysFileService
{
/**
* 文件上传接口
*
* @param file 上传的文件
* @return 访问地址
* @throws Exception
*/
public String uploadFile(MultipartFile file) throws Exception;
}
package com.ruoyi.file.service;
import org.springframework.web.multipart.MultipartFile;
/**
* 文件上传接口
*
* @author ruoyi
*/
public interface ISysFileService
{
/**
* 文件上传接口
*
* @param file 上传的文件
* @return 访问地址
* @throws Exception
*/
public String uploadFile(MultipartFile file) throws Exception;
}

View File

@@ -1,50 +1,53 @@
package com.ruoyi.file.service;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.file.utils.FileUploadUtils;
/**
* 本地文件存储
*
* @author ruoyi
*/
@Primary
@Service
public class LocalSysFileServiceImpl implements ISysFileService
{
/**
* 资源映射路径 前缀
*/
@Value("${file.prefix}")
public String localFilePrefix;
/**
* 域名或本机访问地址
*/
@Value("${file.domain}")
public String domain;
/**
* 上传文件存储在本地的根路径
*/
@Value("${file.path}")
private String localFilePath;
/**
* 本地文件上传接口
*
* @param file 上传的文件
* @return 访问地址
* @throws Exception
*/
@Override
public String uploadFile(MultipartFile file) throws Exception
{
String name = FileUploadUtils.upload(localFilePath, file);
String url = domain + localFilePrefix + name;
return url;
}
}
package com.ruoyi.file.service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.file.utils.FileUploadUtils;
/**
* 本地文件存储
*
* @author ruoyi
*/
@Primary
@Service
@Slf4j
public class LocalSysFileServiceImpl implements ISysFileService
{
/**
* 资源映射路径 前缀
*/
@Value("${file.prefix}")
public String localFilePrefix;
/**
* 域名或本机访问地址
*/
@Value("${file.domain}")
public String domain;
/**
* 上传文件存储在本地的根路径
*/
@Value("${file.path}")
private String localFilePath;
/**
* 本地文件上传接口
*
* @param file 上传的文件
* @return 访问地址
* @throws Exception
*/
@Override
public String uploadFile(MultipartFile file) throws Exception
{
String name = FileUploadUtils.upload(localFilePath, file);
String url = domain + localFilePrefix + name;
return url;
}
}

View File

@@ -1,49 +1,49 @@
package com.ruoyi.file.service;
import java.io.InputStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.nacos.common.utils.IoUtils;
import com.ruoyi.file.config.MinioConfig;
import com.ruoyi.file.utils.FileUploadUtils;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
/**
* Minio 文件存储
*
* @author ruoyi
*/
@Service
public class MinioSysFileServiceImpl implements ISysFileService
{
@Autowired
private MinioConfig minioConfig;
@Autowired
private MinioClient client;
/**
* Minio文件上传接口
*
* @param file 上传的文件
* @return 访问地址
* @throws Exception
*/
@Override
public String uploadFile(MultipartFile file) throws Exception
{
String fileName = FileUploadUtils.extractFilename(file);
InputStream inputStream = file.getInputStream();
PutObjectArgs args = PutObjectArgs.builder()
.bucket(minioConfig.getBucketName())
.object(fileName)
.stream(inputStream, file.getSize(), -1)
.contentType(file.getContentType())
.build();
client.putObject(args);
IoUtils.closeQuietly(inputStream);
return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName;
}
}
package com.ruoyi.file.service;
import java.io.InputStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.nacos.common.utils.IoUtils;
import com.ruoyi.file.config.MinioConfig;
import com.ruoyi.file.utils.FileUploadUtils;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
/**
* Minio 文件存储
*
* @author ruoyi
*/
@Service
public class MinioSysFileServiceImpl implements ISysFileService
{
@Autowired
private MinioConfig minioConfig;
@Autowired
private MinioClient client;
/**
* Minio文件上传接口
*
* @param file 上传的文件
* @return 访问地址
* @throws Exception
*/
@Override
public String uploadFile(MultipartFile file) throws Exception
{
String fileName = FileUploadUtils.extractFilename(file);
InputStream inputStream = file.getInputStream();
PutObjectArgs args = PutObjectArgs.builder()
.bucket(minioConfig.getBucketName())
.object(fileName)
.stream(inputStream, file.getSize(), -1)
.contentType(file.getContentType())
.build();
client.putObject(args);
IoUtils.closeQuietly(inputStream);
return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName;
}
}

View File

@@ -1,185 +1,185 @@
package com.ruoyi.file.utils;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Objects;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.exception.file.FileException;
import com.ruoyi.common.core.exception.file.FileNameLengthLimitExceededException;
import com.ruoyi.common.core.exception.file.FileSizeLimitExceededException;
import com.ruoyi.common.core.exception.file.InvalidExtensionException;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.file.FileTypeUtils;
import com.ruoyi.common.core.utils.file.MimeTypeUtils;
import com.ruoyi.common.core.utils.uuid.Seq;
/**
* 文件上传工具类
*
* @author ruoyi
*/
public class FileUploadUtils
{
/**
* 默认大小 50M
*/
public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024L;
/**
* 默认的文件名最大长度 100
*/
public static final int DEFAULT_FILE_NAME_LENGTH = 100;
/**
* 根据文件路径上传
*
* @param baseDir 相对应用的基目录
* @param file 上传的文件
* @return 文件名称
* @throws IOException
*/
public static final String upload(String baseDir, MultipartFile file) throws IOException
{
try
{
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
}
catch (FileException fe)
{
throw new IOException(fe.getDefaultMessage(), fe);
}
catch (Exception e)
{
throw new IOException(e.getMessage(), e);
}
}
/**
* 文件上传
*
* @param baseDir 相对应用的基目录
* @param file 上传的文件
* @param allowedExtension 上传文件类型
* @return 返回上传成功的文件名
* @throws FileSizeLimitExceededException 如果超出最大大小
* @throws FileNameLengthLimitExceededException 文件名太长
* @throws IOException 比如读写文件出错时
* @throws InvalidExtensionException 文件校验异常
*/
public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
InvalidExtensionException
{
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
{
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
}
assertAllowed(file, allowedExtension);
String fileName = extractFilename(file);
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
file.transferTo(Paths.get(absPath));
return getPathFileName(fileName);
}
/**
* 编码文件名
*/
public static final String extractFilename(MultipartFile file)
{
return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), FileTypeUtils.getExtension(file));
}
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
{
File desc = new File(uploadDir + File.separator + fileName);
if (!desc.exists())
{
if (!desc.getParentFile().exists())
{
desc.getParentFile().mkdirs();
}
}
return desc.isAbsolute() ? desc : desc.getAbsoluteFile();
}
private static final String getPathFileName(String fileName) throws IOException
{
String pathFileName = "/" + fileName;
return pathFileName;
}
/**
* 文件大小校验
*
* @param file 上传的文件
* @throws FileSizeLimitExceededException 如果超出最大大小
* @throws InvalidExtensionException 文件校验异常
*/
public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, InvalidExtensionException
{
long size = file.getSize();
if (size > DEFAULT_MAX_SIZE)
{
throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
}
String fileName = file.getOriginalFilename();
String extension = FileTypeUtils.getExtension(file);
if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
{
if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
{
throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension,
fileName);
}
else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION)
{
throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension,
fileName);
}
else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION)
{
throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
fileName);
}
else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION)
{
throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension,
fileName);
}
else
{
throw new InvalidExtensionException(allowedExtension, extension, fileName);
}
}
}
/**
* 判断MIME类型是否是允许的MIME类型
*
* @param extension 上传文件类型
* @param allowedExtension 允许上传文件类型
* @return true/false
*/
public static final boolean isAllowedExtension(String extension, String[] allowedExtension)
{
for (String str : allowedExtension)
{
if (str.equalsIgnoreCase(extension))
{
return true;
}
}
return false;
}
package com.ruoyi.file.utils;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Objects;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.exception.file.FileException;
import com.ruoyi.common.core.exception.file.FileNameLengthLimitExceededException;
import com.ruoyi.common.core.exception.file.FileSizeLimitExceededException;
import com.ruoyi.common.core.exception.file.InvalidExtensionException;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.file.FileTypeUtils;
import com.ruoyi.common.core.utils.file.MimeTypeUtils;
import com.ruoyi.common.core.utils.uuid.Seq;
/**
* 文件上传工具类
*
* @author ruoyi
*/
public class FileUploadUtils
{
/**
* 默认大小 50M
*/
public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024L;
/**
* 默认的文件名最大长度 100
*/
public static final int DEFAULT_FILE_NAME_LENGTH = 100;
/**
* 根据文件路径上传
*
* @param baseDir 相对应用的基目录
* @param file 上传的文件
* @return 文件名称
* @throws IOException
*/
public static final String upload(String baseDir, MultipartFile file) throws IOException
{
try
{
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
}
catch (FileException fe)
{
throw new IOException(fe.getDefaultMessage(), fe);
}
catch (Exception e)
{
throw new IOException(e.getMessage(), e);
}
}
/**
* 文件上传
*
* @param baseDir 相对应用的基目录
* @param file 上传的文件
* @param allowedExtension 上传文件类型
* @return 返回上传成功的文件名
* @throws FileSizeLimitExceededException 如果超出最大大小
* @throws FileNameLengthLimitExceededException 文件名太长
* @throws IOException 比如读写文件出错时
* @throws InvalidExtensionException 文件校验异常
*/
public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
InvalidExtensionException
{
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
{
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
}
assertAllowed(file, allowedExtension);
String fileName = extractFilename(file);
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
file.transferTo(Paths.get(absPath));
return getPathFileName(fileName);
}
/**
* 编码文件名
*/
public static final String extractFilename(MultipartFile file)
{
return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), FileTypeUtils.getExtension(file));
}
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
{
File desc = new File(uploadDir + File.separator + fileName);
if (!desc.exists())
{
if (!desc.getParentFile().exists())
{
desc.getParentFile().mkdirs();
}
}
return desc.isAbsolute() ? desc : desc.getAbsoluteFile();
}
private static final String getPathFileName(String fileName) throws IOException
{
String pathFileName = "/" + fileName;
return pathFileName;
}
/**
* 文件大小校验
*
* @param file 上传的文件
* @throws FileSizeLimitExceededException 如果超出最大大小
* @throws InvalidExtensionException 文件校验异常
*/
public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, InvalidExtensionException
{
long size = file.getSize();
if (size > DEFAULT_MAX_SIZE)
{
throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
}
String fileName = file.getOriginalFilename();
String extension = FileTypeUtils.getExtension(file);
if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
{
if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
{
throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension,
fileName);
}
else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION)
{
throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension,
fileName);
}
else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION)
{
throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
fileName);
}
else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION)
{
throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension,
fileName);
}
else
{
throw new InvalidExtensionException(allowedExtension, extension, fileName);
}
}
}
/**
* 判断MIME类型是否是允许的MIME类型
*
* @param extension 上传文件类型
* @param allowedExtension 允许上传文件类型
* @return true/false
*/
public static final boolean isAllowedExtension(String extension, String[] allowedExtension)
{
for (String str : allowedExtension)
{
if (str.equalsIgnoreCase(extension))
{
return true;
}
}
return false;
}
}

View File

@@ -14,10 +14,12 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 47.109.135.151:8848
namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 47.109.135.151:8848
namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a
# 配置文件格式
file-extension: yml
# 共享配置

View File

@@ -18,15 +18,6 @@ public class RuoYiGenApplication
public static void main(String[] args)
{
SpringApplication.run(RuoYiGenApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 代码生成模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
System.out.println("(♥◠‿◠)ノ゙ 代码生成模块启动成功 ლ(´ڡ`ლ)゙ \n");
}
}

View File

@@ -215,7 +215,7 @@ public class GenUtils
*/
public static String replaceText(String text)
{
return RegExUtils.replaceAll(text, "(?:表|若依)", "");
return RegExUtils.replaceAll(text, "(?:表|租研舍)", "");
}
/**

View File

@@ -14,10 +14,12 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 47.109.135.151:8848
namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 47.109.135.151:8848
namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a
# 配置文件格式
file-extension: yml
# 共享配置

View File

@@ -18,15 +18,6 @@ public class RuoYiJobApplication
public static void main(String[] args)
{
SpringApplication.run(RuoYiJobApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 定时任务模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
System.out.println("(♥◠‿◠)ノ゙ 定时任务模块启动成功 ლ(´ڡ`ლ)゙ \n");
}
}

View File

@@ -14,10 +14,12 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 47.109.135.151:8848
namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 47.109.135.151:8848
namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a
# 配置文件格式
file-extension: yml
# 共享配置

View File

@@ -71,6 +71,22 @@
<artifactId>ruoyi-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-sms</artifactId>
<version>3.6.4</version>
</dependency>
</dependencies>
<build>

View File

@@ -1,9 +1,14 @@
package com.ruoyi.system;
import org.apache.tomcat.util.http.LegacyCookieProcessor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
/**
* 系统模块
@@ -18,15 +23,14 @@ public class RuoYiSystemApplication
public static void main(String[] args)
{
SpringApplication.run(RuoYiSystemApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ \n");
}
@Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> cookieProcessorCustomizer() {
return tomcatServletWebServerFactory -> tomcatServletWebServerFactory.addContextCustomizers((TomcatContextCustomizer) context -> {
context.setCookieProcessor(new LegacyCookieProcessor());
});
}
}

View File

@@ -0,0 +1,23 @@
package com.ruoyi.system.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Minio 配置信息
*
* @author ruoyi
*/
@Configuration
@ConfigurationProperties(prefix = "system")
@Data
public class SystemConfig
{
/**
* 加密密钥
*/
private String AESkey;
}

View File

@@ -0,0 +1,109 @@
package com.ruoyi.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.domain.http.Channel;
import com.ruoyi.system.service.IChannelService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* 渠道配置Controller
*
* @author ruoyi
* @date 2024-09-15
*/
@RestController
@RequestMapping("/channel")
public class ChannelController extends BaseController
{
@Autowired
private IChannelService channelService;
/**
* 查询渠道配置列表
*/
@RequiresPermissions("system:channel:list")
@GetMapping("/list")
public TableDataInfo list(Channel channel)
{
startPage();
List<Channel> list = channelService.selectChannelList(channel);
return getDataTable(list);
}
/**
* 导出渠道配置列表
*/
@RequiresPermissions("system:channel:export")
@Log(title = "渠道配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Channel channel)
{
List<Channel> list = channelService.selectChannelList(channel);
ExcelUtil<Channel> util = new ExcelUtil<Channel>(Channel.class);
util.exportExcel(response, list, "渠道配置数据");
}
/**
* 获取渠道配置详细信息
*/
@RequiresPermissions("system:channel:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(channelService.selectChannelById(id));
}
/**
* 新增渠道配置
*/
@RequiresPermissions("system:channel:add")
@Log(title = "渠道配置", businessType = BusinessType.INSERT)
@RequestMapping(value = "/add", method = RequestMethod.POST)
public AjaxResult add(@RequestBody Channel channel)
{
return toAjax(channelService.insertChannel(channel));
}
/**
* 修改渠道配置
*/
@RequiresPermissions("system:channel:edit")
@Log(title = "渠道配置", businessType = BusinessType.UPDATE)
@RequestMapping(value = "/edit", method = RequestMethod.POST)
public AjaxResult edit(@RequestBody Channel channel)
{
return toAjax(channelService.updateChannel(channel));
}
/**
* 删除渠道配置
*/
@RequiresPermissions("system:channel:remove")
@Log(title = "渠道配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(channelService.deleteChannelByIds(ids));
}
/**
* 根据渠道标识获取渠道类型
* @param sign
* @return
*/
@GetMapping("/getChannelBySign")
public AjaxResult getChannelBySign(@RequestParam("sign")String sign){
return channelService.getChannelBySign(sign);
}
}

View File

@@ -0,0 +1,46 @@
package com.ruoyi.system.controller;
import com.ruoyi.common.core.domain.http.Channel;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.service.IChannelService;
import com.ruoyi.system.service.ICommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 渠道配置Controller
*
* @author ruoyi
* @date 2024-09-15
*/
@RestController
@RequestMapping("/common")
public class CommonController extends BaseController
{
@Autowired
private ICommonService commonService;
/**
* H5发送验证码
* @param phone 手机号码
* @return AjaxResult
*/
@GetMapping("/sendSms")
public AjaxResult sendSms(@RequestParam("phone")String phone, HttpServletRequest request){
String header = request.getHeader("x-sms-source");
return commonService.sendSms(phone,header);
}
}

View File

@@ -0,0 +1,135 @@
package com.ruoyi.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.GetSumDto;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.dto.ApplyCallback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
import com.ruoyi.system.service.ICustomerApplyLogService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* 客户申请记录Controller
*
* @author ruoyi
* @date 2024-09-15
*/
@RestController
@RequestMapping("/log")
public class CustomerApplyLogController extends BaseController
{
@Autowired
private ICustomerApplyLogService customerApplyLogService;
/**
* 查询客户申请记录列表
*/
@RequiresPermissions("system:log:list")
@GetMapping("/list")
public TableDataInfo list(CustomerApplyLog customerApplyLog)
{
startPage();
List<CustomerApplyLog> list = customerApplyLogService.selectCustomerApplyLogList(customerApplyLog);
return getDataTable(list);
}
/**
* 获取商户今日已申请数
*
*
* @param getSumDto
* @param source 请求来源
* @return 结果
*/
@PostMapping("/sum")
public R<Integer> sum(@RequestBody GetSumDto getSumDto, @RequestHeader(SecurityConstants.FROM_SOURCE) String source){
return R.ok(customerApplyLogService.getApplySum(getSumDto.getMerchantId()));
}
/**
* 获取用户今日是否是否已申请
*
*
* @param customerID
* @param source 请求来源
* @return 结果
*/
@GetMapping("/customerApply")
public R<Boolean> customerApply(@RequestParam("customerID") Long customerID,@RequestHeader(SecurityConstants.FROM_SOURCE) String source){
return customerApplyLogService.getCustomerApply(customerID);
}
/**
* 导出客户申请记录列表
*/
@RequiresPermissions("system:log:export")
@Log(title = "客户申请记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CustomerApplyLog customerApplyLog)
{
List<CustomerApplyLog> list = customerApplyLogService.selectCustomerApplyLogList(customerApplyLog);
ExcelUtil<CustomerApplyLog> util = new ExcelUtil<CustomerApplyLog>(CustomerApplyLog.class);
util.exportExcel(response, list, "客户申请记录数据");
}
/**
* 获取客户申请记录详细信息
*/
@RequiresPermissions("system:log:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(customerApplyLogService.selectCustomerApplyLogById(id));
}
/**
* 新增客户申请记录
*/
@RequiresPermissions("system:log:add")
@Log(title = "客户申请记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CustomerApplyLog customerApplyLog)
{
return toAjax(customerApplyLogService.insertCustomerApplyLog(customerApplyLog));
}
/**
* 修改客户申请记录
*/
@RequiresPermissions("system:log:edit")
@Log(title = "客户申请记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CustomerApplyLog customerApplyLog)
{
return toAjax(customerApplyLogService.updateCustomerApplyLog(customerApplyLog));
}
/**
* 删除客户申请记录
*/
@RequiresPermissions("system:log:remove")
@Log(title = "客户申请记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(customerApplyLogService.deleteCustomerApplyLogByIds(ids));
}
/**
* 下游数据回调
*/
@PostMapping("/applyCallback")
public AjaxResult applyCallback(@RequestBody ApplyCallback applyCallback){
return customerApplyLogService.applyCallBack(applyCallback);
}
}

View File

@@ -0,0 +1,184 @@
package com.ruoyi.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.service.IMerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.domain.http.Customer;
import com.ruoyi.system.service.ICustomerService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* 客户信息Controller
*
* @author ruoyi
* @date 2024-09-15
*/
@RestController
@RequestMapping("/customer")
public class CustomerController extends BaseController
{
@Autowired
private ICustomerService customerService;
@Autowired
private IMerchantService merchantService;
/**
* 查询客户信息列表
*/
@RequiresPermissions("system:customer:list")
@GetMapping("/list")
public TableDataInfo list(Customer customer)
{
startPage();
List<Customer> list = customerService.selectCustomerList(customer);
return getDataTable(list);
}
/**
* 导出客户信息列表
*/
@RequiresPermissions("system:customer:export")
@Log(title = "客户信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Customer customer)
{
List<Customer> list = customerService.selectCustomerList(customer);
ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
util.exportExcel(response, list, "客户信息数据");
}
/**
* 获取客户信息详细信息
*/
@RequiresPermissions("system:customer:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(customerService.selectCustomerById(id));
}
/**
* 通过手机号MD5查询用户信息
*
* @param phoneMD5 用户名
* @return 结果
*/
@GetMapping("/getByMd5")
public R<Customer> getCustomerInfoByPhoneMd5(@RequestParam("phoneMD5")String phoneMD5){
return customerService.selectByPhoneMd5(phoneMD5);
}
/**
* 通过手机号MD5更新用户信息
*
* @param customer 用户
* @return 结果
*/
@PostMapping("/updateByPhoneMd5")
public R updateByPhoneMd5(@RequestBody Customer customer ,@RequestHeader(SecurityConstants.FROM_SOURCE) String source){
return customerService.updateByPhoneMd5(customer);
}
/**
* 新增客户信息
* @return
*/
@PostMapping("/addNewCustomer")
public R add(@RequestBody Customer customer,@RequestHeader(SecurityConstants.FROM_SOURCE) String source){
boolean save = customerService.save(customer);
if (save){
return R.ok();
}
return R.fail();
}
/**
* 新增客户信息
*/
@RequiresPermissions("system:customer:add")
@Log(title = "客户信息", businessType = BusinessType.INSERT)
@RequestMapping(value = "/add", method = RequestMethod.POST)
public AjaxResult add(@RequestBody Customer customer)
{
return toAjax(customerService.insertCustomer(customer));
}
/**
* 修改客户信息
*/
@RequiresPermissions("system:customer:edit")
@Log(title = "客户信息", businessType = BusinessType.UPDATE)
@RequestMapping(value = "/edit", method = RequestMethod.POST)
public AjaxResult edit(@RequestBody Customer customer)
{
return toAjax(customerService.updateCustomer(customer));
}
/**
* 删除客户信息
*/
@RequiresPermissions("system:customer:remove")
@Log(title = "客户信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(customerService.deleteCustomerByIds(ids));
}
/**
* 获取用户token
* @param phone
* @return
*/
@GetMapping("/getCustomerToken")
public String getCustomerToken(@RequestParam("phone") String phone,@RequestParam("channelId")Long channelId) {
return customerService.getCustomerToken(phone);
}
/**
* H5用户登录
*/
@GetMapping("/customerLogin")
public AjaxResult customerLogin(@RequestParam("phone")String phone,@RequestParam("code")Integer code,HttpServletRequest request){
return customerService.customerLogin(phone,code,request);
}
/**
* H5保存用户留资信息
*/
@PostMapping("/saveCustomerInfo")
public AjaxResult saveCustomerInfo(@RequestBody Customer customer, HttpServletRequest request){
return customerService.saveCustomerInfo(customer,request);
}
/**
* 获取商户下渠道列表
* @return
*/
@RequestMapping(value = "/getAllMerchantList", method = RequestMethod.GET)
public AjaxResult getAllMerchantList()
{
return success(merchantService.findAllMerchantList());
}
@PostMapping("/v1/saveCustomerInfo")
public AjaxResult v1SaveCustomerInfo(@RequestBody Customer customer, HttpServletRequest request){
return customerService.v1SaveCustomerInfo(customer,request);
}
}

View File

@@ -0,0 +1,157 @@
package com.ruoyi.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.dto.ApplyCallback;
import com.ruoyi.system.service.IChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.domain.http.Merchant;
import com.ruoyi.system.service.IMerchantService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* 商户Controller
*
* @author ruoyi
* @date 2024-09-15
*/
@RestController
@RequestMapping("/merchant")
public class MerchantController extends BaseController
{
@Autowired
private IMerchantService merchantService;
@Autowired
private IChannelService channelService;
/**
* 查询商户列表
*/
@RequiresPermissions("system:merchant:list")
@GetMapping("/list")
public TableDataInfo list(Merchant merchant)
{
startPage();
List<Merchant> list = merchantService.selectMerchantList(merchant);
return getDataTable(list);
}
/**
* 获取合适的产品
*
* @return 结果
*/
@GetMapping("/merchantList")
public R<List<Merchant>> merchantList(){
return merchantService.getMerchantList();
}
/**
* 导出商户列表
*/
@RequiresPermissions("system:merchant:export")
@Log(title = "商户", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Merchant merchant)
{
List<Merchant> list = merchantService.selectMerchantList(merchant);
ExcelUtil<Merchant> util = new ExcelUtil<Merchant>(Merchant.class);
util.exportExcel(response, list, "商户数据");
}
/**
* 获取商户详细信息
*/
@RequiresPermissions("system:merchant:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(merchantService.selectMerchantById(id));
}
/**
* 获取商户下渠道列表
* @return
*/
@GetMapping("/getMerchantChannelList")
public AjaxResult getMerchantChannelList()
{
return success(channelService.findAllChannelList());
}
/**
* 新增商户
*/
@RequiresPermissions("system:merchant:add")
@Log(title = "商户", businessType = BusinessType.INSERT)
@RequestMapping(value = "/add", method = RequestMethod.POST)
public AjaxResult add(@RequestBody Merchant merchant)
{
return toAjax(merchantService.insertMerchant(merchant));
}
/**
* 修改商户
*/
@RequiresPermissions("system:merchant:edit")
@Log(title = "商户", businessType = BusinessType.UPDATE)
@RequestMapping(value = "/edit", method = RequestMethod.POST)
public AjaxResult edit(@RequestBody Merchant merchant)
{
return toAjax(merchantService.updateMerchant(merchant));
}
/**
* 删除商户
*/
@RequiresPermissions("system:merchant:remove")
@Log(title = "商户", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(merchantService.deleteMerchantByIds(ids));
}
/**
* 获取合适的产品
*/
@GetMapping("/getMatchMerchant")
public AjaxResult getMatchMerchantList(HttpServletRequest request){
return merchantService.getMatchMerchantList(request);
}
/**
* H5申请商户
*/
@GetMapping("/h5applyMerchant")
public AjaxResult H5applyMerchant(@RequestParam("merchantId") String merchantId,HttpServletRequest request){
return merchantService.H5applyMerchant(Long.valueOf(merchantId),request);
}
@GetMapping("/getMatchMerchantNew")
public AjaxResult getMatchMerchantNew(){
return merchantService.getMatchMerchantNew();
}
@GetMapping("/v1/getMatchMerchant")
public AjaxResult V1GetMatchMerchant(HttpServletRequest request){
return merchantService.V1GetMatchMerchant(request);
}
}

View File

@@ -0,0 +1,11 @@
package com.ruoyi.system.domain.dto;
import lombok.Data;
@Data
public class ApplyCallback {
private String sign;
private String Data;
}

View File

@@ -0,0 +1,23 @@
package com.ruoyi.system.domain.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ApplyCallbackDto {
//订单号
private String orderNo;
//md5
private String md5;
//订单价格
private BigDecimal price;
//订单状态
private Integer orderStatus;
}

View File

@@ -0,0 +1,19 @@
package com.ruoyi.system.domain.dto;
import lombok.Data;
@Data
public class MerchantListDto {
//商户名
private String merchantName;
//商户跳转地址
private String merchantUrl;
//商户描述
private String merchantDescribe;
//商户ID
private Long merchantId;
}

View File

@@ -0,0 +1,69 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.http.Channel;
/**
* 渠道配置Mapper接口
*
* @author ruoyi
* @date 2024-09-15
*/
public interface ChannelMapper extends BaseMapper<Channel>
{
/**
* 查询渠道配置
*
* @param id 渠道配置主键
* @return 渠道配置
*/
public Channel selectChannelById(Long id);
/**
* 查询渠道配置列表
*
* @param channel 渠道配置
* @return 渠道配置集合
*/
public List<Channel> selectChannelList(Channel channel);
/**
* 新增渠道配置
*
* @param channel 渠道配置
* @return 结果
*/
public int insertChannel(Channel channel);
/**
* 修改渠道配置
*
* @param channel 渠道配置
* @return 结果
*/
public int updateChannel(Channel channel);
/**
* 删除渠道配置
*
* @param id 渠道配置主键
* @return 结果
*/
public int deleteChannelById(Long id);
/**
* 批量删除渠道配置
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteChannelByIds(Long[] ids);
/**
* 查询渠道配置列表
* @return 渠道配置集合
*/
public List<Channel> findAllChannelList();
}

View File

@@ -0,0 +1,63 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
/**
* 客户申请记录Mapper接口
*
* @author ruoyi
* @date 2024-09-15
*/
public interface CustomerApplyLogMapper extends BaseMapper<CustomerApplyLog>
{
/**
* 查询客户申请记录
*
* @param id 客户申请记录主键
* @return 客户申请记录
*/
public CustomerApplyLog selectCustomerApplyLogById(Long id);
/**
* 查询客户申请记录列表
*
* @param customerApplyLog 客户申请记录
* @return 客户申请记录集合
*/
public List<CustomerApplyLog> selectCustomerApplyLogList(CustomerApplyLog customerApplyLog);
/**
* 新增客户申请记录
*
* @param customerApplyLog 客户申请记录
* @return 结果
*/
public int insertCustomerApplyLog(CustomerApplyLog customerApplyLog);
/**
* 修改客户申请记录
*
* @param customerApplyLog 客户申请记录
* @return 结果
*/
public int updateCustomerApplyLog(CustomerApplyLog customerApplyLog);
/**
* 删除客户申请记录
*
* @param id 客户申请记录主键
* @return 结果
*/
public int deleteCustomerApplyLogById(Long id);
/**
* 批量删除客户申请记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteCustomerApplyLogByIds(Long[] ids);
}

View File

@@ -0,0 +1,63 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.http.Customer;
/**
* 客户信息Mapper接口
*
* @author ruoyi
* @date 2024-09-15
*/
public interface CustomerMapper extends BaseMapper<Customer>
{
/**
* 查询客户信息
*
* @param id 客户信息主键
* @return 客户信息
*/
public Customer selectCustomerById(Long id);
/**
* 查询客户信息列表
*
* @param customer 客户信息
* @return 客户信息集合
*/
public List<Customer> selectCustomerList(Customer customer);
/**
* 新增客户信息
*
* @param customer 客户信息
* @return 结果
*/
public int insertCustomer(Customer customer);
/**
* 修改客户信息
*
* @param customer 客户信息
* @return 结果
*/
public int updateCustomer(Customer customer);
/**
* 删除客户信息
*
* @param id 客户信息主键
* @return 结果
*/
public int deleteCustomerById(Long id);
/**
* 批量删除客户信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteCustomerByIds(Long[] ids);
}

View File

@@ -0,0 +1,71 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.http.Customer;
import com.ruoyi.common.core.domain.http.Merchant;
/**
* 商户Mapper接口
*
* @author ruoyi
* @date 2024-09-15
*/
public interface MerchantMapper extends BaseMapper<Merchant>
{
/**
* 查询商户
*
* @param id 商户主键
* @return 商户
*/
public Merchant selectMerchantById(Long id);
/**
* 查询商户列表
*
* @param merchant 商户
* @return 商户集合
*/
public List<Merchant> selectMerchantList(Merchant merchant);
/**
* 新增商户
*
* @param merchant 商户
* @return 结果
*/
public int insertMerchant(Merchant merchant);
/**
* 修改商户
*
* @param merchant 商户
* @return 结果
*/
public int updateMerchant(Merchant merchant);
/**
* 删除商户
*
* @param id 商户主键
* @return 结果
*/
public int deleteMerchantById(Long id);
/**
* 批量删除商户
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteMerchantByIds(Long[] ids);
/**
* 获取商户列表
* @return
*/
public List<Merchant> findAllMerchantList();
}

View File

@@ -0,0 +1,12 @@
package com.ruoyi.system.process;
import com.ruoyi.common.core.web.domain.AjaxResult;
/**
*根据流程类型 执行不同的处理器
*/
public interface ProcessHandler {
AjaxResult invoke();
}

View File

@@ -0,0 +1,36 @@
package com.ruoyi.system.process.enums;
import com.ruoyi.common.core.exception.ServiceException;
public enum ProcessHandlerEnum {
H5_HANDLER("H5_HANDLER", "H5Handler"),
HALF_HANDLER("HALF_HANDLER", "HalfHandler");
final String code;
final String name;
public String getCode() {
return code;
}
public String getName() {
return name;
}
ProcessHandlerEnum(String code, String name) {
this.code = code;
this.name = name;
}
public static String getNameByCode(String code) {
ProcessHandlerEnum[] processHandlerEnums = values();
for (ProcessHandlerEnum processHandlerEnum : processHandlerEnums) {
if (processHandlerEnum.getCode().equals(code)) {
return processHandlerEnum.getName();
}
}
String msg = String.format("请检查对应的流程处理器是否实现,编码为:%s", code);
throw new ServiceException(msg, 500);
}
}

View File

@@ -0,0 +1,14 @@
package com.ruoyi.system.process.handler;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.process.ProcessHandler;
import org.springframework.stereotype.Component;
@Component(value = "H5Handler")
public class H5Handler implements ProcessHandler {
@Override
public AjaxResult invoke() {
return null;
}
}

View File

@@ -0,0 +1,13 @@
package com.ruoyi.system.process.handler;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.process.ProcessHandler;
import org.springframework.stereotype.Component;
@Component(value = "HalfHandler")
public class HalfHandler implements ProcessHandler {
@Override
public AjaxResult invoke() {
return null;
}
}

View File

@@ -0,0 +1 @@
package com.ruoyi.system.process;

View File

@@ -0,0 +1,75 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.common.core.domain.http.Channel;
import com.ruoyi.common.core.web.domain.AjaxResult;
/**
* 渠道配置Service接口
*
* @author ruoyi
* @date 2024-09-15
*/
public interface IChannelService
{
/**
* 查询渠道配置
*
* @param id 渠道配置主键
* @return 渠道配置
*/
public Channel selectChannelById(Long id);
/**
* 查询渠道配置列表
*
* @param channel 渠道配置
* @return 渠道配置集合
*/
public List<Channel> selectChannelList(Channel channel);
/**
* 新增渠道配置
*
* @param channel 渠道配置
* @return 结果
*/
public long insertChannel(Channel channel);
/**
* 修改渠道配置
*
* @param channel 渠道配置
* @return 结果
*/
public int updateChannel(Channel channel);
/**
* 批量删除渠道配置
*
* @param ids 需要删除的渠道配置主键集合
* @return 结果
*/
public int deleteChannelByIds(Long[] ids);
/**
* 删除渠道配置信息
*
* @param id 渠道配置主键
* @return 结果
*/
public int deleteChannelById(Long id);
/**
* 获取所有的渠道列表
* @return
*/
public List<Channel> findAllChannelList();
/**
* 根据渠道标识获取渠道
* @param sign
* @return
*/
AjaxResult getChannelBySign(String sign);
}

View File

@@ -0,0 +1,24 @@
package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.http.Channel;
import com.ruoyi.common.core.web.domain.AjaxResult;
import java.util.List;
/**
* 渠道配置Service接口
*
* @author ruoyi
* @date 2024-09-15
*/
public interface ICommonService
{
/**
* H5发送验证码
* @param phone
* @return
*/
AjaxResult sendSms(String phone,String smsSource);
}

View File

@@ -0,0 +1,87 @@
package com.ruoyi.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.domain.dto.ApplyCallback;
/**
* 客户申请记录Service接口
*
* @author ruoyi
* @date 2024-09-15
*/
public interface ICustomerApplyLogService extends IService<CustomerApplyLog>
{
/**
* 查询客户申请记录
*
* @param id 客户申请记录主键
* @return 客户申请记录
*/
public CustomerApplyLog selectCustomerApplyLogById(Long id);
/**
* 查询客户申请记录列表
*
* @param customerApplyLog 客户申请记录
* @return 客户申请记录集合
*/
public List<CustomerApplyLog> selectCustomerApplyLogList(CustomerApplyLog customerApplyLog);
/**
* 新增客户申请记录
*
* @param customerApplyLog 客户申请记录
* @return 结果
*/
public int insertCustomerApplyLog(CustomerApplyLog customerApplyLog);
/**
* 修改客户申请记录
*
* @param customerApplyLog 客户申请记录
* @return 结果
*/
public int updateCustomerApplyLog(CustomerApplyLog customerApplyLog);
/**
* 批量删除客户申请记录
*
* @param ids 需要删除的客户申请记录主键集合
* @return 结果
*/
public int deleteCustomerApplyLogByIds(Long[] ids);
/**
* 删除客户申请记录信息
*
* @param id 客户申请记录主键
* @return 结果
*/
public int deleteCustomerApplyLogById(Long id);
/**
* 获取当日商户已申请数
* @param merchantId
* @return
*/
Integer getApplySum(Long merchantId);
/**
* 获取用户今日是否是否已申请
* @param customerID
* @return
*/
R<Boolean> getCustomerApply(Long customerID);
/**
* 申请回调
* @param applyCallback
* @return
*/
AjaxResult applyCallBack(ApplyCallback applyCallback);
}

View File

@@ -0,0 +1,114 @@
package com.ruoyi.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.http.Customer;
import com.ruoyi.common.core.web.domain.AjaxResult;
import javax.servlet.http.HttpServletRequest;
/**
* 客户信息Service接口
*
* @author ruoyi
* @date 2024-09-15
*/
public interface ICustomerService extends IService<Customer>
{
/**
* 查询客户信息
*
* @param id 客户信息主键
* @return 客户信息
*/
public Customer selectCustomerById(Long id);
/**
* 查询客户信息列表
*
* @param customer 客户信息
* @return 客户信息集合
*/
public List<Customer> selectCustomerList(Customer customer);
/**
* 新增客户信息
*
* @param customer 客户信息
* @return 结果
*/
public int insertCustomer(Customer customer);
/**
* 修改客户信息
*
* @param customer 客户信息
* @return 结果
*/
public int updateCustomer(Customer customer);
/**
* 批量删除客户信息
*
* @param ids 需要删除的客户信息主键集合
* @return 结果
*/
public int deleteCustomerByIds(Long[] ids);
/**
* 删除客户信息信息
*
* @param id 客户信息主键
* @return 结果
*/
public int deleteCustomerById(Long id);
/**
* 根据手机好MD5查询用户
* @param phoneMD5
* @return
*/
R<Customer> selectByPhoneMd5(String phoneMD5);
/**
* 通过手机号更新用户信息
* @param customer
* @return
*/
R updateByPhoneMd5(Customer customer);
/**
* 获取用户tooken
* @param phone
* @return
*/
String getCustomerToken(String phone);
/**
* 注册并返回token
* @param phone
* @return
*/
public String registAndretrunToken(String phone,Long channelId);
/**
* h5用户登录
* @param phone
* @param code
* @param request
* @return
*/
AjaxResult customerLogin(String phone, Integer code,HttpServletRequest request);
/**
* 保存用户留资信息
* @param customer
* @param request
* @return
*/
AjaxResult saveCustomerInfo(Customer customer, HttpServletRequest request);
AjaxResult v1SaveCustomerInfo(Customer customer, HttpServletRequest request);
}

View File

@@ -0,0 +1,98 @@
package com.ruoyi.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.http.Customer;
import com.ruoyi.common.core.domain.http.Merchant;
import com.ruoyi.common.core.web.domain.AjaxResult;
import javax.servlet.http.HttpServletRequest;
/**
* 商户Service接口
*
* @author ruoyi
* @date 2024-09-15
*/
public interface IMerchantService extends IService<Merchant>
{
/**
* 查询商户
*
* @param id 商户主键
* @return 商户
*/
public Merchant selectMerchantById(Long id);
/**
* 查询商户列表
*
* @param merchant 商户
* @return 商户集合
*/
public List<Merchant> selectMerchantList(Merchant merchant);
/**
* 新增商户
*
* @param merchant 商户
* @return 结果
*/
public int insertMerchant(Merchant merchant);
/**
* 修改商户
*
* @param merchant 商户
* @return 结果
*/
public int updateMerchant(Merchant merchant);
/**
* 批量删除商户
*
* @param ids 需要删除的商户主键集合
* @return 结果
*/
public int deleteMerchantByIds(Long[] ids);
/**
* 删除商户信息
*
* @param id 商户主键
* @return 结果
*/
public int deleteMerchantById(Long id);
/**
* 获取基本合适的商户
* @return
*/
R<List<Merchant>> getMerchantList();
/**
* H5获取合适产品
* @param request
* @return
*/
AjaxResult getMatchMerchantList(HttpServletRequest request);
/**
* 获取所有的商户列表
* @return
*/
public List<Merchant> findAllMerchantList();
/**
* H5申请订单
* @param merchantId
* @param request
* @return
*/
AjaxResult H5applyMerchant(Long merchantId, HttpServletRequest request);
AjaxResult getMatchMerchantNew();
AjaxResult V1GetMatchMerchant(HttpServletRequest request);
}

View File

@@ -0,0 +1,164 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.system.mapper.ChannelMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.domain.http.Channel;
import com.ruoyi.system.service.IChannelService;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
/**
* 渠道配置Service业务层处理
*
* @author ruoyi
* @date 2024-09-15
*/
@Service
@Slf4j
public class ChannelServiceImpl implements IChannelService
{
@Autowired
private ChannelMapper channelMapper;
@Autowired
private RedisService redisService;
@PostConstruct
public void init(){
log.info("初始化渠道数据开始");
List<Channel> channels = channelMapper.selectList(new LambdaQueryWrapper<Channel>());
for (Channel channel:channels) {
redisService.deleteObject(CacheConstants.CHANNEL_ID+channel.getId());
redisService.setCacheObject(CacheConstants.CHANNEL_ID+channel.getId(),channel);
redisService.deleteObject(CacheConstants.CHANNEL_SIGN+channel.getChannelSign());
redisService.setCacheObject(CacheConstants.CHANNEL_SIGN+channel.getChannelSign(),channel);
}
}
/**
* 查询渠道配置
*
* @param id 渠道配置主键
* @return 渠道配置
*/
@Override
public Channel selectChannelById(Long id)
{
return channelMapper.selectChannelById(id);
}
/**
* 查询渠道配置列表
*
* @param channel 渠道配置
* @return 渠道配置
*/
@Override
public List<Channel> selectChannelList(Channel channel)
{
return channelMapper.selectChannelList(channel);
}
/**
* 新增渠道配置
*
* @param channel 渠道配置
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public long insertChannel(Channel channel)
{
if (StringUtils.isEmpty(channel.getChannelSign())) {
channel.setChannelSign(RandomStringUtils.random(16, true, false));
}
channel.setCreateTime(DateUtils.getNowDate());
channel.setUpdateTime(DateUtils.getNowDate());
long i = channelMapper.insertChannel(channel);
//新增插入缓存
Channel channelById = channelMapper.selectChannelById(i);
redisService.setCacheObject(CacheConstants.CHANNEL_ID+i,channelById);
redisService.setCacheObject(CacheConstants.CHANNEL_SIGN+channel.getChannelSign(),channelById);
return i;
}
/**
* 修改渠道配置
*
* @param channel 渠道配置
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int updateChannel(Channel channel)
{
channel.setUpdateTime(DateUtils.getNowDate());
int i = channelMapper.updateChannel(channel);
Channel channelById = channelMapper.selectChannelById(channel.getId());
redisService.deleteObject(CacheConstants.CHANNEL_ID+channel.getId());
redisService.deleteObject(CacheConstants.CHANNEL_SIGN+channel.getChannelSign());
redisService.setCacheObject(CacheConstants.CHANNEL_ID+channel.getId(),channelById);
redisService.setCacheObject(CacheConstants.CHANNEL_SIGN+channel.getChannelSign(),channelById);
return i;
}
/**
* 批量删除渠道配置
*
* @param ids 需要删除的渠道配置主键
* @return 结果
*/
@Override
public int deleteChannelByIds(Long[] ids)
{
return channelMapper.deleteChannelByIds(ids);
}
/**
* 删除渠道配置信息
*
* @param id 渠道配置主键
* @return 结果
*/
@Override
public int deleteChannelById(Long id)
{
return channelMapper.deleteChannelById(id);
}
/**
* 获取所有的渠道列表
* @return
*/
//@Cacheable(value = "channel",key = "'channel:all'")
public List<Channel> findAllChannelList(){
return channelMapper.findAllChannelList();
}
/**
* 根据渠道标识获取渠道
* @param sign
* @return
*/
@Override
public AjaxResult getChannelBySign(String sign) {
Channel channel = channelMapper.selectOne(new LambdaQueryWrapper<Channel>().eq(Channel::getChannelSign, sign));
if (channel==null||channel.getChannelSign()==null){
return AjaxResult.error("渠道异常");
}
return AjaxResult.success("获取成功",channel.getChannelType());
}
}

View File

@@ -0,0 +1,102 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.constant.RedisConstant;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.sms.component.SmsComponent;
import com.ruoyi.system.service.ICommonService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import java.security.SecureRandom;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* 渠道配置Service业务层处理
*
* @author ruoyi
* @date 2024-09-15
*/
@Service
public class CommonServiceImpl implements ICommonService {
@Autowired
private RedisService redisService;
@Autowired
private SmsComponent smsComponent;
@Autowired
private Environment environment;
@Override
public AjaxResult sendSms(String phone, String smsSource) {
if (StringUtils.isEmpty(phone)) {
return AjaxResult.error("手机号未空");
}
if (phone.length() != 11) {
return AjaxResult.error("手机号长度异常");
}
//正式环境发送验证码 pc4位 h5注册页6位
String code;
// 判断是否为正式环境
if (isProductionProfileActive()) {
//正式环境操作
code = smsSource.equalsIgnoreCase("h5") ? generateCode(6) : generateCode(4);
// 发送短信
Map<String, String> params = new HashMap<>();
params.put(phone, code);
smsComponent.sendP2PMsg(params);
} else {
// 非正式环境直接设置固定验证码
code = smsSource.equalsIgnoreCase("h5") ? "123456" : "1234";
}
//放入缓存 3分钟
redisService.setCacheObject(RedisConstant.H5_LOGIN_CACHE + phone, code, 3 * 60L, TimeUnit.SECONDS);
return AjaxResult.success("发送成功");
}
/**
* 判断当前活跃环境是否是 正式环境
* if (isProductionProfileActive()) {
* // 进行与生产环境相关的逻辑处理
* } else {
* // 进行非生产环境的处理
* }
*
* @return
*/
public boolean isProductionProfileActive() {
// 获取当前应用的活跃环境
String[] activeProfiles = environment.getActiveProfiles();
// 定义线上环境列表
List<String> proList = new ArrayList<>(Arrays.asList("prod", "pro"));
// 检查活跃环境是否包含在 proList 中
for (String profile : activeProfiles) {
if (proList.contains(profile)) {
return true; // 如果有活跃环境在 proList 中,返回 true
}
}
return false; // 如果没有匹配的环境,返回 false
}
/**
* 定义生成验证码的方法
*
* @param length 验证码长度
* @return
*/
private String generateCode(int length) {
SecureRandom secureRandom = new SecureRandom();
int bound = (int) Math.pow(10, length);
int min = bound / 10;
return String.valueOf(secureRandom.nextInt(bound - min) + min);
}
}

View File

@@ -0,0 +1,179 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.LocalDateTimeUtils;
import com.ruoyi.common.core.utils.SecureUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.domain.dto.ApplyCallback;
import com.ruoyi.system.domain.dto.ApplyCallbackDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CustomerApplyLogMapper;
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
import com.ruoyi.system.service.ICustomerApplyLogService;
import org.springframework.util.StringUtils;
/**
* 客户申请记录Service业务层处理
*
* @author ruoyi
* @date 2024-09-15
*/
@Service
@Slf4j
public class CustomerApplyLogServiceImpl extends ServiceImpl<CustomerApplyLogMapper, CustomerApplyLog> implements IService<CustomerApplyLog>,ICustomerApplyLogService
{
@Autowired
private CustomerApplyLogMapper customerApplyLogMapper;
/**
* 查询客户申请记录
*
* @param id 客户申请记录主键
* @return 客户申请记录
*/
@Override
public CustomerApplyLog selectCustomerApplyLogById(Long id)
{
return customerApplyLogMapper.selectCustomerApplyLogById(id);
}
/**
* 查询客户申请记录列表
*
* @param customerApplyLog 客户申请记录
* @return 客户申请记录
*/
@Override
public List<CustomerApplyLog> selectCustomerApplyLogList(CustomerApplyLog customerApplyLog)
{
return customerApplyLogMapper.selectCustomerApplyLogList(customerApplyLog);
}
/**
* 新增客户申请记录
*
* @param customerApplyLog 客户申请记录
* @return 结果
*/
@Override
public int insertCustomerApplyLog(CustomerApplyLog customerApplyLog)
{
customerApplyLog.setCreateTime(DateUtils.getNowDate());
return customerApplyLogMapper.insertCustomerApplyLog(customerApplyLog);
}
/**
* 修改客户申请记录
*
* @param customerApplyLog 客户申请记录
* @return 结果
*/
@Override
public int updateCustomerApplyLog(CustomerApplyLog customerApplyLog)
{
customerApplyLog.setUpdateTime(DateUtils.getNowDate());
return customerApplyLogMapper.updateCustomerApplyLog(customerApplyLog);
}
/**
* 批量删除客户申请记录
*
* @param ids 需要删除的客户申请记录主键
* @return 结果
*/
@Override
public int deleteCustomerApplyLogByIds(Long[] ids)
{
return customerApplyLogMapper.deleteCustomerApplyLogByIds(ids);
}
/**
* 删除客户申请记录信息
*
* @param id 客户申请记录主键
* @return 结果
*/
@Override
public int deleteCustomerApplyLogById(Long id)
{
return customerApplyLogMapper.deleteCustomerApplyLogById(id);
}
/**
* 获取当日商户已申请数
* @param merchantId
* @return
*/
@Override
public Integer getApplySum(Long merchantId) {
Long aLong = customerApplyLogMapper.selectCount(
new LambdaQueryWrapper<CustomerApplyLog>()
.eq(CustomerApplyLog::getMerchantId, merchantId)
.eq(CustomerApplyLog::getOrderStatus, 0)
.ge(CustomerApplyLog::getCreateTime, LocalDateTimeUtils.getDateFromLocalDateTime(LocalDateTimeUtils.getTodayStartTime()))
.le(CustomerApplyLog::getCreateTime, LocalDateTimeUtils.getDateFromLocalDateTime(LocalDateTimeUtils.getTodayEndTime())));
return aLong.intValue();
}
/**
* 获取用户今日是否已申请
* @param customerID
* @return
*/
@Override
public R<Boolean> getCustomerApply(Long customerID) {
Long aLong = customerApplyLogMapper.selectCount(
new LambdaQueryWrapper<CustomerApplyLog>()
.isNotNull(CustomerApplyLog::getMerchantId)
.eq(CustomerApplyLog::getOrderStatus, 20)
.ge(CustomerApplyLog::getCreateTime, LocalDateTimeUtils.getDateFromLocalDateTime(LocalDateTimeUtils.getTodayStartTime()))
.le(CustomerApplyLog::getCreateTime, LocalDateTimeUtils.getDateFromLocalDateTime(LocalDateTimeUtils.getTodayEndTime())));
return R.ok(aLong>0);
}
/**
* 申请回调
*/
@Override
public AjaxResult applyCallBack(ApplyCallback applyCallback) {
String s = SecureUtils.AesUtil.AesDecode(applyCallback.getData(), applyCallback.getSign());
if (StringUtils.isEmpty(s)){
return AjaxResult.error("解密异常");
}
ApplyCallbackDto applyCallbackDto;
try {
applyCallbackDto = JSONObject.parseObject(s, ApplyCallbackDto.class);
log.info("渠道:{},回调数据:{}",applyCallback.getSign(),applyCallbackDto);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error("数据转换异常");
}
try {
CustomerApplyLog customerApplyLog = customerApplyLogMapper.selectOne(new LambdaQueryWrapper<CustomerApplyLog>().eq(CustomerApplyLog::getOrderNo, applyCallbackDto.getOrderNo()));
if (applyCallbackDto.getOrderStatus()!=null) {
customerApplyLog.setOrderStatus(applyCallbackDto.getOrderStatus().longValue());
}
if (applyCallbackDto.getPrice()!=null){
if (customerApplyLog.getPrice()==null){
customerApplyLog.setPrice(applyCallbackDto.getPrice());
}else {
customerApplyLog.setPrice(customerApplyLog.getPrice().add(applyCallbackDto.getPrice()));
}
}
customerApplyLogMapper.updateById(customerApplyLog);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error("数据异常");
}
return AjaxResult.success("回调成功");
}
}

View File

@@ -0,0 +1,282 @@
package com.ruoyi.system.service.impl;
import java.util.*;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.crypto.digest.MD5;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.core.constant.RedisConstant;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.http.Channel;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.EncryptUtil;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.redis.service.CustomerTokenService;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.config.SystemConfig;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CustomerMapper;
import com.ruoyi.common.core.domain.http.Customer;
import com.ruoyi.system.service.ICustomerService;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
/**
* 客户信息Service业务层处理
*
* @author ruoyi
* @date 2024-09-15
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements IService<Customer>,ICustomerService {
private final CustomerMapper customerMapper;
private final SystemConfig systemConfig;
private final CustomerTokenService customerTokenService;
private final RedisService redisService;
private final TokenService tokenService;
/**
* 查询客户信息
*
* @param id 客户信息主键
* @return 客户信息
*/
@Override
public Customer selectCustomerById(Long id)
{
return customerMapper.selectCustomerById(id);
}
/**
* 查询客户信息列表
*
* @param customer 客户信息
* @return 客户信息
*/
@Override
public List<Customer> selectCustomerList(Customer customer)
{
return customerMapper.selectCustomerList(customer);
}
/**
* 新增客户信息
*
* @param customer 客户信息
* @return 结果
*/
@Override
public int insertCustomer(Customer customer)
{
customer.setCreateTime(DateUtils.getNowDate());
return customerMapper.insertCustomer(customer);
}
/**
* 修改客户信息
*
* @param customer 客户信息
* @return 结果
*/
@Override
public int updateCustomer(Customer customer)
{
customer.setUpdateTime(DateUtils.getNowDate());
return customerMapper.updateCustomer(customer);
}
/**
* 批量删除客户信息
*
* @param ids 需要删除的客户信息主键
* @return 结果
*/
@Override
public int deleteCustomerByIds(Long[] ids)
{
return customerMapper.deleteCustomerByIds(ids);
}
/**
* 删除客户信息信息
*
* @param id 客户信息主键
* @return 结果
*/
@Override
public int deleteCustomerById(Long id)
{
return customerMapper.deleteCustomerById(id);
}
/**
* 通过手机号MD5查询
* @param phoneMD5
* @return
*/
@Override
public R<Customer> selectByPhoneMd5(String phoneMD5) {
Customer one = getOne(new LambdaQueryWrapper<Customer>().eq(Customer::getPhoneMd5, phoneMD5));
if (one==null||one.getId()==null){
return R.fail();
}
return R.ok(one);
}
/**
* 通过手机号更新用户信息
* @param customer
* @return
*/
@Override
public R updateByPhoneMd5(Customer customer) {
int update = customerMapper.update(customer, new UpdateWrapper<Customer>().lambda().eq(Customer::getPhoneMd5, customer.getPhoneMd5()));
if (update>0){
return R.ok();
}
return R.fail();
}
@Override
public String getCustomerToken(String phone) {
log.info("获取用户token,手机号:{}", phone);
Customer customer = this.getOne(new LambdaQueryWrapper<Customer>().eq(Customer::getPhone, phone));
log.info("获取用户token,用户信息:{}", customer);
//获取到用户登陆的token
String token = customerTokenService.getToken(customer.getId());
if (StringUtils.isEmpty(token)) {
//生成一个长60的token
//token = customerTokenService.generateToken(customer.getId(), customer.getPhone(), "ANDROID", customer.getChannelId());
token = tokenService.createTokenApp(customer.getId(),customer.getChannelId());
}
return token;
}
/**
* 注册并返回token
* @param phone
* @return
*/
public String registAndretrunToken(String phone,Long channelId){
Customer customer = new Customer();
customer.setChannelId(channelId);
customer.setPhone(EncryptUtil.AESencode(phone, systemConfig.getAESkey()));
customer.setPhoneMd5(MD5.create().digestHex(phone).toLowerCase(Locale.ROOT));
customer.setIsAuth(false);
customer.setFirstLoginTime(new Date());
customer.setLastLoginTime(new Date());
customer.setStatus(1);
customer.setCreateTime(new Date());
customerMapper.insert(customer);
String token = customerTokenService.getToken(customer.getId());
if (StringUtils.isEmpty(token)) {
//生成一个长60的token
//token = customerTokenService.generateToken(customer.getId(), customer.getPhone(), "ANDROID", customer.getChannelId());
token = tokenService.createTokenApp(customer.getId(),channelId);
}
return token;
}
/**
* H5用户登陆
* @param phone
* @param code
* @param request
* @return
*/
@Override
public AjaxResult customerLogin(String phone, Integer code, HttpServletRequest request) {
String sign = request.getHeader("sign");
if (StringUtils.isEmpty(sign)){
return AjaxResult.error("渠道标识不存在");
}
Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN+sign);
Boolean aBoolean = redisService.hasKey(RedisConstant.H5_LOGIN_CACHE + phone);
if (!aBoolean){
return AjaxResult.error("验证码不存在");
}
int cacheCode = redisService.getCacheObject(RedisConstant.H5_LOGIN_CACHE + phone);
if (cacheCode!=code){
return AjaxResult.success("验证码错误");
}
String customerToken = registAndretrunToken(phone,channel.getId());
return AjaxResult.success("登录成功",customerToken);
}
/**
* 保存用户留资信息
* @param customer
* @param request
* @return
*/
@Override
public AjaxResult saveCustomerInfo(Customer customer, HttpServletRequest request) {
String authorization = request.getHeader("Authorization");
Long customerId = customerTokenService.getCustomerId(authorization, false);
String sign = request.getHeader("sign");
if (StringUtils.isEmpty(sign)){
return AjaxResult.error("渠道标识不存在");
}
Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN+sign);
if (customerId==null){
return AjaxResult.error("用户不存在或未登录");
}
if (StringUtils.isEmpty(customer.getIdCard())){
return AjaxResult.error("身份证好不能为空");
}
boolean validCard = IdcardUtil.isValidCard(customer.getIdCard());
if (validCard){
return AjaxResult.error("身份证号码异常");
}
if (StringUtils.isEmpty(customer.getActurlName())){
return AjaxResult.error("姓名不能为空");
}
int ageByIdCard = IdcardUtil.getAgeByIdCard(customer.getIdCard());
customer.setAge(ageByIdCard);
int genderByIdCard = IdcardUtil.getGenderByIdCard(customer.getIdCard());
customer.setSex(genderByIdCard==0?1:0);
customer.setId(customerId);
customer.setChannelId(channel.getId());
customer.setIsAuth(true);
customer.setStatus(1);
updateById(customer);
return AjaxResult.success("保存成功");
}
@Override
public AjaxResult v1SaveCustomerInfo(Customer customer, HttpServletRequest request) {
String authorization = request.getHeader("Authorization");
Long customerId = customerTokenService.getCustomerId(authorization, false);
String sign = request.getHeader("sign");
if (StringUtils.isEmpty(sign)) {
return AjaxResult.error("渠道标识不存在");
}
Channel channel = redisService.getCacheObject(CacheConstants.CHANNEL_SIGN + sign);
if (customerId == null) {
return AjaxResult.error("用户不存在或未登录");
}
if (StringUtils.isEmpty(customer.getActurlName())) {
return AjaxResult.error("姓名不能为空");
}
customer.setId(customerId);
customer.setChannelId(channel.getId());
customer.setIsAuth(true);
customer.setStatus(1);
updateById(customer);
return AjaxResult.success("保存成功");
}
}

View File

@@ -0,0 +1,288 @@
package com.ruoyi.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.constant.RedisConstant;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.http.Customer;
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
import com.ruoyi.common.core.domain.http.Merchant;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.redis.service.CustomerTokenService;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.system.domain.dto.MerchantListDto;
import com.ruoyi.system.mapper.CustomerMapper;
import com.ruoyi.system.mapper.MerchantMapper;
import com.ruoyi.system.service.ICustomerApplyLogService;
import com.ruoyi.system.service.IMerchantService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* 商户Service业务层处理
*
* @author ruoyi
* @date 2024-09-15
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> implements IService<Merchant>,IMerchantService
{
private final MerchantMapper merchantMapper;
private final CustomerTokenService customerTokenService;
private final ICustomerApplyLogService customerApplyLogService;
private final CustomerMapper customerMapper;
private final RedisService redisService;
/**
* 查询商户
*
* @param id 商户主键
* @return 商户
*/
@Override
public Merchant selectMerchantById(Long id)
{
return merchantMapper.selectMerchantById(id);
}
/**
* 查询商户列表
*
* @param merchant 商户
* @return 商户
*/
@Override
public List<Merchant> selectMerchantList(Merchant merchant)
{
return merchantMapper.selectMerchantList(merchant);
}
/**
* 新增商户
*
* @param merchant 商户
* @return 结果
*/
@Override
public int insertMerchant(Merchant merchant)
{
merchant.setCreateTime(DateUtils.getNowDate());
return merchantMapper.insertMerchant(merchant);
}
/**
* 修改商户
*
* @param merchant 商户
* @return 结果
*/
@Override
public int updateMerchant(Merchant merchant)
{
merchant.setUpdateTime(DateUtils.getNowDate());
return merchantMapper.updateMerchant(merchant);
}
/**
* 批量删除商户
*
* @param ids 需要删除的商户主键
* @return 结果
*/
@Override
public int deleteMerchantByIds(Long[] ids)
{
return merchantMapper.deleteMerchantByIds(ids);
}
/**
* 删除商户信息
*
* @param id 商户主键
* @return 结果
*/
@Override
public int deleteMerchantById(Long id)
{
return merchantMapper.deleteMerchantById(id);
}
/**
* 获取基本合适的商户
* @return
*/
@Override
public R<List<Merchant>> getMerchantList() {
List<Merchant> merchants = merchantMapper.selectList(new LambdaQueryWrapper<Merchant>().eq(Merchant::getStatus, true));
if (CollectionUtil.isEmpty(merchants)){
return R.fail();
}
return R.ok(merchants);
}
public List<Merchant> findAllMerchantList(){
return merchantMapper.findAllMerchantList();
}
@Override
public AjaxResult getMatchMerchantList(HttpServletRequest request) {
String authorization = request.getHeader("Authorization");
Long customerId = customerTokenService.getCustomerId(authorization, false);
if (customerId==null){
return AjaxResult.error("用户不存在或未登录");
}
log.info("H5打开页面{}",customerId);
Customer customer = customerMapper.selectById(customerId);
List<Merchant> merchants = matchMerchant(customer);
List<MerchantListDto> merchantListDtos = new ArrayList<>();
for (Merchant merchant:merchants) {
MerchantListDto merchantListDto = new MerchantListDto();
merchantListDto.setMerchantName(merchant.getMerchantName());
merchantListDto.setMerchantDescribe(merchant.getMerchantDescribe());
merchantListDto.setMerchantUrl(merchant.getHitUrl());
merchantListDto.setMerchantId(merchant.getId());
merchantListDtos.add(merchantListDto);
}
return AjaxResult.success(merchantListDtos);
}
@Override
public AjaxResult H5applyMerchant(Long merchantId, HttpServletRequest request) {
//获取用户
String authorization = request.getHeader("Authorization");
Long customerId = customerTokenService.getCustomerId(authorization, false);
Boolean aBoolean = redisService.hasKey(RedisConstant.H5_APPLY_CHECK + customerId);
if (aBoolean){
return AjaxResult.error("请勿重复点击");
}
log.info("H5申请用户{}",customerId);
Customer customer = customerMapper.selectById(customerId);
Merchant merchant = merchantMapper.selectById(merchantId);
redisService.setCacheObject(RedisConstant.H5_APPLY_CHECK+customerId,1,10l, TimeUnit.SECONDS);
//生成订单号
String orderNo = System.currentTimeMillis()+""+merchantId+""+customerId;
//记录申请订单
CustomerApplyLog customerApplyLog = new CustomerApplyLog();
customerApplyLog.setCustomerId(customerId);
customerApplyLog.setMerchantId(merchantId);
customerApplyLog.setChannelId(customer.getChannelId());
customerApplyLog.setOrderStatus(0l);
customerApplyLog.setOrderNo(orderNo);
customerApplyLog.setCreateTime(new Date());
customerApplyLogService.save(customerApplyLog);
return AjaxResult.success("点击成功","orderNo="+orderNo+"&sign="+merchant.getChannelSign());
}
/**
* 获取前筛符合的商户
* @param customer
*/
private List<Merchant> matchMerchant(Customer customer) {
R<List<Merchant>> listR = getMerchantList();
if (listR.getCode()!=200){
return new ArrayList<>();
}
List<Merchant> merchants = new ArrayList<>();
for (Merchant merchant:listR.getData()) {
//限量判定
Integer sum = customerApplyLogService.getApplySum(merchant.getId());
if (merchant.getLimitType()!=null&&merchant.getLimitType()==1&&merchant.getLimitNum()<=sum){
continue;
}
if (merchant.getAgeLimitStart()!=null&&merchant.getAgeLimitEnd()!=null&&(customer.getAge()<merchant.getAgeLimitStart()||customer.getAge()>merchant.getAgeLimitEnd())){
continue;
}
if (merchant.getChannelLimitType()!=null&&(merchant.getChannelLimitType()==1||merchant.getChannelLimitType()==2)){
List<Long> list = Arrays.asList(merchant.getChannelLimit().split(",")).stream().map(val->Long.parseLong(val)).collect(Collectors.toList());
if (merchant.getChannelLimitType()==1&& !list.contains(customer.getChannelId())){
continue;
}
if (merchant.getChannelLimitType()==2&& list.contains(customer.getChannelId())){
continue;
}
}
merchants.add(merchant);
}
return merchants;
}
@Override
public AjaxResult getMatchMerchantNew() {
List<Merchant> merchantLists = matchMerchantNew();
List<MerchantListDto> results = new ArrayList<>();
for (Merchant merchant : merchantLists) {
MerchantListDto merchantListDto = new MerchantListDto();
merchantListDto.setMerchantName(merchant.getMerchantName());
merchantListDto.setMerchantDescribe(merchant.getMerchantDescribe());
merchantListDto.setMerchantUrl(merchant.getHitUrl());
merchantListDto.setMerchantId(merchant.getId());
results.add(merchantListDto);
}
return AjaxResult.success(results);
}
@Override
public AjaxResult V1GetMatchMerchant(HttpServletRequest request) {
String authorization = request.getHeader("Authorization");
Long customerId = customerTokenService.getCustomerId(authorization, false);
if (customerId==null){
return AjaxResult.error("用户不存在或未登录");
}
Customer customer = customerMapper.selectById(customerId);
List<Merchant> merchants = matchMerchant(customer);
List<MerchantListDto> merchantListDtos = new ArrayList<>();
for (Merchant merchant:merchants) {
MerchantListDto merchantListDto = new MerchantListDto();
merchantListDto.setMerchantName(merchant.getMerchantName());
merchantListDto.setMerchantDescribe(merchant.getMerchantDescribe());
merchantListDto.setMerchantUrl(merchant.getHitUrl());
merchantListDto.setMerchantId(merchant.getId());
merchantListDtos.add(merchantListDto);
}
return AjaxResult.success(merchantListDtos);
}
private List<Merchant> getMerchantLists() {
LambdaQueryWrapper<Merchant> queryWrapper = new LambdaQueryWrapper<Merchant>().eq(Merchant::getStatus, true);
List<Merchant> merchants = merchantMapper.selectList(queryWrapper);
return CollectionUtils.isEmpty(merchants) ? new ArrayList<>() : merchants;
}
private List<Merchant> matchMerchantNew() {
List<Merchant> merchantLists = getMerchantLists();
if (CollectionUtils.isEmpty(merchantLists)) {
return merchantLists;
}
List<Merchant> merchants = new ArrayList<>();
for (Merchant merchant : merchantLists) {
//限量判定
Integer sum = customerApplyLogService.getApplySum(merchant.getId());
if (merchant.getLimitType() != null && merchant.getLimitType() == 1 && merchant.getLimitNum() <= sum) {
continue;
}
merchants.add(merchant);
}
return merchants;
}
}

View File

@@ -14,10 +14,12 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 47.109.135.151:8848
namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 47.109.135.151:8848
namespace: b8ad3fd2-18ea-4cdf-a82c-4ce483392b1a
# 配置文件格式
file-extension: yml
# 共享配置

View File

@@ -0,0 +1,114 @@
<?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.system.mapper.ChannelMapper">
<resultMap type="com.ruoyi.common.core.domain.http.Channel" id="ChannelResult">
<result property="id" column="id" />
<result property="channelName" column="channel_name" />
<result property="channelSign" column="channel_sign" />
<result property="channelType" column="channel_type" />
<result property="score" column="score" />
<result property="htmlName" column="html_name" />
<result property="htmlLocation" column="html_location" />
<result property="ips" column="ips" />
<result property="period" column="period" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<resultMap type="com.ruoyi.common.core.domain.http.Channel" id="ChannelResultList">
<result property="id" column="id" />
<result property="channelName" column="channel_name" />
<result property="channelSign" column="channel_sign" />
</resultMap>
<sql id="selectChannelVo">
select id, channel_name, channel_sign,channel_type, score, html_name, html_location, ips, period, create_time, update_time, remark from channel
</sql>
<sql id="selectChannelIdName">
select id, channel_name, channel_sign from channel
</sql>
<select id="selectChannelList" parameterType="com.ruoyi.common.core.domain.http.Channel" resultMap="ChannelResult">
<include refid="selectChannelVo"/>
<where>
<if test="channelName != null and channelName != ''"> and channel_name like concat('%', #{channelName}, '%')</if>
<if test="channelSign != null and channelSign != ''"> and channel_sign = #{channelSign}</if>
<if test="channelType != null and channelType != ''"> and channel_type = #{channelType}</if>
<if test="score != null "> and score = #{score}</if>
<if test="htmlName != null and htmlName != ''"> and html_name like concat('%', #{htmlName}, '%')</if>
<if test="htmlLocation != null and htmlLocation != ''"> and html_location = #{htmlLocation}</if>
<if test="ips != null and ips != ''"> and ips = #{ips}</if>
<if test="period != null and period != ''"> and period = #{period}</if>
</where>
</select>
<select id="selectChannelById" parameterType="java.lang.Long" resultMap="ChannelResult">
<include refid="selectChannelVo"/>
where id = #{id}
</select>
<insert id="insertChannel" parameterType="com.ruoyi.common.core.domain.http.Channel" useGeneratedKeys="true" keyProperty="id">
insert into channel
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="channelName != null">channel_name,</if>
<if test="channelSign != null">channel_sign,</if>
<if test="channelType != null">channel_type,</if>
<if test="score != null">score,</if>
<if test="htmlName != null">html_name,</if>
<if test="htmlLocation != null">html_location,</if>
<if test="ips != null">ips,</if>
<if test="period != null">period,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="channelName != null">#{channelName},</if>
<if test="channelSign != null">#{channelSign},</if>
<if test="channelType != null">#{channelType},</if>
<if test="score != null">#{score},</if>
<if test="htmlName != null">#{htmlName},</if>
<if test="htmlLocation != null">#{htmlLocation},</if>
<if test="ips != null">#{ips},</if>
<if test="period != null">#{period},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateChannel" parameterType="com.ruoyi.common.core.domain.http.Channel">
update channel
<trim prefix="SET" suffixOverrides=",">
<if test="channelName != null">channel_name = #{channelName},</if>
<if test="channelSign != null">channel_sign = #{channelSign},</if>
<if test="channelType != null">channel_type = #{channelType},</if>
<if test="score != null">score = #{score},</if>
<if test="htmlName != null">html_name = #{htmlName},</if>
<if test="htmlLocation != null">html_location = #{htmlLocation},</if>
<if test="ips != null">ips = #{ips},</if>
<if test="period != null">period = #{period},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteChannelById" parameterType="java.lang.Long">
delete from channel where id = #{id}
</delete>
<delete id="deleteChannelByIds" parameterType="java.lang.String">
delete from channel where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="findAllChannelList" resultMap="ChannelResultList">
<include refid="selectChannelIdName"/>
</select>
</mapper>

View File

@@ -0,0 +1,88 @@
<?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.system.mapper.CustomerApplyLogMapper">
<resultMap type="com.ruoyi.common.core.domain.http.CustomerApplyLog" id="CustomerApplyLogResult">
<result property="id" column="id" />
<result property="customerId" column="customer_id" />
<result property="merchantId" column="merchant_id" />
<result property="channelId" column="channel_id" />
<result property="orderStatus" column="order_status" />
<result property="price" column="price" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectCustomerApplyLogVo">
select id, customer_id, merchant_id, channel_id, order_status, price, create_time, update_time, remark from customer_apply_log
</sql>
<select id="selectCustomerApplyLogList" parameterType="com.ruoyi.common.core.domain.http.CustomerApplyLog" resultMap="CustomerApplyLogResult">
<include refid="selectCustomerApplyLogVo"/>
<where>
<if test="customerId != null "> and customer_id = #{customerId}</if>
<if test="merchantId != null "> and merchant_id = #{merchantId}</if>
<if test="channelId != null "> and channel_id = #{channelId}</if>
<if test="orderStatus != null "> and order_status = #{orderStatus}</if>
<if test="price != null "> and price = #{price}</if>
</where>
</select>
<select id="selectCustomerApplyLogById" parameterType="java.lang.Long" resultMap="CustomerApplyLogResult">
<include refid="selectCustomerApplyLogVo"/>
where id = #{id}
</select>
<insert id="insertCustomerApplyLog" parameterType="com.ruoyi.common.core.domain.http.CustomerApplyLog" useGeneratedKeys="true" keyProperty="id">
insert into customer_apply_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="customerId != null">customer_id,</if>
<if test="merchantId != null">merchant_id,</if>
<if test="channelId != null">channel_id,</if>
<if test="orderStatus != null">order_status,</if>
<if test="price != null">price,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="customerId != null">#{customerId},</if>
<if test="merchantId != null">#{merchantId},</if>
<if test="channelId != null">#{channelId},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="price != null">#{price},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateCustomerApplyLog" parameterType="com.ruoyi.common.core.domain.http.CustomerApplyLog">
update customer_apply_log
<trim prefix="SET" suffixOverrides=",">
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="merchantId != null">merchant_id = #{merchantId},</if>
<if test="channelId != null">channel_id = #{channelId},</if>
<if test="orderStatus != null">order_status = #{orderStatus},</if>
<if test="price != null">price = #{price},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCustomerApplyLogById" parameterType="java.lang.Long">
delete from customer_apply_log where id = #{id}
</delete>
<delete id="deleteCustomerApplyLogByIds" parameterType="java.lang.String">
delete from customer_apply_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,184 @@
<?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.system.mapper.CustomerMapper">
<resultMap type="com.ruoyi.common.core.domain.http.Customer" id="CustomerResult">
<result property="id" column="id" />
<result property="channelId" column="channel_id" />
<result property="age" column="age" />
<result property="sex" column="sex" />
<result property="name" column="name" />
<result property="acturlName" column="acturl_name" />
<result property="phone" column="phone" />
<result property="phoneMd5" column="phone_md5" />
<result property="isAuth" column="is_auth" />
<result property="city" column="city" />
<result property="cityCode" column="city_code" />
<result property="firstLoginTime" column="first_login_time" />
<result property="lastLoginTime" column="last_login_time" />
<result property="lastLoginIp" column="last_login_ip" />
<result property="status" column="status" />
<result property="socialSecurity" column="social_security" />
<result property="car" column="car" />
<result property="guaranteeSlip" column="guarantee_slip" />
<result property="education" column="education" />
<result property="accumulationFund" column="accumulation_fund" />
<result property="hourse" column="hourse" />
<result property="career" column="career" />
<result property="huaBei" column="hua_bei" />
<result property="baiTiao" column="bai_tiao" />
<result property="zhiMa" column="zhi_ma" />
<result property="income" column="income" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectCustomerVo">
select id, channel_id, age, sex, name, acturl_name, phone, phone_md5, is_auth, city, city_code, first_login_time, last_login_time, last_login_ip, status, social_security, car, guarantee_slip, education, accumulation_fund, hourse, career, hua_bei, bai_tiao, zhi_ma, income, create_time, update_time from customer
</sql>
<select id="selectCustomerList" parameterType="com.ruoyi.common.core.domain.http.Customer" resultMap="CustomerResult">
<include refid="selectCustomerVo"/>
<where>
<if test="channelId != null "> and channel_id = #{channelId}</if>
<if test="age != null "> and age = #{age}</if>
<if test="sex != null "> and sex = #{sex}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="acturlName != null and acturlName != ''"> and acturl_name like concat('%', #{acturlName}, '%')</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
<if test="phoneMd5 != null and phoneMd5 != ''"> and phone_md5 = #{phoneMd5}</if>
<if test="isAuth != null "> and is_auth = #{isAuth}</if>
<if test="city != null and city != ''"> and city = #{city}</if>
<if test="cityCode != null "> and city_code = #{cityCode}</if>
<if test="firstLoginTime != null "> and first_login_time = #{firstLoginTime}</if>
<if test="lastLoginTime != null "> and last_login_time = #{lastLoginTime}</if>
<if test="lastLoginIp != null "> and last_login_ip = #{lastLoginIp}</if>
<if test="status != null "> and status = #{status}</if>
<if test="socialSecurity != null "> and social_security = #{socialSecurity}</if>
<if test="car != null "> and car = #{car}</if>
<if test="guaranteeSlip != null "> and guarantee_slip = #{guaranteeSlip}</if>
<if test="education != null "> and education = #{education}</if>
<if test="accumulationFund != null "> and accumulation_fund = #{accumulationFund}</if>
<if test="hourse != null "> and hourse = #{hourse}</if>
<if test="career != null "> and career = #{career}</if>
<if test="huaBei != null "> and hua_bei = #{huaBei}</if>
<if test="baiTiao != null "> and bai_tiao = #{baiTiao}</if>
<if test="zhiMa != null "> and zhi_ma = #{zhiMa}</if>
<if test="income != null "> and income = #{income}</if>
</where>
</select>
<select id="selectCustomerById" parameterType="java.lang.Long" resultMap="CustomerResult">
<include refid="selectCustomerVo"/>
where id = #{id}
</select>
<insert id="insertCustomer" parameterType="com.ruoyi.common.core.domain.http.Customer" useGeneratedKeys="true" keyProperty="id">
insert into customer
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="channelId != null">channel_id,</if>
<if test="age != null">age,</if>
<if test="sex != null">sex,</if>
<if test="name != null">name,</if>
<if test="acturlName != null">acturl_name,</if>
<if test="phone != null">phone,</if>
<if test="phoneMd5 != null">phone_md5,</if>
<if test="isAuth != null">is_auth,</if>
<if test="city != null">city,</if>
<if test="cityCode != null">city_code,</if>
<if test="firstLoginTime != null">first_login_time,</if>
<if test="lastLoginTime != null">last_login_time,</if>
<if test="lastLoginIp != null">last_login_ip,</if>
<if test="status != null">status,</if>
<if test="socialSecurity != null">social_security,</if>
<if test="car != null">car,</if>
<if test="guaranteeSlip != null">guarantee_slip,</if>
<if test="education != null">education,</if>
<if test="accumulationFund != null">accumulation_fund,</if>
<if test="hourse != null">hourse,</if>
<if test="career != null">career,</if>
<if test="huaBei != null">hua_bei,</if>
<if test="baiTiao != null">bai_tiao,</if>
<if test="zhiMa != null">zhi_ma,</if>
<if test="income != null">income,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="channelId != null">#{channelId},</if>
<if test="age != null">#{age},</if>
<if test="sex != null">#{sex},</if>
<if test="name != null">#{name},</if>
<if test="acturlName != null">#{acturlName},</if>
<if test="phone != null">#{phone},</if>
<if test="phoneMd5 != null">#{phoneMd5},</if>
<if test="isAuth != null">#{isAuth},</if>
<if test="city != null">#{city},</if>
<if test="cityCode != null">#{cityCode},</if>
<if test="firstLoginTime != null">#{firstLoginTime},</if>
<if test="lastLoginTime != null">#{lastLoginTime},</if>
<if test="lastLoginIp != null">#{lastLoginIp},</if>
<if test="status != null">#{status},</if>
<if test="socialSecurity != null">#{socialSecurity},</if>
<if test="car != null">#{car},</if>
<if test="guaranteeSlip != null">#{guaranteeSlip},</if>
<if test="education != null">#{education},</if>
<if test="accumulationFund != null">#{accumulationFund},</if>
<if test="hourse != null">#{hourse},</if>
<if test="career != null">#{career},</if>
<if test="huaBei != null">#{huaBei},</if>
<if test="baiTiao != null">#{baiTiao},</if>
<if test="zhiMa != null">#{zhiMa},</if>
<if test="income != null">#{income},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateCustomer" parameterType="com.ruoyi.common.core.domain.http.Customer">
update customer
<trim prefix="SET" suffixOverrides=",">
<if test="channelId != null">channel_id = #{channelId},</if>
<if test="age != null">age = #{age},</if>
<if test="sex != null">sex = #{sex},</if>
<if test="name != null">name = #{name},</if>
<if test="acturlName != null">acturl_name = #{acturlName},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="phoneMd5 != null">phone_md5 = #{phoneMd5},</if>
<if test="isAuth != null">is_auth = #{isAuth},</if>
<if test="city != null">city = #{city},</if>
<if test="cityCode != null">city_code = #{cityCode},</if>
<if test="firstLoginTime != null">first_login_time = #{firstLoginTime},</if>
<if test="lastLoginTime != null">last_login_time = #{lastLoginTime},</if>
<if test="lastLoginIp != null">last_login_ip = #{lastLoginIp},</if>
<if test="status != null">status = #{status},</if>
<if test="socialSecurity != null">social_security = #{socialSecurity},</if>
<if test="car != null">car = #{car},</if>
<if test="guaranteeSlip != null">guarantee_slip = #{guaranteeSlip},</if>
<if test="education != null">education = #{education},</if>
<if test="accumulationFund != null">accumulation_fund = #{accumulationFund},</if>
<if test="hourse != null">hourse = #{hourse},</if>
<if test="career != null">career = #{career},</if>
<if test="huaBei != null">hua_bei = #{huaBei},</if>
<if test="baiTiao != null">bai_tiao = #{baiTiao},</if>
<if test="zhiMa != null">zhi_ma = #{zhiMa},</if>
<if test="income != null">income = #{income},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCustomerById" parameterType="java.lang.Long">
delete from customer where id = #{id}
</delete>
<delete id="deleteCustomerByIds" parameterType="java.lang.String">
delete from customer where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,340 @@
<?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.system.mapper.MerchantMapper">
<resultMap type="com.ruoyi.common.core.domain.http.Merchant" id="MerchantResult">
<result property="id" column="id" />
<result property="merchantType" column="merchant_type" />
<result property="merchantName" column="merchant_name" />
<result property="merchantDescribe" column="merchant_describe" />
<result property="merchantCompany" column="merchant_company" />
<result property="logo" column="logo" />
<result property="status" column="status" />
<result property="limitNum" column="limit_num" />
<result property="limitType" column="limit_type" />
<result property="isBalanceMonitoring" column="is_balance_monitoring" />
<result property="balanceMonitoring" column="balance_monitoring" />
<result property="ispass" column="ispass" />
<result property="customerInfoFilterType" column="customer_info_filter_type" />
<result property="channelLimitType" column="channel_limit_type" />
<result property="channelLimit" column="channel_limit" />
<result property="period" column="period" />
<result property="hitUrl" column="hit_url" />
<result property="registUrl" column="regist_url" />
<result property="ageLimitStart" column="age_limit_start" />
<result property="ageLimitEnd" column="age_limit_end" />
<result property="phoneLimit" column="phone_limit" />
<result property="label" column="label" />
<result property="merchantAuth" column="merchant_auth" />
<result property="socialSecurityNo" column="social_security_no" />
<result property="socialSecurityLow" column="social_security_low" />
<result property="socialSecurityHigh" column="social_security_high" />
<result property="carNo" column="car_no" />
<result property="carHave" column="car_have" />
<result property="guaranteeSlipLow" column="guarantee_slip_low" />
<result property="guaranteeSlipCentre" column="guarantee_slip_centre" />
<result property="guaranteeSlipHigh" column="guarantee_slip_high" />
<result property="educationMiddle" column="education_middle" />
<result property="educationHighSchool" column="education_high_school" />
<result property="educationPolytechnic" column="education_polytechnic" />
<result property="educationJuniorCollege" column="education_junior_college" />
<result property="educationUndergraduateCourse" column="education_undergraduate_course" />
<result property="educationPostgraduate" column="education_postgraduate" />
<result property="accumulationFundLow" column="accumulation_fund_low" />
<result property="accumulationFundHigh" column="accumulation_fund_high" />
<result property="hourseNo" column="hourse_no" />
<result property="hourseFullPayment" column="hourse_full_payment" />
<result property="hourseMortgaging" column="hourse_mortgaging" />
<result property="officeWorker" column="office_worker" />
<result property="civilServant" column="civil_servant" />
<result property="privatePropertyOwners" column="private_property_owners" />
<result property="selfEmployedPerson" column="self_employed_person" />
<result property="otherOccupations" column="other_occupations" />
<result property="huaBeiLow" column="hua_bei_low" />
<result property="huaBeiMiddle" column="hua_bei_middle" />
<result property="huaBeiHigh" column="hua_bei_high" />
<result property="baiTiaoLow" column="bai_tiao_low" />
<result property="baiTiaoMiddle" column="bai_tiao_middle" />
<result property="baiTiaoHigh" column="bai_tiao_high" />
<result property="zhiMa" column="zhi_ma" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<resultMap type="com.ruoyi.common.core.domain.http.Merchant" id="MerchantIdNameResult">
<result property="id" column="id" />
<result property="merchantName" column="merchant_name" />
</resultMap>
<sql id="selectMerchantVo">
select id, merchant_type, merchant_name, merchant_describe, merchant_company, logo, status, limit_num, limit_type,is_balance_monitoring,balance_monitoring,ispass, customer_info_filter_type,channel_limit_type,channel_limit,period,hit_url,regist_url,age_limit_start, age_limit_end, phone_limit,label,merchant_auth, social_security_no, social_security_low, social_security_high, car_no, car_have, guarantee_slip_low, guarantee_slip_centre, guarantee_slip_high, education_middle, education_high_school, education_polytechnic, education_junior_college, education_undergraduate_course, education_postgraduate, accumulation_fund_low, accumulation_fund_high, hourse_no, hourse_full_payment, hourse_mortgaging, office_worker, civil_servant, private_property_owners, self_employed_person, other_occupations, hua_bei_low, hua_bei_middle, hua_bei_high, bai_tiao_low, bai_tiao_middle, bai_tiao_high, zhi_ma, create_time, update_time, remark from merchant
</sql>
<sql id="findAllMerchant">
select id, merchant_name from merchant
</sql>
<select id="selectMerchantList" parameterType="com.ruoyi.common.core.domain.http.Merchant" resultMap="MerchantResult">
<include refid="selectMerchantVo"/>
<where>
<if test="merchantType != null "> and merchant_type = #{merchantType}</if>
<if test="merchantName != null and merchantName != ''"> and merchant_name like concat('%', #{merchantName}, '%')</if>
<if test="merchantDescribe != null and merchantDescribe != ''"> and merchant_describe = #{merchantDescribe}</if>
<if test="merchantCompany != null and merchantCompany != ''"> and merchant_company = #{merchantCompany}</if>
<if test="logo != null "> and logo = #{logo}</if>
<if test="status != null "> and status = #{status}</if>
<if test="limitNum != null and limitNum != ''"> and limit_num = #{limitNum}</if>
<if test="limitType != null "> and limit_type = #{limitType}</if>
<if test="isBalanceMonitoring != null "> and is_balance_monitoring = #{isBalanceMonitoring}</if>
<if test="balanceMonitoring != null "> and balance_monitoring = #{balanceMonitoring}</if>
<if test="ispass != null "> and ispass = #{ispass}</if>
<if test="customerInfoFilterType != null "> and customer_info_filter_type = #{customerInfoFilterType}</if>
<if test="channelLimitType != null "> and channel_limit_type = #{channelLimitType}</if>
<if test="channelLimit != null "> and channel_limit = #{channelLimit}</if>
<if test="period != null "> and period = #{period}</if>
<if test="hitUrl != null "> and hit_url = #{hitUrl}</if>
<if test="registUrl != null "> and regist_url = #{registUrl}</if>
<if test="ageLimitStart != null "> and age_limit_start = #{ageLimitStart}</if>
<if test="ageLimitEnd != null "> and age_limit_end = #{ageLimitEnd}</if>
<if test="phoneLimit != null and phoneLimit != ''"> and phone_limit = #{phoneLimit}</if>
<if test="label != null and label != ''"> and label = #{label}</if>
<if test="merchantAuth != null "> and merchant_auth = #{merchantAuth}</if>
<if test="socialSecurityNo != null "> and social_security_no = #{socialSecurityNo}</if>
<if test="socialSecurityLow != null "> and social_security_low = #{socialSecurityLow}</if>
<if test="socialSecurityHigh != null "> and social_security_high = #{socialSecurityHigh}</if>
<if test="carNo != null "> and car_no = #{carNo}</if>
<if test="carHave != null "> and car_have = #{carHave}</if>
<if test="guaranteeSlipLow != null "> and guarantee_slip_low = #{guaranteeSlipLow}</if>
<if test="guaranteeSlipCentre != null "> and guarantee_slip_centre = #{guaranteeSlipCentre}</if>
<if test="guaranteeSlipHigh != null "> and guarantee_slip_high = #{guaranteeSlipHigh}</if>
<if test="educationMiddle != null "> and education_middle = #{educationMiddle}</if>
<if test="educationHighSchool != null "> and education_high_school = #{educationHighSchool}</if>
<if test="educationPolytechnic != null "> and education_polytechnic = #{educationPolytechnic}</if>
<if test="educationJuniorCollege != null "> and education_junior_college = #{educationJuniorCollege}</if>
<if test="educationUndergraduateCourse != null "> and education_undergraduate_course = #{educationUndergraduateCourse}</if>
<if test="educationPostgraduate != null "> and education_postgraduate = #{educationPostgraduate}</if>
<if test="accumulationFundLow != null "> and accumulation_fund_low = #{accumulationFundLow}</if>
<if test="accumulationFundHigh != null "> and accumulation_fund_high = #{accumulationFundHigh}</if>
<if test="hourseNo != null "> and hourse_no = #{hourseNo}</if>
<if test="hourseFullPayment != null "> and hourse_full_payment = #{hourseFullPayment}</if>
<if test="hourseMortgaging != null "> and hourse_mortgaging = #{hourseMortgaging}</if>
<if test="officeWorker != null "> and office_worker = #{officeWorker}</if>
<if test="civilServant != null "> and civil_servant = #{civilServant}</if>
<if test="privatePropertyOwners != null "> and private_property_owners = #{privatePropertyOwners}</if>
<if test="selfEmployedPerson != null "> and self_employed_person = #{selfEmployedPerson}</if>
<if test="otherOccupations != null "> and other_occupations = #{otherOccupations}</if>
<if test="huaBeiLow != null "> and hua_bei_low = #{huaBeiLow}</if>
<if test="huaBeiMiddle != null "> and hua_bei_middle = #{huaBeiMiddle}</if>
<if test="huaBeiHigh != null "> and hua_bei_high = #{huaBeiHigh}</if>
<if test="baiTiaoLow != null "> and bai_tiao_low = #{baiTiaoLow}</if>
<if test="baiTiaoMiddle != null "> and bai_tiao_middle = #{baiTiaoMiddle}</if>
<if test="baiTiaoHigh != null "> and bai_tiao_high = #{baiTiaoHigh}</if>
<if test="zhiMa != null "> and zhi_ma = #{zhiMa}</if>
</where>
</select>
<select id="selectMerchantById" parameterType="java.lang.Long" resultMap="MerchantResult">
<include refid="selectMerchantVo"/>
where id = #{id}
</select>
<insert id="insertMerchant" parameterType="com.ruoyi.common.core.domain.http.Merchant" useGeneratedKeys="true" keyProperty="id">
insert into merchant
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="merchantType != null">merchant_type,</if>
<if test="merchantName != null">merchant_name,</if>
<if test="merchantDescribe != null">merchant_describe,</if>
<if test="merchantCompany != null">merchant_company,</if>
<if test="logo != null">logo,</if>
<if test="status != null">status,</if>
<if test="limitNum != null">limit_num,</if>
<if test="limitType != null">limit_type,</if>
<if test="isBalanceMonitoring != null">is_balance_monitoring,</if>
<if test="balanceMonitoring != null">balance_monitoring,</if>
<if test="ispass != null">ispass,</if>
<if test="customerInfoFilterType != null">customer_info_filter_type,</if>
<if test="channelLimitType != null">channel_limit_type,</if>
<if test="channelLimit != null">channel_limit,</if>
<if test="period != null">period,</if>
<if test="hitUrl != null">hit_url,</if>
<if test="registUrl != null">regist_url,</if>
<if test="ageLimitStart != null">age_limit_start,</if>
<if test="ageLimitEnd != null">age_limit_end,</if>
<if test="phoneLimit != null">phone_limit,</if>
<if test="label != null">label,</if>
<if test="merchantAuth != null">merchant_auth,</if>
<if test="socialSecurityNo != null">social_security_no,</if>
<if test="socialSecurityLow != null">social_security_low,</if>
<if test="socialSecurityHigh != null">social_security_high,</if>
<if test="carNo != null">car_no,</if>
<if test="carHave != null">car_have,</if>
<if test="guaranteeSlipLow != null">guarantee_slip_low,</if>
<if test="guaranteeSlipCentre != null">guarantee_slip_centre,</if>
<if test="guaranteeSlipHigh != null">guarantee_slip_high,</if>
<if test="educationMiddle != null">education_middle,</if>
<if test="educationHighSchool != null">education_high_school,</if>
<if test="educationPolytechnic != null">education_polytechnic,</if>
<if test="educationJuniorCollege != null">education_junior_college,</if>
<if test="educationUndergraduateCourse != null">education_undergraduate_course,</if>
<if test="educationPostgraduate != null">education_postgraduate,</if>
<if test="accumulationFundLow != null">accumulation_fund_low,</if>
<if test="accumulationFundHigh != null">accumulation_fund_high,</if>
<if test="hourseNo != null">hourse_no,</if>
<if test="hourseFullPayment != null">hourse_full_payment,</if>
<if test="hourseMortgaging != null">hourse_mortgaging,</if>
<if test="officeWorker != null">office_worker,</if>
<if test="civilServant != null">civil_servant,</if>
<if test="privatePropertyOwners != null">private_property_owners,</if>
<if test="selfEmployedPerson != null">self_employed_person,</if>
<if test="otherOccupations != null">other_occupations,</if>
<if test="huaBeiLow != null">hua_bei_low,</if>
<if test="huaBeiMiddle != null">hua_bei_middle,</if>
<if test="huaBeiHigh != null">hua_bei_high,</if>
<if test="baiTiaoLow != null">bai_tiao_low,</if>
<if test="baiTiaoMiddle != null">bai_tiao_middle,</if>
<if test="baiTiaoHigh != null">bai_tiao_high,</if>
<if test="zhiMa != null">zhi_ma,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="merchantType != null">#{merchantType},</if>
<if test="merchantName != null">#{merchantName},</if>
<if test="merchantDescribe != null">#{merchantDescribe},</if>
<if test="merchantCompany != null">#{merchantCompany},</if>
<if test="logo != null">#{logo},</if>
<if test="status != null">#{status},</if>
<if test="limitNum != null">#{limitNum},</if>
<if test="limitType != null">#{limitType},</if>
<if test="isBalanceMonitoring != null">#{isBalanceMonitoring},</if>
<if test="balanceMonitoring != null">#{balanceMonitoring},</if>
<if test="ispass != null">#{ispass},</if>
<if test="customerInfoFilterType != null">#{customerInfoFilterType},</if>
<if test="channelLimitType != null">#{channelLimitType},</if>
<if test="channelLimit != null">#{channelLimit},</if>
<if test="period != null">#{period},</if>
<if test="hitUrl != null">#{hitUrl},</if>
<if test="registUrl != null">#{registUrl},</if>
<if test="ageLimitStart != null">#{ageLimitStart},</if>
<if test="ageLimitEnd != null">#{ageLimitEnd},</if>
<if test="phoneLimit != null">#{phoneLimit},</if>
<if test="label != null">#{label},</if>
<if test="merchantAuth != null">#{merchantAuth},</if>
<if test="socialSecurityNo != null">#{socialSecurityNo},</if>
<if test="socialSecurityLow != null">#{socialSecurityLow},</if>
<if test="socialSecurityHigh != null">#{socialSecurityHigh},</if>
<if test="carNo != null">#{carNo},</if>
<if test="carHave != null">#{carHave},</if>
<if test="guaranteeSlipLow != null">#{guaranteeSlipLow},</if>
<if test="guaranteeSlipCentre != null">#{guaranteeSlipCentre},</if>
<if test="guaranteeSlipHigh != null">#{guaranteeSlipHigh},</if>
<if test="educationMiddle != null">#{educationMiddle},</if>
<if test="educationHighSchool != null">#{educationHighSchool},</if>
<if test="educationPolytechnic != null">#{educationPolytechnic},</if>
<if test="educationJuniorCollege != null">#{educationJuniorCollege},</if>
<if test="educationUndergraduateCourse != null">#{educationUndergraduateCourse},</if>
<if test="educationPostgraduate != null">#{educationPostgraduate},</if>
<if test="accumulationFundLow != null">#{accumulationFundLow},</if>
<if test="accumulationFundHigh != null">#{accumulationFundHigh},</if>
<if test="hourseNo != null">#{hourseNo},</if>
<if test="hourseFullPayment != null">#{hourseFullPayment},</if>
<if test="hourseMortgaging != null">#{hourseMortgaging},</if>
<if test="officeWorker != null">#{officeWorker},</if>
<if test="civilServant != null">#{civilServant},</if>
<if test="privatePropertyOwners != null">#{privatePropertyOwners},</if>
<if test="selfEmployedPerson != null">#{selfEmployedPerson},</if>
<if test="otherOccupations != null">#{otherOccupations},</if>
<if test="huaBeiLow != null">#{huaBeiLow},</if>
<if test="huaBeiMiddle != null">#{huaBeiMiddle},</if>
<if test="huaBeiHigh != null">#{huaBeiHigh},</if>
<if test="baiTiaoLow != null">#{baiTiaoLow},</if>
<if test="baiTiaoMiddle != null">#{baiTiaoMiddle},</if>
<if test="baiTiaoHigh != null">#{baiTiaoHigh},</if>
<if test="zhiMa != null">#{zhiMa},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateMerchant" parameterType="com.ruoyi.common.core.domain.http.Merchant">
update merchant
<trim prefix="SET" suffixOverrides=",">
<if test="merchantType != null">merchant_type = #{merchantType},</if>
<if test="merchantName != null">merchant_name = #{merchantName},</if>
<if test="merchantDescribe != null">merchant_describe = #{merchantDescribe},</if>
<if test="merchantCompany != null">merchant_company = #{merchantCompany},</if>
<if test="logo != null">logo = #{logo},</if>
<if test="status != null">status = #{status},</if>
<if test="limitNum != null">limit_num = #{limitNum},</if>
<if test="limitType != null">limit_type = #{limitType},</if>
<if test="isBalanceMonitoring != null">is_balance_monitoring = #{isBalanceMonitoring},</if>
<if test="balanceMonitoring != null">balance_monitoring = #{balanceMonitoring},</if>
<if test="ispass != null">ispass = #{ispass},</if>
<if test="customerInfoFilterType != null">customer_info_filter_type = #{customerInfoFilterType},</if>
<if test="channelLimitType != null">channel_limit_type = #{channelLimitType},</if>
<if test="channelLimit != null">channel_limit = #{channelLimit},</if>
<if test="period != null">period = #{period},</if>
<if test="hitUrl != null">hit_url = #{hitUrl},</if>
<if test="registUrl != null">regist_url = #{registUrl},</if>
<if test="ageLimitStart != null">age_limit_start = #{ageLimitStart},</if>
<if test="ageLimitEnd != null">age_limit_end = #{ageLimitEnd},</if>
<if test="phoneLimit != null">phone_limit = #{phoneLimit},</if>
<if test="label != null">label = #{label},</if>
<if test="merchantAuth != null">merchant_auth = #{merchantAuth},</if>
<if test="socialSecurityNo != null">social_security_no = #{socialSecurityNo},</if>
<if test="socialSecurityLow != null">social_security_low = #{socialSecurityLow},</if>
<if test="socialSecurityHigh != null">social_security_high = #{socialSecurityHigh},</if>
<if test="carNo != null">car_no = #{carNo},</if>
<if test="carHave != null">car_have = #{carHave},</if>
<if test="guaranteeSlipLow != null">guarantee_slip_low = #{guaranteeSlipLow},</if>
<if test="guaranteeSlipCentre != null">guarantee_slip_centre = #{guaranteeSlipCentre},</if>
<if test="guaranteeSlipHigh != null">guarantee_slip_high = #{guaranteeSlipHigh},</if>
<if test="educationMiddle != null">education_middle = #{educationMiddle},</if>
<if test="educationHighSchool != null">education_high_school = #{educationHighSchool},</if>
<if test="educationPolytechnic != null">education_polytechnic = #{educationPolytechnic},</if>
<if test="educationJuniorCollege != null">education_junior_college = #{educationJuniorCollege},</if>
<if test="educationUndergraduateCourse != null">education_undergraduate_course = #{educationUndergraduateCourse},</if>
<if test="educationPostgraduate != null">education_postgraduate = #{educationPostgraduate},</if>
<if test="accumulationFundLow != null">accumulation_fund_low = #{accumulationFundLow},</if>
<if test="accumulationFundHigh != null">accumulation_fund_high = #{accumulationFundHigh},</if>
<if test="hourseNo != null">hourse_no = #{hourseNo},</if>
<if test="hourseFullPayment != null">hourse_full_payment = #{hourseFullPayment},</if>
<if test="hourseMortgaging != null">hourse_mortgaging = #{hourseMortgaging},</if>
<if test="officeWorker != null">office_worker = #{officeWorker},</if>
<if test="civilServant != null">civil_servant = #{civilServant},</if>
<if test="privatePropertyOwners != null">private_property_owners = #{privatePropertyOwners},</if>
<if test="selfEmployedPerson != null">self_employed_person = #{selfEmployedPerson},</if>
<if test="otherOccupations != null">other_occupations = #{otherOccupations},</if>
<if test="huaBeiLow != null">hua_bei_low = #{huaBeiLow},</if>
<if test="huaBeiMiddle != null">hua_bei_middle = #{huaBeiMiddle},</if>
<if test="huaBeiHigh != null">hua_bei_high = #{huaBeiHigh},</if>
<if test="baiTiaoLow != null">bai_tiao_low = #{baiTiaoLow},</if>
<if test="baiTiaoMiddle != null">bai_tiao_middle = #{baiTiaoMiddle},</if>
<if test="baiTiaoHigh != null">bai_tiao_high = #{baiTiaoHigh},</if>
<if test="zhiMa != null">zhi_ma = #{zhiMa},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteMerchantById" parameterType="java.lang.Long">
delete from merchant where id = #{id}
</delete>
<delete id="deleteMerchantByIds" parameterType="java.lang.String">
delete from merchant where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="findAllMerchantList" resultMap="MerchantIdNameResult">
<include refid="findAllMerchant"/>
</select>
</mapper>

View File

@@ -0,0 +1,48 @@
package com.ruoyi.system;
import cn.hutool.json.JSONUtil;
import com.ruoyi.common.sms.component.SmsComponent;
import com.ruoyi.common.sms.entity.response.SmsResponse;
import org.assertj.core.util.Maps;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.HashMap;
import java.util.Map;
import static cn.hutool.extra.spring.SpringUtil.getActiveProfile;
@SpringBootTest
public class RuoYiSystemApplicationTest {
@Autowired
SmsComponent smsComponent;
@Test
public void testGroupMsg(){
String mobile = "15826189779,15826189779,17382317154";
String content = "123456";
SmsResponse groupMsg = smsComponent.sendGroupMsg(mobile, content);
System.out.println(JSONUtil.toJsonStr(groupMsg));
}
@Test
public void testP2pMsg(){
String content = "123456";
Map<String, String> params = new HashMap<>();
params.put("15826189779", content);
SmsResponse sendP2PMsg = smsComponent.sendP2PMsg(params);
System.out.println(JSONUtil.toJsonStr(sendP2PMsg));
}
@Test
public void getActivePro(){
String activeProfile = getActiveProfile();
System.out.println(activeProfile);
}
}