From ed58aae8ec44dee07def3f77dd23102822c545df Mon Sep 17 00:00:00 2001 From: Yixian Date: Fri, 12 Nov 2021 15:10:35 +0800 Subject: [PATCH] =?UTF-8?q?hotfix:=20=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=95=B0=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/impls/DashboardServiceImpl.java | 213 +++++++++--------- .../mappers/TransactionAnalysisMapper.xml | 32 +-- 2 files changed, 119 insertions(+), 126 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java index 0ef0aa84b..bfeed2463 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java @@ -39,7 +39,7 @@ import java.util.concurrent.TimeUnit; * Created by davep on 2016-07-28. */ @Service -public class DashboardServiceImpl implements DashboardService,DashboardAnalysisTask { +public class DashboardServiceImpl implements DashboardService, DashboardAnalysisTask { private Logger logger = LoggerFactory.getLogger(getClass()); @Resource private ClientAnalysisMapper clientAnalysisMapper; @@ -64,25 +64,24 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT private MerchantInfoProvider merchantInfoProvider; - @Override public JSONObject getCommonAnalysis1(JSONObject params) { String jsonStr = stringRedisTemplate.boundValueOps("org_commonAnalysis1" + params.getString("org_id") + params.getString("begin")).get(); JSONObject commonAnalysis1 = JSON.parseObject(jsonStr); - if(commonAnalysis1 != null){ + if (commonAnalysis1 != null) { return commonAnalysis1; } JSONObject res = new JSONObject(); - if(params.getDate("end").after(new Date())){ - if(params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){ - res = transactionAnalysisMapper.getClientTransaction(params); - }else { + if (params.getDate("end").after(new Date())) { + if (params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1)) == 0) { + res = transactionAnalysisMapper.getClientTransaction(params); + } else { res = customerAndOrdersStatisticsMapper.getCommonCount(params); } - }else { - res = customerAndOrdersStatisticsMapper.getCommonCount(params); + } else { + res = customerAndOrdersStatisticsMapper.getCommonCount(params); } - stringRedisTemplate.boundValueOps("org_commonAnalysis1"+params.getString("org_id")+params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES); + stringRedisTemplate.boundValueOps("org_commonAnalysis1" + params.getString("org_id") + params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES); return res; } @@ -91,7 +90,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT public JSONObject getCommonAnalysis3(JSONObject params) { String jsonStr = stringRedisTemplate.boundValueOps("org_commonAnalysis3" + params.getString("org_id") + params.getString("begin")).get(); JSONObject commonAnalysis3 = JSON.parseObject(jsonStr); - if(commonAnalysis3 != null){ + if (commonAnalysis3 != null) { return commonAnalysis3; } JSONObject res = new JSONObject(); @@ -100,7 +99,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT //res.put("total_partners", clientAnalysisMapper.countClients(params)); // 统计所有的商户,包括禁用的 res.put("total_partners", clientAnalysisMapper.countClientsAll(params)); - stringRedisTemplate.boundValueOps("org_commonAnalysis3"+params.getString("org_id")+params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES); + stringRedisTemplate.boundValueOps("org_commonAnalysis3" + params.getString("org_id") + params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES); return res; } @@ -108,25 +107,26 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT public JSONObject getCommonAnalysis2(JSONObject params) { String jsonStr = stringRedisTemplate.boundValueOps("org_commonAnalysis2" + params.getString("org_id") + params.getString("begin")).get(); JSONObject commonAnalysis2 = JSON.parseObject(jsonStr); - if(commonAnalysis2 != null){ + if (commonAnalysis2 != null) { return commonAnalysis2; } JSONObject res = new JSONObject(); - if(params.getDate("end").after(new Date())){ - if(params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){ + if (params.getDate("end").after(new Date())) { + if (params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1)) == 0) { res.put("total_customers", transactionAnalysisMapper.countCustomers(params)); res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params)); res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params)); - }else { + } else { res = getYesOrLasMonth(params); } - }else { + } else { res = getYesOrLasMonth(params); } - stringRedisTemplate.boundValueOps("org_commonAnalysis2"+params.getString("org_id")+params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES); + stringRedisTemplate.boundValueOps("org_commonAnalysis2" + params.getString("org_id") + params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES); return res; } - private JSONObject getYesOrLasMonth(JSONObject params){ + + private JSONObject getYesOrLasMonth(JSONObject params) { JSONObject res = new JSONObject(); res.put("traded_partners", customerAndOrdersStatisticsMapper.countTradedClients(params)); res.put("total_customers", customerAndOrdersStatisticsMapper.countTotalCustomers(params)); @@ -138,7 +138,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT public JSONObject getCommonAnalysis4(JSONObject params) { String jsonStr = stringRedisTemplate.boundValueOps("org_commonAnalysis4" + params.getString("org_id") + params.getString("begin")).get(); JSONObject commonAnalysis4 = JSON.parseObject(jsonStr); - if(commonAnalysis4 != null){ + if (commonAnalysis4 != null) { return commonAnalysis4; } JSONObject res = new JSONObject(); @@ -146,22 +146,22 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT if (!topOrders.isEmpty()) { res.put("top_amount_order", topOrders.get(0)); } - stringRedisTemplate.boundValueOps("org_commonAnalysis4"+params.getString("org_id")+params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES); + stringRedisTemplate.boundValueOps("org_commonAnalysis4" + params.getString("org_id") + params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES); return res; } @Override public List getTradeInTypes(JSONObject params) { - String jsonStr = stringRedisTemplate.boundValueOps("tradeInTypes"+params.getString("org_id")+ params.getString("begin")).get(); - List tradeInTypes = JSONObject.parseArray(jsonStr,JSONObject.class); - if(tradeInTypes != null){ + String jsonStr = stringRedisTemplate.boundValueOps("tradeInTypes" + params.getString("org_id") + params.getString("begin")).get(); + List tradeInTypes = JSONObject.parseArray(jsonStr, JSONObject.class); + if (tradeInTypes != null) { return tradeInTypes; } if (params.containsKey("client_id")) { clientManager.queryModifyClientIds(params.getInteger("client_id"), params); } List res = transactionAnalysisMapper.getTradeAmountInTypes(params); - stringRedisTemplate.boundValueOps("tradeInTypes"+params.getString("org_id")+ params.getString("begin")).set(res.toString(), 5, TimeUnit.MINUTES); + stringRedisTemplate.boundValueOps("tradeInTypes" + params.getString("org_id") + params.getString("begin")).set(res.toString(), 5, TimeUnit.MINUTES); return res; } @@ -175,14 +175,14 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT @Override public List getTopTradePartnersNew(JSONObject params) { - String jsonStr = stringRedisTemplate.boundValueOps("topTradePartnersNew"+params.getString("org_id")+ params.getString("begin")).get(); - List topTradePartnersNew = JSONObject.parseArray(jsonStr,JSONObject.class); - if(topTradePartnersNew != null){ + String jsonStr = stringRedisTemplate.boundValueOps("topTradePartnersNew" + params.getString("org_id") + params.getString("begin")).get(); + List topTradePartnersNew = JSONObject.parseArray(jsonStr, JSONObject.class); + if (topTradePartnersNew != null) { return topTradePartnersNew; } params.putIfAbsent("rankType", "aud_fee"); List res = clientAnalysisMapper.listPartnersTradeAmountNew(params); - stringRedisTemplate.boundValueOps("topTradePartnersNew"+params.getString("org_id")+ params.getString("begin")).set(res.toString(), 5, TimeUnit.MINUTES); + stringRedisTemplate.boundValueOps("topTradePartnersNew" + params.getString("org_id") + params.getString("begin")).set(res.toString(), 5, TimeUnit.MINUTES); return res; } @@ -277,6 +277,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT analysis.add(wechatHtml5); return analysis; } + @Override public List getPartnerTradeAnalysisInDays(JSONObject params) { int date_range = Integer.parseInt(DurationFormatUtils.formatPeriod(params.getDate("begin").getTime(), params.getDate("end").getTime(), "dd")); @@ -293,16 +294,16 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT @Override public List getTradeAnalysisInDays(JSONObject params) { - String jsonStr = stringRedisTemplate.boundValueOps("tradeAnalysisInDays"+params.getString("org_id")+ params.getString("begin")).get(); - List tradeAnalysisInDays = JSONObject.parseArray(jsonStr,JSONObject.class); - if(tradeAnalysisInDays != null){ + String jsonStr = stringRedisTemplate.boundValueOps("tradeAnalysisInDays" + params.getString("org_id") + params.getString("begin")).get(); + List tradeAnalysisInDays = JSONObject.parseArray(jsonStr, JSONObject.class); + if (tradeAnalysisInDays != null) { return tradeAnalysisInDays; } if (!params.containsKey("client_ids") && !params.containsKey("org_id")) { params.put("client_id", 0); } List res = customerAndOrdersStatisticsMapper.getSumCustomersAnalysis(params); - stringRedisTemplate.boundValueOps("tradeAnalysisInDays"+params.getString("org_id")+ params.getString("begin")).set(res.toString(), 5, TimeUnit.MINUTES); + stringRedisTemplate.boundValueOps("tradeAnalysisInDays" + params.getString("org_id") + params.getString("begin")).set(res.toString(), 5, TimeUnit.MINUTES); return res; } @@ -330,11 +331,11 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT params.put("client_id", partner.getIntValue("client_id")); clientManager.queryModifyClientIds(partner.getIntValue("client_id"), params); JSONObject today = getTransJSONO(params); - params.put("begin",DateUtils.addDays(params.getDate("begin"),-1)); - params.put("end",DateUtils.addDays(params.getDate("end"),-1)); + params.put("begin", DateUtils.addDays(params.getDate("begin"), -1)); + params.put("end", DateUtils.addDays(params.getDate("end"), -1)); JSONObject yes = getTransJSONO(params); - res.put("today",today); - res.put("yes",yes); + res.put("today", today); + res.put("yes", yes); // res.put("not_settled", new BigDecimal(transactionAnalysisMapper.analysisNotSettled(params))); // params.put("channel", "system"); // res.put("sys_not_settled", new BigDecimal(transactionAnalysisMapper.analysisNotSettled(params))); @@ -342,18 +343,19 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT // res.put("rpaypmt_card_not_settled", new BigDecimal(transactionAnalysisMapper.analysisNotSettled(params))); // params.put("channel", "rpaypmt_dd"); // res.put("rpaypmt_dd_not_settled", new BigDecimal(transactionAnalysisMapper.analysisNotSettled(params))); - res.put("trade_amount_rise",yes.getBigDecimal("trade_amount").compareTo(BigDecimal.ZERO)>0 ? (today.getBigDecimal("trade_amount").subtract(yes.getBigDecimal("trade_amount"))).divide(yes.getBigDecimal("trade_amount"), 4, RoundingMode.HALF_UP):BigDecimal.ZERO); + res.put("trade_amount_rise", yes.getBigDecimal("trade_amount").compareTo(BigDecimal.ZERO) > 0 ? (today.getBigDecimal("trade_amount").subtract(yes.getBigDecimal("trade_amount"))).divide(yes.getBigDecimal("trade_amount"), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); res.put("trade_count_rise", yes.getIntValue("trade_count") > 0 ? (today.getBigDecimal("trade_count").subtract(yes.getBigDecimal("trade_count"))).divide(yes.getBigDecimal("trade_count"), 4, RoundingMode.HALF_UP) : 0); res.put("customers_rise", yes.getIntValue("customers") > 0 ? (today.getBigDecimal("customers").subtract(yes.getBigDecimal("customers"))).divide(yes.getBigDecimal("customers"), 4, RoundingMode.HALF_UP) : 0); params.remove("begin"); params.remove("end"); List logs = transactionMapper.listSettlementLogTotal(params); - res.put("latest_settle",logs.isEmpty()?BigDecimal.ZERO:logs.get(0).getBigDecimal("income")); + res.put("latest_settle", logs.isEmpty() ? BigDecimal.ZERO : logs.get(0).getBigDecimal("income")); return res; } /** * 根据渠道号分别加载未清算金额 + * * @param partner * @param partnerAnalysisBean * @return @@ -374,16 +376,17 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT params.put("hide_sub_mch", mchConfig.getBooleanValue("hide_sub_mch")); params.put("client_id", partner.getIntValue("client_id")); clientManager.queryModifyClientIds(partner.getIntValue("client_id"), params); - params.put("begin",DateUtils.addDays(params.getDate("begin"),-1)); - params.put("end",DateUtils.addDays(params.getDate("end"),-1)); - String key="not_settled"; - if(StringUtils.isNotEmpty(params.getString("channel"))){ - key=params.getString("channel")+"_not_settled"; + params.put("begin", DateUtils.addDays(params.getDate("begin"), -1)); + params.put("end", DateUtils.addDays(params.getDate("end"), -1)); + String key = "not_settled"; + if (StringUtils.isNotEmpty(params.getString("channel"))) { + key = params.getString("channel") + "_not_settled"; } res.put(key, new BigDecimal(transactionAnalysisMapper.analysisNotSettled(params))); return res; } - private JSONObject getTransJSONO(JSONObject params){ + + private JSONObject getTransJSONO(JSONObject params) { JSONObject res = new JSONObject(); JSONObject object = transactionAnalysisMapper.getClientTransaction(params); res.put("trade_amount", object.getBigDecimal("trade_amount")); @@ -391,6 +394,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT res.put("customers", transactionAnalysisMapper.countCustomers(params)); return res; } + @Override public List getTradeAnalysisInHours(JSONObject partner, AnalysisBean partnerAnalysisBean) { String timezone = partner.getJSONObject("client").getString("timezone"); @@ -446,22 +450,22 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT throw new ParamInvalidException("end", "error.payment.valid.invalid_time"); } List listChannelRate = new ArrayList<>(); - Map exchangeRateMap = new TreeMap<>(); - String[] channels = {"Wechat","Alipay"}; - for (String channel:channels){ + Map exchangeRateMap = new TreeMap<>(); + String[] channels = {"Wechat", "Alipay"}; + for (String channel : channels) { channelsExchangeRate(beginDate, endDate, exchangeRateMap, channel); } - for (Date date:exchangeRateMap.keySet()){ + for (Date date : exchangeRateMap.keySet()) { JSONObject total = exchangeRateMap.get(date); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd "); String time = sdf.format(date); - total.put("date",time); - for (String channel:channels){ - if(total.getJSONObject(channel)==null){ + total.put("date", time); + for (String channel : channels) { + if (total.getJSONObject(channel) == null) { JSONObject mockAnalysis = new JSONObject(); - mockAnalysis.put("exchange_rate",0); - mockAnalysis.put("date",time); - total.put(channel,mockAnalysis); + mockAnalysis.put("exchange_rate", 0); + mockAnalysis.put("date", time); + total.put(channel, mockAnalysis); } } listChannelRate.add(total); @@ -469,17 +473,17 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT return listChannelRate; } - public void channelsExchangeRate(Date beginDate,Date endDate,Map exchangeRateMap, String channel){ + public void channelsExchangeRate(Date beginDate, Date endDate, Map exchangeRateMap, String channel) { - List channelRates = exchangeRateMapper.listExchangeRates(beginDate, endDate,channel); - for (JSONObject analysisItem:channelRates){ + List channelRates = exchangeRateMapper.listExchangeRates(beginDate, endDate, channel); + for (JSONObject analysisItem : channelRates) { Date date = analysisItem.getDate("date"); JSONObject dataItem = exchangeRateMap.get(date); - if(dataItem==null){ + if (dataItem == null) { dataItem = new JSONObject(); - exchangeRateMap.put(date,dataItem); + exchangeRateMap.put(date, dataItem); } - dataItem.put(channel,analysisItem); + dataItem.put(channel, analysisItem); } } @@ -502,16 +506,16 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT public JSONObject getNewRecord() { String jsonStr = stringRedisTemplate.boundValueOps("newRecord").get(); JSONObject newRecord = JSON.parseObject(jsonStr); - if(newRecord != null){ + if (newRecord != null) { return newRecord; } JSONObject max_amount = customerAndOrdersStatisticsMapper.getMaxAmount(0); JSONObject max_orders = customerAndOrdersStatisticsMapper.getMaxOrders(0); JSONObject maxTransactionPartners = customerAndOrdersStatisticsMapper.getMaxTransactionPartners(); JSONObject res = new JSONObject(); - res.put("max_amount",max_amount); - res.put("max_orders",max_orders); - res.put("max_transaction_partners",maxTransactionPartners); + res.put("max_amount", max_amount); + res.put("max_orders", max_orders); + res.put("max_transaction_partners", maxTransactionPartners); stringRedisTemplate.boundValueOps("newRecord").set(res.toJSONString(), 5, TimeUnit.MINUTES); return res; } @@ -523,29 +527,31 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT } @Override - public void generateCustomersAndOrdersStatistics(Date analysisDate){ + public void generateCustomersAndOrdersStatistics(Date analysisDate) { DateFormat format = new SimpleDateFormat("yyyyMMdd"); String date = format.format(analysisDate); - List clients =clientMapper.listClients(); - for (JSONObject client:clients){ + List clients = clientMapper.listClients(); + for (JSONObject client : clients) { generateData(format, date, client); } JSONObject totalObject = new JSONObject(); - totalObject.put("client_id",0); - generateData(format,date,totalObject); + totalObject.put("client_id", 0); + generateData(format, date, totalObject); + logger.info("generate customer and orders statistics on {} done", date); } /** * 重新生成执行商户下某日消费者数据 + * * @param analysisDate * @param clientId */ - public void generateCustomersAndOrdersStatisticsByClientMoniker(Date analysisDate,String clientId){ + public void generateCustomersAndOrdersStatisticsByClientMoniker(Date analysisDate, String clientId) { DateFormat format = new SimpleDateFormat("yyyyMMdd"); String date = format.format(analysisDate); - List clients =clientMapper.listClients(); - for (JSONObject client:clients){ - if(client.getString("client_id").equals(clientId)){ + List clients = clientMapper.listClients(); + for (JSONObject client : clients) { + if (client.getString("client_id").equals(clientId)) { generateData(format, date, client); } } @@ -553,8 +559,8 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT private void generateData(DateFormat format, String date, JSONObject client) { JSONObject params = new JSONObject(); - String timezone =client.getString("timezone"); - if (timezone!=null){ + String timezone = client.getString("timezone"); + if (timezone != null) { format.setTimeZone(TimeZone.getTimeZone(timezone)); } try { @@ -563,17 +569,17 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT } catch (ParseException e) { throw new ParamInvalidException("date", "error.payment.valid.invalid_date_format"); } - if (client.getIntValue("client_id")!=0){ - params.put("client_id",client.getIntValue("client_id")); + if (client.getIntValue("client_id") != 0) { + params.put("client_id", client.getIntValue("client_id")); } List records = transactionAnalysisMapper.getCustomersAndOrdersInDaysUseInScheduled(params); - if (!records.isEmpty()){ + if (!records.isEmpty()) { JSONObject deleteParams = new JSONObject(); - deleteParams.put("begin",params.getDate("begin")); - deleteParams.put("end",params.getDate("end")); - deleteParams.put("client_id",params.getIntValue("client_id")); + deleteParams.put("begin", params.getDate("begin")); + deleteParams.put("end", params.getDate("end")); + deleteParams.put("client_id", params.getIntValue("client_id")); customerAndOrdersStatisticsMapper.delete(deleteParams); - for (JSONObject record:records){ + for (JSONObject record : records) { String sdate = format.format(record.getDate("date")); try { params.put("begin", format.parse(sdate)); @@ -581,17 +587,17 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT } catch (ParseException e) { throw new ParamInvalidException("date", "error.payment.valid.invalid_date_format"); } - params.put("channel",record.getString("channel")); + params.put("channel", record.getString("channel")); int newCustomers = 0; int oldCustomers = transactionAnalysisMapper.countOldCustomers(params); - if (client.getIntValue("client_id")==0){ - newCustomers = record.getIntValue("customers")-oldCustomers; - }else { + if (client.getIntValue("client_id") == 0) { + newCustomers = record.getIntValue("customers") - oldCustomers; + } else { newCustomers = transactionAnalysisMapper.countNewCustomers(params); } - record.put("new_customers",newCustomers); - record.put("old_customers",oldCustomers); - record.put("client_id",client.getIntValue("client_id")); + record.put("new_customers", newCustomers); + record.put("old_customers", oldCustomers); + record.put("client_id", client.getIntValue("client_id")); if (StringUtils.equalsIgnoreCase("rpaypmt_card", record.getString("channel")) || StringUtils.equalsIgnoreCase("rpaypmt_dd", record.getString("channel"))) { record.put("single_amount", record.getBigDecimal("total").divide(record.getBigDecimal("orders"), 2, RoundingMode.HALF_UP)); } @@ -599,37 +605,40 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT } } } + @Override public JSONObject getPlatformAmount(JSONObject params) { String jsonStr = stringRedisTemplate.boundValueOps("org_ChannelAnalysis" + params.getString("org_id") + params.getString("begin")).get(); JSONObject channelAnalysis = JSON.parseObject(jsonStr); - if(channelAnalysis != null){ + if (channelAnalysis != null) { return channelAnalysis; - }else { + } else { JSONObject resp; - if(params.getDate("end").compareTo(new Date()) > 0){ - if(params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){ + if (params.getDate("end").compareTo(new Date()) > 0) { + if (params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1)) == 0) { resp = getTodayChannelCount(params); - }else { + } else { resp = customerAndOrdersStatisticsMapper.getChannelCommonCount(params); } - }else { + } else { resp = customerAndOrdersStatisticsMapper.getChannelCommonCount(params); } - stringRedisTemplate.boundValueOps("org_ChannelAnalysis"+ params.getString("org_id")+params.getString("begin")).set(resp.toJSONString(), 5, TimeUnit.MINUTES); + stringRedisTemplate.boundValueOps("org_ChannelAnalysis" + params.getString("org_id") + params.getString("begin")).set(resp.toJSONString(), 5, TimeUnit.MINUTES); return resp; } } - private JSONObject getTodayChannelCount(JSONObject params){ - String[] channels = new String[]{"Wechat", "Alipay", "AlipayOnline", "Rpay", "rpaypmt_card", "rpaypmt_dd"}; + + private JSONObject getTodayChannelCount(JSONObject params) { + String[] channels = new String[]{"Wechat", "Alipay", "AlipayOnline", "Rpay", "rpaypmt_card", "rpaypmt_dd"}; JSONObject resp = new JSONObject(); - for(String channel:channels) { + for (String channel : channels) { params.put("channel", channel); - resp.put(channel.toLowerCase()+"amount", transactionAnalysisMapper.getPlatformAmount(params).getBigDecimal("amount")); - resp.put(channel.toLowerCase()+"_order_count", transactionAnalysisMapper.getPlatformAmount(params).getIntValue("order_count")); + resp.put(channel.toLowerCase() + "amount", transactionAnalysisMapper.getPlatformAmount(params).getBigDecimal("amount")); + resp.put(channel.toLowerCase() + "_order_count", transactionAnalysisMapper.getPlatformAmount(params).getIntValue("order_count")); } return resp; } + @Override public JSONObject getOrderAndCustomerPerDay(JSONObject partner, AnalysisBean partnerAnalysisBean) { String timezone = partner.getJSONObject("client").getString("timezone"); diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml index a01539533..87932a9c2 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml @@ -441,11 +441,9 @@