2024-09-16 半流程

This commit is contained in:
zhp
2024-09-16 15:42:50 +08:00
parent 8612fb5c39
commit f553524baa
30 changed files with 1899 additions and 150 deletions

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

@@ -5,10 +5,7 @@ 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.PostMapping;
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.*;
/**
* 半流程API接口写这里
@@ -46,10 +43,10 @@ public class PublicHalfController{
/**
* 通用半流程撞库
*/
@PostMapping("checkOrder")
public AjaxResult checkOrder(@RequestBody ComPublicHalfDto comPublicHalfDto)
@GetMapping("checkOrder")
public AjaxResult checkOrder(@RequestParam("phoneMD5")String phoneMd5,@RequestParam("channelSign")String channelSign)
{
sysPublicHalfService.checkOrder(comPublicHalfDto);
sysPublicHalfService.checkOrder(phoneMd5,channelSign);
return null;
}
}

View File

@@ -6,14 +6,20 @@ import lombok.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;
//所在城市代码

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

@@ -2,6 +2,7 @@ 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;
/**
* 文件上传接口
@@ -25,8 +26,8 @@ public interface ISysPublicHalfService
/**
* 渠道查询订单是否成功
* @param comPublicHalfDto
* @param
*/
AjaxResult checkOrder(ComPublicHalfDto comPublicHalfDto);
AjaxResult checkOrder(String phoneMd5, String channelSign);
}

View File

@@ -0,0 +1,249 @@
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.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.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 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()) {
//限量判定
R<Integer> sum = remoteCustomerApplyLogService.sum(merchant.getId(), 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

@@ -1,6 +1,7 @@
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;
@@ -10,7 +11,9 @@ import com.ruoyi.common.core.constant.SecurityConstants;
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.ProbitUtil;
import com.ruoyi.common.core.utils.SecureUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
@@ -20,6 +23,7 @@ import com.ruoyi.system.api.RemoteCustomerService;
import com.ruoyi.system.api.RemoteMerchantService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.*;
import java.util.stream.Collectors;
@@ -186,21 +190,66 @@ public class SysPublicHalfServiceImpl implements ISysPublicHalfService
@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<>();
if (CollectionUtil.isEmpty(merchants)){
map.put("url","");
map.put("regist",false);
result.put("data",map);
return AjaxResult.success(result);
}
String url = channel.getHtmlLocation() + "token="+remoteCustomerService.getCustomerToken(customer.getPhone());
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);
remoteCustomerApplyLogService.add(customerApplyLog);
//返回上游信息
return null;
return AjaxResult.success(result);
}
/**
@@ -208,14 +257,25 @@ public class SysPublicHalfServiceImpl implements ISysPublicHalfService
* @param comPublicHalfDto
*/
@Override
public AjaxResult checkOrder(ComPublicHalfDto comPublicHalfDto) {
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 null;
return draw==0?AjaxResult.success("用户已申请",true):AjaxResult.success("用户未申请","false");
}
}

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

@@ -1,7 +1,6 @@
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;
@@ -11,7 +10,7 @@ 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.CustomerApplyLog;
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;
@@ -51,10 +50,23 @@ public class CustomerApplyLogController extends BaseController
* @param source 请求来源
* @return 结果
*/
@GetMapping("/log/sum")
@GetMapping("/sum")
public R<Integer> sum(@PathVariable("merchantId") Long merchantId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source){
return R.ok(customerApplyLogService.getApplySum(merchantId));
}
/**
* 获取用户今日是否是否已申请
*
*
* @param customerID
* @param source 请求来源
* @return 结果
*/
@GetMapping("/customerApply")
public R<Boolean> customerApply(@PathVariable("customerID") Long customerID,@RequestHeader(SecurityConstants.FROM_SOURCE) String source){
return customerApplyLogService.getCustomerApply(customerID);
}
/**
* 导出客户申请记录列表
*/

View File

@@ -131,4 +131,9 @@ public class CustomerController extends BaseController
{
return toAjax(customerService.deleteCustomerByIds(ids));
}
@GetMapping("/getCustomerToken")
public String getCustomerToken(@RequestParam("phone") String phone) {
return customerService.getCustomerToken(phone);
}
}

View File

