fix cache bug~

master
eason.qian 7 years ago
parent 558c9fd771
commit 3cbdaf0339

@ -0,0 +1,9 @@
package au.com.royalpay.payment.manage.merchants.core;
public interface ClientInfoCacheSupport {
void clearClientCache(int clientId);
void clearClientMonikerCache(String clientMoniker);
}

@ -36,10 +36,6 @@ public interface ClientManager {
JSONObject getClientInfo(int clientId);
void clearClientCache(int clientId);
void clearClientMonikerCache(String clientMoniker);
JSONObject getClientInfoIgnoreInvalid(int clientId);
JSONObject getClientInfoByMoniker(String clientMoniker);

@ -0,0 +1,40 @@
package au.com.royalpay.payment.manage.merchants.core.impls;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class ClientInfoCacheSupportImpl implements ClientInfoCacheSupport{
@Resource
private ClientAccountMapper clientAccountMapper;
@Resource
private SignInAccountService signInAccountService;
@Resource
private ClientManager clientManager;
@Resource
private ClientInfoCacheSupport clientInfoCacheSupport;
@Override
@CacheEvict(value = ":app_client_info:", key = "''+#clientId")
public void clearClientCache(int clientId) {
List<JSONObject> accounts = clientAccountMapper.listPartnerAccounts(clientId);
for (JSONObject acc : accounts) {
signInAccountService.clearAccountCache(acc.getString("account_id"));
}
JSONObject client = clientManager.getClientInfo(clientId);
clientInfoCacheSupport.clearClientMonikerCache(client.getString("client_moniker"));
}
@Override
@CacheEvict(value = ":app_client_info_moniker:", key = "#clientMoniker")
public void clearClientMonikerCache(String clientMoniker) {
}
}

@ -16,29 +16,10 @@ import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper;
import au.com.royalpay.payment.manage.mappers.log.ClientsOperationLogMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAuditProcessMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
import au.com.royalpay.payment.manage.mappers.system.CommoditiesMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper;
import au.com.royalpay.payment.manage.merchants.beans.ActivityPosterBuilder;
import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientRateConfig;
import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo;
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
import au.com.royalpay.payment.manage.merchants.beans.SubMerchantIdApply;
import au.com.royalpay.payment.manage.mappers.system.*;
import au.com.royalpay.payment.manage.merchants.beans.*;
import au.com.royalpay.payment.manage.merchants.core.ClientComplyValidator;
import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.signin.beans.TodoNotice;
@ -67,21 +48,16 @@ import au.com.royalpay.payment.tools.merchants.qrboard.QRBoard;
import au.com.royalpay.payment.tools.merchants.qrboard.QRBoardProvider;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.utils.ImageUtils;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import au.com.royalpay.payment.tools.utils.PasswordUtils;
import au.com.royalpay.payment.tools.utils.PdfUtils;
import au.com.royalpay.payment.tools.utils.QRCodeUtils;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import au.com.royalpay.payment.tools.utils.*;
import au.com.royalpay.payment.tools.websocket.notify.PartnerPageEvent;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils;
@ -107,35 +83,23 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.*;
import java.math.BigDecimal;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.*;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission;
/**
@ -222,6 +186,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private MessageSource messageSource;
@Resource
private ClientsOperationLogMapper clientsOperationLogMapper;
@Resource
private ClientInfoCacheSupport clientInfoCacheSupport;
private static final String SOURCE_AGREE_FILE = "source_agree_file";
private static final String CLIENT_BANK_FILE = "client_bank_file";
@ -250,22 +216,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
return clientMapper.findClient(clientId);
}
@Override
@CacheEvict(value = ":app_client_info:", key = "''+#clientId")
public void clearClientCache(int clientId) {
List<JSONObject> accounts = clientAccountMapper.listPartnerAccounts(clientId);
for (JSONObject acc : accounts) {
signInAccountService.clearAccountCache(acc.getString("account_id"));
}
JSONObject client = getClientInfo(clientId);
clearClientMonikerCache(client.getString("client_moniker"));
}
@Override
@CacheEvict(value = ":app_client_info_moniker:", key = "#clientMoniker")
public void clearClientMonikerCache(String clientMoniker) {
}
@Override
public JSONObject getClientInfoIgnoreInvalid(int clientId) {
return clientMapper.findClientIgnoreInvalid(clientId);
@ -574,7 +524,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
clientMapper.update(updateInfo);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -600,7 +550,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientMapper.update(update);
}
}
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -637,7 +587,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
saveClientAuditProcess(client.getIntValue("client_id"), open_status, 5, "合规通过", manager);
}
}
clearClientCache(client.getIntValue("client_id"));
clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id"));
}
@Override
@ -658,7 +608,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
saveClientAuditProcess(client.getIntValue("client_id"), 10, 1, "绿色通道申请通过", manager);
sendCommissionWechatMessage(client);
initAdminUserAndSendEmail(manager, clientMoniker, client);
clearClientCache(client.getIntValue("client_id"));
clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id"));
}
private void initAdminUserAndSendEmail(JSONObject manager, String clientMoniker, JSONObject client) {
@ -716,7 +666,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
sendInitEmail(client, account.getString("username"), pwd);
}
}
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -836,7 +786,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
int clientId = client.getIntValue("client_id");
updateClientApproveEmailStatus(clientId, 1);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
private void updateClientApproveEmailStatus(int clientId, int status) {
@ -887,7 +837,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
checkOrgPermission(manager, client);
client.put(permissionKey, allow);
clientMapper.update(client);
clearClientCache(client.getIntValue("client_id"));
clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id"));
}
@Override
@ -1074,7 +1024,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
Assert.notNull(partner);
partner.put("enable_pay_notice", enable);
clientMapper.update(partner);
clearClientCache(partner.getIntValue("client_id"));
clientInfoCacheSupport.clearClientCache(partner.getIntValue("client_id"));
}
@Override
@ -1102,7 +1052,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
Assert.notNull(partner, "Merchant is null");
partner.put("enable_refund_auth", enable);
clientMapper.update(partner);
clearClientCache(partner.getIntValue("client_id"));
clientInfoCacheSupport.clearClientCache(partner.getIntValue("client_id"));
}
@Override
@ -1137,7 +1087,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
subClient.put("bd_user", managerId);
clientMapper.update(subClient);
}
clearClientCache(client.getIntValue("client_id"));
clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id"));
}
@Override
@ -1149,7 +1099,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
checkOrgPermission(manager, client);
client.put("credential_code", RandomStringUtils.random(32, true, true));
clientMapper.update(client);
clearClientCache(client.getIntValue("client_id"));
clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id"));
}
@Override
@ -1220,7 +1170,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
update.put("client_id", client.getIntValue("client_id"));
update.put("settle_hour", hour);
clientMapper.update(update);
clearClientCache(client.getIntValue("client_id"));
clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id"));
}
@Override
@ -1692,7 +1642,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
partner.put("client_id", clientId);
partner.put("timezone", timezone);
clientMapper.update(partner);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2194,8 +2144,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
client.put("refund_pwd", pwdHash);
client.put("refund_pwd_salt", salt);
clientMapper.update(client);
clearClientCache(client.getIntValue("client_id"));
clearClientMonikerCache(client.getString("client_moniker"));
clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id"));
}
@Override
@ -2227,7 +2176,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
update.put("client_id", clientId);
update.put("qrcode_surcharge", paySurcharge);
clientMapper.update(update);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2241,7 +2190,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
update.put("client_id", clientId);
update.put("api_surcharge", enableApiSurcharge);
clientMapper.update(update);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2255,7 +2204,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
update.put("client_id", clientId);
update.put("retail_surcharge", paySurcharge);
clientMapper.update(update);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2269,7 +2218,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
update.put("client_id", clientId);
update.put("tax_in_surcharge", taxInSurcharge);
clientMapper.update(update);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2285,13 +2234,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public void updateClientCleanDays(int clientId, int cleanDays) {
clientMapper.updateCleanDays(clientId, cleanDays);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
public void updateClientEmail(int clientId, String contact_email) {
clientMapper.updateClientEmail(clientId, contact_email);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2299,7 +2248,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
JSONObject client = clientDetail(manager, clientMoniker);
int clientId = client.getIntValue("client_id");
clientMapper.disableClient(clientId);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2593,7 +2542,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
checkOrgPermission(manager, client);
client.put("paypad_version", paypad_version);
clientMapper.update(client);
clearClientCache(client.getIntValue("client_id"));
clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id"));
}
@Override
@ -2607,7 +2556,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
updateObj.put("client_id", client.getIntValue("client_id"));
updateObj.put("paypad_version", paypad_version);
clientMapper.update(updateObj);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2630,7 +2579,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
actClientLog.put("operator_type",type);
clientsOperationLogMapper.save(actClientLog);
clearClientCache(client_id);
clientInfoCacheSupport.clearClientCache(client_id);
}
@ -2645,7 +2594,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
updateObj.put("client_id", client.getIntValue("client_id"));
updateObj.put("qrcode_surcharge", paySurcharge);
clientMapper.update(updateObj);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2659,7 +2608,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
updateObj.put("client_id", client.getIntValue("client_id"));
updateObj.put("api_surcharge", enableApiSurcharge);
clientMapper.update(updateObj);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2677,7 +2626,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
updateObj.put("client_id", client.getIntValue("client_id"));
updateObj.put("retail_surcharge", paySurcharge);
clientMapper.update(updateObj);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2705,7 +2654,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
updateObj.put("retail_surcharge", updateSurchargeDTO.getRetailSurcharge());
clientMapper.update(updateObj);
}
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2736,7 +2685,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} catch (Exception e) {
logger.error("RefusePartnerError=======:" + clientMoniker + "," + e.getMessage());
}
clearClientCache(client.getIntValue("client_id"));
clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id"));
}
@Override
@ -2769,7 +2718,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
BigDecimal customerSurchargeRate = new BigDecimal(appClientBean.getCustomerSurchargeRate()).setScale(2, BigDecimal.ROUND_HALF_DOWN);
setCustomerSurchargeRate(client.getString("client_moniker"), customerSurchargeRate);
}
clearClientCache(client_id);
clientInfoCacheSupport.clearClientCache(client_id);
}
@Override
@ -2783,7 +2732,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
update.put("client_id", clientId);
update.put("skip_clearing", skip_clearing);
clientMapper.update(update);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@ -2797,7 +2746,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
update.put("client_id", clientId);
update.put("gateway_upgrade", gatewayUpgrade);
clientMapper.update(update);
clearClientCache(clientId);
clientInfoCacheSupport.clearClientCache(clientId);
}
private void sendMessagetoCompliance(JSONObject client, String bd_user_name) {

@ -83,7 +83,7 @@ public class ManualSettleSupportImpl implements ManualSettleSupport {
todayTask.put("unsettle", unsettleReports);
BigDecimal totalClearing = unsettleReports.stream().map(report -> report.getBigDecimal("clearing_amount")).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
todayTask.put("total_clearing_amount", totalClearing);
BigDecimal totalSettle = unsettleReports.stream().map(report -> report.getBigDecimal("settle_amount")).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
BigDecimal totalSettle = unsettleReports.stream().map(report -> report.getBigDecimal("settle_amount")==null?BigDecimal.ZERO:report.getBigDecimal("settle_amount")).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
todayTask.put("total_settle_amount", totalSettle);
todayTask.put("desc", LocaleSupport.localeMessage("manual_settle.notice"));
}

Loading…
Cancel
Save