Merge remote-tracking branch 'origin/main'
commit
27ec1f391b
@ -0,0 +1,121 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.controller.admin.prizedraw;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.prizedraw.PrizeDrawConvert;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.prizelog.PrizeLogConvert;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.ActivityPrizeDO;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.prizedraw.PrizeDrawService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 抽奖活动")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/promotion/prize-draw")
|
||||||
|
@Validated
|
||||||
|
public class PrizeDrawController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PrizeDrawService prizeDrawService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberLevelApi memberLevelApi;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建抽奖活动")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-draw:create')")
|
||||||
|
public CommonResult<Long> createPrizeDraw(@Valid @RequestBody PrizeDrawSaveReqVO createReqVO) {
|
||||||
|
return success(prizeDrawService.createPrizeDraw(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新抽奖活动")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-draw:update')")
|
||||||
|
public CommonResult<Boolean> updatePrizeDraw(@Valid @RequestBody PrizeDrawSaveReqVO updateReqVO) {
|
||||||
|
prizeDrawService.updatePrizeDraw(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除抽奖活动")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-draw:delete')")
|
||||||
|
public CommonResult<Boolean> deletePrizeDraw(@RequestParam("id") Long id) {
|
||||||
|
prizeDrawService.deletePrizeDraw(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得抽奖活动")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-draw:query')")
|
||||||
|
public CommonResult<PrizeDrawRespVO> getPrizeDraw(@RequestParam("id") Long id) {
|
||||||
|
PrizeDrawDO prizeDraw = prizeDrawService.getPrizeDraw(id);
|
||||||
|
return success(BeanUtils.toBean(prizeDraw, PrizeDrawRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得抽奖活动分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-draw:query')")
|
||||||
|
public CommonResult<PageResult<PrizeDrawRespVO>> getPrizeDrawPage(@Valid PrizeDrawPageReqVO pageReqVO) {
|
||||||
|
PageResult<PrizeDrawDO> pageResult = prizeDrawService.getPrizeDrawPage(pageReqVO);
|
||||||
|
// 处理用户级别返显
|
||||||
|
List<MemberLevelRespDTO> levels = memberLevelApi.getLevelList(
|
||||||
|
convertSet(pageResult.getList(), PrizeDrawDO::getMebLevel));
|
||||||
|
return success(PrizeDrawConvert.INSTANCE.convertPage(pageResult, levels));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出抽奖活动 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-draw:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportPrizeDrawExcel(@Valid PrizeDrawPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<PrizeDrawDO> list = prizeDrawService.getPrizeDrawPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "抽奖活动.xls", "数据", PrizeDrawRespVO.class,
|
||||||
|
BeanUtils.toBean(list, PrizeDrawRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 子表(抽奖活动奖品) ====================
|
||||||
|
|
||||||
|
@GetMapping("/activity-prize/list-by-activity-id")
|
||||||
|
@Operation(summary = "获得抽奖活动奖品列表")
|
||||||
|
@Parameter(name = "activityId", description = "关联抽奖活动id")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-draw:query')")
|
||||||
|
public CommonResult<List<ActivityPrizeDO>> getActivityPrizeListByActivityId(@RequestParam("activityId") Long activityId) {
|
||||||
|
return success(prizeDrawService.getActivityPrizeListByActivityId(activityId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.controller.admin.prizelog;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.bargain.BargainHelpConvert;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.prizelog.PrizeLogConvert;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.prizedraw.PrizeDrawService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.prizelog.PrizeLogService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 抽奖记录")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/promotion/prize-log")
|
||||||
|
@Validated
|
||||||
|
public class PrizeLogController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PrizeLogService prizeLogService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberUserApi memberUserApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PrizeDrawService prizeDrawService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建抽奖记录")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-log:create')")
|
||||||
|
public CommonResult<Long> createPrizeLog(@Valid @RequestBody PrizeLogSaveReqVO createReqVO) {
|
||||||
|
return success(prizeLogService.createPrizeLog(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新抽奖记录")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-log:update')")
|
||||||
|
public CommonResult<Boolean> updatePrizeLog(@Valid @RequestBody PrizeLogSaveReqVO updateReqVO) {
|
||||||
|
prizeLogService.updatePrizeLog(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除抽奖记录")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-log:delete')")
|
||||||
|
public CommonResult<Boolean> deletePrizeLog(@RequestParam("id") Long id) {
|
||||||
|
prizeLogService.deletePrizeLog(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得抽奖记录")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-log:query')")
|
||||||
|
public CommonResult<PrizeLogRespVO> getPrizeLog(@RequestParam("id") Long id) {
|
||||||
|
PrizeLogDO prizeLog = prizeLogService.getPrizeLog(id);
|
||||||
|
return success(BeanUtils.toBean(prizeLog, PrizeLogRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得抽奖记录分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-log:query')")
|
||||||
|
public CommonResult<PageResult<PrizeLogRespVO>> getPrizeLogPage(@Valid PrizeLogPageReqVO pageReqVO) {
|
||||||
|
PageResult<PrizeLogDO> pageResult = prizeLogService.getPrizeLogPage(pageReqVO);
|
||||||
|
// 拼接用户数据
|
||||||
|
Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(
|
||||||
|
convertSet(pageResult.getList(), PrizeLogDO::getMebId));
|
||||||
|
// 拼接活动数据
|
||||||
|
Map<Long, PrizeDrawDO> prizeMap = prizeDrawService.getPrizeDrawMap(
|
||||||
|
convertSet(pageResult.getList(), PrizeLogDO::getActivityId));
|
||||||
|
return success(PrizeLogConvert.INSTANCE.convertPage(pageResult, userMap,prizeMap));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出抽奖记录 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:prize-log:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportPrizeLogExcel(@Valid PrizeLogPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<PrizeLogDO> list = prizeLogService.getPrizeLogPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "抽奖记录.xls", "数据", PrizeLogRespVO.class,
|
||||||
|
BeanUtils.toBean(list, PrizeLogRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,180 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.controller.app.prizedraw;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.lang.WeightRandom;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.PrizeLogPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.PrizeLogRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.PrizeLogSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.app.prizedraw.vo.AppPrizeDrawRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.ActivityPrizeDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.prizedraw.PrizeDrawService;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.prizelog.PrizeLogService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.redisson.api.RLock;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.USER_NOT_EXISTS;
|
||||||
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
@Tag(name = "用户APP - 抽奖活动")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/promotion/prize-draw")
|
||||||
|
@Validated
|
||||||
|
public class AppPrizeDrawController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PrizeDrawService prizeDrawService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PrizeLogService prizeLogService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedissonClient redissonClient;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberUserApi memberUserApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberLevelApi memberLevelApi;
|
||||||
|
|
||||||
|
@GetMapping("/getOne")
|
||||||
|
@Operation(summary = "用户APP--获得抽奖活动规则")
|
||||||
|
public CommonResult<AppPrizeDrawRespVO> getPrizeDraw() {
|
||||||
|
PrizeDrawDO prizeDraw = prizeDrawService.getOnePrizeDraw();
|
||||||
|
if (prizeDraw == null) {//抽奖活动不存在
|
||||||
|
throw exception(PRIZE_DRAW_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
return success(BeanUtils.toBean(prizeDraw, AppPrizeDrawRespVO.class));
|
||||||
|
}
|
||||||
|
@GetMapping("/activity-prize/list-by-activity-id")
|
||||||
|
@Operation(summary = "用户APP--获得抽奖活动奖品列表")
|
||||||
|
@Parameter(name = "activityId", description = "关联抽奖活动id")
|
||||||
|
public CommonResult<List<ActivityPrizeDO>> getActivityPrizeListByActivityId(@RequestParam("activityId") Long activityId) {
|
||||||
|
return success(prizeDrawService.getActivityPrizeListByActivityId(activityId));
|
||||||
|
}
|
||||||
|
@GetMapping("/lottery")
|
||||||
|
@Operation(summary = "用户APP--抽奖")
|
||||||
|
@Parameter(name = "activityId", description = "关联抽奖活动id")
|
||||||
|
public CommonResult<ActivityPrizeDO> lottery(@RequestParam("activityId") Long activityId) {
|
||||||
|
//获取用户id
|
||||||
|
Long loginUserId = getLoginUserId();
|
||||||
|
//查询用户信息
|
||||||
|
MemberUserRespDTO user = memberUserApi.getUser(loginUserId);
|
||||||
|
//用户不存在
|
||||||
|
if(user == null){
|
||||||
|
throw exception(USER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
//获取活动信息
|
||||||
|
PrizeDrawDO prizeDraw = prizeDrawService.getPrizeDraw(activityId);
|
||||||
|
if (prizeDraw == null) {//抽奖活动不存在
|
||||||
|
throw exception(PRIZE_DRAW_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
//判断活动状态
|
||||||
|
if(!ObjectUtil.equal(prizeDraw.getStatus(),"0")){
|
||||||
|
throw exception(PRIZE_DRAW_NOT_START);
|
||||||
|
}
|
||||||
|
//判断抽奖活动时间范围
|
||||||
|
if(!DateUtil.isIn(new Date(),DateUtils.of(prizeDraw.getStartTime()),DateUtils.of(prizeDraw.getEndTime()))){
|
||||||
|
throw exception(PRIZE_DRAW_NOT_TIME);
|
||||||
|
}
|
||||||
|
//判断抽奖活动会员等级
|
||||||
|
MemberLevelRespDTO memberLevel = memberLevelApi.getMemberLevel(user.getLevelId());
|
||||||
|
MemberLevelRespDTO activityLevel = memberLevelApi.getMemberLevel(Long.valueOf(prizeDraw.getMebLevel()));
|
||||||
|
if(memberLevel.getLevel()<activityLevel.getLevel()){
|
||||||
|
throw exception(PRIZE_LOG_NOT_LEVEL);
|
||||||
|
}
|
||||||
|
//判断参与次数
|
||||||
|
Long drawNum = prizeLogService.getPrizeLogByMebIdList(loginUserId, prizeDraw);
|
||||||
|
if(drawNum>=prizeDraw.getDrawNum()){
|
||||||
|
throw exception(PRIZE_LOG_NOT_DRAWNUM);
|
||||||
|
}
|
||||||
|
//抽奖
|
||||||
|
ActivityPrizeDO activityPrizeDO = recursionLottery(prizeDraw);
|
||||||
|
return success(activityPrizeDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActivityPrizeDO recursionLottery(PrizeDrawDO prizeDraw){
|
||||||
|
//获取奖品信息
|
||||||
|
List<ActivityPrizeDO> list = prizeDrawService.getActivityPrizeListByActivityId(prizeDraw.getId());
|
||||||
|
//获取随机数
|
||||||
|
int sortNum = (int) (Math.random() * ((8-list.size()) + 1));
|
||||||
|
// TODO: 2023/8/16 0016 后台限制
|
||||||
|
List<WeightRandom.WeightObj<String>> weightObjList = new ArrayList<WeightRandom.WeightObj<String>>();
|
||||||
|
list.forEach(s -> {
|
||||||
|
weightObjList.add(new WeightRandom.WeightObj<>(s.getId().toString(), Double.valueOf(s.getPrizeChance())));
|
||||||
|
});
|
||||||
|
WeightRandom<String> wr = RandomUtil.weightRandom(weightObjList);
|
||||||
|
String str = wr.next();
|
||||||
|
RLock lock = redissonClient.getLock(str);
|
||||||
|
try {
|
||||||
|
if (lock.tryLock(1000, 10000, TimeUnit.MILLISECONDS)) {
|
||||||
|
ActivityPrizeDO activityPrize = prizeDrawService.getActivityPrize(Long.valueOf(str));
|
||||||
|
//判断被抽中次数
|
||||||
|
Long prizeLogNum = prizeLogService.getPrizeLogList(prizeDraw, activityPrize.getId());
|
||||||
|
if (prizeLogNum >= activityPrize.getWinNum()) {
|
||||||
|
recursionLottery(prizeDraw);
|
||||||
|
}
|
||||||
|
//中奖
|
||||||
|
//添加抽奖记录
|
||||||
|
PrizeLogSaveReqVO createReqVO = new PrizeLogSaveReqVO();
|
||||||
|
createReqVO.setMebId(getLoginUserId());
|
||||||
|
createReqVO.setActivityId(prizeDraw.getId());
|
||||||
|
createReqVO.setPrizeId(activityPrize.getId());
|
||||||
|
createReqVO.setName(activityPrize.getName());
|
||||||
|
createReqVO.setImgUrl(activityPrize.getImgUrl());
|
||||||
|
createReqVO.setWinNum(activityPrize.getWinNum());
|
||||||
|
createReqVO.setPrizeChance(activityPrize.getPrizeChance());
|
||||||
|
createReqVO.setPrizePoolAmount(activityPrize.getPrizePoolAmount());
|
||||||
|
createReqVO.setStatus("1");
|
||||||
|
prizeLogService.createPrizeLog(createReqVO);
|
||||||
|
return activityPrize;
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
if (ObjectUtil.isNotEmpty(lock)){
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getMyPrizeLogDO")
|
||||||
|
@Operation(summary = "获得我的抽奖记录")
|
||||||
|
public CommonResult<List<PrizeLogRespVO>> getPrizeLogPage(@RequestParam("activityId") Long activityId) {
|
||||||
|
//获取活动信息
|
||||||
|
PrizeDrawDO prizeDraw = prizeDrawService.getPrizeDraw(activityId);
|
||||||
|
List<PrizeLogDO> list = prizeLogService.getPrizeLogListByMebId(getLoginUserId(), prizeDraw);
|
||||||
|
return success(BeanUtils.toBean(list, PrizeLogRespVO.class));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.convert.prizedraw;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.PrizeDrawRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.PrizeLogRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.prizelog.PrizeLogConvert;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface PrizeDrawConvert {
|
||||||
|
PrizeDrawConvert INSTANCE = Mappers.getMapper(PrizeDrawConvert.class);
|
||||||
|
|
||||||
|
default PageResult<PrizeDrawRespVO> convertPage(PageResult<PrizeDrawDO> page,
|
||||||
|
List<MemberLevelRespDTO> levels) {
|
||||||
|
PageResult<PrizeDrawRespVO> pageResult = convertPage(page);
|
||||||
|
Map<Long, String> levelMap = convertMap(levels, MemberLevelRespDTO::getId, MemberLevelRespDTO::getName);
|
||||||
|
// 拼接数据
|
||||||
|
pageResult.getList().forEach(record ->{
|
||||||
|
MapUtils.findAndThen(levelMap, record.getMebLevel(),
|
||||||
|
level -> record.setLevelName(levelMap.get(record.getMebLevel())));
|
||||||
|
});
|
||||||
|
return pageResult;
|
||||||
|
}
|
||||||
|
PageResult<PrizeDrawRespVO> convertPage(PageResult<PrizeDrawDO> page);
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.convert.prizelog;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.PrizeLogRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抽奖记录 Convert
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface PrizeLogConvert {
|
||||||
|
|
||||||
|
PrizeLogConvert INSTANCE = Mappers.getMapper(PrizeLogConvert.class);
|
||||||
|
|
||||||
|
default PageResult<PrizeLogRespVO> convertPage(PageResult<PrizeLogDO> page,
|
||||||
|
Map<Long, MemberUserRespDTO> userMap,
|
||||||
|
Map<Long, PrizeDrawDO> prizeMap) {
|
||||||
|
PageResult<PrizeLogRespVO> pageResult = convertPage(page);
|
||||||
|
// 拼接数据
|
||||||
|
pageResult.getList().forEach(record ->{
|
||||||
|
MapUtils.findAndThen(userMap, record.getMebId(),
|
||||||
|
user -> record.setNickname(user.getNickname()));
|
||||||
|
MapUtils.findAndThen(prizeMap, record.getActivityId(),
|
||||||
|
activity -> record.setActivityName(activity.getName()));
|
||||||
|
});
|
||||||
|
return pageResult;
|
||||||
|
}
|
||||||
|
PageResult<PrizeLogRespVO> convertPage(PageResult<PrizeLogDO> page);
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抽奖活动奖品 DO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@TableName("promotion_activity_prize")
|
||||||
|
@KeySequence("promotion_activity_prize_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ActivityPrizeDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id主键
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 关联抽奖活动id
|
||||||
|
*/
|
||||||
|
private Long activityId;
|
||||||
|
/**
|
||||||
|
* 奖品名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 奖品图片路径
|
||||||
|
*/
|
||||||
|
private String imgUrl;
|
||||||
|
/**
|
||||||
|
* 获奖人数上限
|
||||||
|
*/
|
||||||
|
private Integer winNum;
|
||||||
|
/**
|
||||||
|
* 获奖概率
|
||||||
|
*/
|
||||||
|
private String prizeChance;
|
||||||
|
/**
|
||||||
|
* 获奖金额
|
||||||
|
*/
|
||||||
|
private String prizePoolAmount;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.dal.mysql.prizedraw;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.ActivityPrizeDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抽奖活动奖品 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ActivityPrizeMapper extends BaseMapperX<ActivityPrizeDO> {
|
||||||
|
|
||||||
|
default List<ActivityPrizeDO> selectListByActivityId(Long activityId) {
|
||||||
|
return selectList(ActivityPrizeDO::getActivityId, activityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
default int deleteByActivityId(Long activityId) {
|
||||||
|
return delete(ActivityPrizeDO::getActivityId, activityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.dal.mysql.prizedraw;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抽奖活动 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface PrizeDrawMapper extends BaseMapperX<PrizeDrawDO> {
|
||||||
|
|
||||||
|
default PageResult<PrizeDrawDO> selectPage(PrizeDrawPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<PrizeDrawDO>()
|
||||||
|
.likeIfPresent(PrizeDrawDO::getName, reqVO.getName())
|
||||||
|
.eqIfPresent(PrizeDrawDO::getActivityRule, reqVO.getActivityRule())
|
||||||
|
.eqIfPresent(PrizeDrawDO::getStatus, reqVO.getStatus())
|
||||||
|
.betweenIfPresent(PrizeDrawDO::getStartTime, reqVO.getStartTime())
|
||||||
|
.betweenIfPresent(PrizeDrawDO::getEndTime, reqVO.getEndTime())
|
||||||
|
.eqIfPresent(PrizeDrawDO::getMebLevel, reqVO.getMebLevel())
|
||||||
|
.betweenIfPresent(PrizeDrawDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(PrizeDrawDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.dal.mysql.prizelog;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抽奖记录 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface PrizeLogMapper extends BaseMapperX<PrizeLogDO> {
|
||||||
|
|
||||||
|
default PageResult<PrizeLogDO> selectPage(PrizeLogPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<PrizeLogDO>()
|
||||||
|
.eqIfPresent(PrizeLogDO::getMebId, reqVO.getMebId())
|
||||||
|
.eqIfPresent(PrizeLogDO::getActivityId, reqVO.getActivityId())
|
||||||
|
.likeIfPresent(PrizeLogDO::getName, reqVO.getName())
|
||||||
|
.eqIfPresent(PrizeLogDO::getImgUrl, reqVO.getImgUrl())
|
||||||
|
.eqIfPresent(PrizeLogDO::getWinNum, reqVO.getWinNum())
|
||||||
|
.eqIfPresent(PrizeLogDO::getPrizeChance, reqVO.getPrizeChance())
|
||||||
|
.eqIfPresent(PrizeLogDO::getPrizePoolAmount, reqVO.getPrizePoolAmount())
|
||||||
|
.eqIfPresent(PrizeLogDO::getStatus, reqVO.getStatus())
|
||||||
|
.betweenIfPresent(PrizeLogDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(PrizeLogDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.service.prizedraw;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.app.prizedraw.vo.AppPrizeDrawRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.ActivityPrizeDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抽奖活动 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface PrizeDrawService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建抽奖活动
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createPrizeDraw(@Valid PrizeDrawSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新抽奖活动
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updatePrizeDraw(@Valid PrizeDrawSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除抽奖活动
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deletePrizeDraw(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得抽奖活动
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 抽奖活动
|
||||||
|
*/
|
||||||
|
PrizeDrawDO getPrizeDraw(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得抽奖活动分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 抽奖活动分页
|
||||||
|
*/
|
||||||
|
PageResult<PrizeDrawDO> getPrizeDrawPage(PrizeDrawPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
// ==================== 子表(抽奖活动奖品) ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得抽奖活动奖品列表
|
||||||
|
*
|
||||||
|
* @param activityId 关联抽奖活动id
|
||||||
|
* @return 抽奖活动奖品列表
|
||||||
|
*/
|
||||||
|
List<ActivityPrizeDO> getActivityPrizeListByActivityId(Long activityId);
|
||||||
|
/**
|
||||||
|
* 获得抽奖活动奖品
|
||||||
|
*
|
||||||
|
* @param id 奖品id
|
||||||
|
* @return 抽奖活动奖品列表
|
||||||
|
*/
|
||||||
|
ActivityPrizeDO getActivityPrize(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得已开启抽奖活动
|
||||||
|
*
|
||||||
|
* @return 抽奖活动
|
||||||
|
*/
|
||||||
|
PrizeDrawDO getOnePrizeDraw();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得活动 Map
|
||||||
|
*
|
||||||
|
* @param ids 活动id的数组
|
||||||
|
* @return 活动 Map
|
||||||
|
*/
|
||||||
|
default Map<Long, PrizeDrawDO> getPrizeDrawMap(Collection<Long> ids) {
|
||||||
|
List<PrizeDrawDO> list = getPrizeDrawDOList(ids);
|
||||||
|
return convertMap(list, PrizeDrawDO::getId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得活动信息
|
||||||
|
*
|
||||||
|
* @param ids 用户编号的数组
|
||||||
|
* @return 用户信息们
|
||||||
|
*/
|
||||||
|
List<PrizeDrawDO> getPrizeDrawDOList(Collection<Long> ids);
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.service.prizelog;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抽奖记录 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface PrizeLogService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建抽奖记录
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createPrizeLog(@Valid PrizeLogSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新抽奖记录
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updatePrizeLog(@Valid PrizeLogSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除抽奖记录
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deletePrizeLog(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得抽奖记录
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 抽奖记录
|
||||||
|
*/
|
||||||
|
PrizeLogDO getPrizeLog(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得抽奖记录分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 抽奖记录分页
|
||||||
|
*/
|
||||||
|
PageResult<PrizeLogDO> getPrizeLogPage(PrizeLogPageReqVO pageReqVO);
|
||||||
|
/**
|
||||||
|
* 查询用户抽奖次数
|
||||||
|
*
|
||||||
|
* @param mebId 用户id
|
||||||
|
* @return 抽奖记录分页
|
||||||
|
*/
|
||||||
|
Long getPrizeLogByMebIdList(Long mebId,PrizeDrawDO prizeDraw);
|
||||||
|
/**
|
||||||
|
* 查询奖品被抽中次数
|
||||||
|
*
|
||||||
|
* @param prizeDraw 活动
|
||||||
|
* @return 抽奖记录分页
|
||||||
|
*/
|
||||||
|
Long getPrizeLogList(PrizeDrawDO prizeDraw,Long prizeId);
|
||||||
|
/**
|
||||||
|
* 获取我的抽奖记录
|
||||||
|
*
|
||||||
|
* @param prizeDraw 活动
|
||||||
|
* @return 抽奖记录分页
|
||||||
|
*/
|
||||||
|
List<PrizeLogDO> getPrizeLogListByMebId(Long mebId,PrizeDrawDO prizeDraw);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.service.prizelog;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.mysql.prizelog.PrizeLogMapper;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抽奖记录 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class PrizeLogServiceImpl implements PrizeLogService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PrizeLogMapper prizeLogMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createPrizeLog(PrizeLogSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
PrizeLogDO prizeLog = BeanUtils.toBean(createReqVO, PrizeLogDO.class);
|
||||||
|
prizeLogMapper.insert(prizeLog);
|
||||||
|
// 返回
|
||||||
|
return prizeLog.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updatePrizeLog(PrizeLogSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validatePrizeLogExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
PrizeLogDO updateObj = BeanUtils.toBean(updateReqVO, PrizeLogDO.class);
|
||||||
|
prizeLogMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deletePrizeLog(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validatePrizeLogExists(id);
|
||||||
|
// 删除
|
||||||
|
prizeLogMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validatePrizeLogExists(Long id) {
|
||||||
|
if (prizeLogMapper.selectById(id) == null) {
|
||||||
|
throw exception(PRIZE_LOG_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PrizeLogDO getPrizeLog(Long id) {
|
||||||
|
return prizeLogMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<PrizeLogDO> getPrizeLogPage(PrizeLogPageReqVO pageReqVO) {
|
||||||
|
return prizeLogMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getPrizeLogByMebIdList(Long mebId,PrizeDrawDO prizeDraw) {
|
||||||
|
return prizeLogMapper.selectCount(new LambdaQueryWrapperX<PrizeLogDO>()
|
||||||
|
.eq(PrizeLogDO::getMebId, mebId)
|
||||||
|
.ge(PrizeLogDO::getCreateTime, prizeDraw.getStartTime())
|
||||||
|
.le(PrizeLogDO::getCreateTime, prizeDraw.getEndTime())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getPrizeLogList(PrizeDrawDO prizeDraw,Long prizeId) {
|
||||||
|
return prizeLogMapper.selectCount(new LambdaQueryWrapperX<PrizeLogDO>()
|
||||||
|
.eq(PrizeLogDO::getPrizeId,prizeId)
|
||||||
|
.ge(PrizeLogDO::getCreateTime, prizeDraw.getStartTime())
|
||||||
|
.le(PrizeLogDO::getCreateTime, prizeDraw.getEndTime())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PrizeLogDO> getPrizeLogListByMebId(Long mebId,PrizeDrawDO prizeDraw) {
|
||||||
|
return prizeLogMapper.selectList(new LambdaQueryWrapperX<PrizeLogDO>()
|
||||||
|
.eq(PrizeLogDO::getMebId, mebId)
|
||||||
|
.ge(PrizeLogDO::getCreateTime, prizeDraw.getStartTime())
|
||||||
|
.le(PrizeLogDO::getCreateTime, prizeDraw.getEndTime())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,154 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.service.prizedraw;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.mysql.prizedraw.PrizeDrawMapper;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.hutool.core.util.RandomUtil.*;
|
||||||
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link PrizeDrawServiceImpl} 的单元测试类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Import(PrizeDrawServiceImpl.class)
|
||||||
|
public class PrizeDrawServiceImplTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PrizeDrawServiceImpl prizeDrawService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PrizeDrawMapper prizeDrawMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreatePrizeDraw_success() {
|
||||||
|
// 准备参数
|
||||||
|
PrizeDrawSaveReqVO createReqVO = randomPojo(PrizeDrawSaveReqVO.class).setId(null);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
Long prizeDrawId = prizeDrawService.createPrizeDraw(createReqVO);
|
||||||
|
// 断言
|
||||||
|
assertNotNull(prizeDrawId);
|
||||||
|
// 校验记录的属性是否正确
|
||||||
|
PrizeDrawDO prizeDraw = prizeDrawMapper.selectById(prizeDrawId);
|
||||||
|
assertPojoEquals(createReqVO, prizeDraw, "id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdatePrizeDraw_success() {
|
||||||
|
// mock 数据
|
||||||
|
PrizeDrawDO dbPrizeDraw = randomPojo(PrizeDrawDO.class);
|
||||||
|
prizeDrawMapper.insert(dbPrizeDraw);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
PrizeDrawSaveReqVO updateReqVO = randomPojo(PrizeDrawSaveReqVO.class, o -> {
|
||||||
|
o.setId(dbPrizeDraw.getId()); // 设置更新的 ID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
prizeDrawService.updatePrizeDraw(updateReqVO);
|
||||||
|
// 校验是否更新正确
|
||||||
|
PrizeDrawDO prizeDraw = prizeDrawMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||||
|
assertPojoEquals(updateReqVO, prizeDraw);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdatePrizeDraw_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
PrizeDrawSaveReqVO updateReqVO = randomPojo(PrizeDrawSaveReqVO.class);
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> prizeDrawService.updatePrizeDraw(updateReqVO), PRIZE_DRAW_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeletePrizeDraw_success() {
|
||||||
|
// mock 数据
|
||||||
|
PrizeDrawDO dbPrizeDraw = randomPojo(PrizeDrawDO.class);
|
||||||
|
prizeDrawMapper.insert(dbPrizeDraw);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
Long id = dbPrizeDraw.getId();
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
prizeDrawService.deletePrizeDraw(id);
|
||||||
|
// 校验数据不存在了
|
||||||
|
assertNull(prizeDrawMapper.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeletePrizeDraw_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
Long id = randomLongId();
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> prizeDrawService.deletePrizeDraw(id), PRIZE_DRAW_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetPrizeDrawPage() {
|
||||||
|
// mock 数据
|
||||||
|
PrizeDrawDO dbPrizeDraw = randomPojo(PrizeDrawDO.class, o -> { // 等会查询到
|
||||||
|
o.setName(null);
|
||||||
|
o.setActivityRule(null);
|
||||||
|
o.setStatus(null);
|
||||||
|
o.setStartTime(null);
|
||||||
|
o.setEndTime(null);
|
||||||
|
o.setMebLevel(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
});
|
||||||
|
prizeDrawMapper.insert(dbPrizeDraw);
|
||||||
|
// 测试 name 不匹配
|
||||||
|
prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setName(null)));
|
||||||
|
// 测试 activityRule 不匹配
|
||||||
|
prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setActivityRule(null)));
|
||||||
|
// 测试 status 不匹配
|
||||||
|
prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setStatus(null)));
|
||||||
|
// 测试 startTime 不匹配
|
||||||
|
prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setStartTime(null)));
|
||||||
|
// 测试 endTime 不匹配
|
||||||
|
prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setEndTime(null)));
|
||||||
|
// 测试 mebLevel 不匹配
|
||||||
|
prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setMebLevel(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
prizeDrawMapper.insert(cloneIgnoreId(dbPrizeDraw, o -> o.setCreateTime(null)));
|
||||||
|
// 准备参数
|
||||||
|
PrizeDrawPageReqVO reqVO = new PrizeDrawPageReqVO();
|
||||||
|
reqVO.setName(null);
|
||||||
|
reqVO.setActivityRule(null);
|
||||||
|
reqVO.setStatus(null);
|
||||||
|
reqVO.setStartTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
reqVO.setEndTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
reqVO.setMebLevel(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
PageResult<PrizeDrawDO> pageResult = prizeDrawService.getPrizeDrawPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbPrizeDraw, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,162 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.service.prizelog;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.prizelog.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizelog.PrizeLogDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.mysql.prizelog.PrizeLogMapper;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.hutool.core.util.RandomUtil.*;
|
||||||
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link PrizeLogServiceImpl} 的单元测试类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Import(PrizeLogServiceImpl.class)
|
||||||
|
public class PrizeLogServiceImplTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PrizeLogServiceImpl prizeLogService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PrizeLogMapper prizeLogMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreatePrizeLog_success() {
|
||||||
|
// 准备参数
|
||||||
|
PrizeLogSaveReqVO createReqVO = randomPojo(PrizeLogSaveReqVO.class).setId(null);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
Long prizeLogId = prizeLogService.createPrizeLog(createReqVO);
|
||||||
|
// 断言
|
||||||
|
assertNotNull(prizeLogId);
|
||||||
|
// 校验记录的属性是否正确
|
||||||
|
PrizeLogDO prizeLog = prizeLogMapper.selectById(prizeLogId);
|
||||||
|
assertPojoEquals(createReqVO, prizeLog, "id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdatePrizeLog_success() {
|
||||||
|
// mock 数据
|
||||||
|
PrizeLogDO dbPrizeLog = randomPojo(PrizeLogDO.class);
|
||||||
|
prizeLogMapper.insert(dbPrizeLog);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
PrizeLogSaveReqVO updateReqVO = randomPojo(PrizeLogSaveReqVO.class, o -> {
|
||||||
|
o.setId(dbPrizeLog.getId()); // 设置更新的 ID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
prizeLogService.updatePrizeLog(updateReqVO);
|
||||||
|
// 校验是否更新正确
|
||||||
|
PrizeLogDO prizeLog = prizeLogMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||||
|
assertPojoEquals(updateReqVO, prizeLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdatePrizeLog_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
PrizeLogSaveReqVO updateReqVO = randomPojo(PrizeLogSaveReqVO.class);
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> prizeLogService.updatePrizeLog(updateReqVO), PRIZE_LOG_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeletePrizeLog_success() {
|
||||||
|
// mock 数据
|
||||||
|
PrizeLogDO dbPrizeLog = randomPojo(PrizeLogDO.class);
|
||||||
|
prizeLogMapper.insert(dbPrizeLog);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
Long id = dbPrizeLog.getId();
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
prizeLogService.deletePrizeLog(id);
|
||||||
|
// 校验数据不存在了
|
||||||
|
assertNull(prizeLogMapper.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeletePrizeLog_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
Long id = randomLongId();
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> prizeLogService.deletePrizeLog(id), PRIZE_LOG_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetPrizeLogPage() {
|
||||||
|
// mock 数据
|
||||||
|
PrizeLogDO dbPrizeLog = randomPojo(PrizeLogDO.class, o -> { // 等会查询到
|
||||||
|
o.setMebId(null);
|
||||||
|
o.setActivityId(null);
|
||||||
|
o.setName(null);
|
||||||
|
o.setImgUrl(null);
|
||||||
|
o.setWinNum(null);
|
||||||
|
o.setPrizeChance(null);
|
||||||
|
o.setPrizePoolAmount(null);
|
||||||
|
o.setStatus(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
});
|
||||||
|
prizeLogMapper.insert(dbPrizeLog);
|
||||||
|
// 测试 mebId 不匹配
|
||||||
|
prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setMebId(null)));
|
||||||
|
// 测试 activityId 不匹配
|
||||||
|
prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setActivityId(null)));
|
||||||
|
// 测试 name 不匹配
|
||||||
|
prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setName(null)));
|
||||||
|
// 测试 imgUrl 不匹配
|
||||||
|
prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setImgUrl(null)));
|
||||||
|
// 测试 winNum 不匹配
|
||||||
|
prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setWinNum(null)));
|
||||||
|
// 测试 prizeChance 不匹配
|
||||||
|
prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setPrizeChance(null)));
|
||||||
|
// 测试 prizePoolAmount 不匹配
|
||||||
|
prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setPrizePoolAmount(null)));
|
||||||
|
// 测试 status 不匹配
|
||||||
|
prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setStatus(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
prizeLogMapper.insert(cloneIgnoreId(dbPrizeLog, o -> o.setCreateTime(null)));
|
||||||
|
// 准备参数
|
||||||
|
PrizeLogPageReqVO reqVO = new PrizeLogPageReqVO();
|
||||||
|
reqVO.setMebId(null);
|
||||||
|
reqVO.setActivityId(null);
|
||||||
|
reqVO.setName(null);
|
||||||
|
reqVO.setImgUrl(null);
|
||||||
|
reqVO.setWinNum(null);
|
||||||
|
reqVO.setPrizeChance(null);
|
||||||
|
reqVO.setPrizePoolAmount(null);
|
||||||
|
reqVO.setStatus(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
PageResult<PrizeLogDO> pageResult = prizeLogService.getPrizeLogPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbPrizeLog, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.api.order;
|
||||||
|
|
||||||
|
public interface TradeOrderItemApi {
|
||||||
|
}
|
@ -0,0 +1,125 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionconfig;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.convert.distributionconfig.DistributionConfigConvert;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO;
|
||||||
|
import cn.iocoder.yudao.module.member.service.distributionconfig.DistributionConfigService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 分销配置")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/member/distribution-config")
|
||||||
|
@Validated
|
||||||
|
public class DistributionConfigController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DistributionConfigService distributionConfigService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberLevelApi memberLevelApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProductSpuApi spuApi;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建分销配置")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-config:create')")
|
||||||
|
public CommonResult<Long> createDistributionConfig(@Valid @RequestBody DistributionConfigSaveReqVO createReqVO) {
|
||||||
|
return success(distributionConfigService.createDistributionConfig(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新分销配置")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-config:update')")
|
||||||
|
public CommonResult<Boolean> updateDistributionConfig(@Valid @RequestBody DistributionConfigSaveReqVO updateReqVO) {
|
||||||
|
distributionConfigService.updateDistributionConfig(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除分销配置")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-config:delete')")
|
||||||
|
public CommonResult<Boolean> deleteDistributionConfig(@RequestParam("id") Long id) {
|
||||||
|
distributionConfigService.deleteDistributionConfig(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得分销配置")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-config:query')")
|
||||||
|
public CommonResult<DistributionConfigRespVO> getDistributionConfig(@RequestParam("id") Long id) {
|
||||||
|
DistributionConfigDO distributionConfig = distributionConfigService.getDistributionConfig(id);
|
||||||
|
return success(BeanUtils.toBean(distributionConfig, DistributionConfigRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得分销配置分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-config:query')")
|
||||||
|
public CommonResult<PageResult<DistributionConfigRespVO>> getDistributionConfigPage(@Valid DistributionConfigPageReqVO pageReqVO) {
|
||||||
|
PageResult<DistributionConfigDO> pageResult = distributionConfigService.getDistributionConfigPage(pageReqVO);
|
||||||
|
// 处理用户级别返显
|
||||||
|
List<MemberLevelRespDTO> levels = memberLevelApi.getLevelList(
|
||||||
|
convertSet(pageResult.getList(), DistributionConfigDO::getLevelId));
|
||||||
|
// 拼接数据
|
||||||
|
List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(pageResult.getList(), DistributionConfigDO::getProductId));
|
||||||
|
return success(DistributionConfigConvert.INSTANCE.convertPage(pageResult, levels,spuList));
|
||||||
|
// return success(BeanUtils.toBean(pageResult, DistributionConfigRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出分销配置 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-config:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportDistributionConfigExcel(@Valid DistributionConfigPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<DistributionConfigDO> list = distributionConfigService.getDistributionConfigPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "分销配置.xls", "数据", DistributionConfigRespVO.class,
|
||||||
|
BeanUtils.toBean(list, DistributionConfigRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 子表(分销配置关联会员等级) ====================
|
||||||
|
|
||||||
|
@GetMapping("/distribution-meb-config/list-by-config-id")
|
||||||
|
@Operation(summary = "获得分销配置关联会员等级列表")
|
||||||
|
@Parameter(name = "configId", description = "分销配置id")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-config:query')")
|
||||||
|
public CommonResult<List<DistributionMebConfigDO>> getDistributionMebConfigListByConfigId(@RequestParam("configId") Long configId) {
|
||||||
|
return success(distributionConfigService.getDistributionMebConfigListByConfigId(configId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分销配置分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class DistributionConfigPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "分销商品id", example = "18678")
|
||||||
|
private Long productId;
|
||||||
|
@Schema(description = "购买人提升会员等级", example = "18678")
|
||||||
|
private Long levelId;
|
||||||
|
|
||||||
|
@Schema(description = "启用状态", example = "2")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分销配置 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class DistributionConfigRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16387")
|
||||||
|
@ExcelProperty("id主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "分销商品id", example = "18678")
|
||||||
|
@ExcelProperty("分销商品id")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
@Schema(description = "购买人提升会员等级", example = "18678")
|
||||||
|
@ExcelProperty("购买人提升会员等级")
|
||||||
|
private Long levelId;
|
||||||
|
|
||||||
|
@Schema(description = "启用状态", example = "2")
|
||||||
|
@ExcelProperty("启用状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "购买人提升会员等级", example = "18678")
|
||||||
|
@ExcelProperty("购买人提升会员等级")
|
||||||
|
private String levelName;
|
||||||
|
|
||||||
|
@Schema(description = "商品名称", example = "18678")
|
||||||
|
@ExcelProperty("商品名称")
|
||||||
|
private String supName;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分销配置新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class DistributionConfigSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16387")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "分销商品id", example = "18678")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
@Schema(description = "购买人提升会员等级", example = "18678")
|
||||||
|
private Long levelId;
|
||||||
|
|
||||||
|
@Schema(description = "启用状态", example = "2")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "分销配置关联会员等级列表")
|
||||||
|
private List<DistributionMebConfigDO> distributionMebConfigs;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionlog;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.convert.distributionlog.DistributionLogConvert;
|
||||||
|
import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO;
|
||||||
|
import cn.iocoder.yudao.module.member.service.distributionlog.DistributionLogService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 分销记录")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/member/distribution-log")
|
||||||
|
@Validated
|
||||||
|
public class DistributionLogController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DistributionLogService distributionLogService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberUserService memberUserService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建分销记录")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-log:create')")
|
||||||
|
public CommonResult<Long> createDistributionLog(@Valid @RequestBody DistributionLogSaveReqVO createReqVO) {
|
||||||
|
return success(distributionLogService.createDistributionLog(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新分销记录")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-log:update')")
|
||||||
|
public CommonResult<Boolean> updateDistributionLog(@Valid @RequestBody DistributionLogSaveReqVO updateReqVO) {
|
||||||
|
distributionLogService.updateDistributionLog(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除分销记录")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-log:delete')")
|
||||||
|
public CommonResult<Boolean> deleteDistributionLog(@RequestParam("id") Long id) {
|
||||||
|
distributionLogService.deleteDistributionLog(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得分销记录")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-log:query')")
|
||||||
|
public CommonResult<DistributionLogRespVO> getDistributionLog(@RequestParam("id") Long id) {
|
||||||
|
DistributionLogDO distributionLog = distributionLogService.getDistributionLog(id);
|
||||||
|
return success(BeanUtils.toBean(distributionLog, DistributionLogRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得分销记录分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-log:query')")
|
||||||
|
public CommonResult<PageResult<DistributionLogRespVO>> getDistributionLogPage(@Valid DistributionLogPageReqVO pageReqVO) {
|
||||||
|
pageReqVO.setGameStatus("0");
|
||||||
|
PageResult<DistributionLogDO> pageResult = distributionLogService.getDistributionLogPage(pageReqVO);
|
||||||
|
// 拼接结果返回
|
||||||
|
List<MemberUserDO> users = memberUserService.getUserList(
|
||||||
|
convertSet(pageResult.getList(), DistributionLogDO::getMebId));
|
||||||
|
return success(DistributionLogConvert.INSTANCE.convertPage(pageResult, users));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出分销记录 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-log:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportDistributionLogExcel(@Valid DistributionLogPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<DistributionLogDO> list = distributionLogService.getDistributionLogPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "分销记录.xls", "数据", DistributionLogRespVO.class,
|
||||||
|
BeanUtils.toBean(list, DistributionLogRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分销记录分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class DistributionLogPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "推荐人id", example = "5267")
|
||||||
|
private Long referrerId;
|
||||||
|
|
||||||
|
@Schema(description = "推荐人id(便于回溯)", example = "23906")
|
||||||
|
private Long oldReferrerId;
|
||||||
|
|
||||||
|
@Schema(description = "购买人id", example = "6637")
|
||||||
|
private Long mebId;
|
||||||
|
|
||||||
|
@Schema(description = "佣金")
|
||||||
|
private Integer brokerage;
|
||||||
|
|
||||||
|
@Schema(description = "分佣结算核销状态", example = "2")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "游戏状态", example = "2")
|
||||||
|
private String gameStatus;
|
||||||
|
|
||||||
|
@Schema(description = "游戏兑换状态", example = "1")
|
||||||
|
private String convertStatus;
|
||||||
|
|
||||||
|
@Schema(description = "推荐人会员等级id", example = "10242")
|
||||||
|
private Long levelId;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分销记录 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class DistributionLogRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4693")
|
||||||
|
@ExcelProperty("id主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "推荐人id", example = "5267")
|
||||||
|
@ExcelProperty("推荐人id")
|
||||||
|
private Long referrerId;
|
||||||
|
|
||||||
|
@Schema(description = "推荐人id(便于回溯)", example = "23906")
|
||||||
|
@ExcelProperty("推荐人id(便于回溯)")
|
||||||
|
private Long oldReferrerId;
|
||||||
|
|
||||||
|
@Schema(description = "购买人id", example = "6637")
|
||||||
|
@ExcelProperty("购买人id")
|
||||||
|
private Long mebId;
|
||||||
|
|
||||||
|
@Schema(description = "佣金")
|
||||||
|
@ExcelProperty("佣金")
|
||||||
|
private Integer brokerage;
|
||||||
|
|
||||||
|
@Schema(description = "分佣结算核销状态", example = "2")
|
||||||
|
@ExcelProperty("分佣结算核销状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "游戏状态", example = "2")
|
||||||
|
@ExcelProperty("游戏状态")
|
||||||
|
private String gameStatus;
|
||||||
|
|
||||||
|
@Schema(description = "游戏兑换状态", example = "1")
|
||||||
|
@ExcelProperty("游戏兑换状态")
|
||||||
|
private String convertStatus;
|
||||||
|
|
||||||
|
@Schema(description = "推荐人会员等级id", example = "10242")
|
||||||
|
@ExcelProperty("推荐人会员等级id")
|
||||||
|
private Long levelId;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "用户昵称", example = "2")
|
||||||
|
@ExcelProperty("用户昵称")
|
||||||
|
private String nickname;
|
||||||
|
|
||||||
|
@Schema(description = "用户名称", example = "2")
|
||||||
|
@ExcelProperty("用户名称")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "手机号", example = "2")
|
||||||
|
@ExcelProperty("手机号")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分销记录新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class DistributionLogSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4693")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "推荐人id", example = "5267")
|
||||||
|
private Long referrerId;
|
||||||
|
|
||||||
|
@Schema(description = "推荐人id(便于回溯)", example = "23906")
|
||||||
|
private Long oldReferrerId;
|
||||||
|
|
||||||
|
@Schema(description = "购买人id", example = "6637")
|
||||||
|
private Long mebId;
|
||||||
|
|
||||||
|
@Schema(description = "佣金")
|
||||||
|
private Integer brokerage;
|
||||||
|
|
||||||
|
@Schema(description = "分佣结算核销状态", example = "2")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "游戏状态", example = "2")
|
||||||
|
private String gameStatus;
|
||||||
|
|
||||||
|
@Schema(description = "游戏兑换状态", example = "1")
|
||||||
|
private String convertStatus;
|
||||||
|
|
||||||
|
@Schema(description = "推荐人会员等级id", example = "10242")
|
||||||
|
private Long levelId;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,124 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.convert.distributionlog.DistributionLogConvert;
|
||||||
|
import cn.iocoder.yudao.module.member.convert.distributionstatistics.DistributionStatisticsConvert;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO;
|
||||||
|
import cn.iocoder.yudao.module.member.service.distributionstatistics.DistributionStatisticsService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 分销统计")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/member/distribution-statistics")
|
||||||
|
@Validated
|
||||||
|
public class DistributionStatisticsController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DistributionStatisticsService distributionStatisticsService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberUserService memberUserService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberLevelApi memberLevelApi;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建分销统计")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-statistics:create')")
|
||||||
|
public CommonResult<Long> createDistributionStatistics(@Valid @RequestBody DistributionStatisticsSaveReqVO createReqVO) {
|
||||||
|
return success(distributionStatisticsService.createDistributionStatistics(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新分销统计")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-statistics:update')")
|
||||||
|
public CommonResult<Boolean> updateDistributionStatistics(@Valid @RequestBody DistributionStatisticsSaveReqVO updateReqVO) {
|
||||||
|
distributionStatisticsService.updateDistributionStatistics(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/updateAlready")
|
||||||
|
@Operation(summary = "结算分销统计")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-statistics:update')")
|
||||||
|
public CommonResult<Boolean> updateAlready(@Valid @RequestBody DistributionStatisticsSaveReqVO updateReqVO) {
|
||||||
|
distributionStatisticsService.updateAlready(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除分销统计")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-statistics:delete')")
|
||||||
|
public CommonResult<Boolean> deleteDistributionStatistics(@RequestParam("id") Long id) {
|
||||||
|
distributionStatisticsService.deleteDistributionStatistics(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得分销统计")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-statistics:query')")
|
||||||
|
public CommonResult<DistributionStatisticsRespVO> getDistributionStatistics(@RequestParam("id") Long id) {
|
||||||
|
DistributionStatisticsDO distributionStatistics = distributionStatisticsService.getDistributionStatistics(id);
|
||||||
|
return success(BeanUtils.toBean(distributionStatistics, DistributionStatisticsRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得分销统计分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-statistics:query')")
|
||||||
|
public CommonResult<PageResult<DistributionStatisticsRespVO>> getDistributionStatisticsPage(@Valid DistributionStatisticsPageReqVO pageReqVO) {
|
||||||
|
PageResult<DistributionStatisticsRespVO> pageResult = distributionStatisticsService.getDistributionStatisticsPage1(pageReqVO);
|
||||||
|
// 拼接结果返回
|
||||||
|
// 处理用户级别返显
|
||||||
|
List<MemberLevelRespDTO> levels = memberLevelApi.getLevelList(
|
||||||
|
convertSet(pageResult.getList(), DistributionStatisticsRespVO::getLevelId));
|
||||||
|
List<MemberUserDO> users = memberUserService.getUserList(
|
||||||
|
convertSet(pageResult.getList(), DistributionStatisticsRespVO::getMebId));
|
||||||
|
return success(DistributionStatisticsConvert.INSTANCE.convertPage(pageResult, users,levels));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出分销统计 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:distribution-statistics:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportDistributionStatisticsExcel(@Valid DistributionStatisticsPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<DistributionStatisticsDO> list = distributionStatisticsService.getDistributionStatisticsPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "分销统计.xls", "数据", DistributionStatisticsRespVO.class,
|
||||||
|
BeanUtils.toBean(list, DistributionStatisticsRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分销统计分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class DistributionStatisticsPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "会员等级id", example = "19012")
|
||||||
|
private Long levelId;
|
||||||
|
|
||||||
|
@Schema(description = "会员id", example = "10495")
|
||||||
|
private Long mebId;
|
||||||
|
|
||||||
|
@Schema(description = "推荐记录id", example = "5711")
|
||||||
|
private Long logId;
|
||||||
|
|
||||||
|
@Schema(description = "推荐人id", example = "2750")
|
||||||
|
private Long referrerId;
|
||||||
|
|
||||||
|
@Schema(description = "分佣结算核销状态", example = "1")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分销统计 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class DistributionStatisticsRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25196")
|
||||||
|
@ExcelProperty("id主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "会员等级id", example = "19012")
|
||||||
|
@ExcelProperty("会员等级id")
|
||||||
|
private Long levelId;
|
||||||
|
|
||||||
|
@Schema(description = "会员id", example = "10495")
|
||||||
|
@ExcelProperty("会员id")
|
||||||
|
private Long mebId;
|
||||||
|
|
||||||
|
@Schema(description = "推荐记录id", example = "5711")
|
||||||
|
@ExcelProperty("推荐记录id")
|
||||||
|
private Long logId;
|
||||||
|
|
||||||
|
@Schema(description = "推荐人id", example = "2750")
|
||||||
|
@ExcelProperty("推荐人id")
|
||||||
|
private Long referrerId;
|
||||||
|
|
||||||
|
@Schema(description = "分佣结算核销状态", example = "1")
|
||||||
|
@ExcelProperty("分佣结算核销状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "用户昵称", example = "2")
|
||||||
|
@ExcelProperty("用户昵称")
|
||||||
|
private String nickname;
|
||||||
|
|
||||||
|
@Schema(description = "用户名称", example = "2")
|
||||||
|
@ExcelProperty("用户名称")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "手机号", example = "2")
|
||||||
|
@ExcelProperty("手机号")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@Schema(description = "会员等级", example = "2")
|
||||||
|
@ExcelProperty("会员等级")
|
||||||
|
private String levelName;
|
||||||
|
|
||||||
|
@Schema(description = "已结算", example = "2")
|
||||||
|
@ExcelProperty("已结算")
|
||||||
|
private Integer haveAlready;
|
||||||
|
|
||||||
|
@Schema(description = "未结算", example = "2")
|
||||||
|
@ExcelProperty("未结算")
|
||||||
|
private Integer unAlready;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分销统计新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class DistributionStatisticsSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25196")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "会员等级id", example = "19012")
|
||||||
|
private Long levelId;
|
||||||
|
|
||||||
|
@Schema(description = "会员id", example = "10495")
|
||||||
|
private Long mebId;
|
||||||
|
|
||||||
|
@Schema(description = "推荐记录id", example = "5711")
|
||||||
|
private Long logId;
|
||||||
|
|
||||||
|
@Schema(description = "推荐人id", example = "2750")
|
||||||
|
private Long referrerId;
|
||||||
|
|
||||||
|
@Schema(description = "分佣结算核销状态", example = "1")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.convert.distributionconfig;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.DistributionConfigRespVO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DistributionConfigConvert {
|
||||||
|
DistributionConfigConvert INSTANCE = Mappers.getMapper(DistributionConfigConvert.class);
|
||||||
|
|
||||||
|
default PageResult<DistributionConfigRespVO> convertPage(PageResult<DistributionConfigDO> page,
|
||||||
|
List<MemberLevelRespDTO> levels
|
||||||
|
, List<ProductSpuRespDTO> spuList) {
|
||||||
|
PageResult<DistributionConfigRespVO> pageResult = convertPage(page);
|
||||||
|
Map<Long, String> levelMap = convertMap(levels, MemberLevelRespDTO::getId, MemberLevelRespDTO::getName);
|
||||||
|
// 拼接关联属性
|
||||||
|
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
||||||
|
// 拼接数据
|
||||||
|
pageResult.getList().forEach(record ->{
|
||||||
|
findAndThen(spuMap, record.getProductId(), spu -> {
|
||||||
|
record.setSupName(spu.getName());
|
||||||
|
});
|
||||||
|
MapUtils.findAndThen(levelMap, record.getLevelId(),
|
||||||
|
level -> record.setLevelName(levelMap.get(record.getLevelId())));
|
||||||
|
});
|
||||||
|
return pageResult;
|
||||||
|
}
|
||||||
|
PageResult<DistributionConfigRespVO> convertPage(PageResult<DistributionConfigDO> page);
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.convert.distributionlog;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.DistributionConfigRespVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.DistributionLogRespVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordRespVO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DistributionLogConvert {
|
||||||
|
DistributionLogConvert INSTANCE = Mappers.getMapper(DistributionLogConvert.class);
|
||||||
|
|
||||||
|
default PageResult<DistributionLogRespVO> convertPage(PageResult<DistributionLogDO> pageResult, List<MemberUserDO> users) {
|
||||||
|
PageResult<DistributionLogRespVO> voPageResult = convertPage(pageResult);
|
||||||
|
// user 拼接
|
||||||
|
Map<Long, MemberUserDO> userMap = convertMap(users, MemberUserDO::getId);
|
||||||
|
voPageResult.getList().forEach(record -> MapUtils.findAndThen(userMap, record.getMebId(),
|
||||||
|
memberUserRespDTO -> record.setNickname(memberUserRespDTO.getNickname()).setUserName(memberUserRespDTO.getName()).setPhone(memberUserRespDTO.getMobile())));
|
||||||
|
return voPageResult;
|
||||||
|
}
|
||||||
|
PageResult<DistributionLogRespVO> convertPage(PageResult<DistributionLogDO> page);
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.convert.distributionstatistics;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
|
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.DistributionConfigRespVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.DistributionLogRespVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.DistributionStatisticsRespVO;
|
||||||
|
import cn.iocoder.yudao.module.member.convert.distributionlog.DistributionLogConvert;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DistributionStatisticsConvert {
|
||||||
|
DistributionStatisticsConvert INSTANCE = Mappers.getMapper(DistributionStatisticsConvert.class);
|
||||||
|
|
||||||
|
default PageResult<DistributionStatisticsRespVO> convertPage(PageResult<DistributionStatisticsRespVO> pageResult, List<MemberUserDO> users,List<MemberLevelRespDTO> levels) {
|
||||||
|
PageResult<DistributionStatisticsRespVO> voPageResult = convertPage(pageResult);
|
||||||
|
// user 拼接
|
||||||
|
Map<Long, MemberUserDO> userMap = convertMap(users, MemberUserDO::getId);
|
||||||
|
Map<Long, String> levelMap = convertMap(levels, MemberLevelRespDTO::getId, MemberLevelRespDTO::getName);
|
||||||
|
voPageResult.getList().forEach(record -> {
|
||||||
|
MapUtils.findAndThen(userMap, record.getMebId(),
|
||||||
|
memberUserRespDTO -> record.setNickname(memberUserRespDTO.getNickname()).setUserName(memberUserRespDTO.getName()).setPhone(memberUserRespDTO.getMobile()));
|
||||||
|
MapUtils.findAndThen(levelMap, record.getLevelId(),
|
||||||
|
level -> record.setLevelName(levelMap.get(record.getLevelId())));
|
||||||
|
});
|
||||||
|
return voPageResult;
|
||||||
|
}
|
||||||
|
PageResult<DistributionStatisticsRespVO> convertPage(PageResult<DistributionStatisticsRespVO> page);
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销配置 DO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@TableName("member_distribution_config")
|
||||||
|
@KeySequence("member_distribution_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DistributionConfigDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id主键
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 分销商品id
|
||||||
|
*/
|
||||||
|
private Long productId;
|
||||||
|
/**
|
||||||
|
* 启用状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
|
* 购买人提升会员等级
|
||||||
|
*/
|
||||||
|
private Long levelId;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销配置关联会员等级 DO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@TableName("member_distribution_meb_config")
|
||||||
|
@KeySequence("member_distribution_meb_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DistributionMebConfigDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id主键
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 分销配置id
|
||||||
|
*/
|
||||||
|
private Long configId;
|
||||||
|
/**
|
||||||
|
* 会员等级
|
||||||
|
*/
|
||||||
|
private Long levelId;
|
||||||
|
/**
|
||||||
|
* 佣金
|
||||||
|
*/
|
||||||
|
private Integer brokerage;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.dataobject.distributionlog;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销记录 DO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@TableName("member_distribution_log")
|
||||||
|
@KeySequence("member_distribution_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DistributionLogDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id主键
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 推荐人id
|
||||||
|
*/
|
||||||
|
private Long referrerId;
|
||||||
|
/**
|
||||||
|
* 推荐人id(便于回溯)
|
||||||
|
*/
|
||||||
|
private Long oldReferrerId;
|
||||||
|
/**
|
||||||
|
* 购买人id
|
||||||
|
*/
|
||||||
|
private Long mebId;
|
||||||
|
/**
|
||||||
|
* 佣金
|
||||||
|
*/
|
||||||
|
private Integer brokerage;
|
||||||
|
/**
|
||||||
|
* 分佣结算核销状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
|
* 游戏状态
|
||||||
|
*/
|
||||||
|
private String gameStatus;
|
||||||
|
/**
|
||||||
|
* 游戏兑换状态
|
||||||
|
*/
|
||||||
|
private String convertStatus;
|
||||||
|
/**
|
||||||
|
* 推荐人会员等级id
|
||||||
|
*/
|
||||||
|
private Long levelId;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销统计 DO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@TableName("member_distribution_statistics")
|
||||||
|
@KeySequence("member_distribution_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DistributionStatisticsDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id主键
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 会员等级id
|
||||||
|
*/
|
||||||
|
private Long levelId;
|
||||||
|
/**
|
||||||
|
* 会员id
|
||||||
|
*/
|
||||||
|
private Long mebId;
|
||||||
|
/**
|
||||||
|
* 推荐记录id
|
||||||
|
*/
|
||||||
|
private Long logId;
|
||||||
|
/**
|
||||||
|
* 推荐人id
|
||||||
|
*/
|
||||||
|
private Long referrerId;
|
||||||
|
/**
|
||||||
|
* 分佣结算核销状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.mysql.distributionconfig;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销配置 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DistributionConfigMapper extends BaseMapperX<DistributionConfigDO> {
|
||||||
|
|
||||||
|
default PageResult<DistributionConfigDO> selectPage(DistributionConfigPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<DistributionConfigDO>()
|
||||||
|
.eqIfPresent(DistributionConfigDO::getProductId, reqVO.getProductId())
|
||||||
|
.eqIfPresent(DistributionConfigDO::getStatus, reqVO.getStatus())
|
||||||
|
.betweenIfPresent(DistributionConfigDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(DistributionConfigDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.mysql.distributionconfig;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销配置关联会员等级 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DistributionMebConfigMapper extends BaseMapperX<DistributionMebConfigDO> {
|
||||||
|
|
||||||
|
default List<DistributionMebConfigDO> selectListByConfigId(Long configId) {
|
||||||
|
return selectList(DistributionMebConfigDO::getConfigId, configId);
|
||||||
|
}
|
||||||
|
|
||||||
|
default int deleteByConfigId(Long configId) {
|
||||||
|
return delete(DistributionMebConfigDO::getConfigId, configId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.mysql.distributionlog;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销记录 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DistributionLogMapper extends BaseMapperX<DistributionLogDO> {
|
||||||
|
|
||||||
|
default PageResult<DistributionLogDO> selectPage(DistributionLogPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<DistributionLogDO>()
|
||||||
|
.eqIfPresent(DistributionLogDO::getReferrerId, reqVO.getReferrerId())
|
||||||
|
.eqIfPresent(DistributionLogDO::getOldReferrerId, reqVO.getOldReferrerId())
|
||||||
|
.eqIfPresent(DistributionLogDO::getMebId, reqVO.getMebId())
|
||||||
|
.eqIfPresent(DistributionLogDO::getBrokerage, reqVO.getBrokerage())
|
||||||
|
.eqIfPresent(DistributionLogDO::getStatus, reqVO.getStatus())
|
||||||
|
.eqIfPresent(DistributionLogDO::getGameStatus, reqVO.getGameStatus())
|
||||||
|
.eqIfPresent(DistributionLogDO::getConvertStatus, reqVO.getConvertStatus())
|
||||||
|
.eqIfPresent(DistributionLogDO::getLevelId, reqVO.getLevelId())
|
||||||
|
.betweenIfPresent(DistributionLogDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(DistributionLogDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.mysql.distributionstatistics;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销统计 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DistributionStatisticsMapper extends BaseMapperX<DistributionStatisticsDO> {
|
||||||
|
|
||||||
|
default PageResult<DistributionStatisticsDO> selectPage(DistributionStatisticsPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<DistributionStatisticsDO>()
|
||||||
|
.eqIfPresent(DistributionStatisticsDO::getLevelId, reqVO.getLevelId())
|
||||||
|
.eqIfPresent(DistributionStatisticsDO::getMebId, reqVO.getMebId())
|
||||||
|
.eqIfPresent(DistributionStatisticsDO::getLogId, reqVO.getLogId())
|
||||||
|
.eqIfPresent(DistributionStatisticsDO::getReferrerId, reqVO.getReferrerId())
|
||||||
|
.eqIfPresent(DistributionStatisticsDO::getStatus, reqVO.getStatus())
|
||||||
|
.betweenIfPresent(DistributionStatisticsDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(DistributionStatisticsDO::getId));
|
||||||
|
}
|
||||||
|
@Select({"<script>",
|
||||||
|
"SELECT\n" +
|
||||||
|
"\ts.meb_id,\n" +
|
||||||
|
"\ts.level_id,\n" +
|
||||||
|
"\tsum( CASE WHEN s.STATUS = 0 THEN 1 ELSE 0 END ) AS 'have_already',\n" +
|
||||||
|
"\tsum( CASE WHEN s.STATUS = 1 THEN 1 ELSE 0 END ) AS 'un_already' \n" +
|
||||||
|
"FROM\n" +
|
||||||
|
"\tmember_distribution_statistics s",
|
||||||
|
"where s.deleted = FALSE ",
|
||||||
|
"<if test='status !=null and status!=\"\" '>" ,
|
||||||
|
" and s.status = #{status}" ,
|
||||||
|
"</if> ",
|
||||||
|
"GROUP BY\n" +
|
||||||
|
"\ts.meb_id,\n" +
|
||||||
|
"\ts.level_id",
|
||||||
|
"order BY\n" +
|
||||||
|
"\ts.meb_id,\n" +
|
||||||
|
"\ts.level_id",
|
||||||
|
"</script>"})
|
||||||
|
IPage<DistributionStatisticsRespVO> selectPage1(IPage<?> page, @Param("status") String status);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.distributionconfig;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销配置 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface DistributionConfigService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建分销配置
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createDistributionConfig(@Valid DistributionConfigSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新分销配置
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateDistributionConfig(@Valid DistributionConfigSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除分销配置
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteDistributionConfig(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得分销配置
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 分销配置
|
||||||
|
*/
|
||||||
|
DistributionConfigDO getDistributionConfig(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得分销配置分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 分销配置分页
|
||||||
|
*/
|
||||||
|
PageResult<DistributionConfigDO> getDistributionConfigPage(DistributionConfigPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
// ==================== 子表(分销配置关联会员等级) ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得分销配置关联会员等级列表
|
||||||
|
*
|
||||||
|
* @param configId 分销配置id
|
||||||
|
* @return 分销配置关联会员等级列表
|
||||||
|
*/
|
||||||
|
List<DistributionMebConfigDO> getDistributionMebConfigListByConfigId(Long configId);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.distributionlog;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销记录 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface DistributionLogService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建分销记录
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createDistributionLog(@Valid DistributionLogSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新分销记录
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateDistributionLog(@Valid DistributionLogSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除分销记录
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteDistributionLog(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得分销记录
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 分销记录
|
||||||
|
*/
|
||||||
|
DistributionLogDO getDistributionLog(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得分销记录分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 分销记录分页
|
||||||
|
*/
|
||||||
|
PageResult<DistributionLogDO> getDistributionLogPage(DistributionLogPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.distributionlog;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.distributionlog.DistributionLogMapper;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销记录 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class DistributionLogServiceImpl implements DistributionLogService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DistributionLogMapper distributionLogMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createDistributionLog(DistributionLogSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
DistributionLogDO distributionLog = BeanUtils.toBean(createReqVO, DistributionLogDO.class);
|
||||||
|
distributionLogMapper.insert(distributionLog);
|
||||||
|
// 返回
|
||||||
|
return distributionLog.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDistributionLog(DistributionLogSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateDistributionLogExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
DistributionLogDO updateObj = BeanUtils.toBean(updateReqVO, DistributionLogDO.class);
|
||||||
|
distributionLogMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDistributionLog(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateDistributionLogExists(id);
|
||||||
|
// 删除
|
||||||
|
distributionLogMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateDistributionLogExists(Long id) {
|
||||||
|
if (distributionLogMapper.selectById(id) == null) {
|
||||||
|
throw exception(DISTRIBUTION_LOG_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DistributionLogDO getDistributionLog(Long id) {
|
||||||
|
return distributionLogMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<DistributionLogDO> getDistributionLogPage(DistributionLogPageReqVO pageReqVO) {
|
||||||
|
return distributionLogMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.distributionstatistics;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销统计 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface DistributionStatisticsService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建分销统计
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createDistributionStatistics(@Valid DistributionStatisticsSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新分销统计
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateDistributionStatistics(@Valid DistributionStatisticsSaveReqVO updateReqVO);
|
||||||
|
/**
|
||||||
|
* 更新分销统计
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateAlready(@Valid DistributionStatisticsSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除分销统计
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteDistributionStatistics(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得分销统计
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 分销统计
|
||||||
|
*/
|
||||||
|
DistributionStatisticsDO getDistributionStatistics(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得分销统计分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 分销统计分页
|
||||||
|
*/
|
||||||
|
PageResult<DistributionStatisticsDO> getDistributionStatisticsPage(DistributionStatisticsPageReqVO pageReqVO);
|
||||||
|
/**
|
||||||
|
* 获得分销统计分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 分销统计分页
|
||||||
|
*/
|
||||||
|
PageResult<DistributionStatisticsRespVO> getDistributionStatisticsPage1(DistributionStatisticsPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.distributionstatistics;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||||
|
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.distributionstatistics.DistributionStatisticsMapper;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销统计 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class DistributionStatisticsServiceImpl implements DistributionStatisticsService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DistributionStatisticsMapper distributionStatisticsMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createDistributionStatistics(DistributionStatisticsSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
DistributionStatisticsDO distributionStatistics = BeanUtils.toBean(createReqVO, DistributionStatisticsDO.class);
|
||||||
|
distributionStatisticsMapper.insert(distributionStatistics);
|
||||||
|
// 返回
|
||||||
|
return distributionStatistics.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDistributionStatistics(DistributionStatisticsSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateDistributionStatisticsExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
DistributionStatisticsDO updateObj = BeanUtils.toBean(updateReqVO, DistributionStatisticsDO.class);
|
||||||
|
distributionStatisticsMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAlready(DistributionStatisticsSaveReqVO updateReqVO) {
|
||||||
|
// 结算
|
||||||
|
distributionStatisticsMapper.update(new UpdateWrapper<DistributionStatisticsDO>().lambda().set(DistributionStatisticsDO::getStatus,0).eq(DistributionStatisticsDO::getMebId,updateReqVO.getMebId()).eq(DistributionStatisticsDO::getLevelId,updateReqVO.getLevelId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDistributionStatistics(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateDistributionStatisticsExists(id);
|
||||||
|
// 删除
|
||||||
|
distributionStatisticsMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateDistributionStatisticsExists(Long id) {
|
||||||
|
if (distributionStatisticsMapper.selectById(id) == null) {
|
||||||
|
throw exception(DISTRIBUTION_STATISTICS_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DistributionStatisticsDO getDistributionStatistics(Long id) {
|
||||||
|
return distributionStatisticsMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<DistributionStatisticsDO> getDistributionStatisticsPage(DistributionStatisticsPageReqVO pageReqVO) {
|
||||||
|
return distributionStatisticsMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<DistributionStatisticsRespVO> getDistributionStatisticsPage1(DistributionStatisticsPageReqVO pageReqVO) {
|
||||||
|
IPage<DistributionStatisticsRespVO> pageResult = distributionStatisticsMapper.selectPage1(
|
||||||
|
MyBatisUtils.buildPage(pageReqVO),
|
||||||
|
pageReqVO.getStatus());
|
||||||
|
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
|
||||||
|
// return distributionStatisticsMapper.selectPage1(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,138 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.distributionconfig;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.distributionconfig.DistributionConfigMapper;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.hutool.core.util.RandomUtil.*;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DistributionConfigServiceImpl} 的单元测试类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Import(DistributionConfigServiceImpl.class)
|
||||||
|
public class DistributionConfigServiceImplTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DistributionConfigServiceImpl distributionConfigService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DistributionConfigMapper distributionConfigMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateDistributionConfig_success() {
|
||||||
|
// 准备参数
|
||||||
|
DistributionConfigSaveReqVO createReqVO = randomPojo(DistributionConfigSaveReqVO.class).setId(null);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
Long distributionConfigId = distributionConfigService.createDistributionConfig(createReqVO);
|
||||||
|
// 断言
|
||||||
|
assertNotNull(distributionConfigId);
|
||||||
|
// 校验记录的属性是否正确
|
||||||
|
DistributionConfigDO distributionConfig = distributionConfigMapper.selectById(distributionConfigId);
|
||||||
|
assertPojoEquals(createReqVO, distributionConfig, "id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateDistributionConfig_success() {
|
||||||
|
// mock 数据
|
||||||
|
DistributionConfigDO dbDistributionConfig = randomPojo(DistributionConfigDO.class);
|
||||||
|
distributionConfigMapper.insert(dbDistributionConfig);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
DistributionConfigSaveReqVO updateReqVO = randomPojo(DistributionConfigSaveReqVO.class, o -> {
|
||||||
|
o.setId(dbDistributionConfig.getId()); // 设置更新的 ID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
distributionConfigService.updateDistributionConfig(updateReqVO);
|
||||||
|
// 校验是否更新正确
|
||||||
|
DistributionConfigDO distributionConfig = distributionConfigMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||||
|
assertPojoEquals(updateReqVO, distributionConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateDistributionConfig_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
DistributionConfigSaveReqVO updateReqVO = randomPojo(DistributionConfigSaveReqVO.class);
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> distributionConfigService.updateDistributionConfig(updateReqVO), DISTRIBUTION_CONFIG_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteDistributionConfig_success() {
|
||||||
|
// mock 数据
|
||||||
|
DistributionConfigDO dbDistributionConfig = randomPojo(DistributionConfigDO.class);
|
||||||
|
distributionConfigMapper.insert(dbDistributionConfig);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
Long id = dbDistributionConfig.getId();
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
distributionConfigService.deleteDistributionConfig(id);
|
||||||
|
// 校验数据不存在了
|
||||||
|
assertNull(distributionConfigMapper.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteDistributionConfig_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
Long id = randomLongId();
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> distributionConfigService.deleteDistributionConfig(id), DISTRIBUTION_CONFIG_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetDistributionConfigPage() {
|
||||||
|
// mock 数据
|
||||||
|
DistributionConfigDO dbDistributionConfig = randomPojo(DistributionConfigDO.class, o -> { // 等会查询到
|
||||||
|
o.setProductId(null);
|
||||||
|
o.setStatus(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
});
|
||||||
|
distributionConfigMapper.insert(dbDistributionConfig);
|
||||||
|
// 测试 productId 不匹配
|
||||||
|
distributionConfigMapper.insert(cloneIgnoreId(dbDistributionConfig, o -> o.setProductId(null)));
|
||||||
|
// 测试 status 不匹配
|
||||||
|
distributionConfigMapper.insert(cloneIgnoreId(dbDistributionConfig, o -> o.setStatus(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
distributionConfigMapper.insert(cloneIgnoreId(dbDistributionConfig, o -> o.setCreateTime(null)));
|
||||||
|
// 准备参数
|
||||||
|
DistributionConfigPageReqVO reqVO = new DistributionConfigPageReqVO();
|
||||||
|
reqVO.setProductId(null);
|
||||||
|
reqVO.setStatus(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
PageResult<DistributionConfigDO> pageResult = distributionConfigService.getDistributionConfigPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbDistributionConfig, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,162 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.distributionlog;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.distributionlog.DistributionLogMapper;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.hutool.core.util.RandomUtil.*;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DistributionLogServiceImpl} 的单元测试类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Import(DistributionLogServiceImpl.class)
|
||||||
|
public class DistributionLogServiceImplTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DistributionLogServiceImpl distributionLogService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DistributionLogMapper distributionLogMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateDistributionLog_success() {
|
||||||
|
// 准备参数
|
||||||
|
DistributionLogSaveReqVO createReqVO = randomPojo(DistributionLogSaveReqVO.class).setId(null);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
Long distributionLogId = distributionLogService.createDistributionLog(createReqVO);
|
||||||
|
// 断言
|
||||||
|
assertNotNull(distributionLogId);
|
||||||
|
// 校验记录的属性是否正确
|
||||||
|
DistributionLogDO distributionLog = distributionLogMapper.selectById(distributionLogId);
|
||||||
|
assertPojoEquals(createReqVO, distributionLog, "id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateDistributionLog_success() {
|
||||||
|
// mock 数据
|
||||||
|
DistributionLogDO dbDistributionLog = randomPojo(DistributionLogDO.class);
|
||||||
|
distributionLogMapper.insert(dbDistributionLog);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
DistributionLogSaveReqVO updateReqVO = randomPojo(DistributionLogSaveReqVO.class, o -> {
|
||||||
|
o.setId(dbDistributionLog.getId()); // 设置更新的 ID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
distributionLogService.updateDistributionLog(updateReqVO);
|
||||||
|
// 校验是否更新正确
|
||||||
|
DistributionLogDO distributionLog = distributionLogMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||||
|
assertPojoEquals(updateReqVO, distributionLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateDistributionLog_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
DistributionLogSaveReqVO updateReqVO = randomPojo(DistributionLogSaveReqVO.class);
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> distributionLogService.updateDistributionLog(updateReqVO), DISTRIBUTION_LOG_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteDistributionLog_success() {
|
||||||
|
// mock 数据
|
||||||
|
DistributionLogDO dbDistributionLog = randomPojo(DistributionLogDO.class);
|
||||||
|
distributionLogMapper.insert(dbDistributionLog);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
Long id = dbDistributionLog.getId();
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
distributionLogService.deleteDistributionLog(id);
|
||||||
|
// 校验数据不存在了
|
||||||
|
assertNull(distributionLogMapper.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteDistributionLog_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
Long id = randomLongId();
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> distributionLogService.deleteDistributionLog(id), DISTRIBUTION_LOG_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetDistributionLogPage() {
|
||||||
|
// mock 数据
|
||||||
|
DistributionLogDO dbDistributionLog = randomPojo(DistributionLogDO.class, o -> { // 等会查询到
|
||||||
|
o.setReferrerId(null);
|
||||||
|
o.setOldReferrerId(null);
|
||||||
|
o.setMebId(null);
|
||||||
|
o.setBrokerage(null);
|
||||||
|
o.setStatus(null);
|
||||||
|
o.setGameStatus(null);
|
||||||
|
o.setConvertStatus(null);
|
||||||
|
o.setLevelId(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
});
|
||||||
|
distributionLogMapper.insert(dbDistributionLog);
|
||||||
|
// 测试 referrerId 不匹配
|
||||||
|
distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setReferrerId(null)));
|
||||||
|
// 测试 oldReferrerId 不匹配
|
||||||
|
distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setOldReferrerId(null)));
|
||||||
|
// 测试 mebId 不匹配
|
||||||
|
distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setMebId(null)));
|
||||||
|
// 测试 brokerage 不匹配
|
||||||
|
distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setBrokerage(null)));
|
||||||
|
// 测试 status 不匹配
|
||||||
|
distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setStatus(null)));
|
||||||
|
// 测试 gameStatus 不匹配
|
||||||
|
distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setGameStatus(null)));
|
||||||
|
// 测试 convertStatus 不匹配
|
||||||
|
distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setConvertStatus(null)));
|
||||||
|
// 测试 levelId 不匹配
|
||||||
|
distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setLevelId(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setCreateTime(null)));
|
||||||
|
// 准备参数
|
||||||
|
DistributionLogPageReqVO reqVO = new DistributionLogPageReqVO();
|
||||||
|
reqVO.setReferrerId(null);
|
||||||
|
reqVO.setOldReferrerId(null);
|
||||||
|
reqVO.setMebId(null);
|
||||||
|
reqVO.setBrokerage(null);
|
||||||
|
reqVO.setStatus(null);
|
||||||
|
reqVO.setGameStatus(null);
|
||||||
|
reqVO.setConvertStatus(null);
|
||||||
|
reqVO.setLevelId(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
PageResult<DistributionLogDO> pageResult = distributionLogService.getDistributionLogPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbDistributionLog, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,150 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.distributionstatistics;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.distributionstatistics.DistributionStatisticsMapper;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.hutool.core.util.RandomUtil.*;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DistributionStatisticsServiceImpl} 的单元测试类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Import(DistributionStatisticsServiceImpl.class)
|
||||||
|
public class DistributionStatisticsServiceImplTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DistributionStatisticsServiceImpl distributionStatisticsService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DistributionStatisticsMapper distributionStatisticsMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateDistributionStatistics_success() {
|
||||||
|
// 准备参数
|
||||||
|
DistributionStatisticsSaveReqVO createReqVO = randomPojo(DistributionStatisticsSaveReqVO.class).setId(null);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
Long distributionStatisticsId = distributionStatisticsService.createDistributionStatistics(createReqVO);
|
||||||
|
// 断言
|
||||||
|
assertNotNull(distributionStatisticsId);
|
||||||
|
// 校验记录的属性是否正确
|
||||||
|
DistributionStatisticsDO distributionStatistics = distributionStatisticsMapper.selectById(distributionStatisticsId);
|
||||||
|
assertPojoEquals(createReqVO, distributionStatistics, "id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateDistributionStatistics_success() {
|
||||||
|
// mock 数据
|
||||||
|
DistributionStatisticsDO dbDistributionStatistics = randomPojo(DistributionStatisticsDO.class);
|
||||||
|
distributionStatisticsMapper.insert(dbDistributionStatistics);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
DistributionStatisticsSaveReqVO updateReqVO = randomPojo(DistributionStatisticsSaveReqVO.class, o -> {
|
||||||
|
o.setId(dbDistributionStatistics.getId()); // 设置更新的 ID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
distributionStatisticsService.updateDistributionStatistics(updateReqVO);
|
||||||
|
// 校验是否更新正确
|
||||||
|
DistributionStatisticsDO distributionStatistics = distributionStatisticsMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||||
|
assertPojoEquals(updateReqVO, distributionStatistics);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateDistributionStatistics_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
DistributionStatisticsSaveReqVO updateReqVO = randomPojo(DistributionStatisticsSaveReqVO.class);
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> distributionStatisticsService.updateDistributionStatistics(updateReqVO), DISTRIBUTION_STATISTICS_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteDistributionStatistics_success() {
|
||||||
|
// mock 数据
|
||||||
|
DistributionStatisticsDO dbDistributionStatistics = randomPojo(DistributionStatisticsDO.class);
|
||||||
|
distributionStatisticsMapper.insert(dbDistributionStatistics);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
Long id = dbDistributionStatistics.getId();
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
distributionStatisticsService.deleteDistributionStatistics(id);
|
||||||
|
// 校验数据不存在了
|
||||||
|
assertNull(distributionStatisticsMapper.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteDistributionStatistics_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
Long id = randomLongId();
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> distributionStatisticsService.deleteDistributionStatistics(id), DISTRIBUTION_STATISTICS_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetDistributionStatisticsPage() {
|
||||||
|
// mock 数据
|
||||||
|
DistributionStatisticsDO dbDistributionStatistics = randomPojo(DistributionStatisticsDO.class, o -> { // 等会查询到
|
||||||
|
o.setLevelId(null);
|
||||||
|
o.setMebId(null);
|
||||||
|
o.setLogId(null);
|
||||||
|
o.setReferrerId(null);
|
||||||
|
o.setStatus(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
});
|
||||||
|
distributionStatisticsMapper.insert(dbDistributionStatistics);
|
||||||
|
// 测试 levelId 不匹配
|
||||||
|
distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setLevelId(null)));
|
||||||
|
// 测试 mebId 不匹配
|
||||||
|
distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setMebId(null)));
|
||||||
|
// 测试 logId 不匹配
|
||||||
|
distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setLogId(null)));
|
||||||
|
// 测试 referrerId 不匹配
|
||||||
|
distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setReferrerId(null)));
|
||||||
|
// 测试 status 不匹配
|
||||||
|
distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setStatus(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setCreateTime(null)));
|
||||||
|
// 准备参数
|
||||||
|
DistributionStatisticsPageReqVO reqVO = new DistributionStatisticsPageReqVO();
|
||||||
|
reqVO.setLevelId(null);
|
||||||
|
reqVO.setMebId(null);
|
||||||
|
reqVO.setLogId(null);
|
||||||
|
reqVO.setReferrerId(null);
|
||||||
|
reqVO.setStatus(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
PageResult<DistributionStatisticsDO> pageResult = distributionStatisticsService.getDistributionStatisticsPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbDistributionStatistics, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1 +1,2 @@
|
|||||||
SHOPRO_DEV_BASE_URL = http://192.168.0.135:48080
|
# SHOPRO_DEV_BASE_URL = https://yanghaodong.51vip.biz
|
||||||
|
SHOPRO_DEV_BASE_URL = http://192.168.1.118:48080
|
@ -0,0 +1,39 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
|
||||||
|
<s-layout class="set-wrap" title="抽奖规则" :bgStyle="{ color: '#FFF' }">
|
||||||
|
<!-- <view class="ss-p-30">
|
||||||
|
<mp-html class="richtext" :content="state.content" />
|
||||||
|
</view> -->
|
||||||
|
|
||||||
|
|
||||||
|
<rich-text :nodes="data"></rich-text>
|
||||||
|
</s-layout>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import MineApi from '@/sheep/api/prize/index'
|
||||||
|
import { onLoad, onReachBottom, onShow, onUnload, onHide } from '@dcloudio/uni-app';
|
||||||
|
|
||||||
|
const data = ref()
|
||||||
|
|
||||||
|
const getActivityRules = async () => {
|
||||||
|
const res = await MineApi.ActivityRules()
|
||||||
|
data.value = res.data.name
|
||||||
|
// data.value = res.data.value = res.result.content.replace(
|
||||||
|
// /<img(.*?)\s*width=".*?"\s*height=".*?"\s*\/?>/g,
|
||||||
|
// '<img$1 style="max-width: 100%;" />'
|
||||||
|
// )
|
||||||
|
// data.value = data.value.replace(/style="display: block; margin-left: auto; margin-right: auto;"/g, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
getActivityRules()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue