package com.matrix.system.hive.statistics; 
 | 
  
 | 
import com.matrix.core.constance.MatrixConstance; 
 | 
import com.matrix.core.pojo.AjaxResult; 
 | 
import com.matrix.core.pojo.PaginationVO; 
 | 
import com.matrix.core.tools.DateUtil; 
 | 
import com.matrix.core.tools.WebUtil; 
 | 
import com.matrix.core.tools.excl.ExcelSheetPO; 
 | 
import com.matrix.core.tools.excl.ExcelVersion; 
 | 
import com.matrix.system.common.bean.SysUsers; 
 | 
import com.matrix.system.common.constance.AppConstance; 
 | 
import com.matrix.system.common.tools.ResponseHeadUtil; 
 | 
import com.matrix.system.hive.action.util.QueryUtil; 
 | 
import com.matrix.system.hive.bean.AchieveNew; 
 | 
import com.matrix.system.hive.service.AchieveNewService; 
 | 
import org.springframework.stereotype.Controller; 
 | 
import org.springframework.ui.ModelMap; 
 | 
import org.springframework.web.bind.annotation.RequestMapping; 
 | 
import org.springframework.web.bind.annotation.ResponseBody; 
 | 
  
 | 
import javax.annotation.Resource; 
 | 
import javax.servlet.http.HttpServletRequest; 
 | 
import javax.servlet.http.HttpServletResponse; 
 | 
import java.io.IOException; 
 | 
import java.io.OutputStream; 
 | 
import java.util.ArrayList; 
 | 
import java.util.List; 
 | 
  
 | 
/** 
 | 
 * 业绩统计 
 | 
 */ 
 | 
@Controller 
 | 
@RequestMapping(value = "/admin/achieve") 
 | 
public class AchieveAction { 
 | 
  
 | 
  
 | 
    @Resource 
 | 
    private AchieveNewService achieveNewService; 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 门店每日单据明细表 
 | 
     */ 
 | 
    @RequestMapping(value = "/findSumDailyInfoNew") 
 | 
    public @ResponseBody 
 | 
    AjaxResult findSumDailyInfoNew(AchieveNew achieveNew, PaginationVO pageVo) { 
 | 
        SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); 
 | 
        if(!AppConstance.ZONGDIAN.equals(sysUsers.getShopName())){ 
 | 
            achieveNew.setShopId(sysUsers.getShopId()); 
 | 
        } 
 | 
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, achieveNewService.findSumDailyInfoNew(achieveNew, null), 
 | 
                0); 
 | 
        return result; 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 每日单据明细表 
 | 
     */ 
 | 
    @RequestMapping(value = "/findDailyInfoNew") 
 | 
    public @ResponseBody 
 | 
    AjaxResult findDailyInfoNew(AchieveNew achieveNew, PaginationVO pageVo) { 
 | 
        SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); 
 | 
        if(!AppConstance.ZONGDIAN.equals(sysUsers.getShopName())){ 
 | 
            achieveNew.setShopId(sysUsers.getShopId()); 
 | 
        } 
 | 
        pageVo.setSort("datatime"); 
 | 
        pageVo.setOrder("desc"); 
 | 
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, achieveNewService.findDayFlow(achieveNew, pageVo), 
 | 
                achieveNewService.findDayFlowTotal(achieveNew, pageVo)); 
 | 
        return result; 
 | 
    } 
 | 
  
 | 
    @RequestMapping(value = "/exportDailyInfoNew") 
 | 
    public void exportDailyInfoNew(ModelMap model, HttpServletRequest request, HttpServletResponse response, AchieveNew achieveNew) throws IOException { 
 | 
        //这里是从数据库里查数据并组装成我们想要的数据结构的过程 
 | 
        List<ExcelSheetPO> res = new ArrayList<>(); 
 | 
        ExcelSheetPO orderSheet = new ExcelSheetPO(); 
 | 
        String title = "每日单据明细"; 
 | 
        orderSheet.setSheetName(title); 
 | 
        orderSheet.setTitle(title); 
 | 
        String[] header = {"年", "月", "日",   "订单类型", "订单编号", "会员级别", "姓名", "项目名称", "总金额", "卡项", "现金单次", "现金产品", "划扣", "本金消耗", "赠消", "提成", "顾问", "美疗师", "人头", "项目个数", "项目时间", "门店"}; 
 | 
        orderSheet.setHeaders(header); 
 | 
        SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); 
 | 
        if(!AppConstance.ZONGDIAN.equals(sysUsers.getShopName())){ 
 | 
            achieveNew.setShopId(sysUsers.getShopId()); 
 | 
        } 
 | 
  
 | 
        QueryUtil.setQueryLimitCom(achieveNew); 
 | 
        List<AchieveNew> dataList = achieveNewService.findDayFlow(achieveNew, null); 
 | 
        List<List<Object>> list = new ArrayList<>(); 
 | 
        if (dataList.size() > 0) { 
 | 
            for (AchieveNew item : dataList) { 
 | 
                List<Object> temp = new ArrayList<>(); 
 | 
                temp.add(item.getYear()); 
 | 
                temp.add(item.getMonth()); 
 | 
                temp.add(item.getDay()); 
 | 
                temp.add(item.getOrderType()); 
 | 
                temp.add(item.getOrderNo()); 
 | 
                temp.add(item.getLevelName()); 
 | 
                temp.add(item.getVipName()); 
 | 
                temp.add(item.getProName()); 
 | 
                temp.add(item.getZkTotal()); 
 | 
                temp.add(item.getCardCash()); 
 | 
                temp.add(item.getProjCash()); 
 | 
                temp.add(item.getGoodsCash()); 
 | 
                temp.add(item.getConsume()); 
 | 
                temp.add(item.getHisConsume()); 
 | 
                temp.add(item.getFreeConsume()); 
 | 
                temp.add(item.getProjPercentage()); 
 | 
                temp.add(item.getGuwen()); 
 | 
                temp.add(item.getMeiliao()); 
 | 
                temp.add(item.getNumberOfPeople()); 
 | 
                temp.add(item.getProjNum()); 
 | 
                temp.add(item.getProjTime()); 
 | 
                temp.add(item.getShopName()); 
 | 
                list.add(temp); 
 | 
            } 
 | 
        } 
 | 
        orderSheet.setDataList(list); 
 | 
        res.add(orderSheet); 
 | 
        response = ResponseHeadUtil.setExcelHead(response); 
 | 
        response.setHeader("Content-Disposition", 
 | 
                "attachment;filename=" + java.net.URLEncoder.encode(title + DateUtil.getTimeMark() + ".xlsx".trim(), "UTF-8")); 
 | 
        OutputStream os = response.getOutputStream(); 
 | 
        com.matrix.core.tools.excl.ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true); 
 | 
    } 
 | 
  
 | 
  
 | 
} 
 |