|
@@ -13,6 +13,7 @@ import com.miaxis.common.core.page.ResponsePageInfo;
|
|
import com.miaxis.common.sms.MD5Utils;
|
|
import com.miaxis.common.sms.MD5Utils;
|
|
import com.miaxis.common.utils.SecurityUtils;
|
|
import com.miaxis.common.utils.SecurityUtils;
|
|
import com.miaxis.common.utils.StringUtils;
|
|
import com.miaxis.common.utils.StringUtils;
|
|
|
|
+import com.miaxis.common.utils.uuid.CommonUtils;
|
|
import com.miaxis.customer.dto.AppletCustomerInfoDto;
|
|
import com.miaxis.customer.dto.AppletCustomerInfoDto;
|
|
import com.miaxis.customer.service.ICustomerInfoService;
|
|
import com.miaxis.customer.service.ICustomerInfoService;
|
|
import com.miaxis.customer.vo.ExhibitionCustomerInfoVo;
|
|
import com.miaxis.customer.vo.ExhibitionCustomerInfoVo;
|
|
@@ -35,9 +36,14 @@ import org.apache.http.impl.client.HttpClientBuilder;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.security.PrivateKey;
|
|
|
|
+import java.security.Signature;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -58,16 +64,21 @@ public class FilmController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private WxpayConfig wxpayConfig;
|
|
private WxpayConfig wxpayConfig;
|
|
|
|
|
|
|
|
+ @Value("${app.appid}")
|
|
|
|
+ private String appid;
|
|
|
|
+
|
|
private static String appKey = "10000000000";
|
|
private static String appKey = "10000000000";
|
|
|
|
|
|
private static String appSecret = "25f9e794323b453885f5181f1b624d0b";
|
|
private static String appSecret = "25f9e794323b453885f5181f1b624d0b";
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 微信支付获取预订单id
|
|
* 微信支付获取预订单id
|
|
*/
|
|
*/
|
|
@GetMapping(value = "/prepareOrder")
|
|
@GetMapping(value = "/prepareOrder")
|
|
@ApiOperation("微信支付获取预订单id")
|
|
@ApiOperation("微信支付获取预订单id")
|
|
- public Response getPrepareOrderId() throws Exception{
|
|
|
|
|
|
+ public Response<JSONObject> getPrepareOrderId() throws Exception{
|
|
HttpPost httpPost = new HttpPost(wxpayConfig.getV3url());
|
|
HttpPost httpPost = new HttpPost(wxpayConfig.getV3url());
|
|
httpPost.addHeader("Accept", "application/json");
|
|
httpPost.addHeader("Accept", "application/json");
|
|
httpPost.addHeader("Content-type","application/json; charset=utf-8");
|
|
httpPost.addHeader("Content-type","application/json; charset=utf-8");
|
|
@@ -89,14 +100,32 @@ public class FilmController extends BaseController {
|
|
httpPost.setEntity(new StringEntity(bos.toString("UTF-8")));
|
|
httpPost.setEntity(new StringEntity(bos.toString("UTF-8")));
|
|
HttpResponse response = httpClient.execute(httpPost);
|
|
HttpResponse response = httpClient.execute(httpPost);
|
|
String bodyAsString = EntityUtils.toString(response.getEntity());
|
|
String bodyAsString = EntityUtils.toString(response.getEntity());
|
|
|
|
+ String packageStr = "prepay_id="+JSONObject.parseObject(bodyAsString).get("prepay_id");
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
- jsonObject.put("package",bodyAsString.replaceAll("\"",""));
|
|
|
|
|
|
+ jsonObject.put("package",packageStr);
|
|
String nonce_str = RandomStringUtils.randomAlphanumeric(32);
|
|
String nonce_str = RandomStringUtils.randomAlphanumeric(32);
|
|
jsonObject.put("nonceStr",nonce_str);
|
|
jsonObject.put("nonceStr",nonce_str);
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- return Response.success();
|
|
|
|
|
|
+ long timestamp = System.currentTimeMillis()/1000;
|
|
|
|
+ jsonObject.put("timeStamp",timestamp);
|
|
|
|
+ jsonObject.put("signType","RSA");
|
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
|
+ sb.append(appid + "\\n");
|
|
|
|
+ sb.append(timestamp + "\\n");
|
|
|
|
+ sb.append(nonce_str + "\\n");
|
|
|
|
+ sb.append(packageStr+ "\\n");
|
|
|
|
+ System.out.println(sb);
|
|
|
|
+
|
|
|
|
+ File file = new ClassPathResource("wechatpay/apiclient_key.pem").getFile();
|
|
|
|
+ String realPath =file.getAbsolutePath();
|
|
|
|
+ PrivateKey privateKey = CommonUtils.getPrivateKey(realPath);
|
|
|
|
+ // 进行签名服务
|
|
|
|
+ Signature signature = Signature.getInstance("SHA256withRSA");
|
|
|
|
+ signature.initSign(privateKey);
|
|
|
|
+ signature.update(sb.toString().getBytes("UTF-8"));
|
|
|
|
+ byte[] signedData = signature.sign();
|
|
|
|
+ String base64Str = Base64.getEncoder().encodeToString(signedData);
|
|
|
|
+ jsonObject.put("paySign",base64Str);
|
|
|
|
+ return Response.success(jsonObject);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|