diff --git a/pom.xml b/pom.xml index 9685086b..628a00da 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,7 @@ 2.14.4 3.5.2 1.18.30 + 5.8.26 @@ -219,7 +220,7 @@ ${ruoyi.version} - com.baomidou + com.baomidou mybatis-plus-boot-starter ${mybatis-plus.version} @@ -228,6 +229,11 @@ lombok ${lombok.version} + + cn.hutool + hutool-all + ${hutools.version} + diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteCustomerService.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteCustomerService.java new file mode 100644 index 00000000..e895d06f --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteCustomerService.java @@ -0,0 +1,55 @@ +package com.ruoyi.system.api; + +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.system.api.factory.RemoteCustomerFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +/** + * 用户服务 + * + * @author ruoyi + */ +@FeignClient(contextId = "remoteCustomerService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteCustomerFallbackFactory.class) +public interface RemoteCustomerService +{ + /** + * 通过用户名查询用户信息 + * + * @param id 用户名 + * @param source 请求来源 + * @return 结果 + */ + @GetMapping("/customer/{id}") + public R getCustomerInfoById(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** + * 通过手机号MD5查询用户信息 + * + * @param phoneMD5 用户名 + * @param source 请求来源 + * @return 结果 + */ + @GetMapping("/customer/getByMd5") + public R getCustomerInfoByPhoneMd5(@RequestParam("phoneMD5")String phoneMD5, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** + * 通过手机号MD5更新用户信息 + * + * @param customer 用户 + * @return 结果 + */ + @PostMapping("/customer/updateByPhoneMd5") + public R updateByPhoneMd5(Customer customer ,@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** + * 新增客户信息 + * @return + */ + @PostMapping("/customer/addNewCustomer") + public R add(@RequestBody Customer customer,@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCustomerFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCustomerFallbackFactory.java new file mode 100644 index 00000000..3501b1b9 --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCustomerFallbackFactory.java @@ -0,0 +1,50 @@ +package com.ruoyi.system.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Customer; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.system.api.RemoteCustomerService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * 用户服务降级处理 + * + * @author ruoyi + */ +@Component +@Slf4j +public class RemoteCustomerFallbackFactory implements FallbackFactory +{ + @Override + public RemoteCustomerService create(Throwable throwable) + { + log.error("用户服务调用失败:{}", throwable.getMessage()); + return new RemoteCustomerService() + { + @Override + public R getCustomerInfoById(Long id, String source) + { + return R.fail("获取用户失败:" + throwable.getMessage()); + } + + @Override + public R getCustomerInfoByPhoneMd5(String phoneMD5, String source) { + log.info("查询用户失败:{}",throwable.getMessage()); + return R.fail("查询用户失败:" + throwable.getMessage()); + } + + @Override + public R updateByPhoneMd5(Customer customer, String source) { + return R.fail("更新用户失败:" + throwable.getMessage()); + } + + @Override + public R add(Customer customer, String source) { + log.info("新增用户失败:{}",throwable.getMessage()); + return R.fail("新增用户失败"); + } + }; + } +} diff --git a/ruoyi-common/ruoyi-common-core/pom.xml b/ruoyi-common/ruoyi-common-core/pom.xml index 151b9ed4..e1e311de 100644 --- a/ruoyi-common/ruoyi-common-core/pom.xml +++ b/ruoyi-common/ruoyi-common-core/pom.xml @@ -106,7 +106,15 @@ javax.servlet javax.servlet-api + + org.projectlombok + lombok + + + cn.hutool + hutool-all + diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/CacheConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/CacheConstants.java index e2df52b6..a3f6cc45 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/CacheConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/CacheConstants.java @@ -56,4 +56,20 @@ public class CacheConstants * 登录IP黑名单 cache key */ public static final String SYS_LOGIN_BLACKIPLIST = SYS_CONFIG_KEY + "sys.login.blackIPList"; + + + public static final String PROJET = "xymz:"; + /** + * 渠道redis缓存键 + */ + public static final String CHANNEL_ID = PROJET + "channel:id:"; + /** + * 渠道redis缓存键 + */ + public static final String CHANNEL_SIGN = PROJET + "channel:sign:"; + + /** + * 商户redis缓存键 + */ + public static final String MERCHANT = PROJET + "merchant:key:"; } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Customer.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Customer.java new file mode 100644 index 00000000..eda92b13 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/http/Customer.java @@ -0,0 +1,121 @@ +package com.ruoyi.common.core.domain.http; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 客户信息对象 customer + * + * @author ruoyi + * @date 2024-09-15 + */ +@Data +public class Customer extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 年龄 */ + @Excel(name = "年龄") + private Integer age; + + /** 0 男 1 女 */ + @Excel(name = "0 男 1 女") + private Integer sex; + + /** 昵称 */ + @Excel(name = "昵称") + private String name; + + /** 真实姓名 */ + @Excel(name = "真实姓名") + private String acturlName; + + /** 手机号 */ + @Excel(name = "手机号") + private String phone; + + /** 手机号MD5 */ + @Excel(name = "手机号MD5") + private String phoneMd5; + + /** 0 未实名 1已实名 */ + @Excel(name = "0 未实名 1已实名") + private Boolean isAuth; + + /** 城市 */ + @Excel(name = "城市") + private String city; + + /** 城市编码 */ + @Excel(name = "城市编码") + private Integer cityCode; + + /** 首次登录时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "首次登录时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date firstLoginTime; + + /** 最后登录时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date lastLoginTime; + + /** 最后登录IP */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "最后登录IP", width = 30, dateFormat = "yyyy-MM-dd") + private Date lastLoginIp; + + /** 用户状态 1正常 2异常 可继续扩展 */ + @Excel(name = "用户状态 1正常 2异常 可继续扩展") + private Integer status; + + /** 无社保 */ + @Excel(name = "社保") + private Integer socialSecurity; + + /** 无车 */ + @Excel(name = "车") + private Integer car; + + /** 保单缴纳不满一年 */ + @Excel(name = "保单") + private Integer guaranteeSlip; + + /** 初中 */ + @Excel(name = "学历") + private Integer education; + + /** 公积金未满6个月 */ + @Excel(name = "公积金") + private Integer accumulationFund; + + /** 本地无房 */ + @Excel(name = "房") + private Integer hourse; + + /** 上班族 */ + @Excel(name = "职业") + private Integer career; + + + /** 花呗5000以下 */ + @Excel(name = "花呗") + private Integer huaBei; + + /** 白条5000以下 */ + @Excel(name = "白条") + private Integer baiTiao; + + /** 芝麻分 */ + @Excel(name = "芝麻分") + private Integer zhiMa; + +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/SecureUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/SecureUtils.java new file mode 100644 index 00000000..ac5a7a23 --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/SecureUtils.java @@ -0,0 +1,504 @@ +package com.ruoyi.common.core.utils; + + +import com.ruoyi.common.core.constant.HttpStatus; +import lombok.extern.slf4j.Slf4j; + +import javax.crypto.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.Base64; +import java.util.Objects; +import java.util.Random; +import java.util.regex.Pattern; + +/** + * @author LiYu + * @ClassName SecureUtil.java + * @Description 加解密工具类 + * @createTime 2024年05月20日 11:04:00 + */ +@Slf4j +public class SecureUtils { + /** + * md5加密 + */ + public static class Md5Util { + + /** + * 判断是否为md5加密 + * + * @param str 字符串 + * @return 结果 + */ + public static boolean isMd5(String str) { + return str.matches("^[a-f0-9]{32}$"); + } + + /** + * MD5加密并转大写 + * + * @param str 字符串 + * @return 结果 + */ + public static String md5ToUpperCase(String str) { + return StringUtils.hasText(str) ? isMd5(str) ? str : cn.hutool.crypto.SecureUtil.md5(str).toUpperCase() : null; + } + + /** + * MD5加密并转小写 + * + * @param str 字符串 + * @return 结果 + */ + public static String md5ToLowerCase(String str) { + return StringUtils.hasText(str) ? isMd5(str) ? str : cn.hutool.crypto.SecureUtil.md5(str).toLowerCase() : null; + } + + /** + * MD5加密 + * + * @param str 字符串 + * @return 结果 + */ + public static String md5(String str) { + return StringUtils.hasText(str) ? isMd5(str) ? str : cn.hutool.crypto.SecureUtil.md5(str) : null; + } + } + + /** + * des加密 + */ + public static class DesUtil { + /** + * 加密key + */ + public static final String KEY = "_@Ks`Y*9jLb.hvho}C;GwDpw"; + /** + * 偏移量 + */ + public static final String IV = "2%8iTpSi"; + + /** + * 创建加密对象 + * + * @param iv 偏移量 + * @param mode 模式 + * @return 结果 + */ + private static Cipher createCipher(String iv, int mode) throws NoSuchAlgorithmException, NoSuchPaddingException, + InvalidKeyException, InvalidAlgorithmParameterException { + byte[] key = KEY.getBytes(); + Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); + IvParameterSpec ivParameterSpec = new IvParameterSpec(iv.getBytes()); + cipher.init(mode, new SecretKeySpec(key, "DESede"), ivParameterSpec); + return cipher; + } + + /** + * 加密 + * + * @param data 数据 + * @param iv 偏移量 + * @return 结果 + */ + public static String encrypt(String data, String iv) { + try { + Cipher cipher = createCipher(iv, Cipher.ENCRYPT_MODE); + return URLEncoder.encode(Base64.getEncoder().encodeToString(cipher.doFinal(data.getBytes())), "UTF-8"); + } catch (Exception e) { + log.error("加密失败", e); + } + return null; + } + + /** + * 加密 + * + * @param data 数据 + * @return 结果 + */ + public static String encrypt(String data) { + return encrypt(data, IV); + } + + /** + * 解密 + * + * @param data 数据 + * @param iv 偏移量 + * @return 结果 + */ + public static String decrypt(String data, String iv) { + try { + Cipher cipher = createCipher(iv, Cipher.DECRYPT_MODE); + return new String(cipher.doFinal(Base64.getDecoder().decode(URLDecoder.decode(data, "UTF-8")))); + } catch (Exception e) { + log.error("解密失败", e); + } + return null; + } + + /** + * 解密 + * + * @param data 数据 + * @return 结果 + */ + public static String decrypt(String data) { + return decrypt(data, IV); + } + + } + + /** + * AES加解密 + */ + public static class AesUtil { + /** + * 加密模式之 ECB,算法/模式/补码方式 + */ + public static final String AES_ECB = "AES/ECB/PKCS5Padding"; + + /** + * 加密模式之 CBC,算法/模式/补码方式 + */ + public static final String AES_CBC = "AES/CBC/PKCS5Padding"; + + /** + * 加密模式之 CFB,算法/模式/补码方式 + */ + public static final String AES_CFB = "AES/CFB/PKCS5Padding"; + + /** + * AES 中的 IV 必须是 16 字节(128位)长 + */ + public static final Integer IV_LENGTH = 16; + + /*** + * 空校验 + * @param str 需要判断的值 + */ + public static boolean isEmpty(Object str) { + return null == str || "".equals(str); + } + + /*** + * String 转 byte + * @param str 需要转换的字符串 + */ + public static byte[] getBytes(String str) { + if (isEmpty(str)) { + return null; + } + + try { + return str.getBytes(StandardCharsets.UTF_8); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /*** + * 初始化向量(IV),它是一个随机生成的字节数组,用于增加加密和解密的安全性 + */ + public static String getIv() { + String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + Random random = new Random(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < IV_LENGTH; i++) { + int number = random.nextInt(str.length()); + sb.append(str.charAt(number)); + } + return sb.toString(); + } + + + /*** + * 获取一个 AES 密钥规范 + */ + public static SecretKeySpec getSecretKeySpec(String key) { + return new SecretKeySpec(Objects.requireNonNull(getBytes(key)), "AES"); + } + + /** + * 加密 - 模式 ECB + * + * @param text 需要加密的文本内容 + * @param key 加密的密钥 key + */ + public static String encrypt(String text, String key) { + if (isEmpty(text) || isEmpty(key)) { + return null; + } + try { + // 创建AES加密器 + Cipher cipher = Cipher.getInstance(AES_ECB); + SecretKeySpec secretKeySpec = getSecretKeySpec(key); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); + // 加密字节数组 + byte[] encryptedBytes = cipher.doFinal(Objects.requireNonNull(getBytes(text))); + // 将密文转换为 Base64 编码字符串 + return Base64.getEncoder().encodeToString(encryptedBytes); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + /** + * 解密 - 模式 ECB + * + * @param text 需要解密的文本内容 + * @param key 解密的密钥 key + */ + public static String decrypt(String text, String key) { + if (isEmpty(text) || isEmpty(key)) { + return null; + } + // 将密文转换为16字节的字节数组 + byte[] textBytes = Base64.getDecoder().decode(text); + try { + // 创建AES加密器 + Cipher cipher = Cipher.getInstance(AES_ECB); + SecretKeySpec secretKeySpec = getSecretKeySpec(key); + cipher.init(Cipher.DECRYPT_MODE, secretKeySpec); + // 解密字节数组 + byte[] decryptedBytes = cipher.doFinal(textBytes); + // 将明文转换为字符串 + return new String(decryptedBytes, StandardCharsets.UTF_8); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 加密 - 自定义加密模式 + * + * @param text 需要加密的文本内容 + * @param key 加密的密钥 key + * @param iv 初始化向量 + * @param mode 加密模式 + */ + public static String encrypt(String text, String key, String iv, String mode) { + if (isEmpty(text) || isEmpty(key) || isEmpty(iv)) { + return null; + } + try { + // 创建AES加密器 + Cipher cipher = Cipher.getInstance(mode); + SecretKeySpec secretKeySpec = getSecretKeySpec(key); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(Objects.requireNonNull(getBytes(iv)))); + // 加密字节数组 + byte[] encryptedBytes = cipher.doFinal(Objects.requireNonNull(getBytes(text))); + // 将密文转换为 Base64 编码字符串 + return Base64.getEncoder().encodeToString(encryptedBytes); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 加密 + * + * @param content 待加密内容 + * @param password 加密密钥 + * @return 加密后的内容 + */ + public static String AesEncode(String content, String password) { + try { + byte[] encryptResult = encryptByte(content, password); + return Base64Util.encode(encryptResult); + } catch (Exception e) { + log.error("加密出现问题!", e); + e.printStackTrace(); + } + return null; + } + + /** + * 解密 + * + * @param content 待解密内容 + * @param password 解密密钥 + * @return 解密后的内容 + */ + public static String AesDecode(String content, String password) { + try { + byte[] decryptResult = decryptByte(Base64Util.decodeToByteArray(content), password); + return new String(decryptResult, StandardCharsets.UTF_8); + } catch (Exception e) { + log.error("解密出现问题!", e); + return null; + } + } + + /** + * 加密 - 模式 CBC + * + * @param text 需要加密的文本内容 + * @param key 加密的密钥 key + * @param iv 初始化向量 + * @return 加密后的内容 + */ + public static String encryptCbc(String text, String key, String iv) { + return encrypt(text, key, iv, AES_CBC); + } + + /** + * 解密 - 自定义加密模式 + * + * @param text 需要解密的文本内容 + * @param key 解密的密钥 key + * @param iv 初始化向量 + * @param mode 加密模式 + */ + public static String decrypt(String text, String key, String iv, String mode) { + if (isEmpty(text) || isEmpty(key) || isEmpty(iv)) { + return null; + } + // 将密文转换为16字节的字节数组 + byte[] textBytes = Base64.getDecoder().decode(text); + try { + // 创建AES加密器 + Cipher cipher = Cipher.getInstance(mode); + SecretKeySpec secretKeySpec = getSecretKeySpec(key); + cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(Objects.requireNonNull(getBytes(iv)))); + // 解密字节数组 + byte[] decryptedBytes = cipher.doFinal(textBytes); + // 将明文转换为字符串 + return new String(decryptedBytes, StandardCharsets.UTF_8); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 解密 + * + * @param content 待解密内容 + * @param password 解密密钥 + * @return 解密后的内容 + */ + private static byte[] decryptByte(byte[] content, String password) + throws Exception { + KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); + SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); + secureRandom.setSeed(password.getBytes()); + keyGenerator.init(128, secureRandom); + SecretKey secretKey = keyGenerator.generateKey(); + byte[] enCodeFormat = secretKey.getEncoded(); + SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES"); + Cipher cipher = Cipher.getInstance("AES"); + cipher.init(Cipher.DECRYPT_MODE, key); + return cipher.doFinal(content); + } + + /** + * 加密 + * + * @param content 需要加密的内容 + * @param password 加密密码 + * @return 加密后的字节数组 + */ + private static byte[] encryptByte(String content, String password) + throws Exception { + KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); + SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); + secureRandom.setSeed(password.getBytes()); + keyGenerator.init(128, secureRandom); + SecretKey secretKey = keyGenerator.generateKey(); + byte[] enCodeFormat = secretKey.getEncoded(); + SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES"); + Cipher cipher = Cipher.getInstance("AES");// 创建密码器 + byte[] byteContent = content.getBytes(StandardCharsets.UTF_8); + cipher.init(Cipher.ENCRYPT_MODE, key); + return cipher.doFinal(byteContent); + } + + /** + * 解密 - 模式 CBC + * + * @param text 需要加密的文本内容 + * @param key 加密的密钥 key + * @param iv 初始化向量 + * @return 加密后的内容 + */ + public static String decryptCbc(String text, String key, String iv) { + return decrypt(text, key, iv, AES_CBC); + } + + + + + } + + + /** + * Base64加解密 + */ + public static class Base64Util { + /** + * 编码字符串为Base64 + * + * @param input 需要编码的字符串 + * @return 编码后的Base64字符串 + */ + public static String encode(String input) { + return Base64.getEncoder().encodeToString(input.getBytes()); + } + + /** + * 从Base64编码解码为字符串 + * + * @param input Base64编码的字符串 + * @return 解码后的字符串 + */ + public static String decode(String input) { + byte[] decodedBytes = Base64.getDecoder().decode(input); + return new String(decodedBytes); + } + + /** + * 编码字节数组为Base64字符串 + * + * @param input 需要编码的字节数组 + * @return 编码后的Base64字符串 + */ + public static String encode(byte[] input) { + return Base64.getEncoder().encodeToString(input); + } + + /** + * 解码Base64字符串为字节数组 + * + * @param input Base64编码的字符串 + * @return 解码后的字节数组 + */ + public static byte[] decodeToByteArray(String input) { + return Base64.getDecoder().decode(input); + } + + /** + * 判断是否为Base64编码 + * + * @param str 字符串 + * @return 结果 + */ + public static boolean isBase64(String str) { + String base64Pattern = "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$"; + return Pattern.matches(base64Pattern, str); + } + } + + public static void main(String[] args) { + + } +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/match/MatchQualification.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/match/MatchQualification.java new file mode 100644 index 00000000..fdd96a0b --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/match/MatchQualification.java @@ -0,0 +1,9 @@ +package com.ruoyi.common.core.utils.match; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class MatchQualification { + + +} diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/ISysPublicHalfService.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/ISysPublicHalfService.java index 22392d6a..4dcc27cf 100644 --- a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/ISysPublicHalfService.java +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/ISysPublicHalfService.java @@ -1,6 +1,7 @@ package com.ruoyi.btc.service; import com.ruoyi.btc.domain.ComPublicHalfDto; +import com.ruoyi.common.core.web.domain.AjaxResult; /** * 文件上传接口 @@ -14,18 +15,18 @@ public interface ISysPublicHalfService * 半流程通用撞库接口 * @param comPublicHalfDto */ - void check(ComPublicHalfDto comPublicHalfDto); + AjaxResult check(ComPublicHalfDto comPublicHalfDto); /** * 半流程通用进件 * @param comPublicHalfDto */ - void input(ComPublicHalfDto comPublicHalfDto); + AjaxResult input(ComPublicHalfDto comPublicHalfDto); /** * 渠道查询订单是否成功 * @param comPublicHalfDto */ - void checkOrder(ComPublicHalfDto comPublicHalfDto); + AjaxResult checkOrder(ComPublicHalfDto comPublicHalfDto); } diff --git a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/impl/SysPublicHalfServiceImpl.java b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/impl/SysPublicHalfServiceImpl.java index a42fb729..05849b1f 100644 --- a/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/impl/SysPublicHalfServiceImpl.java +++ b/ruoyi-modules/ruoyi-btc/src/main/java/com/ruoyi/btc/service/impl/SysPublicHalfServiceImpl.java @@ -1,10 +1,23 @@ package com.ruoyi.btc.service.impl; +import cn.hutool.core.bean.BeanUtil; +import com.alibaba.fastjson.JSONObject; import com.ruoyi.btc.domain.ComPublicHalfDto; +import com.ruoyi.btc.domain.CustomerInfoDto; import com.ruoyi.btc.service.ISysPublicHalfService; +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Customer; +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.system.api.RemoteCustomerService; +import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; +import java.util.Date; + /** * 本地文件存储 * @@ -12,28 +25,104 @@ import org.springframework.stereotype.Service; */ @Primary @Service +@RequiredArgsConstructor public class SysPublicHalfServiceImpl implements ISysPublicHalfService { - + private final RemoteCustomerService remoteCustomerService; /** * 半流程通用撞库 * @param comPublicHalfDto */ @Override - public void check(ComPublicHalfDto comPublicHalfDto) { + public AjaxResult check(ComPublicHalfDto comPublicHalfDto) { //校验 IP地址是否正常 渠道标识是否存在 数据是否为空 - + if (StringUtils.isEmpty(comPublicHalfDto.getChannelSignature())){ + 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.setActurlName(customerInfoDto.getNameMd5()); + customer.setFirstLoginTime(new Date()); + customer.setLastLoginTime(new Date()); + customer.setIsAuth(false); + customer.setStatus(2); + R customerInfoByPhoneMd5 = remoteCustomerService.getCustomerInfoByPhoneMd5(customerInfoDto.getPhoneMd5(), SecurityConstants.INNER); + if (customerInfoByPhoneMd5.getCode()==200){ + remoteCustomerService.updateByPhoneMd5(customer,SecurityConstants.INNER); + }else { + remoteCustomerService.add(customer,SecurityConstants.INNER); + } //匹配资质 造轮子 返回多个符合的商户 + //结束返回上游结果 + return null; + } + /** + * 校验参数 + * @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; } /** @@ -41,7 +130,7 @@ public class SysPublicHalfServiceImpl implements ISysPublicHalfService * @param comPublicHalfDto */ @Override - public void input(ComPublicHalfDto comPublicHalfDto) { + public AjaxResult input(ComPublicHalfDto comPublicHalfDto) { //校验 IP地址是否正常 渠道标识是否存在 数据是否为空 //解密为customerInfoDto @@ -57,7 +146,7 @@ public class SysPublicHalfServiceImpl implements ISysPublicHalfService //返回渠道绑定的注册页拼接token //返回上游信息 - + return null; } /** @@ -65,7 +154,7 @@ public class SysPublicHalfServiceImpl implements ISysPublicHalfService * @param comPublicHalfDto */ @Override - public void checkOrder(ComPublicHalfDto comPublicHalfDto) { + public AjaxResult checkOrder(ComPublicHalfDto comPublicHalfDto) { //根据手机号MD5渠道标识 查询是否成功 //失败直接失败 @@ -73,5 +162,6 @@ public class SysPublicHalfServiceImpl implements ISysPublicHalfService //成功抽奖 按扣量比抽 //返回是否成功 + return null; } } diff --git a/ruoyi-modules/ruoyi-system/pom.xml b/ruoyi-modules/ruoyi-system/pom.xml index 0d9795a7..b5708a5f 100644 --- a/ruoyi-modules/ruoyi-system/pom.xml +++ b/ruoyi-modules/ruoyi-system/pom.xml @@ -71,6 +71,11 @@ ruoyi-common-swagger + + com.baomidou + mybatis-plus-boot-starter + + diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CustomerController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CustomerController.java index a4774697..e562e212 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CustomerController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CustomerController.java @@ -1,21 +1,16 @@ package com.ruoyi.system.controller; import java.util.List; -import java.io.IOException; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.core.constant.SecurityConstants; +import com.ruoyi.common.core.domain.R; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +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.system.domain.Customer; +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; @@ -70,6 +65,40 @@ public class CustomerController extends BaseController return success(customerService.selectCustomerById(id)); } + /** + * 通过手机号MD5查询用户信息 + * + * @param phoneMD5 用户名 + * @return 结果 + */ + @GetMapping("/getByMd5") + public R getCustomerInfoByPhoneMd5(@RequestParam("phoneMD5")String phoneMD5){ + return customerService.selectByPhoneMd5(phoneMD5); + } + + /** + * 通过手机号MD5更新用户信息 + * + * @param customer 用户 + * @return 结果 + */ + @PostMapping("/updateByPhoneMd5") + public R updateByPhoneMd5(Customer customer ,@RequestHeader(SecurityConstants.FROM_SOURCE) String source){ + return customerService.updateByPhoneMd5(customer); + } + + /** + * 新增客户信息 + * @return + */ + @PostMapping("/customer/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(); + } /** * 新增客户信息 */ diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/Customer.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/Customer.java deleted file mode 100644 index cce4f58f..00000000 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/Customer.java +++ /dev/null @@ -1,660 +0,0 @@ -package com.ruoyi.system.domain; - -import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.core.annotation.Excel; -import com.ruoyi.common.core.web.domain.BaseEntity; - -/** - * 客户信息对象 customer - * - * @author ruoyi - * @date 2024-09-15 - */ -public class Customer extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** $column.columnComment */ - private Long id; - - /** 年龄 */ - @Excel(name = "年龄") - private Long age; - - /** 0 男 1 女 */ - @Excel(name = "0 男 1 女") - private Long sex; - - /** 昵称 */ - @Excel(name = "昵称") - private String name; - - /** 真实姓名 */ - @Excel(name = "真实姓名") - private String acturlName; - - /** 手机号 */ - @Excel(name = "手机号") - private String phone; - - /** 手机号MD5 */ - @Excel(name = "手机号MD5") - private String phoneMd5; - - /** 0 未实名 1已实名 */ - @Excel(name = "0 未实名 1已实名") - private Long isAuth; - - /** 城市 */ - @Excel(name = "城市") - private String city; - - /** 城市编码 */ - @Excel(name = "城市编码") - private Long cityCode; - - /** 首次登录时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "首次登录时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date firstLoginTime; - - /** 最后登录时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date lastLoginTime; - - /** 最后登录IP */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "最后登录IP", width = 30, dateFormat = "yyyy-MM-dd") - private Date lastLoginIp; - - /** 用户状态 1正常 2异常 可继续扩展 */ - @Excel(name = "用户状态 1正常 2异常 可继续扩展") - private Long status; - - /** 无社保 */ - @Excel(name = "无社保") - private Long socialSecurityNo; - - /** 社保未满6个月 */ - @Excel(name = "社保未满6个月") - private Long socialSecurityLow; - - /** 社保6个月以上 */ - @Excel(name = "社保6个月以上") - private Long socialSecurityHigh; - - /** 无车 */ - @Excel(name = "无车") - private Long carNo; - - /** 有车 */ - @Excel(name = "有车") - private Long carHave; - - /** 保单缴纳不满一年 */ - @Excel(name = "保单缴纳不满一年") - private Long guaranteeSlipLow; - - /** 保单缴纳一年以上 */ - @Excel(name = "保单缴纳一年以上") - private Long guaranteeSlipCentre; - - /** 保单缴纳2年以上 */ - @Excel(name = "保单缴纳2年以上") - private Long guaranteeSlipHigh; - - /** 初中 */ - @Excel(name = "初中") - private Long educationMiddle; - - /** 高中 */ - @Excel(name = "高中") - private Long educationHighSchool; - - /** 中专 */ - @Excel(name = "中专") - private Long educationPolytechnic; - - /** 大专 */ - @Excel(name = "大专") - private Long educationJuniorCollege; - - /** 本科 */ - @Excel(name = "本科") - private Long educationUndergraduateCourse; - - /** 研究生及以上 */ - @Excel(name = "研究生及以上") - private Long educationPostgraduate; - - /** 公积金未满6个月 */ - @Excel(name = "公积金未满6个月") - private Long accumulationFundLow; - - /** 公积金满6个月以上 */ - @Excel(name = "公积金满6个月以上") - private Long accumulationFundHigh; - - /** 本地无房 */ - @Excel(name = "本地无房") - private Long hourseNo; - - /** 本地全款房 */ - @Excel(name = "本地全款房") - private Long hourseFullPayment; - - /** 本地按揭 */ - @Excel(name = "本地按揭") - private Long hourseMortgaging; - - /** 上班族 */ - @Excel(name = "上班族") - private Long officeWorker; - - /** 公务员 */ - @Excel(name = "公务员") - private Long civilServant; - - /** 私营业主 */ - @Excel(name = "私营业主") - private Long privatePropertyOwners; - - /** 个体户 */ - @Excel(name = "个体户") - private Long selfEmployedPerson; - - /** 其他职业 */ - @Excel(name = "其他职业") - private Long otherOccupations; - - /** 花呗5000以下 */ - @Excel(name = "花呗5000以下") - private Long huaBeiLow; - - /** 花呗5000-10000 */ - @Excel(name = "花呗5000-10000") - private Long huaBeiMiddle; - - /** 花呗10000以上 */ - @Excel(name = "花呗10000以上") - private Long huaBeiHigh; - - /** 白条5000以下 */ - @Excel(name = "白条5000以下") - private Long baiTiaoLow; - - /** 白条5000-10000 */ - @Excel(name = "白条5000-10000") - private Long baiTiaoMiddle; - - /** 白条10000以上 */ - @Excel(name = "白条10000以上") - private Long baiTiaoHigh; - - /** 芝麻分 */ - @Excel(name = "芝麻分") - private Long zhiMa; - - public void setId(Long id) - { - this.id = id; - } - - public Long getId() - { - return id; - } - public void setAge(Long age) - { - this.age = age; - } - - public Long getAge() - { - return age; - } - public void setSex(Long sex) - { - this.sex = sex; - } - - public Long getSex() - { - return sex; - } - public void setName(String name) - { - this.name = name; - } - - public String getName() - { - return name; - } - public void setActurlName(String acturlName) - { - this.acturlName = acturlName; - } - - public String getActurlName() - { - return acturlName; - } - public void setPhone(String phone) - { - this.phone = phone; - } - - public String getPhone() - { - return phone; - } - public void setPhoneMd5(String phoneMd5) - { - this.phoneMd5 = phoneMd5; - } - - public String getPhoneMd5() - { - return phoneMd5; - } - public void setIsAuth(Long isAuth) - { - this.isAuth = isAuth; - } - - public Long getIsAuth() - { - return isAuth; - } - public void setCity(String city) - { - this.city = city; - } - - public String getCity() - { - return city; - } - public void setCityCode(Long cityCode) - { - this.cityCode = cityCode; - } - - public Long getCityCode() - { - return cityCode; - } - public void setFirstLoginTime(Date firstLoginTime) - { - this.firstLoginTime = firstLoginTime; - } - - public Date getFirstLoginTime() - { - return firstLoginTime; - } - public void setLastLoginTime(Date lastLoginTime) - { - this.lastLoginTime = lastLoginTime; - } - - public Date getLastLoginTime() - { - return lastLoginTime; - } - public void setLastLoginIp(Date lastLoginIp) - { - this.lastLoginIp = lastLoginIp; - } - - public Date getLastLoginIp() - { - return lastLoginIp; - } - public void setStatus(Long status) - { - this.status = status; - } - - public Long getStatus() - { - return status; - } - public void setSocialSecurityNo(Long socialSecurityNo) - { - this.socialSecurityNo = socialSecurityNo; - } - - public Long getSocialSecurityNo() - { - return socialSecurityNo; - } - public void setSocialSecurityLow(Long socialSecurityLow) - { - this.socialSecurityLow = socialSecurityLow; - } - - public Long getSocialSecurityLow() - { - return socialSecurityLow; - } - public void setSocialSecurityHigh(Long socialSecurityHigh) - { - this.socialSecurityHigh = socialSecurityHigh; - } - - public Long getSocialSecurityHigh() - { - return socialSecurityHigh; - } - public void setCarNo(Long carNo) - { - this.carNo = carNo; - } - - public Long getCarNo() - { - return carNo; - } - public void setCarHave(Long carHave) - { - this.carHave = carHave; - } - - public Long getCarHave() - { - return carHave; - } - public void setGuaranteeSlipLow(Long guaranteeSlipLow) - { - this.guaranteeSlipLow = guaranteeSlipLow; - } - - public Long getGuaranteeSlipLow() - { - return guaranteeSlipLow; - } - public void setGuaranteeSlipCentre(Long guaranteeSlipCentre) - { - this.guaranteeSlipCentre = guaranteeSlipCentre; - } - - public Long getGuaranteeSlipCentre() - { - return guaranteeSlipCentre; - } - public void setGuaranteeSlipHigh(Long guaranteeSlipHigh) - { - this.guaranteeSlipHigh = guaranteeSlipHigh; - } - - public Long getGuaranteeSlipHigh() - { - return guaranteeSlipHigh; - } - public void setEducationMiddle(Long educationMiddle) - { - this.educationMiddle = educationMiddle; - } - - public Long getEducationMiddle() - { - return educationMiddle; - } - public void setEducationHighSchool(Long educationHighSchool) - { - this.educationHighSchool = educationHighSchool; - } - - public Long getEducationHighSchool() - { - return educationHighSchool; - } - public void setEducationPolytechnic(Long educationPolytechnic) - { - this.educationPolytechnic = educationPolytechnic; - } - - public Long getEducationPolytechnic() - { - return educationPolytechnic; - } - public void setEducationJuniorCollege(Long educationJuniorCollege) - { - this.educationJuniorCollege = educationJuniorCollege; - } - - public Long getEducationJuniorCollege() - { - return educationJuniorCollege; - } - public void setEducationUndergraduateCourse(Long educationUndergraduateCourse) - { - this.educationUndergraduateCourse = educationUndergraduateCourse; - } - - public Long getEducationUndergraduateCourse() - { - return educationUndergraduateCourse; - } - public void setEducationPostgraduate(Long educationPostgraduate) - { - this.educationPostgraduate = educationPostgraduate; - } - - public Long getEducationPostgraduate() - { - return educationPostgraduate; - } - public void setAccumulationFundLow(Long accumulationFundLow) - { - this.accumulationFundLow = accumulationFundLow; - } - - public Long getAccumulationFundLow() - { - return accumulationFundLow; - } - public void setAccumulationFundHigh(Long accumulationFundHigh) - { - this.accumulationFundHigh = accumulationFundHigh; - } - - public Long getAccumulationFundHigh() - { - return accumulationFundHigh; - } - public void setHourseNo(Long hourseNo) - { - this.hourseNo = hourseNo; - } - - public Long getHourseNo() - { - return hourseNo; - } - public void setHourseFullPayment(Long hourseFullPayment) - { - this.hourseFullPayment = hourseFullPayment; - } - - public Long getHourseFullPayment() - { - return hourseFullPayment; - } - public void setHourseMortgaging(Long hourseMortgaging) - { - this.hourseMortgaging = hourseMortgaging; - } - - public Long getHourseMortgaging() - { - return hourseMortgaging; - } - public void setOfficeWorker(Long officeWorker) - { - this.officeWorker = officeWorker; - } - - public Long getOfficeWorker() - { - return officeWorker; - } - public void setCivilServant(Long civilServant) - { - this.civilServant = civilServant; - } - - public Long getCivilServant() - { - return civilServant; - } - public void setPrivatePropertyOwners(Long privatePropertyOwners) - { - this.privatePropertyOwners = privatePropertyOwners; - } - - public Long getPrivatePropertyOwners() - { - return privatePropertyOwners; - } - public void setSelfEmployedPerson(Long selfEmployedPerson) - { - this.selfEmployedPerson = selfEmployedPerson; - } - - public Long getSelfEmployedPerson() - { - return selfEmployedPerson; - } - public void setOtherOccupations(Long otherOccupations) - { - this.otherOccupations = otherOccupations; - } - - public Long getOtherOccupations() - { - return otherOccupations; - } - public void setHuaBeiLow(Long huaBeiLow) - { - this.huaBeiLow = huaBeiLow; - } - - public Long getHuaBeiLow() - { - return huaBeiLow; - } - public void setHuaBeiMiddle(Long huaBeiMiddle) - { - this.huaBeiMiddle = huaBeiMiddle; - } - - public Long getHuaBeiMiddle() - { - return huaBeiMiddle; - } - public void setHuaBeiHigh(Long huaBeiHigh) - { - this.huaBeiHigh = huaBeiHigh; - } - - public Long getHuaBeiHigh() - { - return huaBeiHigh; - } - public void setBaiTiaoLow(Long baiTiaoLow) - { - this.baiTiaoLow = baiTiaoLow; - } - - public Long getBaiTiaoLow() - { - return baiTiaoLow; - } - public void setBaiTiaoMiddle(Long baiTiaoMiddle) - { - this.baiTiaoMiddle = baiTiaoMiddle; - } - - public Long getBaiTiaoMiddle() - { - return baiTiaoMiddle; - } - public void setBaiTiaoHigh(Long baiTiaoHigh) - { - this.baiTiaoHigh = baiTiaoHigh; - } - - public Long getBaiTiaoHigh() - { - return baiTiaoHigh; - } - public void setZhiMa(Long zhiMa) - { - this.zhiMa = zhiMa; - } - - public Long getZhiMa() - { - return zhiMa; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("age", getAge()) - .append("sex", getSex()) - .append("name", getName()) - .append("acturlName", getActurlName()) - .append("phone", getPhone()) - .append("phoneMd5", getPhoneMd5()) - .append("isAuth", getIsAuth()) - .append("city", getCity()) - .append("cityCode", getCityCode()) - .append("firstLoginTime", getFirstLoginTime()) - .append("lastLoginTime", getLastLoginTime()) - .append("lastLoginIp", getLastLoginIp()) - .append("status", getStatus()) - .append("socialSecurityNo", getSocialSecurityNo()) - .append("socialSecurityLow", getSocialSecurityLow()) - .append("socialSecurityHigh", getSocialSecurityHigh()) - .append("carNo", getCarNo()) - .append("carHave", getCarHave()) - .append("guaranteeSlipLow", getGuaranteeSlipLow()) - .append("guaranteeSlipCentre", getGuaranteeSlipCentre()) - .append("guaranteeSlipHigh", getGuaranteeSlipHigh()) - .append("educationMiddle", getEducationMiddle()) - .append("educationHighSchool", getEducationHighSchool()) - .append("educationPolytechnic", getEducationPolytechnic()) - .append("educationJuniorCollege", getEducationJuniorCollege()) - .append("educationUndergraduateCourse", getEducationUndergraduateCourse()) - .append("educationPostgraduate", getEducationPostgraduate()) - .append("accumulationFundLow", getAccumulationFundLow()) - .append("accumulationFundHigh", getAccumulationFundHigh()) - .append("hourseNo", getHourseNo()) - .append("hourseFullPayment", getHourseFullPayment()) - .append("hourseMortgaging", getHourseMortgaging()) - .append("officeWorker", getOfficeWorker()) - .append("civilServant", getCivilServant()) - .append("privatePropertyOwners", getPrivatePropertyOwners()) - .append("selfEmployedPerson", getSelfEmployedPerson()) - .append("otherOccupations", getOtherOccupations()) - .append("huaBeiLow", getHuaBeiLow()) - .append("huaBeiMiddle", getHuaBeiMiddle()) - .append("huaBeiHigh", getHuaBeiHigh()) - .append("baiTiaoLow", getBaiTiaoLow()) - .append("baiTiaoMiddle", getBaiTiaoMiddle()) - .append("baiTiaoHigh", getBaiTiaoHigh()) - .append("zhiMa", getZhiMa()) - .append("createTime", getCreateTime()) - .append("updateTime", getUpdateTime()) - .toString(); - } -} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ChannelMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ChannelMapper.java index 1767da95..0d0b2835 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ChannelMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ChannelMapper.java @@ -33,7 +33,7 @@ public interface ChannelMapper * @param channel 渠道配置 * @return 结果 */ - public int insertChannel(Channel channel); + public Long insertChannel(Channel channel); /** * 修改渠道配置 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CustomerMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CustomerMapper.java index 6fa20ecf..bcd9eab5 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CustomerMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CustomerMapper.java @@ -1,7 +1,9 @@ package com.ruoyi.system.mapper; import java.util.List; -import com.ruoyi.system.domain.Customer; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.common.core.domain.http.Customer; /** * 客户信息Mapper接口 @@ -9,7 +11,7 @@ import com.ruoyi.system.domain.Customer; * @author ruoyi * @date 2024-09-15 */ -public interface CustomerMapper +public interface CustomerMapper extends BaseMapper { /** * 查询客户信息 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IChannelService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IChannelService.java index 11852064..6f48263c 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IChannelService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IChannelService.java @@ -33,7 +33,7 @@ public interface IChannelService * @param channel 渠道配置 * @return 结果 */ - public int insertChannel(Channel channel); + public Long insertChannel(Channel channel); /** * 修改渠道配置 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICustomerService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICustomerService.java index de4beb8e..d9fc95ed 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICustomerService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ICustomerService.java @@ -1,7 +1,10 @@ package com.ruoyi.system.service; import java.util.List; -import com.ruoyi.system.domain.Customer; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.http.Customer; /** * 客户信息Service接口 @@ -9,7 +12,7 @@ import com.ruoyi.system.domain.Customer; * @author ruoyi * @date 2024-09-15 */ -public interface ICustomerService +public interface ICustomerService extends IService { /** * 查询客户信息 @@ -58,4 +61,18 @@ public interface ICustomerService * @return 结果 */ public int deleteCustomerById(Long id); + + /** + * 根据手机好MD5查询用户 + * @param phoneMD5 + * @return + */ + R selectByPhoneMd5(String phoneMD5); + + /** + * 通过手机号更新用户信息 + * @param customer + * @return + */ + R updateByPhoneMd5(Customer customer); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ChannelServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ChannelServiceImpl.java index 8ec61d03..8a08bb1d 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ChannelServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ChannelServiceImpl.java @@ -1,8 +1,11 @@ package com.ruoyi.system.service.impl; import java.util.List; + +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.redis.service.RedisService; import com.ruoyi.system.mapper.ChannelMapper; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -23,6 +26,8 @@ public class ChannelServiceImpl implements IChannelService { @Autowired private ChannelMapper channelMapper; + @Autowired + private RedisService redisService; /** * 查询渠道配置 @@ -56,13 +61,18 @@ public class ChannelServiceImpl implements IChannelService */ @Override @Transactional(rollbackFor = Exception.class) - public int insertChannel(Channel channel) + public Long insertChannel(Channel channel) { if (StringUtils.isEmpty(channel.getChannelSign())) { channel.setChannelSign(RandomStringUtils.random(16, true, false)); } channel.setCreateTime(DateUtils.getNowDate()); - return channelMapper.insertChannel(channel); + 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; } /** @@ -76,7 +86,14 @@ public class ChannelServiceImpl implements IChannelService public int updateChannel(Channel channel) { channel.setUpdateTime(DateUtils.getNowDate()); - return channelMapper.updateChannel(channel); + 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; } /** diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CustomerServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CustomerServiceImpl.java index 3c9f12c6..b51dd9b6 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CustomerServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CustomerServiceImpl.java @@ -1,11 +1,17 @@ package com.ruoyi.system.service.impl; import java.util.List; + +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.domain.R; import com.ruoyi.common.core.utils.DateUtils; -import org.springframework.beans.factory.annotation.Autowired; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.CustomerMapper; -import com.ruoyi.system.domain.Customer; +import com.ruoyi.common.core.domain.http.Customer; import com.ruoyi.system.service.ICustomerService; /** @@ -15,10 +21,9 @@ import com.ruoyi.system.service.ICustomerService; * @date 2024-09-15 */ @Service -public class CustomerServiceImpl implements ICustomerService -{ - @Autowired - private CustomerMapper customerMapper; +@RequiredArgsConstructor +public class CustomerServiceImpl extends ServiceImpl implements IService,ICustomerService { + private final CustomerMapper customerMapper; /** * 查询客户信息 @@ -93,4 +98,32 @@ public class CustomerServiceImpl implements ICustomerService { return customerMapper.deleteCustomerById(id); } + + /** + * 通过手机号MD5查询 + * @param phoneMD5 + * @return + */ + @Override + public R selectByPhoneMd5(String phoneMD5) { + Customer one = getOne(new LambdaQueryWrapper().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().lambda().eq(Customer::getPhoneMd5, customer.getPhoneMd5())); + if (update>0){ + return R.ok(); + } + return R.fail(); + } } diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/CustomerMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/CustomerMapper.xml index 68337dfc..bf072ced 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/CustomerMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/CustomerMapper.xml @@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select 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_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 from customer - and age = #{age} @@ -113,7 +113,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + insert into customer age, @@ -213,7 +213,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + update customer age = #{age},