Commit e7834fe4 authored by 赵然's avatar 赵然

'zr'

parent ed887bac
package main.com.atguigu.springmvc.handlers;
import io.restassured.response.Response;
import main.com.atguigu.springmvc.common.MatcherString;
import main.com.atguigu.springmvc.common.MysqlUtils;
import main.com.atguigu.springmvc.service.Authorization;
import main.com.atguigu.springmvc.service.NewActivityService;
import io.restassured.response.Response;
import main.com.atguigu.springmvc.service.SqlService;
import main.com.atguigu.springmvc.service.ViewService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -18,8 +18,6 @@ import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
//@RequestMapping("/Sign")
@Controller
......@@ -330,69 +328,4 @@ public class CollectModule {
return map;
}
/**
* 功能:星宿台设置卡片数量操作
* @return
*/
@RequestMapping(value = "/setQuantity", method= RequestMethod.POST)
@ResponseBody
public Map setQuantity(HttpServletRequest request) throws Exception {
java.net.URLDecoder urlDecoder=new java.net.URLDecoder();
String userId = urlDecoder.decode(request.getParameter("userId"),"utf-8");
String projectId = request.getParameter("projectId");
String spId = request.getParameter("spId");
String quantity = request.getParameter("quantity");
System.out.println("用户id:" + userId);
System.out.println("项目id:" + projectId);
System.out.println("道具id:" + spId);
//userid转consumerid
Map<String,String> login_map = authorization.dafuwengLogin(Integer.parseInt(userId));
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);
Map<String, String> map = new HashMap<>();
String sql = "SELECT * FROM projectx.tb_user_sp where user_id = '"+consumerId+"' and project_id = '"+projectId+"' and sp_id = '"+spId+"' ";
Response response = sqlService.findSimpleResult(sql);
System.out.println("查询结果为:" + response.asString());
if (response.asString().equals("{}")) {
try {
String sqlAdd = "INSERT INTO projectx.tb_user_sp (project_id, user_id, sp_id, quantity, gmt_create, gmt_modified) values ('"+projectId+"', '"+consumerId+"', '"+spId+"', "+quantity+", '2019-09-25 15:58:11', '2019-09-27 14:23:57')";
System.out.println("sql为:" + sqlAdd);
sqlService.update(sqlAdd);
System.out.println("如果道具原本为空,重置成功!");
map.put("success", "true");
map.put("message", "道具数设置成功,用户"+userId+"的"+spId+"数量为:"+quantity);
} catch (Exception e) {
map.put("success", "false");
map.put("message", "道具数设置失败!");
}
}else {
try {
sqlService.update("update projectx.tb_user_sp set quantity = '"+quantity+"' where user_id = '"+consumerId+"' and project_id = '"+projectId+"' and sp_id = '"+spId+"'");
System.out.println("如果道具原本有值,重置成功!");
map.put("success", "true");
map.put("message", "道具数设置成功,用户"+userId+"的"+spId+"数量为:"+quantity);
} catch (Exception e) {
map.put("success", "false");
map.put("message", "道具数设置失败!");
}
}
return map;
}
}
......@@ -69,6 +69,8 @@ public class CreatUrlModule {
Map<String, String> params=new HashMap<String, String>();
params.put("uid",userId);
params.put("credits",credits);
params.put("timestamp",String.valueOf(System.currentTimeMillis() + 240 * 60 * 1000));
if(dcustom!=null&&dcustom!=""&&dcustom != "null") {
if(type == null || type.equals("1")) {
params.put("dcustom", dcustom);
......
This diff is collapsed.
package main.com.atguigu.springmvc.handlers;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.restassured.response.Response;
import main.com.atguigu.springmvc.common.MatcherString;
import main.com.atguigu.springmvc.common.MysqlUtils;
import main.com.atguigu.springmvc.service.Authorization;
import main.com.atguigu.springmvc.service.NewActivityService;
import main.com.atguigu.springmvc.service.SqlService;
......@@ -14,7 +12,6 @@ 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 org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
......@@ -211,6 +208,11 @@ public class NewSignModule {
for(int i =0;i<ar.size();i++){
SignInfo = SignInfo + ar.getJSONObject(i).getString("gmt_create") + " 签到成功\n";
}
String actionId = ar.getJSONObject(0).getString("action_id");
String playwayType = ar.getJSONObject(0).getString("playway_type");
SignInfo = SignInfo +"\n\n项目actionId为"+actionId+"\n项目playwayType为"+playwayType;
map.put("success", "true");
map.put("message", SignInfo);
......@@ -232,18 +234,20 @@ public class NewSignModule {
String projectId = request.getParameter("projectId");
String playwayId = request.getParameter("playwayId");
String actionId = request.getParameter("actionId");
String playwayType = request.getParameter("playwayType");
String continue_day = request.getParameter("days");
String discon = request.getParameter("discon");
System.out.println("用户id:" + userId);
System.out.println("项目id:" + projectId);
System.out.println("玩法id:" + playwayId);
System.out.println("连续签到天数为:" + continue_day);
System.out.println("是否断签:" + discon);
String[] temp = playwayId.split("_");
System.out.println("分割前数据为:" + temp[0] + "分割后数据为:" + temp[1]);
//String[] temp = playwayId.split("_");
//System.out.println("分割前数据为:" + temp[0] + "分割后数据为:" + temp[1]);
//userid转consumerid
Map<String,String> login_map = authorization.dafuwengLogin(Integer.parseInt(userId));
......@@ -262,7 +266,7 @@ public class NewSignModule {
while (i > 1) {
String sign_date = this.getTime(i * (-1));
Thread.sleep(500);
String sql2 = "INSERT INTO projectx.tb_action_record (project_id, playway_id, action_id, user_id, playway_type, extra, gmt_create, gmt_modified) values ( '" + projectId + "', '" + playwayId + "', '" + temp[0] + "', '" + consumerId + "', " + temp[1] + ", null, '" + sign_date + "', '2019-10-10 16:20:57')";
String sql2 = "INSERT INTO projectx.tb_action_record (project_id, playway_id, action_id, user_id, playway_type, extra, gmt_create, gmt_modified) values ( '" + projectId + "', '" + playwayId + "', '" + actionId + "', '" + consumerId + "', " + playwayType + ", null, '" + sign_date + "', '2019-10-10 16:20:57')";
sqlService.update(sql2);
i--;
}
......@@ -270,7 +274,7 @@ public class NewSignModule {
while (i > 0) {
String sign_date = this.getTime(i * (-1));
Thread.sleep(500);
String sql2 = "INSERT INTO projectx.tb_action_record (project_id, playway_id, action_id, user_id, playway_type, extra, gmt_create, gmt_modified) values ( '" + projectId + "', '" + playwayId + "', '" + temp[0] + "', '" + consumerId + "', " + temp[1] + ", null, '" + sign_date + "', '2019-10-10 16:20:57')";
String sql2 = "INSERT INTO projectx.tb_action_record (project_id, playway_id, action_id, user_id, playway_type, extra, gmt_create, gmt_modified) values ( '" + projectId + "', '" + playwayId + "', '" + actionId + "', '" + consumerId + "', " + playwayType + ", null, '" + sign_date + "', '2019-10-10 16:20:57')";
sqlService.update(sql2);
i--;
}
......
......@@ -150,7 +150,7 @@ public class RankModule {
String uids = request.getParameter("uids");
String[] uidParams = uids.split(",");
String[] consumerIds = new String[20];
String[] consumerIds = new String[uidParams.length];
for (int i = 0; i < uidParams.length; i++) {
//将userid转consumerid
Map<String, String> login_map = authorization.dafuwengLogin(Integer.parseInt(uidParams[i]));
......@@ -307,15 +307,35 @@ public class RankModule {
Response response2 = sqlService.findModeResult(sql);
JSONArray ar = JSONArray.parseArray(response2.asString());
/*for (int i =0;i<ar.size();i++) {
resultMap.put("ranking_type", ar.getJSONObject(i).getString("ranking_type"));
resultMap.put("start_time", ar.getJSONObject(i).getString("start_time"));
resultMap.put("end_time", ar.getJSONObject(i).getString("end_time"));
resultMap.put("op_status", ar.getJSONObject(i).getString("op_status"));
}*/
List list = new ArrayList();
for (int i =0;i<ar.size();i++) {
Map map = new HashMap();
map.put("ranking_type", ar.getJSONObject(i).getString("ranking_type"));
map.put("start_time", ar.getJSONObject(i).getString("start_time"));
map.put("end_time", ar.getJSONObject(i).getString("end_time"));
String op_status = ar.getJSONObject(i).getString("op_status");
if(op_status.equals("0")){
String op_status_cn = "无需开奖";
map.put("op_status", op_status_cn);
}if(op_status.equals("1")){
String op_status_cn = "未开奖";
map.put("op_status", op_status_cn);
}if(op_status.equals("2")){
String op_status_cn = "开奖中";
map.put("op_status", op_status_cn);
}if(op_status.equals("3")){
String op_status_cn = "开奖异常";
map.put("op_status", op_status_cn);
}if(op_status.equals("4")){
String op_status_cn = "已开奖";
map.put("op_status", op_status_cn);
}
list.add(map);
}
resultMap.put("success", "true");
resultMap.put("message", ar);
resultMap.put("message", list);
}
return resultMap;
}
......
......@@ -16,7 +16,6 @@ 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 org.testng.Assert;
import javax.servlet.http.HttpServletRequest;
import java.net.URLDecoder;
......@@ -44,9 +43,9 @@ public class UserModule {
* 功能:partnerId查询用户基本信息
* @return
*/
@RequestMapping(value = "/searchInfo", method= RequestMethod.POST)
@RequestMapping(value = "/searchInfo3", method= RequestMethod.POST)
@ResponseBody
public Map searchInfo(HttpServletRequest request) throws Exception {
public Map searchInfo3(HttpServletRequest request) throws Exception {
viewService.count();
......@@ -69,12 +68,13 @@ public class UserModule {
String appId = MatcherString.getString(decodedText, "aid\":(.*?),", 1);
System.out.println("开发者id为:" + appId);
String tag = String.format("%04d", Long.parseLong(consumer_id) % 1024);
System.out.println("用户consumer_id的取余为:" + tag);
Response sqlresul = sqlService.findSimpleResult("select * from consumer_extra.consumer_extra where consumer_id = "+consumer_id);
String nickname = String.valueOf(sqlresul.jsonPath().getString("nickname"));
String result = "开发者id为:" + appId + "\nconsumer_id为:" + consumer_id + "\nconsumer_id取模结果为:" + tag;
map.put("appId", appId);
map.put("consumerId", consumer_id);
map.put("nickname", nickname);
map.put("message", result);
return map;
}
......@@ -114,6 +114,45 @@ public class UserModule {
return map;
}
/**
* 功能:partnerId查询用户基本信息
* @return
*/
@RequestMapping(value = "/searchInfo", method= RequestMethod.POST)
@ResponseBody
public Map searchInfo(HttpServletRequest request) throws Exception {
viewService.count();
String partnerId = request.getParameter("userId");
System.out.println("用户partnerId为:" + partnerId);
Map<String, String> map = new HashMap<>();
Map<String,String> login_map = authorization.dafuwengLogin(Integer.parseInt(partnerId));
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 consumer_id = MatcherString.getString(decodedText, "cid\":(.*?)}", 1);
System.out.println("用户consumer_id为:" + consumer_id);
String appId = MatcherString.getString(decodedText, "aid\":(.*?),", 1);
System.out.println("开发者id为:" + appId);
String tag = String.format("%04d", Long.parseLong(consumer_id) % 1024);
System.out.println("用户consumer_id的取余为:" + tag);
String result = "开发者id为:" + appId + "\nconsumer_id为:" + consumer_id + "\nconsumer_id取模结果为:" + tag;
map.put("message", result);
return map;
}
/**
* 功能:查询所有用户基本信息
* @return
......
......@@ -74,7 +74,125 @@ public class NewActivityService {
return response;
}
//助力抽奖
//星速台获取用户卡片详情
public Response getCards(int uid,String projectId) throws Exception{
Response response = given().cookies(authorization.dafuwengLogin(uid)).get(url+"/projectx/"+projectId+"/clcard/getCards.do");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/clcard/getCards.do接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/clcard/getCards.do接口失败,返回信息:"+response.asString());
}
return response;
}
//星速台获取助力分享码
public Response getShareCodeNew(int uid,String projectId) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("realShare","1");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(url+"/projectx/"+projectId+"/clcard/share.do");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/clcard/share.do接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/clcard/share.do接口失败,返回信息:"+response.asString());
}
return response;
}
//星速台获取索卡分享码
public Response askCode(int uid,String projectId,String cardId) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("cardId",cardId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(url+"/projectx/"+projectId+"/clcard/requestCard.do");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/clcard/requestCard.do接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/clcard/requestCard.do接口失败,返回信息:"+response.asString());
}
return response;
}
//星速台获取赠卡分享码
public Response giveCard(int uid,String projectId,String cardId) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("cardId",cardId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(url+"/projectx/"+projectId+"/clcard/giveCard.do");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/clcard/giveCard.do接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/clcard/giveCard.do接口失败,返回信息:"+response.asString());
}
return response;
}
//星速台助力抽奖
public Response assist(int userId,String shareCode,String projectId) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("channel","1");
map.put("shareCode",shareCode);
Response response = given().cookies(authorization.dafuwengLogin(userId,true)).params(map).get(url+"/projectx/"+projectId+"/clcard/assist.do");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","接口请求异常");
}catch(Exception e){
throw new Exception("/clcard/assist.do接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/clcard/assist.do接口失败,返回信息:"+response.asString());
}
return response;
}
//星速台赠卡
public Response grantCard(int userId,String shareCode,String projectId) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("channel","1");
map.put("shareCode",shareCode);
Response response = given().cookies(authorization.dafuwengLogin(userId,true)).params(map).get(url+"/projectx/"+projectId+"/clcard/grantCard.do");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","接口请求异常");
}catch(Exception e){
throw new Exception("/clcard/grantCard.do接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/clcard/grantCard.do接口失败,返回信息:"+response.asString());
}
return response;
}
//星速台收卡
public Response acceptCard(int userId,String shareCode,String projectId) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("channel","1");
map.put("shareCode",shareCode);
Response response = given().cookies(authorization.dafuwengLogin(userId,true)).params(map).get(url+"/projectx/"+projectId+"/clcard/acceptCard.do");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","接口请求异常");
}catch(Exception e){
throw new Exception("/clcard/acceptCard.do接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/clcard/acceptCard.do接口失败,返回信息:"+response.asString());
}
return response;
}
public Response helpShareCodeV2(int userId,String clGoodsRuleId,String activityId,String activityType,String shareCode) throws Exception{
Map<String, String> map = new HashMap<>();
......@@ -91,7 +209,7 @@ public class NewActivityService {
}catch(Error er){
throw new Exception("/activtyShareCode/helpShareCodeV2接口失败,返回信息:"+response.asString());
}
// authorization.dafuwengLogin(2720,true);
// authorization.dafuwengLogin(2720,true);
return response;
}
......
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