|
|
@@ -1,8 +1,13 @@
|
|
|
package org.dromara.backstage.wx.contorller;
|
|
|
|
|
|
import cn.hutool.core.codec.Base64;
|
|
|
+import cn.hutool.core.util.URLUtil;
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.backstage.business.payments.ThirdPayBusiness;
|
|
|
import org.dromara.backstage.payment.domain.vo.PtUserAccountVo;
|
|
|
import org.dromara.backstage.wx.domain.vo.WxCreditAccountVo;
|
|
|
@@ -24,6 +29,7 @@ import java.util.Map;
|
|
|
/**
|
|
|
* 微信
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Validated
|
|
|
@RequiredArgsConstructor
|
|
|
@RestController
|
|
|
@@ -91,14 +97,25 @@ public class WxController extends BaseController {
|
|
|
|
|
|
@PostMapping("/pay")
|
|
|
public R<String> wxPay(HttpServletRequest request, @RequestParam String ssoId, @RequestParam String transValue) {
|
|
|
- String userAgent = request.getHeader("user-agent");
|
|
|
- String userId = LoginHelper.getUserId().toString();
|
|
|
+ //String userAgent = request.getHeader("user-agent");
|
|
|
+ //String userId = LoginHelper.getUserId().toString();
|
|
|
String openId = Base64.decodeStr(ssoId);
|
|
|
- Map<String, String> mapParams = new HashMap<>();
|
|
|
- mapParams.put("userId", userId);
|
|
|
- mapParams.put("ssoId", openId);
|
|
|
- mapParams.put("dealValue", transValue);
|
|
|
- mapParams.put("userAgent", userAgent);
|
|
|
- return thirdPayBusiness.createDirectPayment(mapParams);
|
|
|
+ //Map<String, String> mapParams = new HashMap<>();
|
|
|
+ //mapParams.put("userId", userId);
|
|
|
+ //mapParams.put("ssoId", openId);
|
|
|
+ //mapParams.put("dealValue", transValue);
|
|
|
+ //mapParams.put("userAgent", userAgent);
|
|
|
+ //return thirdPayBusiness.createDirectPayment(mapParams);
|
|
|
+ String callBackUrl = "http://10.32.23.157:8080/pay-server/pay/back/1881509159999418369";
|
|
|
+ String payUrl = "https://portal.hnswdx.gov.cn/pay/toPay.html?openid=" + URLUtil.encode(openId) + "&price=" + transValue + "&title="
|
|
|
+ + URLUtil.encode("微信支付") + "&userAgent=MicroMessenger&detailsId=3&callBackUrl=" + callBackUrl;
|
|
|
+ log.info("支付地址");
|
|
|
+ HttpRequest req = HttpUtil.createGet(payUrl).header("user-agent", request.getHeader("user-agent"));
|
|
|
+ try (HttpResponse res = req.execute()) {
|
|
|
+ return R.ok(res.body());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("[微信支付错误]-[{0}]", e);
|
|
|
+ return R.fail(e.getLocalizedMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|