接口对接

This commit is contained in:
Lenovo 2024-07-02 11:56:39 +08:00
parent 0946b3566c
commit 7d2afbcee3
2 changed files with 121 additions and 5 deletions

View File

@ -1,27 +1,44 @@
package com.ruoyi.business.controller;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.business.domain.SysCookie;
import com.ruoyi.business.utils.HttpClientUtilT;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 调用美团接口
*/
@RestController
@RequestMapping("/mt")
public class MeituanController {
/**
* 获取cookies
* @param cookie
* @return
*/
@PostMapping(value = "/cookies")
public AjaxResult cookie(@RequestBody SysCookie cookie)
{
return AjaxResult.success();
}
/**
* 获取订单
* @return
@ -39,8 +56,7 @@ public class MeituanController {
for (Map.Entry<String, Object> stringObjectEntry : params.entrySet()) {
param = param + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue()+"&";
}
param = param.substring(0, param.length()-1);
url=url+param;
url = url + param.substring(0, param.length()-1);
Map<String,String> headers = new HashMap<>();
headers.put("Cookie", "WEBDFPID=81x675y2y0x156y20z8194xvv5622uv180938x0x565979585zu21vx7-2034987530564-1719627530564QGCGCKGfd79fef3d01d5e9aadc18ccd4d0c95072413; _lxsdk_cuid=19061b46258c8-0a575a85246371-d373666-1fa400-19061b4625873; _lxsdk=19061b46258c8-0a575a85246371-d373666-1fa400-19061b4625873; device_uuid=!f681d2ae-d8e3-44ae-abed-9319cef9b9a1; uuid_update=true; shopCategory=food; JSESSIONID=1uja6towq16yyjlh5bsieyjib; acctId=196975850; token=08Y-B6R3RJh0vWW3sunjIls8g5ks282V0XDqw0_8uK2I*; wmPoiId=21737990; isOfflineSelfOpen=0; city_id=510100; isChain=0; ignore_set_router_proxy=false; region_id=1000510100; region_version=1717637457; bsid=owwHans2BfoYdNrDqfvWbv2A2saE_AOD_UtRrtJNH0nhZDvBSKHje0DOtzsvg4RQ1sA0nGCkn25eIU2f8BViXA; city_location_id=510100; location_id=510107; has_not_waimai_poi=0; cityId=210100; provinceId=210000; set_info=%7B%22wmPoiId%22%3A%2221737990%22%2C%22region_id%22%3A%221000510100%22%2C%22region_version%22%3A1717637457%7D; wpush_server_url=wss://wpush.meituan.com; pushToken=08Y-B6R3RJh0vWW3sunjIls8g5ks282V0XDqw0_8uK2I*; setPrivacyTime=1_20240701; logan_session_token=9i1ql2qeonn9g01klg1m; _lxsdk_s=1906ce6f1b5-623-dde-89d%7C%7C75");
Map<String,Object> body = new HashMap<>();
@ -137,4 +153,35 @@ public class MeituanController {
return R.ok(result);
}
@GetMapping("/getMtgsig")
public R mtgsig() throws Exception{
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
String url = "http://43.140.224.18:12000/get_mtgsig";
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
Map<String,Object> subUrlParams = new LinkedHashMap<>();
subUrlParams.put("url","https://e.waimai.meituan.com/v2/order/history/r/search/ajax?");
subUrlParams.put("searchItem","2001141341103646099");
subUrlParams.put("region_id","1000440100");
subUrlParams.put("region_version","1687236854");
subUrlParams.put("yodaReady","h5");
subUrlParams.put("csecplatform",4);
subUrlParams.put("csecversion","2.4.0");
subUrlParams.put("data","");
subUrlParams.put("dfpid","x528894270u555uvyz734vu21zz348v08095w0y4y68979584766w00y");
String urlParam = "";
for (Map.Entry<String, Object> stringObjectEntry : subUrlParams.entrySet()) {
urlParam = urlParam + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue()+"&";
}
StringEntity params = new StringEntity(urlParam.substring(0, urlParam.length()-1));
httpPost.setEntity(params);
CloseableHttpResponse response = httpClient.execute(httpPost);
String result = EntityUtils.toString(response.getEntity());
return R.ok(result);
}
}

View File

@ -0,0 +1,69 @@
package com.ruoyi.business.domain;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 通知公告表 sys_notice
*
* @author ruoyi
*/
public class SysCookie extends BaseEntity
{
private static final long serialVersionUID = 1L;
private int bingType;
private String cookie;
private String userName;
private String account;
private String password;
private String wmPoiName;
public void setBingType(int bingType) {
this.bingType = bingType;
}
public void setCookie(String cookie) {
this.cookie = cookie;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setAccount(String account) {
this.account = account;
}
public void setPassword(String password) {
this.password = password;
}
public void setWmPoiName(String wmPoiName) {
this.wmPoiName = wmPoiName;
}
public int getBingType() {
return bingType;
}
public String getCookie() {
return cookie;
}
public String getUserName() {
return userName;
}
public String getAccount() {
return account;
}
public String getPassword() {
return password;
}
public String getWmPoiName() {
return wmPoiName;
}
}