Commit dee2d70e authored by 赵然's avatar 赵然

zr

parent 346317e9
...@@ -12,7 +12,7 @@ public class MysqlUtils { ...@@ -12,7 +12,7 @@ public class MysqlUtils {
//数据库密码 //数据库密码
private String PASSWORD; //= "yanzi"; private String PASSWORD; //= "yanzi";
//驱动信息 //驱动信息
private String DRIVER="com.mysql.jdbc.Driver"; private String DRIVER="com.mysql.cj.jdbc.Driver"; //com.mysql.jdbc.Driver
//数据库地址 //数据库地址
private String URL;// = "jdbc:mysql://localhost:3306/mydb"; private String URL;// = "jdbc:mysql://localhost:3306/mydb";
private Connection connection; private Connection connection;
...@@ -57,7 +57,7 @@ public class MysqlUtils { ...@@ -57,7 +57,7 @@ public class MysqlUtils {
// //
// } // }
public static MysqlUtils mysqlDuiba(String databaseName){ public static MysqlUtils mysqlDuiba(String databaseName){
return new MysqlUtils("duiba_test","svbP3KUw2PurAnBb2rbs3vohF","172.16.80.25","3306",databaseName); return new MysqlUtils("duiba_tmp","duiba_tmpkduiba_tmduiba_tmp","47.97.127.67","13002",databaseName);
} }
/** /**
...@@ -144,13 +144,17 @@ public class MysqlUtils { ...@@ -144,13 +144,17 @@ public class MysqlUtils {
public List<Map<String, Object>> findModeResult(String sql, Object ...params) throws SQLException{ public List<Map<String, Object>> findModeResult(String sql, Object ...params) throws SQLException{
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
int index = 1; int index = 1;
pstmt = connection.prepareStatement(sql); pstmt = connection.prepareStatement(sql,ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
pstmt.setFetchSize(Integer.MIN_VALUE);
pstmt.setFetchDirection(ResultSet.FETCH_REVERSE);
if(params != null && !(params.length==0)){ if(params != null && !(params.length==0)){
for(int i=0; i<params.length; i++){ for(int i=0; i<params.length; i++){
pstmt.setObject(index++, params[i]); pstmt.setObject(index++, params[i]);
} }
} }
resultSet = pstmt.executeQuery(); resultSet = pstmt.executeQuery();
ResultSetMetaData metaData = resultSet.getMetaData(); ResultSetMetaData metaData = resultSet.getMetaData();
int cols_len = metaData.getColumnCount(); int cols_len = metaData.getColumnCount();
while(resultSet.next()){ while(resultSet.next()){
......
package main.com.atguigu.springmvc.entities; package main.com.atguigu.springmvc.entities;
import java.util.Date;
public class AppDO { public class AppDO {
private Long id;
private String name;
private String appKey;
private String appSecret;
private Date gmtCreate;
private Date gmtModified;
private Long consumeTemplateId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAppKey() {
return appKey;
}
public void setAppKey(String appKey) {
this.appKey = appKey;
}
public String getAppSecret() {
return appSecret;
}
public void setAppSecret(String appSecret) {
this.appSecret = appSecret;
}
public Date getGmtCreate() {
return gmtCreate;
}
public void setGmtCreate(Date gmtCreate) {
this.gmtCreate = gmtCreate;
}
public Date getGmtModified() {
return gmtModified;
}
public void setGmtModified(Date gmtModified) {
this.gmtModified = gmtModified;
}
public Long getConsumeTemplateId() {
return consumeTemplateId;
}
public void setConsumeTemplateId(Long consumeTemplateId) {
this.consumeTemplateId = consumeTemplateId;
}
} }
package main.com.atguigu.springmvc.entities; package main.com.atguigu.springmvc.entities;
import java.util.Date;
public class UserDO { public class UserDO {
private Long id;
private String name; //用户名
private Long credits = 0L ;//积分余额
private boolean enable = false; //该用户是否可用
private Long version=0L;
private Long appId;
private String gmtCreate;
private String gmtModified;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getCredits() {
return credits;
}
public void setCredits(Long credits) {
this.credits = credits;
}
public boolean isEnable() {
return enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
public String getGmtCreate() {
return gmtCreate;
}
public void setGmtCreate(String gmtCreate) {
this.gmtCreate = gmtCreate;
}
public String getGmtModified() {
return gmtModified;
}
public void setGmtModified(String gmtModified) {
this.gmtModified = gmtModified;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
public Long getAppId() {
return appId;
}
public void setAppId(Long appId) {
this.appId = appId;
}
} }
...@@ -33,6 +33,7 @@ public class CollectModule { ...@@ -33,6 +33,7 @@ public class CollectModule {
final Base64.Decoder decoder = Base64.getDecoder(); final Base64.Decoder decoder = Base64.getDecoder();
private MysqlUtils jdbc; private MysqlUtils jdbc;
private String consumer_base64 = null ;
/** /**
* 功能:助力集卡综合操作 * 功能:助力集卡综合操作
* @return * @return
...@@ -175,27 +176,40 @@ public class CollectModule { ...@@ -175,27 +176,40 @@ public class CollectModule {
@ResponseBody @ResponseBody
public Map doSet(HttpServletRequest request) throws Exception { public Map doSet(HttpServletRequest request) throws Exception {
String userId = request.getParameter("userId"); //String userId = request.getParameter("userId");
java.net.URLDecoder urlDecoder=new java.net.URLDecoder();
String userId = urlDecoder.decode(request.getParameter("userId"),"utf-8");
String cardId = request.getParameter("cardId"); String cardId = request.getParameter("cardId");
String count = request.getParameter("count"); String count = request.getParameter("count");
String type = request.getParameter("type");
consumer_base64 = urlDecoder.decode(request.getParameter("ac"),"utf-8");
System.out.println("用户id:" + userId); System.out.println("用户id:" + userId);
System.out.println("用户ac:" + consumer_base64);
System.out.println("卡片id:" + cardId); System.out.println("卡片id:" + cardId);
System.out.println("卡片type:" + type);
Response good = sqlService.findSimpleResult("select * from goods.item where id = "+cardId); Response good = sqlService.findSimpleResult("select * from goods.item where id = "+cardId);
String card_name = String.valueOf(good.jsonPath().getString("name")); String card_name = String.valueOf(good.jsonPath().getString("name"));
//userid转consumerid //userid转consumerid
Map<String,String> login_map = authorization.dafuwengLogin(Integer.parseInt(userId)); //Map<String,String> login_map = authorization.dafuwengLogin(Integer.parseInt(userId));
if(consumer_base64.isEmpty()|| consumer_base64.equals(null) || consumer_base64.equals("")) {
Map<String, String> login_map = authorization.dafuwengLoginStr(userId);
System.out.println("用户login_map为:" + login_map.toString()); System.out.println("用户login_map为:" + login_map.toString());
String consumer_base64 = String.valueOf(login_map.get("_ac")); consumer_base64 = String.valueOf(login_map.get("_ac"));
System.out.println("用户consumer_base64为:" + consumer_base64); System.out.println("用户consumer_base64为:" + consumer_base64);
}
String decodedText = new String(decoder.decode(consumer_base64)); String decodedText = new String(decoder.decode(consumer_base64));
System.out.println("用户consumer_base64转码后为:" + decodedText); System.out.println("用户consumer_base64转码后为:" + decodedText);
String consumerId = MatcherString.getString(decodedText, "cid\":(.*?)}", 1); String consumerId = MatcherString.getString(decodedText, "cid\":(.*?)}", 1);
System.out.println("用户consumer_id为:" + consumerId); System.out.println("用户consumer_id为:" + consumerId);
String appId = MatcherString.getString(decodedText, "aid\":(.*?),", 1);
System.out.println("用户appid为:" + appId);
String tag = String.format("%04d", Long.parseLong(consumerId) % 1024); String tag = String.format("%04d", Long.parseLong(consumerId) % 1024);
System.out.println("用户consumer_id的取余为:" + tag); System.out.println("用户consumer_id的取余为:" + tag);
...@@ -203,14 +217,17 @@ public class CollectModule { ...@@ -203,14 +217,17 @@ public class CollectModule {
map.put("cardId", cardId); map.put("cardId", cardId);
String sql = "SELECT * FROM ckvtable.tb_kvtable_"+tag+" where consumer_id = '"+consumerId+"' and vkey = 'cl_good_cid_itemId_"+consumerId+"_"+cardId+"';"; //String sql = "SELECT * FROM ckvtable.tb_kvtable_"+tag+" where consumer_id = '"+consumerId+"' and vkey = 'cl_good_cid_itemId_"+consumerId+"_"+cardId+"';";
String sql = "SELECT * FROM collect_card_consumer.tb_collect_card_info_"+tag+" where consumer_id = '"+consumerId+"' and item_id = '"+cardId+"';";
Response response = sqlService.findSimpleResult(sql); Response response = sqlService.findSimpleResult(sql);
System.out.println("查询结果为:" + response.asString()); System.out.println("查询结果为:" + response.asString());
if (response.asString().equals("{}")) { if (response.asString().equals("{}")) {
try { try {
String sqlAdd = "INSERT INTO ckvtable.tb_kvtable_"+tag+" ( `consumer_id`, `vspace`, `vkey`, `int_value`, `string_value`, `gmt_create`, `gmt_modified`) VALUES ( '"+consumerId+"', 'duiba-activity-web', 'cl_good_cid_itemId_"+consumerId+"_"+cardId+"', '"+count+"', NULL, '2018-09-04 16:05:19', '2018-09-05 16:14:48')"; //String sqlAdd = "INSERT INTO ckvtable.tb_kvtable_"+tag+" ( `consumer_id`, `vspace`, `vkey`, `int_value`, `string_value`, `gmt_create`, `gmt_modified`) VALUES ( '"+consumerId+"', 'duiba-activity-web', 'cl_good_cid_itemId_"+consumerId+"_"+cardId+"', '"+count+"', NULL, '2018-09-04 16:05:19', '2018-09-05 16:14:48')";
String sqlAdd = "INSERT INTO collect_card_consumer.tb_collect_card_info_"+tag+" ( `app_id`, `consumer_id`, `partner_user_id`, `item_type`, `item_id`, `item_count`, `item_total_count`, `gmt_create`, `gmt_modify`) VALUES ( '"+appId+"','"+consumerId+"', '"+userId+"', '"+type+"', '"+cardId+"','"+count+"','"+count+"', '2018-09-04 16:05:19', '2018-09-05 16:14:48')";
System.out.println("sql为:" + sqlAdd);
sqlService.update(sqlAdd); sqlService.update(sqlAdd);
System.out.println("如果卡片原本为空,重置成功!"); System.out.println("如果卡片原本为空,重置成功!");
...@@ -222,7 +239,9 @@ public class CollectModule { ...@@ -222,7 +239,9 @@ public class CollectModule {
} }
}else { }else {
try { 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 ckvtable.tb_kvtable_"+tag+" set int_value = '"+count+"' where consumer_id = '"+consumerId+"' and vkey = 'cl_good_cid_itemId_"+consumerId+"_"+cardId+"'");
sqlService.update("update collect_card_consumer.tb_collect_card_info_"+tag+" set item_count = '"+count+"',item_total_count = '"+count+"' where consumer_id = '"+consumerId+"' and item_id = '"+cardId+"'");
System.out.println("如果卡片原本有值,重置成功!"); System.out.println("如果卡片原本有值,重置成功!");
map.put("success", "true"); map.put("success", "true");
...@@ -244,21 +263,27 @@ public class CollectModule { ...@@ -244,21 +263,27 @@ public class CollectModule {
@ResponseBody @ResponseBody
public Map doClear(HttpServletRequest request) throws Exception { public Map doClear(HttpServletRequest request) throws Exception {
String userId = request.getParameter("userId"); //String userId = request.getParameter("userId");
java.net.URLDecoder urlDecoder=new java.net.URLDecoder();
String userId = urlDecoder.decode(request.getParameter("userId"),"utf-8");
String ruleId = request.getParameter("ruleId"); String ruleId = request.getParameter("ruleId");
String termId = request.getParameter("termId"); String termId = request.getParameter("termId");
consumer_base64 = request.getParameter("ac");
System.out.println("用户id:" + userId); System.out.println("用户id:" + userId);
System.out.println("助力id:" + ruleId); System.out.println("助力id:" + ruleId);
consumer_base64 = urlDecoder.decode(request.getParameter("ac"),"utf-8");
//userid转consumerid //userid转consumerid
Map<String,String> login_map = authorization.dafuwengLogin(Integer.parseInt(userId)); if(consumer_base64.isEmpty()|| consumer_base64.equals(null) || consumer_base64.equals("")) {
Map<String, String> login_map = authorization.dafuwengLogin(Integer.parseInt(userId));
System.out.println("用户login_map为:" + login_map.toString()); System.out.println("用户login_map为:" + login_map.toString());
String consumer_base64 = String.valueOf(login_map.get("_ac")); consumer_base64 = String.valueOf(login_map.get("_ac"));
System.out.println("用户consumer_base64为:" + consumer_base64); System.out.println("用户consumer_base64为:" + consumer_base64);
}
String decodedText = new String(decoder.decode(consumer_base64)); String decodedText = new String(decoder.decode(consumer_base64));
System.out.println("用户consumer_base64转码后为:" + decodedText); System.out.println("用户consumer_base64转码后为:" + decodedText);
String consumerId = MatcherString.getString(decodedText, "cid\":(.*?)}", 1); String consumerId = MatcherString.getString(decodedText, "cid\":(.*?)}", 1);
...@@ -270,7 +295,9 @@ public class CollectModule { ...@@ -270,7 +295,9 @@ public class CollectModule {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
String sql = "SELECT * FROM ckvtable.tb_kvtable_"+tag+" where consumer_id = '"+consumerId+"' and vkey = 'cl_good_cid_Crule_grade_"+consumerId+"_"+ruleId+"_"+termId+"'"; //String sql = "SELECT * FROM ckvtable.tb_kvtable_"+tag+" where consumer_id = '"+consumerId+"' and vkey = 'cl_good_cid_Crule_grade_"+consumerId+"_"+ruleId+"_"+termId+"'";
String sql = "SELECT * FROM collect_card.tb_collect_card_win_record where consumer_id = '"+consumerId+"' and rule_id = '"+ruleId+"' and grade_level = '"+termId+"'";
System.out.println("sql为:" + sql); System.out.println("sql为:" + sql);
// jdbc = MysqlUtils.mysqlDuiba("ckvtable"); // jdbc = MysqlUtils.mysqlDuiba("ckvtable");
...@@ -284,7 +311,7 @@ public class CollectModule { ...@@ -284,7 +311,7 @@ public class CollectModule {
}else { }else {
try { try {
//jdbc.update("delete FROM tb_kvtable_"+tag+" where consumer_id = '"+consumerId+"' and vkey = 'cl_good_cid_Crule_grade_"+consumerId+"_"+ruleId+"_"+termId+"'"); //jdbc.update("delete FROM tb_kvtable_"+tag+" where consumer_id = '"+consumerId+"' and vkey = 'cl_good_cid_Crule_grade_"+consumerId+"_"+ruleId+"_"+termId+"'");
sqlService.update("delete FROM ckvtable.tb_kvtable_"+tag+" where consumer_id = '"+consumerId+"' and vkey = 'cl_good_cid_Crule_grade_"+consumerId+"_"+ruleId+"_"+termId+"'"); sqlService.update("delete FROM collect_card.tb_collect_card_win_record where consumer_id = '"+consumerId+"' and rule_id = '"+ruleId+"' and grade_level = '"+termId+"'");
map.put("success", "true"); map.put("success", "true");
map.put("message", "用户"+userId+"的开大奖记录清除成功"); map.put("message", "用户"+userId+"的开大奖记录清除成功");
......
...@@ -59,6 +59,8 @@ public class Authorization { ...@@ -59,6 +59,8 @@ public class Authorization {
private static Map<String,String> dafuwengCookies; private static Map<String,String> dafuwengCookies;
private static Map<Integer,Map> dafuwengCookiesMap = new HashMap<>(); private static Map<Integer,Map> dafuwengCookiesMap = new HashMap<>();
private static Map<String,Map> dafuwengCookiesMapStr = new HashMap<>();
private static Map<String,String> hdCookies; private static Map<String,String> hdCookies;
private static Map<String,String> hdCookiesMabo; private static Map<String,String> hdCookiesMabo;
private Map<String,String> ssoCookies =null; private Map<String,String> ssoCookies =null;
...@@ -103,6 +105,44 @@ public class Authorization { ...@@ -103,6 +105,44 @@ public class Authorization {
return dafuwengCookiesMap.get(uid); return dafuwengCookiesMap.get(uid);
} }
public Map dafuwengLoginStr(String uid){
int i=10;
while((dafuwengCookiesMapStr==null||dafuwengCookiesMapStr.get(uid)==null||dafuwengCookiesMapStr.get(uid).size()==0)&&i>0) {
// String url = PROTOCOL + dafuwengHost + ":" + dafuwengPort + dafuwengLoginPath;
String url = PROTOCOL + dafuwengHost + dafuwengLoginPath;
Response response=given().redirects().follow(false).param("uid",uid).get(url);
String location = response.getHeader("location");
dafuwengCookies=response.getCookies();
//logger.info(location);
URL url1=null;
try {
url1= new URL(location);
} catch (MalformedURLException e) {
e.printStackTrace();
}
if(url1!=null&&url1.getProtocol().equals("http")) {
response=given().cookies(dafuwengCookies).redirects().follow(false).get(location);
}else if(url1!=null&&url1.getProtocol().equals("https")){
response=given().cookies(dafuwengCookies).relaxedHTTPSValidation().redirects().follow(false).get(location);
}
dafuwengCookies=response.getCookies();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
dafuwengCookiesMapStr.put(uid,dafuwengCookies);
i--;
}
if(i==0&&dafuwengCookies==null){
// logger.info("dafuweng登陆app失败,cookies为null");
}
// logger.info("dafuweng cookies:"+dafuwengCookies.toString());
return dafuwengCookiesMapStr.get(uid);
}
/** /**
* 大富翁登陆 * 大富翁登陆
* @param uid * @param uid
......
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