|
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.wechat.pay.java.core.certificate.CertificateDownloader;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
import org.apache.http.client.methods.HttpGet;
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
@@ -24,16 +25,19 @@ import org.jeecg.modules.pay.routing.WeChatProfitSharingService;
|
|
|
import org.jeecg.modules.pay.serverPay.HttpClientUtil;
|
|
|
import org.jeecg.modules.pay.serverPay.PayKit;
|
|
|
import org.jeecg.modules.pay.serverPay.RsaKit;
|
|
|
+import org.jeecg.modules.pay.unionPay.UnionPayUtils;
|
|
|
import org.jeecg.modules.system.app.entity.AppOrder;
|
|
|
import org.jeecg.modules.system.app.service.IAppOrderService;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.security.PrivateKey;
|
|
|
import java.security.cert.X509Certificate;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
@@ -136,6 +140,39 @@ public class payController {
|
|
|
return "success";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取分账结果
|
|
|
+ * @param out_order_no
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/getResult")
|
|
|
+ public JSONObject getResult(@RequestParam("out_order_no") String out_order_no){
|
|
|
+ AppOrder appOrder = appOrderService.getOne(Wrappers.lambdaQuery(AppOrder.class).eq(AppOrder::getOrderCode, out_order_no).last("limit 1"));
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("sub_mchid", WechatConstants.WECHAT_SUB_MCH_ID);
|
|
|
+ map.put("transaction_id", appOrder.getTransactionId());
|
|
|
+
|
|
|
+ String params = WechatPayV3Utils.formatUrlParam(map);
|
|
|
+ try {
|
|
|
+ String url = WechatUrlConstants.PAY_V3_GET_PROFIT_SHARING + "P"+out_order_no + "?" + params;
|
|
|
+// String url = "https://api.mch.weixin.qq.com/v3/profitsharing/orders/PD202509261128071344?sub_mchid=1726971843&transaction_id=4200002838202509266221070669";
|
|
|
+
|
|
|
+ JSONObject res = wechatPayV3Utils.sendGet(url);
|
|
|
+ log.info("微信服务商分账结果查询--------------------------------------------------wechatPay res:{}", res.toString());
|
|
|
+ return res;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单次分账测试
|
|
|
+ * @param out_order_no
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
@GetMapping(value = "/test1")
|
|
|
public JSONObject test(@RequestParam("out_order_no") String out_order_no) throws Exception {
|
|
|
|
|
@@ -164,8 +201,9 @@ public class payController {
|
|
|
profitSharingRequest
|
|
|
.setAppid(WechatConstants.WECHAT_SP_APPID)
|
|
|
.setSub_mchid(WechatConstants.WECHAT_SUB_MCH_ID)
|
|
|
- .setTransaction_id("4200002835202509151465989607")
|
|
|
- .setOut_order_no(out_order_no)
|
|
|
+ .setTransaction_id(appOrder.getTransactionId())
|
|
|
+// .setOut_order_no(out_order_no)
|
|
|
+ .setOut_order_no("P"+out_order_no)
|
|
|
.setReceivers(receivers)
|
|
|
.setUnfreeze_unsplit(Boolean.TRUE);
|
|
|
try {
|
|
@@ -177,6 +215,62 @@ public class payController {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 请求分账回退
|
|
|
+ * @param out_order_no
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/returnOrder")
|
|
|
+ public JSONObject returnOrder(@RequestParam("out_order_no") String out_order_no) throws Exception {
|
|
|
+ AppOrder appOrder = appOrderService.getOne(Wrappers.lambdaQuery(AppOrder.class).eq(AppOrder::getOrderCode, out_order_no).last("limit 1"));
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("sub_mchid",WechatConstants.WECHAT_SUB_MCH_ID);
|
|
|
+ map.put("out_order_no ","P"+out_order_no);
|
|
|
+ map.put("order_id",appOrder.getProfitSharingOrderId());
|
|
|
+ map.put("out_return_no","T"+out_order_no);
|
|
|
+ map.put("return_mchid","1723757626");
|
|
|
+ map.put("amount",1);
|
|
|
+ map.put("description","帝释天退还");
|
|
|
+ try {
|
|
|
+ JSONObject res = wechatPayV3Utils.sendPost(WechatUrlConstants.PAY_V3_RETURN_ORDER, JSONObject.from(map));
|
|
|
+ log.info("微信服务商分账回退--------------------------------------------------wechatPay res:{}", res.toString());
|
|
|
+ return res;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询分账回退结果
|
|
|
+ * @param out_order_no
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/getReturnOrder")
|
|
|
+ public JSONObject getReturnOrder(@RequestParam("out_order_no") String out_order_no) throws Exception {
|
|
|
+
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("sub_mchid", WechatConstants.WECHAT_SUB_MCH_ID);
|
|
|
+ map.put("out_order_no", "P" + out_order_no);
|
|
|
+
|
|
|
+ String params = WechatPayV3Utils.formatUrlParam(map);
|
|
|
+ try {
|
|
|
+ String url = WechatUrlConstants.PAY_V3_GET_RETURN_ORDER + "T" + out_order_no + "?" + params;
|
|
|
+// String url = "https://api.mch.weixin.qq.com/v3/profitsharing/orders/TD202509261128071344?sub_mchid=1726971843&out_order_no=PD202509261128071344";
|
|
|
+
|
|
|
+ JSONObject res = wechatPayV3Utils.sendGet(url);
|
|
|
+ log.info("微信服务商分账结果查询--------------------------------------------------wechatPay res:{}", res.toString());
|
|
|
+ return res;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping(value = "/test2")
|
|
|
public void CertificateDownloaderTest() {
|
|
|
//用于证书解密的密钥
|