From 3990542fdd42d5fc4a0f91cbd2cbfe5524754689 Mon Sep 17 00:00:00 2001 From: zy_Java <654600784@qq.com> Date: Thu, 20 Aug 2020 15:02:19 +0800 Subject: [PATCH] 0820_2.0 --- .../ccsens/game/service/MessageService.java | 1 + .../ccsens/game/service/ScreenService.java | 23 ++++++++++++++----- .../com/ccsens/game/util/GameConstant.java | 2 +- game/src/main/resources/application-dev.yml | 1 + game/src/main/resources/application-prod.yml | 3 ++- game/src/main/resources/application-test.yml | 3 ++- game/src/main/resources/application.yml | 4 ++-- tall/src/main/resources/application.yml | 4 ++-- .../main/java/com/ccsens/util/PropUtil.java | 6 +++++ .../java/com/ccsens/util/wx/WxXcxUtil.java | 6 ++++- 10 files changed, 39 insertions(+), 14 deletions(-) diff --git a/game/src/main/java/com/ccsens/game/service/MessageService.java b/game/src/main/java/com/ccsens/game/service/MessageService.java index a6cb6aa6..8e6f96b7 100644 --- a/game/src/main/java/com/ccsens/game/service/MessageService.java +++ b/game/src/main/java/com/ccsens/game/service/MessageService.java @@ -44,6 +44,7 @@ public class MessageService implements IMessageService { inMessage.setToDomain(MessageConstant.DomainType.User); inMessage.setTos(userIdSet); inMessage.setData(JSONObject.toJSONString(message)); + log.info("新建或再玩一次发送消息:{}",inMessage); rabbitTemplate.convertAndSend(RabbitMQConfig.MESSAGE_QUEUE_NAME, JSONObject.toJSONString(inMessage)); } diff --git a/game/src/main/java/com/ccsens/game/service/ScreenService.java b/game/src/main/java/com/ccsens/game/service/ScreenService.java index f1775238..44e9975d 100644 --- a/game/src/main/java/com/ccsens/game/service/ScreenService.java +++ b/game/src/main/java/com/ccsens/game/service/ScreenService.java @@ -29,7 +29,6 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.ZSetOperations; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; @@ -76,8 +75,6 @@ public class ScreenService implements IScreenService { private SendMsg sendMsg; @Resource private RedisUtil redisUtil; - @Value("${spring.profiles.active}") - private String active; /** * 创建游戏 @@ -123,8 +120,7 @@ public class ScreenService implements IScreenService { gameRecord.setUrl(gameUrl + gameType.getScreenUrl() + "?id=" + gameRecord.getId()); // gameRecord.setQrCodeUrl(gameUrl + gameRecord.getId() + File.separator + gameType.getClientUrl()); - log.info("active:{}", active); - if ("prod".equals(active)) { + if("1".equalsIgnoreCase(PropUtil.openWx)){ //生成二维码 String fileName = "/gameQrCode/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".png"; String path = WebConstant.UPLOAD_PATH_BASE + fileName; @@ -137,6 +133,7 @@ public class ScreenService implements IScreenService { //给一个默认测试的 gameRecord.setQrCodeUrl(PropUtil.qrCode + "/gameQrCode/2020-08-19/1597822577181.png"); } + //查找此任务下的游戏配置表 byte businessType = 8; if( GameConstant.GAME_TYPE_SP.equalsIgnoreCase(memberGame.getGameType())){ @@ -876,7 +873,20 @@ public class ScreenService implements IScreenService { default:break; } gameRecordNew.setUrl(gameUrl + gameType.getScreenUrl() + "?id=" + gameRecordNew.getId()); - gameRecordNew.setQrCodeUrl(gameUrl+ gameRecordNew.getId() + File.separator + gameType.getClientUrl()); +// gameRecordNew.setQrCodeUrl(gameUrl+ gameRecordNew.getId() + File.separator + gameType.getClientUrl()); + if("1".equalsIgnoreCase(PropUtil.openWx)){ + //生成二维码 + String fileName = "/gameQrCode/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".png"; + String path = WebConstant.UPLOAD_PATH_BASE + fileName; + WxXcxUtil.getWxCode(WebConstant.QRCODE_GAME + , "id=" + gameRecord.getId() + "&type=" + gameType.getCode(), null, path,gameType.getCode()); + gameRecord.setQrCodeUrl(PropUtil.qrCode + fileName); + log.info("调用微信生成二维码"); + } else { + log.info("测试环境,不调用生成二维码"); + //给一个默认测试的 + gameRecord.setQrCodeUrl(PropUtil.qrCode + "/gameQrCode/2020-08-19/1597822577181.png"); + } gameRecordDao.insertSelective(gameRecordNew); //修改购买的游戏的使用次数 gameUserPay.setUsedCount(gameUserPay.getUsedCount() + 1); @@ -915,6 +925,7 @@ public class ScreenService implements IScreenService { } } chromeMessageDto.setReceivers(messageUserList); + log.info("再玩一次发送消息:{}",chromeMessageDto); messageService.sendGameMessageWithGetUrl(chromeMessageDto,userIdSet); return gameRecordNew.getUrl(); diff --git a/game/src/main/java/com/ccsens/game/util/GameConstant.java b/game/src/main/java/com/ccsens/game/util/GameConstant.java index b5435679..a31b956d 100644 --- a/game/src/main/java/com/ccsens/game/util/GameConstant.java +++ b/game/src/main/java/com/ccsens/game/util/GameConstant.java @@ -57,7 +57,7 @@ public class GameConstant { /**游戏:分组*/ public static final byte GAME_GROUP = 1; /**游戏:单人*/ - public static final byte GAME_SINGLE = 1; + public static final byte GAME_SINGLE = 0; /** * 生成游戏key diff --git a/game/src/main/resources/application-dev.yml b/game/src/main/resources/application-dev.yml index 9e0b4c23..acc4b645 100644 --- a/game/src/main/resources/application-dev.yml +++ b/game/src/main/resources/application-dev.yml @@ -31,3 +31,4 @@ gatewayUrl: https://test.tall.wiki/gateway/ notGatewayUrl: https://test.tall.wiki/ file: qrCode: https://test.tall.wiki/gateway/tall/uploads/ + openWX: 0 diff --git a/game/src/main/resources/application-prod.yml b/game/src/main/resources/application-prod.yml index c0f6363e..c4a36346 100644 --- a/game/src/main/resources/application-prod.yml +++ b/game/src/main/resources/application-prod.yml @@ -33,4 +33,5 @@ eureka: gatewayUrl: https://www.tall.wiki/gateway/ notGatewayUrl: https://www.tall.wiki/ file: - qrCode: https://www.tall.wiki/gateway/tall/v1.0/uploads/ \ No newline at end of file + qrCode: https://www.tall.wiki/gateway/tall/v1.0/uploads/ + openWX: 1 \ No newline at end of file diff --git a/game/src/main/resources/application-test.yml b/game/src/main/resources/application-test.yml index 31d43e97..6a261fde 100644 --- a/game/src/main/resources/application-test.yml +++ b/game/src/main/resources/application-test.yml @@ -33,4 +33,5 @@ eureka: gatewayUrl: https://test.tall.wiki/gateway/ notGatewayUrl: https://test.tall.wiki/ file: - qrCode: https://test.tall.wiki/gateway/tall/v1.0/uploads/ \ No newline at end of file + qrCode: https://test.tall.wiki/gateway/tall/v1.0/uploads/ + openWX: 1 \ No newline at end of file diff --git a/game/src/main/resources/application.yml b/game/src/main/resources/application.yml index 5889ff7f..d082c0ea 100644 --- a/game/src/main/resources/application.yml +++ b/game/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: test - include: common, util-test \ No newline at end of file + active: prod + include: common, util-prod \ No newline at end of file diff --git a/tall/src/main/resources/application.yml b/tall/src/main/resources/application.yml index b2acd365..4fc2efe4 100644 --- a/tall/src/main/resources/application.yml +++ b/tall/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: dev - include: util-dev,common + active: prod + include: util-prod,common diff --git a/util/src/main/java/com/ccsens/util/PropUtil.java b/util/src/main/java/com/ccsens/util/PropUtil.java index 72a2dff1..5f26e9a8 100644 --- a/util/src/main/java/com/ccsens/util/PropUtil.java +++ b/util/src/main/java/com/ccsens/util/PropUtil.java @@ -21,6 +21,8 @@ public class PropUtil { public static String qrCode; public static String wxPrefix; public static String smsCode; + public static String openWx; + @Value("${gatewayUrl:}") public void setGatewayUrl(String gatewayUrl) { @@ -63,4 +65,8 @@ public class PropUtil { public void setSmsCode(String smsCode) { PropUtil.smsCode = smsCode; } + @Value("${file.openWX:}") + public static void setOpenWx(String openWx) { + PropUtil.openWx = openWx; + } } diff --git a/util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java b/util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java index ac2e63fe..ae37c5a7 100644 --- a/util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java +++ b/util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java @@ -12,6 +12,7 @@ import lombok.Data; import org.apache.commons.codec.digest.DigestUtils; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.ConnectException; @@ -234,7 +235,10 @@ public class WxXcxUtil { * @throws Exception */ public static void getWxCode(String page,String scene,LineColor color,String path,String code) throws Exception { - + File file = new File(path); + if(!file.getParentFile().exists()){ + file.getParentFile().mkdirs(); + } String url = String.format(URL_GET_WX_CODE_B, WxGzhUtil.getAccessToken(appId(code),secret(code))); WechatCode wechatCode = new WechatCode();