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,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>