|
@@ -4,9 +4,10 @@ import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
+import com.fs.qw.domain.QwCompany;
|
|
|
import com.fs.qw.dto.ReceiptDto;
|
|
import com.fs.qw.dto.ReceiptDto;
|
|
|
-import com.fs.wx.kf.service.IWeixinKfService;
|
|
|
|
|
-import com.fs.wx.kf.vo.WeixinKfTokenVO;
|
|
|
|
|
|
|
+import com.fs.qw.service.IQwCompanyService;
|
|
|
|
|
+import com.fs.qwApi.service.QwApiService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -26,24 +27,11 @@ import java.util.Map;
|
|
|
public class WeWorkExternalPayService {
|
|
public class WeWorkExternalPayService {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private IWeixinKfService weixinKfService;
|
|
|
|
|
|
|
+ private QwApiService qwApiService;
|
|
|
|
|
|
|
|
- @Value("123")
|
|
|
|
|
- private String corpId;
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IQwCompanyService iQwCompanyService;
|
|
|
|
|
|
|
|
- @Value("123")
|
|
|
|
|
- private String corpSecret;
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取 access_token
|
|
|
|
|
- */
|
|
|
|
|
- private String getAccessToken() {
|
|
|
|
|
- WeixinKfTokenVO tokenVO = weixinKfService.getToken(corpId, corpSecret);
|
|
|
|
|
- if (tokenVO.getErrcode() != null && tokenVO.getErrcode() != 0) {
|
|
|
|
|
- throw new RuntimeException("获取企业微信access_token失败:" + tokenVO.getErrmsg());
|
|
|
|
|
- }
|
|
|
|
|
- return tokenVO.getAccess_token();
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 拉取所有收款记录(自动分页)
|
|
* 拉取所有收款记录(自动分页)
|
|
@@ -51,7 +39,10 @@ public class WeWorkExternalPayService {
|
|
|
* @param endTime 结束时间戳(秒)
|
|
* @param endTime 结束时间戳(秒)
|
|
|
* @param payeeUserid 可选,收款成员userid
|
|
* @param payeeUserid 可选,收款成员userid
|
|
|
*/
|
|
*/
|
|
|
- public List<ReceiptDto> fetchAllReceipts(Long beginTime, Long endTime, String payeeUserid) {
|
|
|
|
|
|
|
+ public List<ReceiptDto> fetchAllReceipts(Long beginTime, Long endTime, String payeeUserid,String corpId) {
|
|
|
|
|
+ QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
|
|
+ String openSecret = qwCompany.getOpenSecret();
|
|
|
|
|
+
|
|
|
List<ReceiptDto> allReceipts = new ArrayList<>();
|
|
List<ReceiptDto> allReceipts = new ArrayList<>();
|
|
|
String cursor = null;
|
|
String cursor = null;
|
|
|
|
|
|
|
@@ -67,7 +58,7 @@ public class WeWorkExternalPayService {
|
|
|
}
|
|
}
|
|
|
params.put("limit", 1000);
|
|
params.put("limit", 1000);
|
|
|
|
|
|
|
|
- String accessToken = getAccessToken();
|
|
|
|
|
|
|
+ String accessToken = qwApiService.getToken(corpId, openSecret);
|
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/externalpay/get_bill_list?access_token=" + accessToken;
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/externalpay/get_bill_list?access_token=" + accessToken;
|
|
|
|
|
|
|
|
// 发送 POST 请求
|
|
// 发送 POST 请求
|