|
|
|
|
@ -1,5 +1,7 @@ |
|
|
|
|
package org.springblade.modules.weixin.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
@ -16,7 +18,11 @@ import org.springblade.modules.weixin.entity.WeChatUser; |
|
|
|
|
import org.springblade.modules.weixin.service.IWeChatUserService; |
|
|
|
|
import org.springblade.modules.weixin.utils.WeChatUtil; |
|
|
|
|
import org.springblade.modules.weixin.utils.WxPayUtils; |
|
|
|
|
import org.springframework.http.HttpEntity; |
|
|
|
|
import org.springframework.http.HttpHeaders; |
|
|
|
|
import org.springframework.http.MediaType; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
@ -90,7 +96,19 @@ public class AppEbLoginController { |
|
|
|
|
|
|
|
|
|
@PostMapping("/createOrder") |
|
|
|
|
public R createOrder(String openId) { |
|
|
|
|
return R.data(WxPayUtils.createOrderJSApiV3(openId)); |
|
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
|
String url = "https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi"; |
|
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
|
headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8")); |
|
|
|
|
|
|
|
|
|
String content = JSON.toJSONString(WxPayUtils.buildWxJsApiV3PayJson(openId, 0)); |
|
|
|
|
|
|
|
|
|
HttpEntity<String> httpEntity = new HttpEntity<>(content, headers); |
|
|
|
|
|
|
|
|
|
// 发送post请求,并输出结果
|
|
|
|
|
String s = restTemplate.postForObject(url, httpEntity, String.class); |
|
|
|
|
return R.data(s); |
|
|
|
|
// return R.data(WxPayUtils.createOrderJSApiV3(openId));
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|