Commit b6786341 authored by 赵然's avatar 赵然

zr

parent 580cc254
...@@ -49,6 +49,8 @@ public class CreatUrlModule { ...@@ -49,6 +49,8 @@ public class CreatUrlModule {
credits = "0"; credits = "0";
} }
String dcustom = request.getParameter("dcustom"); String dcustom = request.getParameter("dcustom");
String type = request.getParameter("type");
String transfer = request.getParameter("transfer"); String transfer = request.getParameter("transfer");
String redirect = request.getParameter("redirect"); String redirect = request.getParameter("redirect");
String phone = request.getParameter("phone"); String phone = request.getParameter("phone");
...@@ -69,7 +71,11 @@ public class CreatUrlModule { ...@@ -69,7 +71,11 @@ public class CreatUrlModule {
params.put("uid",userId); params.put("uid",userId);
params.put("credits",credits); params.put("credits",credits);
if(dcustom!=null&&dcustom!=""&&dcustom != "null") { if(dcustom!=null&&dcustom!=""&&dcustom != "null") {
params.put("dcustom", URLEncoder.encode( dcustom, "UTF-8" )); if(type.equals("1")||type == null) {
params.put("dcustom", dcustom);
}else {
params.put("dcustom", URLEncoder.encode(dcustom, "UTF-8"));
}
} }
if(transfer!=null&&transfer!=""&&transfer != "null"){ if(transfer!=null&&transfer!=""&&transfer != "null"){
params.put("transfer",transfer); params.put("transfer",transfer);
......
package main.com.atguigu.springmvc.handlers;
import com.alibaba.fastjson.JSONArray;
import io.restassured.response.Response;
import main.com.atguigu.springmvc.common.MatcherString;
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.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.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
@Controller
public class RankModule {
@Autowired
NewActivityService newActivityService;
@Autowired
Authorization authorization;
@Autowired
SqlService sqlService;
@Autowired
ViewService viewService;
final Base64.Decoder decoder = Base64.getDecoder();
/**
* 功能:清除排行榜指定期次的开奖记录
* @return
*/
@RequestMapping(value = "/clearPrize", method= RequestMethod.POST)
@ResponseBody
public Map clearPrize(HttpServletRequest request) throws Exception {
String projectId = request.getParameter("projectId");
String type = request.getParameter("type");
System.out.println("项目id:" + projectId);
System.out.println("期次id:" + type);
Map<String, String> map = new HashMap<>();
String sql = "select * from projectx.tb_ranking_config where project_id='"+projectId+"' and type = '"+type+"'";
Response response = sqlService.findSimpleResult(sql);
System.out.println("查询结果为:" + response.asString());
if (response.asString().equals("{}")) {
map.put("success", "true");
map.put("message", "该期次无排行榜信息!");
}else {
try {
//sqlService.update("update ckvtable.tb_kvtable_"+tag+" set int_value = '"+count+"' where consumer_id = '"+consumerId+"' and vkey = 'cl_good_cid_itemId_"+consumerId+"_"+cardId+"'");
sqlService.update("update projectx.tb_ranking_config set send_prize='1',send_prize_time = NULL where project_id ='"+projectId+"' and type = '"+type+"'");
Thread.sleep(1000);
sqlService.update("update projectx.tb_ranking set prize_id=NULL,send_prize='0',send_prize_time = null where project_id ='"+projectId+"' and type = '"+type+"'");
map.put("success", "true");
map.put("message", "期次"+type+"的开奖记录清除成功!");
} catch (Exception e) {
map.put("success", "false");
map.put("message", "清除开奖数据失败!");
}
}
return map;
}
/**
* 功能:构建排行榜数据
* @return
*/
@RequestMapping(value = "/creatRankData", method= RequestMethod.POST)
@ResponseBody
public Map creatRankData(HttpServletRequest request) throws Exception {
String projectId = request.getParameter("projectId");
String type = request.getParameter("type");
System.out.println("项目id:" + projectId);
System.out.println("期次id:" + type);
String uids = request.getParameter("uids");
String[] uidParams = uids.split(",");
String[] consumerIds = new String[20];
for (int i = 0; i < uidParams.length; i++) {
//将userid转consumerid
Map<String, String> login_map = authorization.dafuwengLogin(Integer.parseInt(uidParams[i]));
//System.out.println("用户login_map为:" + login_map.toString());
String consumer_base64 = String.valueOf(login_map.get("_ac"));
//System.out.println("用户consumer_base64为:" + consumer_base64);
String decodedText = new String(decoder.decode(consumer_base64));
//System.out.println("助力者consumer_base64转码后为:" + decodedText);
String consumerId = MatcherString.getString(decodedText, "cid\":(.*?)}", 1);
//System.out.println("用户consumer_id为:" + consumerId);
consumerIds[i] = consumerId;
}
String score = request.getParameter("scores");
String[] scores = score.split(",");
int max;
if (uidParams.length < scores.length) {
max = uidParams.length;
} else {
max = scores.length;
}
System.out.println("max值为:" + max);
Map<String, String> map = new HashMap<>();
//构建tb_ranking_config数据
String sql2 = "select * from projectx.tb_ranking_config where project_id='" + projectId + "' and type = '" + type + "'";
Response response = sqlService.findSimpleResult(sql2);
System.out.println("查询结果为:" + response.asString());
if (response.asString().equals("{}")) {
String sql3 = "insert into projectx.tb_ranking_config(project_id, type, ranking_name, send_prize, manual_send_prize, send_prize_time, error_message) values ('" + projectId + "', '" + type + "', '" + type + "', 1, 0, null, '')";
sqlService.update(sql3);
}
//构建tb_ranking数据
for (int n = 0; n < max; n++) {
String a = scores[n];
Long base = 999999999999L;
Long b = Long.valueOf((new Date().getTime())/10);
BigDecimal num = new BigDecimal(base);
BigDecimal num2 = new BigDecimal(b);
BigDecimal result = num.subtract(num2);
//maxScoreOrder=分数+""+(999999999999-(当前时间戳/10));
String order = a.concat(String.valueOf(result));
String sql = "insert into projectx.tb_ranking(project_id, type, user_id, max_score, max_score_order, send_prize, prize_id, send_prize_time) values ('" + projectId + "', '" + type + "', '" + consumerIds[n] + "', '" + scores[n] + "', '" + order + "', 0, null, null)";
System.out.println("创建SQL为:" + sql);
sqlService.update(sql);
Thread.sleep(500);
}
try {
map.put("success", "true");
map.put("message", "排行榜数据构建成功!");
} catch (Exception e) {
map.put("success", "false");
map.put("message", "排行榜数据构建失败T_T 请确认数据库数据");
}
return map;
}
}
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