From 6350b5e4c758208ef215bc7f883ea489aad11625 Mon Sep 17 00:00:00 2001 From: Yixian Date: Wed, 23 Feb 2022 10:47:53 +0800 Subject: [PATCH] add logs --- .../core/impls/ClientManagerImpl.java | 38 +++++++++-------- .../payment/manage/valid/ImageTest.java | 42 +++++++++++++++++++ 2 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 src/test/java/au/com/royalpay/payment/manage/valid/ImageTest.java diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 9bde522ff..e8f2aa83c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -603,10 +603,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("aps_config_id", apsConfig.getId()); client.put("alipay_cn_switch", apsConfig.getAlipayCnSwitch()); } - Boolean overseaSwitch= overseaSwitchConfigMapper.getOverseaSwitch(client.getInteger("client_id")); - if(overseaSwitch==null||overseaSwitch){ + Boolean overseaSwitch = overseaSwitchConfigMapper.getOverseaSwitch(client.getInteger("client_id")); + if (overseaSwitch == null || overseaSwitch) { client.put("oversea_wallet_switch", true); - }else{ + } else { client.put("oversea_wallet_switch", false); } return client; @@ -2189,7 +2189,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid JSONObject configJson = config.toJSON(); BigDecimal transactionFeeDecimal = config.getTransactionFee(); TransactionFee transFee = Optional.ofNullable(paymentApi.channelCalculator(config.getRateName())) - .map(calculator->calculator.convertTransactionFee(transactionFeeDecimal)) + .map(calculator -> calculator.convertTransactionFee(transactionFeeDecimal)) .orElse(TransactionFee.ZERO); configJson.put("transaction_fee", transFee.storeValue()); JSONObject org = orgMapper.findOne(client.getIntValue("org_id")); @@ -2709,6 +2709,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid ImageIO.write(background, "jpeg", ous); ous.flush(); IOUtils.closeQuietly(ous); + } else { + logger.error("get aggregate poster file failed:[{}]", boardBackgroundResult.getStatusCode(), + boardBackgroundResult.getResponseContentString(), boardBackgroundResult.getException()); } } catch (IOException e) { throw new ServerErrorException("Error", e); @@ -4982,6 +4985,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid /** * 支付宝aps海外钱包 开关 + * * @param manager * @param clientMoniker * @param enableOverseaWallet @@ -4994,19 +4998,19 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } checkOrgPermission(manager, client); - Boolean overseaSwitch= overseaSwitchConfigMapper.getOverseaSwitch(client.getIntValue("client_id")); - logger.info("======>overseaSwitch:{}",overseaSwitch); - if(overseaSwitch==null){ - ApsOverseasConfigData data = ApsOverseasConfigData.saveData(manager.getString("manager_id"),client.getString("client_id"),enableOverseaWallet); - logger.info("=======>data:OverseasSwitch:{}",data.getOverseasSwitch()); - overseaSwitchConfigMapper.save(data); - }else{ - JSONObject config=new JSONObject(); - config.put("clientId", client.getString("client_id")); - config.put("modifier", manager.getString("manager_id")); - config.put("overseas_switch", enableOverseaWallet); - overseaSwitchConfigMapper.updateApsOverseasConfigByClientId(config); - } + Boolean overseaSwitch = overseaSwitchConfigMapper.getOverseaSwitch(client.getIntValue("client_id")); + logger.info("======>overseaSwitch:{}", overseaSwitch); + if (overseaSwitch == null) { + ApsOverseasConfigData data = ApsOverseasConfigData.saveData(manager.getString("manager_id"), client.getString("client_id"), enableOverseaWallet); + logger.info("=======>data:OverseasSwitch:{}", data.getOverseasSwitch()); + overseaSwitchConfigMapper.save(data); + } else { + JSONObject config = new JSONObject(); + config.put("clientId", client.getString("client_id")); + config.put("modifier", manager.getString("manager_id")); + config.put("overseas_switch", enableOverseaWallet); + overseaSwitchConfigMapper.updateApsOverseasConfigByClientId(config); + } } @Override diff --git a/src/test/java/au/com/royalpay/payment/manage/valid/ImageTest.java b/src/test/java/au/com/royalpay/payment/manage/valid/ImageTest.java new file mode 100644 index 000000000..d1b72d958 --- /dev/null +++ b/src/test/java/au/com/royalpay/payment/manage/valid/ImageTest.java @@ -0,0 +1,42 @@ +package au.com.royalpay.payment.manage.valid; + +import au.com.royalpay.payment.tools.env.PlatformEnvironment; +import au.com.royalpay.payment.tools.exceptions.ServerErrorException; +import cn.yixblog.platform.http.HttpRequestGenerator; +import cn.yixblog.platform.http.HttpRequestResult; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.io.IOUtils; +import org.junit.Test; +import org.springframework.web.bind.annotation.RequestMethod; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +public class ImageTest { + + @Test + public void test() throws IOException { + try (ByteArrayOutputStream ous = new ByteArrayOutputStream()){ + HttpRequestResult boardBackgroundResult = new HttpRequestGenerator("https://au.rpaygroup.com/static/images/post.jpg", + RequestMethod.GET).execute(); + if (boardBackgroundResult.isSuccess()) { + InputStream ins = boardBackgroundResult.getResponseContentStream(); + BufferedImage background = ImageIO.read(ins); + IOUtils.closeQuietly(ins); + // Graphics g = background.getGraphics(); + // drawPosterLogo(client, g); + // g.dispose(); + + ImageIO.write(background, "jpeg", ous); + ous.flush(); + System.out.println(ous.toByteArray().length); + } + } catch (IOException e) { + throw new ServerErrorException("Error", e); + } + } +}