|
@@ -1,20 +1,28 @@
|
|
|
package com.jeeplus.modules.wexintheorder.Utils;
|
|
|
|
|
|
+import com.jeeplus.modules.statement.entity.StatementDataInfo;
|
|
|
import com.jeeplus.modules.wexinpackage.access.util.access.AccessTokenUtil;
|
|
|
import com.jeeplus.modules.wexinpackage.access.util.access.RequestAccess;
|
|
|
import com.jeeplus.modules.wexinpackage.access.util.access.WeChatParamsUtil;
|
|
|
import com.jeeplus.modules.wexintheorder.entity.TheOrder;
|
|
|
import net.sf.json.JSONObject;
|
|
|
+import org.codehaus.jackson.map.ObjectMapper;
|
|
|
import org.junit.Test;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
+import java.io.IOException;
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
+import java.time.Instant;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.ZoneOffset;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
|
|
|
public class OrderUtils {
|
|
|
|
|
@@ -222,4 +230,92 @@ public class OrderUtils {
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //查询小程序使用的token
|
|
|
+ public static String getToken(String corpId,String corpsecret){
|
|
|
+ String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=ID&corpsecret=SECRET";//获取用户信息
|
|
|
+ String sureUrl = url.replace("ID", corpId).replace("SECRET",corpsecret);
|
|
|
+ System.out.println("url============="+sureUrl);
|
|
|
+ JSONObject jsonObject = RequestAccess.httpRequest(sureUrl, "POST", null);
|
|
|
+ System.out.println("jsonObject========="+jsonObject);
|
|
|
+ String string = jsonObject.getString("access_token");
|
|
|
+ if (null != jsonObject) {
|
|
|
+ if (0 != jsonObject.getInt("errcode")) {
|
|
|
+ System.out.println("成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return string;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //查询用户打卡记录
|
|
|
+ public static JSONObject getCheckInData(String token, List<String> userIdList,String startDate,String endDate){
|
|
|
+ String string = "";
|
|
|
+ JSONObject jsonObject = null;
|
|
|
+ try {
|
|
|
+ String url = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata?access_token=ACCESS_TOKEN";//获取用户信息
|
|
|
+ String sureUrl = url.replace("ACCESS_TOKEN", token);
|
|
|
+ System.out.println("url============="+sureUrl);
|
|
|
+
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("opencheckindatatype","1");
|
|
|
+
|
|
|
+
|
|
|
+ map.put("starttime",getDateTimestamp(startDate));
|
|
|
+ map.put("endtime",getDateTimestamp(endDate));
|
|
|
+ map.put("useridlist",userIdList);
|
|
|
+
|
|
|
+
|
|
|
+ String content = mapper.writeValueAsString(map);
|
|
|
+
|
|
|
+ jsonObject = RequestAccess.httpRequest(sureUrl, "POST", content);
|
|
|
+ System.out.println("jsonObject========="+jsonObject);
|
|
|
+ if (0 != jsonObject.getInt("errcode")) {
|
|
|
+ //string = jsonObject.getString("access_token");
|
|
|
+ return jsonObject;
|
|
|
+ }else{
|
|
|
+ string = jsonObject.getString("checkindata");
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static long getDateTimestamp(String timeString) {
|
|
|
+ // 定义时间格式
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ // 解析字符串时间为 LocalDateTime
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.parse(timeString, formatter);
|
|
|
+
|
|
|
+ // 转换为 Instant 并获取秒数
|
|
|
+ long timestamp = localDateTime.toEpochSecond(ZoneOffset.UTC);
|
|
|
+
|
|
|
+ System.out.println("10位时间戳: " + timestamp); // 输出: 1492732800
|
|
|
+ return timestamp;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getDateByTimestamp(long dateStamp) {// 示例Unix时间戳(10位)
|
|
|
+
|
|
|
+ // 转换为Instant对象
|
|
|
+ Instant instant = Instant.ofEpochSecond(dateStamp);
|
|
|
+
|
|
|
+ // 转换为系统默认时区的LocalDateTime对象
|
|
|
+ LocalDateTime dateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
|
|
+
|
|
|
+ // 定义日期时间格式化器
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ // 格式化日期时间
|
|
|
+ String formattedDateTime = dateTime.format(formatter);
|
|
|
+
|
|
|
+ // 输出结果
|
|
|
+ System.out.println("Unix时间戳: " + dateStamp);
|
|
|
+ System.out.println("格式化后的日期时间: " + formattedDateTime);
|
|
|
+ return formattedDateTime;
|
|
|
+ }
|
|
|
}
|