package com.lightinit.hsdataplatform.controller.admin;

import com.lightinit.hsdataplatform.dictionary.DicAccountManageTransactionTransType;
import com.lightinit.hsdataplatform.entity.BaseExample;
import com.lightinit.hsdataplatform.model.admin.*;
import com.lightinit.hsdataplatform.service.admin.IAccountManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/admin/accountManage")
public class AccountManageController {


    @Autowired
    private IAccountManageService accountManageService ;

    @RequestMapping(value = "balance_index.htm")
    public ModelAndView balance_index(){
        ModelAndView modelAndView = new ModelAndView("admin/accountManage/balance_index");
        return modelAndView;
    }

    @RequestMapping(value = "balance_list.action")
    public ModelAndView balance_list(AccountManageBalanceDtoModel inputModel, @RequestParam(defaultValue = "1") int pageNo) {
        ModelAndView modelAndView = new ModelAndView("admin/accountManage/balance_list");
        BaseExample.Page pager = new BaseExample.Page(pageNo, 10);
        inputModel.setPage(pager);
        List<AccountManageBalanceVOModel> outputModel = accountManageService.queryBalanceList(inputModel);
        pager.setTotal(accountManageService.queryBalanceCount(inputModel));
        modelAndView.addObject("list", outputModel);
        modelAndView.addObject("pager", pager);
        return modelAndView;
    }

    @RequestMapping(value = "recharge_index.htm")
    public ModelAndView recharge_index(){
        ModelAndView modelAndView = new ModelAndView("admin/accountManage/recharge_index");
        return modelAndView;
    }

    @RequestMapping(value = "recharge_list.action")
    public ModelAndView recharge_list(AccountManageRechargeDtoModel inputModel, @RequestParam(defaultValue = "1") int pageNo) {
        ModelAndView modelAndView = new ModelAndView("admin/accountManage/recharge_list");
        BaseExample.Page pager = new BaseExample.Page(pageNo, 10);
        inputModel.setPage(pager);
        inputModel.setTransType(DicAccountManageTransactionTransType.RECHARGE);
        List<AccountManageRechargeVOModel> outputModel = accountManageService.queryRechargeList(inputModel);
        pager.setTotal(accountManageService.queryRechargeCount(inputModel));
        modelAndView.addObject("list", outputModel);
        modelAndView.addObject("pager", pager);
        modelAndView.addObject("sumTransAmount", accountManageService.querySumTransAmount(inputModel));
        return modelAndView;
    }



    @RequestMapping(value = "transaction_index.htm")
    public ModelAndView transaction_index(){
        ModelAndView modelAndView = new ModelAndView("admin/accountManage/transaction_index");
        return modelAndView;
    }

    @RequestMapping(value = "transaction_list.action")
    public ModelAndView transaction_list(AccountManageRechargeDtoModel inputModel, @RequestParam(defaultValue = "1") int pageNo) {
        ModelAndView modelAndView = new ModelAndView("admin/accountManage/transaction_list");
        BaseExample.Page pager = new BaseExample.Page(pageNo, 10);
        inputModel.setPage(pager);
        inputModel.setTransType(DicAccountManageTransactionTransType.TRANSACTION);
        List<AccountManageTransactionVOModel> outputModel = accountManageService.queryTransactionList(inputModel);
        pager.setTotal(accountManageService.queryTransactionCount(inputModel));
        modelAndView.addObject("list", outputModel);
        modelAndView.addObject("pager", pager);
        return modelAndView;
    }
}
