|
@@ -0,0 +1,103 @@
|
|
|
+package com.zanxiang.manage.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.zanxiang.common.enums.GameStrategyTypeEnum;
|
|
|
+import com.zanxiang.common.utils.bean.BeanUtils;
|
|
|
+import com.zanxiang.manage.domain.dto.GameCategoryDTO;
|
|
|
+import com.zanxiang.manage.domain.dto.GameDTO;
|
|
|
+import com.zanxiang.manage.domain.dto.PayMerchantDTO;
|
|
|
+import com.zanxiang.manage.domain.params.GamePayStrategyListParam;
|
|
|
+import com.zanxiang.manage.domain.vo.GamePayStrategyListVO;
|
|
|
+import com.zanxiang.manage.service.*;
|
|
|
+import com.zanxiang.mybatis.entity.GamePayStrategy;
|
|
|
+import com.zanxiang.mybatis.mapper.GameStrategyMapper;
|
|
|
+import org.apache.logging.log4j.util.Strings;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author : lingfeng
|
|
|
+ * @time : 2022-06-23
|
|
|
+ * @description : 游戏支付策略
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class GamePayStrategyServiceImpl extends ServiceImpl<GameStrategyMapper, GamePayStrategy> implements IGamePayStrategyService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IGameCategoryService gameCategoryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IGameService gameService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IPayMerchantService payMerchantService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IGamePayWayService gamePayWayService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<GamePayStrategyListVO> pageList(GamePayStrategyListParam param) {
|
|
|
+ Map<Long, GameCategoryDTO> gameCategoryMap = gameCategoryService.gameCategoryMap();
|
|
|
+ Map<Long, GameDTO> gameMap = gameService.gameMap();
|
|
|
+ Map<String, PayMerchantDTO> payMerchantMap = payMerchantService.payMerchantMap();
|
|
|
+ return super.page(param.toPage(), new LambdaQueryWrapper<GamePayStrategy>()
|
|
|
+ .like(Strings.isNotBlank(param.getName()), GamePayStrategy::getName, param.getName())
|
|
|
+ .eq(param.getType() != null, GamePayStrategy::getType, param.getType())
|
|
|
+ .eq(param.getGameId() != null, GamePayStrategy::getGameId, param.getGameId())
|
|
|
+ .eq(param.getStatus() != null, GamePayStrategy::getStatus, param.getStatus())
|
|
|
+ .orderByDesc(GamePayStrategy::getCreateTime))
|
|
|
+ .convert(gamePayStrategy -> this.toVO(gameMap, gameCategoryMap, gamePayStrategy, payMerchantMap));
|
|
|
+ }
|
|
|
+
|
|
|
+ private GamePayStrategyListVO toVO(Map<Long, GameDTO> gameMap, Map<Long, GameCategoryDTO> gameCategoryMap,
|
|
|
+ GamePayStrategy gamePayStrategy, Map<String, PayMerchantDTO> payMerchantMap) {
|
|
|
+ GamePayStrategyListVO gamePayStrategyListVO = BeanUtils.copy(gamePayStrategy, GamePayStrategyListVO.class);
|
|
|
+ if (gamePayStrategyListVO == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ gamePayStrategyListVO.setTypeName(GameStrategyTypeEnum.getNameByType(gamePayStrategyListVO.getType()));
|
|
|
+ GameDTO gameDTO = gameMap.get(gamePayStrategyListVO.getGameId());
|
|
|
+ if (gameDTO != null) {
|
|
|
+ GameCategoryDTO gameCategoryDTO = gameCategoryMap.get(gameDTO.getCategory());
|
|
|
+ gamePayStrategyListVO.setGameName(gameDTO.getName());
|
|
|
+ if (gameCategoryDTO != null) {
|
|
|
+ gamePayStrategyListVO.setGameCategory(gameCategoryDTO.getName());
|
|
|
+ gamePayStrategyListVO.setGameCategoryId(gameCategoryDTO.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Set<String> gameMerchantNoSet = gamePayWayService.getGameMerchantNo(gamePayStrategyListVO.getGameId());
|
|
|
+ Map<String, String> merchantMap = new HashMap<>(gameMerchantNoSet.size());
|
|
|
+ gameMerchantNoSet.forEach(merchantNo -> {
|
|
|
+ PayMerchantDTO payMerchantDTO = payMerchantMap.get(merchantNo);
|
|
|
+ if (payMerchantDTO != null) {
|
|
|
+ merchantMap.put(payMerchantDTO.getMerchantNo(), payMerchantDTO.getMerchantName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ gamePayStrategyListVO.setPayMerchantMap(merchantMap);
|
|
|
+ return gamePayStrategyListVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean statusUpdate(Long id, Integer status) {
|
|
|
+ return super.update(new LambdaUpdateWrapper<GamePayStrategy>()
|
|
|
+ .set(GamePayStrategy::getStatus, status)
|
|
|
+ .set(GamePayStrategy::getUpdateTime, LocalDateTime.now())
|
|
|
+ .eq(GamePayStrategy::getId, id));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean deleteById(Long id) {
|
|
|
+ return super.removeById(id);
|
|
|
+ }
|
|
|
+}
|