邀请人列表 条件 添加邀请人 邀请身份 是否有效

This commit is contained in:
2025-10-30 17:59:55 +08:00
parent 84d2420c59
commit 86e6714f97
10 changed files with 136 additions and 120 deletions

View File

@@ -70,7 +70,7 @@ public interface ShopUserMapper extends BaseMapper<ShopUser> {
* @param distributionUserId 分销员ID
* @return 分页结果
*/
List<InviteUserVO> getInviteUser(Long distributionUserId, Long shopUserId);
List<InviteUserVO> getInviteUser(Long distributionUserId, Long shopUserId, Long distributionLevelId);
void updateOneOrTwoAmount(Long userId, Long mainShopId, BigDecimal amount, Integer isOne);

View File

@@ -99,9 +99,9 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
}
@Override
public Page<InviteUserVO> getInviteUser(Long distributionUserId, Long shopUserId, Integer page, Integer size) {
public Page<InviteUserVO> getInviteUser(Long distributionUserId, Long shopUserId, Long distributionLevelId, Integer page, Integer size) {
PageHelper.startPage(page, size);
List<InviteUserVO> inviteUser = mapper.getInviteUser(distributionUserId, shopUserId);
List<InviteUserVO> inviteUser = mapper.getInviteUser(distributionUserId, shopUserId, distributionLevelId);
return PageUtil.convert(new PageInfo<>(inviteUser));
}

View File

@@ -5,7 +5,7 @@
<mapper namespace="com.czg.service.account.mapper.ShopUserMapper">
<update id="incrAccount">
update tb_shop_user
set amount = COALESCE(amount, 0) + #{money},
set amount = COALESCE(amount, 0) + #{money},
update_time = #{time}
where id = #{id}
@@ -32,7 +32,6 @@
</update>
<select id="selectUserSummary" resultType="com.czg.account.dto.shopuser.ShopUserSummaryDTO">
select count(a.id) userTotal, sum(IFNULL(a.amount, 0)) balanceTotal,sum(IFNULL(b.amount,0)) chargeTotal from
tb_shop_user as a
@@ -58,7 +57,7 @@
COUNT(DISTINCT c.id) AS couponNum
FROM tb_shop_user AS b
LEFT JOIN mk_shop_coupon_record AS c
ON c.shop_user_id = b.id
ON c.shop_user_id = b.id
AND c.`status` = 1
AND c.use_start_time &lt; NOW()
AND c.use_end_time > NOW()
@@ -130,78 +129,78 @@
</select>
<select id="selectPushEventUser" resultType="com.czg.account.entity.ShopUser">
SELECT DISTINCT
u.id,u.user_id, u.head_img, u.nick_name, u.amount, u.account_points, u.phone,
<choose>
<!-- 当有筛选条件时才计算订单相关字段 -->
<when test="param.orderTimeToday == 1 or param.orderTimeYesterday == 1 or
<select id="selectPushEventUser" resultType="com.czg.account.entity.ShopUser">
SELECT DISTINCT
u.id,u.user_id, u.head_img, u.nick_name, u.amount, u.account_points, u.phone,
<choose>
<!-- 当有筛选条件时才计算订单相关字段 -->
<when test="param.orderTimeToday == 1 or param.orderTimeYesterday == 1 or
param.orderTimeTwoWeeks == 1 or param.orderTimeMoreThanTwoWeeks == 1 or
param.noOrder == 1 or param.oneOrder == 1 or param.fiveOrder == 1">
COUNT(o.id) AS order_count,
SUM(CASE WHEN o.trade_day = CURDATE() THEN 1 ELSE 0 END) AS today_orders,
SUM(CASE WHEN o.trade_day = CURDATE() - INTERVAL 1 DAY THEN 1 ELSE 0 END) AS yesterday_orders,
SUM(CASE WHEN o.trade_day >= CURDATE() - INTERVAL 2 WEEK AND o.trade_day &lt; CURDATE() - INTERVAL 1
DAY
THEN 1 ELSE 0 END) AS two_weeks_orders,
SUM(CASE WHEN o.trade_day &lt; CURDATE() - INTERVAL 2 WEEK THEN 1 ELSE 0 END) AS earlier_orders
</when>
<!-- 无筛选条件时不计算订单相关字段 -->
<otherwise>
0 AS order_count,
0 AS today_orders,
0 AS yesterday_orders,
0 AS two_weeks_orders,
0 AS earlier_orders
</otherwise>
</choose>
FROM tb_shop_user u
<!-- 只有当有筛选条件时才关联order表 -->
<if test="param.orderTimeToday == 1 or param.orderTimeYesterday == 1 or
COUNT(o.id) AS order_count,
SUM(CASE WHEN o.trade_day = CURDATE() THEN 1 ELSE 0 END) AS today_orders,
SUM(CASE WHEN o.trade_day = CURDATE() - INTERVAL 1 DAY THEN 1 ELSE 0 END) AS yesterday_orders,
SUM(CASE WHEN o.trade_day >= CURDATE() - INTERVAL 2 WEEK AND o.trade_day &lt; CURDATE() - INTERVAL 1
DAY
THEN 1 ELSE 0 END) AS two_weeks_orders,
SUM(CASE WHEN o.trade_day &lt; CURDATE() - INTERVAL 2 WEEK THEN 1 ELSE 0 END) AS earlier_orders
</when>
<!-- 无筛选条件时不计算订单相关字段 -->
<otherwise>
0 AS order_count,
0 AS today_orders,
0 AS yesterday_orders,
0 AS two_weeks_orders,
0 AS earlier_orders
</otherwise>
</choose>
FROM tb_shop_user u
<!-- 只有当有筛选条件时才关联order表 -->
<if test="param.orderTimeToday == 1 or param.orderTimeYesterday == 1 or
param.orderTimeTwoWeeks == 1 or param.orderTimeMoreThanTwoWeeks == 1 or
param.noOrder == 1 or param.oneOrder == 1 or param.fiveOrder == 1">
LEFT JOIN `tb_order_info` o ON u.user_id = o.user_id and o.user_id is not null AND o.shop_id = #{shopId}
AND o.status = 'done'
</if>
WHERE u.main_shop_id = #{mainShopId} and u.phone is not null and u.user_id is not null
<!-- 性别筛选条件 -->
<if test="!(param.sexMan == 1 and param.sexWoman == 1 and param.sexUnknown == 1)
LEFT JOIN `tb_order_info` o ON u.user_id = o.user_id and o.user_id is not null AND o.shop_id = #{shopId}
AND o.status = 'done'
</if>
WHERE u.main_shop_id = #{mainShopId} and u.phone is not null and u.user_id is not null
<!-- 性别筛选条件 -->
<if test="!(param.sexMan == 1 and param.sexWoman == 1 and param.sexUnknown == 1)
and (param.sexMan == 1 or param.sexWoman == 1 or param.sexUnknown == 1)">
AND
<trim prefix="(" suffix=")" prefixOverrides="OR">
<if test="param.sexMan == 1">OR u.sex = 1</if>
<if test="param.sexWoman == 1">OR u.sex = 0</if>
<if test="param.sexUnknown == 1">OR u.sex IS NULL</if>
</trim>
</if>
AND
<trim prefix="(" suffix=")" prefixOverrides="OR">
<if test="param.sexMan == 1">OR u.sex = 1</if>
<if test="param.sexWoman == 1">OR u.sex = 0</if>
<if test="param.sexUnknown == 1">OR u.sex IS NULL</if>
</trim>
</if>
<!-- 会员状态筛选 -->
<if test="param.isVip != null">
AND u.is_vip = #{param.isVip}
</if>
<!-- 会员状态筛选 -->
<if test="param.isVip != null">
AND u.is_vip = #{param.isVip}
</if>
<if test="param.isRecharge != null">
AND u.recharge_count <![CDATA[ ${param.isRecharge == 0 ? '=' : '>'} ]]> 0
</if>
<!-- 只有当有筛选条件时才需要HAVING子句 -->
<if test="param.orderTimeToday == 1 or param.orderTimeYesterday == 1 or
<if test="param.isRecharge != null">
AND u.recharge_count <![CDATA[ ${param.isRecharge == 0 ? '=' : '>'} ]]> 0
</if>
<!-- 只有当有筛选条件时才需要HAVING子句 -->
<if test="param.orderTimeToday == 1 or param.orderTimeYesterday == 1 or
param.orderTimeTwoWeeks == 1 or param.orderTimeMoreThanTwoWeeks == 1 or
param.noOrder == 1 or param.oneOrder == 1 or param.fiveOrder == 1">
GROUP BY u.id
HAVING
<trim prefix="(" suffix=")" prefixOverrides="OR">
<if test="param.orderTimeToday == 1">OR today_orders > 0</if>
<if test="param.orderTimeYesterday == 1">OR yesterday_orders > 0</if>
<if test="param.orderTimeTwoWeeks == 1">OR two_weeks_orders > 0</if>
<if test="param.orderTimeMoreThanTwoWeeks == 1">OR earlier_orders > 0</if>
GROUP BY u.id
HAVING
<trim prefix="(" suffix=")" prefixOverrides="OR">
<if test="param.orderTimeToday == 1">OR today_orders > 0</if>
<if test="param.orderTimeYesterday == 1">OR yesterday_orders > 0</if>
<if test="param.orderTimeTwoWeeks == 1">OR two_weeks_orders > 0</if>
<if test="param.orderTimeMoreThanTwoWeeks == 1">OR earlier_orders > 0</if>
<if test="param.noOrder == 1">OR order_count = 0</if>
<if test="param.oneOrder == 1">OR order_count = 1</if>
<if test="param.fiveOrder == 1">OR order_count >= 5</if>
</trim>
</if>
order by u.create_time desc
</select>
<if test="param.noOrder == 1">OR order_count = 0</if>
<if test="param.oneOrder == 1">OR order_count = 1</if>
<if test="param.fiveOrder == 1">OR order_count >= 5</if>
</trim>
</if>
order by u.create_time desc
</select>
<select id="selectAcPushEventUser" resultType="com.czg.account.entity.ShopUser">
SELECT DISTINCT
@@ -291,11 +290,12 @@
dist.status AS status,
dist.distribution_level_id AS levelId,
dist.distribution_level_name AS levelName,
CASE WHEN dist.id IS NOT NULL THEN 1 ELSE 0 END AS isDistribution
dist.distribution_shops AS distributionShops
FROM `tb_shop_user` as u
left join mk_distribution_user dist on u.id = dist.id
WHERE u.`distribution_user_id` = #{distributionUserId}
<if test="distributionLevelId != null">and dist.distribution_level_id = #{distributionLevelId}</if>
<if test="shopUserId != null">and u.id = #{shopUserId}</if>
ORDER BY u.`id` DESC
ORDER BY u.`invite_time` DESC
</select>
</mapper>