礼包后台fixed
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package com.accompany.admin.vo.packcenter;
|
||||
|
||||
import com.accompany.core.annotation.I18n;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class UserUsePackRecordAdminVo {
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Long id;
|
||||
private Long uid;
|
||||
private Integer partitionId;
|
||||
@ApiModelProperty("分区")
|
||||
private String partitionDesc;
|
||||
@ApiModelProperty(value = "平台ID")
|
||||
private Long erbanNo;
|
||||
private String nick;
|
||||
private Long targetUid;
|
||||
@ApiModelProperty(value = "赠送平台ID")
|
||||
private Long targeErbanNo;
|
||||
private String targeNick;
|
||||
@ApiModelProperty(value = "礼包名称")
|
||||
@I18n(className = "PackInfo")
|
||||
private String packName;
|
||||
@ApiModelProperty(value = "赠送礼包ID")
|
||||
private Integer packId;
|
||||
@ApiModelProperty(value = "数量")
|
||||
private Integer packNum;
|
||||
@ApiModelProperty(value = "使用时间")
|
||||
private Date createTime;
|
||||
@ApiModelProperty(value = "使用类型.1-自己用,2-赠送")
|
||||
private Byte useType;
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
package com.accompany.admin.service.packcenter;
|
||||
|
||||
import com.accompany.admin.vo.packcenter.UserUsePackRecordAdminVo;
|
||||
import com.accompany.business.model.packcenter.PackInfo;
|
||||
import com.accompany.business.model.packcenter.UserUsePackRecord;
|
||||
import com.accompany.business.service.packcenter.PackInfoService;
|
||||
import com.accompany.business.service.packcenter.UserUsePackRecordService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.result.PageResult;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class UserUsePackRecordAdminService {
|
||||
@Autowired
|
||||
private UserUsePackRecordService userUsePackRecordService;
|
||||
@Autowired
|
||||
private PackInfoService packInfoService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
public BusiResult<PageResult<UserUsePackRecordAdminVo>> list(Integer pageNo, Integer pageSize, Integer packId, Long erbanNo, Long targetErbanNo) {
|
||||
PageResult<UserUsePackRecordAdminVo> pageResult = new PageResult<>();
|
||||
Page<UserUsePackRecord> page = new Page<>(pageNo, pageSize);
|
||||
Long uid = null, targetUid = null;
|
||||
if (erbanNo != null) {
|
||||
Users user = usersService.getUserByErbanNo(erbanNo);
|
||||
if (user == null) {
|
||||
throw new AdminServiceException("ID:" + erbanNo + ",不存在");
|
||||
}
|
||||
uid = user.getUid();
|
||||
}
|
||||
if (targetErbanNo != null) {
|
||||
Users user = usersService.getUserByErbanNo(targetErbanNo);
|
||||
if (user == null) {
|
||||
throw new AdminServiceException("ID:" + targetErbanNo + ",不存在");
|
||||
}
|
||||
targetUid = user.getUid();
|
||||
}
|
||||
LambdaQueryWrapper<UserUsePackRecord> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(uid != null, UserUsePackRecord::getUid, uid);
|
||||
wrapper.eq(packId != null, UserUsePackRecord::getPackId, packId);
|
||||
wrapper.eq(targetUid != null, UserUsePackRecord::getTargetUid, targetUid);
|
||||
List<UserUsePackRecord> list = userUsePackRecordService.list(page, wrapper);
|
||||
List<UserUsePackRecordAdminVo> resultList = new ArrayList<>();
|
||||
pageResult.setRows(resultList);
|
||||
pageResult.setTotal((int)page.getTotal());
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return BusiResult.success(pageResult);
|
||||
}
|
||||
List<Long> uids = list.stream().map(UserUsePackRecord::getUid).collect(Collectors.toList());
|
||||
List<Long> targetUids = list.stream().map(UserUsePackRecord::getTargetUid).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(targetUids)) {
|
||||
uids.addAll(targetUids);
|
||||
}
|
||||
List<Integer> packIds = list.stream().map(UserUsePackRecord::getPackId).collect(Collectors.toList());
|
||||
Map<Long, Users> usersMap = usersService.getUsersMapByUids(uids);
|
||||
Map<Integer, PackInfo> packInfoMap = packInfoService.mapByPackIds(packIds);
|
||||
for (UserUsePackRecord packRecord : list) {
|
||||
UserUsePackRecordAdminVo vo = new UserUsePackRecordAdminVo();
|
||||
BeanUtils.copyProperties(packRecord, vo);
|
||||
Users users = usersMap.get(packRecord.getUid());
|
||||
if (users != null) {
|
||||
vo.setErbanNo(users.getErbanNo());
|
||||
vo.setNick(users.getNick());
|
||||
}
|
||||
users = usersMap.get(packRecord.getTargetUid());
|
||||
if (users != null) {
|
||||
vo.setTargeErbanNo(users.getErbanNo());
|
||||
vo.setTargeNick(users.getNick());
|
||||
vo.setPartitionId(users.getPartitionId());
|
||||
vo.setPartitionDesc(PartitionEnum.getByPartitionId(users.getPartitionId()).getDesc());
|
||||
}
|
||||
PackInfo packInfo = packInfoMap.get(packRecord.getPackId());
|
||||
if (packInfo != null) {
|
||||
vo.setPackName(packInfo.getPackName());
|
||||
}
|
||||
resultList.add(vo);
|
||||
}
|
||||
return BusiResult.success(pageResult);
|
||||
}
|
||||
}
|
@@ -30,6 +30,10 @@ public class PackInfoAdminController extends BaseController {
|
||||
@Autowired
|
||||
private AdminLogService adminLogService;
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNo", value = "第几页", required = true, dataType = "Integer", paramType = "query"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, dataType = "Integer", paramType = "query")
|
||||
})
|
||||
@ApiOperation(value = "礼包配置列表", httpMethod = "GET")
|
||||
@GetMapping("/configList")
|
||||
public BusiResult<PageResult<PackInfoAdminVo>> list(Integer pageNo, Integer pageSize) {
|
||||
|
@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = "礼包发放记录", value = "礼包发放记录")
|
||||
@RestController
|
||||
@RequestMapping("/admin/userPackRecord")
|
||||
@RequestMapping("/admin/userPack")
|
||||
public class UserPackRecordAdminController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@@ -28,7 +28,9 @@ public class UserPackRecordAdminController extends BaseController {
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "packId", value = "礼包id", required = true),
|
||||
@ApiImplicitParam(name = "erbanNo", value = "用户id", required = true)
|
||||
@ApiImplicitParam(name = "erbanNo", value = "用户id", required = true),
|
||||
@ApiImplicitParam(name = "pageNo", value = "第几页", required = true, dataType = "Integer", paramType = "query"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, dataType = "Integer", paramType = "query")
|
||||
})
|
||||
@ApiOperation(value = "发放记录", httpMethod = "GET")
|
||||
@GetMapping("/recordList")
|
||||
|
@@ -0,0 +1,36 @@
|
||||
package com.accompany.admin.controller.packcenter;
|
||||
|
||||
import com.accompany.admin.service.packcenter.UserUsePackRecordAdminService;
|
||||
import com.accompany.admin.vo.packcenter.UserUsePackRecordAdminVo;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.result.PageResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = "礼包使用记录", value = "礼包使用记录")
|
||||
@RestController
|
||||
@RequestMapping("/admin/userUsePack")
|
||||
public class UserUsePackRecordAdminController {
|
||||
@Autowired
|
||||
private UserUsePackRecordAdminService userUsePackRecordAdminService;
|
||||
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "packId", value = "礼包id", required = true),
|
||||
@ApiImplicitParam(name = "erbanNo", value = "用户id", required = true),
|
||||
@ApiImplicitParam(name = "targetErbanNo", value = "接收用户id", required = true),
|
||||
@ApiImplicitParam(name = "pageNo", value = "第几页", required = true, dataType = "Integer", paramType = "query"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, dataType = "Integer", paramType = "query")
|
||||
})
|
||||
@ApiOperation(value = "礼包使用记录", httpMethod = "GET")
|
||||
@GetMapping("/recordList")
|
||||
public BusiResult<PageResult<UserUsePackRecordAdminVo>> list(Integer pageNo, Integer pageSize, Integer packId, Long erbanNo, Long targetErbanNo) {
|
||||
return userUsePackRecordAdminService.list(pageNo, pageSize, packId, erbanNo, targetErbanNo);
|
||||
}
|
||||
}
|
@@ -1,11 +1,13 @@
|
||||
package com.accompany.business.model.packcenter;
|
||||
|
||||
import com.accompany.core.mybatis.typehandler.IntegerListTypeHandler;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户使用礼包记录实体类
|
||||
@@ -30,7 +32,7 @@ public class UserUsePackRecord implements Serializable {
|
||||
/**
|
||||
* 用户uid
|
||||
*/
|
||||
private Long target_uid;
|
||||
private Long targetUid;
|
||||
|
||||
private Long userPackId;
|
||||
/**
|
||||
@@ -40,7 +42,8 @@ public class UserUsePackRecord implements Serializable {
|
||||
/**
|
||||
* 礼包奖励id
|
||||
*/
|
||||
private String numberList;
|
||||
@TableField(typeHandler = IntegerListTypeHandler.class)
|
||||
private List<Integer> numberList;
|
||||
/**
|
||||
* 礼包数量
|
||||
*/
|
||||
@@ -52,7 +55,7 @@ public class UserUsePackRecord implements Serializable {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
private Byte createTime;
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user