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

Loading…
Cancel
Save