拼好饭订单解析
This commit is contained in:
parent
09a91cda78
commit
4704f1b9a8
|
@ -35,6 +35,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -382,21 +383,44 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
Object o = array.get(i);
|
Object o = array.get(i);
|
||||||
JSONObject oj = JSONObject.parseObject(JSON.toJSONString(o));
|
JSONObject oj = JSONObject.parseObject(JSON.toJSONString(o));
|
||||||
try {
|
try {
|
||||||
String isPhf = oj.getString("businessType");
|
String businessType = oj.getString("businessType");
|
||||||
JSONObject order0 = oj.getJSONObject("orderInfo");
|
JSONObject order0 = oj.getJSONObject("orderInfo");
|
||||||
JSONObject commonInfo = oj.getJSONObject("commonInfo");
|
JSONObject commonInfo = oj.getJSONObject("commonInfo");
|
||||||
|
String userId = commonInfo.getString("wmUserId");
|
||||||
|
String daySeq = ""; String wmOrderViewId = ""; String orderTimeFmt = ""; String expectTime = ""; String statusDesc = ""; String orderCount = "";
|
||||||
|
String privacyPhone = null; String recipientPhone = null; String recipientBindedPhone = null;
|
||||||
|
if ("1".equals(businessType)) {
|
||||||
JSONObject order1 = order0.getJSONObject("orderInfo");
|
JSONObject order1 = order0.getJSONObject("orderInfo");
|
||||||
JSONObject foodInfo = order0.getJSONObject("foodInfo");
|
JSONObject foodInfo = order0.getJSONObject("foodInfo");
|
||||||
JSONObject userLabelVo = foodInfo.getJSONObject("userLabelVo");
|
JSONObject userLabelVo = foodInfo.getJSONObject("userLabelVo");
|
||||||
JSONArray array1 = userLabelVo.getJSONArray("contents");
|
JSONArray array1 = userLabelVo.getJSONArray("contents");
|
||||||
String info = array1.getJSONObject(0).getString("info");
|
String info = array1.getJSONObject(0).getString("info");
|
||||||
JSONObject expectTimeVo = order1.getJSONObject("expectTimeVo");
|
JSONObject expectTimeVo = order1.getJSONObject("expectTimeVo");
|
||||||
String daySeq = order1.getString("dayseq");
|
daySeq = order1.getString("dayseq");
|
||||||
String wmOrderViewId = order1.getString("wmOrderViewId");
|
wmOrderViewId = order1.getString("wmOrderViewId");
|
||||||
String orderTimeFmt = order1.getString("orderTimeFmt");
|
orderTimeFmt = "2024-"+order1.getString("orderTimeFmt");
|
||||||
String expectTime = expectTimeVo.getString("expectTimeFmt");
|
expectTime = expectTimeVo.getString("expectTimeFmt");
|
||||||
String statusDesc = order1.getString("statusDesc");
|
statusDesc = order1.getString("statusDesc");
|
||||||
String userId = commonInfo.getString("wmUserId");
|
if ("门店新客".equals(info)){
|
||||||
|
orderCount = "1";
|
||||||
|
} else if (info.contains("下单")){
|
||||||
|
orderCount = info.substring(info.indexOf("下单")+2,info.length()-1);
|
||||||
|
}
|
||||||
|
}else if("2".equals(businessType)){
|
||||||
|
statusDesc = "用户已收餐";
|
||||||
|
wmOrderViewId = commonInfo.getString("wm_order_id_view");
|
||||||
|
orderTimeFmt = order0.getString("order_time_fmt");
|
||||||
|
expectTime = order0.getString("expectTimeFmt");
|
||||||
|
daySeq = commonInfo.getString("wm_poi_order_dayseq");
|
||||||
|
privacyPhone = order0.getString("privacy_phone");
|
||||||
|
recipientPhone = order0.getString("recipient_phone");
|
||||||
|
recipientBindedPhone = order0.getString("recipient_bindedPhone");
|
||||||
|
|
||||||
|
|
||||||
|
orderCount = getOrderCountByType(wmOrderViewId,cookie);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
String redisDaySeq = Optional.ofNullable(redisTemplate.opsForValue().get(key)).orElse(null);
|
String redisDaySeq = Optional.ofNullable(redisTemplate.opsForValue().get(key)).orElse(null);
|
||||||
if (redisDaySeq == null) {
|
if (redisDaySeq == null) {
|
||||||
redisTemplate.opsForValue().set(key, daySeq);
|
redisTemplate.opsForValue().set(key, daySeq);
|
||||||
|
@ -428,18 +452,17 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
orderInfo.setCompleteTime("2024-"+expectTime);
|
orderInfo.setCompleteTime("2024-"+expectTime);
|
||||||
orderInfo.setOrderStatus(statusDesc);
|
orderInfo.setOrderStatus(statusDesc);
|
||||||
orderInfo.setCustomId(userId);
|
orderInfo.setCustomId(userId);
|
||||||
if ("门店新客".equals(info)){
|
orderInfo.setOrderCount(orderCount);
|
||||||
orderInfo.setOrderCount("1");
|
orderInfo.setPrivcyPhone(privacyPhone);
|
||||||
} else if (info.contains("下单")){
|
orderInfo.setRecipientPhone(recipientPhone);
|
||||||
orderInfo.setOrderCount(info.substring(info.indexOf("下单")+2,info.length()-1));
|
orderInfo.setRecipientBindedPhone(recipientBindedPhone);
|
||||||
}
|
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||||
try {
|
try {
|
||||||
orderInfo.setOrderTime(format.parse("2024-"+orderTimeFmt));
|
orderInfo.setOrderTime(format.parse(orderTimeFmt));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new RuntimeException(e);
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
orderInfo.setIsPhf(isPhf);
|
orderInfo.setIsPhf(businessType);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
System.out.println(wmPoiId+" "+oj.toJSONString());
|
System.out.println(wmPoiId+" "+oj.toJSONString());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -449,20 +472,15 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
}
|
}
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
List<BusOrderInfo> newList = list.stream().collect(Collectors.toMap(BusOrderInfo::getOrderNo, p->p,(p1, p2)->p1)).values().stream().collect(Collectors.toList());
|
List<BusOrderInfo> newList = list.stream().collect(Collectors.toMap(BusOrderInfo::getOrderNo, p->p,(p1, p2)->p1)).values().stream().collect(Collectors.toList());
|
||||||
// list.stream().sorted(Comparator.comparing(OrderInfo::getDaySeq)).collect(Collectors.toList());
|
|
||||||
// int integral = iBusAgentInfoService.getIntegralByAccount(busStoreInfoMapper.getBindUserByStoreCode(wmPoiId));
|
|
||||||
// for (OrderInfo orderInfo : list) {
|
|
||||||
// System.out.println(orderInfo.getDaySeq() + "," + orderInfo.getWmOrderViewId() + "," + orderInfo.getExpectTimeFmt() + "," + orderInfo.getStatusDesc());
|
|
||||||
// BusOrderInfo busOrderInfo = new BusOrderInfo(orderInfo);
|
|
||||||
// busOrderInfo.setStoreCode(wmPoiId);
|
|
||||||
// busOrderInfoMapper.insertBusOrderInfo(busOrderInfo);
|
|
||||||
// priPhoneInfo(busOrderInfo.getId(),orderInfo.getWmOrderViewId(),cookie);
|
|
||||||
// }
|
|
||||||
busOrderInfoMapper.batchInsertOrder(newList);
|
busOrderInfoMapper.batchInsertOrder(newList);
|
||||||
|
|
||||||
priPhoneInfo(newList,cookie);
|
List<BusOrderInfo> newList1 = newList.stream().filter(x -> x.getPrivcyPhone() == null && x.getRecipientPhone() == null && x.getRecipientBindedPhone() == null).collect(Collectors.toList());
|
||||||
|
|
||||||
|
priPhoneInfo(newList1,cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
pageNum += 1;
|
pageNum += 1;
|
||||||
|
|
||||||
JSONObject jo = merchantOrders(pageNum, date, cookie);
|
JSONObject jo = merchantOrders(pageNum, date, cookie);
|
||||||
if ("0".equals(jo.getString("code"))) {
|
if ("0".equals(jo.getString("code"))) {
|
||||||
array = jo.getJSONObject("data").getJSONArray("wmOrderList");
|
array = jo.getJSONObject("data").getJSONArray("wmOrderList");
|
||||||
|
@ -488,6 +506,41 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
return R.fail(jsonObject.getString("msg"));
|
return R.fail(jsonObject.getString("msg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getOrderCountByType(String wmOrderViewId,String cookie){
|
||||||
|
CloseableHttpClient httpClient = proxyHttpClient();
|
||||||
|
String url = "https://e.waimai.meituan.com/gw/phf/v2/order/receive/processed/r/orderAsyncInfos/v3";
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("region_id", valueFromCookie("region_id",cookie));
|
||||||
|
params.put("region_version", valueFromCookie("region_version",cookie));
|
||||||
|
String wmPoiId = valueFromCookie("wmPoiId",cookie);
|
||||||
|
String cityId = valueFromCookie("cityId",cookie);
|
||||||
|
|
||||||
|
params.put("orderInfos", "[%7B%22wmOrderViewId%22:%22"+wmOrderViewId+"%22,%22wmPoiId%22:"+wmPoiId+",%22cityId%22:"+cityId+"%7D]");
|
||||||
|
|
||||||
|
params.put("yodaReady", "h5");
|
||||||
|
params.put("csecplatform", 4);
|
||||||
|
params.put("csecversion", "2.4.0");
|
||||||
|
params.put("mtgsig", mtgsigInfo(wmOrderViewId,valueFromCookie("region_id", cookie),valueFromCookie("region_version", cookie)));
|
||||||
|
url = appendParams(url, params);
|
||||||
|
HttpGet request = new HttpGet(url);
|
||||||
|
request.setHeader("Cookie",cookie);
|
||||||
|
request.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36");
|
||||||
|
String result = null;
|
||||||
|
try {
|
||||||
|
result = EntityUtils.toString(httpClient.execute(request).getEntity());
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
JSONObject json = JSONObject.parseObject(result);
|
||||||
|
String code = json.getString("code");
|
||||||
|
if ("0".equals(code)) {
|
||||||
|
JSONObject data = json.getJSONObject("data");
|
||||||
|
JSONObject info = data.getJSONObject(wmOrderViewId);
|
||||||
|
return info.getString("purchase_number");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private JSONObject merchantOrders(int pageNum, String date, String cookie) {
|
private JSONObject merchantOrders(int pageNum, String date, String cookie) {
|
||||||
String url = "https://e.waimai.meituan.com/gw/api/order/mix/history/list/common";
|
String url = "https://e.waimai.meituan.com/gw/api/order/mix/history/list/common";
|
||||||
Map<String, Object> params = new LinkedHashMap<>();
|
Map<String, Object> params = new LinkedHashMap<>();
|
||||||
|
|
Loading…
Reference in New Issue