游戏接口调整
This commit is contained in:
@@ -46,6 +46,7 @@ public interface GameErrorCodeConstants {
|
||||
ErrorCode GAME_USER_BEEHIVE_NOT_EXISTS = new ErrorCode(2_001_110_013, "用户蜂箱不存在");
|
||||
|
||||
ErrorCode GAME_USER_PROPS_NOT_EXISTS = new ErrorCode(2_001_110_014, "用户道具不存在");
|
||||
ErrorCode NO_HAVE_PROPS = new ErrorCode(2_001_110_014, "道具不足");
|
||||
ErrorCode NO_HAVE_PROPS = new ErrorCode(2_001_110_114, "道具不足");
|
||||
ErrorCode USE_LIMITED = new ErrorCode(2_001_110_214, "今日该道具已使用上限");
|
||||
|
||||
}
|
||||
|
@@ -11,7 +11,8 @@ import java.util.Arrays;
|
||||
public enum TaskType implements ArrayValuable<Integer> {
|
||||
LOGIN(1, "登录"),
|
||||
PURCHASE(2, "购买"),
|
||||
SHARE(3, "分享");
|
||||
SHARE(3, "分享"),
|
||||
USE_PROPS(4, "使用道具");
|
||||
|
||||
|
||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(TaskType::getType).toArray(Integer[]::new);
|
||||
|
@@ -24,7 +24,7 @@ public class GameTaskRespVO {
|
||||
@ExcelProperty("任务编码")
|
||||
private String taskCode;
|
||||
|
||||
@Schema(description = "任务类型 1登录2购买3分享", example = "2")
|
||||
@Schema(description = "任务类型 1登录2购买3分享4使用道具", example = "2")
|
||||
@ExcelProperty("任务类型")
|
||||
private Integer taskType;
|
||||
|
||||
|
@@ -1,9 +1,7 @@
|
||||
package cn.iocoder.yudao.bee.front.controller.admin.game.gametask.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
|
||||
@Schema(description = "管理后台 - 养蜂游戏每日任务新增/修改 Request VO")
|
||||
@Data
|
||||
|
@@ -66,8 +66,8 @@ public class AppGameIndexController {
|
||||
@GetMapping("/get/strategy")
|
||||
@Operation(summary = "获取丰收攻略")
|
||||
@PermitAll
|
||||
public CommonResult<List<GameStrategyRespVO>> getStrategy() {
|
||||
return success(BeanUtils.toBean(gameStrategyService.getGameStrategyList(),GameStrategyRespVO.class));
|
||||
public CommonResult<List<AppGameStrategyRespVO>> getStrategy() {
|
||||
return success(gameStrategyService.getAppGameStrategyList());
|
||||
}
|
||||
|
||||
@GetMapping("/get/redemption/records")
|
||||
@@ -95,8 +95,8 @@ public class AppGameIndexController {
|
||||
@Operation(summary = "获取蜂场公告详情")
|
||||
@Parameter(name = "id", description = "公告编号", required = true, example = "1024")
|
||||
@PermitAll
|
||||
public CommonResult<GameAnnouncementRespVO> getBeeFarmAnnouncement(@RequestParam("id")Integer id) {
|
||||
return success(BeanUtils.toBean(gameAnnouncementService.getGameAnnouncement(id),GameAnnouncementRespVO.class));
|
||||
public CommonResult<AppGameAnnouncementRespVO> getBeeFarmAnnouncement(@RequestParam("id")Integer id) {
|
||||
return success(gameAnnouncementService.getAppGameAnnouncement(id));
|
||||
}
|
||||
|
||||
@GetMapping("/get/userList")
|
||||
@@ -156,9 +156,8 @@ public class AppGameIndexController {
|
||||
@GetMapping("/harvest/beehive")
|
||||
@Operation(summary = "收获蜂箱")
|
||||
@Parameter(name = "id", description = "蜂箱编号", required = true, example = "1024")
|
||||
public CommonResult<Boolean> harvestBeehive(@RequestParam("id")Integer id){
|
||||
gameBeehiveService.harvestBeehive(id);
|
||||
return success(true);
|
||||
public CommonResult<GameHarvestRespVO> harvestBeehive(@RequestParam("id")Integer id){
|
||||
return success(gameBeehiveService.harvestBeehive(id));
|
||||
}
|
||||
|
||||
@GetMapping("/fed/bee")
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.bee.front.controller.app.game.dto;
|
||||
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gameannouncement.vo.GameAnnouncementRespVO;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AppGameAnnouncementRespVO extends GameAnnouncementRespVO {
|
||||
|
||||
@Schema(description = "公告图片")
|
||||
@ExcelProperty("公告图片")
|
||||
private List<String> imgUrls;
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.bee.front.controller.app.game.dto;
|
||||
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gamestrategy.vo.GameStrategyRespVO;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AppGameStrategyRespVO extends GameStrategyRespVO {
|
||||
|
||||
@Schema(description = "攻略图片")
|
||||
@ExcelProperty("攻略图片")
|
||||
private List<String> imgUrls;
|
||||
}
|
@@ -50,6 +50,7 @@ import cn.iocoder.yudao.bee.front.service.commissionrecords.CommissionRecordsSer
|
||||
import cn.iocoder.yudao.bee.front.service.coupons.CouponsService;
|
||||
import cn.iocoder.yudao.bee.front.service.distribution.DistributionService;
|
||||
import cn.iocoder.yudao.bee.front.service.flow.FlowOrderService;
|
||||
import cn.iocoder.yudao.bee.front.service.game.DailyTaskService;
|
||||
import cn.iocoder.yudao.bee.front.service.honeyproduct.HoneyProductService;
|
||||
import cn.iocoder.yudao.bee.front.service.product.ProductService;
|
||||
import cn.iocoder.yudao.bee.front.util.AssertUtils;
|
||||
@@ -167,6 +168,9 @@ public class BeeOrderServiceImpl implements BeeOrderService {
|
||||
@Resource
|
||||
private BeeOrderItemMapper beeOrderItemMapper;
|
||||
|
||||
@Resource
|
||||
private DailyTaskService dailyTaskService;
|
||||
|
||||
@Override
|
||||
public Integer createOrder(BeeOrderSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@@ -500,6 +504,7 @@ public class BeeOrderServiceImpl implements BeeOrderService {
|
||||
createCommissionRecords(user,BeanUtils.toBean(order,BeeOrderSaveReqVO.class), CommissionTypeEnum.DISTRIBUTION_OF_PRODUCTS.getType());
|
||||
//累计分销订单量增加
|
||||
set2LevelDistributionOrderCount(order.getUserId());
|
||||
dailyTaskService.handleUserPurchase(order.getUserId());
|
||||
}
|
||||
|
||||
private void payFlowOrder(Long payOrderId) {
|
||||
|
@@ -3,11 +3,11 @@ package cn.iocoder.yudao.bee.front.service.game;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.bee.front.dal.dataobject.game.GameTaskDO;
|
||||
import cn.iocoder.yudao.bee.front.dal.dataobject.game.GameTaskRecordsDO;
|
||||
import cn.iocoder.yudao.bee.front.dal.dataobject.game.GameUserDO;
|
||||
import cn.iocoder.yudao.bee.front.dal.mysql.game.GameTaskMapper;
|
||||
import cn.iocoder.yudao.bee.front.dal.mysql.game.GameTaskRecordsMapper;
|
||||
import cn.iocoder.yudao.bee.front.enums.game.GameTaskStatusEnum;
|
||||
import cn.iocoder.yudao.bee.front.enums.game.TaskType;
|
||||
import cn.iocoder.yudao.bee.front.service.beehive.BeehiveServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -25,12 +25,15 @@ public class DailyTaskService {
|
||||
@Resource
|
||||
private GameTaskRecordsMapper userTaskMapper;
|
||||
|
||||
@Resource
|
||||
private GameUserService gameUserService;
|
||||
|
||||
|
||||
/**
|
||||
* 用户登录时调用
|
||||
*/
|
||||
public void handleUserLogin(Integer userId) {
|
||||
getSelf().updateTaskProgress(userId, TaskType.LOGIN);
|
||||
public boolean handleUserLogin(Integer userId) {
|
||||
return getSelf().updateTaskProgress(userId, TaskType.LOGIN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,11 +50,22 @@ public class DailyTaskService {
|
||||
getSelf().updateTaskProgress(userId, TaskType.SHARE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户使用道具调用
|
||||
*/
|
||||
public void handleUseProps(Integer userId) {
|
||||
getSelf().updateTaskProgress(userId, TaskType.USE_PROPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务进度
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTaskProgress(Integer userId, TaskType taskType) {
|
||||
public boolean updateTaskProgress(Integer userId, TaskType taskType) {
|
||||
GameUserDO gameUserDO = gameUserService.getGameUserByUserId(userId);
|
||||
//用户未使用过小游戏
|
||||
if (gameUserDO == null) return false;
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
|
||||
// 查询任务配置
|
||||
@@ -62,21 +76,21 @@ public class DailyTaskService {
|
||||
);
|
||||
|
||||
if (task == null) {
|
||||
return; // 任务不存在或已禁用
|
||||
return false; // 任务不存在或已禁用
|
||||
}
|
||||
|
||||
// 查询用户今日任务状态
|
||||
GameTaskRecordsDO userTask = userTaskMapper.selectOne(
|
||||
Wrappers.<GameTaskRecordsDO>lambdaQuery()
|
||||
.eq(GameTaskRecordsDO::getGameUserId, userId)
|
||||
.eq(GameTaskRecordsDO::getGameUserId, gameUserDO.getId())
|
||||
.eq(GameTaskRecordsDO::getTaskId, task.getId())
|
||||
.eq(GameTaskRecordsDO::getCreateTime, today.atStartOfDay())
|
||||
.between(GameTaskRecordsDO::getCreateTime, today.atStartOfDay(),today.plusDays(1).atStartOfDay())
|
||||
);
|
||||
|
||||
// 任务不存在则初始化
|
||||
if (userTask == null) {
|
||||
userTask = new GameTaskRecordsDO();
|
||||
userTask.setGameUserId(userId);
|
||||
userTask.setGameUserId(gameUserDO.getId());
|
||||
userTask.setTaskId(task.getId());
|
||||
userTask.setCreateTime(LocalDateTime.now());
|
||||
userTask.setProcess(1);
|
||||
@@ -87,8 +101,8 @@ public class DailyTaskService {
|
||||
userTaskMapper.insert(userTask);
|
||||
}
|
||||
// 任务已完成或已领取则不处理
|
||||
else if (userTask.getStatus() >= 2) {
|
||||
return;
|
||||
else if (userTask.getStatus() >= 1) {
|
||||
return false;
|
||||
}
|
||||
// 任务未完成则增加计数
|
||||
else {
|
||||
@@ -101,6 +115,7 @@ public class DailyTaskService {
|
||||
|
||||
userTaskMapper.updateById(userTask);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private DailyTaskService getSelf() {
|
||||
|
@@ -7,17 +7,14 @@ import cn.iocoder.yudao.bee.front.dal.dataobject.game.GameUserDO;
|
||||
import cn.iocoder.yudao.bee.front.dal.mysql.game.GameAccessRecordsMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
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;
|
||||
|
||||
|
||||
@@ -101,7 +98,7 @@ public class GameAccessRecordsServiceImpl implements GameAccessRecordsService {
|
||||
LambdaQueryWrapper<GameAccessRecordsDO> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(GameAccessRecordsDO::getUserId, userId)
|
||||
.eq(GameAccessRecordsDO::getPropsId, propsId)
|
||||
.between(GameAccessRecordsDO::getCreateTime, LocalDate.now().atStartOfDay(), LocalDateTime.now());
|
||||
.between(GameAccessRecordsDO::getCreateTime, LocalDate.now().atStartOfDay(), LocalDate.now().plusDays(1).atStartOfDay());
|
||||
Long count = gameAccessRecordsMapper.selectCount(queryWrapper);
|
||||
return count == null ? 0 : count;
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gameannouncement.vo.GameAnnouncementPageReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gameannouncement.vo.GameAnnouncementSaveReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.app.game.dto.AppGameAnnouncementRespVO;
|
||||
import cn.iocoder.yudao.bee.front.dal.dataobject.game.GameAnnouncementDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
@@ -56,4 +57,5 @@ public interface GameAnnouncementService {
|
||||
|
||||
List<GameAnnouncementDO> getGameAnnouncementList();
|
||||
|
||||
AppGameAnnouncementRespVO getAppGameAnnouncement(Integer id);
|
||||
}
|
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.bee.front.service.game;
|
||||
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gameannouncement.vo.GameAnnouncementPageReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gameannouncement.vo.GameAnnouncementSaveReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.app.game.dto.AppGameAnnouncementRespVO;
|
||||
import cn.iocoder.yudao.bee.front.dal.dataobject.game.GameAnnouncementDO;
|
||||
import cn.iocoder.yudao.bee.front.dal.mysql.game.GameAnnouncementMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -17,6 +18,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.bee.front.enums.GameErrorCodeConstants.GAME_ANNOUNCEMENT_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.bee.front.util.RichTextUtils.extractImageUrls;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
@@ -78,4 +80,18 @@ public class GameAnnouncementServiceImpl implements GameAnnouncementService {
|
||||
public List<GameAnnouncementDO> getGameAnnouncementList() {
|
||||
return gameAnnouncementMapper.selectList(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppGameAnnouncementRespVO getAppGameAnnouncement(Integer id) {
|
||||
GameAnnouncementDO gameAnnouncement = getGameAnnouncement(id);
|
||||
AppGameAnnouncementRespVO respVO = BeanUtils.toBean(gameAnnouncement, AppGameAnnouncementRespVO.class);
|
||||
if (gameAnnouncement != null) {
|
||||
List<String> imageUrls = extractImageUrls(gameAnnouncement.getContent());
|
||||
if (!imageUrls.isEmpty()) {
|
||||
respVO.setImgUrls(imageUrls);
|
||||
}
|
||||
return respVO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -3,7 +3,9 @@ package cn.iocoder.yudao.bee.front.service.game;
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gamebeehive.vo.GameBeehivePageReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gamebeehive.vo.GameBeehiveRespVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gamebeehive.vo.GameBeehiveSaveReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gameharvest.vo.GameHarvestRespVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.app.game.dto.GameBeehiveInfoDTO;
|
||||
import cn.iocoder.yudao.bee.front.dal.dataobject.game.GameBeehiveDO;
|
||||
import cn.iocoder.yudao.bee.front.controller.app.game.dto.LevelNeedDTO;
|
||||
@@ -69,7 +71,7 @@ public interface GameBeehiveService {
|
||||
void levelUp(Integer id);
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
void harvestBeehive(Integer id);
|
||||
GameHarvestRespVO harvestBeehive(Integer id);
|
||||
|
||||
List<GameBeehiveDO> getBeehiveList();
|
||||
}
|
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.bee.front.service.game;
|
||||
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gamebeehive.vo.GameBeehivePageReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gamebeehive.vo.GameBeehiveSaveReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gameharvest.vo.GameHarvestRespVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gameharvest.vo.GameHarvestSaveReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gameuser.vo.GameUserSaveReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gameuserbeehive.vo.GameUserBeehiveSaveReqVO;
|
||||
@@ -266,7 +267,7 @@ public class GameBeehiveServiceImpl implements GameBeehiveService {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void harvestBeehive(Integer id) {
|
||||
public GameHarvestRespVO harvestBeehive(Integer id) {
|
||||
Integer userId = gameUserService.getLoginGameUser().getId();
|
||||
GameUserBeehiveDO gameUserBeehiveDO = gameUserBeehiveService.getGameUserBeehiveByBeehiveId(id,userId);
|
||||
AssertUtils.notNull(gameUserBeehiveDO,GAME_BEEHIVE_NOT_EXISTS);
|
||||
@@ -302,9 +303,12 @@ public class GameBeehiveServiceImpl implements GameBeehiveService {
|
||||
default:throw exception(LEVEL_NOT_ENOUGH);
|
||||
}
|
||||
//创建收获信息
|
||||
gameHarvestService.createGameHarvest(harvestSaveReqVO);
|
||||
Integer harvestId = gameHarvestService.createGameHarvest(harvestSaveReqVO);
|
||||
//收获后清理蜂箱数据
|
||||
gameUserBeehiveService.deleteGameUserBeehive(gameUserBeehiveDO.getId());
|
||||
GameHarvestRespVO bean = BeanUtils.toBean(harvestSaveReqVO, GameHarvestRespVO.class);
|
||||
bean.setId(harvestId).setCreateTime(LocalDateTime.now());
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -4,6 +4,7 @@ import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gamestrategy.vo.GameStrategyPageReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gamestrategy.vo.GameStrategySaveReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.app.game.dto.AppGameStrategyRespVO;
|
||||
import cn.iocoder.yudao.bee.front.dal.dataobject.game.GameStrategyDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
@@ -55,4 +56,6 @@ public interface GameStrategyService {
|
||||
PageResult<GameStrategyDO> getGameStrategyPage(GameStrategyPageReqVO pageReqVO);
|
||||
|
||||
List<GameStrategyDO> getGameStrategyList();
|
||||
|
||||
List<AppGameStrategyRespVO> getAppGameStrategyList();
|
||||
}
|
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.bee.front.service.game;
|
||||
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gamestrategy.vo.GameStrategyPageReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.admin.game.gamestrategy.vo.GameStrategySaveReqVO;
|
||||
import cn.iocoder.yudao.bee.front.controller.app.game.dto.AppGameStrategyRespVO;
|
||||
import cn.iocoder.yudao.bee.front.dal.dataobject.game.GameStrategyDO;
|
||||
import cn.iocoder.yudao.bee.front.dal.mysql.game.GameStrategyMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -17,6 +18,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.bee.front.enums.GameErrorCodeConstants.GAME_STRATEGY_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.bee.front.util.RichTextUtils.extractImageUrls;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
@@ -78,4 +80,20 @@ public class GameStrategyServiceImpl implements GameStrategyService {
|
||||
public List<GameStrategyDO> getGameStrategyList() {
|
||||
return gameStrategyMapper.selectList(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppGameStrategyRespVO> getAppGameStrategyList() {
|
||||
List<AppGameStrategyRespVO> respVOS = BeanUtils.toBean(getGameStrategyList(), AppGameStrategyRespVO.class);
|
||||
if (respVOS != null && !respVOS.isEmpty()) {
|
||||
respVOS.forEach(respVO -> {
|
||||
List<String> imageUrls = extractImageUrls(respVO.getContent());
|
||||
if (!imageUrls.isEmpty()) {
|
||||
respVO.setImgUrls(imageUrls);
|
||||
}
|
||||
});
|
||||
|
||||
return respVOS;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -11,6 +11,7 @@ import cn.iocoder.yudao.bee.front.dal.dataobject.game.GameUserDO;
|
||||
import cn.iocoder.yudao.bee.front.dal.dataobject.game.GameUserPropsDO;
|
||||
import cn.iocoder.yudao.bee.front.dal.mysql.game.GameTaskMapper;
|
||||
import cn.iocoder.yudao.bee.front.dal.mysql.game.GameTaskRecordsMapper;
|
||||
import cn.iocoder.yudao.bee.front.enums.game.GameHarvestStatusEnum;
|
||||
import cn.iocoder.yudao.bee.front.enums.game.GameTaskStatusEnum;
|
||||
import cn.iocoder.yudao.bee.front.enums.game.RewardTypeEnum;
|
||||
import cn.iocoder.yudao.bee.front.util.AssertUtils;
|
||||
@@ -78,6 +79,12 @@ public class GameTaskServiceImpl implements GameTaskService {
|
||||
validateTaskExists(updateReqVO.getId());
|
||||
// 更新
|
||||
GameTaskDO updateObj = BeanUtils.toBean(updateReqVO, GameTaskDO.class);
|
||||
updateObj.setStatus(1);
|
||||
if (RewardTypeEnum.PROPS.getType().equals(updateObj.getRewardType())) {
|
||||
updateObj.setReward(0);
|
||||
}else if (RewardTypeEnum.NECTAR.getType().equals(updateObj.getRewardType())) {
|
||||
updateObj.setPropsId(0);
|
||||
}
|
||||
taskMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@@ -113,7 +120,7 @@ public class GameTaskServiceImpl implements GameTaskService {
|
||||
});
|
||||
List<GameTaskRespVO> gameTaskRespVOS = BeanUtils.toBean(gameTaskDOS, GameTaskRespVO.class);
|
||||
gameTaskRespVOS.forEach(gameTaskRespVO -> {
|
||||
if (gameTaskRespVO.getPropsId() != null) {
|
||||
if (gameTaskRespVO.getPropsId() != null && gameTaskRespVO.getPropsId() > 0) {
|
||||
String name = gamePropsService.getGameProps(gameTaskRespVO.getPropsId()).getName();
|
||||
gameTaskRespVO.setPropsName(name);
|
||||
}
|
||||
@@ -138,7 +145,7 @@ public class GameTaskServiceImpl implements GameTaskService {
|
||||
if (gameTaskRecordsDO != null) {
|
||||
taskRespVO.setStatus(gameTaskRecordsDO.getStatus())
|
||||
.setCurrentProcess(gameTaskRecordsDO.getProcess());
|
||||
}
|
||||
}else taskRespVO.setCurrentProcess(0);
|
||||
}
|
||||
return gameTaskRespVOS;
|
||||
}
|
||||
|
@@ -37,13 +37,19 @@ public class GameUserPropsServiceImpl implements GameUserPropsService {
|
||||
|
||||
@Resource
|
||||
private GameUserPropsMapper gameUserPropsMapper;
|
||||
@Autowired
|
||||
|
||||
@Resource
|
||||
private GameUserService gameUserService;
|
||||
@Autowired
|
||||
|
||||
@Resource
|
||||
private GamePropsService gamePropsService;
|
||||
@Autowired
|
||||
|
||||
@Resource
|
||||
private GameAccessRecordsService gameAccessRecordsService;
|
||||
|
||||
@Resource
|
||||
private DailyTaskService dailyTaskService;
|
||||
|
||||
@Override
|
||||
public Integer createGameUserProps(GameUserPropsSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@@ -135,6 +141,8 @@ public class GameUserPropsServiceImpl implements GameUserPropsService {
|
||||
GameUserPropsDO gameUserPropsDO = gameUserPropsMapper
|
||||
.selectOne(GameUserPropsDO::getPropsId, id, GameUserPropsDO::getUserId, loginGameUser.getId());
|
||||
if (gameUserPropsDO == null || gameUserPropsDO.getStock()<1) throw exception(NO_HAVE_PROPS);
|
||||
Long count = gameAccessRecordsService.getAccessRecordsCountByUserIdAndPropsId(loginGameUser.getId(), id);
|
||||
if (count >= 20) throw exception(USE_LIMITED);
|
||||
GamePropsDO gameProps = gamePropsService.getGameProps(id);
|
||||
//扣减数量,生成使用记录
|
||||
gameUserPropsDO.setStock(gameUserPropsDO.getStock()-1);
|
||||
@@ -169,5 +177,7 @@ public class GameUserPropsServiceImpl implements GameUserPropsService {
|
||||
gameAccessRecordsService.createGameAccessRecords(saveReqVO);
|
||||
}
|
||||
gameAccessRecordsService.createGameAccessRecords(gameAccessRecordsSaveReqVO);
|
||||
dailyTaskService.handleUseProps(loginGameUser.getBeeUserId());
|
||||
}
|
||||
|
||||
}
|
@@ -77,6 +77,8 @@ public class GameUserServiceImpl implements GameUserService {
|
||||
private GameTaskMapper gameTaskMapper;
|
||||
@Autowired
|
||||
private GameBeehiveService gameBeehiveService;
|
||||
@Autowired
|
||||
private DailyTaskService dailyTaskService;
|
||||
|
||||
@Override
|
||||
public Integer createGameUser(GameUserSaveReqVO createReqVO) {
|
||||
@@ -142,7 +144,7 @@ public class GameUserServiceImpl implements GameUserService {
|
||||
GameUserDO loginGameUser = getLoginGameUser();
|
||||
|
||||
// 处理登录任务
|
||||
boolean b = handleLoginTask(loginGameUser.getId());
|
||||
boolean b = dailyTaskService.handleUserLogin(loginGameUser.getBeeUserId());
|
||||
|
||||
// 处理每日登录赠送道具
|
||||
if (b) handleDailyLoginProps(loginGameUser);
|
||||
|
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.bee.front.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class RichTextUtils {
|
||||
|
||||
/**
|
||||
* 从富文本中提取所有图片路径
|
||||
* @param richText 富文本内容
|
||||
* @return 图片路径列表
|
||||
*/
|
||||
public static List<String> extractImageUrls(String richText) {
|
||||
List<String> imageUrls = new ArrayList<>();
|
||||
if (richText == null || richText.isEmpty()) {
|
||||
return imageUrls;
|
||||
}
|
||||
|
||||
// 定义正则表达式模式,用于匹配 <img> 标签中的 src 属性
|
||||
String regex = "<img[^>]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>";
|
||||
Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(richText);
|
||||
|
||||
// 查找所有匹配项
|
||||
while (matcher.find()) {
|
||||
imageUrls.add(matcher.group(1));
|
||||
}
|
||||
|
||||
return imageUrls;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user