@Override
public void setTingLogisticsNumber(SetTingLogisticsNumberReq request, SetTingLogisticsNumberResp response) {
int success = 0;
int failure = 0;
if (request.expressId == 1) {
String regex = "(^[A-Z]{2}[0-9]{9}[A-Z]{2}$)";
boolean flag = Pattern.matches(regex, request.startNo);
if (flag) {
Long ref = tradeMapper.selectExpressShipNo(request.startNo);
if (ref == 0) {
List<String> expressShipNoList = CreateEMS(request.startNo, request.tradeIdList.size());
for (int i = 0; i < expressShipNoList.size(); i++) {
String expressShipNo = expressShipNoList.get(i);
String tradeId = request.getTradeIdList().get(i);
try {
tradeMapper.setTingLogisticsNumber(expressShipNo, Long.parseLong(tradeId));
success++;
} catch (NumberFormatException e) {
LOG.error(e);
failure++;
}
}
response.errorCode = success;
response.errorMessage = "设置成功" + success + "条," + "失败" + failure + "条";
} else {
response.errorCode = 0;
response.errorMessage = "快递单号已存在!请重新输入";
}
} else {
response.errorCode = 0;
response.errorMessage = "格式不正确!请重新输入";
}
}