crm功能开发

This commit is contained in:
朱春云 2025-09-26 16:22:24 +08:00
parent 9409bbd6d2
commit 048ec0d0be
7 changed files with 371 additions and 254 deletions

View File

@ -101,7 +101,7 @@ public class BusiNoticeServiceImpl extends ServiceImpl<BusiNoticeMapper,BusiNoti
busiNoticeVoIPage.getRecords().forEach(item->{ busiNoticeVoIPage.getRecords().forEach(item->{
try { try {
item.setUserNickName(userService.selectUserById(item.getUserId()).getNickName()); item.setUserNickName(userService.selectUserById(item.getUserId()).getNickName());
MemberUserVO memberUserVO = memberUserService.queryByUserId(item.getUserId(), "01"); MemberUserVO memberUserVO = memberUserService.queryByUserIdEasy(item.getUserId(), "01");
item.setIdentityType(memberUserVO.getIdentityType()); item.setIdentityType(memberUserVO.getIdentityType());
LambdaQueryWrapper<BusiNoticeSign> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BusiNoticeSign> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BusiNoticeSign::getNoticeId,item.getId()); queryWrapper.eq(BusiNoticeSign::getNoticeId,item.getId());
@ -158,7 +158,11 @@ public class BusiNoticeServiceImpl extends ServiceImpl<BusiNoticeMapper,BusiNoti
data.setApprovalStatus("1"); data.setApprovalStatus("1");
data.setApprovalUserId(null); data.setApprovalUserId(null);
data.setApprovalTime(new Date()); data.setApprovalTime(new Date());
if (StringUtils.isNotEmpty(data.getThirdUrl())){ if (data.getEndDate().before(new Date())){
data.setApprovalStatus("8");
result.put("code",500);
result.put("msg","截至时间不能早于当前时间!");
} else if (StringUtils.isNotEmpty(data.getThirdUrl())){
//如果以问号或eid=结尾驳回 //如果以问号或eid=结尾驳回
if (data.getThirdUrl().endsWith("eid=") || data.getThirdUrl().endsWith("?")){ if (data.getThirdUrl().endsWith("eid=") || data.getThirdUrl().endsWith("?")){
data.setApprovalStatus("8"); data.setApprovalStatus("8");
@ -265,25 +269,53 @@ public class BusiNoticeServiceImpl extends ServiceImpl<BusiNoticeMapper,BusiNoti
result.put("code",100); result.put("code",100);
result.put("msg","草稿数据暂存成功"); result.put("msg","草稿数据暂存成功");
}else { }else {
//判断 内容重复度 是否大于70%
//先获取 当前系统中截止日期之前的
LambdaQueryWrapper<BusiNotice> queryWrapper =new LambdaQueryWrapper<>();
queryWrapper.gt(BusiNotice::getEndDate, DateUtil.format(new Date(),"yyyy-MM-dd")).eq(BusiNotice::getApprovalStatus,1)
.ne(BusiNotice::getId,data.getId());
List<BusiNotice> list = this.list(queryWrapper);
//无问题数据直接审核通过 //无问题数据直接审核通过
data.setApprovalStatus("1"); data.setApprovalStatus("1");
data.setApprovalUserId(null); data.setApprovalUserId(null);
data.setApprovalTime(new Date()); data.setApprovalTime(new Date());
if (data.getEndDate().before(new Date())){
data.setApprovalStatus("8");
result.put("code",500);
result.put("msg","截至时间不能早于当前时间!");
} else if (StringUtils.isNotEmpty(data.getThirdUrl())){
//如果以问号或eid=结尾驳回
if (data.getThirdUrl().endsWith("eid=") || data.getThirdUrl().endsWith("?")){
data.setApprovalStatus("8");
result.put("code",500);
result.put("msg","第三方链接格式非法!");
}else{
//判断 内容重复度 是否大于70%
//先获取 当前系统中截止日期之前的
LambdaQueryWrapper<BusiNotice> queryWrapper =new LambdaQueryWrapper<>();
queryWrapper.gt(BusiNotice::getEndDate, DateUtil.format(new Date(),"yyyy-MM-dd")).eq(BusiNotice::getApprovalStatus,1).ne(BusiNotice::getId,data.getId());
List<BusiNotice> list = this.list(queryWrapper);
//遍历 list的每条数据与data对比如果两条数据相似度大于70% 提出预警 //遍历 list的每条数据与data对比如果两条数据相似度大于70% 提出预警
for (BusiNotice busiNotice : list) { for (BusiNotice busiNotice : list) {
//过滤掉换行和空格符
if (StringUtils.isNotEmpty(data.getThirdUrl())&&StringUtils.isNotEmpty(busiNotice.getThirdUrl())){ if (StringUtils.isNotEmpty(data.getThirdUrl())&&StringUtils.isNotEmpty(busiNotice.getThirdUrl())){
if (data.getThirdUrl().equals(busiNotice.getThirdUrl())){ if (data.getThirdUrl().replaceAll("\\s*|\t|\r|\n","").equals(busiNotice.getThirdUrl().replaceAll("\\s*|\t|\r|\n",""))){
//title detail 相似度大于70% 待审核 //两条thirdurl相等
data.setApprovalStatus("8"); data.setApprovalStatus("8");
data.setSimilarityIds(Optional.ofNullable(data.getSimilarityIds()).orElse("")+busiNotice.getId()+","); data.setSimilarityIds(Optional.ofNullable(data.getSimilarityIds()).orElse("")+busiNotice.getId()+",");
result.put("code",500); result.put("code",500);
result.put("msg","通告查重,下次早点上传哦!"); result.put("msg","通告查重,下次早点上传哦!");
}else if (busiNotice.getThirdUrl().replaceAll("\\s*|\t|\r|\n","").contains(data.getThirdUrl().replaceAll("\\s*|\t|\r|\n",""))||data.getThirdUrl().replaceAll("\\s*|\t|\r|\n","").contains(busiNotice.getThirdUrl().replaceAll("\\s*|\t|\r|\n",""))){
//两条thirdurl存在包含情况
data.setApprovalStatus("8");
data.setSimilarityIds(Optional.ofNullable(data.getSimilarityIds()).orElse("")+busiNotice.getId()+",");
result.put("code",500);
result.put("msg","通告查重,下次早点上传哦!");
}else if (isEidEqual(data.getThirdUrl().replaceAll("\\s*|\t|\r|\n",""),busiNotice.getThirdUrl().replaceAll("\\s*|\t|\r|\n",""))){
//两条thirdurl都存在eid且eid相等
data.setApprovalStatus("8");
data.setSimilarityIds(Optional.ofNullable(data.getSimilarityIds()).orElse("")+busiNotice.getId()+",");
result.put("code",500);
result.put("msg","通告查重,下次早点上传哦!");
}
if (data.getApprovalStatus().equals("8")){
break;
}
}
} }
} }
} }

View File

@ -15,11 +15,14 @@ import com.ruoyi.common.utils.DateUtils;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.member.domain.MemberPoints;
import com.ruoyi.member.service.IMemberCardService; import com.ruoyi.member.service.IMemberCardService;
import com.ruoyi.member.service.IMemberPointsService;
import com.ruoyi.member.service.IMemberUserService; import com.ruoyi.member.service.IMemberUserService;
import com.ruoyi.member.vo.MemberUserVO; import com.ruoyi.member.vo.MemberUserVO;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -49,6 +52,10 @@ public class BusiNoticeSignServiceImpl extends ServiceImpl<BusiNoticeSignMapper,
private BusiNoticeMapper noticeMapper; private BusiNoticeMapper noticeMapper;
@Autowired @Autowired
private IMemberUserService memberUserService; private IMemberUserService memberUserService;
@Autowired
private ISysConfigService sysConfigService;
@Autowired
private IMemberPointsService memberPointsService;
@Override @Override
public IPage<BusiNoticeSign> queryListPage(BusiNoticeSign pageReqVO, Page<BusiNoticeSign> page) { public IPage<BusiNoticeSign> queryListPage(BusiNoticeSign pageReqVO, Page<BusiNoticeSign> page) {
@ -106,6 +113,27 @@ public class BusiNoticeSignServiceImpl extends ServiceImpl<BusiNoticeSignMapper,
busiNoticeSign.setAddrId(appNoticeSign.getAddressId()); busiNoticeSign.setAddrId(appNoticeSign.getAddressId());
busiNoticeSignMapper.insert(busiNoticeSign); busiNoticeSignMapper.insert(busiNoticeSign);
} }
//处理优质通告积分赠送
try {
MemberUserVO tgz = memberUserService.queryByUserId(busiNotice.getUserId(), "01");
if (StringUtils.isNotEmpty(tgz.getIdentityType()) && tgz.getIdentityType().equals("05")) {
//判断距离通告发布24小时内报名人数是否达到50人
if (noticeMapper.selectCount(new LambdaQueryWrapper<BusiNotice>().eq(BusiNotice::getId, appNoticeSign.getNoticeId()).ge(BusiNotice::getCreateTime, DateUtils.getNowDate().getTime() - 86400000)) == 50) {
String point = sysConfigService.selectConfigByKey("goodNotice");
if (StringUtils.isNotEmpty(point) && Integer.parseInt(point) > 0) {
MemberPoints memberPoints = new MemberPoints();
memberPoints.setUserId(busiNotice.getUserId());
memberPoints.setPoints(Integer.parseInt(point));
memberPoints.setType("1");
memberPoints.setTitle("发布优质通告:" + busiNotice.getTitle() + ",奖励" + Integer.parseInt(point) + "积分");
memberPointsService.savePoints(memberPoints);
}
}
}
}catch (Exception e){
log.error("优质通告积分赠送失败",e);
}
} }

View File

@ -64,6 +64,8 @@ public interface IMemberUserService extends IService<MemberUser> {
**/ **/
MemberUserVO queryByUserId(Long userId,String userType); MemberUserVO queryByUserId(Long userId,String userType);
MemberUserVO queryByUserIdEasy(Long userId,String userType);
/** /**
* 微信授权登陆 * 微信授权登陆
* *

View File

@ -2,6 +2,7 @@ package com.ruoyi.member.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -28,11 +29,13 @@ import com.ruoyi.constant.DictConstants;
import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.member.domain.MemberCard; import com.ruoyi.member.domain.MemberCard;
import com.ruoyi.member.domain.MemberOrder; import com.ruoyi.member.domain.MemberOrder;
import com.ruoyi.member.domain.MemberPoints;
import com.ruoyi.member.domain.MemberUser; import com.ruoyi.member.domain.MemberUser;
import com.ruoyi.member.mapper.MemberUserMapper; import com.ruoyi.member.mapper.MemberUserMapper;
import com.ruoyi.member.service.*; import com.ruoyi.member.service.*;
import com.ruoyi.member.vo.MemberUserVO; import com.ruoyi.member.vo.MemberUserVO;
import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -88,6 +91,12 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberU
private ISysRoleService roleService; private ISysRoleService roleService;
@Autowired @Autowired
private IMemberOrderService orderService; private IMemberOrderService orderService;
@Autowired
private IMemberPointsService memberPointsService;
@Autowired
private ISysConfigService sysConfigService;
@Autowired
private IMemberUserService memberUserService;
/** /**
* 分页列表查询 * 分页列表查询
@ -240,6 +249,23 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberU
} }
/**
* 通过用户id查询用户详情信息
*
* @param userId 用户id
* @param userType userType
* @return com.ruoyi.member.vo.MemberUserVO
* @author PQZ
* @date 11:40 2025/4/9
**/
@Override
public MemberUserVO queryByUserIdEasy(Long userId, String userType) {
//博主通告主基本信息
return memberUserMapper.queryByUserId(userId, userType);
}
/** /**
* 微信授权登陆 * 微信授权登陆
* *
@ -283,6 +309,24 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberU
user.setInviteId(inviteId); user.setInviteId(inviteId);
//新增 用户 //新增 用户
userMapper.insertUser(user); userMapper.insertUser(user);
if (ObjectUtil.isNotEmpty(inviteId)) {
MemberUserVO tgz = memberUserService.queryByUserId(inviteId, "01");
if (StringUtils.isNotEmpty(tgz.getIdentityType()) && tgz.getIdentityType().equals("05")) {
try {
String point = sysConfigService.selectConfigByKey("inviteUser");
if (StringUtils.isNotEmpty(point) && Integer.parseInt(point) > 0) {
MemberPoints memberPoints = new MemberPoints();
memberPoints.setUserId(inviteId);
memberPoints.setPoints(Integer.parseInt(point));
memberPoints.setType("1");
memberPoints.setTitle("邀请新用户:" + phone + ",得" + Integer.parseInt(point) + "积分");
memberPointsService.savePoints(memberPoints);
}
} catch (Exception e) {
log.error("邀请用户积分异常", e);
}
}
}
//插入用户扩展信息表数据 //插入用户扩展信息表数据
this.save(new MemberUser(DictConstants.USER_TYPE_TGZ,user,dlRightsConfig.getAddNotice())); this.save(new MemberUser(DictConstants.USER_TYPE_TGZ,user,dlRightsConfig.getAddNotice()));
this.save(new MemberUser(DictConstants.USER_TYPE_BZ,user,null)); this.save(new MemberUser(DictConstants.USER_TYPE_BZ,user,null));

View File

@ -12,57 +12,60 @@
main.approval_remark, main.creator, main.create_time, main.updater, main.update_time, main.del_flag,main.is_platform_free,main.is_urgent,main.similarity_ids, main.approval_remark, main.creator, main.create_time, main.updater, main.update_time, main.del_flag,main.is_platform_free,main.is_urgent,main.similarity_ids,
bTable.title as platformName,main.third_url bTable.title as platformName,main.third_url
from dl_busi_notice main from dl_busi_notice main
left join dl_base_category bTable on main.platform_code = bTable.code left join dl_base_category bTable on main.platform_code = bTable.code and bTable.del_flag = 0
<if test="entity.userNickName != null "> <if test="entity.userNickName != null and entity.userNickName != ''">
left join sys_user uTable on uTable.user_id = main.user_id left join sys_user uTable on uTable.user_id = main.user_id and uTable.del_flag = '0'
</if> </if>
<where> <where>
main.del_flag = '0' main.del_flag = 0
<if test="entity.id != null "> and main.id = #{entity.id}</if> <if test="entity.id != null and entity.id != ''"> and main.id = #{entity.id}</if>
<if test="entity.userNickName != null "> and uTable.nick_name like concat('%', #{entity.userNickName}, '%')</if> <if test="entity.userNickName != null and entity.userNickName != ''"> and uTable.nick_name like concat('%', #{entity.userNickName}, '%')</if>
<if test="entity.userId != null "> and main.user_id = #{entity.userId}</if> <if test="entity.userId != null"> and main.user_id = #{entity.userId}</if>
<if test="entity.province != null "> and main.province = #{entity.province}</if> <if test="entity.province != null and entity.province != ''"> and main.province = #{entity.province}</if>
<if test="entity.city != null "> and main.city = #{entity.city}</if> <if test="entity.city != null and entity.city != ''"> and main.city = #{entity.city}</if>
<if test="entity.thirdUrl != null and entity.thirdUrl == '01' "> and (main.third_url is not null and main.third_url != '')</if> <if test="entity.thirdUrl != null and entity.thirdUrl == '01'"> and (main.third_url is not null and main.third_url != '')</if>
<if test="entity.thirdUrl != null and entity.thirdUrl == '02' "> and (main.third_url is null or main.third_url = '')</if> <if test="entity.thirdUrl != null and entity.thirdUrl == '02'"> and (main.third_url is null or main.third_url = '')</if>
<if test="entity.params.thirdUrl != null and entity.params.thirdUrl != '' "> and (main.third_url like concat('%', #{entity.params.thirdUrl}, '%'))</if> <if test="entity.params.thirdUrl != null and entity.params.thirdUrl != ''"> and (main.third_url like concat('%', #{entity.params.thirdUrl}, '%'))</if>
<if test="entity.title != null and entity.title != ''"> and main.title like concat('%', #{entity.title}, '%')</if> <if test="entity.title != null and entity.title != ''"> and main.title like concat('%', #{entity.title}, '%')</if>
<if test="entity.platformCode != null and entity.platformCode != ''"> and main.platform_code = #{entity.platformCode}</if> <if test="entity.platformCode != null and entity.platformCode != ''"> and main.platform_code = #{entity.platformCode}</if>
<if test="entity.isUrgent != null and entity.isUrgent != ''"> and main.is_urgent = #{entity.isUrgent}</if> <if test="entity.isUrgent != null and entity.isUrgent != ''"> and main.is_urgent = #{entity.isUrgent}</if>
<if test="entity.isPlatformFree != null and entity.isPlatformFree != ''"> and main.is_platform_free = #{entity.isPlatformFree}</if> <if test="entity.isPlatformFree != null and entity.isPlatformFree != ''"> and main.is_platform_free = #{entity.isPlatformFree}</if>
<if test="entity.params.isRuning != null "> <if test="entity.params.isRuning != null">
<choose> <choose>
<when test="entity.params.isRuning=='01'"> <when test="entity.params.isRuning=='01'">
and main.approval_status !='2' and main.end_date &gt;= CURDATE() and main.approval_status != '2' and main.end_date &gt;= CURDATE()
</when> </when>
<when test="entity.params.isRuning=='02'"> <when test="entity.params.isRuning=='02'">
and (main.approval_status ='2' or main.end_date &lt; CURDATE()) and (main.approval_status = '2' or main.end_date &lt; CURDATE())
</when> </when>
</choose> </choose>
</if> </if>
<if test="entity.params.beginFeeDown != null and entity.params.beginFeeDown != ''"> <if test="entity.params.beginFeeDown != null and entity.params.beginFeeDown != ''">
and main.fee_down <![CDATA[>= ]]> #{entity.params.beginFeeDown} and main.fee_down <![CDATA[>=]]> #{entity.params.beginFeeDown}
</if> </if>
<if test=" entity.params.endFeeDown != null and entity.params.endFeeDown != ''"> <if test="entity.params.endFeeDown != null and entity.params.endFeeDown != ''">
and main.fee_down <![CDATA[<= ]]> #{entity.params.endFeeDown} and main.fee_down <![CDATA[<=]]> #{entity.params.endFeeDown}
</if> </if>
<if test="entity.params.beginFansDown != null and entity.params.beginFansDown != ''"> <if test="entity.params.beginFansDown != null and entity.params.beginFansDown != ''">
and main.fans_down <![CDATA[>= ]]> #{entity.params.beginFansDown} and main.fans_down <![CDATA[>=]]> #{entity.params.beginFansDown}
</if> </if>
<if test=" entity.params.endFansDown != null and entity.params.endFansDown != ''"> <if test="entity.params.endFansDown != null and entity.params.endFansDown != ''">
and main.fans_down <![CDATA[<= ]]> #{entity.params.endFansDown} and main.fans_down <![CDATA[<=]]> #{entity.params.endFansDown}
</if> </if>
<if test="entity.brand != null and entity.brand != ''"> and main.brand like concat('%', #{entity.brand}, '%')</if> <if test="entity.brand != null and entity.brand != ''"> and main.brand like concat('%', #{entity.brand}, '%')</if>
<if test="entity.pic != null and entity.pic != ''"> and main.pic = #{entity.pic}</if> <if test="entity.pic != null and entity.pic != ''"> and main.pic = #{entity.pic}</if>
<if test="entity.collect != null and entity.collect != ''"> and main.collect = #{entity.collect}</if> <if test="entity.collect != null and entity.collect != ''"> and main.collect = #{entity.collect}</if>
<if test="entity.bloggerTypes != null and entity.bloggerTypes != ''"> and main.blogger_types = #{entity.bloggerTypes}</if> <if test="entity.bloggerTypes != null and entity.bloggerTypes != ''"> and main.blogger_types = #{entity.bloggerTypes}</if>
<if test="entity.isUseCoupon != null "> and main.is_use_coupon = #{entity.isUseCoupon}</if> <if test="entity.isUseCoupon != null"> and main.is_use_coupon = #{entity.isUseCoupon}</if>
<if test="entity.approvalStatus != null and entity.approvalStatus != ''"> and main.approval_status = #{entity.approvalStatus}</if> <if test="entity.approvalStatus != null and entity.approvalStatus != ''"> and main.approval_status = #{entity.approvalStatus}</if>
<if test="entity.params.beginCreateTime != null and entity.params.beginCreateTime != '' and entity.params.endCreateTime != null and entity.params.endCreateTime != ''"> and main.create_time between #{entity.params.beginCreateTime} and #{entity.params.endCreateTime}</if> <if test="entity.params.beginCreateTime != null and entity.params.beginCreateTime != '' and entity.params.endCreateTime != null and entity.params.endCreateTime != ''">
and main.create_time between #{entity.params.beginCreateTime} and #{entity.params.endCreateTime}
</if>
</where> </where>
order by FIELD(main.approval_status,0,1,9,2) asc, main.create_time desc order by FIELD(main.approval_status,'0','1','9','2') asc, main.create_time desc
</select> </select>
<select id="queryListByUserId" resultType="com.ruoyi.busi.vo.BusiNoticeVo"> <select id="queryListByUserId" resultType="com.ruoyi.busi.vo.BusiNoticeVo">
SELECT SELECT
main.*, main.*,
@ -78,55 +81,56 @@ order by dbns.create_time desc
<select id="queryAppListPage" resultType="com.ruoyi.busi.vo.BusiNoticeVo"> <select id="queryAppListPage" resultType="com.ruoyi.busi.vo.BusiNoticeVo">
SELECT SELECT
dbn.*, dbn.*,
-- dbnv.view_num AS viewNum,
su.avatar, su.avatar,
su.nick_name AS userNickName su.nick_name AS userNickName
-- count(sign.id) as reportNum
FROM FROM
dl_busi_notice dbn dl_busi_notice dbn
-- LEFT JOIN dl_busi_notice_view dbnv ON dbn.id = dbnv.id LEFT JOIN sys_user su ON dbn.user_id = su.user_id AND su.del_flag = 0
LEFT JOIN sys_user su ON dbn.user_id = su.user_id
-- left join dl_busi_notice_sign sign on sign.notice_id = dbn.id and sign.del_flag = 0
<if test="entity.userId!=null and entity.userId!=''"> <if test="entity.userId!=null and entity.userId!=''">
left join dl_member_blacklist blacklist on blacklist.black_user_id = dbn.user_id and blacklist.del_flag = 0 and blacklist.user_id = #{entity.userId} LEFT JOIN dl_member_blacklist blacklist ON blacklist.black_user_id = dbn.user_id
AND blacklist.del_flag = 0
AND blacklist.user_id = #{entity.userId}
</if> </if>
WHERE WHERE
dbn.del_flag = 0 and dbn.end_date &gt;= CURDATE() dbn.del_flag = 0
AND (dbn.approval_status = '1') AND dbn.end_date &gt;= CURDATE()
AND dbn.approval_status = '1'
<if test="entity.userId!=null and entity.userId!=''"> <if test="entity.userId!=null and entity.userId!=''">
and blacklist.id is null AND blacklist.id IS NULL
</if> </if>
<if test="entity.gift!=null and entity.gift!=''"> <if test="entity.gift!=null and entity.gift!=''">
AND (( dbn.fee_down is null or dbn.fee_down = 0 ) and dbn.fee_up = 0) AND ((dbn.fee_down IS NULL OR dbn.fee_down = 0) AND dbn.fee_up = 0)
</if> </if>
<if test="entity.cityName!=null and entity.cityName!=''"> <if test="entity.cityName!=null and entity.cityName!=''">
AND dbn.city =#{entity.cityName} AND dbn.city = #{entity.cityName}
</if> </if>
<if test="entity.platformCode!=null and entity.platformCode!=''"> <if test="entity.platformCode!=null and entity.platformCode!=''">
AND ( dbn.platform_code =#{entity.platformCode} ) AND dbn.platform_code = #{entity.platformCode}
</if>
<if test="entity.isUrgent != null and entity.isUrgent != ''">
AND dbn.is_urgent = #{entity.isUrgent}
</if>
<if test="entity.isPlatformFree != null and entity.isPlatformFree != ''">
AND dbn.is_platform_free = #{entity.isPlatformFree}
</if> </if>
<if test="entity.isUrgent != null and entity.isUrgent != ''"> and dbn.is_urgent = #{entity.isUrgent}</if>
<if test="entity.isPlatformFree != null and entity.isPlatformFree != ''"> and dbn.is_platform_free = #{entity.isPlatformFree}</if>
<if test="entity.bloggerType!=null and entity.bloggerType!=''"> <if test="entity.bloggerType!=null and entity.bloggerType!=''">
AND ( dbn.blogger_types LIKE CONCAT('%',#{entity.bloggerType},'%') ) AND dbn.blogger_types LIKE CONCAT('%',#{entity.bloggerType},'%')
</if> </if>
<if test="entity.searchValue!=null and entity.searchValue!=''"> <if test="entity.searchValue!=null and entity.searchValue!=''">
AND ( dbn.title LIKE CONCAT('%',#{entity.searchValue},'%') OR AND (dbn.title LIKE CONCAT('%',#{entity.searchValue},'%') OR
dbn.detail LIKE CONCAT('%',#{entity.searchValue},'%') ) dbn.detail LIKE CONCAT('%',#{entity.searchValue},'%'))
</if> </if>
<if test="entity.rewardType=='money'"> <if test="entity.rewardType=='money'">
AND ( dbn.fee_down IS NOT NULL OR dbn.fee_up IS NOT NULL ) AND (dbn.fee_down IS NOT NULL OR dbn.fee_up IS NOT NULL)
</if> </if>
<if test="entity.rewardType=='gift'"> <if test="entity.rewardType=='gift'">
AND ( dbn.have_gift = '1' ) AND dbn.have_gift = '1'
</if> </if>
<choose> <choose>
<!-- 情况一:同时填写了下限和上限 --> <!-- 情况一:同时填写了下限和上限 -->
<when test="entity.fansDown != null and entity.fansUp != null"> <when test="entity.fansDown != null and entity.fansUp != null">
AND ( AND (dbn.fans_down <![CDATA[ <= ]]> #{entity.fansUp}
dbn.fans_down <![CDATA[ <= ]]> #{entity.fansUp} AND (dbn.fans_up IS NULL OR dbn.fans_up >= #{entity.fansDown}))
AND (dbn.fans_up IS NULL OR dbn.fans_up >= #{entity.fansDown})
)
</when> </when>
<!-- 情况二:只填写了下限 --> <!-- 情况二:只填写了下限 -->
@ -143,10 +147,8 @@ order by dbns.create_time desc
<choose> <choose>
<!-- 情况一:同时填写了下限和上限 --> <!-- 情况一:同时填写了下限和上限 -->
<when test="entity.feeDown != null and entity.feeUp != null"> <when test="entity.feeDown != null and entity.feeUp != null">
AND ( AND (dbn.fee_down <![CDATA[ <= ]]> #{entity.feeUp}
dbn.fee_down <![CDATA[ <= ]]> #{entity.feeUp} AND (dbn.fee_up IS NULL OR dbn.fee_up >= #{entity.feeDown}))
AND (dbn.fee_up IS NULL OR dbn.fee_up >= #{entity.feeDown})
)
</when> </when>
<!-- 情况二:只填写了下限 --> <!-- 情况二:只填写了下限 -->
@ -159,25 +161,21 @@ order by dbns.create_time desc
AND dbn.fee_down <![CDATA[ <= ]]> #{entity.feeUp} AND dbn.fee_down <![CDATA[ <= ]]> #{entity.feeUp}
</when> </when>
</choose> </choose>
group by dbn.id
ORDER BY ORDER BY
<choose> <choose>
<when test="entity.sortBy=='new'"> <when test="entity.sortBy=='new'">
-- 查最新的 --
dbn.create_time DESC dbn.create_time DESC
</when> </when>
<when test="entity.sortBy=='money'"> <when test="entity.sortBy=='money'">
-- 查高奖励 --
dbn.fee_up DESC dbn.fee_up DESC
</when> </when>
<otherwise> <otherwise>
-- 默认正序排列 --
dbn.create_time DESC dbn.create_time DESC
</otherwise> </otherwise>
</choose> </choose>
</select> </select>
<select id="selectByIdVo" resultType="com.ruoyi.busi.vo.BusiNoticeVo"> <select id="selectByIdVo" resultType="com.ruoyi.busi.vo.BusiNoticeVo">
select main.*, select main.*,
uTable.nick_name as userNickName,ifnull(noticeView.view_num,0) as viewNum, uTable.nick_name as userNickName,ifnull(noticeView.view_num,0) as viewNum,
@ -250,15 +248,13 @@ order by dbns.create_time desc
<select id="subscribeList" resultType="com.ruoyi.busi.vo.BusiNoticeVo"> <select id="subscribeList" resultType="com.ruoyi.busi.vo.BusiNoticeVo">
SELECT SELECT
dbn.*, dbn.*,
-- dbnv.view_num AS viewNum,
su.avatar, su.avatar,
su.nick_name AS userNickName, su.nick_name AS userNickName,
count(sign.id) as reportNum (SELECT COUNT(1) FROM dl_busi_notice_sign sign
WHERE sign.notice_id = dbn.id AND sign.del_flag = 0) as reportNum
FROM FROM
dl_busi_notice dbn dl_busi_notice dbn
-- LEFT JOIN dl_busi_notice_view dbnv ON dbn.id = dbnv.id
LEFT JOIN sys_user su ON dbn.user_id = su.user_id LEFT JOIN sys_user su ON dbn.user_id = su.user_id
left join dl_busi_notice_sign sign on sign.notice_id = dbn.id and sign.del_flag = 0
WHERE WHERE
dbn.del_flag = 0 dbn.del_flag = 0
AND (dbn.approval_status = '1') AND (dbn.approval_status = '1')
@ -266,76 +262,73 @@ order by dbns.create_time desc
<if test="entity.platformCode!=null and entity.platformCode.size>0"> <if test="entity.platformCode!=null and entity.platformCode.size>0">
and dbn.platform_code IN and dbn.platform_code IN
<foreach collection="entity.platformCode" item="it" open="(" close=")" separator=","> <foreach collection="entity.platformCode" item="it" open="(" close=")" separator=",">
-- platform_code 包含it
#{it} #{it}
</foreach> </foreach>
</if> </if>
<if test="entity.bloggerTypeCode!=null and entity.bloggerTypeCode.size>0"> <if test="entity.bloggerTypeCode!=null and entity.bloggerTypeCode.size>0">
and and (
<foreach collection="entity.bloggerTypeCode" item="it" open="(" close=")" separator="or"> <foreach collection="entity.bloggerTypeCode" item="it" separator=" OR ">
dbn.blogger_types like concat('%',#{it},'%') dbn.blogger_types like concat('%',#{it},'%')
</foreach> </foreach>
)
</if> </if>
<if test="entity.settleTypeCode!=null and entity.settleTypeCode!=''"> <if test="entity.settleTypeCode!=null and entity.settleTypeCode!=''">
and dbn.is_platform_free = #{entity.settleTypeCode} and dbn.is_platform_free = #{entity.settleTypeCode}
</if> </if>
<if test="entity.keywordsList!=null and entity.keywordsList.size>0 "> <if test="entity.keywordsList!=null and entity.keywordsList.size>0 ">
and and (
<foreach collection="entity.keywordsList" item="it" open="(" close=")" separator="or"> <foreach collection="entity.keywordsList" item="it" separator=" OR ">
title like concat('%',#{it},'%') or detail like concat('%',#{it},'%') or brand like concat('%',#{it},'%') (title like concat('%',#{it},'%') or detail like concat('%',#{it},'%') or brand like concat('%',#{it},'%'))
</foreach> </foreach>
)
</if> </if>
<if test="entity.fansUp!=null"> <if test="entity.fansUp!=null">
AND ( dbn.fans_up &lt;=#{entity.fansUp} ) AND dbn.fans_up &lt;=#{entity.fansUp}
</if> </if>
<if test="entity.fansDown!=null"> <if test="entity.fansDown!=null">
AND ( dbn.fans_up &gt;=#{entity.fansDown} ) AND dbn.fans_up &gt;=#{entity.fansDown}
</if> </if>
<if test="entity.feeUp!=null"> <if test="entity.feeUp!=null">
AND ( dbn.fee_up &lt;=#{entity.feeUp} ) AND dbn.fee_up &lt;=#{entity.feeUp}
</if> </if>
<if test="entity.feeDown!=null"> <if test="entity.feeDown!=null">
AND ( dbn.fee_down &gt;=#{entity.feeDown} ) AND dbn.fee_down &gt;=#{entity.feeDown}
</if> </if>
<if test="entity.isUrgent != null and entity.isUrgent != ''"> and dbn.is_urgent = #{entity.isUrgent}</if> <if test="entity.isUrgent != null and entity.isUrgent != ''"> and dbn.is_urgent = #{entity.isUrgent}</if>
<if test="entity.isPlatformFree != null and entity.isPlatformFree != ''"> and dbn.is_platform_free = #{entity.isPlatformFree}</if> <if test="entity.isPlatformFree != null and entity.isPlatformFree != ''"> and dbn.is_platform_free = #{entity.isPlatformFree}</if>
group by dbn.id
ORDER BY ORDER BY
-- 默认正序排列 --
dbn.create_time DESC dbn.create_time DESC
</select> </select>
<select id="loveList" resultType="com.ruoyi.busi.vo.BusiNoticeVo"> <select id="loveList" resultType="com.ruoyi.busi.vo.BusiNoticeVo">
SELECT SELECT
dbn.*, dbn.*,
-- dbnv.view_num AS viewNum,
su.avatar, su.avatar,
su.nick_name AS userNickName, su.nick_name AS userNickName
count(sign.id) as reportNum
FROM FROM
dl_busi_notice dbn dl_busi_notice dbn
-- LEFT JOIN dl_busi_notice_view dbnv ON dbn.id = dbnv.id INNER JOIN dl_busi_user_love love ON dbn.user_id = love.love_user_id AND love.user_id = #{entity.userId}
LEFT JOIN sys_user su ON dbn.user_id = su.user_id LEFT JOIN sys_user su ON dbn.user_id = su.user_id
inner join dl_busi_user_love love on dbn.user_id = love.love_user_id and love.user_id = #{entity.userId}
left join dl_busi_notice_sign sign on sign.notice_id = dbn.id and sign.del_flag = 0
WHERE WHERE
dbn.del_flag = 0 dbn.del_flag = 0
AND (dbn.approval_status = '1') AND dbn.approval_status = '1'
and dbn.end_date &gt;= CURDATE() AND dbn.end_date &gt;= CURDATE()
group by dbn.id
ORDER BY ORDER BY
dbn.create_time DESC dbn.create_time DESC
</select> </select>
<select id="myNoticeList" resultType="com.ruoyi.busi.vo.BusiNoticeVo"> <select id="myNoticeList" resultType="com.ruoyi.busi.vo.BusiNoticeVo">
SELECT SELECT
dbn.*, dbn.*,
-- dbnv.view_num AS viewNum,
su.avatar, su.avatar,
su.nick_name AS userNickName, su.nick_name AS userNickName,
count(sign.id) as reportNum, (SELECT COUNT(1) FROM dl_busi_notice_sign sign
WHERE sign.notice_id = dbn.id AND sign.del_flag = 0) as reportNum,
mySign.create_time as signTime, mySign.create_time as signTime,
card.account_name as cardName, card.account_name as cardName,
CASE CASE
@ -348,43 +341,40 @@ order by dbns.create_time desc
mySign.id as signId mySign.id as signId
FROM FROM
dl_busi_notice dbn dl_busi_notice dbn
-- LEFT JOIN dl_busi_notice_view dbnv ON dbn.id = dbnv.id
LEFT JOIN sys_user su ON dbn.user_id = su.user_id LEFT JOIN sys_user su ON dbn.user_id = su.user_id
LEFT join dl_busi_notice_sign sign on sign.notice_id = dbn.id and sign.del_flag = 0 INNER JOIN dl_busi_notice_sign mySign ON dbn.id = mySign.notice_id AND mySign.user_id = #{entity.userId}
inner join dl_busi_notice_sign mySign on dbn.id = mySign.notice_id and dbn.del_flag = 0 and mySign.user_id = #{entity.userId} INNER JOIN dl_member_busi_card card ON card.id = mySign.card_id AND card.del_flag = 0
inner join dl_member_busi_card card on card.id = mySign.card_id and card.del_flag = 0
WHERE WHERE
dbn.del_flag = 0 dbn.del_flag = 0
AND (dbn.approval_status = '1') AND dbn.approval_status = '1'
<if test="entity.searchValue!=null and entity.searchValue!='' "> <if test="entity.searchValue!=null and entity.searchValue!=''">
AND (dbn.title LIKE CONCAT('%',#{entity.searchValue},'%') OR AND (dbn.title LIKE CONCAT('%',#{entity.searchValue},'%') OR
dbn.detail LIKE CONCAT('%',#{entity.searchValue},'%')) dbn.detail LIKE CONCAT('%',#{entity.searchValue},'%'))
</if> </if>
<if test="entity.reportStatus!=null and entity.reportStatus!='' "> <if test="entity.reportStatus!=null and entity.reportStatus!=''">
<choose> <choose>
<when test="entity.reportStatus=='审核中'"> <when test="entity.reportStatus=='审核中'">
and mySign.status ='01' and dbn.end_date &gt;= CURDATE() AND mySign.status ='01' AND dbn.end_date &gt;= CURDATE()
</when> </when>
<when test="entity.reportStatus=='已通过'"> <when test="entity.reportStatus=='已通过'">
and mySign.status ='02' AND mySign.status ='02'
</when> </when>
<when test="entity.reportStatus=='未合作'"> <when test="entity.reportStatus=='未合作'">
and mySign.status ='01' and dbn.end_date &lt; CURDATE() AND mySign.status ='01' AND dbn.end_date &lt; CURDATE()
</when> </when>
</choose> </choose>
</if> </if>
group by dbn.id,mySign.id
ORDER BY ORDER BY
dbn.create_time DESC dbn.create_time DESC
</select> </select>
<select id="myPublishNoticeList" resultType="com.ruoyi.busi.vo.BusiNoticeVo"> <select id="myPublishNoticeList" resultType="com.ruoyi.busi.vo.BusiNoticeVo">
SELECT SELECT
dbn.*, dbn.*,
-- dbnv.view_num AS viewNum,
su.avatar, su.avatar,
su.nick_name AS userNickName, su.nick_name AS userNickName,
count(sign.id) as reportNum, (SELECT COUNT(1) FROM dl_busi_notice_sign sign
WHERE sign.notice_id = dbn.id AND sign.del_flag = 0) as reportNum,
CASE CASE
WHEN dbn.end_date &lt; CURDATE() THEN '已关闭' WHEN dbn.end_date &lt; CURDATE() THEN '已关闭'
WHEN dbn.approval_status = '0' THEN '审核中' WHEN dbn.approval_status = '0' THEN '审核中'
@ -395,31 +385,29 @@ order by dbns.create_time desc
END AS reportStatusText END AS reportStatusText
FROM FROM
dl_busi_notice dbn dl_busi_notice dbn
-- LEFT JOIN dl_busi_notice_view dbnv ON dbn.id = dbnv.id
LEFT JOIN sys_user su ON dbn.user_id = su.user_id LEFT JOIN sys_user su ON dbn.user_id = su.user_id
LEFT join dl_busi_notice_sign sign on sign.notice_id = dbn.id and sign.del_flag = 0
WHERE WHERE
dbn.del_flag = 0 and dbn.approval_status !=8 and dbn.user_id = #{entity.userId} dbn.del_flag = 0 AND dbn.approval_status != '8' AND dbn.user_id = #{entity.userId}
<if test="entity.searchValue!=null and entity.searchValue!='' "> <if test="entity.searchValue!=null and entity.searchValue!=''">
AND (dbn.title LIKE CONCAT('%',#{entity.searchValue},'%') OR AND (dbn.title LIKE CONCAT('%',#{entity.searchValue},'%') OR
dbn.detail LIKE CONCAT('%',#{entity.searchValue},'%')) dbn.detail LIKE CONCAT('%',#{entity.searchValue},'%'))
</if> </if>
<if test="entity.status!=null and entity.status!='' "> <if test="entity.status!=null and entity.status!=''">
<choose> <choose>
<when test="entity.status=='进行中'"> <when test="entity.status=='进行中'">
and dbn.approval_status !='2' and dbn.end_date &gt;= CURDATE() AND dbn.approval_status != '2' AND dbn.end_date &gt;= CURDATE()
</when> </when>
<when test="entity.status=='已关闭'"> <when test="entity.status=='已关闭'">
and (dbn.approval_status ='2' or dbn.end_date &lt; CURDATE()) AND (dbn.approval_status = '2' OR dbn.end_date &lt; CURDATE())
</when> </when>
<when test="entity.status=='审核通过'"> <when test="entity.status=='审核通过'">
and (dbn.approval_status ='1' or dbn.end_date &lt; CURDATE()) AND (dbn.approval_status = '1' OR dbn.end_date &lt; CURDATE())
</when> </when>
</choose> </choose>
</if> </if>
group by dbn.id
ORDER BY ORDER BY
dbn.create_time DESC dbn.create_time DESC
</select> </select>
</mapper> </mapper>

View File

@ -19,45 +19,69 @@
</sql> </sql>
<select id="getOkUser" resultType="com.alibaba.fastjson2.JSONObject" <select id="getOkUser" resultType="com.alibaba.fastjson2.JSONObject"
parameterType="com.ruoyi.busi.vo.SubscribeDataObj"> parameterType="com.ruoyi.busi.vo.SubscribeDataObj">
SELECT SELECT DISTINCT
distinct su.wx_open_id as wxOpenId, su.wx_open_id as wxOpenId,
sub.keywords_list as keywordsList, sub.keywords_list as keywordsList,
'0' as allOk '0' as allOk
FROM FROM
dl_busi_subscribe sub dl_busi_subscribe sub
inner join sys_user su on sub.user_id = su.user_id and su.wx_open_id is not null INNER JOIN sys_user su ON sub.user_id = su.user_id AND su.wx_open_id IS NOT NULL
where sub.new_notice = '1' and sub.del_flag ='0' WHERE sub.new_notice = '1'
AND sub.del_flag = '0'
-- 领域 -- 领域
and (sub.blogger_type_code = '-1' AND (
sub.blogger_type_code = '-1'
<if test="bloggerTypeCode != null and bloggerTypeCode.length>0"> <if test="bloggerTypeCode != null and bloggerTypeCode.length>0">
<foreach item="item" index="index" collection="bloggerTypeCode" OR <foreach item="item" index="index" collection="bloggerTypeCode"
open="(" separator="or" close=")"> open="(" separator=" OR " close=")">
sub.blogger_type_code like concat('%',#{item},'%') sub.blogger_type_code LIKE CONCAT('%',#{item},'%')
</foreach> </foreach>
</if> </if>
) )
-- 平台 -- 平台
and (sub.platform_code = '-1' or sub.platform_code like concat('%',#{platformCode},'%')) AND (
sub.platform_code = '-1'
OR sub.platform_code LIKE CONCAT('%',#{platformCode},'%')
)
-- 结算方式 -- 结算方式
and (sub.settle_type_code = '-1' or sub.settle_type_code like concat('%',#{settleTypeCode},'%')) AND (
sub.settle_type_code = '-1'
OR sub.settle_type_code LIKE CONCAT('%',#{settleTypeCode},'%')
)
-- 粉丝限制 -- 粉丝限制
and (sub.fans_limit = '0' or sub.fans_limit is null AND (
or (sub.fans_limit = '1' and sub.fans_up <![CDATA[<= ]]> #{fansUp} and sub.fans_down <![CDATA[>= ]]> #{fansDown})) sub.fans_limit = '0'
OR sub.fans_limit IS NULL
OR (
sub.fans_limit = '1'
AND sub.fans_up <![CDATA[<= ]]> #{fansUp}
AND sub.fans_down <![CDATA[>= ]]> #{fansDown}
)
)
-- 收费限制 -- 收费限制
and (sub.fee_limit = '0' or sub.fee_limit is null AND (
or (sub.fee_limit = '1' and sub.fee_up <![CDATA[<= ]]> #{feeUp} and sub.fee_down <![CDATA[>= ]]> #{feeDown})) sub.fee_limit = '0'
union OR sub.fee_limit IS NULL
SELECT OR (
distinct su.wx_open_id as wxOpenId, sub.fee_limit = '1'
AND sub.fee_up <![CDATA[<= ]]> #{feeUp}
AND sub.fee_down <![CDATA[>= ]]> #{feeDown}
)
)
UNION
SELECT DISTINCT
su.wx_open_id as wxOpenId,
'' as keywordsList, '' as keywordsList,
'1' as allOk '1' as allOk
FROM FROM
dl_busi_subscribe sub dl_busi_subscribe sub
inner join sys_user su on sub.user_id = su.user_id and su.wx_open_id is not null INNER JOIN sys_user su ON sub.user_id = su.user_id AND su.wx_open_id IS NOT NULL
inner join dl_busi_user_love love on love.user_id = sub.user_id and love.love_user_id = #{loveUserId} INNER JOIN dl_busi_user_love love ON love.user_id = sub.user_id AND love.love_user_id = #{loveUserId}
where sub.new_notice = '1' and sub.del_flag ='0' and sub.fork_notice = '1' WHERE sub.new_notice = '1'
AND sub.del_flag = '0'
AND sub.fork_notice = '1'
</select> </select>

View File

@ -62,17 +62,10 @@
su.status AS status, su.status AS status,
su.avatar AS avatar, su.avatar AS avatar,
su.phonenumber AS phonenumber, su.phonenumber AS phonenumber,
su_temp.nick_name AS inviteName, su_temp.nick_name AS inviteName
GROUP_CONCAT(mc.card_name SEPARATOR ', ') AS memberCardName
from dl_member_user main from dl_member_user main
LEFT JOIN sys_user su ON main.user_id = su.user_id AND su.del_flag = 0 LEFT JOIN sys_user su ON main.user_id = su.user_id AND su.del_flag = 0
LEFT JOIN sys_user su_temp ON su.invite_id = su_temp.user_id AND su_temp.del_flag = 0 LEFT JOIN sys_user su_temp ON su.invite_id = su_temp.user_id AND su_temp.del_flag = 0
LEFT JOIN dl_member_card mc
ON main.user_id = mc.user_id
AND mc.start_date &lt;= CURDATE()
AND mc.end_date &gt;= CURDATE()
AND mc.del_flag = 0
AND mc.user_type = #{entity.userType}
<where> <where>
main.del_flag = 0 main.del_flag = 0
<if test="entity.userType != null and entity.userType != ''"> <if test="entity.userType != null and entity.userType != ''">
@ -97,7 +90,7 @@
ORDER BY ${entity.params.orderBy} ORDER BY ${entity.params.orderBy}
</when> </when>
<otherwise> <otherwise>
ORDER BY mc.create_time desc ORDER BY main.create_time desc
</otherwise> </otherwise>
</choose> </choose>
@ -157,29 +150,39 @@
su.avatar AS avatar, su.avatar AS avatar,
su.phonenumber AS phonenumber, su.phonenumber AS phonenumber,
su_temp.nick_name AS inviteName, su_temp.nick_name AS inviteName,
GROUP_CONCAT(mc.card_name SEPARATOR ', ') AS memberCardName, mc.card_name AS memberCardName,
sum(dmo2.goods_price) AS monthMoney, dmo2.monthMoney AS monthMoney,
sum(dmo.goods_price) AS allMoney, dmo.allMoney AS allMoney,
main.create_time main.create_time
from dl_member_user main from dl_member_user main
LEFT JOIN sys_user su ON main.user_id = su.user_id AND su.del_flag = 0 LEFT JOIN sys_user su ON main.user_id = su.user_id AND su.del_flag = 0
LEFT JOIN sys_user su_temp ON su.invite_id = su_temp.user_id AND su_temp.del_flag = 0 LEFT JOIN sys_user su_temp ON su.invite_id = su_temp.user_id AND su_temp.del_flag = 0
LEFT JOIN ( LEFT JOIN (
SELECT mc_inner.* SELECT mc1.user_id, mc1.card_name
FROM dl_member_card mc_inner FROM dl_member_card mc1
INNER JOIN ( INNER JOIN (
SELECT user_id, MAX(create_time) AS latest_time SELECT user_id, MAX(create_time) as latest_time
FROM dl_member_card FROM dl_member_card
WHERE del_flag = 0 AND user_type = #{entity.userType} WHERE del_flag = 0 AND user_type = #{entity.userType}
GROUP BY user_id GROUP BY user_id
) latest ON mc_inner.user_id = latest.user_id AND mc_inner.create_time = latest.latest_time ) mc2 ON mc1.user_id = mc2.user_id AND mc1.create_time = mc2.latest_time
WHERE mc1.start_date &lt;= CURDATE() AND mc1.end_date &gt;= CURDATE()
) mc ON main.user_id = mc.user_id ) mc ON main.user_id = mc.user_id
AND mc.start_date &lt;= CURDATE() LEFT JOIN (
AND mc.end_date &gt;= CURDATE() SELECT user_id, SUM(goods_price) AS allMoney
left join dl_member_order dmo on dmo.user_id = su.user_id and dmo.user_type = '02' and dmo.is_pay = 1 FROM dl_member_order
left join dl_member_order dmo2 on dmo2.user_id = su.user_id and dmo2.user_type = '02' and dmo2.is_pay = 1 WHERE user_type = '02' AND is_pay = 1
and dmo.create_time <![CDATA[>=]]> DATE_FORMAT(CURDATE(), '%Y-%m-01') GROUP BY user_id
and dmo.create_time <![CDATA[<=]]> LAST_DAY(CURDATE()) ) dmo ON dmo.user_id = su.user_id
LEFT JOIN (
SELECT user_id, SUM(goods_price) AS monthMoney
FROM dl_member_order
WHERE user_type = '02'
AND is_pay = 1
AND create_time &gt;= DATE_FORMAT(CURDATE(), '%Y-%m-01')
AND create_time &lt;= LAST_DAY(CURDATE())
GROUP BY user_id
) dmo2 ON dmo2.user_id = su.user_id
<where> <where>
main.del_flag = 0 main.del_flag = 0
<if test="entity.userType != null and entity.userType != ''"> <if test="entity.userType != null and entity.userType != ''">
@ -196,25 +199,21 @@
<if test="entity.params.minnum != null"> and main.ttotal_num &gt;= #{entity.params.minnum} </if> <if test="entity.params.minnum != null"> and main.ttotal_num &gt;= #{entity.params.minnum} </if>
<if test="entity.params.maxnum != null"> and main.ttotal_num &lt;= #{entity.params.maxnum} </if> <if test="entity.params.maxnum != null"> and main.ttotal_num &lt;= #{entity.params.maxnum} </if>
<if test="entity.params.isVip != null and entity.params.isVip != ''"> and mc.card_name = #{entity.params.isVip} </if> <if test="entity.params.isVip != null and entity.params.isVip != ''"> and mc.card_name = #{entity.params.isVip} </if>
</where> </where>
GROUP BY main.user_id
<if test="entity.params.isXf != null and entity.params.isXf == '01'"> <if test="entity.params.isXf != null and entity.params.isXf == '01'">
having sum(dmo.goods_price)>0 AND dmo.allMoney > 0
</if> </if>
<if test="entity.params.isXf != null and entity.params.isXf == '02'"> <if test="entity.params.isXf != null and entity.params.isXf == '02'">
having sum(dmo.goods_price) is null AND (dmo.allMoney IS NULL OR dmo.allMoney = 0)
</if> </if>
<choose> <choose>
<when test="entity.params.orderBy != null and entity.params.orderBy != ''"> <when test="entity.params.orderBy != null and entity.params.orderBy != ''">
ORDER BY ${entity.params.orderBy} ORDER BY ${entity.params.orderBy}
</when> </when>
<otherwise> <otherwise>
ORDER BY mc.create_time desc ORDER BY mc.card_name IS NULL, main.create_time DESC
</otherwise> </otherwise>
</choose> </choose>
</select> </select>
</mapper> </mapper>