From d42f32d6c6ff2cbaab2fbdabbeefb2367e72d446 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 25 三月 2024 17:08:31 +0800
Subject: [PATCH] 新增加功能
---
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java | 11 +++--
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java | 9 ++++
cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java | 91 +++++++++++++++++++++++++++++++--------------
cloud-server-other/src/main/java/com/dsh/other/entity/TGameConfig.java | 4 ++
4 files changed, 82 insertions(+), 33 deletions(-)
diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java
index a08600c..da91d5d 100644
--- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java
+++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java
@@ -1,6 +1,7 @@
package com.dsh.communityWorldCup.service.impl;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.communityWorldCup.entity.WorldCup;
@@ -271,7 +272,13 @@
*/
@Override
public void endWorldCupCallback(String custom, Integer red_score, Integer blue_score) {
- List<Long> ids = JSON.parseArray(custom, Long.class);
+ JSONObject jsonObject = JSON.parseObject(custom);
+ Integer gameType = jsonObject.getInteger("gameType");
+ //智慧球场比赛
+ if(2 == gameType){
+ return;
+ }
+ List<Long> ids = jsonObject.getJSONArray("ids").toJavaList(Long.class);
List<WorldCupCompetitor> worldCupCompetitors = this.listByIds(ids);
try {
WorldCupCompetitor worldCupCompetitor1 = worldCupCompetitors.get(0);
diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java
index d13cbad..a466f4b 100644
--- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java
+++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java
@@ -181,6 +181,9 @@
worldCup.setMatchNumber(worldCup.getMatchNumber() + 1);
this.updateById(worldCup);
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("gameType", 1);
+ jsonObject.put("ids", ids);
//2、调起开启游戏的接口。
HashMap<String, String> map = new HashMap<>();
map.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
@@ -188,12 +191,12 @@
map.put("red_sutu_id", tGame.getRed());
map.put("blue_sutu_id", tGame.getBlue());
map.put("api_url", "http://221.182.45.100:56666/communityWorldCup/base/worldCup/endWorldCupCallback");
- map.put("custom", JSON.toJSONString(ids));
+ map.put("custom", jsonObject.toJSONString());
String s = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/quickStart", map);
- JSONObject jsonObject = JSONObject.parseObject(s);
- Integer code1 = jsonObject.getInteger("code");
- String message = jsonObject.getString("message");
+ JSONObject jsonObject1 = JSONObject.parseObject(s);
+ Integer code1 = jsonObject1.getInteger("code");
+ String message = jsonObject1.getString("message");
if (200 == code1) {
return ResultUtil.success();
} else {
diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java
index 3d1174c..bc18bca 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java
@@ -1,6 +1,8 @@
package com.dsh.other.controller;
import cn.hutool.http.HttpRequest;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.response.AlipayTradeQueryResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -63,6 +65,12 @@
@Autowired
private ISiteBookingService siteBookingService;
+ private String smid = "2088330203191220";//平台支付宝商户号
+ @Autowired
+ private ISiteService siteService;
+
+
+
@ResponseBody
@PostMapping("/api/game/getIntro")
@@ -111,6 +119,13 @@
Integer id = list.get(0).getId();
tGameConfigs = gameConfigService.listJs(id);
}
+ tGameConfigs.forEach(g -> {
+ if(g.getGameId() == 0){
+ g.setGameType(2);
+ }else{
+ g.setGameType(1);
+ }
+ });
List<TGameConfig> filteredList = tGameConfigs.stream()
.filter(gameConfig -> !gameConfig.getImg().isEmpty())
.collect(Collectors.toList());
@@ -160,9 +175,6 @@
- private String smid = "2088330203191220";//平台支付宝商户号
- @Autowired
- private ISiteService siteService;
@@ -170,6 +182,7 @@
@PostMapping("/api/game/payGame")
@ApiOperation(value = "支付游戏", tags = {"用户—游戏"})
@ApiImplicitParams({
+ @ApiImplicitParam(value = "游戏类型(1=普通游戏,2=世界杯)", name = "gameType", dataType = "int", required = true),
@ApiImplicitParam(value = "三方游戏id", name = "gameId", dataType = "int", required = true),
@ApiImplicitParam(value = "游戏配置id", name = "configId", dataType = "int", required = true),
@ApiImplicitParam(value = "sutuId", name = "sutuId", dataType = "int", required = true),
@@ -177,7 +190,7 @@
@ApiImplicitParam(value = "1微信 2支付宝 3玩湃币 5积分", name = "type", dataType = "int", required = true),
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
})
- public ResultUtil payGame(Integer gameId, Integer configId, Integer type, Integer sutuId, Integer spaceId) {
+ public ResultUtil payGame(Integer gameType, Integer gameId, Integer configId, Integer type, Integer sutuId, Integer spaceId) {
try {
Integer uid = tokenUtil.getUserIdFormRedis();
if (null == uid) {
@@ -187,7 +200,7 @@
AppUser appUser1 = appUserClient.queryAppUser(uid);
User one = userService.getOne(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1));
if (null != one) {
- Integer integer = startGame(uid, gameId, spaceId, sutuId);
+ Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId);
return ResultUtil.success();
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
@@ -204,7 +217,7 @@
if (type == 1) {
tGameRecord.setMoney(config.getCash());
gameRecordService.updateById(tGameRecord);
- String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+configId;
+ String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+configId + "_" + gameType;
ResultUtil weixinpay = payMoneyUtil.weixinpay("游戏支付", params, code, config.getCash().toString(),
"/base/game/wechatPaymentGameCallback", "APP", "");
if (weixinpay.getCode() == 200) {
@@ -248,7 +261,7 @@
gameRecord.setOrderNo(transaction_id);
}
gameRecordService.updateBatchById(list);
- Integer integer = startGame(uid, gameId, spaceId, sutuId);
+ Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId);
break;
}
if ("USERPAYING".equals(s) || "NOTPAY".equals(s)) {
@@ -267,7 +280,7 @@
tGameRecord.setMoney(config.getCash());
gameRecordService.updateById(tGameRecord);
String smid1="";
- String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+configId;
+ String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+ configId + "_" + gameType;
// 判断这个课包属于哪个门店 属于哪个运营商 根据运营商 id 获取对应的商户号
TGame game = gameService.getOne(new QueryWrapper<TGame>().eq("blue", sutuId).or().eq("red", sutuId));
Integer operationId = game.getOperationId();
@@ -324,7 +337,7 @@
}
gameRecordService.updateBatchById(list);
- Integer integer = startGame(uid, gameId, spaceId, sutuId);
+ Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId);
// 判断这个课包属于哪个门店 属于哪个运营商 根据运营商 id 获取对应的商户号
TGame game = gameService.getById(gameId);
String smid2="";
@@ -364,7 +377,7 @@
int i1 = playPaiCoins - i;
appUser.setPlayPaiCoins(i1);
appUserClient.updateAppUser(appUser);
- startGame(uid, gameId, spaceId, sutuId);
+ startGame(uid, gameType, gameId, spaceId, sutuId);
return ResultUtil.success();
} else if (type == 5) {
@@ -379,7 +392,7 @@
appUser.setIntegral(i1);
appUser.setPoints(playCoin.intValue());
appUserClient.updateAppUser(appUser);
- startGame(uid, gameId, spaceId, sutuId);
+ startGame(uid, gameType, gameId, spaceId, sutuId);
return ResultUtil.success();
} else {
return ResultUtil.error("支付方式错误");
@@ -391,22 +404,44 @@
}
- private static Integer startGame(Integer uid, Integer gameId, Integer spaceId, Integer sutuId) {
- HashMap<String, String> map = new HashMap<>();
- map.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
- map.put("app_user_id", uid + "");
- map.put("game_id", gameId + "");
- map.put("space_id", spaceId + "");
- map.put("sutu_id", sutuId + "");
+ public Integer startGame(Integer uid, Integer gameType, Integer gameId, Integer spaceId, Integer sutuId) {
+ TGame game = gameService.getOne(new QueryWrapper<TGame>().eq("blue", sutuId).or().eq("red", sutuId));
+ if(1 == gameType){
+ HashMap<String, String> map = new HashMap<>();
+ map.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
+ map.put("app_user_id", uid + "");
+ map.put("game_id", gameId + "");
+ map.put("space_id", spaceId + "");
+ map.put("sutu_id", sutuId + "");
- String s = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/gameStart", map);
- JSONObject jsonObject = JSONObject.parseObject(s);
- Object code = jsonObject.get("code");
- if (String.valueOf(code) != null && "200".equals(String.valueOf(code))) {
- System.err.println("--------------启动了一次游戏");
- return 200;
- } else {
- return 500;
+ String s = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/gameStart", map);
+ JSONObject jsonObject = JSONObject.parseObject(s);
+ Object code = jsonObject.get("code");
+ if (String.valueOf(code) != null && "200".equals(String.valueOf(code))) {
+ System.err.println("--------------启动了一次游戏");
+ return 200;
+ } else {
+ return 500;
+ }
+ }else{
+ //2、调起开启游戏的接口。
+ HashMap<String, String> map = new HashMap<>();
+ map.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
+ map.put("space_id", spaceId + "");
+ map.put("red_sutu_id", game.getRed());
+ map.put("blue_sutu_id", game.getBlue());
+ map.put("api_url", "http://221.182.45.100:56666/communityWorldCup/base/worldCup/endWorldCupCallback");
+ map.put("custom", "{\"gameType\": 2}");
+
+ String s = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/quickStart", map);
+ JSONObject jsonObject = JSONObject.parseObject(s);
+ Integer code1 = jsonObject.getInteger("code");
+ String message = jsonObject.getString("message");
+ if (200 == code1) {
+ return 200;
+ } else {
+ return 500;
+ }
}
}
@@ -452,7 +487,7 @@
}
gameRecordService.updateBatchById(list);
String[] s = attach.split("_");
- Integer integer = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3]));
+ Integer integer = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[4]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3]));
PrintWriter out = null;
try {
@@ -492,7 +527,7 @@
}
gameRecordService.updateBatchById(list);
String[] s = attach.split("_");
- Integer integer = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3]));
+ Integer integer = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[4]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3]));
PrintWriter out = null;
try {
diff --git a/cloud-server-other/src/main/java/com/dsh/other/entity/TGameConfig.java b/cloud-server-other/src/main/java/com/dsh/other/entity/TGameConfig.java
index 0f07210..4309c0c 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/entity/TGameConfig.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/entity/TGameConfig.java
@@ -10,6 +10,7 @@
import java.io.Serializable;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@@ -70,6 +71,9 @@
private String intro;
@TableField(exist = false)
private String video;
+ @TableField(exist = false)
+ @ApiModelProperty("游戏类型(1=普通游戏,2=世界杯)")
+ private Integer gameType;
@Override
--
Gitblit v1.7.1