分享用户活动fixed

分享用户活动
This commit is contained in:
2025-05-12 19:16:39 +08:00
parent 34313b2697
commit 9ff2e01496
5 changed files with 84 additions and 35 deletions

View File

@@ -14,6 +14,7 @@ import com.accompany.common.result.BusiResult;
import com.accompany.common.result.PageResult;
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.util.I18NMessageSourceUtil;
@@ -91,6 +92,7 @@ public class UserEventAdminService {
if (users != null) {
userEventAdmin2VO.setNick(users.getNick());
userEventAdmin2VO.setErbanNo(users.getErbanNo());
userEventAdmin2VO.setPartitionDesc(PartitionEnum.getByPartitionId(users.getPartitionId()).getDesc());
}
users = usersMap.get(userEventAdmin2VO.getRoomUid());
if (users != null) {
@@ -128,6 +130,7 @@ public class UserEventAdminService {
userEvent.setUpdateTime(new Date());
userEvent.setEventStatus(eventStatus);
userEvent.setAdminId(adminId);
userEvent.setVerifyTime(userEvent.getUpdateTime());
boolean b = userEventService.updateById(userEvent);
if (!b) {
throw new AdminServiceException(6000, "OPERAT ERROR");

View File

@@ -301,6 +301,7 @@ public enum I18nAlertEnum {
LUCKY_NUMBER_HAS_JACKPOT_TIP("你在幸运数字活动中中奖啦!快去领取你的金币!"),
LUCKY_NUMBER_GET_JACKPOT_TIP("恭喜你在幸运数字活动中获得了{0}金币。"),
USER_EVENT_SHARE_TEXT("快来加入我们一起聊天吧!{0}"),
;
private final String defaultStr;

View File

@@ -1,11 +1,10 @@
package com.accompany.business.service.userevent;
import com.accompany.business.model.userevent.UserEvent;
import com.accompany.business.message.UserEventBeginEndMessage;
import com.accompany.business.model.userevent.vo.UserEventConfigVo;
import com.accompany.business.model.userevent.vo.UserEventVO;
import com.accompany.common.device.DeviceInfo;
import com.accompany.common.result.BusiResult;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -14,7 +13,7 @@ import java.util.List;
/**
* 用户活动模块 服务类
*
* @author
* @author
* @since 2024-03-11
*/
public interface UserEventService extends IService<UserEvent> {
@@ -28,6 +27,7 @@ public interface UserEventService extends IService<UserEvent> {
/**
* 移除管理员时删除对应房间活动
*
* @param uid
* @param roomUid
* @return
@@ -36,6 +36,7 @@ public interface UserEventService extends IService<UserEvent> {
/**
* 被封禁时删除对应房间活动
*
* @param erbanNo
* @return
*/
@@ -43,15 +44,18 @@ public interface UserEventService extends IService<UserEvent> {
/**
* 详情
*
* @param uid
* @param eventId
* @return
*/
UserEventVO detail(Long uid, Long eventId);
UserEventVO subList(Long uid, Long eventId, Integer page, Integer pageSize);
/**
* 房间内详情
*
* @param roomUid
* @return
*/
@@ -59,6 +63,7 @@ public interface UserEventService extends IService<UserEvent> {
/**
* 更新订阅数
*
* @param eventId
* @param num
* @return
@@ -67,6 +72,7 @@ public interface UserEventService extends IService<UserEvent> {
/**
* 更新分享数
*
* @param eventId
* @param num
* @return
@@ -75,6 +81,7 @@ public interface UserEventService extends IService<UserEvent> {
/**
* 活动广场
*
* @param uid
* @param page
* @param pageSize
@@ -84,6 +91,7 @@ public interface UserEventService extends IService<UserEvent> {
/**
* 我的广场,包括我的+订阅的
*
* @param uid
* @param page
* @param pageSize
@@ -101,15 +109,19 @@ public interface UserEventService extends IService<UserEvent> {
/**
* 活动开始定时任务
*
* @param subMinutes
*/
void taskBegin(int subMinutes);
/**
* 活动结束定时任务
*
* @param subMinutes
*/
void taskEnd(int subMinutes);
void taskNotOperateExpire(int subMinutes);
BusiResult<String> genLink(Long uid, Long eventId, DeviceInfo deviceInfo);
}

View File

@@ -21,6 +21,7 @@ import com.accompany.business.service.userevent.UserEventService;
import com.accompany.business.service.userevent.UserEventSubService;
import com.accompany.business.util.VipUtil;
import com.accompany.common.config.SystemConfig;
import com.accompany.common.device.DeviceInfo;
import com.accompany.common.result.BusiResult;
import com.accompany.common.status.BusiStatus;
import com.accompany.common.utils.DateTimeUtil;
@@ -43,6 +44,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -53,6 +55,7 @@ import java.util.stream.Collectors;
import static com.accompany.common.constant.Constant.DefMsgType.USER_EVENT;
import static com.accompany.common.constant.Constant.DefMsgType.USER_EVENT_BEGIN;
import static com.accompany.common.constant.Constant.SysConfId.SHARE_LINK;
import static com.accompany.common.constant.Constant.SysConfId.USER_EVENT_CONFIG;
import static com.accompany.common.status.BusiStatus.*;
import static java.util.Collections.EMPTY_LIST;
@@ -204,6 +207,9 @@ public class UserEventServiceImpl extends ServiceImpl<UserEventMapper, UserEvent
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(users.getPartitionId());
userEventVO.setEventStartTimeStr(DateTimeUtil.convertWithZoneId(userEventVO.getEventStartTime(), partitionEnum.getZoneId()).format(DateTimeUtil.datetimeFormatter));
userEventVO.setEventEndTimeStr(DateTimeUtil.convertWithZoneId(userEventVO.getEventEndTime(), partitionEnum.getZoneId()).format(DateTimeUtil.datetimeFormatter));
if (uid != null) {
userEventVO.setSubStatus(userEventSubService.subStatus(uid, eventId));
}
return userEventVO;
}
@@ -489,4 +495,18 @@ public class UserEventServiceImpl extends ServiceImpl<UserEventMapper, UserEvent
baseSendService.sendSystemMsg(uid.toString(), I18NMessageSourceUtil.getMessage(I18nAlertEnum.USER_EVENT_REJECT, uid));
}
}
@Override
public BusiResult<String> genLink(Long uid, Long eventId, DeviceInfo deviceInfo) {
String link = sysConfService.getSysConfValueById(SHARE_LINK);
if (StringUtils.isEmpty(link)) {
throw new ServiceException("LINK ERROR");
}
Users users = usersService.getUsersByUid(uid);
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(users.getPartitionId());
Map<String, String> linkMap = JSONObject.parseObject(link, Map.class);
link = String.format("%s/ev/%s?lang=%s", linkMap.get(deviceInfo.getOs().toLowerCase()), eventId, partitionEnum.getLang());
String message = I18NMessageSourceUtil.getMessage(I18nAlertEnum.USER_EVENT_SHARE_TEXT, new Object[]{link}, uid);
return BusiResult.success(message);
}
}

View File

@@ -1,20 +1,26 @@
package com.accompany.business.controller.userevent;
import com.accompany.business.message.UserEventBeginEndMessage;
import com.accompany.business.common.BaseController;
import com.accompany.business.model.userevent.constant.UserEventConstant;
import com.accompany.business.model.userevent.vo.UserEventConfigVo;
import com.accompany.business.model.userevent.vo.UserEventVO;
import com.accompany.business.service.userevent.UserEventDataService;
import com.accompany.business.service.userevent.UserEventService;
import com.accompany.common.result.BusiResult;
import com.accompany.common.utils.UUIDUtil;
import com.accompany.common.status.BusiStatus;
import com.accompany.core.exception.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static com.accompany.common.constant.ApplicationConstant.PublicParameters.PUB_UID;
@@ -22,27 +28,29 @@ import static com.accompany.common.constant.ApplicationConstant.PublicParameters
@RestController
@RequestMapping(value = "/userevent")
@Api(tags = "用户活动", value = "用户活动")
public class UserEventController {
public class UserEventController extends BaseController {
@Autowired
private UserEventService userEventService;
@Autowired
private UserEventDataService userEventDataService;
@Autowired
private RedissonClient redissonClient;
@ApiImplicitParams({
@ApiImplicitParam(name = "eventStartTimeStr", value = "活动开始时间格式yyyy-MM-dd HH:mm:ss", required = true, dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "uid", value = "用户uid", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "roomUid", value = "房间uid", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "eventTopic", value = "活动标题", required = true, dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "eventBanner", value = "活动图片", required = true, dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "eventDuration", value = "eventDuration", required = true, dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "noticeFans", value = "是否通知用户粉丝0-否1-是", required = true, dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "eventDetail", value = "活动描述内容", required = true, dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "payBanner", value = "是否上传首页第二Banner0-否1-是", required = true, dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "payGoldNum", value = "上传首页第二Banner付款金币数", required = true, dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "eventStartTimeStr", value = "活动开始时间格式yyyy-MM-dd HH:mm:ss", required = true, dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "uid", value = "用户uid", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "roomUid", value = "房间uid", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "eventTopic", value = "活动标题", required = true, dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "eventBanner", value = "活动图片", required = true, dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "eventDuration", value = "eventDuration", required = true, dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "noticeFans", value = "是否通知用户粉丝0-否1-是", required = true, dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "eventDetail", value = "活动描述内容", required = true, dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "payBanner", value = "是否上传首页第二Banner0-否1-是", required = true, dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "payGoldNum", value = "上传首页第二Banner付款金币数", required = true, dataType = "string", paramType = "query"),
})
@ApiOperation(value = "发布活动",httpMethod = "POST")
@ApiOperation(value = "发布活动", httpMethod = "POST")
@PostMapping("/publish")
public BusiResult<Void> publish(UserEventVO userEvent) {
userEventService.saveRecord(userEvent);
@@ -50,9 +58,9 @@ public class UserEventController {
}
@ApiImplicitParams({
@ApiImplicitParam(name = "eventId", value = "活动id", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "eventId", value = "活动id", required = true, dataType = "long", paramType = "query"),
})
@ApiOperation(value = "删除活动",httpMethod = "POST")
@ApiOperation(value = "删除活动", httpMethod = "POST")
@PostMapping("/del")
public BusiResult<Void> del(@RequestHeader(value = PUB_UID) Long pubUid, Long eventId) {
userEventService.del(pubUid, eventId);
@@ -60,43 +68,43 @@ public class UserEventController {
}
@ApiImplicitParams({
@ApiImplicitParam(name = "uid", value = "uid", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "eventId", value = "活动id", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "uid", value = "uid", required = false, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "eventId", value = "活动id", required = true, dataType = "long", paramType = "query"),
})
@ApiOperation(value = "详情",httpMethod = "GET")
@ApiOperation(value = "详情", httpMethod = "GET")
@GetMapping("/detail")
public BusiResult<UserEventVO> detail(Long uid, Long eventId) {
public BusiResult<UserEventVO> detail(Long uid, Long eventId) throws InterruptedException {
return BusiResult.success(userEventService.detail(uid, eventId));
}
@ApiImplicitParams({
@ApiImplicitParam(name = "uid", value = "uid", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "eventId", value = "活动id", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "page", value = "page", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "uid", value = "uid", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "eventId", value = "活动id", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "page", value = "page", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "long", paramType = "query"),
})
@ApiOperation(value = "详情-订阅列表",httpMethod = "GET")
@ApiOperation(value = "详情-订阅列表", httpMethod = "GET")
@GetMapping("/subList")
public BusiResult<UserEventVO> subList(Long uid, Long eventId, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer pageSize) {
return BusiResult.success(userEventService.subList(uid, eventId, page, pageSize));
}
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "page", required = true, dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "page", value = "page", required = true, dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int", paramType = "query"),
})
@ApiOperation(value = "活动广场",httpMethod = "GET")
@ApiOperation(value = "活动广场", httpMethod = "GET")
@GetMapping("/square")
public BusiResult<List<UserEventVO>> square(@RequestHeader(value = PUB_UID) Long pubUid, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "2") Integer pageSize) {
return userEventService.square(pubUid, page, pageSize);
}
@ApiImplicitParams({
@ApiImplicitParam(name = "uid", value = "uid", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "page", value = "page", required = true, dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "uid", value = "uid", required = true, dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "page", value = "page", required = true, dataType = "int", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int", paramType = "query"),
})
@ApiOperation(value = "我的广场",httpMethod = "GET")
@ApiOperation(value = "我的广场", httpMethod = "GET")
@GetMapping("/mysquare")
public BusiResult<List<UserEventVO>> mysquare(@RequestParam Long uid, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "2") Integer pageSize) {
return userEventService.mysquare(uid, page, pageSize);
@@ -109,6 +117,11 @@ public class UserEventController {
return new BusiResult<>(userEventService.userEventConfig(uid));
}
@ApiOperation(value = "获取活动短链", httpMethod = "POST")
@PostMapping("/genLink")
public BusiResult<String> genLink(@RequestHeader(PUB_UID) Long uid, Long eventId, HttpServletRequest request) {
return userEventService.genLink(uid, eventId, getDeviceInfo(request));
}
@ApiOperation(value = "taskBegin", httpMethod = "GET")
@GetMapping("/taskBegin")