订单收单时间优化
This commit is contained in:
parent
397488b9b5
commit
22c903c8ef
|
@ -98,7 +98,8 @@ public class MeituanController {
|
|||
// String ck = "WEBDFPID=1720313779673YKASQECfd79fef3d01d5e9aadc18ccd4d0c95072894-1720313779673-1720313779673YKASQECfd79fef3d01d5e9aadc18ccd4d0c95072894; _lxsdk_cuid=1908ab11622c8-05c631efe52fbf-26031d51-1fa400-1908ab11623c8; _lxsdk=1908ab11622c8-05c631efe52fbf-26031d51-1fa400-1908ab11623c8; device_uuid=!add95b49-6d31-414c-b096-458e40b710e0; uuid_update=true; shopCategory=food; JSESSIONID=166osatxa3vej17siwfi3kfzso; logan_session_token=y5xcyzjk6epwp80j79nx; acctId=160394866; token=0vqM7ZAhWG5gEXioWJq2CpJTDb5vmeQ64StlZHudt6Pk*; wmPoiId=18277065; isOfflineSelfOpen=0; city_id=440100; isChain=0; ignore_set_router_proxy=false; region_id=1000440100; region_version=1687236854; set_info=%7B%22ignoreSetRouterProxy%22%3Afalse%2C%22region_id%22%3A%221000440100%22%2C%22region_version%22%3A1687236854%2C%22wmPoiId%22%3A18277065%7D; bsid=LA-NjGQthUuIAYmATre3dMUaeO3fwl-hrGQwBLxOUSxeJmBKyXpk1tC7WdiUH4UoqHDtHHYPiymWJM5KJ80Vag; city_location_id=440100; location_id=440103; wpush_server_url=wss%3A%2F%2Fwpush.meituan.com; has_not_waimai_poi=0; _lxsdk_s=1908ab11624-5f4-1f2-8a6%7C%7C5";
|
||||
// String d = "2024-07-07";
|
||||
// String poiId = "18277065";
|
||||
return iMeituanService.orderInfo(wmPoiId, date, cookie);
|
||||
iMeituanService.orderInfo(wmPoiId, date, cookie);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,7 @@ public interface IMeituanService {
|
|||
* @param cookie
|
||||
* @return
|
||||
*/
|
||||
R orderInfo(String wmPoiId, String date, String cookie);
|
||||
void orderInfo(String wmPoiId, String date, String cookie);
|
||||
|
||||
/**
|
||||
* 获取号码
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.ruoyi.business.domain.BusStoreInfo;
|
|||
import com.ruoyi.business.mapper.BusStoreInfoMapper;
|
||||
import com.ruoyi.business.service.IMeituanService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -17,6 +18,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
* 自定义线程池 studentService换为ip
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AsyncTaskImpl {
|
||||
|
||||
@Autowired
|
||||
|
@ -31,13 +33,9 @@ public class AsyncTaskImpl {
|
|||
LocalDateTime now = LocalDateTime.now();
|
||||
//异步线程要做的事情
|
||||
for (BusStoreInfo store : busStoreInfoList) {
|
||||
R flag = iMeituanService.orderInfo(store.getStoreCode(),now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")),store.getStoreCookie());
|
||||
// R flag = R.fail();
|
||||
if (flag.getCode() != 200) {
|
||||
System.out.println(store.getStoreName()+"获取订单信息返回错误..."+store.getStoreCode());
|
||||
}
|
||||
iMeituanService.orderInfo(store.getStoreCode(),now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")),store.getStoreCookie());
|
||||
}
|
||||
System.out.println("end executeAsync");
|
||||
log.error("==================end executeAsync===============");
|
||||
}finally {
|
||||
countDownLatch.countDown();// 很关键, 无论上面程序是否异常必须执行countDown,否则await无法释放
|
||||
}
|
||||
|
|
|
@ -376,7 +376,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R orderInfo(String wmPoiId, String date, String cookie) {
|
||||
public void orderInfo(String wmPoiId, String date, String cookie) {
|
||||
try {
|
||||
int pageNum = 1;
|
||||
String getUrl = proxyProperties.gettpsUrl();
|
||||
|
@ -400,7 +400,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
JSONObject order0 = oj.getJSONObject("orderInfo");
|
||||
JSONObject commonInfo = oj.getJSONObject("commonInfo");
|
||||
String userId = commonInfo.getString("wmUserId");
|
||||
String daySeq = ""; String wmOrderViewId = ""; String orderTimeFmt = ""; String statusDesc = ""; String orderCount = "";
|
||||
String daySeq = ""; String wmOrderViewId = ""; String orderTimeFmt = ""; String statusDesc = ""; String orderCount = "";String expectTime = "";
|
||||
String privacyPhone = null; String recipientPhone = null; String recipientBindedPhone = null;
|
||||
JSONObject order1 = order0.getJSONObject("orderInfo");
|
||||
if ("1".equals(businessType)) {
|
||||
|
@ -439,6 +439,8 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
} else if (info.contains("下单")){
|
||||
orderCount = info.substring(info.indexOf("下单")+2,info.length()-1);
|
||||
}
|
||||
JSONObject expectTimeVo = order1.getJSONObject("expectTimeVo");
|
||||
expectTime = expectTimeVo.getString("expectTimeFmt");
|
||||
}else if("2".equals(businessType)){
|
||||
statusDesc = "用户已收餐";
|
||||
orderTimeFmt = order0.getString("order_time_fmt");
|
||||
|
@ -447,6 +449,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
recipientPhone = order0.getString("recipient_phone");
|
||||
recipientBindedPhone = order0.getString("recipient_bindedPhone");
|
||||
orderCount = getOrderCountByType(getUrl,wmOrderViewId,cookie);
|
||||
expectTime = order0.getString("expectTimeFmt");
|
||||
}
|
||||
|
||||
BusOrderInfo orderInfo = new BusOrderInfo();
|
||||
|
@ -458,8 +461,11 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
orderInfo.setStoreName(storeInfo1.getStoreName());
|
||||
|
||||
String reachTime = receiveTime(wmPoiId,cookie,wmOrderViewId,getUrl);
|
||||
|
||||
orderInfo.setCompleteTime(date+" "+reachTime);
|
||||
if (reachTime == null){
|
||||
orderInfo.setCompleteTime("2024-" + expectTime);
|
||||
}else {
|
||||
orderInfo.setCompleteTime(date + " " + reachTime);
|
||||
}
|
||||
orderInfo.setOrderStatus(statusDesc);
|
||||
orderInfo.setCustomId(userId);
|
||||
orderInfo.setOrderCount(orderCount);
|
||||
|
@ -480,35 +486,27 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
}
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
|
||||
priPhoneInfo(list, cookie, getUrl);
|
||||
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
|
||||
pageNum += 1;
|
||||
|
||||
JSONObject jo = merchantOrders(getUrl,pageNum, date, cookie);
|
||||
if ("0".equals(jo.getString("code"))) {
|
||||
array = jo.getJSONObject("data").getJSONArray("wmOrderList");
|
||||
} else if ("1001".equals(jo.getString("code"))) {
|
||||
storeInfo1.setGrantStatus("2");
|
||||
busStoreInfoMapper.updateBusStoreInfo(storeInfo1);
|
||||
log.error("掉线",jo.getString("msg"));
|
||||
return R.fail(jo.getString("msg"));
|
||||
log.error("掉线");
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
} else if ("1001".equals(code)) {
|
||||
storeInfo1.setGrantStatus("2");
|
||||
busStoreInfoMapper.updateBusStoreInfo(storeInfo1);
|
||||
}
|
||||
return R.fail(jsonObject.getString("msg"));
|
||||
}catch (Exception e){
|
||||
log.error("================拉取订单出错:==============="+e.getMessage());
|
||||
// return orderInfo(wmPoiId, date, cookie);
|
||||
return R.fail("拉取订单出错");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -598,8 +596,6 @@ public class MeituanServiceImpl implements IMeituanService {
|
|||
orderInfo.setRecipientPhone(recipientPhone);
|
||||
orderInfo.setRecipientBindedPhone(recipientBindedPhone);
|
||||
|
||||
// log.error("****************订单解析成功:****************"+JSON.toJSONString(orderInfo));
|
||||
|
||||
lsList.add(orderInfo);
|
||||
|
||||
BusReturnVisitInfo returnVisitInfo = new BusReturnVisitInfo();
|
||||
|
|
Loading…
Reference in New Issue