用户活动banner,优化
This commit is contained in:
@@ -123,6 +123,10 @@ public class FirstPageBannerAdminService {
|
||||
firstPageBanner.setDelTag(0);
|
||||
}
|
||||
firstPageBanner.setUpdateTime(date);
|
||||
return this.saveOrUpdateFirstPageBannerV2(firstPageBanner);
|
||||
}
|
||||
|
||||
public Boolean saveOrUpdateFirstPageBannerV2(FirstPageBanner firstPageBanner) {
|
||||
return firstPageBannerService.saveOrUpdate(firstPageBanner);
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,7 @@
|
||||
package com.accompany.admin.service.firstpage;
|
||||
|
||||
import com.accompany.admin.util.PartitionSecondBannerWrapper;
|
||||
import com.accompany.admin.vo.FirstPageBannerAdminVo;
|
||||
import com.accompany.admin.vo.SecondPageBannerAdminVo;
|
||||
import com.accompany.business.model.firstpage.FirstPageBanner;
|
||||
import com.accompany.business.model.firstpage.SecondPageBanner;
|
||||
import com.accompany.business.service.firstpage.SecondPageBannerService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
|
@@ -1,32 +1,44 @@
|
||||
package com.accompany.admin.service.userevent;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.accompany.admin.service.firstpage.FirstPageBannerAdminService;
|
||||
import com.accompany.admin.service.system.AdminUserService;
|
||||
import com.accompany.admin.service.userevent.vo.UserEventAdminVO;
|
||||
import com.accompany.business.dto.DomainConfigDto;
|
||||
import com.accompany.business.model.firstpage.FirstPageBanner;
|
||||
import com.accompany.business.model.userevent.UserEvent;
|
||||
import com.accompany.business.model.userevent.constant.UserEventConstant;
|
||||
import com.accompany.business.service.BaseSendService;
|
||||
import com.accompany.business.service.fillstrategy.strategy.FillConstant;
|
||||
import com.accompany.business.service.purse.UserPurseService;
|
||||
import com.accompany.business.service.record.BillRecordService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.service.userevent.UserEventService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.result.PageResult;
|
||||
import com.accompany.common.utils.EnvComponent;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.enumeration.BillObjTypeEnum;
|
||||
import com.accompany.core.enumeration.I18nAlertEnum;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.util.I18NMessageSourceUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.accompany.common.constant.Constant.SysConfId.DOMAIN_CONFIG;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class UserEventAdminService {
|
||||
@@ -43,6 +55,12 @@ public class UserEventAdminService {
|
||||
private UserPurseService userPurseService;
|
||||
@Autowired
|
||||
private BillRecordService billRecordService;
|
||||
@Autowired
|
||||
private FirstPageBannerAdminService firstPageBannerAdminService;
|
||||
@Autowired
|
||||
private SysConfService sysConfService;
|
||||
@Autowired
|
||||
private EnvComponent envComponent;
|
||||
|
||||
public BusiResult<PageResult<UserEventAdminVO>> listEvent(Long erbanNo, Long roomErbanNo, Integer pageNo, Integer pageSize,
|
||||
Integer partitionId, String startTime, String endTime, Integer eventStatus) {
|
||||
@@ -124,9 +142,12 @@ public class UserEventAdminService {
|
||||
if (userEvent.getEventStatus() == UserEventConstant.EventStatus.DELETE) {
|
||||
throw new AdminServiceException(6000, "EVENT HAVE BEEN DELETED");
|
||||
}
|
||||
if (eventStatus == UserEventConstant.EventStatus.PASS) {
|
||||
if (userEvent.getEventStatus() == UserEventConstant.EventStatus.PASS) {
|
||||
throw new AdminServiceException(6000, "EVENT HAVE BEEN PASS");
|
||||
}
|
||||
if (userEvent.getEventStatus() == UserEventConstant.EventStatus.EXPIRE) {
|
||||
throw new AdminServiceException(6000, "EVENT HAVE BEEN EXPIRE");
|
||||
}
|
||||
userEvent.setUpdateTime(new Date());
|
||||
userEvent.setEventStatus(eventStatus);
|
||||
userEvent.setAdminId(adminId);
|
||||
@@ -138,6 +159,7 @@ public class UserEventAdminService {
|
||||
Long uid = userEvent.getUid();
|
||||
if (eventStatus == UserEventConstant.EventStatus.PASS) {
|
||||
baseSendService.sendSystemMsg(uid.toString(), I18NMessageSourceUtil.getMessage(I18nAlertEnum.USER_EVENT_PASS, uid));
|
||||
this.addFirstBanner(userEvent, uid);
|
||||
} else if (eventStatus == UserEventConstant.EventStatus.REJECT) {
|
||||
if (userEvent.getPayBanner() == UserEventConstant.PayBanner.YES) {
|
||||
//扣钱
|
||||
@@ -150,4 +172,43 @@ public class UserEventAdminService {
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
private void addFirstBanner(UserEvent userEvent, Long uid) {
|
||||
if (userEvent.getPayBanner() != UserEventConstant.PayBanner.YES) {
|
||||
return;
|
||||
}
|
||||
Users users = usersService.getUsersByUid(uid);
|
||||
FirstPageBanner firstPageBanner = new FirstPageBanner();
|
||||
firstPageBanner.setPartitionIds(Arrays.asList(users.getPartitionId()));
|
||||
firstPageBanner.setBannerName(userEvent.getEventTopic());
|
||||
firstPageBanner.setCreateTime(new Date());
|
||||
firstPageBanner.setStartTime(userEvent.getEventStartTime());
|
||||
firstPageBanner.setEndTime(userEvent.getEventEndTime());
|
||||
firstPageBanner.setBannerPic(userEvent.getEventBanner());
|
||||
firstPageBanner.setShowType((byte)1);
|
||||
firstPageBanner.setOperator("sys");
|
||||
firstPageBanner.setSkipType(FillConstant.SkipType.h5Link);
|
||||
firstPageBanner.setBannerStatus(Constant.Yes1No0.YES);
|
||||
firstPageBanner.setSeqNo(1);
|
||||
firstPageBanner.setBannerType((int)Constant.BannerType.BANNER_HOME);
|
||||
firstPageBanner.setPlatform("all");
|
||||
firstPageBanner.setAndroidVersion("1");
|
||||
firstPageBanner.setIosVersion("1");
|
||||
firstPageBanner.setShowRule(Constant.ActShowRule.ALWAYS_SHOW);
|
||||
|
||||
String sysConfValueById = sysConfService.getSysConfValueById(DOMAIN_CONFIG);
|
||||
String domainUrl = "";
|
||||
if (StringUtils.isNotEmpty(sysConfValueById)) {
|
||||
DomainConfigDto domainConfigDto = JSONObject.parseObject(sysConfValueById, DomainConfigDto.class);
|
||||
if (domainConfigDto != null) {
|
||||
if (envComponent.getOnlineEnv()) {
|
||||
domainUrl = domainConfigDto.getEnv();
|
||||
} else {
|
||||
domainUrl = domainConfigDto.getBeta();
|
||||
}
|
||||
}
|
||||
}
|
||||
firstPageBanner.setSkipUri(String.format(UserEventConstant.H5_URL, domainUrl, userEvent.getId()));
|
||||
firstPageBannerAdminService.saveOrUpdateFirstPageBannerV2(firstPageBanner);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -948,6 +948,7 @@ public enum BusiStatus {
|
||||
USER_EVENT_DELETE(20513, "活动已经被删除"),
|
||||
USER_EVENT_BEGIN_SELECT(20513, "超过可选时间范围"),
|
||||
USER_EVENT_EXIST(20513, "该房间已经申请[时间范围]举办活动了"),
|
||||
USER_EVENT_GOLD_CONFIG_ERROR(20513, "GOLD_CONFIG_ERROR"),
|
||||
;
|
||||
|
||||
private final int value;
|
||||
|
@@ -1443,6 +1443,9 @@ public class Constant {
|
||||
|
||||
|
||||
public static final String USER_EVENT_CONFIG = "user_event_config";//用户活动扣款金额限制
|
||||
|
||||
|
||||
public static final String DOMAIN_CONFIG = "domain_config";//h5域名配置
|
||||
}
|
||||
|
||||
public static class WithDrawStatus {
|
||||
|
@@ -0,0 +1,9 @@
|
||||
package com.accompany.business.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DomainConfigDto {
|
||||
private String beta;
|
||||
private String env;
|
||||
}
|
@@ -73,6 +73,12 @@ public class FirstPageBanner implements Serializable {
|
||||
@TableField(value = "region_id")
|
||||
private Integer regionId ;
|
||||
|
||||
/**
|
||||
* 是否展示在活动入口,0-否,1-是
|
||||
*/
|
||||
@TableField(value = "activity_show")
|
||||
private Byte activityShow ;
|
||||
|
||||
/**
|
||||
* 分区描述
|
||||
*/
|
||||
|
@@ -5,6 +5,8 @@ import com.accompany.common.redis.BaseRedisKey;
|
||||
|
||||
public interface UserEventConstant {
|
||||
|
||||
String H5_URL = "%s/molistar/modules/eventDetails/index.html?eventId=%s&lang=en";
|
||||
|
||||
interface EventStatus {
|
||||
byte IN_REVIEW = 0; //待审核
|
||||
byte PASS = 1; //通过
|
||||
@@ -13,6 +15,13 @@ public interface UserEventConstant {
|
||||
byte EXPIRE = 4;//过期
|
||||
}
|
||||
|
||||
interface EventLiveStatus {
|
||||
byte WAITING = 1; //未开始
|
||||
byte LIVING= 2;// 进行中
|
||||
|
||||
byte END = 3;//已过期
|
||||
}
|
||||
|
||||
interface NoticeFans {
|
||||
byte NO = 0; //否
|
||||
byte YES = 1; //是
|
||||
|
@@ -22,7 +22,7 @@ public class UserEventVO extends UserEvent {
|
||||
private String eventStartTimeStr;//活动开始时间
|
||||
private String eventEndTimeStr;//活动结束时间
|
||||
private String verifyTimeStr;
|
||||
private Boolean liveStatus;
|
||||
private Byte liveStatus;
|
||||
private String roomAvatar;
|
||||
private Long roomErbanNo;
|
||||
private Boolean subStatus;
|
||||
|
@@ -64,7 +64,7 @@ public class FirstPageBannerService extends ServiceImpl<FirstPageBannerMapper, F
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<FirstPageBannerVo> getFirstPageBanner(Integer type, DeviceInfo deviceInfo, Long uid){
|
||||
public List<FirstPageBannerVo> getFirstPageBanner(Integer type, DeviceInfo deviceInfo, Long uid, Byte activityShow){
|
||||
Users u = usersService.getUsersByUid(uid);
|
||||
if (null == u){
|
||||
return Collections.emptyList();
|
||||
@@ -92,6 +92,10 @@ public class FirstPageBannerService extends ServiceImpl<FirstPageBannerMapper, F
|
||||
list = list.stream().filter(v -> CollectionUtil.isEmpty(v.getPartitionIds()) || v.getPartitionIds().contains(u.getPartitionId())).collect(Collectors.toList());
|
||||
list = list.stream().filter(banner -> banner.getEndTime() != null && banner.getStartTime() != null
|
||||
&& now.compareTo(banner.getStartTime()) >= 0 && now.compareTo(banner.getEndTime()) <= 0).collect(Collectors.toList());
|
||||
boolean activityShowFlag = activityShow != null && activityShow != -1;
|
||||
if (!CollectionUtils.isEmpty(list) && activityShowFlag) {
|
||||
list = list.stream().filter(x -> !x.getActivityShow().equals(activityShow)).collect(Collectors.toList());
|
||||
}
|
||||
if (u.getRegionId() == null) {
|
||||
list = list.stream().filter(v -> regionInfoService.ALL_REGION.equals(v.getRegionId()))
|
||||
.collect(Collectors.toList());
|
||||
|
@@ -20,7 +20,9 @@ import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.service.region.RegionInfoService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@@ -122,6 +122,9 @@ public class UserEventServiceImpl extends ServiceImpl<UserEventMapper, UserEvent
|
||||
return BusiResult.fail("INSERT ERROR");
|
||||
}
|
||||
if (UserEventConstant.PayBanner.YES == userEvent.getPayBanner()) {
|
||||
if (configVo.getGoldNum() != userEvent.getPayGoldNum().longValue()) {
|
||||
throw new ServiceException(BusiStatus.USER_EVENT_GOLD_CONFIG_ERROR);
|
||||
}
|
||||
//扣钱
|
||||
Double payGoldNum = userEvent.getPayGoldNum().doubleValue();
|
||||
userPurseService.subDiamond(uid, payGoldNum, BillObjTypeEnum.USER_EVENT_PAY_BANNER,
|
||||
@@ -200,9 +203,7 @@ public class UserEventServiceImpl extends ServiceImpl<UserEventMapper, UserEvent
|
||||
userEventVO.setRoomAvatar(room.getAvatar());
|
||||
Users users = usersService.getUsersByUid(userEventVO.getRoomUid());
|
||||
userEventVO.setRoomErbanNo(users.getErbanNo());
|
||||
Date now = new Date();
|
||||
boolean liveStatus = now.after(userEventVO.getEventStartTime()) && now.before(userEventVO.getEventEndTime());
|
||||
userEventVO.setLiveStatus(liveStatus);
|
||||
userEventVO.setLiveStatus(genLiveStatus(userEventVO.getEventStartTime(), userEventVO.getEventEndTime(), new Date()));
|
||||
Users users1 = usersService.getUsersByUid(userEvent.getUid());
|
||||
userEventVO.setErbanNo(users1.getErbanNo());
|
||||
userEventVO.setNick(users1.getNick());
|
||||
@@ -273,9 +274,7 @@ public class UserEventServiceImpl extends ServiceImpl<UserEventMapper, UserEvent
|
||||
}
|
||||
UserEventVO userEventVO = new UserEventVO();
|
||||
BeanUtils.copyProperties(userEvent, userEventVO);
|
||||
Date now = new Date();
|
||||
boolean liveStatus = now.after(userEventVO.getEventStartTime()) && now.before(userEventVO.getEventEndTime());
|
||||
userEventVO.setLiveStatus(liveStatus);
|
||||
userEventVO.setLiveStatus(genLiveStatus(userEventVO.getEventStartTime(), userEventVO.getEventEndTime(), new Date()));
|
||||
userEventVO.setSubStatus(userEventSubService.subStatus(pubUid, userEventVO.getId()));
|
||||
return userEventVO;
|
||||
}
|
||||
@@ -378,8 +377,7 @@ public class UserEventServiceImpl extends ServiceImpl<UserEventMapper, UserEvent
|
||||
vo.setRoomAvatar(room.getAvatar());
|
||||
}
|
||||
Date eventStartTime = vo.getEventStartTime();
|
||||
boolean liveStatus = now.after(eventStartTime) && now.before(vo.getEventEndTime());
|
||||
vo.setLiveStatus(liveStatus);
|
||||
vo.setLiveStatus(genLiveStatus(eventStartTime, vo.getEventEndTime(), now));
|
||||
vo.setEventStartTimeStr(DateTimeUtil.convertWithZoneId(eventStartTime, partitionEnum.getZoneId()).format(DateTimeUtil.datetimeFormatter));
|
||||
vo.setSubStatus(subbedEvents.contains(vo.getId()));
|
||||
}
|
||||
@@ -477,7 +475,7 @@ public class UserEventServiceImpl extends ServiceImpl<UserEventMapper, UserEvent
|
||||
Date offsetHour = DateUtil.offsetHour(now, subMinutes);
|
||||
LambdaQueryWrapper<UserEvent> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(UserEvent::getEventStatus, UserEventConstant.EventStatus.IN_REVIEW)
|
||||
.gt(UserEvent::getCreateTime, offsetHour);
|
||||
.lt(UserEvent::getCreateTime, offsetHour);
|
||||
List<UserEvent> userEvents = baseMapper.selectList(wrapper);
|
||||
if (CollectionUtils.isEmpty(userEvents)) {
|
||||
return;
|
||||
@@ -512,4 +510,14 @@ public class UserEventServiceImpl extends ServiceImpl<UserEventMapper, UserEvent
|
||||
String message = I18NMessageSourceUtil.getMessage(I18nAlertEnum.USER_EVENT_SHARE_TEXT, new Object[]{link}, uid);
|
||||
return BusiResult.success(message);
|
||||
}
|
||||
|
||||
private Byte genLiveStatus(Date startTime, Date endTime, Date now) {
|
||||
if (now.after(startTime) && now.before(endTime)) {
|
||||
return UserEventConstant.EventLiveStatus.LIVING;
|
||||
} else if (now.before(startTime)) {
|
||||
return UserEventConstant.EventLiveStatus.WAITING;
|
||||
} else {
|
||||
return UserEventConstant.EventLiveStatus.END;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -76,12 +76,12 @@ public class HomeController extends BaseController {
|
||||
*/
|
||||
@ApiOperation("获取首页banner数据")
|
||||
@GetMapping(value = "/banner")
|
||||
public BusiResult<List<FirstPageBannerVo>> getHomeBanner(@RequestParam(defaultValue = "1") Integer type, HttpServletRequest request) {
|
||||
public BusiResult<List<FirstPageBannerVo>> getHomeBanner(@RequestParam(defaultValue = "1") Integer type, @RequestParam(defaultValue = "-1") Byte activityShow, HttpServletRequest request) {
|
||||
List<FirstPageBannerVo> banners = null;
|
||||
if (Constant.BannerType.BANNER_ROOM == type) {
|
||||
banners = resourceService.convertBanner(resourceService.resources(ResourceTypeEnum.ROOM.ordinal(), 0, Constant.PayloadSkiptype.room, Constant.PayloadSkiptype.h5));
|
||||
} else {
|
||||
banners = firstPageBannerService.getFirstPageBanner(type, DeviceInfoContextHolder.get(), UidContextHolder.get());
|
||||
banners = firstPageBannerService.getFirstPageBanner(type, DeviceInfoContextHolder.get(), UidContextHolder.get(), activityShow);
|
||||
}
|
||||
return BusiResult.success(banners);
|
||||
}
|
||||
|
@@ -73,8 +73,8 @@ public class UserEventController extends BaseController {
|
||||
})
|
||||
@ApiOperation(value = "详情", httpMethod = "GET")
|
||||
@GetMapping("/detail")
|
||||
public BusiResult<UserEventVO> detail(Long uid, Long eventId) throws InterruptedException {
|
||||
return BusiResult.success(userEventService.detail(uid, eventId));
|
||||
public BusiResult<UserEventVO> detail(Long eventId) throws InterruptedException {
|
||||
return BusiResult.success(userEventService.detail(getUid(), eventId));
|
||||
}
|
||||
|
||||
@ApiImplicitParams({
|
||||
|
Reference in New Issue
Block a user