礼包中心礼包记录
This commit is contained in:
@@ -15,7 +15,7 @@ public class PackInfoAdminVo {
|
||||
@ApiModelProperty("分区")
|
||||
private String partitionDesc;
|
||||
@ApiModelProperty("礼包名称")
|
||||
@I18n(className = "PackInfo")
|
||||
@I18n(className = "PackInfo", fieldName = "packName")
|
||||
private String packName;
|
||||
@ApiModelProperty("状态.1-有效,0-无效")
|
||||
private Byte status;
|
||||
|
@@ -67,10 +67,10 @@ public class PackInfoAdminService {
|
||||
}
|
||||
|
||||
public BusiResult<Void> save(PackInfoAdminVo vo) {
|
||||
I18NMessageSourceUtil.deserialization(vo, Collections.singletonList("packName"));
|
||||
PackInfo packInfo = new PackInfo();
|
||||
packInfo.setUpdateTime(new Date());
|
||||
BeanUtils.copyProperties(vo, packInfo);
|
||||
packInfo.setUpdateTime(new Date());
|
||||
I18NMessageSourceUtil.deserialization(packInfo, Collections.singletonList("packName"));
|
||||
packInfoService.saveOrUpdate(packInfo);
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
@@ -22,4 +22,10 @@ public interface PackConstant {
|
||||
byte valid = 1;
|
||||
byte empty = 2;
|
||||
}
|
||||
|
||||
interface UserPackRecordType {
|
||||
byte RECEIVE = 1;
|
||||
byte SEND = 2;
|
||||
byte USED = 3;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,37 @@
|
||||
package com.accompany.business.vo.packcenter;
|
||||
|
||||
import com.accompany.core.annotation.I18n;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class UserPackRecordVo {
|
||||
@ApiModelProperty("礼包名称")
|
||||
@I18n(className = "PackInfo")
|
||||
private String packName;
|
||||
@ApiModelProperty("样式")
|
||||
private String imgUrl;
|
||||
@ApiModelProperty("礼包数量")
|
||||
private Integer packNum;
|
||||
@ApiModelProperty("来源.1-官方赠送(官方赠送不返回用户信息),2-用户赠送")
|
||||
private Byte source;
|
||||
@ApiModelProperty("赠送人头像")
|
||||
private String avatar;
|
||||
@ApiModelProperty("赠送人UID")
|
||||
private Long uid;
|
||||
@ApiModelProperty("赠送人ID")
|
||||
private Long erbanNo;
|
||||
@ApiModelProperty("赠送人昵称")
|
||||
private String nick;
|
||||
@ApiModelProperty("接收人昵称")
|
||||
private String targetNick;
|
||||
@ApiModelProperty("赠送使用时间")
|
||||
private String sendDate;
|
||||
|
||||
}
|
@@ -15,12 +15,16 @@ public class UserPackVo {
|
||||
@ApiModelProperty("礼包名称")
|
||||
@I18n(className = "PackInfo")
|
||||
private String packName;
|
||||
@ApiModelProperty("样式")
|
||||
private String imgUrl;
|
||||
@ApiModelProperty("过期剩余秒数")
|
||||
private Long expireSeconds;
|
||||
@ApiModelProperty("礼包数量")
|
||||
private Integer packNum;
|
||||
@ApiModelProperty("礼包使用数量")
|
||||
private Integer useNum;
|
||||
@ApiModelProperty("礼包剩余数量")
|
||||
private Integer remainNum;
|
||||
@ApiModelProperty("奖励信息")
|
||||
private List<PackItemRewardVo> rewardList;
|
||||
}
|
||||
|
@@ -14,9 +14,12 @@ import com.accompany.business.service.activity.h5.ActivityH5AwardRecordService;
|
||||
import com.accompany.business.service.activity.h5.ActivityH5LevelAwardService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.vo.packcenter.PackItemRewardVo;
|
||||
import com.accompany.business.vo.packcenter.UserPackRecordVo;
|
||||
import com.accompany.business.vo.packcenter.UserPackVo;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.common.utils.PageUtil;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.util.I18NMessageSourceUtil;
|
||||
@@ -24,6 +27,7 @@ import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -96,8 +100,10 @@ public class PackCenterService {
|
||||
}
|
||||
vo.setUserPackId(userPack.getId());
|
||||
vo.setPackName(packInfo.getPackName());
|
||||
vo.setImgUrl(packInfo.getImgUrl());
|
||||
vo.setPackNum(userPack.getPackNum());
|
||||
vo.setUseNum(userPack.getUseNum());
|
||||
vo.setRemainNum(userPack.getPackNum() - userPack.getUseNum());
|
||||
vo.setExpireSeconds(DateUtil.between(date, userPack.getExpireTime(), DateUnit.SECOND));
|
||||
List<PackItemRewardVo> rewardList = new ArrayList<>();
|
||||
vo.setRewardList(rewardList);
|
||||
@@ -157,7 +163,7 @@ public class PackCenterService {
|
||||
for (int i = 0; i < useNum; i++) {
|
||||
for (ActivityH5LevelAward award : activityH5LevelAwards) {
|
||||
award.setAwardNum(award.getAwardNum() * useNum);
|
||||
activityH5AwardRecordService.sendDetailAward(targetUid, targetUser.getPartitionId(), "", award, ActivityType.PACK_CENTER_REWARD);
|
||||
activityH5AwardRecordService.sendDetailAward(targetUid, targetUser.getPartitionId(), "" , award, ActivityType.PACK_CENTER_REWARD);
|
||||
}
|
||||
}
|
||||
usePackRecord.setNumberList(awardIds);
|
||||
@@ -197,5 +203,93 @@ public class PackCenterService {
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
public List<UserPackRecordVo> records(Long uid, Integer pageNo, Integer pageSize, Integer recordType) {
|
||||
Users users = usersService.getUsersByUid(uid);
|
||||
Integer partitionId = users.getPartitionId();
|
||||
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
|
||||
List<UserPackRecordVo> resultList = new ArrayList<>();
|
||||
if (PackConstant.UserPackRecordType.RECEIVE == recordType) {
|
||||
List<UserPackRecord> userPackRecords = userPackRecordService.recordList(uid, pageNo, pageSize);
|
||||
if (CollectionUtils.isEmpty(userPackRecords)) {
|
||||
return resultList;
|
||||
}
|
||||
List<Integer> packIds = userPackRecords.stream().map(UserPackRecord::getPackId).collect(Collectors.toList());
|
||||
List<Long> sendUids = userPackRecords.stream().filter(x -> x.getSendUid() != null && x.getSendUid() > 0)
|
||||
.map(UserPackRecord::getSendUid).collect(Collectors.toList());
|
||||
Map<Integer, PackInfo> packInfoMap = packInfoService.mapByPackIds(packIds);
|
||||
Map<Long, Users> usersMap = usersService.getUsersMapByUids(sendUids);
|
||||
for (UserPackRecord userPackRecord : userPackRecords) {
|
||||
UserPackRecordVo recordVo = new UserPackRecordVo();
|
||||
PackInfo packInfo = packInfoMap.get(userPackRecord.getPackId());
|
||||
if (packInfo == null) {
|
||||
continue;
|
||||
}
|
||||
recordVo.setPackName(packInfo.getPackName());
|
||||
recordVo.setImgUrl(packInfo.getImgUrl());
|
||||
recordVo.setPackNum(userPackRecord.getPackNum());
|
||||
if (PackConstant.PackSource.USER_SEND == userPackRecord.getSource()) {
|
||||
Users users1 = usersMap.get(userPackRecord.getSendUid());
|
||||
recordVo.setNick(users1.getNick());
|
||||
recordVo.setAvatar(users1.getAvatar());
|
||||
recordVo.setErbanNo(users1.getErbanNo());
|
||||
recordVo.setUid(users1.getUid());
|
||||
}
|
||||
recordVo.setTargetNick(users.getNick());
|
||||
ZonedDateTime zonedDateTime = DateTimeUtil.convertWithZoneId(userPackRecord.getCreateTime(), partitionEnum.getZoneId());
|
||||
recordVo.setSendDate(zonedDateTime.format(DateTimeUtil.datetimeFormatter));
|
||||
recordVo.setSource(userPackRecord.getSource());
|
||||
resultList.add(recordVo);
|
||||
}
|
||||
} else if (PackConstant.UserPackRecordType.SEND == recordType) {
|
||||
List<UserPackRecord> userPackRecords = userPackRecordService.recordSendList(uid, pageNo, pageSize);
|
||||
if (CollectionUtils.isEmpty(userPackRecords)) {
|
||||
return resultList;
|
||||
}
|
||||
List<Integer> packIds = userPackRecords.stream().map(UserPackRecord::getPackId).collect(Collectors.toList());
|
||||
List<Long> uids = userPackRecords.stream().map(UserPackRecord::getUid).collect(Collectors.toList());
|
||||
Map<Integer, PackInfo> packInfoMap = packInfoService.mapByPackIds(packIds);
|
||||
Map<Long, Users> usersMap = usersService.getUsersMapByUids(uids);
|
||||
for (UserPackRecord userPackRecord : userPackRecords) {
|
||||
UserPackRecordVo recordVo = new UserPackRecordVo();
|
||||
PackInfo packInfo = packInfoMap.get(userPackRecord.getPackId());
|
||||
if (packInfo == null) {
|
||||
continue;
|
||||
}
|
||||
recordVo.setPackName(packInfo.getPackName());
|
||||
recordVo.setImgUrl(packInfo.getImgUrl());
|
||||
recordVo.setPackNum(userPackRecord.getPackNum());
|
||||
if (PackConstant.PackSource.USER_SEND == userPackRecord.getSource()) {
|
||||
Users users1 = usersMap.get(userPackRecord.getUid());
|
||||
recordVo.setTargetNick(users1.getNick());
|
||||
}
|
||||
recordVo.setNick(users.getNick());
|
||||
ZonedDateTime zonedDateTime = DateTimeUtil.convertWithZoneId(userPackRecord.getCreateTime(), partitionEnum.getZoneId());
|
||||
recordVo.setSendDate(zonedDateTime.format(DateTimeUtil.datetimeFormatter));
|
||||
recordVo.setSource(userPackRecord.getSource());
|
||||
resultList.add(recordVo);
|
||||
}
|
||||
} else if (PackConstant.UserPackRecordType.USED == recordType) {
|
||||
List<UserUsePackRecord> userUsePackRecords = userUsePackRecordService.listByUid(uid, PackConstant.PackUseType.SELF, pageNo, pageSize);
|
||||
if (CollectionUtils.isEmpty(userUsePackRecords)) {
|
||||
return resultList;
|
||||
}
|
||||
List<Integer> packIds = userUsePackRecords.stream().map(UserUsePackRecord::getPackId).collect(Collectors.toList());
|
||||
Map<Integer, PackInfo> packInfoMap = packInfoService.mapByPackIds(packIds);
|
||||
for (UserUsePackRecord userUsePackRecord : userUsePackRecords) {
|
||||
UserPackRecordVo recordVo = new UserPackRecordVo();
|
||||
PackInfo packInfo = packInfoMap.get(userUsePackRecord.getPackId());
|
||||
if (packInfo == null) {
|
||||
continue;
|
||||
}
|
||||
recordVo.setPackName(packInfo.getPackName());
|
||||
recordVo.setImgUrl(packInfo.getImgUrl());
|
||||
recordVo.setPackNum(userUsePackRecord.getPackNum());
|
||||
ZonedDateTime zonedDateTime = DateTimeUtil.convertWithZoneId(userUsePackRecord.getCreateTime(), partitionEnum.getZoneId());
|
||||
recordVo.setSendDate(zonedDateTime.format(DateTimeUtil.datetimeFormatter));
|
||||
resultList.add(recordVo);
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@ package com.accompany.business.service.packcenter;
|
||||
import com.accompany.business.model.packcenter.UserPackRecord;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户礼包获得记录 服务类
|
||||
*
|
||||
@@ -11,5 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface UserPackRecordService extends IService<UserPackRecord> {
|
||||
|
||||
List<UserPackRecord> recordList(Long uid, Integer pageNo, Integer pageSize);
|
||||
List<UserPackRecord> recordSendList(Long sendUid, Integer pageNo, Integer pageSize);
|
||||
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@ package com.accompany.business.service.packcenter;
|
||||
import com.accompany.business.model.packcenter.UserUsePackRecord;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户使用礼包记录 服务类
|
||||
*
|
||||
@@ -11,5 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface UserUsePackRecordService extends IService<UserUsePackRecord> {
|
||||
|
||||
|
||||
List<UserUsePackRecord> listByUid(Long uid, Byte useType, Integer pageNo, Integer pageSize);
|
||||
}
|
||||
|
@@ -1,11 +1,17 @@
|
||||
package com.accompany.business.service.packcenter.impl;
|
||||
|
||||
import com.accompany.business.constant.PackConstant;
|
||||
import com.accompany.business.model.packcenter.UserPackRecord;
|
||||
import com.accompany.business.mybatismapper.packcenter.UserPackRecordMapper;
|
||||
import com.accompany.business.service.packcenter.UserPackRecordService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户礼包获得记录 服务实现类
|
||||
*
|
||||
@@ -15,5 +21,21 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class UserPackRecordServiceImpl extends ServiceImpl<UserPackRecordMapper, UserPackRecord> implements UserPackRecordService {
|
||||
|
||||
@Override
|
||||
public List<UserPackRecord> recordList(Long uid, Integer pageNo, Integer pageSize) {
|
||||
LambdaQueryWrapper<UserPackRecord> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(UserPackRecord::getUid, uid)
|
||||
.eq(UserPackRecord::getStatus, PackConstant.UserPackRecordStatus.NORMAL)
|
||||
.orderByDesc(UserPackRecord::getCreateTime);
|
||||
return baseMapper.selectList(new Page<>(pageNo, pageSize, false), wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserPackRecord> recordSendList(Long sendUid, Integer pageNo, Integer pageSize) {
|
||||
LambdaQueryWrapper<UserPackRecord> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(UserPackRecord::getSendUid, sendUid)
|
||||
.eq(UserPackRecord::getStatus, PackConstant.UserPackRecordStatus.NORMAL)
|
||||
.orderByDesc(UserPackRecord::getCreateTime);
|
||||
return baseMapper.selectList(new Page<>(pageNo, pageSize, false), wrapper);
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,14 @@ package com.accompany.business.service.packcenter.impl;
|
||||
import com.accompany.business.model.packcenter.UserUsePackRecord;
|
||||
import com.accompany.business.mybatismapper.packcenter.UserUsePackRecordMapper;
|
||||
import com.accompany.business.service.packcenter.UserUsePackRecordService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户使用礼包记录 服务实现类
|
||||
*
|
||||
@@ -16,4 +21,12 @@ import org.springframework.stereotype.Service;
|
||||
public class UserUsePackRecordServiceImpl extends ServiceImpl<UserUsePackRecordMapper, UserUsePackRecord> implements UserUsePackRecordService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<UserUsePackRecord> listByUid(Long uid, Byte useType, Integer pageNo, Integer pageSize) {
|
||||
LambdaQueryWrapper<UserUsePackRecord> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(UserUsePackRecord::getUid, uid)
|
||||
.eq(UserUsePackRecord::getUseType, useType)
|
||||
.orderByDesc(UserUsePackRecord::getCreateTime);
|
||||
return baseMapper.selectList(new Page<>(pageNo, pageSize, false), wrapper);
|
||||
}
|
||||
}
|
||||
|
@@ -238,7 +238,7 @@ public class VipUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer getVipAuthItemIntValue(Map<Byte, List<VipAuthItem>> typeMap, Byte authType, Integer defaultValud) {
|
||||
public static Integer getVipAuthItemIntValue(Map<Byte, List<VipAuthItem>> typeMap, Byte authType, Integer defaultValue) {
|
||||
List<VipAuthItem> authItems = typeMap.get(authType);
|
||||
return Optional.ofNullable(authItems)
|
||||
.filter(list -> !list.isEmpty())
|
||||
@@ -247,7 +247,7 @@ public class VipUtil {
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.map(String::trim)
|
||||
.map(Integer::valueOf)
|
||||
.orElse(defaultValud);
|
||||
.orElse(defaultValue);
|
||||
}
|
||||
|
||||
public static String getVipAuthItemValue(Integer vipLevel, Byte authType) {
|
||||
|
@@ -1,9 +1,12 @@
|
||||
package com.accompany.business.controller;
|
||||
|
||||
import com.accompany.business.service.packcenter.PackCenterService;
|
||||
import com.accompany.business.vo.packcenter.UserPackRecordVo;
|
||||
import com.accompany.business.vo.packcenter.UserPackVo;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -32,9 +35,22 @@ public class PackCenterController {
|
||||
return BusiResult.success(userPackVos);
|
||||
}
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userPackId", value = "礼包ID"),
|
||||
@ApiImplicitParam(name = "targetUid", value = "目标用户ID"),
|
||||
@ApiImplicitParam(name = "useNum", value = "礼包数量"),
|
||||
})
|
||||
@ApiOperation(value = "使用礼包", httpMethod = "GET")
|
||||
@GetMapping("/usePack")
|
||||
public BusiResult<Void> usePack(@RequestHeader(PUB_UID) Long uid, Long targetUid, Long userPackId, Integer useNum) {
|
||||
return packCenterService.usePack(uid, targetUid, userPackId, useNum);
|
||||
}
|
||||
|
||||
@ApiImplicitParam(name = "recordType", value = "1-我收到的,2-我送出的,3-我使用的")
|
||||
@ApiOperation(value = "礼包记录", httpMethod = "GET")
|
||||
@GetMapping("/records")
|
||||
public BusiResult<List<UserPackRecordVo>> records(@RequestHeader(PUB_UID) Long uid, Integer pageNo, Integer pageSize, Integer recordType) {
|
||||
List<UserPackRecordVo> userPackVos = packCenterService.records(uid, pageNo, pageSize, recordType);
|
||||
return BusiResult.success(userPackVos);
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@ package com.accompany.business.controller.user;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.annotation.Authorization;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.vo.UserVo;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -40,4 +42,25 @@ public class H5UserController {
|
||||
return BusiResult.success(userVo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "h5根据ID获取用户基础信息",httpMethod = "GET")
|
||||
@Authorization
|
||||
@GetMapping("/search")
|
||||
public BusiResult<UserVo> search(@RequestHeader(value = PUB_UID) Long uid, Long erbanNo) {
|
||||
Users targetUser = usersService.getUserByErbanNo(erbanNo);
|
||||
UserVo userVo = null;
|
||||
if (targetUser == null) {
|
||||
return BusiResult.success(userVo);
|
||||
}
|
||||
Users selfUser = usersService.getUsersByUid(uid);
|
||||
if (!targetUser.getPartitionId().equals(selfUser.getPartitionId())) {
|
||||
throw new ServiceException(BusiStatus.PARTITION_ERROR);
|
||||
}
|
||||
userVo = usersService.converToUserVo(targetUser, null, null, null, null, null);
|
||||
if (userVo.getInviteUid() != null) {
|
||||
Users inviteUser = usersService.getUsersByUid(userVo.getInviteUid());
|
||||
userVo.setInviteErbanNo(inviteUser.getErbanNo());
|
||||
}
|
||||
return BusiResult.success(userVo);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user