|
@@ -4,27 +4,32 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fasterxml.jackson.databind.util.JSONPObject;
|
|
|
import com.zanxiang.common.enums.DeleteEnum;
|
|
|
import com.zanxiang.common.enums.PayWayEnum;
|
|
|
+import com.zanxiang.common.enums.StatusEnum;
|
|
|
import com.zanxiang.common.exception.ParamNullException;
|
|
|
import com.zanxiang.common.utils.JsonUtil;
|
|
|
+import com.zanxiang.common.utils.StringUtils;
|
|
|
import com.zanxiang.common.utils.bean.BeanUtils;
|
|
|
import com.zanxiang.manage.domain.mapper.GamePayWayListMapper;
|
|
|
import com.zanxiang.manage.domain.params.GameAnalogPayParam;
|
|
|
import com.zanxiang.manage.domain.params.GamePayWayListParam;
|
|
|
import com.zanxiang.manage.domain.params.GamePayWayParam;
|
|
|
-import com.zanxiang.manage.domain.vo.GameAnalogPayVO;
|
|
|
-import com.zanxiang.manage.domain.vo.GamePayWayListVO;
|
|
|
-import com.zanxiang.manage.domain.vo.GamePayWayVO;
|
|
|
-import com.zanxiang.manage.service.GamePayWayService;
|
|
|
-import com.zanxiang.mybatis.entity.GamePayWay;
|
|
|
+import com.zanxiang.manage.domain.vo.*;
|
|
|
+import com.zanxiang.manage.service.*;
|
|
|
+import com.zanxiang.mybatis.entity.*;
|
|
|
import com.zanxiang.mybatis.mapper.GamePayWayMapper;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 游戏支付配置表 服务实现类
|
|
@@ -38,6 +43,18 @@ public class GamePayWayServiceImpl extends ServiceImpl<GamePayWayMapper, GamePay
|
|
|
@Autowired
|
|
|
private GamePayWayListMapper gamePayWayListMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PayMerchantService payMerchantService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PayBoxService payBoxService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PayApplicationService payApplicationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GameStrategyService gameStrategyService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<GamePayWayVO> getByGameId(Long gameId) {
|
|
|
List<GamePayWay> gamePayWayList = super.list(new LambdaQueryWrapper<GamePayWay>()
|
|
@@ -46,6 +63,16 @@ public class GamePayWayServiceImpl extends ServiceImpl<GamePayWayMapper, GamePay
|
|
|
return BeanUtils.copyList(gamePayWayList, GamePayWayVO.class);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<GamePayWayVO> getByGameIdForStatusYes(Long gameId) {
|
|
|
+ List<GamePayWay> gamePayWayList = super.list(new LambdaQueryWrapper<GamePayWay>()
|
|
|
+ .eq(GamePayWay::getGameId, gameId)
|
|
|
+ .eq(GamePayWay::getStatus, StatusEnum.YES.getCode())
|
|
|
+ .select(GamePayWay::getId, GamePayWay::getPayWayName));
|
|
|
+ return BeanUtils.copyList(gamePayWayList, GamePayWayVO.class);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean saveOrUpdate(GamePayWayParam bo) {
|
|
|
if (bo.getIsDelete() != null && bo.getIsDelete() == DeleteEnum.YES.getCode()) {
|
|
@@ -113,4 +140,87 @@ public class GamePayWayServiceImpl extends ServiceImpl<GamePayWayMapper, GamePay
|
|
|
}
|
|
|
return super.saveOrUpdate(gamePayWay);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AllGamePayWayByGameIdVO getAllGamePayWayByGameId(Long gameId) {
|
|
|
+ List<GamePayWay> gamePayWayList = super.list(new LambdaQueryWrapper<GamePayWay>()
|
|
|
+ .eq(GamePayWay::getGameId, gameId)
|
|
|
+ .eq(GamePayWay::getStatus, StatusEnum.YES.getCode())
|
|
|
+ );
|
|
|
+ if (CollectionUtils.isEmpty(gamePayWayList)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ AllGamePayWayByGameIdVO data = new AllGamePayWayByGameIdVO();
|
|
|
+ gamePayWayList.stream().forEach(t -> {
|
|
|
+ //支付宝
|
|
|
+ if (PayWayEnum.ALIPAY.getNum().equals(t.getPayWayId())) {
|
|
|
+ if (Objects.isNull(t.getPayMerchantId()) || t.getPayMerchantId() == 0) {
|
|
|
+ //商户号为空则跳过
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ PayMerchant payMerchantInfo = payMerchantService.getById(t.getPayMerchantId());
|
|
|
+ if (Objects.isNull(payMerchantInfo)) {
|
|
|
+ //商户号内容为空
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ GameAlipayPayVO alipayPayVO = new GameAlipayPayVO();
|
|
|
+ alipayPayVO.setMerchantNo(payMerchantInfo.getMerchantNo());
|
|
|
+ alipayPayVO.setMerchantName(payMerchantInfo.getMerchantName());
|
|
|
+ alipayPayVO.setLoginName(payMerchantInfo.getLoginName());
|
|
|
+ alipayPayVO.setManagePerson(payMerchantInfo.getManagePerson());
|
|
|
+ data.setAlipayPayVO(alipayPayVO);
|
|
|
+ }
|
|
|
+ //微信
|
|
|
+ if (PayWayEnum.WXPAY.getNum().equals(t.getPayWayId())) {
|
|
|
+
|
|
|
+ if (Objects.isNull(t.getPayBoxId()) || t.getPayBoxId() == 0) {
|
|
|
+ //商户号为空则跳过
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ PayBox payBoxInfo = payBoxService.getById(t.getPayBoxId());
|
|
|
+ if (Objects.isNull(payBoxInfo) || Objects.isNull(payBoxInfo.getPayApplicationId()) ||
|
|
|
+ payBoxInfo.getPayApplicationId() <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ PayApplication payApplicationInfo = payApplicationService.getById(payBoxInfo.getPayApplicationId());
|
|
|
+ if (Objects.isNull(payApplicationInfo)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ GameWxpayPayVO gameWxpayPayVO = new GameWxpayPayVO();
|
|
|
+ gameWxpayPayVO.setBoxName(payBoxInfo.getName());
|
|
|
+ gameWxpayPayVO.setApplicationName(payApplicationInfo.getName());
|
|
|
+ gameWxpayPayVO.setAppId(payApplicationInfo.getAppId());
|
|
|
+ gameWxpayPayVO.setPrimevalId(payApplicationInfo.getPrimevalId());
|
|
|
+ gameWxpayPayVO.setCompany(payApplicationInfo.getCompany());
|
|
|
+ gameWxpayPayVO.setManagePerson(payApplicationInfo.getManagePerson());
|
|
|
+
|
|
|
+ //获取商户号列表
|
|
|
+ List<PayMerchant> payMerchantList = payMerchantService.list();
|
|
|
+ Map<String, PayMerchant> payMerchantData = payMerchantList.stream().collect(Collectors.toMap(PayMerchant::getMerchantNo, PayMerchant -> PayMerchant));
|
|
|
+ if (StringUtils.isNotEmpty(payBoxInfo.getPayMerchantId())) {
|
|
|
+ String merchantDetail = payBoxService.getMerchantDetail(payMerchantData, payBoxInfo.getPayMerchantId());
|
|
|
+ gameWxpayPayVO.setPayMerchantDetail(merchantDetail);
|
|
|
+ }
|
|
|
+ data.setWxpayPayVO(gameWxpayPayVO);
|
|
|
+ }
|
|
|
+ //米大师虚拟支付
|
|
|
+ if (PayWayEnum.MIPAY.getNum().equals(t.getPayWayId())) {
|
|
|
+ GameAnalogPayVO.PayConfigBean payConfigBean = JsonUtil.toObj(t.getPayConfig(), GameAnalogPayVO.PayConfigBean.class);
|
|
|
+ data.setAnalogPayVO(payConfigBean);
|
|
|
+ }
|
|
|
+ //支付策略配置
|
|
|
+ GameStrategy gameStrategy = gameStrategyService.getOne(new LambdaQueryWrapper<GameStrategy>()
|
|
|
+ .eq(GameStrategy::getGameId, gameId)
|
|
|
+ .eq(GameStrategy::getStatus, StatusEnum.YES.getCode()).last("limit 1")
|
|
|
+ );
|
|
|
+ if (!Objects.isNull(gameStrategy)) {
|
|
|
+ GameStrategyInfoVO gameStrategyInfo = BeanUtils.copy(gameStrategy, GameStrategyInfoVO.class);
|
|
|
+ if (StringUtils.isNotEmpty(gameStrategy.getConfig())) {
|
|
|
+ gameStrategyInfo.setConfig(BeanUtils.copy(gameStrategy.getConfig(), GameStrategyOrderVO.class));
|
|
|
+ }
|
|
|
+ data.setGameStrategyVO(gameStrategyInfo);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return data;
|
|
|
+ }
|
|
|
}
|