Commit b368f500 authored by 赵然's avatar 赵然

zr

parent 3c5bb45a
......@@ -31,9 +31,6 @@ public class RankModule {
ViewService viewService;
final Base64.Decoder decoder = Base64.getDecoder();
private static String next_reset_time2;
private static String next_op_time2;
/**
* 功能:清除排行榜指定期次的开奖记录
......@@ -366,10 +363,16 @@ public class RankModule {
String start_time2 = this.getTime(start_time,rolldays * (-1));
String end_time2 = this.getTime(end_time,rolldays * (-1));
if(next_reset_time!=null&&next_reset_time!=""&&next_reset_time != "null"){
next_reset_time2 = this.getTime(next_reset_time,rolldays * (-1));
String next_reset_time2 = this.getTime(next_reset_time,rolldays * (-1));
String sqlconfig1 = "update projectx.tb_leaderboard_config set next_reset_time = '" + next_reset_time2 + "' where project_id = '" + projectId + "'";
System.out.println(sqlconfig1);
sqlService.update(sqlconfig1);
}
if(next_op_time!=null&&next_op_time!=""&&next_op_time != "null") {
next_op_time2 = this.getTime(next_op_time,rolldays * (-1));
String next_op_time2 = this.getTime(next_op_time,rolldays * (-1));
String sqlconfig2 = "update projectx.tb_leaderboard_config set next_op_time = '" + next_op_time2 + "' where project_id = '" + projectId + "'";
System.out.println(sqlconfig2);
sqlService.update(sqlconfig2);
}
//截取current_ranking_type的年月日:4_2020-03-31
String dataString = current_ranking_type.substring(current_ranking_type.indexOf("_")+1).trim();
......@@ -377,18 +380,95 @@ public class RankModule {
String current_ranking_type2 = id.concat("_").concat(dataStringDeal);
//开始更新tb_leaderboard_config
if(next_reset_time!=null&&next_reset_time!=""&&next_reset_time != "null") {
String sqlconfig3 = "update projectx.tb_leaderboard_config set start_time = '" + start_time2 + "',end_time = '" + end_time2 + "',current_ranking_type='" + current_ranking_type2 + "' where project_id = '" + projectId + "'";
System.out.println(sqlconfig3);
sqlService.update(sqlconfig3);
//开始处理tb_leaderboard_archive表的时间:ranking_type、ranking_name、start_join_time、start_time、end_time
String sqlarchive = "SELECT ranking_type,ranking_name,start_join_time,start_time,end_time FROM projectx.tb_leaderboard_archive where project_id = '"+projectId+"'";
Response response3 = sqlService.findModeResult(sqlarchive);
JSONArray archive = JSONArray.parseArray(response3.asString());
for (int i =0;i<archive.size();i++) {
//获取tb_leaderboard_archive初始数据
String ranking_type = archive.getJSONObject(i).getString("ranking_type");
//String ranking_name = config.getJSONObject(i).getString("ranking_name");
String start_join_time = archive.getJSONObject(i).getString("start_join_time");
String start_time_archive = archive.getJSONObject(i).getString("start_time");
String end_time_archive = archive.getJSONObject(i).getString("end_time");
//开始计算推移tb_leaderboard_archive
String start_join_time_ar = this.getTime(start_join_time,rolldays * (-1));
String start_time_archive_ar = this.getTime(start_time_archive,rolldays * (-1));
String end_time_archive_ar = this.getTime(end_time_archive,rolldays * (-1));
//截取ranking_type的年月日:4_2020-03-31
String dataString_ar = ranking_type.substring(ranking_type.indexOf("_")+1).trim();
String dataStringDeal_ar = this.getTime2(dataString_ar,rolldays * (-1));
String ranking_type2 = id.concat("_").concat(dataStringDeal_ar);
String ranking_name2 = dataStringDeal_ar.concat("期");
//开始更新tb_leaderboard_archive
String sqlconfig4 = "update projectx.tb_leaderboard_archive set ranking_type = '" + ranking_type2 + "',ranking_name = '" + ranking_name2 + "',start_join_time='" + start_time_archive_ar + "',start_time='" + start_join_time_ar + "',end_time='" + end_time_archive_ar + "' where project_id = '" + projectId + "' and ranking_type = '"+ranking_type+"'";
System.out.println(sqlconfig4);
sqlService.update(sqlconfig4);
}
Map<String, String> map = new HashMap<>();
map.put("success", "true");
map.put("message", "排行榜周期推移成功!");
return map;
}
/**
* 功能:排行榜期次周期推移(往前移)
* @return
*/
@RequestMapping(value = "/typeRollForward", method= RequestMethod.POST)
@ResponseBody
public Map typeRollForward(HttpServletRequest request) throws Exception {
String projectId = request.getParameter("projectId");
int rolldays = Integer.valueOf(request.getParameter("rolldays"));
String rolldata = request.getParameter("rolldata");
//开始处理tb_leaderboard_config表的时间:start_time、end_time、next_reset_time、next_op_time、current_ranking_type
String sql = "SELECT id,start_time,end_time,next_reset_time,next_op_time,current_ranking_type FROM projectx.tb_leaderboard_config where project_id = '"+projectId+"'";
Response response2 = sqlService.findModeResult(sql);
JSONArray config = JSONArray.parseArray(response2.asString());
//获取tb_leaderboard_config初始数据
String id = config.getJSONObject(0).getString("id");
String start_time = config.getJSONObject(0).getString("start_time");
String end_time = config.getJSONObject(0).getString("end_time");
String next_reset_time = config.getJSONObject(0).getString("next_reset_time");
String next_op_time = config.getJSONObject(0).getString("next_op_time");
String current_ranking_type = config.getJSONObject(0).getString("current_ranking_type");
//开始计算推移tb_leaderboard_config
String start_time2 = this.getTime(start_time,rolldays*(-1) );
String end_time2 = this.getTime(end_time,rolldays*(-1) );
if(next_reset_time!=null&&next_reset_time!=""&&next_reset_time != "null"){
String next_reset_time2 = this.getTime(next_reset_time,rolldays*(-1) );
String sqlconfig1 = "update projectx.tb_leaderboard_config set next_reset_time = '" + next_reset_time2 + "' where project_id = '" + projectId + "'";
System.out.println(sqlconfig1);
sqlService.update(sqlconfig1);
}
if(next_op_time!=null&&next_op_time!=""&&next_op_time != "null"){
if(next_op_time!=null&&next_op_time!=""&&next_op_time != "null") {
String next_op_time2 = this.getTime(next_op_time,rolldays *(-1));
String sqlconfig2 = "update projectx.tb_leaderboard_config set next_op_time = '" + next_op_time2 + "' where project_id = '" + projectId + "'";
System.out.println(sqlconfig2);
sqlService.update(sqlconfig2);
}
//截取current_ranking_type的年月日:4_2020-03-31
if(current_ranking_type!=null&&current_ranking_type!=""&&current_ranking_type != "null") {
String dataString = current_ranking_type.substring(current_ranking_type.indexOf("_") + 1).trim();
String dataStringDeal = this.getTime2(dataString, rolldays*(-1));
String current_ranking_type2 = id.concat("_").concat(dataStringDeal);
String sqlconfig3 = "update projectx.tb_leaderboard_config set current_ranking_type = '" + current_ranking_type2 + "' where project_id = '" + projectId + "'";
System.out.println(sqlconfig3);
sqlService.update(sqlconfig3);
}
String sqlconfig3 = "update projectx.tb_leaderboard_config set start_time = '" + start_time2 + "',end_time = '" + end_time2 + "',current_ranking_type='" + current_ranking_type2 + "' where project_id = '" + projectId + "'";
//开始更新tb_leaderboard_config
String sqlconfig3 = "update projectx.tb_leaderboard_config set start_time = '" + start_time2 + "',end_time = '" + end_time2 + "' where project_id = '" + projectId + "'";
System.out.println(sqlconfig3);
sqlService.update(sqlconfig3);
......@@ -406,12 +486,12 @@ public class RankModule {
String end_time_archive = archive.getJSONObject(i).getString("end_time");
//开始计算推移tb_leaderboard_archive
String start_join_time_ar = this.getTime(start_join_time,rolldays * (-1));
String start_time_archive_ar = this.getTime(start_time_archive,rolldays * (-1));
String end_time_archive_ar = this.getTime(end_time_archive,rolldays * (-1));
//截取ranking_type的年月日:4_2020-03-31
String dataString_ar = ranking_type.substring(ranking_type.indexOf("_")+1).trim();
String dataStringDeal_ar = this.getTime2(dataString_ar,rolldays * (-1));
String start_join_time_ar = this.getTime(start_join_time,rolldays*(-1) );
String start_time_archive_ar = this.getTime(start_time_archive,rolldays*(-1) );
String end_time_archive_ar = this.getTime(end_time_archive,rolldays *(-1));
//截取ranking_type的年月日:4_2020-03-31
String dataString_ar = ranking_type.substring(ranking_type.indexOf("_")+1).trim();
String dataStringDeal_ar = this.getTime2(dataString_ar,rolldays *(-1));
String ranking_type2 = id.concat("_").concat(dataStringDeal_ar);
String ranking_name2 = dataStringDeal_ar.concat("期");
......@@ -421,6 +501,24 @@ public class RankModule {
sqlService.update(sqlconfig4);
}
if(rolldata.equals("true")){
//开始处理tb_ranking表的周期
String sqlranking = "SELECT type FROM projectx.tb_ranking where project_id = '"+projectId+"'";
Response response4 = sqlService.findModeResult(sqlranking);
JSONArray rankingdata = JSONArray.parseArray(response4.asString());
for (int i =0;i<rankingdata.size();i++) {
//获取type初始数据
String type = rankingdata.getJSONObject(i).getString("type");
String typespit = type.substring(type.indexOf("_")+1).trim();
String typedeal = this.getTime2(typespit,rolldays*(-1) );
String typeRoll = id.concat("_").concat(typedeal);
//开始更新tb_ranking
String sqlRanking = "update projectx.tb_ranking set type = '" + typeRoll + "' where project_id = '" + projectId + "' and type = '"+type+"'";
System.out.println(sqlRanking);
sqlService.update(sqlRanking);
}
}
Map<String, String> map = new HashMap<>();
map.put("success", "true");
......@@ -428,6 +526,111 @@ public class RankModule {
return map;
}
/**
* 功能:排行榜期次周期推移(往后移)
* @return
*/
@RequestMapping(value = "/typeRollBackward", method= RequestMethod.POST)
@ResponseBody
public Map typeRollBackward(HttpServletRequest request) throws Exception {
String projectId = request.getParameter("projectId");
int rolldays = Integer.valueOf(request.getParameter("rolldays"));
String rolldata = request.getParameter("rolldata");
//开始处理tb_leaderboard_config表的时间:start_time、end_time、next_reset_time、next_op_time、current_ranking_type
String sql = "SELECT id,start_time,end_time,next_reset_time,next_op_time,current_ranking_type FROM projectx.tb_leaderboard_config where project_id = '"+projectId+"'";
Response response2 = sqlService.findModeResult(sql);
JSONArray config = JSONArray.parseArray(response2.asString());
//获取tb_leaderboard_config初始数据
String id = config.getJSONObject(0).getString("id");
String start_time = config.getJSONObject(0).getString("start_time");
String end_time = config.getJSONObject(0).getString("end_time");
String next_reset_time = config.getJSONObject(0).getString("next_reset_time");
String next_op_time = config.getJSONObject(0).getString("next_op_time");
String current_ranking_type = config.getJSONObject(0).getString("current_ranking_type");
//开始计算推移tb_leaderboard_config
String start_time2 = this.getTime(start_time,rolldays );
String end_time2 = this.getTime(end_time,rolldays);
if(next_reset_time!=null&&next_reset_time!=""&&next_reset_time != "null"){
String next_reset_time2 = this.getTime(next_reset_time,rolldays);
String sqlconfig1 = "update projectx.tb_leaderboard_config set next_reset_time = '" + next_reset_time2 + "' where project_id = '" + projectId + "'";
System.out.println(sqlconfig1);
sqlService.update(sqlconfig1);
}
if(next_op_time!=null&&next_op_time!=""&&next_op_time != "null") {
String next_op_time2 = this.getTime(next_op_time,rolldays);
String sqlconfig2 = "update projectx.tb_leaderboard_config set next_op_time = '" + next_op_time2 + "' where project_id = '" + projectId + "'";
System.out.println(sqlconfig2);
sqlService.update(sqlconfig2);
}
//截取current_ranking_type的年月日:4_2020-03-31
if(current_ranking_type!=null&&current_ranking_type!=""&&current_ranking_type != "null") {
String dataString = current_ranking_type.substring(current_ranking_type.indexOf("_") + 1).trim();
String dataStringDeal = this.getTime2(dataString, rolldays);
String current_ranking_type2 = id.concat("_").concat(dataStringDeal);
String sqlconfig3 = "update projectx.tb_leaderboard_config set current_ranking_type = '" + current_ranking_type2 + "' where project_id = '" + projectId + "'";
System.out.println(sqlconfig3);
sqlService.update(sqlconfig3);
}
//开始更新tb_leaderboard_config
String sqlconfig3 = "update projectx.tb_leaderboard_config set start_time = '" + start_time2 + "',end_time = '" + end_time2 + "' where project_id = '" + projectId + "'";
System.out.println(sqlconfig3);
sqlService.update(sqlconfig3);
//开始处理tb_leaderboard_archive表的时间:ranking_type、ranking_name、start_join_time、start_time、end_time
String sqlarchive = "SELECT ranking_type,ranking_name,start_join_time,start_time,end_time FROM projectx.tb_leaderboard_archive where project_id = '"+projectId+"'";
Response response3 = sqlService.findModeResult(sqlarchive);
JSONArray archive = JSONArray.parseArray(response3.asString());
for (int i = archive.size()-1; i>=0; i--) {
//获取tb_leaderboard_archive初始数据
String ranking_type = archive.getJSONObject(i).getString("ranking_type");
//String ranking_name = config.getJSONObject(i).getString("ranking_name");
String start_join_time = archive.getJSONObject(i).getString("start_join_time");
String start_time_archive = archive.getJSONObject(i).getString("start_time");
String end_time_archive = archive.getJSONObject(i).getString("end_time");
//开始计算推移tb_leaderboard_archive
String start_join_time_ar = this.getTime(start_join_time,rolldays );
String start_time_archive_ar = this.getTime(start_time_archive,rolldays );
String end_time_archive_ar = this.getTime(end_time_archive,rolldays);
//截取ranking_type的年月日:4_2020-03-31
String dataString_ar = ranking_type.substring(ranking_type.indexOf("_")+1).trim();
String dataStringDeal_ar = this.getTime2(dataString_ar,rolldays);
String ranking_type2 = id.concat("_").concat(dataStringDeal_ar);
String ranking_name2 = dataStringDeal_ar.concat("期");
//开始更新tb_leaderboard_archive
String sqlconfig4 = "update projectx.tb_leaderboard_archive set ranking_type = '" + ranking_type2 + "',ranking_name = '" + ranking_name2 + "',start_join_time='" + start_time_archive_ar + "',start_time='" + start_join_time_ar + "',end_time='" + end_time_archive_ar + "' where project_id = '" + projectId + "' and ranking_type = '"+ranking_type+"'";
System.out.println(sqlconfig4);
sqlService.update(sqlconfig4);
}
if(rolldata.equals("true")){
//开始处理tb_ranking表的周期
String sqlranking = "SELECT type FROM projectx.tb_ranking where project_id = '"+projectId+"'";
Response response4 = sqlService.findModeResult(sqlranking);
JSONArray rankingdata = JSONArray.parseArray(response4.asString());
for (int i = rankingdata.size()-1; i>=0; i--) {
//获取type初始数据
String type = rankingdata.getJSONObject(i).getString("type");
String typespit = type.substring(type.indexOf("_")+1).trim();
String typedeal = this.getTime2(typespit,rolldays);
String typeRoll = id.concat("_").concat(typedeal);
//开始更新tb_ranking
String sqlRanking = "update projectx.tb_ranking set type = '" + typeRoll + "' where project_id = '" + projectId + "' and type = '"+type+"'";
System.out.println(sqlRanking);
sqlService.update(sqlRanking);
}
}
Map<String, String> map = new HashMap<>();
map.put("success", "true");
map.put("message", "排行榜周期推移成功!");
return map;
}
/**
* 功能:排行榜自动开奖辅助
......
package main.com.atguigu.springmvc.handlers;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import io.restassured.response.Response;
import main.com.atguigu.springmvc.service.Authorization;
import main.com.atguigu.springmvc.service.NewActivityService;
import main.com.atguigu.springmvc.service.SqlService;
import main.com.atguigu.springmvc.service.ViewService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@Controller
public class WechatInfoModule {
@Autowired
NewActivityService newActivityService;
@Autowired
Authorization authorization;
@Autowired
SqlService sqlService;
@Autowired
ViewService viewService;
/**
* 功能:通过actId和appId查询配置的关注带参二维码公众号后发送的消息
* @return
*/
@RequestMapping(value = "/qrcodeInfo", method= RequestMethod.POST)
@ResponseBody
public Map qrcodeInfo(HttpServletRequest request ) throws Exception{
String appId = request.getParameter("appId");
String actId = request.getParameter("actId");
Map<String, Object> map = new HashMap<>();
StringBuilder sb = new StringBuilder();
sb.append("SELECT id,act_id,app_id,reply_text,reply_url,gmt_modified FROM wechat.tb_wx_reply_config where ");
if(StringUtils.isNotBlank(actId)) {
//如果actId是星宿台项目,则将actId转化成10进制字符串
if (actId.startsWith("p")){
actId = decodeHEX(actId.substring(1, actId.length()));
}
sb.append("act_id='").append(actId).append("' and ");
}
if(StringUtils.isNotBlank(appId)) {
sb.append("app_id='").append(appId).append("' and ");
}
sb.append("1=1 order by id desc");
//System.out.println(sb.toString());
Response response = sqlService.findModeResult(sb.toString());
if(response.asString().equals("[]")) {
map.put("success", "false");
map.put("message", "未查询到消息");
} else {
JSONArray ar = JSONArray.parseArray(response.asString());
map.put("success", "true");
map.put("message", ar);
}
return map;
}
/**
* 功能:新增关注带参二维码公众号后发送的消息
* @return
*/
@RequestMapping(value = "/createqrcodeInfo", method= RequestMethod.POST)
@ResponseBody
public Map createqrcodeInfo(HttpServletRequest request ) throws Exception {
String originalActId = request.getParameter("actId");
//如果actId是星宿台项目,则将actId转化成10进制字符串
if (originalActId.startsWith("p")){
originalActId = decodeHEX(originalActId.substring(1, originalActId.length()));
}
String actId = originalActId;
String appId = request.getParameter("appId");
String actType = request.getParameter("actType");
String replyText = request.getParameter("replyText");
String replyText0 = "<a href=\"{1}\">"+replyText+"</a>";
String replyUrl = request.getParameter("replyUrl");
Map<String, Object> map = new HashMap<>();
String sql1 = "SELECT act_id,app_id FROM wechat.tb_wx_reply_config";
Response response1 = sqlService.findModeResult(sql1);
//System.out.println(response1.asString());
List<InfoVO> infoVOList = Collections.emptyList();
if(response1.asString() != null && StringUtils.isNotBlank(response1.asString())) {
infoVOList = JSON.parseArray(response1.asString(), InfoVO.class);
}
if(StringUtils.isBlank(actId)|| StringUtils.isBlank(appId)|| StringUtils.isBlank(actType)|| StringUtils.isBlank(replyText)|| StringUtils.isBlank(replyUrl)){
map.put("success", "false");
map.put("message", "请填写所有信息!");
}else if(infoVOList.stream().anyMatch(infoVO -> Objects.equals(actId, infoVO.getActId()) && Objects.equals(appId, infoVO.getAppId()))) {
//判断输入的appid下已有该actid的消息,则不执行插入;否则执行插入
map.put("success", "false");
map.put("message", "当前appid下已有该actid的消息");
}else{
String sql2 = "insert into wechat.tb_wx_reply_config (act_id,app_id,act_type,reply_text,reply_url)values(" + actId + ",'" + appId + "','"+actType+"','" + replyText0 + "','" + replyUrl + "')";
sqlService.update(sql2);
map.put("success", "true");
map.put("message", "消息配置成功!");
}
return map;
}
public static class InfoVO {
private String actId;
private String appId;
public String getActId() {
return actId;
}
public void setActId(String actId) {
this.actId = actId;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
}
/**
* 功能:修改关注带参二维码公众号后发送的消息
* @return
*/
@RequestMapping(value = "/updateqrcodeInfo", method= RequestMethod.POST)
@ResponseBody
public Map updateqrcodeInfo(HttpServletRequest request ) throws Exception{
String id=request.getParameter("id");
String originalActId=request.getParameter("actId");
//如果actId是星宿台项目,则将actId转化成10进制字符串
if (originalActId.startsWith("p")){
originalActId = decodeHEX(originalActId.substring(1, originalActId.length()));
}
String actId = originalActId;
String appId=request.getParameter("appId");
String actType=request.getParameter("actType");
String replyText=request.getParameter("replyText");
String replyText0 = "<a href=\"{1}\">"+replyText+"</a>";
String replyUrl=request.getParameter("replyUrl");
Map<String, Object> map = new HashMap<>();
if(StringUtils.isBlank(id)){
map.put("success", "false");
map.put("message", "请输入id!");
}else{
boolean needUpdate = false;
StringBuilder sb = new StringBuilder();
sb.append("update wechat.tb_wx_reply_config set ");
if(StringUtils.isNotBlank(actId)) {
needUpdate = true;
sb.append("act_id='").append(actId).append("',");
}
if(StringUtils.isNotBlank(appId)) {
needUpdate = true;
sb.append("app_id='").append(appId).append("',");
}
if(StringUtils.isNotBlank(actType)) {
needUpdate = true;
sb.append("act_type='").append(actType).append("',");
}
if(StringUtils.isNotBlank(replyText)) {
needUpdate = true;
sb.append("reply_text='").append(replyText0).append("',");
}
if(StringUtils.isNotBlank(replyUrl)) {
needUpdate = true;
sb.append("reply_url='").append(replyUrl).append("',");
}
sb.append("id='").append(id).append("'");
sb.append(" where id=").append(id);
//System.out.println(sb.toString());
String sql3 = "SELECT act_id,app_id FROM wechat.tb_wx_reply_config";
Response response3 = sqlService.findModeResult(sql3);
List<InfoVO> infoVOList = Collections.emptyList();
if(response3.asString() != null && StringUtils.isNotBlank(response3.asString())) {
infoVOList = JSON.parseArray(response3.asString(), InfoVO.class);
}
if(!needUpdate) {
map.put("success", "false");
map.put("message", "请输入要修改的内容!");
} else if(infoVOList.stream().anyMatch(infoVO -> Objects.equals(actId, infoVO.getActId()) && Objects.equals(appId, infoVO.getAppId()))) {
//判断输入的appid下已有该actid的消息,则不执行插入;否则执行插入
map.put("success", "false");
map.put("message", "当前appid下已有该actid的消息");
}else {
sqlService.update(sb.toString());
map.put("success", "true");
map.put("message", "消息修改成功!");
}
}
return map;
}
//将16进制字符串转化为10进制数字的字符串
public static String decodeHEX(String hexs){
int numb=Integer.parseInt(hexs,16);
String actID=Integer.toString(numb);
return actID;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment