6a8587e7 by joe

增加统计方法

1 parent b7b44628
......@@ -18,9 +18,12 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -46,34 +49,37 @@ public class ScoreLogInfoController {
@RequestMapping("/save")
public MessageEntity save(HttpServletRequest request, @ModelAttribute ScoreLogInfo scoreLogInfo,
String access_token, String state, String timestamp, String rands, String jsondata, String checksum,
String secret) {
String secret) throws ParseException, UnsupportedEncodingException {
MessageEntity.Builder builder = new MessageEntity.Builder(request);
boolean flag = false;
String code = "9000";
String openid = scoreLogInfo.getOpenid();
if (StringUtils.isNotBlank(jsondata)) {
jsondata = URLDecoder.decode(jsondata);
ObjectMapper objectMapper = new ObjectMapper();
Map map = null;
try {
map = objectMapper.readValue(jsondata, Map.class);
} catch (IOException e) {
e.printStackTrace();
}
// if(map != null && map.containsKey("gtmc_code") &&
// map.get("gtmc_code").toString().equals("200")){
// String checksum1 = MD5Utils.hash(access_token +openid +state +timestamp
// +rands +jsondata +secret);
// if(checksum1.equals(checksum)){
scoreLogInfo.setGtmcUid(map.get("gtmc_uid").toString());
scoreLogInfo.setGtmcDepartment(map.get("gtmc_department").toString());
scoreLogInfo.setGtmcName(map.get("gtmc_name").toString());
code = this.scoreLogInfoService.save(scoreLogInfo);
if (code.equals("2000")) {
flag = true;
// String openid = scoreLogInfo.getOpenid();
Date lastDay = sdf.parse("2017-12-14 23:59:59");
if(lastDay.after(new Date())) {
if (StringUtils.isNotBlank(jsondata)) {
jsondata = URLDecoder.decode(jsondata,"utf-8");
ObjectMapper objectMapper = new ObjectMapper();
Map map = null;
try {
map = objectMapper.readValue(jsondata, Map.class);
} catch (IOException e) {
e.printStackTrace();
}
// if(map != null && map.containsKey("gtmc_code") &&
// map.get("gtmc_code").toString().equals("200")){
// String checksum1 = MD5Utils.hash(access_token +openid +state +timestamp
// +rands +jsondata +secret);
// if(checksum1.equals(checksum)){
scoreLogInfo.setGtmcUid(map.get("gtmc_uid").toString());
scoreLogInfo.setGtmcDepartment(map.get("gtmc_department").toString());
scoreLogInfo.setGtmcName(map.get("gtmc_name").toString());
code = this.scoreLogInfoService.save(scoreLogInfo);
if (code.equals("2000")) {
flag = true;
}
// }
// }
}
// }
// }
}
return builder.success(flag).code(code).create();
}
......@@ -117,6 +123,14 @@ public class ScoreLogInfoController {
long l = this.scoreLogInfoService.saveShare(openid);
return builder.success(true).code("2000").content(l).create();
}
@RequestMapping("/saveStat")
public MessageEntity saveStat(HttpServletRequest request, @RequestParam String openid) {
MessageEntity.Builder builder = new MessageEntity.Builder(request);
long l = this.scoreLogInfoService.saveStat(openid);
return builder.success(true).code("2000").content(l).create();
}
// public static void main(String[] args) {
// String
......
......@@ -69,7 +69,7 @@ public class WxController {
try {
readValue = mapper.readValue(responseEntity, Map.class);
if (null != readValue.get("errcode")) {
return null;
return builder.success(false).code("999").content(readValue).create();
}
} catch (IOException e) {
e.printStackTrace();;
......
......@@ -14,4 +14,6 @@ public interface ShareLogMapper {
long countByDay(@Param("openid") String openid, @Param("startDate") String startDate,
@Param("endDate") String endDate);
boolean saveStat(@Param("openid") String openid);
}
......
......@@ -23,4 +23,6 @@ public interface ScoreLogInfoService {
long saveShare(String openid);
long saveStat(String openid);
}
......
......@@ -109,4 +109,11 @@ public class ScoreLogInfoServiceImpl implements ScoreLogInfoService {
}
@Override
public long saveStat(String openid) {
shareLogMapper.saveStat(openid);
return 0;
}
}
......
......@@ -9,7 +9,7 @@
)
values(
#{openid},
#{share_time}
#{shareTime}
);
</insert>
......@@ -21,6 +21,13 @@
and openid= #{openid};
</select>
<insert id="saveStat">
insert into `t_kmr_stat_log`(
`openid`
) values (
#{openid}
)
</insert>
</mapper>
\ No newline at end of file
......