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,13 +49,15 @@ public class ScoreLogInfoController { ...@@ -46,13 +49,15 @@ 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();
57 Date lastDay = sdf.parse("2017-12-14 23:59:59");
58 if(lastDay.after(new Date())) {
54 if (StringUtils.isNotBlank(jsondata)) { 59 if (StringUtils.isNotBlank(jsondata)) {
55 jsondata = URLDecoder.decode(jsondata); 60 jsondata = URLDecoder.decode(jsondata,"utf-8");
56 ObjectMapper objectMapper = new ObjectMapper(); 61 ObjectMapper objectMapper = new ObjectMapper();
57 Map map = null; 62 Map map = null;
58 try { 63 try {
...@@ -75,6 +80,7 @@ public class ScoreLogInfoController { ...@@ -75,6 +80,7 @@ public class ScoreLogInfoController {
75 // } 80 // }
76 // } 81 // }
77 } 82 }
83 }
78 return builder.success(flag).code(code).create(); 84 return builder.success(flag).code(code).create();
79 } 85 }
80 86
...@@ -118,6 +124,14 @@ public class ScoreLogInfoController { ...@@ -118,6 +124,14 @@ public class ScoreLogInfoController {
118 return builder.success(true).code("2000").content(l).create(); 124 return builder.success(true).code("2000").content(l).create();
119 } 125 }
120 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 }
134
121 // public static void main(String[] args) { 135 // public static void main(String[] args) {
122 // String 136 // String
123 // access_token="4_ei8KYHlVKGE8zLguYGl7iHLEBf28u4nAzxocOMXGvzKoPxpU3Dxr_kq8cQlfDD34qFiJWgQpYxj3k3gobg0hyA"; 137 // access_token="4_ei8KYHlVKGE8zLguYGl7iHLEBf28u4nAzxocOMXGvzKoPxpU3Dxr_kq8cQlfDD34qFiJWgQpYxj3k3gobg0hyA";
......
...@@ -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
......