2四、生鮮電商平臺-系統報表設計與架構

說明:任何一個運行的平臺都須要一個很清楚的報表來顯示,那麼做爲Java開源生鮮電商平臺而言,咱們應該如何設計報表呢?或者說咱們但願報表來看到什麼數據呢?html

          經過報表咱們能夠分析出目前整個公司的運營狀況,以及下一步的調整方向,這樣更加有理有據的掌握整個市場與決策。數據庫

 

設計基礎維度:json

         1. 今日訂單,今日營業額,總訂單數,總營業額緩存

         2. 今日的註冊買家,總的註冊買家。app

         3. 實時的營收,實時的下單買家。echarts

         4. 今日下單買家,空降A(空降A指的是今天註冊同時下單的客戶)學習

 

數據的力量在於清楚的明白的告訴整個系統運營人員,昨天咱們的銷售團隊創造了多少的業績,以及整個趨勢是怎麼樣的,今天的努力方向是怎麼樣的,昨天的所獲是怎麼樣的spa

如何進行一塊兒努力與學習。設計

 

業務分析: 今日訂單,今日營業額,總訂單數,總營業額等來源於訂單表以及訂單彙總表。鑑於數據量並非很大,因此能夠實時的進行查詢。3d

                    若是存在數據量過大,好比訂單表咱們有100w的數量,那麼能夠採用定時器在規定的時間內進行執行,而後把統計結果放在統計表中

 

統計表的系統設計以下:

       

