Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
b2c287d368
|
|
@ -7,6 +7,7 @@ import com.czg.account.service.ShopUserFlowService;
|
|||
import com.czg.account.vo.ShopUserFlowVO;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.market.entity.SmsPushEventUser;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
|
|
@ -157,4 +158,15 @@ public class ShopUserController {
|
|||
return CzgResult.success(shopUserService.updateMoney(shopUserMoneyEditDTO) > 0L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取营销推送任务用户列表
|
||||
* @param smsPushEventUser 营销推送任务用户
|
||||
* @return 用户列表
|
||||
*/
|
||||
@PostMapping("/getPushEventUser")
|
||||
public CzgResult<Page<ShopUser>> getPushEventUser(@RequestBody @Validated SmsPushEventUser smsPushEventUser) {
|
||||
smsPushEventUser.setShopId(StpKit.USER.getShopId());
|
||||
return CzgResult.success(shopUserService.getPushEventUser(smsPushEventUser));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,10 @@ public class ShopUser implements Serializable {
|
|||
* 钱包余额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 充值次数
|
||||
*/
|
||||
private Integer rechargeCount;
|
||||
/**
|
||||
* 消费累计
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.czg.account.service;
|
|||
|
||||
import com.czg.account.dto.shopuser.*;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.market.entity.SmsPushEventUser;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
|
@ -19,6 +20,7 @@ public interface AShopUserService {
|
|||
Page<ShopUser> getPage(String key, Integer isVip);
|
||||
|
||||
Page<ShopUserDTO> getPage(String key, Integer isVip, BigDecimal amount);
|
||||
Page<ShopUser> getPushEventUser(SmsPushEventUser smsPushEventUser);
|
||||
|
||||
Boolean add(Long shopId, ShopUserAddDTO shopUserAddDTO);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,29 +41,54 @@ public class SmsPushEventUser implements Serializable {
|
|||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 性别 0未知 1男 2女
|
||||
* 性别 未知 男 女
|
||||
* 1查询 其余不查
|
||||
*/
|
||||
private String gender;
|
||||
private Integer sexMan;
|
||||
private Integer sexWoman;
|
||||
private Integer sexUnknown;
|
||||
|
||||
/**
|
||||
* 是否会员 0否 1是 null全查
|
||||
*/
|
||||
private Integer isVip;
|
||||
/**
|
||||
* 是否充值过 0否 1是 null为全查
|
||||
*/
|
||||
private Integer isRecharge;
|
||||
|
||||
|
||||
/**
|
||||
* 下单时间 0:今天 1:昨天 2:两周内 3:两周前
|
||||
* 下单时间 从未下单 1查询 其余不查
|
||||
*/
|
||||
private String orderTimes;
|
||||
private Integer noOrder;
|
||||
/**
|
||||
* 下单时间 下过一单 1查询 其余不查
|
||||
*/
|
||||
private Integer oneOrder;
|
||||
/**
|
||||
* 下单时间 下过五单及以上 1查询 其余不查
|
||||
*/
|
||||
private Integer fiveOrder;
|
||||
|
||||
|
||||
/**
|
||||
* 下单时间 0:从未下单 其它数字表示下过几单
|
||||
* 下单时间 今天 1查询 其余不查
|
||||
*/
|
||||
private String orderHistory;
|
||||
private Integer orderTimeToday;
|
||||
/**
|
||||
* 下单时间 昨天 1查询 其余不查
|
||||
*/
|
||||
private Integer orderTimeYesterday;
|
||||
/**
|
||||
* 下单时间 两周内 1查询 其余不查
|
||||
*/
|
||||
private Integer orderTimeTwoWeeks;
|
||||
/**
|
||||
* 下单时间 两周前 1查询 其余不查
|
||||
*/
|
||||
private Integer orderTimeMoreThanTwoWeeks;
|
||||
|
||||
/**
|
||||
* 充值过 0否 1是
|
||||
*/
|
||||
private String isRecharge;
|
||||
|
||||
/**
|
||||
* 会员 0非会员 1会员
|
||||
*/
|
||||
private String vip;
|
||||
|
||||
/**
|
||||
* 预留 短信推送用 会员等级 0 全部会员 1仅限等级 2以上等级
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.czg.account.dto.shopuser.ShopUserSummaryDTO;
|
|||
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
|
||||
import com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.market.entity.SmsPushEventUser;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -24,6 +25,7 @@ public interface ShopUserMapper extends BaseMapper<ShopUser> {
|
|||
List<ShopUserDTO> selectPageByKeyAndIsVip(@Param("shopId") Long shopId, @Param("isVip") Integer isVip, @Param("key") String key, @Param("amount") BigDecimal amount);
|
||||
|
||||
int incrAccount(@Param("id") Long id, @Param("time") LocalDateTime time, @Param("money") BigDecimal money);
|
||||
|
||||
int decrAccount(@Param("id") Long id, @Param("time") LocalDateTime time, @Param("money") BigDecimal money);
|
||||
|
||||
ShopUserSummaryDTO selectUserSummary(@Param("shopId") Long shopId, @Param("isVip") Integer isVip);
|
||||
|
|
@ -34,4 +36,17 @@ public interface ShopUserMapper extends BaseMapper<ShopUser> {
|
|||
|
||||
UserInfoAssetsSummaryDTO selectAssetsSummary(@Param("userId") Long userInfoId);
|
||||
|
||||
/**
|
||||
* 查询符合推送条件的用户
|
||||
*
|
||||
* @param mainShopId 主店铺ID
|
||||
* @param shopId 店铺ID
|
||||
* @return 分页结果
|
||||
*/
|
||||
Page<ShopUser> selectPushEventUser(
|
||||
@Param("mainShopId") Long mainShopId,
|
||||
@Param("shopId") Long shopId,
|
||||
SmsPushEventUser smsPushEventUser
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.czg.account.service.UserInfoService;
|
|||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.market.entity.MemberLevelConfig;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
import com.czg.market.entity.SmsPushEventUser;
|
||||
import com.czg.market.service.MemberLevelConfigService;
|
||||
import com.czg.market.service.MkShopCouponRecordService;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
|
|
@ -34,6 +35,9 @@ 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;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -89,6 +93,18 @@ public class AShopUserServiceImpl implements AShopUserService {
|
|||
return PageUtil.convert(new PageInfo<>(shopUserMapper.selectPageByKeyAndIsVip(mainIdByShopId, isVip, key, amount)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ShopUser> getPushEventUser(SmsPushEventUser smsPushEventUser) {
|
||||
PageHelper.startPage(PageUtil.buildPage());
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(smsPushEventUser.getShopId());
|
||||
// 调用Mapper层查询
|
||||
return shopUserMapper.selectPushEventUser(
|
||||
mainShopId,
|
||||
smsPushEventUser.getShopId(),
|
||||
smsPushEventUser
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO) {
|
||||
if (StrUtil.isNotBlank(shopUserEditDTO.getPhone())) {
|
||||
|
|
|
|||
|
|
@ -116,4 +116,82 @@
|
|||
${qwSql}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectPushEventUser" resultType="com.czg.account.entity.ShopUser">
|
||||
SELECT DISTINCT
|
||||
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">
|
||||
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 < CURDATE() - INTERVAL 1 DAY
|
||||
THEN 1 ELSE 0 END) AS two_weeks_orders,
|
||||
SUM(CASE WHEN o.trade_day < 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 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>
|
||||
WHERE u.main_shop_id = #{mainShopId}
|
||||
<!-- 性别筛选条件 -->
|
||||
<if test="(sexMan == 1 or sexWoman == 1 or 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>
|
||||
</trim>
|
||||
</if>
|
||||
|
||||
<!-- 会员状态筛选 -->
|
||||
<if test="isVip != null">
|
||||
AND u.is_vip = #{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>
|
||||
<!-- 只有当有筛选条件时才需要HAVING子句 -->
|
||||
<if test="orderTimeToday == 1 or orderTimeYesterday == 1 or
|
||||
orderTimeTwoWeeks == 1 or orderTimeMoreThanTwoWeeks == 1 or
|
||||
noOrder == 1 or oneOrder == 1 or 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="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>
|
||||
</trim>
|
||||
</if>
|
||||
order by u.create_time desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue