master
kira 6 years ago
parent 234b07c54b
commit 58fb928ef2

@ -22,13 +22,13 @@ import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -67,15 +67,25 @@ public class PostponeClientTask {
Date yearTomorrow = DateUtils.addYears(tomorrow, 1);
String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd");
List<JSONObject> expiryClient = clientRateMapper.getAllExpiry(now);
StringBuilder sb = new StringBuilder();
List<JSONObject> successClients = new LinkedList<>();
if (CollectionUtils.isEmpty(expiryClient)) {
return;
}
Map<Integer, JSONObject> expiryClients = new HashMap<>();
expiryClient.forEach(p -> {
expiryClients.put(p.getInteger("client_id"), p);
for (JSONObject p : expiryClient) {
try {
modifyRate(now, yearTomorrow, expireDate, p, sb);
} catch (Exception ignore) {
continue;
}
}
sb.deleteCharAt(sb.length() - 1);
sendComplianceNotify(sb, expireDate);
});
expiryClients.values().forEach(p -> {
}
@Transactional
public void modifyRate(Date now, Date yearTomorrow, String expireDate, JSONObject p, StringBuilder sb) {
int client_id = p.getIntValue("client_id");
List<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(client_id);
List<JSONObject> clientRates = clientRateMapper.maxChannelExpiryTime(client_id, null);
@ -107,9 +117,8 @@ public class PostponeClientTask {
adminAccounts.forEach(o -> {
sendClientPostponeNotify(o, expireDate);
});
});
sendComplianceNotify(expiryClients, expireDate);
});
sb.append(p.getString("client_moniker"));
sb.append("、");
}
private void sendClientPostponeNotify(JSONObject account, String newExpireDate) {
@ -132,13 +141,7 @@ public class PostponeClientTask {
}
}
private void sendComplianceNotify(Map<Integer, JSONObject> clients, String newExpireDate) {
StringBuffer sb = new StringBuffer();
clients.values().forEach(p -> {
sb.append(p.getString("client_moniker"));
sb.append("、");
});
sb.deleteCharAt(sb.length() - 1);
private void sendComplianceNotify(StringBuilder sb, String newExpireDate) {
List<String> compliance = managerMapper.listOpenIdsOfCompliances();
compliance.forEach(p -> {
MpWechatApi api = mpWechatApiProvider.getApiFromOpenId(p);

Loading…
Cancel
Save