添加动态微信好提取接口
This commit is contained in:
@ -0,0 +1,23 @@
|
||||
package com.stdiet.custom.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SysWxAdLog {
|
||||
|
||||
private String userId;
|
||||
|
||||
private String ip;
|
||||
|
||||
private String userAgent;
|
||||
|
||||
private String channelId;
|
||||
|
||||
private String wxId;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private Date date;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.stdiet.custom.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.stdiet.common.annotation.Excel;
|
||||
@ -11,6 +12,7 @@ import com.stdiet.common.core.domain.BaseEntity;
|
||||
* @author xiezhijun
|
||||
* @date 2021-02-03
|
||||
*/
|
||||
@Data
|
||||
public class SysWxSaleAccount extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -39,85 +41,7 @@ public class SysWxSaleAccount extends BaseEntity
|
||||
/** 删除标识 0未删除 1已删除,默认0 */
|
||||
private Integer delFlag;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
private Integer status;
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setWxNickName(String wxNickName)
|
||||
{
|
||||
this.wxNickName = wxNickName;
|
||||
}
|
||||
|
||||
public String getWxNickName()
|
||||
{
|
||||
return wxNickName;
|
||||
}
|
||||
public void setWxAccount(String wxAccount)
|
||||
{
|
||||
this.wxAccount = wxAccount;
|
||||
}
|
||||
|
||||
public String getWxAccount()
|
||||
{
|
||||
return wxAccount;
|
||||
}
|
||||
public void setWxPhone(String wxPhone)
|
||||
{
|
||||
this.wxPhone = wxPhone;
|
||||
}
|
||||
|
||||
public String getWxPhone()
|
||||
{
|
||||
return wxPhone;
|
||||
}
|
||||
public void setWxCodeUrl(String wxCodeUrl)
|
||||
{
|
||||
this.wxCodeUrl = wxCodeUrl;
|
||||
}
|
||||
|
||||
public String getWxCodeUrl()
|
||||
{
|
||||
return wxCodeUrl;
|
||||
}
|
||||
public void setWxType(Integer wxType)
|
||||
{
|
||||
this.wxType = wxType;
|
||||
}
|
||||
|
||||
public Integer getWxType()
|
||||
{
|
||||
return wxType;
|
||||
}
|
||||
public void setDelFlag(Integer delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("wxNickName", getWxNickName())
|
||||
.append("wxAccount", getWxAccount())
|
||||
.append("wxPhone", getWxPhone())
|
||||
.append("wxCodeUrl", getWxCodeUrl())
|
||||
.append("remark", getRemark())
|
||||
.append("wxType", getWxType())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("delFlag", getDelFlag())
|
||||
.toString();
|
||||
}
|
||||
private Integer useCount;
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.stdiet.custom.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.stdiet.custom.domain.SysWxAdLog;
|
||||
import com.stdiet.custom.domain.SysWxDistribution;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@ -73,4 +75,5 @@ public interface SysWxDistributionMapper
|
||||
* @return
|
||||
*/
|
||||
List<SysWxDistribution> selectDistributionWxByUserId(@Param("userId")Long userId);
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.stdiet.custom.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.stdiet.custom.domain.SysWxAdLog;
|
||||
import com.stdiet.custom.domain.SysWxSaleAccount;
|
||||
|
||||
/**
|
||||
@ -65,4 +67,8 @@ public interface SysWxSaleAccountMapper
|
||||
* @return
|
||||
*/
|
||||
SysWxSaleAccount selectWxAccountByAccountOrPhone(SysWxSaleAccount sysWxSaleAccount);
|
||||
|
||||
SysWxSaleAccount selectWxAdId();
|
||||
|
||||
int insertWxAdLog(SysWxAdLog sysWxAdLog);
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.stdiet.custom.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.stdiet.custom.domain.SysWxAdLog;
|
||||
import com.stdiet.custom.domain.SysWxDistribution;
|
||||
|
||||
/**
|
||||
@ -72,4 +74,5 @@ public interface ISysWxDistributionService
|
||||
* @return
|
||||
*/
|
||||
List<SysWxDistribution> selectDistributionWxByUserId(Long userId);
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.stdiet.custom.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.stdiet.custom.domain.SysWxAdLog;
|
||||
import com.stdiet.custom.domain.SysWxSaleAccount;
|
||||
|
||||
/**
|
||||
@ -66,4 +68,8 @@ public interface ISysWxSaleAccountService
|
||||
* @return
|
||||
*/
|
||||
SysWxSaleAccount selectWxAccountByAccountOrPhone(String accountOrPhone, int type);
|
||||
|
||||
String getWxAdId(SysWxAdLog sysWxAdLog);
|
||||
|
||||
Integer logWxAd(SysWxAdLog sysWxAdLog);
|
||||
}
|
@ -2,6 +2,7 @@ package com.stdiet.custom.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.stdiet.common.utils.DateUtils;
|
||||
import com.stdiet.custom.domain.SysWxAdLog;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.stdiet.custom.mapper.SysWxDistributionMapper;
|
||||
@ -112,4 +113,5 @@ public class SysWxDistributionServiceImpl implements ISysWxDistributionService
|
||||
public List<SysWxDistribution> selectDistributionWxByUserId(Long userId){
|
||||
return sysWxDistributionMapper.selectDistributionWxByUserId(userId);
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,15 @@
|
||||
package com.stdiet.custom.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.stdiet.common.utils.DateUtils;
|
||||
import com.stdiet.common.utils.StringUtils;
|
||||
import com.stdiet.custom.domain.SysWxAdLog;
|
||||
import com.stdiet.custom.domain.SysWxSaleAccount;
|
||||
import com.stdiet.custom.mapper.SysWxSaleAccountMapper;
|
||||
import com.stdiet.custom.service.ISysWxSaleAccountService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.stdiet.custom.mapper.SysWxSaleAccountMapper;
|
||||
import com.stdiet.custom.domain.SysWxSaleAccount;
|
||||
import com.stdiet.custom.service.ISysWxSaleAccountService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信账号Service业务层处理
|
||||
@ -16,8 +18,7 @@ import com.stdiet.custom.service.ISysWxSaleAccountService;
|
||||
* @date 2021-02-03
|
||||
*/
|
||||
@Service
|
||||
public class SysWxSaleAccountServiceImpl implements ISysWxSaleAccountService
|
||||
{
|
||||
public class SysWxSaleAccountServiceImpl implements ISysWxSaleAccountService {
|
||||
@Autowired
|
||||
private SysWxSaleAccountMapper sysWxSaleAccountMapper;
|
||||
|
||||
@ -28,8 +29,7 @@ public class SysWxSaleAccountServiceImpl implements ISysWxSaleAccountService
|
||||
* @return 微信账号
|
||||
*/
|
||||
@Override
|
||||
public SysWxSaleAccount selectSysWxSaleAccountById(Long id)
|
||||
{
|
||||
public SysWxSaleAccount selectSysWxSaleAccountById(Long id) {
|
||||
return sysWxSaleAccountMapper.selectSysWxSaleAccountById(id);
|
||||
}
|
||||
|
||||
@ -40,8 +40,7 @@ public class SysWxSaleAccountServiceImpl implements ISysWxSaleAccountService
|
||||
* @return 微信账号
|
||||
*/
|
||||
@Override
|
||||
public List<SysWxSaleAccount> selectSysWxSaleAccountList(SysWxSaleAccount sysWxSaleAccount)
|
||||
{
|
||||
public List<SysWxSaleAccount> selectSysWxSaleAccountList(SysWxSaleAccount sysWxSaleAccount) {
|
||||
return sysWxSaleAccountMapper.selectSysWxSaleAccountList(sysWxSaleAccount);
|
||||
}
|
||||
|
||||
@ -52,8 +51,7 @@ public class SysWxSaleAccountServiceImpl implements ISysWxSaleAccountService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysWxSaleAccount(SysWxSaleAccount sysWxSaleAccount)
|
||||
{
|
||||
public int insertSysWxSaleAccount(SysWxSaleAccount sysWxSaleAccount) {
|
||||
sysWxSaleAccount.setCreateTime(DateUtils.getNowDate());
|
||||
return sysWxSaleAccountMapper.insertSysWxSaleAccount(sysWxSaleAccount);
|
||||
}
|
||||
@ -65,8 +63,7 @@ public class SysWxSaleAccountServiceImpl implements ISysWxSaleAccountService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysWxSaleAccount(SysWxSaleAccount sysWxSaleAccount)
|
||||
{
|
||||
public int updateSysWxSaleAccount(SysWxSaleAccount sysWxSaleAccount) {
|
||||
sysWxSaleAccount.setUpdateTime(DateUtils.getNowDate());
|
||||
return sysWxSaleAccountMapper.updateSysWxSaleAccount(sysWxSaleAccount);
|
||||
}
|
||||
@ -78,8 +75,7 @@ public class SysWxSaleAccountServiceImpl implements ISysWxSaleAccountService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysWxSaleAccountByIds(Long[] ids)
|
||||
{
|
||||
public int deleteSysWxSaleAccountByIds(Long[] ids) {
|
||||
return sysWxSaleAccountMapper.deleteSysWxSaleAccountByIds(ids);
|
||||
}
|
||||
|
||||
@ -90,25 +86,46 @@ public class SysWxSaleAccountServiceImpl implements ISysWxSaleAccountService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysWxSaleAccountById(Long id)
|
||||
{
|
||||
public int deleteSysWxSaleAccountById(Long id) {
|
||||
return sysWxSaleAccountMapper.deleteSysWxSaleAccountById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据微信号或手机号查询是否已存在
|
||||
*
|
||||
* @param accountOrPhone 手机号或微信号
|
||||
* @param type 0微信号 1手机号
|
||||
* @param type 0微信号 1手机号
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SysWxSaleAccount selectWxAccountByAccountOrPhone(String accountOrPhone, int type){
|
||||
public SysWxSaleAccount selectWxAccountByAccountOrPhone(String accountOrPhone, int type) {
|
||||
SysWxSaleAccount param = new SysWxSaleAccount();
|
||||
if(type == 0){
|
||||
if (type == 0) {
|
||||
param.setWxAccount(accountOrPhone);
|
||||
}else{
|
||||
} else {
|
||||
param.setWxPhone(accountOrPhone);
|
||||
}
|
||||
return sysWxSaleAccountMapper.selectWxAccountByAccountOrPhone(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWxAdId(SysWxAdLog sysWxAdLog) {
|
||||
SysWxSaleAccount sysWxSaleAccount = sysWxSaleAccountMapper.selectWxAdId();
|
||||
if (StringUtils.isNotNull(sysWxSaleAccount)) {
|
||||
sysWxSaleAccount.setUseCount(sysWxSaleAccount.getUseCount() + 1);
|
||||
int rows = sysWxSaleAccountMapper.updateSysWxSaleAccount(sysWxSaleAccount);
|
||||
if (rows > 0) {
|
||||
String wxId = sysWxSaleAccount.getWxAccount();
|
||||
sysWxAdLog.setWxId(wxId);
|
||||
logWxAd(sysWxAdLog);
|
||||
return wxId;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer logWxAd(SysWxAdLog sysWxAdLog) {
|
||||
return sysWxSaleAccountMapper.insertWxAdLog(sysWxAdLog);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.stdiet.custom.utils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public class HttpRequestUtils {
|
||||
|
||||
public static String getIpAddr(HttpServletRequest request) {
|
||||
String ipAddress = null;
|
||||
try {
|
||||
ipAddress = request.getHeader("x-forwarded-for");
|
||||
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getRemoteAddr();
|
||||
if (ipAddress.equals("127.0.0.1")) {
|
||||
// 根据网卡取本机配置的IP
|
||||
InetAddress inet = null;
|
||||
try {
|
||||
inet = InetAddress.getLocalHost();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ipAddress = inet.getHostAddress();
|
||||
}
|
||||
}
|
||||
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
|
||||
if (ipAddress != null && ipAddress.length() > 15) { // "***.***.***.***".length()
|
||||
// = 15
|
||||
if (ipAddress.indexOf(",") > 0) {
|
||||
ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ipAddress = "";
|
||||
}
|
||||
// ipAddress = this.getRequest().getRemoteAddr();
|
||||
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user