|
@@ -0,0 +1,93 @@
|
|
|
+package com.miaxis.app.controller.film;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
+import com.miaxis.common.config.WxpayConfig;
|
|
|
+import com.miaxis.common.constant.Constants;
|
|
|
+import com.miaxis.common.core.controller.BaseController;
|
|
|
+import com.miaxis.common.core.domain.Response;
|
|
|
+import com.miaxis.common.core.domain.entity.UserInfo;
|
|
|
+import com.miaxis.common.core.page.ResponsePageInfo;
|
|
|
+import com.miaxis.common.utils.SecurityUtils;
|
|
|
+import com.miaxis.customer.dto.AppletCustomerInfoDto;
|
|
|
+import com.miaxis.customer.service.ICustomerInfoService;
|
|
|
+import com.miaxis.customer.vo.ExhibitionCustomerInfoVo;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.Data;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
+import org.apache.http.client.HttpClient;
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 【小程序-客户信息】Controller
|
|
|
+ *
|
|
|
+ * @author miaxis
|
|
|
+ * @date 2021-03-10
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequiredArgsConstructor
|
|
|
+@RequestMapping(Constants.STUDENT_PREFIX+"/film/wxpay")
|
|
|
+@Api(tags = {"【小程序-电影】"})
|
|
|
+public class FilmController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private HttpClient httpClient;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WxpayConfig wxpayConfig;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 微信支付获取预订单id
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/prepareOrder")
|
|
|
+ @ApiOperation("微信支付获取预订单id")
|
|
|
+ public Response<PrepareOrderEntity> getPrepareOrderId() throws Exception{
|
|
|
+ HttpPost httpPost = new HttpPost(wxpayConfig.getV3url());
|
|
|
+ httpPost.addHeader("Accept", "application/json");
|
|
|
+ httpPost.addHeader("Content-type","application/json; charset=utf-8");
|
|
|
+
|
|
|
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+
|
|
|
+ ObjectNode rootNode = objectMapper.createObjectNode();
|
|
|
+ rootNode.put("mchid","1608699504")
|
|
|
+ .put("appid", "wx8f43db501343feab")
|
|
|
+ .put("description", "Image形象店-深圳腾大-QQ公仔")
|
|
|
+ .put("notify_url", "https://www.weixin.qq.com/wxpay/pay.php")
|
|
|
+ .put("out_trade_no", "1217752501201407033233368044");
|
|
|
+ rootNode.putObject("amount")
|
|
|
+ .put("total", 1);
|
|
|
+ rootNode.putObject("payer")
|
|
|
+ .put("openid", "oO7PJ5GVKa0c_rfU34yIO0RgfTTg");
|
|
|
+ objectMapper.writeValue(bos, rootNode);
|
|
|
+ httpPost.setEntity(new StringEntity(bos.toString("UTF-8")));
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ String bodyAsString = EntityUtils.toString(response.getEntity());
|
|
|
+ PrepareOrderEntity prepareOrderEntity = JSON.parseObject(bodyAsString,PrepareOrderEntity.class);
|
|
|
+ return Response.success(prepareOrderEntity);
|
|
|
+
|
|
|
+ }
|
|
|
+ @Data
|
|
|
+ public static class PrepareOrderEntity{
|
|
|
+ String prepay_id;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|