@@ -1,111 +0,0 @@
package com.ruoyi.system.domain;
import java.math.BigDecimal;
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_apply_log
*
* @author ruoyi
* @date 2024-09-15
*/
public class CustomerApplyLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 用户id */
@Excel(name = "用户id")
private Long customerId;
/** 商户ID */
@Excel(name = "商户ID")
private Long merchantId;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long channelId;
/** 订单状态 0 已申请 1 注册中 2风控中 3下单中 4 下单成功 5已成交 */
@Excel(name = "订单状态 0 已申请 1 注册中 2风控中 3下单中 4 下单成功 5已成交 ")
private Long orderStatus;
/** 成交金额 分 */
@Excel(name = "成交金额 分")
private BigDecimal price;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setCustomerId(Long customerId)
{
this.customerId = customerId;
}
public Long getCustomerId()
{
return customerId;
}
public void setMerchantId(Long merchantId)
{
this.merchantId = merchantId;
}
public Long getMerchantId()
{
return merchantId;
}
public void setChannelId(Long channelId)
{
this.channelId = channelId;
}
public Long getChannelId()
{
return channelId;
}
public void setOrderStatus(Long orderStatus)
{
this.orderStatus = orderStatus;
}
public Long getOrderStatus()
{
return orderStatus;
}
public void setPrice(BigDecimal price)
{
this.price = price;
}
public BigDecimal getPrice()
{
return price;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("customerId", getCustomerId())
.append("merchantId", getMerchantId())
.append("channelId", getChannelId())
.append("orderStatus", getOrderStatus())
.append("price", getPrice())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@@ -4,7 +4,6 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.http.Channel;
import com.ruoyi.system.domain.CustomerApplyLog;
/**
* 渠道配置Mapper接口

View File

@@ -3,8 +3,7 @@ package com.ruoyi.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.http.Merchant;
import com.ruoyi.system.domain.CustomerApplyLog;
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
/**
* 客户申请记录Mapper接口

View File

@@ -3,7 +3,8 @@ package com.ruoyi.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.system.domain.CustomerApplyLog;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
/**
* 客户申请记录Service接口
@@ -67,4 +68,11 @@ public interface ICustomerApplyLogService extends IService<CustomerApplyLog>
* @return
*/
Integer getApplySum(Long merchantId);
/**
* 获取用户今日是否是否已申请
* @param customerID
* @return
*/
R<Boolean> getCustomerApply(Long customerID);
}

View File

@@ -75,4 +75,11 @@ public interface ICustomerService extends IService<Customer>
* @return
*/
R updateByPhoneMd5(Customer customer);
/**
* 获取用户tooken
* @param phone
* @return
*/
String getCustomerToken(String phone);
}

View File

@@ -5,12 +5,13 @@ import java.util.List;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CustomerApplyLogMapper;
import com.ruoyi.system.domain.CustomerApplyLog;
import com.ruoyi.common.core.domain.http.CustomerApplyLog;
import com.ruoyi.system.service.ICustomerApplyLogService;
/**
@@ -114,4 +115,20 @@ public class CustomerApplyLogServiceImpl extends ServiceImpl<CustomerApplyLogMap
.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, 0)
.ge(CustomerApplyLog::getCreateTime, LocalDateTimeUtils.getDateFromLocalDateTime(LocalDateTimeUtils.getTodayStartTime()))
.le(CustomerApplyLog::getCreateTime, LocalDateTimeUtils.getDateFromLocalDateTime(LocalDateTimeUtils.getTodayEndTime())));
return R.ok(aLong>0);
}
}

View File

@@ -6,13 +6,19 @@ 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.RedisConstant;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.EncryptUtil;
import com.ruoyi.common.redis.service.CustomerTokenService;
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;
/**
* 客户信息Service业务层处理
@@ -22,9 +28,11 @@ import com.ruoyi.system.service.ICustomerService;
*/
@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;
/**
* 查询客户信息
*
@@ -126,4 +134,19 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
}
return R.fail();
}
@Override
public String getCustomerToken(String phone) {
log.info("获取用户token,手机号:{},加密结果:{}", phone, EncryptUtil.AESencode(phone, systemConfig.getAESkey()));
Customer customer = this.getOne(new LambdaQueryWrapper<Customer>().eq(Customer::getPhone, EncryptUtil.AESencode(phone, systemConfig.getAESkey())));
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());
}
return token;
}
}

View File

@@ -4,7 +4,7 @@ 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.system.domain.CustomerApplyLog" id="CustomerApplyLogResult">
<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" />
@@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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.system.domain.CustomerApplyLog" resultMap="CustomerApplyLogResult">
<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>
@@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<insert id="insertCustomerApplyLog" parameterType="com.ruoyi.system.domain.CustomerApplyLog" useGeneratedKeys="true" keyProperty="id">
<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>
@@ -60,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<update id="updateCustomerApplyLog" parameterType="com.ruoyi.system.domain.CustomerApplyLog">
<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>