| | |
| | | package com.xiaopeng.operation.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.xiaopeng.api.dto.operation.XpActivityDto; |
| | | import com.xiaopeng.api.feignClient.order.XpOrderClient; |
| | | import com.xiaopeng.api.model.operation.XpActicityStrategy; |
| | | import com.xiaopeng.api.model.operation.XpActicityUser; |
| | | import com.xiaopeng.api.model.operation.XpActivity; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Random; |
| | |
| | | @Resource |
| | | private IXpActivityNoticeService activityNotice; |
| | | |
| | | @Resource |
| | | private XpOrderClient xpOrderClient; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<XpActivity> pageList(XpActivityPageListQuery query) { |
| | | PageInfo<XpActivity> pageInfo = new PageInfo<>(query.getPageNum(),query.getPageSize()); |
| | |
| | | query.like(XpActivity::getActicityName, acticityName); |
| | | return listObjs(query, Object::toString); |
| | | } |
| | | |
| | | @Override |
| | | public XpActivity activiting() { |
| | | LambdaQueryWrapper<XpActivity> query = new LambdaQueryWrapper<>(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | query.le(XpActivity::getStartTime, now) |
| | | .ge(XpActivity::getEndTime, now); |
| | | List<XpActivity> list = list(query); |
| | | if(!list.isEmpty()){ |
| | | return list.get(new Random().nextInt(list.size())); |
| | | } |
| | | return null; |
| | | public XpActivity activiting(Long uid) { |
| | | //获取当前用户可参与的活动 |
| | | List<Integer> actitctiyIds = new ArrayList<>(); |
| | | //全部用户 |
| | | List<XpActicityUser> list = userService.list(new QueryWrapper<XpActicityUser>().eq("is_deleted", 0).eq("user_type", 1)); |
| | | actitctiyIds.addAll(list.stream().map(XpActicityUser::getActitcityId).collect(Collectors.toList())); |
| | | //判断用户类型 2=老用户,3=新用户,4=流失用户 |
| | | Integer userType = xpOrderClient.determineUserType(uid).getData(); |
| | | list = userService.list(new QueryWrapper<XpActicityUser>().eq("is_deleted", 0).eq("user_type", userType)); |
| | | actitctiyIds.addAll(list.stream().map(XpActicityUser::getActitcityId).collect(Collectors.toList())); |
| | | //指定用户 |
| | | list = userService.list(new QueryWrapper<XpActicityUser>().eq("is_deleted", 0).eq("user_type", 5) |
| | | .last(" and JSON_CONTAINS(user_list, '" + uid + "', '$')")); |
| | | actitctiyIds.addAll(list.stream().map(XpActicityUser::getActitcityId).collect(Collectors.toList())); |
| | | |
| | | XpActivity one = this.getOne(new QueryWrapper<XpActivity>().eq("status", 2).eq("is_deleted", 0) |
| | | .eq("mini_program_notification", 1).in(!actitctiyIds.isEmpty(), "id", actitctiyIds) |
| | | .last(" and now() between start_time and end_time order by float_window_priority desc limit 1")); |
| | | return one; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return ret; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取悬浮弹窗活动数据 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public XpActivity getFloatActicity(Long uid) { |
| | | //获取当前用户可参与的活动 |
| | | List<Integer> actitctiyIds = new ArrayList<>(); |
| | | //全部用户 |
| | | List<XpActicityUser> list = userService.list(new QueryWrapper<XpActicityUser>().eq("is_deleted", 0).eq("user_type", 1)); |
| | | actitctiyIds.addAll(list.stream().map(XpActicityUser::getActitcityId).collect(Collectors.toList())); |
| | | //判断用户类型 2=老用户,3=新用户,4=流失用户 |
| | | Integer userType = xpOrderClient.determineUserType(uid).getData(); |
| | | list = userService.list(new QueryWrapper<XpActicityUser>().eq("is_deleted", 0).eq("user_type", userType)); |
| | | actitctiyIds.addAll(list.stream().map(XpActicityUser::getActitcityId).collect(Collectors.toList())); |
| | | //指定用户 |
| | | list = userService.list(new QueryWrapper<XpActicityUser>().eq("is_deleted", 0).eq("user_type", 5) |
| | | .last(" and JSON_CONTAINS(user_list, '" + uid + "', '$')")); |
| | | actitctiyIds.addAll(list.stream().map(XpActicityUser::getActitcityId).collect(Collectors.toList())); |
| | | |
| | | XpActivity one = this.getOne(new QueryWrapper<XpActivity>().eq("status", 2).eq("is_deleted", 0) |
| | | .eq("enable_float_window", 1).in(!actitctiyIds.isEmpty(), "id", actitctiyIds) |
| | | .last(" and now() between start_time and end_time order by float_window_priority desc limit 1")); |
| | | return one; |
| | | } |
| | | } |