2024-09-16 注册页申请流程
parent
f9142064c9
commit
9c5090d606
|
|
@ -24,4 +24,9 @@ public class RedisConstant {
|
|||
* app用户设备标识
|
||||
*/
|
||||
public final static String APP_DEVICE_IDENTIFICATION = CacheConstants.PROJET + ":app:app:device:identification:";
|
||||
|
||||
/**
|
||||
* H5登录验证码
|
||||
*/
|
||||
public final static String H5_LOGIN_CACHE = CacheConstants.PROJET+"H5:login:cache:";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.ruoyi.common.core.domain.http;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import lombok.Data;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
|
|
@ -11,6 +10,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
|
|||
* @author ruoyi
|
||||
* @date 2024-09-15
|
||||
*/
|
||||
@Data
|
||||
public class Channel extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -26,6 +26,10 @@ public class Channel extends BaseEntity
|
|||
@Excel(name = "渠道签名")
|
||||
private String channelSign;
|
||||
|
||||
/** 渠道名称 */
|
||||
@Excel(name = "渠道名称")
|
||||
private String channelType;
|
||||
|
||||
/** 扣量比 */
|
||||
@Excel(name = "扣量比")
|
||||
private Long score;
|
||||
|
|
@ -46,93 +50,5 @@ public class Channel extends BaseEntity
|
|||
@Excel(name = "开启关闭时段")
|
||||
private String period;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setChannelName(String channelName)
|
||||
{
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
public String getChannelName()
|
||||
{
|
||||
return channelName;
|
||||
}
|
||||
public void setChannelSign(String channelSign)
|
||||
{
|
||||
this.channelSign = channelSign;
|
||||
}
|
||||
|
||||
public String getChannelSign()
|
||||
{
|
||||
return channelSign;
|
||||
}
|
||||
public void setScore(Long score)
|
||||
{
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public Long getScore()
|
||||
{
|
||||
return score;
|
||||
}
|
||||
public void setHtmlName(String htmlName)
|
||||
{
|
||||
this.htmlName = htmlName;
|
||||
}
|
||||
|
||||
public String getHtmlName()
|
||||
{
|
||||
return htmlName;
|
||||
}
|
||||
public void setHtmlLocation(String htmlLocation)
|
||||
{
|
||||
this.htmlLocation = htmlLocation;
|
||||
}
|
||||
|
||||
public String getHtmlLocation()
|
||||
{
|
||||
return htmlLocation;
|
||||
}
|
||||
public void setIps(String ips)
|
||||
{
|
||||
this.ips = ips;
|
||||
}
|
||||
|
||||
public String getIps()
|
||||
{
|
||||
return ips;
|
||||
}
|
||||
public void setPeriod(String period)
|
||||
{
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public String getPeriod()
|
||||
{
|
||||
return period;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("channelName", getChannelName())
|
||||
.append("channelSign", getChannelSign())
|
||||
.append("score", getScore())
|
||||
.append("htmlName", getHtmlName())
|
||||
.append("htmlLocation", getHtmlLocation())
|
||||
.append("ips", getIps())
|
||||
.append("period", getPeriod())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ public class Merchant extends BaseEntity
|
|||
@Excel(name = "定量数")
|
||||
private Integer limitNum;
|
||||
|
||||
/**注册地址**/
|
||||
private String hitUrl;
|
||||
|
||||
/** 是否定量 0否 1是 */
|
||||
@Excel(name = "是否定量 0否 1是")
|
||||
private Integer limitType;
|
||||
|
|
|
|||
|
|
@ -3,14 +3,7 @@ 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.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;
|
||||
|
|
@ -101,4 +94,16 @@ public class ChannelController extends BaseController
|
|||
{
|
||||
return toAjax(channelService.deleteChannelByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据渠道标识获取渠道类型
|
||||
* @param sign
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getChannelBySign")
|
||||
public AjaxResult getChannelBySign(@RequestParam("sign")String sign){
|
||||
return channelService.getChannelBySign(sign);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
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
|
||||
*/
|
||||
@GetMapping("/getChannelBySign")
|
||||
public AjaxResult getChannelBySign(@RequestParam("phone")String phone, HttpServletRequest request){
|
||||
return commonService.sendSms(phone);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
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;
|
||||
|
|
@ -132,8 +133,32 @@ public class CustomerController extends BaseController
|
|||
return toAjax(customerService.deleteCustomerByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户token
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getCustomerToken")
|
||||
public String getCustomerToken(@RequestParam("phone") String phone) {
|
||||
return customerService.getCustomerToken(phone);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* H5用户登录
|
||||
*/
|
||||
@GetMapping("/customerLogin")
|
||||
public AjaxResult customerLogin(@RequestParam("phone")String phone,@RequestParam("code")Integer code){
|
||||
return customerService.customerLogin(phone,code);
|
||||
}
|
||||
|
||||
/**
|
||||
* H5保存用户留资信息
|
||||
*/
|
||||
@PostMapping("saveCustomerInfo")
|
||||
public AjaxResult saveCustomerInfo(@RequestBody Customer customer, HttpServletRequest request){
|
||||
return customerService.saveCustomerInfo(customer,request);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
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;
|
||||
|
|
@ -122,4 +123,13 @@ public class MerchantController extends BaseController
|
|||
{
|
||||
return toAjax(merchantService.deleteMerchantByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取合适的产品
|
||||
*/
|
||||
@GetMapping("/getMatchMerchant")
|
||||
public AjaxResult getMatchMerchantList(HttpServletRequest request){
|
||||
return merchantService.getMatchMerchantList(request);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ruoyi.system.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MerchantListDto {
|
||||
|
||||
//商户名
|
||||
String merchantName;
|
||||
|
||||
//商户跳转地址
|
||||
String merchantUrl;
|
||||
|
||||
//商户描述
|
||||
String merchantDescribe;
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ 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接口
|
||||
|
|
@ -64,4 +65,11 @@ public interface IChannelService
|
|||
* @return
|
||||
*/
|
||||
public List<Channel> findAllChannelList();
|
||||
|
||||
/**
|
||||
* 根据渠道标识获取渠道
|
||||
* @param sign
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getChannelBySign(String sign);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -5,6 +5,9 @@ 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接口
|
||||
|
|
@ -82,4 +85,20 @@ public interface ICustomerService extends IService<Customer>
|
|||
* @return
|
||||
*/
|
||||
String getCustomerToken(String phone);
|
||||
|
||||
/**
|
||||
* h5用户登录
|
||||
* @param phone
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
AjaxResult customerLogin(String phone, Integer code);
|
||||
|
||||
/**
|
||||
* 保存用户留资信息
|
||||
* @param customer
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
AjaxResult saveCustomerInfo(Customer customer, HttpServletRequest request);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ 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接口
|
||||
|
|
@ -69,4 +72,10 @@ public interface IMerchantService extends IService<Merchant>
|
|||
*/
|
||||
R<List<Merchant>> getMerchantList();
|
||||
|
||||
/**
|
||||
* H5获取合适产品
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getMatchMerchantList(HttpServletRequest request);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@ 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 org.apache.commons.lang3.RandomStringUtils;
|
||||
|
|
@ -128,4 +130,18 @@ public class ChannelServiceImpl implements IChannelService
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
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.system.service.ICommonService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 渠道配置Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-09-15
|
||||
*/
|
||||
@Service
|
||||
public class CommonServiceImpl implements ICommonService
|
||||
{
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
|
||||
@Override
|
||||
public AjaxResult sendSms(String phone) {
|
||||
if (StringUtils.isEmpty(phone)){
|
||||
return AjaxResult.error("手机号未空");
|
||||
}
|
||||
if (phone.length()!=11){
|
||||
return AjaxResult.error("手机号长度异常");
|
||||
}
|
||||
//发送验证码
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
int code = secureRandom.nextInt(9000) + 1000;
|
||||
|
||||
//发送验证码工具类
|
||||
|
||||
//放入缓存 3分钟
|
||||
redisService.setCacheObject(RedisConstant.H5_LOGIN_CACHE+phone,1234,3*60l, TimeUnit.SECONDS);
|
||||
|
||||
return AjaxResult.success("发送成功");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,23 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.http.Merchant;
|
||||
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.system.config.SystemConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -20,6 +27,8 @@ 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业务层处理
|
||||
*
|
||||
|
|
@ -33,6 +42,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||
private final CustomerMapper customerMapper;
|
||||
private final SystemConfig systemConfig;
|
||||
private final CustomerTokenService customerTokenService;
|
||||
private final RedisService redisService;
|
||||
/**
|
||||
* 查询客户信息
|
||||
*
|
||||
|
|
@ -149,4 +159,44 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* H5用户登陆
|
||||
* @param phone
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult customerLogin(String phone, Integer code) {
|
||||
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 = getCustomerToken(phone);
|
||||
|
||||
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);
|
||||
if (customerId==null){
|
||||
return AjaxResult.error("用户不存在或未登录");
|
||||
}
|
||||
customer.setId(customerId);
|
||||
updateById(customer);
|
||||
return AjaxResult.success("保存成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,33 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.http.Customer;
|
||||
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.system.domain.dto.MerchantListDto;
|
||||
import com.ruoyi.system.mapper.CustomerApplyLogMapper;
|
||||
import com.ruoyi.system.mapper.CustomerMapper;
|
||||
import com.ruoyi.system.service.ICustomerApplyLogService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.MerchantMapper;
|
||||
import com.ruoyi.common.core.domain.http.Merchant;
|
||||
import com.ruoyi.system.service.IMerchantService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 商户Service业务层处理
|
||||
*
|
||||
|
|
@ -23,10 +35,13 @@ import com.ruoyi.system.service.IMerchantService;
|
|||
* @date 2024-09-15
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> implements IService<Merchant>,IMerchantService
|
||||
{
|
||||
@Autowired
|
||||
private MerchantMapper merchantMapper;
|
||||
private final MerchantMapper merchantMapper;
|
||||
private final CustomerTokenService customerTokenService;
|
||||
private final ICustomerApplyLogService customerApplyLogService;
|
||||
private final CustomerMapper customerMapper;
|
||||
|
||||
/**
|
||||
* 查询商户
|
||||
|
|
@ -114,4 +129,59 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|||
}
|
||||
return R.ok(merchants);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getMatchMerchantList(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());
|
||||
merchantListDtos.add(merchantListDto);
|
||||
}
|
||||
return AjaxResult.success(merchantListDtos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取前筛符合的商户
|
||||
* @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()==1&&merchant.getLimitNum()<=sum){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue