|
@@ -31,6 +31,7 @@ import org.apache.http.HttpResponse;
|
|
|
import org.apache.http.HttpStatus;
|
|
|
import org.apache.http.client.HttpClient;
|
|
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
+import org.apache.http.client.methods.HttpGet;
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
import org.apache.http.entity.StringEntity;
|
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
@@ -45,6 +46,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.security.PrivateKey;
|
|
|
import java.security.Signature;
|
|
|
import java.util.*;
|
|
@@ -132,6 +134,7 @@ public class FilmController extends BaseController {
|
|
|
order.setSeatId(filmOrderCreateDTO.getSeatId());
|
|
|
order.setSeatno(filmOrderCreateDTO.getSeatno());
|
|
|
order.setReservedPhone(filmOrderCreateDTO.getReservedPhone());
|
|
|
+ order.setOpenid(student.getOpenid());
|
|
|
filmOrderService.save(order);
|
|
|
|
|
|
|
|
@@ -160,6 +163,7 @@ public class FilmController extends BaseController {
|
|
|
byte[] signedData = signature.sign();
|
|
|
String base64Str = Base64.getEncoder().encodeToString(signedData);
|
|
|
jsonObject.put("paySign",base64Str);
|
|
|
+ jsonObject.put("outTradeNo",orderCode);
|
|
|
return Response.success(jsonObject);
|
|
|
|
|
|
}
|
|
@@ -242,6 +246,30 @@ public class FilmController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 微信支付查单接口
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/wxorder/{outTradeNo}")
|
|
|
+ @ApiOperation("根据订单号查询订单状态")
|
|
|
+ public Response<String> getOrderInfo(
|
|
|
+ @ApiParam(name = "outTradeNo", value = "商户订单号", required = true)
|
|
|
+ @PathVariable("outTradeNo") String outTradeNo
|
|
|
+ ) throws IOException {
|
|
|
+ HttpGet get = new HttpGet("https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/"
|
|
|
+ +outTradeNo+"?mchid="+wxpayConfig.getMerchantId());
|
|
|
+ get.addHeader("Accept", "application/json");
|
|
|
+ HttpResponse response = httpClient.execute(get);
|
|
|
+ String bodyAsString = EntityUtils.toString(response.getEntity());
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(bodyAsString);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ return Response.success(jsonObject.getString("trade_state"));
|
|
|
+ } else {
|
|
|
+ throw new CustomException(EntityUtils.toString(response.getEntity()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|