|
@@ -1,16 +1,13 @@
|
|
|
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.DeleteEnum;
|
|
|
-import com.zanxiang.common.exception.ParamNullException;
|
|
|
+import com.zanxiang.common.enums.PayWayEnum;
|
|
|
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.PayDeviceDTO;
|
|
|
+import com.zanxiang.manage.domain.dto.*;
|
|
|
import com.zanxiang.manage.domain.params.GamePayWayListParam;
|
|
|
-import com.zanxiang.manage.domain.params.GamePayWayParam;
|
|
|
import com.zanxiang.manage.domain.vo.GamePayWayListVO;
|
|
|
import com.zanxiang.manage.domain.vo.GamePayWayVO;
|
|
|
import com.zanxiang.manage.service.*;
|
|
@@ -19,12 +16,11 @@ import com.zanxiang.mybatis.mapper.GamePayWayMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -37,16 +33,7 @@ import java.util.stream.Collectors;
|
|
|
public class GamePayWayServiceImpl extends ServiceImpl<GamePayWayMapper, GamePayWay> implements IGamePayWayService {
|
|
|
|
|
|
@Autowired
|
|
|
- private IPayMerchantService payMerchantService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IPayBoxService payBoxService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IPayApplicationService payApplicationService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IGameStrategyService gameStrategyService;
|
|
|
+ private IGameAppletService gameAppletService;
|
|
|
|
|
|
@Autowired
|
|
|
private IGameCategoryService gameCategoryService;
|
|
@@ -57,60 +44,29 @@ public class GamePayWayServiceImpl extends ServiceImpl<GamePayWayMapper, GamePay
|
|
|
@Autowired
|
|
|
private IPayDeviceService payDeviceService;
|
|
|
|
|
|
- @Override
|
|
|
- public List<GamePayWayVO> getByGameId(Long gameId) {
|
|
|
- List<GamePayWay> gamePayWayList = super.list(new LambdaQueryWrapper<GamePayWay>()
|
|
|
- .eq(GamePayWay::getGameId, gameId));
|
|
|
- if (CollectionUtils.isEmpty(gamePayWayList)) {
|
|
|
- return Collections.emptyList();
|
|
|
- }
|
|
|
- List<Long> payDeviceIdList = gamePayWayList.stream().map(GamePayWay::getPayDeviceId).distinct().collect(Collectors.toList());
|
|
|
- Map<Long, PayDeviceDTO> payDeviceMap = payDeviceService.payDeviceMap();
|
|
|
- List<GamePayWayVO> list = new ArrayList<>();
|
|
|
- payDeviceIdList.forEach(payDeviceId -> list.add(GamePayWayVO.builder()
|
|
|
- .id(payDeviceId)
|
|
|
- .payWayName(payDeviceMap.get(payDeviceId).getPayDeviceName())
|
|
|
- .build()));
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public Boolean saveOrUpdate(GamePayWayParam bo) {
|
|
|
- if (bo.getIsDelete() != null && bo.getIsDelete() == DeleteEnum.YES.getCode()) {
|
|
|
- if (bo.getId() == null) {
|
|
|
- throw new ParamNullException("Id");
|
|
|
- }
|
|
|
- return removeById(bo.getId());
|
|
|
- }
|
|
|
- return saveOrUpdate(BeanUtils.copy(bo, GamePayWay.class));
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private IPayWayService payWayService;
|
|
|
|
|
|
@Override
|
|
|
- public IPage<GamePayWayListVO> list(GamePayWayListParam param) {
|
|
|
+ public IPage<GamePayWayListVO> pageList(GamePayWayListParam param) {
|
|
|
Map<Long, GameCategoryDTO> gameCategoryMap = gameCategoryService.gameCategoryMap();
|
|
|
Map<Long, GameDTO> gameMap = gameService.gameMap();
|
|
|
+ Map<Long, PayDeviceDTO> payDeviceMap = payDeviceService.payDeviceMap();
|
|
|
+ Map<Long, PayWayDTO> payWayMap = payWayService.payWayMap();
|
|
|
return super.page(param.toPage(), new LambdaQueryWrapper<GamePayWay>()
|
|
|
.eq(param.getGameId() != null, GamePayWay::getGameId, param.getGameId())
|
|
|
.eq(param.getPayWayId() != null, GamePayWay::getPayWayId, param.getPayWayId())
|
|
|
- .eq(param.getStatus() != null, GamePayWay::getStatus, param.getStatus()))
|
|
|
- .convert(gamePayWay -> this.toVO(gameMap, gameCategoryMap, gamePayWay));
|
|
|
+ .eq(param.getStatus() != null, GamePayWay::getStatus, param.getStatus())
|
|
|
+ .orderByDesc(GamePayWay::getCreateTime))
|
|
|
+ .convert(gamePayWay -> this.toVO(gameMap, gameCategoryMap, gamePayWay, payWayMap, payDeviceMap));
|
|
|
}
|
|
|
|
|
|
- private GamePayWayListVO toVO(Map<Long, GameDTO> gameMap, Map<Long, GameCategoryDTO> gameCategoryMap, GamePayWay gamePayWay) {
|
|
|
+ private GamePayWayListVO toVO(Map<Long, GameDTO> gameMap, Map<Long, GameCategoryDTO> gameCategoryMap,
|
|
|
+ GamePayWay gamePayWay, Map<Long, PayWayDTO> payWayMap, Map<Long, PayDeviceDTO> payDeviceMap) {
|
|
|
+ GamePayWayListVO gamePayWayListVO = BeanUtils.copy(gamePayWay, GamePayWayListVO.class);
|
|
|
if (gamePayWay == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- GamePayWayListVO gamePayWayListVO = BeanUtils.copy(gamePayWay, GamePayWayListVO.class);
|
|
|
GameDTO gameDTO = gameMap.get(gamePayWayListVO.getGameId());
|
|
|
if (gameDTO != null) {
|
|
|
gamePayWayListVO.setGameName(gameDTO.getName());
|
|
@@ -120,138 +76,68 @@ public class GamePayWayServiceImpl extends ServiceImpl<GamePayWayMapper, GamePay
|
|
|
gamePayWayListVO.setGameCategory(gameCategoryDTO.getName());
|
|
|
}
|
|
|
}
|
|
|
+ Long payWayId = gamePayWay.getPayWayId();
|
|
|
+ PayWayDTO payWayDTO = payWayMap.get(payWayId);
|
|
|
+ if (payWayDTO != null) {
|
|
|
+ gamePayWayListVO.setPayWayName(payWayDTO.getPayWayName());
|
|
|
+ }
|
|
|
+ PayDeviceDTO payDeviceDTO = payDeviceMap.get(gamePayWay.getPayDeviceId());
|
|
|
+ if (payDeviceDTO != null) {
|
|
|
+ gamePayWayListVO.setPayDeviceName(payDeviceDTO.getPayDeviceName());
|
|
|
+ }
|
|
|
+ if (Objects.equals(PayWayEnum.ALI_PAY.getPayWayId(), payWayId.intValue())) {
|
|
|
+ GamePayWayListVO.AliPayConfigBean aliPayConfigBean = new GamePayWayListVO.AliPayConfigBean();
|
|
|
+ aliPayConfigBean.setAppId(gamePayWay.getAppId());
|
|
|
+ gamePayWayListVO.setAliPayConfig(aliPayConfigBean);
|
|
|
+ }
|
|
|
+ if (Objects.equals(PayWayEnum.WX_PAY.getPayWayId(), payWayId.intValue())) {
|
|
|
+ GamePayWayListVO.WxPayConfigBean wxPayConfigBean = new GamePayWayListVO.WxPayConfigBean();
|
|
|
+ wxPayConfigBean.setPayBoxId(gamePayWay.getPayBoxId());
|
|
|
+ wxPayConfigBean.setThumbUrl(gamePayWay.getThumbUrl());
|
|
|
+ wxPayConfigBean.setAppId(gamePayWay.getAppId());
|
|
|
+ wxPayConfigBean.setMerchantNo(gamePayWay.getMerchantNo());
|
|
|
+ gamePayWayListVO.setWxPayConfig(wxPayConfigBean);
|
|
|
+ }
|
|
|
+ if (Objects.equals(PayWayEnum.MI_PAY.getPayWayId(), payWayId.intValue())) {
|
|
|
+ GameAppletDTO gameAppletDTO = gameAppletService.getByGameId(gamePayWay.getGameId());
|
|
|
+ GamePayWayListVO.MiPayConfigBean miPayConfigBean = new GamePayWayListVO.MiPayConfigBean();
|
|
|
+ miPayConfigBean.setAppId(gameAppletDTO.getMiPayAppId());
|
|
|
+ miPayConfigBean.setAppKey(gameAppletDTO.getMiPayAppKey());
|
|
|
+ miPayConfigBean.setAppKeyDev(gameAppletDTO.getMiPayAppKeyDev());
|
|
|
+ gamePayWayListVO.setMiPayConfig(miPayConfigBean);
|
|
|
+ }
|
|
|
return gamePayWayListVO;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean statusUpdate(Long id, Integer status) {
|
|
|
+ return super.update(new LambdaUpdateWrapper<GamePayWay>()
|
|
|
+ .set(GamePayWay::getStatus, status)
|
|
|
+ .set(GamePayWay::getUpdateTime, LocalDateTime.now())
|
|
|
+ .eq(GamePayWay::getId, id));
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean deleteById(Long id) {
|
|
|
+ return super.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<GamePayWayVO> getByGameId(Long gameId) {
|
|
|
+ List<GamePayWay> gamePayWayList = super.list(new LambdaQueryWrapper<GamePayWay>()
|
|
|
+ .eq(GamePayWay::getGameId, gameId));
|
|
|
+ if (CollectionUtils.isEmpty(gamePayWayList)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ List<Long> payDeviceIdList = gamePayWayList.stream().map(GamePayWay::getPayDeviceId).distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, PayDeviceDTO> payDeviceMap = payDeviceService.payDeviceMap();
|
|
|
+ List<GamePayWayVO> list = new ArrayList<>();
|
|
|
+ payDeviceIdList.forEach(payDeviceId -> list.add(GamePayWayVO.builder()
|
|
|
+ .id(payDeviceId)
|
|
|
+ .payWayName(payDeviceMap.get(payDeviceId).getPayDeviceName())
|
|
|
+ .build()));
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|