|
@@ -1,6 +1,7 @@
|
|
package com.mofangchuxing.aska.service.impl;
|
|
package com.mofangchuxing.aska.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.mofangchuxing.aska.dao.domain.*;
|
|
import com.mofangchuxing.aska.dao.domain.*;
|
|
@@ -13,6 +14,7 @@ import com.mofangchuxing.aska.service.ProfitSharingService;
|
|
import com.mofangchuxing.aska.service.utils.WxPayV3Utils;
|
|
import com.mofangchuxing.aska.service.utils.WxPayV3Utils;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -23,6 +25,9 @@ import javax.crypto.IllegalBlockSizeException;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.ArrayBlockingQueue;
|
|
|
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Author: syl
|
|
* @Author: syl
|
|
@@ -51,6 +56,8 @@ public class ProfitSharingServiceImpl implements ProfitSharingService {
|
|
private PayRequestMapper payRequestMapper;
|
|
private PayRequestMapper payRequestMapper;
|
|
@Resource
|
|
@Resource
|
|
private RestTemplate restTemplate;
|
|
private RestTemplate restTemplate;
|
|
|
|
+ @Resource
|
|
|
|
+ private FreezeMapper freezeMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void addSplitReceivers(String clientType, Long retailId, String couponNo) throws IllegalBlockSizeException, IOException {
|
|
public void addSplitReceivers(String clientType, Long retailId, String couponNo) throws IllegalBlockSizeException, IOException {
|
|
@@ -404,4 +411,31 @@ public class ProfitSharingServiceImpl implements ProfitSharingService {
|
|
log.info("testQuery = {}", jsonObject.toJSONString());
|
|
log.info("testQuery = {}", jsonObject.toJSONString());
|
|
return jsonObject;
|
|
return jsonObject;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public JSONObject queryLastMoney(String transactionId) {
|
|
|
|
+ String url = "https://api.mch.weixin.qq.com/v3/profitsharing/transactions/" + transactionId +"/amounts";
|
|
|
|
+ JSONObject jsonObject = wxPayV3Utils.getRequest(url, JSONObject.class);
|
|
|
|
+ log.info("queryLastMoney = {}", jsonObject.toJSONString());
|
|
|
|
+ return jsonObject;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void freeze() {
|
|
|
|
+ List<Freeze> freezeList = freezeMapper.getAllList();
|
|
|
|
+ ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 50, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(200000),
|
|
|
|
+ new BasicThreadFactory.Builder().namingPattern("thread-pool-").build());
|
|
|
|
+ for (int i = 0; i < freezeList.size(); i++) {
|
|
|
|
+ Freeze freeze = freezeList.get(i);
|
|
|
|
+ executor.execute(() -> {
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
+ param.put("out_order_no", "PF" + freeze.getOrderNo());
|
|
|
|
+ param.put("transaction_id", freeze.getTranId());
|
|
|
|
+ param.put("description", "解冻全部剩余资金");
|
|
|
|
+ String url = "https://api.mch.weixin.qq.com/v3/profitsharing/orders/unfreeze";
|
|
|
|
+ JSONObject jsonObject = wxPayV3Utils.postRequest(url, JSONUtil.toJsonStr(param), JSONObject.class);
|
|
|
|
+ log.info("freeze id = {} result = {}", freeze.getId(), jsonObject.toJSONString());
|
|
|
|
+ ThreadUtil.sleep(200);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|