Browse Source

0819_2.0

master
zy_Java 5 years ago
parent
commit
ad685c33b2
  1. 42
      game/src/main/java/com/ccsens/game/service/ScreenService.java
  2. 3
      game/src/main/resources/application-dev.yml
  3. 35
      game/src/main/resources/application-prod.yml
  4. 6
      game/src/main/resources/application-test.yml
  5. 4
      game/src/main/resources/application.yml
  6. 4
      health/src/main/java/com/ccsens/health/service/AsyncService.java
  7. 3
      health/src/main/java/com/ccsens/health/service/ClockService.java
  8. 5
      mt/src/main/resources/application-prod.yml
  9. 3
      mt/src/main/resources/application-test.yml
  10. 7
      util/src/main/java/com/ccsens/util/WebConstant.java
  11. 113
      util/src/main/java/com/ccsens/util/wx/WxGzhUtil.java
  12. 45
      util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java

42
game/src/main/java/com/ccsens/game/service/ScreenService.java

@ -18,18 +18,17 @@ import com.ccsens.game.bean.vo.ScreenVo;
import com.ccsens.game.persist.dao.*;
import com.ccsens.game.util.GameConstant;
import com.ccsens.game.util.SendMsg;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.ExcelUtil;
import com.ccsens.util.RedisUtil;
import com.ccsens.util.WebConstant;
import com.ccsens.util.*;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.util.exception.BaseException;
import com.ccsens.util.wx.WxXcxUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.extern.slf4j.Slf4j;
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,6 +75,8 @@ public class ScreenService implements IScreenService {
private SendMsg sendMsg;
@Resource
private RedisUtil redisUtil;
@Value("${spring.profiles.active}")
private String active;
/**
* 创建游戏
@ -111,15 +112,30 @@ public class ScreenService implements IScreenService {
gameRecord.setTaskId(memberGame.getTaskId());
gameRecord.setGameGroup((byte) 0);
//添加路径
String gameUrl = WebConstant.TEST_URL_GAME_SQ;
String gameUrl = PropUtil.notGatewayUrl + WebConstant.TEST_URL_GAME_SQ;
switch (gameType.getCode()){
case GameConstant.GAME_TYPE_SQ: break;
case GameConstant.GAME_TYPE_SP: gameUrl = WebConstant.TEST_URL_GAME_SP; break;
case GameConstant.GAME_TYPE_BH: gameUrl = WebConstant.TEST_URL_GAME_BH; break;
case GameConstant.GAME_TYPE_SP: gameUrl = PropUtil.notGatewayUrl + WebConstant.TEST_URL_GAME_SP; break;
case GameConstant.GAME_TYPE_BH: gameUrl = PropUtil.notGatewayUrl + WebConstant.TEST_URL_GAME_BH; break;
default:break;
}
gameRecord.setUrl(gameUrl + gameType.getScreenUrl() + "?id=" + gameRecord.getId());
gameRecord.setQrCodeUrl(gameUrl + gameRecord.getId() + File.separator + gameType.getClientUrl());
// gameRecord.setQrCodeUrl(gameUrl + gameRecord.getId() + File.separator + gameType.getClientUrl());
log.info("active:{}", active);
if ("prod".equals(active)) {
//生成二维码
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");
}
//查找此任务下的游戏配置表
byte businessType = 8;
if( GameConstant.GAME_TYPE_SP.equalsIgnoreCase(memberGame.getGameType())){
@ -232,7 +248,7 @@ public class ScreenService implements IScreenService {
}
//添加分组信息
if(gameRecord.getGameGroup() == 1){
for (int i = 8; i < sheet.getLastRowNum(); i++){
for (int i = 8; i <= sheet.getLastRowNum(); i++){
XSSFRow groupRow = sheet.getRow(i);
if(ObjectUtil.isNotNull(groupRow)){
String groupName = ExcelUtil.getCellValue(groupRow.getCell(0));
@ -428,7 +444,7 @@ public class ScreenService implements IScreenService {
ScreenVo.GameInfoVo gameInfoVo = new ScreenVo.GameInfoVo();
GameRecord gameRecord = getGameRecord(memberRecord.getMemberRecord());
log.info("查找游戏信息:{}",gameRecord);
log.info("查找游戏记录信息:{}",gameRecord);
GameUserPay gameUserPay = gameUserPayDao.selectByPrimaryKey(gameRecord.getUserPayId());
if (ObjectUtil.isNull(gameUserPay)) {
throw new BaseException(CodeEnum.NOT_GAME_TYPE);
@ -831,11 +847,11 @@ public class ScreenService implements IScreenService {
gameRecordNew.setUserPayId(gameUserPay.getId());
gameRecordNew.setGameStatus(GameConstant.GAME_PENDING);
//添加路径
String gameUrl = WebConstant.TEST_URL_GAME_SQ;
String gameUrl = PropUtil.notGatewayUrl + WebConstant.TEST_URL_GAME_SQ;
switch (gameType.getCode()){
case GameConstant.GAME_TYPE_SQ: break;
case GameConstant.GAME_TYPE_SP: gameUrl = WebConstant.TEST_URL_GAME_SP ; break;
case GameConstant.GAME_TYPE_BH: gameUrl = WebConstant.TEST_URL_GAME_BH; break;
case GameConstant.GAME_TYPE_SP: gameUrl = PropUtil.notGatewayUrl + WebConstant.TEST_URL_GAME_SP ; break;
case GameConstant.GAME_TYPE_BH: gameUrl = PropUtil.notGatewayUrl + WebConstant.TEST_URL_GAME_BH; break;
default:break;
}
gameRecordNew.setUrl(gameUrl + gameType.getScreenUrl() + "?id=" + gameRecordNew.getId());

3
game/src/main/resources/application-dev.yml

@ -27,3 +27,6 @@ spring:
swagger:
enable: true
gatewayUrl: https://test.tall.wiki/gateway/
notGatewayUrl: https://test.tall.wiki/
qrCode: https://test.tall.wiki/gateway/tall/uploads/

35
game/src/main/resources/application-prod.yml

@ -0,0 +1,35 @@
server:
port: 7050
servlet:
context-path:
spring:
application:
name: game
datasource:
type: com.alibaba.druid.pool.DruidDataSource
rabbitmq:
host: 127.0.0.1
password: 111111
port: 5672
username: admin
redis:
database: 0
host: 127.0.0.1
jedis:
pool:
max-active: 200
max-idle: 10
max-wait: -1ms
min-idle: 0
password: ''
port: 6379
timeout: 1000ms
swagger:
enable: true
eureka:
instance:
ip-address: 81.70.54.64
gatewayUrl: https://www.tall.wiki/gateway/
notGatewayUrl: https://www.tall.wiki/
qrCode: https://www.tall.wiki/gateway/tall/uploads/

6
game/src/main/resources/application-test.yml

@ -28,4 +28,8 @@ swagger:
enable: true
eureka:
instance:
ip-address: 192.168.0.99
ip-address: 192.168.0.99
gatewayUrl: https://test.tall.wiki/gateway/
notGatewayUrl: https://test.tall.wiki/
qrCode: https://test.tall.wiki/gateway/tall/uploads/

4
game/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring:
profiles:
active: test
include: common, util-test
active: dev
include: common, util-dev

4
health/src/main/java/com/ccsens/health/service/AsyncService.java

@ -2,7 +2,6 @@ package com.ccsens.health.service;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.health.bean.po.HealthRecords;
import com.ccsens.health.bean.vo.HealthVo;
import com.ccsens.health.util.HealthConstant;
import com.ccsens.util.PropUtil;
@ -10,7 +9,6 @@ import com.ccsens.util.RedisUtil;
import com.ccsens.util.WebConstant;
import com.ccsens.util.wx.WxXcxUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
@ -40,7 +38,7 @@ public class AsyncService implements IAsyncService {
String fileName = "/qrCode/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".png";
String path = WebConstant.UPLOAD_PATH_BASE+fileName;
WxXcxUtil.getWxCode(WebConstant.QRCODE_HEALTH
,scene,color,path);
,scene,color,path,"health");
String qrcodePath = PropUtil.qrCode + fileName;
log.info("二维码路径:{}", qrcodePath);
return new AsyncResult<String>(qrcodePath);

3
health/src/main/java/com/ccsens/health/service/ClockService.java

@ -20,7 +20,6 @@ import com.ccsens.util.exception.BaseException;
import com.ccsens.util.wx.WxXcxUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.netflix.discovery.provider.ISerializer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -297,7 +296,7 @@ public class ClockService implements IClockService {
String fileName = "/qrCode/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".png";
String path = WebConstant.UPLOAD_PATH_BASE + fileName;
WxXcxUtil.getWxCode(WebConstant.QRCODE_SITE
, "d=" + siteQrcode.getId() + "&t=" + createQRCode.getType(), null, path);
, "d=" + siteQrcode.getId() + "&t=" + createQRCode.getType(), null, path,"health");
qrcodePath = PropUtil.qrCode + fileName;
log.info("调用微信生成二维码");
} else {

5
mt/src/main/resources/application-prod.yml

@ -28,4 +28,7 @@ swagger:
enable: true
eureka:
instance:
ip-address: 81.70.54.64
ip-address: 81.70.54.64
gatewayUrl: https://www.tall.wiki/gateway/
notGatewayUrl: https://www.tall.wiki/

3
mt/src/main/resources/application-test.yml

@ -28,4 +28,5 @@ swagger:
enable: true
eureka:
instance:
ip-address: 192.168.0.99
ip-address: 192.168.0.99

7
util/src/main/java/com/ccsens/util/WebConstant.java

@ -186,9 +186,9 @@ public class WebConstant {
// public static final String URL_BASE = "https://api.ccsens.com/ptpro/uploads/";
public static final String TEST_URL = "https://test.tall.wiki/";
public static final String TEST_URL_GAME_SQ = TEST_URL + "game-dev/";
public static final String TEST_URL_GAME_SP = TEST_URL + "game-sp/";
public static final String TEST_URL_GAME_BH = TEST_URL + "game-bh/";
public static final String TEST_URL_GAME_SQ = "game-dev/";
public static final String TEST_URL_GAME_SP = "game-sp/";
public static final String TEST_URL_GAME_BH = "game-bh/";
public static final String TALL_UPLOADS = "tall/v1.0/uploads/";
public static final String TEST_URL_BASE = TEST_URL + "gateway/" + TALL_UPLOADS;
@ -198,6 +198,7 @@ public class WebConstant {
public static final String QRCODE_HEALTH = "pages/user-code/user-code";
public static final String QRCODE_SITE = "pages/sign/sign";
public static final String QRCODE_GAME = "pages/index/index";
public static final Integer Expired_Verify_Code_In_Seconds = 120;
public static final Integer Exist_Verify_Code_In_Seconds = 60;

113
util/src/main/java/com/ccsens/util/wx/WxGzhUtil.java

@ -1,7 +1,6 @@
package com.ccsens.util.wx;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
@ -9,11 +8,12 @@ import com.ccsens.util.DateUtil;
import com.ccsens.util.JacksonUtil;
import com.ccsens.util.RedisUtil;
import com.ccsens.util.WebConstant;
import com.ccsens.util.bean.wx.po.*;
import com.ccsens.util.bean.wx.po.WxAccessToken;
import com.ccsens.util.bean.wx.po.WxOauth2AccessToken;
import com.ccsens.util.bean.wx.po.WxOauth2UserInfo;
import com.ccsens.util.exception.BaseException;
import com.ccsens.util.exception.BusinessException;
import com.ccsens.util.exception.WxException;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -24,7 +24,6 @@ import javax.annotation.Resource;
import java.io.IOException;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Map;
/**
* @author __zHangSan
@ -210,11 +209,11 @@ public class WxGzhUtil {
/**
* 获取Access_token
*/
public static String getAccessToken() throws BaseException {
public static String getAccessToken(String appId,String secret) throws BaseException {
Object obj = util.redisUtil.get(WebConstant.Wx.ACCESS_TOKEN);
if(obj == null || StrUtil.isBlank((String)obj) ){
WxAccessToken wxAccessToken = null;
String url = String.format(URL_GET_ACCESS_TOKEN,"client_credential",appid_health,secret_health);
String url = String.format(URL_GET_ACCESS_TOKEN,"client_credential",appId,secret);
String response = HttpRequest.get(url).execute().body();
log.info("getAccessToken: {}",response);
try {
@ -238,50 +237,50 @@ public class WxGzhUtil {
logger.info("读取reids的token:{}", obj);
return (String)obj;
}
/**
* 查询微信公众号底部菜单
*/
public static String queryMenu() throws BaseException {
String url = String.format(URL_QUERY_MENU,getAccessToken());
String menuString = HttpRequest.get(url).execute().body();
log.info("url:{}, menuString: {}",url,menuString);
return menuString;
}
/**
* 创建微信公众号底部菜单
*/
public static void createMenu(WxGzhMenu gzhMenu) throws BaseException {
String url = String.format(URL_CREATE_MENU,getAccessToken());
String menuString = null;
try {
menuString = JacksonUtil.beanToJson(gzhMenu);
log.info(menuString);
} catch (JsonProcessingException e) {
e.printStackTrace();
throw new BusinessException(-1,e.getMessage());
}
String response = HttpRequest.post(url).body(menuString).execute().body();
if(StrUtil.isEmpty(response)){
throw new BusinessException(-1,"the response of HttpRequest is empty.");
}
Map<String,Object> map = null;
try {
map = JacksonUtil.jsonToMap(response);
} catch (IOException e) {
throw new BusinessException(-1,e.getMessage());
}
Object errcode = map.get("errcode");
if(errcode == null || ((Integer)errcode) != 0) {
throw new WxException((Integer)errcode,(String)map.get("errmsg"));
}
}
public static String getAuthedUrl(String url, WxGzhAuthType wxGzhAuthType){
return String.format(GZH_AUTH_URL,APPID, URLUtil.encode(url),wxGzhAuthType.getText());
}
//
// /**
// * 查询微信公众号底部菜单
// */
// public static String queryMenu() throws BaseException {
// String url = String.format(URL_QUERY_MENU,getAccessToken());
// String menuString = HttpRequest.get(url).execute().body();
// log.info("url:{}, menuString: {}",url,menuString);
// return menuString;
// }
// /**
// * 创建微信公众号底部菜单
// */
// public static void createMenu(WxGzhMenu gzhMenu) throws BaseException {
// String url = String.format(URL_CREATE_MENU,getAccessToken());
// String menuString = null;
// try {
// menuString = JacksonUtil.beanToJson(gzhMenu);
// log.info(menuString);
// } catch (JsonProcessingException e) {
// e.printStackTrace();
// throw new BusinessException(-1,e.getMessage());
// }
// String response = HttpRequest.post(url).body(menuString).execute().body();
// if(StrUtil.isEmpty(response)){
// throw new BusinessException(-1,"the response of HttpRequest is empty.");
// }
// Map<String,Object> map = null;
// try {
// map = JacksonUtil.jsonToMap(response);
// } catch (IOException e) {
// throw new BusinessException(-1,e.getMessage());
// }
//
// Object errcode = map.get("errcode");
// if(errcode == null || ((Integer)errcode) != 0) {
// throw new WxException((Integer)errcode,(String)map.get("errmsg"));
// }
// }
//
// public static String getAuthedUrl(String url, WxGzhAuthType wxGzhAuthType){
// return String.format(GZH_AUTH_URL,APPID, URLUtil.encode(url),wxGzhAuthType.getText());
// }
/**
* 获取网页授权凭证
@ -351,11 +350,15 @@ public class WxGzhUtil {
return getOauth2UserInfo(wxOauth2AccessToken.getAccessToken(),wxOauth2AccessToken.getOpenId());
}
public static void sendTemplate(WxTemplateMessage message) {
String url = String.format(MESSAGE_TEMPLATE_SEND,getAccessToken());
String response = HttpRequest.post(url).body(JSONObject.toJSONString(message)).execute().body();
pageResponseSuccess(response);
}
// /**
// * 发送消息模板
// * @param message
// */
// public static void sendTemplate(WxTemplateMessage message) {
// String url = String.format(MESSAGE_TEMPLATE_SEND,getAccessToken());
// String response = HttpRequest.post(url).body(JSONObject.toJSONString(message)).execute().body();
// pageResponseSuccess(response);
// }
/**
* 判断结果是否正确 错误抛异常errcode!=0为错误

45
util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java

@ -3,7 +3,6 @@ package com.ccsens.util.wx;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.ccsens.util.HttpsUtil;
import com.ccsens.util.JacksonUtil;
import com.ccsens.util.WebConstant;
@ -16,7 +15,6 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.ConnectException;
import java.nio.Buffer;
import java.util.*;
@Data
@ -230,13 +228,14 @@ public class WxXcxUtil {
/**
* 获取小程序二维码/小程序码
* 获取小程序二维码/小程序码小程序码
* @param code 不同的小程序的code
* @return
* @throws Exception
*/
public static void getWxCode(String page,String scene,LineColor color,String path) throws Exception {
public static void getWxCode(String page,String scene,LineColor color,String path,String code) throws Exception {
String url = String.format(URL_GET_WX_CODE_B, WxGzhUtil.getAccessToken());
String url = String.format(URL_GET_WX_CODE_B, WxGzhUtil.getAccessToken(appId(code),secret(code)));
WechatCode wechatCode = new WechatCode();
wechatCode.page = page;
@ -251,24 +250,24 @@ public class WxXcxUtil {
}
/**
* 获取小程序二维码/小程序码(长度128有数量限制)
* @return
* @throws Exception
*/
public static void getWxCodeTest(String page,String scene,LineColor color,String path) throws Exception {
String url = String.format(URL_GET_WX_CODE_C, WxGzhUtil.getAccessToken());
WechatCodeA wechatCodeA = new WechatCodeA();
wechatCodeA.path = page;
// wechatCode.path = page+"?"+scene;
// WechatCodeA.line_color = color;
String postStr = JacksonUtil.beanToJson(wechatCodeA);
System.out.println(postStr);
HttpsUtil.httpsRequest(url,"POST",postStr,path);
}
// /**
// * 获取小程序二维码/小程序码(长度128,有数量限制)(二维码)
// * @return
// * @throws Exception
// */
// public static void getWxCodeTest(String page,String scene,LineColor color,String path) throws Exception {
// String url = String.format(URL_GET_WX_CODE_C, WxGzhUtil.getAccessToken());
//
// WechatCodeA wechatCodeA = new WechatCodeA();
// wechatCodeA.path = page;
//// wechatCode.path = page+"?"+scene;
//
//// WechatCodeA.line_color = color;
//
// String postStr = JacksonUtil.beanToJson(wechatCodeA);
// System.out.println(postStr);
// HttpsUtil.httpsRequest(url,"POST",postStr,path);
// }
/**
* 统一下单

Loading…
Cancel
Save