订单拉取解析增加redis删除

This commit is contained in:
Lenovo 2024-08-01 08:16:52 +08:00
parent fc5e0af648
commit b1f85cd3ab
1 changed files with 21 additions and 11 deletions

View File

@ -383,6 +383,13 @@ public class MeituanServiceImpl implements IMeituanService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public R orderInfo(String wmPoiId, String date, String cookie) { public R orderInfo(String wmPoiId, String date, String cookie) {
try { try {
LocalDate localDate = LocalDate.parse(date);
LocalDate prevDay = localDate.minusDays(1);
String oldKey = wmPoiId + prevDay.toString();
if (redisTemplate.opsForValue().get(oldKey) != null){
redisTemplate.delete(oldKey);
}
int pageNum = 1; int pageNum = 1;
String getUrl = proxyProperties.gettpsUrl(); String getUrl = proxyProperties.gettpsUrl();
JSONObject jsonObject = merchantOrders(getUrl,pageNum, date, cookie); JSONObject jsonObject = merchantOrders(getUrl,pageNum, date, cookie);
@ -442,9 +449,9 @@ public class MeituanServiceImpl implements IMeituanService {
if (redisDaySeq == null) { if (redisDaySeq == null) {
redisTemplate.opsForValue().set(key, daySeq); redisTemplate.opsForValue().set(key, daySeq);
} else { } else {
// if (Integer.valueOf(daySeq) > Integer.valueOf(redisDaySeq)) { if (Integer.valueOf(daySeq) > Integer.valueOf(redisDaySeq)) {
// redisTemplate.opsForValue().set(key, daySeq); redisTemplate.opsForValue().set(key, daySeq);
// } }
if (daySeq.equals(lastDayseq)) { if (daySeq.equals(lastDayseq)) {
flag = true; flag = true;
break; break;
@ -517,7 +524,7 @@ public class MeituanServiceImpl implements IMeituanService {
}catch (Exception e){ }catch (Exception e){
System.out.println("================拉取订单出错:==============="+e.getMessage()); System.out.println("================拉取订单出错:==============="+e.getMessage());
// return orderInfo(wmPoiId, date, cookie); // return orderInfo(wmPoiId, date, cookie);
return R.fail("=====================拉取订单出错=================="); return R.fail("拉取订单出错");
} }
} }
@ -600,6 +607,9 @@ public class MeituanServiceImpl implements IMeituanService {
orderInfo.setPrivcyPhone(privacyPhone); orderInfo.setPrivcyPhone(privacyPhone);
orderInfo.setRecipientPhone(recipientPhone); orderInfo.setRecipientPhone(recipientPhone);
orderInfo.setRecipientBindedPhone(recipientBindedPhone); orderInfo.setRecipientBindedPhone(recipientBindedPhone);
System.out.println("****************订单解析成功:****************"+JSON.toJSONString(orderInfo));
lsList.add(orderInfo); lsList.add(orderInfo);
BusReturnVisitInfo returnVisitInfo = new BusReturnVisitInfo(); BusReturnVisitInfo returnVisitInfo = new BusReturnVisitInfo();
@ -614,16 +624,16 @@ public class MeituanServiceImpl implements IMeituanService {
e.printStackTrace(); e.printStackTrace();
continue; continue;
} }
lss.add(returnVisitInfo); lss.add(returnVisitInfo);
} }
} }
System.out.println("********************************"+JSON.toJSONString(lsList)); if (lsList.size() > 0) {
// if (lsList.size() > 0) { busOrderInfoMapper.batchInsertOrder(lsList);
// busOrderInfoMapper.batchInsertOrder(lsList); }
// } if (lss.size() > 0) {
// if (lss.size() > 0) { busReturnVisitInfoMapper.batchInsertVisit(lss);
// busReturnVisitInfoMapper.batchInsertVisit(lss); }
// }
} }
private String getOrderCountByType(String getUrl, String wmOrderViewId,String cookie){ private String getOrderCountByType(String getUrl, String wmOrderViewId,String cookie){