Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
张松
2025-10-16 14:05:36 +08:00
25 changed files with 572 additions and 69 deletions

View File

@@ -43,10 +43,10 @@ public interface ShopUserMapper extends BaseMapper<ShopUser> {
* @param shopId 店铺ID
* @return 分页结果
*/
Page<ShopUser> selectPushEventUser(
List<ShopUser> selectPushEventUser(
@Param("mainShopId") Long mainShopId,
@Param("shopId") Long shopId,
SmsPushEventUser smsPushEventUser
@Param("param") SmsPushEventUser smsPushEventUser
);
}

View File

@@ -29,15 +29,13 @@ import com.github.pagehelper.PageInfo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
@@ -46,6 +44,7 @@ import java.util.stream.Collectors;
* @author Administrator
* @since 2025-02-08
*/
@Slf4j
@DubboService
public class AShopUserServiceImpl implements AShopUserService {
@Resource
@@ -95,14 +94,18 @@ public class AShopUserServiceImpl implements AShopUserService {
@Override
public Page<ShopUser> getPushEventUser(SmsPushEventUser smsPushEventUser) {
PageHelper.startPage(new Page<>(smsPushEventUser.getPage(), smsPushEventUser.getSize()));
Long mainShopId = shopInfoService.getMainIdByShopId(smsPushEventUser.getShopId());
// 调用Mapper层查询
return shopUserMapper.selectPushEventUser(
mainShopId,
smsPushEventUser.getShopId(),
smsPushEventUser
);
try {
Long mainShopId = shopInfoService.getMainIdByShopId(smsPushEventUser.getShopId());
PageHelper.startPage(smsPushEventUser.getPage(), smsPushEventUser.getSize());
smsPushEventUser.checkIsAll();
// 调用Mapper层查询
List<ShopUser> shopUsers = shopUserMapper.selectPushEventUser(mainShopId,
smsPushEventUser.getShopId(), smsPushEventUser);
return PageUtil.convert(new PageInfo<>(shopUsers));
}catch (Exception e){
log.info("获取营销推送任务用户列表失败{},{}", smsPushEventUser, e.getMessage());
return PageUtil.convert(new PageInfo<>());
}
}
@Override

View File

@@ -51,7 +51,6 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
}
@Override
public ShopUser getShopUserInfo(Long shopId, long userId) {
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
@@ -117,6 +116,11 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
shopUser.setConsumeCount(userInfo.getConsumeCount() + 1);
shopUser.setConsumeAmount(userInfo.getConsumeAmount().add(shopUserEditDTO.getMoney()));
updateById(shopUser);
} else if (shopUserEditDTO.getType() == 1 && shopUserEditDTO.getBizEnum().getCode().contains("In")) {
ShopUser shopUser = new ShopUser();
shopUser.setId(userInfo.getId());
shopUser.setRechargeCount(userInfo.getRechargeCount() + 1);
updateById(shopUser);
}
return userFlow.getId();
}

View File

@@ -122,9 +122,9 @@
u.id, u.head_img, u.nick_name, u.amount, u.account_points, u.phone,
<choose>
<!-- 当有筛选条件时才计算订单相关字段 -->
<when test="orderTimeToday == 1 or orderTimeYesterday == 1 or
orderTimeTwoWeeks == 1 or orderTimeMoreThanTwoWeeks == 1 or
noOrder == 1 or oneOrder == 1 or fiveOrder == 1">
<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,
@@ -141,54 +141,48 @@
0 AS earlier_orders
</otherwise>
</choose>
FROM shop_user u
FROM tb_shop_user u
<!-- 只有当有筛选条件时才关联order表 -->
<if test="orderTimeToday == 1 or orderTimeYesterday == 1 or
orderTimeTwoWeeks == 1 or orderTimeMoreThanTwoWeeks == 1 or
noOrder == 1 or oneOrder == 1 or fiveOrder == 1">
LEFT JOIN `order` 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 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
<!-- 性别筛选条件 -->
<if test="(sexMan == 1 or sexWoman == 1 or sexUnknown == 1)">
<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="sexMan == 1">OR u.sex = 1</if>
<if test="sexWoman == 1">OR u.sex = 0</if>
<if test="sexUnknown == 1">OR u.sex IS NULL</if>
<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="isVip != null">
AND u.is_vip = #{isVip}
<if test="param.isVip != null">
AND u.is_vip = #{param.isVip}
</if>
<!-- 充值状态筛选 -->
<if test="isRecharge != null">
AND
<if test="isRecharge == 0">
u.recharge_count = 0
</if>
<if test="isRecharge != 0">
u.recharge_count > 0
</if>
</if>
<if test="param.isRecharge != null">
AND u.recharge_count <![CDATA[ ${param.isRecharge == 0 ? '=' : '>'} ]]> 0
</if>
<!-- 只有当有筛选条件时才需要HAVING子句 -->
<if test="orderTimeToday == 1 or orderTimeYesterday == 1 or
orderTimeTwoWeeks == 1 or orderTimeMoreThanTwoWeeks == 1 or
noOrder == 1 or oneOrder == 1 or fiveOrder == 1">
<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="orderTimeToday == 1">OR today_orders > 0</if>
<if test="orderTimeYesterday == 1">OR yesterday_orders > 0</if>
<if test="orderTimeTwoWeeks == 1">OR two_weeks_orders > 0</if>
<if test="orderTimeMoreThanTwoWeeks == 1">OR earlier_orders > 0</if>
<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="noOrder == 1">OR order_count = 0</if>
<if test="oneOrder == 1">OR order_count = 1</if>
<if test="fiveOrder == 1">OR order_count >= 5</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