diff --git a/ruoyi-admin/src/main/java/com/ruoyi/business/controller/MeituanController.java b/ruoyi-admin/src/main/java/com/ruoyi/business/controller/MeituanController.java index 7d1194b..e5adad4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/business/controller/MeituanController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/business/controller/MeituanController.java @@ -14,6 +14,7 @@ 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.client.utils.URLEncodedUtils; import org.apache.http.entity.StringEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.impl.client.CloseableHttpClient; @@ -22,6 +23,7 @@ import org.apache.http.util.EntityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.net.URLEncoder; import java.util.*; /** @@ -61,8 +63,8 @@ public class MeituanController { * @return */ @GetMapping("/getOrders") - public R orders() { - return iMeituanService.orderInfo(); + public R orders(String wmPoiId, String date, String cookie) { + return iMeituanService.orderInfo(wmPoiId, date, cookie); } @@ -72,8 +74,8 @@ public class MeituanController { * @throws Exception */ @GetMapping("/getPriPhone") - public R priPhone(String orderId) { - return iMeituanService.priPhoneInfo(orderId); + public R priPhone(String orderId,String regionId,String regionVersion,String cookie) { + return iMeituanService.priPhoneInfo(orderId, regionId, regionVersion, cookie); } /** @@ -97,34 +99,8 @@ public class MeituanController { } @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 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 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); + public String mtgsig(String orderId,String regionId,String regionVersion) { + return iMeituanService.mtgsigInfo(orderId,regionId,regionVersion); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/business/service/IMeituanService.java b/ruoyi-system/src/main/java/com/ruoyi/business/service/IMeituanService.java index ced25c9..8209cc8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/business/service/IMeituanService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/business/service/IMeituanService.java @@ -7,7 +7,8 @@ public interface IMeituanService { String getScore(); - R orderInfo(); - R priPhoneInfo(String orderId); + R orderInfo(String wmPoiId, String date, String cookie); + R priPhoneInfo(String orderId,String regionId,String regionVersion,String cookie); + String mtgsigInfo(String orderId,String regionId,String regionVersion); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/MeituanServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/MeituanServiceImpl.java index 4424ad6..ddb5403 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/MeituanServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/MeituanServiceImpl.java @@ -13,8 +13,11 @@ import com.ruoyi.common.utils.HttpClientUtilT; 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.beans.factory.annotation.Autowired; @@ -22,6 +25,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import java.io.IOException; +import java.net.URLEncoder; import java.util.*; import java.util.stream.Collectors; @@ -57,16 +61,15 @@ public class MeituanServiceImpl implements IMeituanService { } @Override - public R orderInfo() { + public R orderInfo(String wmPoiId, String date, String cookie) { int pageNum = 1; - JSONObject jsonObject = merchantOrders(pageNum,"2024-07-03", - "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; pushToken=08Y-B6R3RJh0vWW3sunjIls8g5ks282V0XDqw0_8uK2I*; shopCategory=food; JSESSIONID=on7soe32fcruh809e5hfls7z; acctId=196975850; token=0pU06uu_iGAHgwhFO85t0G6PZxaoBiSNFdZyi2pS2mG0*; wmPoiId=21737990; isOfflineSelfOpen=0; city_id=510100; isChain=0; ignore_set_router_proxy=false; region_id=1000510100; region_version=1717637457; bsid=19mI8ZOraG-XXNAMJ2qmJEDbBIf97CFoQ_ndkcmZM0iBR9UKTpOcERrZsXLftuuJUJ6l1nOl3Q5pc0lul3KOWw; 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; setPrivacyTime=1_20240704; wpush_server_url=wss://wpush.meituan.com; logan_session_token=h11r1rr8yb4n872vhlsr; _lxsdk_s=1907b53fb56-164-582-76a%7C%7C62"); + JSONObject jsonObject = merchantOrders(pageNum, date, cookie); String code = jsonObject.getString("code"); if ("0".equals(code)) { JSONArray array = jsonObject.getJSONObject("data").getJSONArray("wmOrderList"); boolean flag = false; - String key = "wmPoiId" + "2024-06-28"; + String key = wmPoiId + date; String lastDayseq = Optional.ofNullable(redisTemplate.opsForValue().get(key)).orElse(null); while (array != null && array.size() > 0) { if (flag){ @@ -110,8 +113,7 @@ public class MeituanServiceImpl implements IMeituanService { } } pageNum += 1; - JSONObject jo = merchantOrders(pageNum, "2024-07-03", - "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; pushToken=08Y-B6R3RJh0vWW3sunjIls8g5ks282V0XDqw0_8uK2I*; shopCategory=food; JSESSIONID=on7soe32fcruh809e5hfls7z; acctId=196975850; token=0pU06uu_iGAHgwhFO85t0G6PZxaoBiSNFdZyi2pS2mG0*; wmPoiId=21737990; isOfflineSelfOpen=0; city_id=510100; isChain=0; ignore_set_router_proxy=false; region_id=1000510100; region_version=1717637457; bsid=19mI8ZOraG-XXNAMJ2qmJEDbBIf97CFoQ_ndkcmZM0iBR9UKTpOcERrZsXLftuuJUJ6l1nOl3Q5pc0lul3KOWw; 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; setPrivacyTime=1_20240704; wpush_server_url=wss://wpush.meituan.com; logan_session_token=h11r1rr8yb4n872vhlsr; _lxsdk_s=1907b53fb56-164-582-76a%7C%7C62"); + JSONObject jo = merchantOrders(pageNum, date, cookie); if("0".equals(jo.getString("code"))){ array = jo.getJSONObject("data").getJSONArray("wmOrderList"); } else { @@ -163,16 +165,17 @@ public class MeituanServiceImpl implements IMeituanService { } @Override - public R priPhoneInfo(String orderId) { + public R priPhoneInfo(String orderId,String regionId,String regionVersion,String cookie) { String url = "https://e.waimai.meituan.com/v2/order/history/r/search/ajax"; Map params = new LinkedHashMap<>(); params.put("searchItem",orderId); - params.put("region_id","1000440100"); - params.put("region_version","1687236854"); + params.put("region_id",regionId); + params.put("region_version",regionVersion); params.put("yodaReady","h5"); params.put("csecplatform",4); params.put("csecversion","2.4.0"); - params.put("mtgsig","%7B%22a1%22%3A%221.1%22%2C%22a2%22%3A1719559430105%2C%22a3%22%3A%221719555287467YYKUWIAfd79fef3d01d5e9aadc18ccd4d0c95077155%22%2C%22a5%22%3A%22RysVtjJl6dwe7UCBGvbf%22%2C%22a6%22%3A%22hs1.4aOG4x69iuIGtADfqn9IKcTw1%2FkgMmU2b7SKfkduAyV5JdsMP7K%2FyaI4LzRA7LmuUUNuW8gACTFDnxuSagQ8j8Q%3D%3D%22%2C%22x0%22%3A4%2C%22d1%22%3A%224ddede8d030621664d0ad9194ed8ffee%22%7D"); + String mtgsig = mtgsigInfo(orderId,regionId,regionVersion); + params.put("mtgsig",mtgsig); String param = "?"; for (Map.Entry stringObjectEntry : params.entrySet()) { param = param + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue()+"&"; @@ -184,7 +187,7 @@ public class MeituanServiceImpl implements IMeituanService { HttpPost httpPost = new HttpPost(url); HttpEntity entity = builder.build(); httpPost.setEntity(entity); - httpPost.setHeader("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; pushToken=08Y-B6R3RJh0vWW3sunjIls8g5ks282V0XDqw0_8uK2I*; shopCategory=food; JSESSIONID=on7soe32fcruh809e5hfls7z; acctId=196975850; token=0pU06uu_iGAHgwhFO85t0G6PZxaoBiSNFdZyi2pS2mG0*; wmPoiId=21737990; isOfflineSelfOpen=0; city_id=510100; isChain=0; ignore_set_router_proxy=false; region_id=1000510100; region_version=1717637457; bsid=19mI8ZOraG-XXNAMJ2qmJEDbBIf97CFoQ_ndkcmZM0iBR9UKTpOcERrZsXLftuuJUJ6l1nOl3Q5pc0lul3KOWw; 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; setPrivacyTime=1_20240704; wpush_server_url=wss://wpush.meituan.com; logan_session_token=h11r1rr8yb4n872vhlsr; _lxsdk_s=1907b53fb56-164-582-76a%7C%7C62"); + httpPost.setHeader("Cookie",cookie); String resp = null; try { HttpResponse response = client.execute(httpPost); @@ -219,7 +222,42 @@ public class MeituanServiceImpl implements IMeituanService { return R.ok(JSON.toJSON(list)); } } - return R.fail("获取手机号码失败"); + return R.fail("获取手机号码失败"+resp); + } + + @Override + public String mtgsigInfo(String orderId,String regionId,String regionVersion) { + 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 subUrlParams = new LinkedHashMap<>(); + subUrlParams.put("url","https://e.waimai.meituan.com/v2/order/history/r/search/ajax?"); + subUrlParams.put("searchItem",orderId); + subUrlParams.put("region_id",regionId); + subUrlParams.put("region_version",regionVersion); + 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 stringObjectEntry : subUrlParams.entrySet()) { + urlParam = urlParam + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue()+"&"; + } + String result = null; + try { + StringEntity params = new StringEntity(urlParam.substring(0, urlParam.length()-1)); + httpPost.setEntity(params); + CloseableHttpResponse response = httpClient.execute(httpPost); + result = EntityUtils.toString(response.getEntity()); + }catch (Exception e) { + e.printStackTrace(); + } + return URLEncoder.encode(result); } /**