diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/DashboardService.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/DashboardService.java index 4ce8b420f..3b7510566 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/DashboardService.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/DashboardService.java @@ -50,4 +50,8 @@ public interface DashboardService { void generateCustomersAndOrdersStatistics(Date analysisDate); + JSONObject getOrderAndCustomerPerDay(JSONObject partner,AnalysisBean partnerAnalysisBean); + + List getStatisticsCustomersAndOrdersInDays(JSONObject partner, AnalysisBean partnerAnalysisBean); + } 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 248197b91..9b64ef9ec 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 @@ -7,6 +7,7 @@ import au.com.royalpay.payment.manage.analysis.core.DashboardService; import au.com.royalpay.payment.manage.analysis.mappers.ClientAnalysisMapper; import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; +import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.mappers.system.ExchangeRateMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; @@ -16,6 +17,7 @@ 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.lang3.time.DateUtils; import org.apache.commons.lang3.time.DurationFormatUtils; import org.slf4j.Logger; @@ -23,6 +25,7 @@ import org.slf4j.LoggerFactory; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -54,6 +57,11 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT @Resource private ExchangeRateMapper exchangeRateMapper; + @Resource + private TransactionMapper transactionMapper; + + + @Override public JSONObject getCommonAnalysis1(JSONObject params) { JSONObject res = transactionAnalysisMapper.getClientTransaction(params); @@ -231,22 +239,30 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT } JSONObject res = new JSONObject(); params.put("client_id", partner.getIntValue("client_id")); + JSONObject today = getTransJSONO(params); + 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("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, BigDecimal.ROUND_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, BigDecimal.ROUND_HALF_UP) : 0); + res.put("customers_rise", yes.getIntValue("customers") > 0 ? (today.getBigDecimal("customers").subtract(yes.getBigDecimal("customers"))).divide(yes.getBigDecimal("customers"), 4, BigDecimal.ROUND_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")); + return res; + } + private JSONObject getTransJSONO(JSONObject params){ + JSONObject res = new JSONObject(); JSONObject object = transactionAnalysisMapper.getClientTransaction(params); res.put("trade_amount", object.getBigDecimal("trade_amount")); res.put("trade_count", object.getIntValue("trade_count")); - res.put("refund_amount", object.getBigDecimal("refund_amount")); - res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params)); - res.put("pre_amount", transactionAnalysisMapper.analysisPreAmount(params)); - List topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc"))); - if (!topOrders.isEmpty()) { - res.put("top_amount_order", topOrders.get(0)); - } - res.put("total_customers", transactionAnalysisMapper.countCustomers(params)); - res.put("new_customers", transactionAnalysisMapper.countNewCustomers(params)); - res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params)); + res.put("customers", transactionAnalysisMapper.countCustomers(params)); return res; } - @Override public List getTradeAnalysisInHours(JSONObject partner, AnalysisBean partnerAnalysisBean) { String timezone = partner.getJSONObject("client").getString("timezone"); @@ -457,4 +473,32 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT resp.put("aliOnline_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"); + JSONObject params = partnerAnalysisBean.toParams(timezone); + try { + clientManager.validateClients(partner.getIntValue("client_id"), params); + } catch (Exception e) { + logger.error("Dashboard analysis request including not permission client_id"); + params.remove("client_ids"); + } + params.put("client_id", partner.getIntValue("client_id")); + return customerAndOrdersStatisticsMapper.getAvgOrderAndCustomerStatistics(params); + } + + @Override + public List getStatisticsCustomersAndOrdersInDays(JSONObject partner, AnalysisBean partnerAnalysisBean) { + String timezone = partner.getJSONObject("client").getString("timezone"); + JSONObject params = partnerAnalysisBean.toParams(timezone); + try { + clientManager.validateClients(partner.getIntValue("client_id"), params); + } catch (Exception e) { + logger.error("Dashboard analysis request including not permission client_id"); + params.remove("client_ids"); + } + params.put("client_id", partner.getIntValue("client_id")); + return customerAndOrdersStatisticsMapper.getPartnerCustomerAndOrderStatistics(params); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerDashboardController.java b/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerDashboardController.java index 7860afa83..75e8f2337 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerDashboardController.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerDashboardController.java @@ -2,13 +2,15 @@ package au.com.royalpay.payment.manage.analysis.web; import au.com.royalpay.payment.manage.analysis.beans.AnalysisBean; import au.com.royalpay.payment.manage.analysis.core.DashboardService; +import au.com.royalpay.payment.manage.analysis.core.PartnerCardDashboardService; +import au.com.royalpay.payment.manage.logview.beans.ClientLoginLogQueryBean; +import au.com.royalpay.payment.manage.management.clearing.core.CleanService; import au.com.royalpay.payment.manage.permission.manager.PartnerMapping; +import au.com.royalpay.payment.manage.signin.core.ClientLoginLogRepository; +import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.tools.CommonConsts; import com.alibaba.fastjson.JSONObject; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @@ -22,6 +24,12 @@ public class PartnerDashboardController { @Resource private DashboardService dashboardService; + @Resource + private PartnerCardDashboardService partnerCardDashboardService; + + @Resource + private CleanService cleanService; + @PartnerMapping("/common_analysis") public JSONObject commonAnalysis(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, AnalysisBean partnerAnalysisBean) { return dashboardService.getCommonAnalysis(partner,partnerAnalysisBean); @@ -34,11 +42,22 @@ public class PartnerDashboardController { @PartnerMapping("/fee_analysis") public List tradeInDays(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner,AnalysisBean partnerAnalysisBean) { - return dashboardService.getTradeAnalysisInDays(partner,partnerAnalysisBean); + return dashboardService.getStatisticsCustomersAndOrdersInDays(partner,partnerAnalysisBean); } @PartnerMapping("/customers") public List customersInDays(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner,AnalysisBean partnerAnalysisBean) { return dashboardService.getCustomersAndOrdersInDays(partner,partnerAnalysisBean); } + @PartnerMapping("/trans_type_analysis") + public List getTransTypesAnalysis(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner,AnalysisBean partnerAnalysisBean) { + JSONObject params = partnerAnalysisBean.toParams("timezone"); + params.put("client_id",partner.getString("client_id")); + return dashboardService.getTradeInTypes(params); + } + + @PartnerMapping("/avg_order_customer") + public JSONObject getAvgOrderAndCustomer(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner,AnalysisBean partnerAnalysisBean) { + return dashboardService.getOrderAndCustomerPerDay(partner,partnerAnalysisBean); + } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml index 451e81553..0193e2c0f 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml @@ -95,7 +95,7 @@ @@ -192,9 +192,21 @@ + + + AND s.client_id IN + + #{client_id} + + + + and s.client_id=#{client_id} + + and s.date >= #{begin} + and s.date < #{end} + 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 0cc9af372..013fb8311 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 @@ -202,7 +202,15 @@ INNER JOIN pmt_orders o ON o.order_id = l.order_id WHERE (l.transaction_type = 'Credit' or l.refund_id is not null) ]]> - AND l.client_id = #{client_id} + + AND l.client_id IN + + #{client_id} + + + + and l.client_id=#{client_id} + and o.create_time >= #{begin} and o.create_time <= #{end} and l.org_id=#{org_id} diff --git a/src/main/ui/index.html b/src/main/ui/index.html index 0c58df012..f0f665890 100644 --- a/src/main/ui/index.html +++ b/src/main/ui/index.html @@ -1,4 +1,4 @@ - + + <!– Tell the browser to be responsive to screen width –> - + + <!– Bootstrap 3.3.5 –> - - + <!– Font Awesome –> + <!––> - + <!– Ionicons –> - + <!– Theme style –> - + <!– AdminLTE Skins. Choose a skin from the css/skins + folder instead of downloading all of them to reduce the load. –> + ( 1300-10-77-50 | + support@royalpay.com.au | + WeChat ) + + + + +<!– ./wrapper –> + +--> + + + + + + RoyalPay + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ royalpay +

Easy Business,Easy Pay

+
+
+
+ +
+
+ + + + + +
+ + + + +
+ + + -
+
-