複製代碼
CREATE TABLE `report_days` (
  `id` bigint(20) DEFAULT NULL,
  `order_number_count` int(11) DEFAULT NULL COMMENT '今日訂單數',
  `order_rmb_count` decimal(12,2) DEFAULT NULL COMMENT '今日營業額',
  `order_number_amount` int(11) DEFAULT NULL COMMENT '總訂單數',
  `order_rmb_amount` decimal(12,2) DEFAULT NULL COMMENT '總營業額',
  `create_time` datetime DEFAULT NULL COMMENT '建立時間'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='每日報表';
複製代碼

說明:其實就是向這裏面進行數據的更新與增長操做便可,天天進行報表的讀取與顯示

           不過有些網友提出採用緩存來處理,我我的的意見是不須要。數據也沒那麼多,並且都是定時器來執行,緩存的價值與意義很小。

 

相關的執行代碼以下:

複製代碼
@Component
public class TaskReport {

    private static final Logger logger=LoggerFactory.getLogger(TaskReport.class);
    
    @Autowired
    private BuyerOrderReportService buyerOrderReportService;
    
    @Autowired
    private ReportDayService reportDayService;
    
    @Autowired
    private BillService billService;
    /**
     * 計算天天報表;
     *    每日上午6:00觸發
     */
    @Scheduled(cron="0 0 6 * * ?")
    protected void day(){
        try{
            logger.info("TaskReport.day.start");
            //統計天天訂單報表;
            Integer today = 0;//0表示今天    1表示昨天;
            reportDayService.insertBatch(today);
            //統計買家每日訂單金額;
            buyerOrderReportService.insertBatch(today);
        }catch(Exception e){
            logger.error("TaskReport.day.exception",e);
        }finally {
            logger.info("TaskReport.day.end");
        }
        
複製代碼

 

2. 相關的報表的形狀顯示,目前折線圖,柱狀圖是比較理想的一種方式,採用百度的echarts進行顯示

   

相關的運行實例以下:

 

 

 

 

 

 

 

 補充說明:相關的echarts的用法,這邊就不列舉了,的確蠻簡單的,返回json給echarts所須要的數據格式便可。

代碼這裏只貼出相對核心的代碼:

複製代碼
public class IndexController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(IndexController.class);
    
    @Autowired
    private OrderInfoService orderInfoService;

    @Autowired
    private OrderItemService orderItemService;

    @Autowired
    private SalesService salesService;

    @Autowired
    private BuyerService buyerService;

    @Autowired
    private SellerService sellerService;

    @Autowired
    private ReportedService reportedService;

    @RequestMapping(value = "/index", method = { RequestMethod.GET, RequestMethod.POST })
    public String index(HttpServletRequest request, HttpServletResponse response, Model model, Long areaId) {

        logger.info("[IndexController][index] :查詢訂單統計數據");
        try {

            // 查詢訂單總數量和金額
            Map<String, Object> totalMap = orderInfoService.getCountAndAmount();
            int totalCount = (int) totalMap.get("count");
            BigDecimal totalAmount = (BigDecimal) totalMap.get("amount");
            if (totalAmount == null) {
                totalAmount = BigDecimal.ZERO;
            }
            // 查詢今日的訂單總數量和金額
            Map<String, Object> todayMap = orderInfoService.getOrderCountAndAmountByToday();
            int todayOrderCount = (int) todayMap.get("count");
            BigDecimal todayOrderAmount = (BigDecimal) todayMap.get("amount");
            if (todayOrderAmount == null) {
                todayOrderAmount = BigDecimal.ZERO;
            }

            // 查詢實時的訂單總數量和金額
            Map<String, Object> realTimeRevenueMap = orderInfoService.getRealTimeRevenueCount();
            int realTimeOrderCount = (int) realTimeRevenueMap.get("count");
            BigDecimal realTimeOrderAmount = (BigDecimal) realTimeRevenueMap.get("amount");
            if (realTimeOrderAmount == null) {
                realTimeOrderAmount = BigDecimal.ZERO;
            }

            // 入駐買家數量
            int totalBuyerCount = buyerService.getBuyerCount(null);
            // 當日註冊買家數量
            int todayBuyercount = buyerService.getDailyBuyerCount();
            // 當日入駐賣家數量
            int todaySellerCount = sellerService.getDailySellerCount();

            model.addAttribute("totalCount", totalCount);
            model.addAttribute("totalAmount", totalAmount);
            model.addAttribute("todayOrderCount", todayOrderCount);
            model.addAttribute("todayOrderAmount", todayOrderAmount);
            model.addAttribute("totalBuyerCount", totalBuyerCount);
            model.addAttribute("todayBuyercount", todayBuyercount);
            model.addAttribute("todaySellerCount", todaySellerCount);
            model.addAttribute("realTimeOrderAmount", realTimeOrderAmount);
            model.addAttribute("realTimeOrderCount", realTimeOrderCount);

            // 查詢今兒下單買家數量和空降A;
            int order_buyerCount = orderInfoService.getBuyerCountByTodayOrder();
            int newBuyerNum = orderInfoService.getBuyerNumByThatDay();
            model.addAttribute("order_buyerCount", order_buyerCount);
            model.addAttribute("newBuyerNum", newBuyerNum);
            Reported reported = new Reported();
            reported.setrSolveStatus(1);
            int count = reportedService.getCount(reported);
            model.addAttribute("count", count);
        } catch (Exception ex) {
            logger.error("[IndexController][index] :exception", ex);
        }
        return "index";
    }
複製代碼

 

3.對於賣家而言,咱們的報表須要有如下幾個維度來統計(統計最新的TOP的賣家)

        3.1   買家消費。

        3. 2  賣家收入

        3.3   熱賣的菜品

        3.4   銷售業績

        3. 5  訂單項最多的買家。

 

   

 

 這裏面也是些統計的數據,相對而言跟上面的買家維度差很少,代碼方面也相似,無外乎須要的是多點數據庫的查詢與統計便可。

 

總結:其實整個報表的設計與實現過程並不難,難的是你爲何要這樣設計,你經過這個運營的後臺給整個項目的運營可以帶來怎麼樣的用戶體驗與指導,

            你須要經過數據來診斷這個銷售團隊過程當中是否存在什麼問題。有沒什麼刷單以及其餘的做弊嫌疑在裏面。

 

最後:不少人說系統功能很強大很好,可是個人一種思惟方式是不必定,強大當然好,可是你須要經過這麼多的系統數據中來分析出問題的關鍵,而不是所謂的代碼堆積。

           你所須要的是思考,再思考,最終思考。

 

 

轉載自-- https://www.cnblogs.com/jurendage/p/9108863.html

相關文章
相關標籤/搜索