6a8587e7 by joe

增加统计方法

1 parent b7b44628
...@@ -18,9 +18,12 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -18,9 +18,12 @@ import org.springframework.web.bind.annotation.RestController;
18 18
19 import javax.servlet.http.HttpServletRequest; 19 import javax.servlet.http.HttpServletRequest;
20 import java.io.IOException; 20 import java.io.IOException;
21 import java.io.UnsupportedEncodingException;
21 import java.net.URLDecoder; 22 import java.net.URLDecoder;
22 import java.net.URLEncoder; 23 import java.net.URLEncoder;
24 import java.text.ParseException;
23 import java.text.SimpleDateFormat; 25 import java.text.SimpleDateFormat;
26 import java.util.Date;
24 import java.util.HashMap; 27 import java.util.HashMap;
25 import java.util.List; 28 import java.util.List;
26 import java.util.Map; 29 import java.util.Map;
...@@ -46,34 +49,37 @@ public class ScoreLogInfoController { ...@@ -46,34 +49,37 @@ public class ScoreLogInfoController {
46 @RequestMapping("/save") 49 @RequestMapping("/save")
47 public MessageEntity save(HttpServletRequest request, @ModelAttribute ScoreLogInfo scoreLogInfo, 50 public MessageEntity save(HttpServletRequest request, @ModelAttribute ScoreLogInfo scoreLogInfo,
48 String access_token, String state, String timestamp, String rands, String jsondata, String checksum, 51 String access_token, String state, String timestamp, String rands, String jsondata, String checksum,
49 String secret) { 52 String secret) throws ParseException, UnsupportedEncodingException {
50 MessageEntity.Builder builder = new MessageEntity.Builder(request); 53 MessageEntity.Builder builder = new MessageEntity.Builder(request);
51 boolean flag = false; 54 boolean flag = false;
52 String code = "9000"; 55 String code = "9000";
53 String openid = scoreLogInfo.getOpenid(); 56 // String openid = scoreLogInfo.getOpenid();
54 if (StringUtils.isNotBlank(jsondata)) { 57 Date lastDay = sdf.parse("2017-12-14 23:59:59");
55 jsondata = URLDecoder.decode(jsondata); 58 if(lastDay.after(new Date())) {
56 ObjectMapper objectMapper = new ObjectMapper(); 59 if (StringUtils.isNotBlank(jsondata)) {
57 Map map = null; 60 jsondata = URLDecoder.decode(jsondata,"utf-8");
58 try { 61 ObjectMapper objectMapper = new ObjectMapper();
59 map = objectMapper.readValue(jsondata, Map.class); 62 Map map = null;
60 } catch (IOException e) { 63 try {
61 e.printStackTrace(); 64 map = objectMapper.readValue(jsondata, Map.class);
62 } 65 } catch (IOException e) {
63 // if(map != null && map.containsKey("gtmc_code") && 66 e.printStackTrace();
64 // map.get("gtmc_code").toString().equals("200")){ 67 }
65 // String checksum1 = MD5Utils.hash(access_token +openid +state +timestamp 68 // if(map != null && map.containsKey("gtmc_code") &&
66 // +rands +jsondata +secret); 69 // map.get("gtmc_code").toString().equals("200")){
67 // if(checksum1.equals(checksum)){ 70 // String checksum1 = MD5Utils.hash(access_token +openid +state +timestamp
68 scoreLogInfo.setGtmcUid(map.get("gtmc_uid").toString()); 71 // +rands +jsondata +secret);
69 scoreLogInfo.setGtmcDepartment(map.get("gtmc_department").toString()); 72 // if(checksum1.equals(checksum)){
70 scoreLogInfo.setGtmcName(map.get("gtmc_name").toString()); 73 scoreLogInfo.setGtmcUid(map.get("gtmc_uid").toString());
71 code = this.scoreLogInfoService.save(scoreLogInfo); 74 scoreLogInfo.setGtmcDepartment(map.get("gtmc_department").toString());
72 if (code.equals("2000")) { 75 scoreLogInfo.setGtmcName(map.get("gtmc_name").toString());
73 flag = true; 76 code = this.scoreLogInfoService.save(scoreLogInfo);
77 if (code.equals("2000")) {
78 flag = true;
79 }
80 // }
81 // }
74 } 82 }
75 // }
76 // }
77 } 83 }
78 return builder.success(flag).code(code).create(); 84 return builder.success(flag).code(code).create();
79 } 85 }
...@@ -117,6 +123,14 @@ public class ScoreLogInfoController { ...@@ -117,6 +123,14 @@ public class ScoreLogInfoController {
117 long l = this.scoreLogInfoService.saveShare(openid); 123 long l = this.scoreLogInfoService.saveShare(openid);
118 return builder.success(true).code("2000").content(l).create(); 124 return builder.success(true).code("2000").content(l).create();
119 } 125 }
126
127
128 @RequestMapping("/saveStat")
129 public MessageEntity saveStat(HttpServletRequest request, @RequestParam String openid) {
130 MessageEntity.Builder builder = new MessageEntity.Builder(request);
131 long l = this.scoreLogInfoService.saveStat(openid);
132 return builder.success(true).code("2000").content(l).create();
133 }
120 134
121 // public static void main(String[] args) { 135 // public static void main(String[] args) {
122 // String 136 // String
......
...@@ -69,7 +69,7 @@ public class WxController { ...@@ -69,7 +69,7 @@ public class WxController {
69 try { 69 try {
70 readValue = mapper.readValue(responseEntity, Map.class); 70 readValue = mapper.readValue(responseEntity, Map.class);
71 if (null != readValue.get("errcode")) { 71 if (null != readValue.get("errcode")) {
72 return null; 72 return builder.success(false).code("999").content(readValue).create();
73 } 73 }
74 } catch (IOException e) { 74 } catch (IOException e) {
75 e.printStackTrace();; 75 e.printStackTrace();;
......
...@@ -14,4 +14,6 @@ public interface ShareLogMapper { ...@@ -14,4 +14,6 @@ public interface ShareLogMapper {
14 long countByDay(@Param("openid") String openid, @Param("startDate") String startDate, 14 long countByDay(@Param("openid") String openid, @Param("startDate") String startDate,
15 @Param("endDate") String endDate); 15 @Param("endDate") String endDate);
16 16
17 boolean saveStat(@Param("openid") String openid);
18
17 } 19 }
......
...@@ -23,4 +23,6 @@ public interface ScoreLogInfoService { ...@@ -23,4 +23,6 @@ public interface ScoreLogInfoService {
23 23
24 long saveShare(String openid); 24 long saveShare(String openid);
25 25
26 long saveStat(String openid);
27
26 } 28 }
......
...@@ -109,4 +109,11 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService { ...@@ -109,4 +109,11 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService {
109 } 109 }
110 110
111 111
112 @Override
113 public long saveStat(String openid) {
114 shareLogMapper.saveStat(openid);
115 return 0;
116 }
117
118
112 } 119 }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
9 ) 9 )
10 values( 10 values(
11 #{openid}, 11 #{openid},
12 #{share_time} 12 #{shareTime}
13 ); 13 );
14 </insert> 14 </insert>
15 15
...@@ -21,6 +21,13 @@ ...@@ -21,6 +21,13 @@
21 and openid= #{openid}; 21 and openid= #{openid};
22 </select> 22 </select>
23 23
24 <insert id="saveStat">
25 insert into `t_kmr_stat_log`(
26 `openid`
27 ) values (
28 #{openid}
29 )
30 </insert>
24 31
25 32
26 </mapper> 33 </mapper>
...\ No newline at end of file ...\ No newline at end of file
......