Browse Source

Merge branch 'master' of http://47.112.200.206:3000/shenhao/sys

wuwen 4 years ago
parent
commit
b8a0a74b3a
24 changed files with 1638 additions and 74 deletions
  1. 237 0
      src/main/java/com/ssj/agent/controller/AgentController.java
  2. 34 0
      src/main/java/com/ssj/agent/dao/AgentDao.java
  3. 169 0
      src/main/java/com/ssj/agent/dao/AgentEntity.java
  4. 20 0
      src/main/java/com/ssj/agent/dao/AgentQueryDao.java
  5. 70 0
      src/main/java/com/ssj/agent/dao/Rebate.java
  6. 69 0
      src/main/java/com/ssj/agent/dao/impl/AgentQueryDaoImpl.java
  7. 33 0
      src/main/java/com/ssj/agent/service/IAgentService.java
  8. 104 0
      src/main/java/com/ssj/agent/service/impl/AgentServiceImpl.java
  9. 13 1
      src/main/java/com/ssj/bean/sys/fx/domain/MerchantMealOrder.java
  10. 35 26
      src/main/java/com/ssj/dao/weixin/library/dao/impl/LibUserHistoryQueryDaoImpl.java
  11. 1 1
      src/main/java/com/ssj/dao/weixin/sales/dao/impl/LibStaffingQueryDaoImpl.java
  12. 1 1
      src/main/java/com/ssj/service/sys/fx/service/MerchantMealService.java
  13. 2 1
      src/main/java/com/ssj/service/sys/fx/service/impl/MerchantMealServiceImpl.java
  14. 2 2
      src/main/java/com/ssj/sys/controller/FxController.java
  15. 71 0
      src/main/java/com/ssj/sys/controller/SysLibController.java
  16. 78 4
      src/main/java/com/ssj/sys/controller/SysSalesController.java
  17. 132 0
      src/main/resources/templates/sys/agent/edit.html
  18. 106 0
      src/main/resources/templates/sys/agent/list.html
  19. 202 0
      src/main/resources/templates/sys/agent/main.html
  20. 99 0
      src/main/resources/templates/sys/agent/monthList.html
  21. 116 4
      src/main/resources/templates/sys/fx/merchantMealScAdd.html
  22. 26 15
      src/main/resources/templates/sys/lib/libUserHistorylist.html
  23. 1 1
      src/main/resources/templates/sys/login/index.html
  24. 17 18
      src/main/resources/templates/sys/sales/libVipServiceList.html

+ 237 - 0
src/main/java/com/ssj/agent/controller/AgentController.java

@@ -0,0 +1,237 @@
+package com.ssj.agent.controller;
+
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
+import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
+import com.ssj.agent.dao.AgentEntity;
+import com.ssj.agent.service.IAgentService;
+import com.ssj.bean.common.framework.core.domain.Response;
+import com.ssj.bean.sys.organization.domain.Organization;
+import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
+import com.ssj.framework.basic.common.bean.SplitPage;
+import com.ssj.framework.core.common.controller.BaseController;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Sort;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * @author sh
+ * @className AgentController
+ * @description 代理
+ * @date 2021/1/15
+ */
+@Controller
+@RequestMapping("sys/agent")
+public class AgentController extends BaseController {
+
+    @Autowired
+    private IAgentService agentService;
+
+    /**
+     * 栏目主页面
+     * @return
+     */
+    @RequestMapping("/main")
+    public String main() {
+        return "sys/agent/main";
+    }
+
+
+    @RequestMapping("/mainTree")
+    @ResponseBody
+    public List<AgentEntity> mainTree(@RequestParam(required = false, value = "id") String pId) throws Exception {
+        if(pId ==null) {
+            pId="-1";
+        }
+        return agentService.findByPid(pId);
+    }
+
+    /**
+     * 查询列表
+     * @param
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping("/list")
+    public String list(Model model, @RequestParam(required = false, defaultValue = "-1") String EQ_pId,
+                       @RequestParam(required = false, defaultValue = "10") int pageSize,
+                       @RequestParam(required = false, defaultValue = "1") int pageNo) {
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put("EQ_upId", EQ_pId);
+        params.put("LIKE_agentName",request.getParameter("LIKE_agentName")==null?"":request.getParameter("LIKE_agentName"));
+        Page<AgentEntity> page= agentService.findByPage(params, initPage(pageNo,pageSize, Sort.Direction.DESC, new String[] { "createTime" }));
+        SplitPage sp = initPage(pageNo,pageSize,params,(int) page.getTotalElements());
+        model.addAttribute("list", page.getContent());
+        model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
+        model.addAttribute("page", sp);
+        model.addAttribute("search", params);
+        return "sys/agent/list";
+    }
+
+    @RequestMapping(value = "/edit")
+    public String edit(Model model, String id, String pId) throws Exception {
+        AgentEntity agent = agentService.getById(id);
+        if(agent ==null){
+            agent = new AgentEntity();
+            agent.setUpId(pId);
+        }
+        model.addAttribute("org", agent);
+        return "sys/agent/edit";
+    }
+
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ResponseBody
+    public Response save(AgentEntity org){
+        Response response = new  Response();
+        Boolean isAdd = org.getId()==null?true:false;
+        if(isAdd){
+            //检查code是否重复 设置唯一索引
+            int count = agentService.findByCode(org.getCode());
+            if(count>0){
+                return response.failure(org.getCode()+"此编码已经存在,请更换重新添加!");
+            }
+            org.setCreateTime(new Date());
+            org.setSubCount(0);
+        }
+        org.setUpdateTime(new Date());
+        org.setLever(agentService.getById(org.getUpId()).getLever()+1);
+        org.setStatus(1);
+        org=agentService.save(org);
+        agentService.changeSubCount(org.getUpId(), true);
+
+        response.success(org);
+        return response;
+    }
+
+    @RequestMapping(value = "/delete", method = RequestMethod.POST)
+    @ResponseBody
+    public Response  delete(String id,String pId){
+        Response response = new  Response();
+        AgentEntity agent = agentService.getById(id);
+        agent.setStatus(2);
+        agent.setUpdateTime(new Date());
+        agentService.save(agent);
+        agentService.changeSubCount(pId, false);
+        response.success();
+        return response;
+    }
+
+
+    @RequestMapping("/agentList")
+    @ResponseBody
+    public Response agentList(Model model,String name,Integer pageNo,Integer pageSize) {
+        Response response = new  Response();
+        Map<String,Object> data=new HashMap<>();
+        if(pageNo==null) {
+            pageNo=1;
+        }
+        Long countNum=agentService.countByLikeName(name);
+        List<AgentEntity> jsonList =agentService.findByLikeName(name,pageNo,pageSize);
+        data.put("jsonList", jsonList);
+        data.put("pageNo", pageNo);
+        data.put("countNum", countNum);
+        data.put("countPage", Math.ceil((double)countNum/(double)pageSize));
+        response.success(data, "成功");
+        return response;
+    }
+
+    @RequestMapping("/agentMonthList")
+    public String agentMonthList(Model model,@RequestParam(required = false, defaultValue = "10") int pageSize,
+                                 @RequestParam(required = false, defaultValue = "1") int pageNo){
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put("beginDate",request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
+        params.put("endDate",request.getParameter("endDate")==null?"":request.getParameter("endDate"));
+
+        Page<Map<String,Object>> page= agentService.agentMonthList(params, initPage(pageNo,pageSize));
+        SplitPage sp = initPage(pageNo,pageSize,params,(int) page.getTotalElements());
+        model.addAttribute("list", page.getContent());
+        model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
+        model.addAttribute("page", sp);
+        model.addAttribute("search", params);
+        return "sys/agent/monthList";
+    }
+
+    @RequestMapping(value = "/exportExcel", method = RequestMethod.POST)
+    @ResponseBody
+    public  void exportExcel(){
+        ServletOutputStream os = null;
+        try {
+            String libName="销售订单数据";
+            //获得输出流
+            os = response.getOutputStream();
+            //清空输出流
+            response.reset();
+            exportExcelHead(response,libName);
+            Map<String, Object> params = new HashMap<String, Object>();
+            params.put("beginDate",request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
+            params.put("endDate",request.getParameter("endDate")==null?"":request.getParameter("endDate"));
+            Page<Map<String,Object>> page= agentService.agentMonthList(params, initPage(1,10000));
+            List<Map<String,Object>> list = page.getContent();
+            List<Map<String, Object>> dataList = new ArrayList<>();
+            dataList.addAll(list);
+            String exportHead = "学校|league_name;人数|lib_service;年份|year;个人|agentMoney;管理|managerMoney;培训|trainMoney";
+            List<ExcelExportEntity> entity = addEntity(exportHead);
+            //把我们构造好的bean对象放到params就可以了
+            Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(libName, libName, ExcelType.XSSF), entity,
+                    dataList);
+            workbook.write(os);
+        }catch (IOException e) {
+            logger.error("异常", e);
+        }catch (Exception e1){
+            logger.error("异常", e1);
+        }finally{
+            if(os != null){
+                try {
+                    os.flush();
+                    os.close();
+                } catch (IOException e) {
+                    logger.error("异常", e);
+                }
+            }
+
+        }
+    }
+
+    private List<ExcelExportEntity> addEntity(String exportHead){
+        List<ExcelExportEntity> entity = new ArrayList<>();
+        String[] headArr = exportHead.split(";");
+        for (String str:headArr){
+            int index = str.indexOf("|");
+            entity.add(new ExcelExportEntity(str.substring(0,index), str.substring(index+1)));
+        }
+        return  entity;
+    }
+
+    private void exportExcelHead(HttpServletResponse response,String fileName) throws Exception{
+        String lastFileName = new String(fileName.getBytes("gb2312"), "ISO8859-1") +".xlsx";
+        //设定输出文件头
+        response.setHeader("Content-disposition", "attachment; filename="+ lastFileName);
+        response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+        response.setCharacterEncoding("utf-8");
+    }
+
+    private  SplitPage initPage(int pageNo,int pageSize,Map<String, Object> params,int rowCnt){
+        SplitPage sp = new SplitPage();
+        sp.setAction(request.getRequestURI());
+        sp.setPageNo(pageNo);
+        sp.setPageSize(pageSize);
+        sp.setParams(params);
+        sp.setRowCnt(rowCnt);
+        return  sp;
+    }
+}

+ 34 - 0
src/main/java/com/ssj/agent/dao/AgentDao.java

@@ -0,0 +1,34 @@
+package com.ssj.agent.dao;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * @author sh
+ * @className AgentDao
+ * @description 数据交互
+ * @date 2021/1/15
+ */
+@Repository
+public interface AgentDao extends JpaRepository<AgentEntity, String> {
+
+    @Query(nativeQuery = true,value = "select * from tb_agent where up_id=?1")
+    List<AgentEntity> findByPid(String pId);
+
+    Page<AgentEntity> findAll(Specification<AgentEntity> specification,Pageable initPage);
+
+    @Query(nativeQuery = true,value ="select count(1) from tb_agent where code=?1" )
+    int findByCode(String code);
+
+    @Query(nativeQuery = true,value ="select count(1) from tb_agent where status=1 " )
+    Long countByStatus();
+
+    @Query(nativeQuery = true,value ="select count(1) from tb_agent where status=1 and agent_name REGEXP ?1 " )
+    Long countByLikeName(String name);
+}

+ 169 - 0
src/main/java/com/ssj/agent/dao/AgentEntity.java

@@ -0,0 +1,169 @@
+package com.ssj.agent.dao;
+
+
+import com.ssj.bean.common.framework.core.domain.BaseEntity;
+import org.apache.ibatis.annotations.Update;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.util.Date;
+
+/**
+ * @author sh
+ * @className AgentEntity
+ * @description 商户代理类
+ * @date 2021/1/15
+ */
+@Entity
+@Table(name="tb_agent")
+public class AgentEntity extends BaseEntity {
+
+    /**
+     * 代理姓名
+     */
+    private String agentName;
+
+    /**
+     * 编码 唯一
+     */
+    private String code;
+
+    /**
+     * 创建的登录账号
+     */
+    private String adminName;
+
+    /**
+     * 上级id
+     */
+    private String upId;
+
+    /**
+     * 级别
+     */
+    private Integer lever;
+
+    /**
+     * 状态(在职/离职)
+     */
+    private Integer status;
+
+    /**
+     * 销售类型
+     * 1、销售
+     * 2、管理人员
+     */
+    private Integer type;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    /**
+     * 是否存在父节点,不持久化
+     */
+    private boolean isParent;
+
+    /**
+     * 子节点数量
+     */
+    private int subCount;
+
+    public String getAgentName() {
+        return agentName;
+    }
+
+    public void setAgentName(String agentName) {
+        this.agentName = agentName;
+    }
+
+
+    public String getAdminName() {
+        return adminName;
+    }
+
+    public void setAdminName(String adminName) {
+        this.adminName = adminName;
+    }
+
+    public String getUpId() {
+        return upId;
+    }
+
+    public void setUpId(String upId) {
+        this.upId = upId;
+    }
+
+    public Integer getLever() {
+        return lever;
+    }
+
+    public void setLever(Integer lever) {
+        this.lever = lever;
+    }
+
+    @Column(updatable = false)
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Transient
+    public boolean getIsParent() {
+        if (isParent == true) {
+            return true;
+        } else {
+            return subCount > 0;
+        }
+    }
+
+    public void setIsParent(boolean parent) {
+        isParent = parent;
+    }
+
+    public int getSubCount() {
+        return subCount;
+    }
+
+    public void setSubCount(int subCount) {
+        this.subCount = subCount;
+    }
+}

+ 20 - 0
src/main/java/com/ssj/agent/dao/AgentQueryDao.java

@@ -0,0 +1,20 @@
+package com.ssj.agent.dao;
+
+import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author sh
+ * @className AgentQueryDao
+ * @description TODO
+ * @date 2021/1/22
+ */
+public interface AgentQueryDao {
+    List<AgentEntity> findByLikeName(String name, Integer pageNo, Integer pageSize);
+
+    Page<Map<String, Object>> agentMonthList(Map<String, Object> params, Pageable initPage);
+}

+ 70 - 0
src/main/java/com/ssj/agent/dao/Rebate.java

@@ -0,0 +1,70 @@
+package com.ssj.agent.dao;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author sh
+ * @className Rebate
+ * @description 返利模型
+ * @date 2021/1/21
+ */
+public class Rebate implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Boolean passable;
+    private BigDecimal agentMoney = BigDecimal.ZERO;
+    private BigDecimal managerMoney = BigDecimal.ZERO;
+    private BigDecimal trainMoney = BigDecimal.ZERO;
+    private Integer yearIndex;
+    private Integer vips = 300;
+    private BigDecimal countMonth = BigDecimal.TEN;
+
+    public BigDecimal getAgentMoney() {
+        return agentMoney;
+    }
+
+    public void setAgentMoney(BigDecimal agentMoney) {
+        this.agentMoney = agentMoney;
+    }
+
+    public BigDecimal getManagerMoney() {
+        return managerMoney;
+    }
+
+    public void setManagerMoney(BigDecimal managerMoney) {
+        this.managerMoney = managerMoney;
+    }
+
+    public BigDecimal getTrainMoney() {
+        return trainMoney;
+    }
+
+    public void setTrainMoney(BigDecimal trainMoney) {
+        this.trainMoney = trainMoney;
+    }
+
+    public  void getRebate(int yearIndex, int totals){
+        this.yearIndex = yearIndex;
+        passable = totals>=vips?true:false;
+        switch (yearIndex){
+            case 1:
+                agentMoney = (passable==true?BigDecimal.valueOf(50):BigDecimal.valueOf(40)).divide(countMonth).multiply(BigDecimal.valueOf(totals));
+                managerMoney = (passable==true?BigDecimal.valueOf(10):BigDecimal.valueOf(8)).divide(countMonth).multiply(BigDecimal.valueOf(totals));
+                trainMoney = BigDecimal.valueOf(5).divide(countMonth).multiply(BigDecimal.valueOf(totals));
+                break;
+            case 2:
+                agentMoney = (passable==true?BigDecimal.valueOf(35):BigDecimal.valueOf(30)).divide(countMonth).multiply(BigDecimal.valueOf(totals));
+                managerMoney = (passable==true?BigDecimal.valueOf(7):BigDecimal.valueOf(6)).divide(countMonth).multiply(BigDecimal.valueOf(totals));
+                trainMoney = BigDecimal.valueOf(15).divide(countMonth).multiply(BigDecimal.valueOf(totals));
+                break;
+            case 3:
+                agentMoney = (passable==true?BigDecimal.valueOf(20):BigDecimal.valueOf(15)).divide(countMonth).multiply(BigDecimal.valueOf(totals));
+                managerMoney = (passable==true?BigDecimal.valueOf(3):BigDecimal.valueOf(2)).divide(countMonth).multiply(BigDecimal.valueOf(totals));
+                trainMoney = BigDecimal.valueOf(15).divide(countMonth).multiply(BigDecimal.valueOf(totals));
+                break;
+            default:
+                break;
+        }
+    }
+}

+ 69 - 0
src/main/java/com/ssj/agent/dao/impl/AgentQueryDaoImpl.java

@@ -0,0 +1,69 @@
+package com.ssj.agent.dao.impl;
+
+import com.ssj.agent.dao.AgentEntity;
+import com.ssj.agent.dao.AgentQueryDao;
+import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
+import com.ssj.framework.core.persistence.PagingHibernateJdbcDao;
+import com.ssj.framework.core.util.StringUtil;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Repository;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author sh
+ * @className AgentQueryDaoImpl
+ * @description TODO
+ * @date 2021/1/22
+ */
+@Repository
+public class AgentQueryDaoImpl implements AgentQueryDao {
+
+    @Autowired
+    private PagingHibernateJdbcDao dao;
+
+    @Override
+    public List<AgentEntity> findByLikeName(String name, Integer pageNo, Integer pageSize) {
+
+        StringBuilder selSQL = new StringBuilder();
+        List<Object> queryParams = new ArrayList<Object>();
+        selSQL.append(" SELECT * FROM `tb_agent` t where status = 1 and t.type between 1 and 2 ");
+        if(StringUtils.isNotEmpty(name)) {
+            selSQL.append("  AND t.agent_name like  CONCAT('%',?,'%') ");
+            queryParams.add(name);
+        }
+        selSQL.append(" ORDER BY t.create_time asc limit ?,?");
+        queryParams.add((pageNo-1)*pageSize);
+        queryParams.add(pageSize);
+        return dao.findList(selSQL.toString(), queryParams.toArray(),AgentEntity.class);
+    }
+
+    @Override
+    public Page<Map<String, Object>> agentMonthList(Map<String, Object> params, Pageable initPage) {
+        StringBuilder selSql = new StringBuilder();
+        List<Object> queryParams = new ArrayList<>();
+        selSql.append("SELECT t.sign_type,m.sign_time,m.end_sign_time,t.price,t12.league_name,t.lib_service, \n");
+        selSql.append("(select count(1) from tb_lib_vip a where a.lib_id = t11.lib_id) as stu_count,DATE_FORMAT(m.sign_time,'%Y') as year  \n");
+        selSql.append("from fx_merchant_meal_order t \n");
+        selSql.append("left join fx_merchant_meal m on t.id = m.order_id \n");
+        selSql.append("left join fx_merchant t11 on t.merchant_id = t11.id \n");
+        selSql.append("join tb_lib_join t12 on t11.lib_id = t12.id \n");
+        selSql.append("where t11.pos_type = 3  \n");
+        if(StringUtil.isNotEmpty(MapUtils.getString(params,"beginDate"))){
+            selSql.append(" and m.sign_time >= ? ");
+            queryParams.add(params.get("beginDate"));
+        }
+        if(StringUtil.isNotEmpty(MapUtils.getString(params,"endDate"))){
+            selSql.append(" and m.end_sign_time <= ? ");
+            queryParams.add(params.get("endDate"));
+        }
+        selSql.append(" order by t.create_time asc");
+        return dao.findPage(selSql.toString(),queryParams.toArray(),initPage);
+    }
+}

+ 33 - 0
src/main/java/com/ssj/agent/service/IAgentService.java

@@ -0,0 +1,33 @@
+package com.ssj.agent.service;
+
+import com.ssj.agent.dao.AgentEntity;
+import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
+import com.ssj.framework.core.common.service.BaseService;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author sh
+ * @className IAgentService
+ * @description TODO
+ * @date 2021/1/15
+ */
+public interface IAgentService extends BaseService<AgentEntity,String> {
+
+    List<AgentEntity> findByPid(String pId);
+
+    Page<AgentEntity> findByPage(Map<String, Object> params, Pageable initPage);
+
+    int findByCode(String code);
+
+    void changeSubCount(String upId, boolean b);
+
+    Long countByLikeName(String name);
+
+    List<AgentEntity> findByLikeName(String name, Integer pageNo, Integer pageSize);
+
+    Page<Map<String, Object>> agentMonthList(Map<String, Object> params, Pageable initPage);
+}

+ 104 - 0
src/main/java/com/ssj/agent/service/impl/AgentServiceImpl.java

@@ -0,0 +1,104 @@
+package com.ssj.agent.service.impl;
+
+import com.ssj.agent.dao.AgentDao;
+import com.ssj.agent.dao.AgentEntity;
+import com.ssj.agent.dao.AgentQueryDao;
+import com.ssj.agent.dao.Rebate;
+import com.ssj.agent.service.IAgentService;
+import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
+import com.ssj.framework.core.common.service.BaseServiceImpl;
+import com.ssj.framework.core.persistence.DynamicSpecifications;
+import com.ssj.framework.core.persistence.SearchFilter;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.data.repository.PagingAndSortingRepository;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @author sh
+ * @className AgentServiceImpl
+ * @description 代理实现类
+ * @date 2021/1/15
+ */
+@Service
+public class AgentServiceImpl extends BaseServiceImpl<AgentEntity,String> implements IAgentService  {
+
+    @Autowired
+    private AgentDao dao;
+
+    @Autowired
+    private AgentQueryDao queryDao;
+
+    @Override
+    public PagingAndSortingRepository<AgentEntity, String> getDao() {
+        return dao;
+    }
+
+    @Override
+    public List<AgentEntity> findByPid(String pId) {
+        return dao.findByPid(pId);
+    }
+
+    @Override
+    public Page<AgentEntity> findByPage(Map<String, Object> params, Pageable initPage) {
+        Map<String, SearchFilter> filters = SearchFilter.parse(params);
+        Specification<AgentEntity> specification = DynamicSpecifications.bySearchFilter(filters.values(), AgentEntity.class);
+        return  dao.findAll(specification,initPage);
+    }
+
+    @Override
+    public int findByCode(String code) {
+        return dao.findByCode(code);
+    }
+
+    @Override
+    public void changeSubCount(String upId, boolean increase) {
+        AgentEntity agent = this.getById(upId);
+        if(agent == null){return;}
+        int subCount = agent.getSubCount();
+        if(increase){
+            subCount ++;
+        }else{
+            subCount --;
+        }
+        agent.setSubCount(subCount);
+        this.save(agent);
+    }
+
+    @Override
+    public Long countByLikeName(String name) {
+        if(StringUtils.isEmpty(name)){
+            return dao.countByStatus();
+        }
+        return  dao.countByLikeName(name);
+    }
+
+    @Override
+    public List<AgentEntity> findByLikeName(String name, Integer pageNo, Integer pageSize) {
+        return queryDao.findByLikeName(name,pageNo,pageSize);
+    }
+
+    @Override
+    public Page<Map<String, Object>> agentMonthList(Map<String, Object> params, Pageable initPage) {
+        Page<Map<String, Object>>  page = queryDao.agentMonthList(params,initPage);
+        List<Map<String, Object>> list = page.getContent();
+        if(!Objects.isNull(list) && !list.isEmpty()){
+            for (Map<String, Object> map :list){
+                Rebate rebate = new Rebate();
+                rebate.getRebate(1, MapUtils.getInteger(map,"lib_service"));
+                map.put("agentMoney",rebate.getAgentMoney());
+                map.put("managerMoney",rebate.getManagerMoney());
+                map.put("trainMoney",rebate.getTrainMoney());
+            }
+        }
+        return page;
+    }
+}

+ 13 - 1
src/main/java/com/ssj/bean/sys/fx/domain/MerchantMealOrder.java

@@ -43,6 +43,11 @@ public class MerchantMealOrder extends BaseEntity {
     
     private String remarks;
 
+	/**
+	 * 销售id
+	 */
+	private String agentId;
+
 	public String getMerchantId() {
 		return merchantId;
 	}
@@ -162,5 +167,12 @@ public class MerchantMealOrder extends BaseEntity {
 	public void setActiveTime(Date activeTime) {
 		this.activeTime = activeTime;
 	}
-  
+
+	public String getAgentId() {
+		return agentId;
+	}
+
+	public void setAgentId(String agentId) {
+		this.agentId = agentId;
+	}
 }

+ 35 - 26
src/main/java/com/ssj/dao/weixin/library/dao/impl/LibUserHistoryQueryDaoImpl.java

@@ -4,6 +4,7 @@ import com.ssj.dao.weixin.library.dao.LibUserHistoryQueryDao;
 import com.ssj.framework.core.persistence.PagingHibernateJdbcDao;
 import com.ssj.framework.weixin.util.Collections3;
 import com.ssj.service.reading.out.*;
+import org.apache.commons.collections4.MapUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -23,50 +24,58 @@ public class LibUserHistoryQueryDaoImpl implements LibUserHistoryQueryDao{
 			Map<String, Object> searchParams, Pageable pageable) {
 		 StringBuilder selSQL = new StringBuilder();
 	        List<Object> queryParams = new ArrayList<Object>();
-	        selSQL.append(" SELECT a.child_name,a.title,a.user_id,a.update_time,a.create_time,a.state,a.local_image,a.qr_url,a.flow_id FROM(\n ");
-	        selSQL.append(" SELECT t11.child_name,t.end_time,t13.user_id,t15.update_time,t15.create_time,t14.local_image,t.id,t.title,t14.lib_id,t13.qr_url,t11.flow_id, ");
-	        selSQL.append(" case when t15.update_time is null and t.end_time>=SYSDATE() then 1 ");
-	        selSQL.append(" when t15.update_time is  null and t.end_time<SYSDATE() then 2 ");
-	        selSQL.append(" when t15.update_time is not null then 3 end as state");
-	        selSQL.append(" from (select t.end_time,t.id,t.title,t.detail_id,t.book_detail_id,t.vip_id from tb_lib_user_history t WHERE t.order_type='1' ) t");
-	        selSQL.append(" left join (select t15.update_time,t15.create_time,t15.id from  tb_order_details t15) t15 on t.detail_id = t15.id");
-	        selSQL.append(" INNER JOIN (select t11.id,t11.child_name,t11.flow_id from tb_lib_read_vip t11) t11 on  t.vip_id = t11.id ");
-	        selSQL.append(" left join (select t13.user_id,t13.qr_url,t13.id,t13.info_id from tb_lib_book_detail t13) t13 on t.book_detail_id = t13.id");
-	        selSQL.append(" left join (select t14.local_image,t14.lib_id,t14.id,t14.org_code from tb_lib_book_info t14) t14 on t13.info_id = t14.id");
-	        selSQL.append(" WHERE 1=1 ");
-	        
-	        if (searchParams.get("orgCode") != null && !searchParams.get("orgCode").equals("")) {
-	        	selSQL.append(" and  t14.org_code in ( ");
-	        	selSQL.append(searchParams.get("orgCode"));
-	        	selSQL.append(" ) ");
-	        }
+			selSQL.append("SELECT t15.league_name,t14.child_name,t.title,t.book_img,t11.qr_url,t14.flow_id,t.create_time,t.update_time,case when t.update_time is null then t11.back_book_time else null end as back_book_time,\n");
+			selSQL.append("case when t.update_time is  null and t11.back_book_time<SYSDATE() then '逾期'  \n");
+			selSQL.append("when  t.update_time is null then '在借' \n");
+			selSQL.append("when t.update_time is not null then '已还' end as state \n");
+			selSQL.append("from tb_order_details t \n");
+			selSQL.append("left join tb_lib_read_vip t14 on t.vip_id = t14.id\n");
+			selSQL.append("left join tb_lib_book_detail t11 on t.book_detail_id = t11.id  \n");
+			selSQL.append("left join tb_lib_join t15 on t.lib_id = t15.id\n");
 	        
+//	        if (searchParams.get("orgCode") != null && !searchParams.get("orgCode").equals("")) {
+//	        	selSQL.append(" and  t14.org_code in ( ");
+//	        	selSQL.append(searchParams.get("orgCode"));
+//	        	selSQL.append(" ) ");
+//	        }
+			selSQL.append( " where 1=1 \n");
 	        if (searchParams.get("title") != null && !searchParams.get("title").equals("")) {
-	            selSQL.append(" and  t.title LIKE  CONCAT(CONCAT('%',?,'%')) ");
+	            selSQL.append(" and  t.title LIKE  CONCAT('%',?,'%') ");
 	            queryParams.add(searchParams.get("title"));
 	        }
 	        if (searchParams.get("libId") != null && !searchParams.get("libId").equals("")) {
-	        	selSQL.append(" and  t14.lib_id = ?  ");
+	        	selSQL.append(" and  t.lib_id = ?  ");
 	        	queryParams.add(searchParams.get("libId"));
 	        }
 	        if (searchParams.get("child_name") != null && !searchParams.get("child_name").equals("")) {
-	        	selSQL.append(" and  t11.child_name LIKE  CONCAT(CONCAT('%',?,'%')) ");
+	        	selSQL.append(" and  t14.child_name LIKE  CONCAT('%',?,'%') ");
 	        	queryParams.add(searchParams.get("child_name"));
 	        }
 	        if (searchParams.get("beginDate") != null && !searchParams.get("beginDate").equals("")) {
-	        	selSQL.append(" and TO_DAYS(t15.create_time) >=TO_DAYS(?) ");
+	        	selSQL.append(" and TO_DAYS(t.create_time) >=TO_DAYS(?) ");
 	        	queryParams.add(searchParams.get("beginDate"));
 	        }
 	        if (searchParams.get("endDate") != null && !searchParams.get("endDate").equals("")) {
-	        	selSQL.append(" and TO_DAYS(t15.create_time) <=TO_DAYS(?) ");
+	        	selSQL.append(" and TO_DAYS(t.create_time) <=TO_DAYS(?) ");
 	        	queryParams.add(searchParams.get("endDate"));
 	        }
-	        selSQL.append(") a ");
 	        if (searchParams.get("state") != null && !searchParams.get("state").equals("")) {
-	            selSQL.append(" where  a.state =? ");
-	            queryParams.add(searchParams.get("state"));
+	        	int state = MapUtils.getInteger(searchParams,"state");
+	        	switch (state){
+					case 1:
+						selSQL.append(" and t.update_time is null  ");
+						break;
+					case 2:
+						selSQL.append(" and  t.update_time is null and t11.back_book_time<SYSDATE()");
+						break;
+					case 3:
+						selSQL.append(" and  t.update_time is not  null ");
+						break;
+					default:
+						break;
+				}
 	        }
-	        selSQL.append("  ORDER BY a.create_time DESC");
+	        selSQL.append("  ORDER BY t.create_time DESC");
 	        return dao.findPage(selSQL.toString(), queryParams.toArray(), pageable);
 	}
 

+ 1 - 1
src/main/java/com/ssj/dao/weixin/sales/dao/impl/LibStaffingQueryDaoImpl.java

@@ -79,7 +79,7 @@ public class LibStaffingQueryDaoImpl  implements  LibStaffingQueryDao {
         selSQL.append(" ,v.vipno,v.flow_id ,j.league_name,s.start_time,s.end_time,s.order_details_id  ");
         selSQL.append(" from  tb_lib_vip_service s  JOIN  tb_lib_join  j ");
         selSQL.append(" on s.lib_id =j.id  ");
-        selSQL.append("  JOIN  tb_lib_vip  v  on  s.vip_id  = v.id  ");
+        selSQL.append("  JOIN  tb_lib_read_vip  v  on  s.vip_id  = v.id  ");
         selSQL.append(" where   1=1  ");
         
         if (searchParams.get("child_name") != null && !searchParams.get("child_name").equals("")) {

+ 1 - 1
src/main/java/com/ssj/service/sys/fx/service/MerchantMealService.java

@@ -29,7 +29,7 @@ public interface MerchantMealService extends BaseService<MerchantMeal, String> {
 	
 	void saveMerchantMeal(String merchantId,Integer signType,Integer libService,Integer buyMonth,Integer giveMonth,Double unitPrice,Double price,String startActiveTime,String activeTime);
 	
-	void saveMerchantMealSC(String merchantId,Integer signType,Integer libService,String startActiveTime,String endActiveTime,Double unitPrice,Double price);
+	void saveMerchantMealSC(String merchantId,Integer signType,Integer libService,String startActiveTime,String endActiveTime,Double unitPrice,Double price,String agentId);
 	
 	void updateMerchantByMeal(String merchantId);
 	

+ 2 - 1
src/main/java/com/ssj/service/sys/fx/service/impl/MerchantMealServiceImpl.java

@@ -247,7 +247,7 @@ public class MerchantMealServiceImpl extends BaseServiceImpl<MerchantMeal, Strin
 
 	@Override
 	@Transactional
-	public void saveMerchantMealSC(String merchantId, Integer signType, Integer libService, String startActiveTime,String endActiveTime,Double unitPrice, Double price) {
+	public void saveMerchantMealSC(String merchantId, Integer signType, Integer libService, String startActiveTime,String endActiveTime,Double unitPrice, Double price,String agentId) {
 		List<MerchantMeal> merchantMeals=new ArrayList<MerchantMeal>();
 		Merchant merchant=merchantService.getById(merchantId);
 		switch (merchant.getPosType()) {
@@ -266,6 +266,7 @@ public class MerchantMealServiceImpl extends BaseServiceImpl<MerchantMeal, Strin
 			mealOrder.setCreateTime(new Date());
 			mealOrder.setType(2);
 			mealOrder.setSignType(signType);
+			mealOrder.setAgentId(agentId);
 			switch (mealOrder.getSignType()) {
 			case 1:
 				mealOrder.setPortNum(200);

+ 2 - 2
src/main/java/com/ssj/sys/controller/FxController.java

@@ -5161,7 +5161,7 @@ public class FxController  extends BaseController {
 	////学校服务包开通
 	@RequestMapping("/saveMerchantMealSc")
 	@ResponseBody
-    public Response saveMerchantMealSc(Model model,String id,Integer signType,Integer libService,String startActiveTime,String endActiveTime,Double unitPrice,Double price)throws Exception {
+    public Response saveMerchantMealSc(Model model,String id,Integer signType,Integer libService,String startActiveTime,String endActiveTime,Double unitPrice,Double price,String agentId)throws Exception {
 		Response response = new  Response();
 		if(signType==null) {
 			response.failure("请选择购买的服务包");
@@ -5186,7 +5186,7 @@ public class FxController  extends BaseController {
 		}
 		Merchant merchant=merchantService.getById(id);
 		if(merchant.getPosType()==3) {
-			merchantMealService.saveMerchantMealSC(id, signType, libService, startActiveTime, endActiveTime, unitPrice, price);
+			merchantMealService.saveMerchantMealSC(id, signType, libService, startActiveTime, endActiveTime, unitPrice, price,agentId);
 			response.success("成功");
 		}else {
 			response.failure("商户类型不可购买此服务包");

+ 71 - 0
src/main/java/com/ssj/sys/controller/SysLibController.java

@@ -1,5 +1,9 @@
 package com.ssj.sys.controller;
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
+import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
 import com.alibaba.fastjson.JSONObject;
 import com.ssj.bean.common.framework.core.domain.Response;
 import com.ssj.bean.sys.role.domain.Admin;
@@ -29,6 +33,7 @@ import com.ssj.sys.util.thirdparty.excel.CustomizeToExcel;
 import com.ssj.sys.util.thirdparty.excel.ExcelColumn;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Sort.Direction;
@@ -1292,4 +1297,70 @@ public class SysLibController extends BaseController {
 		}
 	}
 
+	@RequestMapping(value = "/exportExcel", method = RequestMethod.POST)
+	@ResponseBody
+	public  void exportExcel(){
+		ServletOutputStream os = null;
+		try {
+			String libName="借阅记录";
+			//获得输出流
+			os = response.getOutputStream();
+			//清空输出流
+			response.reset();
+			exportExcelHead(response,libName);
+			Map<String, Object> params = new HashMap<String, Object>();
+			params.put("state", request.getParameter("state")== null ? "":request.getParameter("state"));
+			params.put("title", request.getParameter("title")== null ? "":request.getParameter("title"));
+			params.put("child_name", request.getParameter("child_name")== null ? "":request.getParameter("child_name"));
+			params.put("beginDate", request.getParameter("beginDate")==null?"":request.getParameter("beginDate"));
+			params.put("endDate", request.getParameter("endDate")==null?"":request.getParameter("endDate"));
+			params.put("libId", request.getParameter("libId")==null?"-1":request.getParameter("libId"));
+			if(!"admin".equals(loginName())){
+				params.put("orgCode", orgCodeStr());
+			}
+			Page<Map<String,Object>> page= libUserHistoryService.findForPage(params, initPage(1,10000));
+			List<Map<String,Object>> list = page.getContent();
+			List<Map<String, Object>> dataList = new ArrayList<>();
+			dataList.addAll(list);
+			String exportHead = "馆|league_name;书名|title;借书人|child_name;卡号|flow_id;状态|state;借书时间|create_time;还书时间|update_time;理应还书时间|back_book_time";
+			List<ExcelExportEntity> entity = addEntity(exportHead);
+			//把我们构造好的bean对象放到params就可以了
+			Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(libName, libName, ExcelType.XSSF), entity,
+					dataList);
+			workbook.write(os);
+		}catch (IOException e) {
+			logger.error("异常", e);
+		}catch (Exception e1){
+			logger.error("异常", e1);
+		}finally{
+			if(os != null){
+				try {
+					os.flush();
+					os.close();
+				} catch (IOException e) {
+					logger.error("异常", e);
+				}
+			}
+
+		}
+	}
+
+	private List<ExcelExportEntity> addEntity(String exportHead){
+		List<ExcelExportEntity> entity = new ArrayList<>();
+		String[] headArr = exportHead.split(";");
+		for (String str:headArr){
+			int index = str.indexOf("|");
+			entity.add(new ExcelExportEntity(str.substring(0,index), str.substring(index+1)));
+		}
+		return  entity;
+	}
+
+	private void exportExcelHead(HttpServletResponse response,String fileName) throws Exception{
+		String lastFileName = new String(fileName.getBytes("gb2312"), "ISO8859-1") +".xlsx";
+		//设定输出文件头
+		response.setHeader("Content-disposition", "attachment; filename="+ lastFileName);
+		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+		response.setCharacterEncoding("utf-8");
+	}
+
 }

+ 78 - 4
src/main/java/com/ssj/sys/controller/SysSalesController.java

@@ -1,5 +1,9 @@
 package com.ssj.sys.controller;
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
+import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
 import com.ssj.bean.common.framework.core.domain.Response;
 import com.ssj.bean.weixin.libmy.domain.TbLibJoin;
 import com.ssj.bean.weixin.sales.domain.*;
@@ -9,6 +13,7 @@ import com.ssj.service.sys.sort.service.SortService;
 import com.ssj.service.weixin.library.service.ILibJoinService;
 import com.ssj.service.weixin.sales.service.*;
 import com.ssj.service.weixin.zuoyb.service.ZuoybStudentPushSerivce;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Sort.Direction;
@@ -19,11 +24,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.math.BigDecimal;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /** 
  * @author  ZhangCaibao 
@@ -815,6 +820,75 @@ public class SysSalesController extends BaseController {
 				return "sys/sales/libVipServiceList";
 			}
 
+	@RequestMapping(value = "/exportExcel", method = RequestMethod.POST)
+	@ResponseBody
+	public  void exportExcel(){
+		ServletOutputStream os = null;
+		try {
+			String libName="图书馆会员服务";
+			//获得输出流
+			os = response.getOutputStream();
+			//清空输出流
+			response.reset();
+			exportExcelHead(response,libName);
+			Map<String, Object> params = new HashMap<String, Object>();
+			params.put("child_name",request.getParameter("child_name") == null ? "" : request.getParameter("child_name"));
+			params.put("level",request.getParameter("level") == null ? "" : request.getParameter("level"));
+			params.put("flow_id",request.getParameter("flow_id") == null ? "" : request.getParameter("flow_id"));
+			params.put("type",request.getParameter("type") == null ? "" : request.getParameter("type"));
+			params.put("libId", request.getParameter("libId")==null?"":request.getParameter("libId"));
+			if(!"admin".equals(loginName())){
+				params.put("orgCode",orgCodeStr());
+			}else{
+				if(params.get("libId").toString().equals("")){
+					params.put("orgCode","1");
+				}
+			}
+			Page<Map<String,Object>> page= libVipServiceService.findForPage(params, initPage(1,10000));
+			List<Map<String,Object>> list = page.getContent();
+			List<Map<String, Object>> dataList = new ArrayList<>();
+			dataList.addAll(list);
+			String exportHead = "图书馆|league_name;学生姓名|child_name;家长姓名|parent_name;联系方式|phone;卡号|flow_id;会员卡状态|stat;服务开始时间|start_time;服务结束时间|end_time";
+			List<ExcelExportEntity> entity = addEntity(exportHead);
+			//把我们构造好的bean对象放到params就可以了
+			Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(libName, libName, ExcelType.XSSF), entity,
+					dataList);
+			workbook.write(os);
+		}catch (IOException e) {
+			logger.error("异常", e);
+		}catch (Exception e1){
+			logger.error("异常", e1);
+		}finally{
+			if(os != null){
+				try {
+					os.flush();
+					os.close();
+				} catch (IOException e) {
+					logger.error("异常", e);
+				}
+			}
+
+		}
+	}
+
+	private List<ExcelExportEntity> addEntity(String exportHead){
+		List<ExcelExportEntity> entity = new ArrayList<>();
+		String[] headArr = exportHead.split(";");
+		for (String str:headArr){
+			int index = str.indexOf("|");
+			entity.add(new ExcelExportEntity(str.substring(0,index), str.substring(index+1)));
+		}
+		return  entity;
+	}
+
+	private void exportExcelHead(HttpServletResponse response, String fileName) throws Exception{
+		String lastFileName = new String(fileName.getBytes("gb2312"), "ISO8859-1") +".xlsx";
+		//设定输出文件头
+		response.setHeader("Content-disposition", "attachment; filename="+ lastFileName);
+		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+		response.setCharacterEncoding("utf-8");
+	}
+
 	/**
 	 *  馆长查询有哪些会员购买该馆的服务
 	 * @param model

+ 132 - 0
src/main/resources/templates/sys/agent/edit.html

@@ -0,0 +1,132 @@
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+<title>私塾家</title>
+<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
+<script th:include="sys/common/metaJS" th:remove="tag"></script> 
+<script src="sys/js/jquery.validate.min.js" th:src="@{/static/sys/js/jquery.validate.min.js}"></script>
+<script src="sys/js/jquery-validation/messages_zh.js" th:src="@{/static/sys/js/jquery-validation/messages_zh.js}"></script>
+<style type="text/css">
+    body{min-width:280px;}
+	.select1{
+		width:100%;
+		height: 32px;
+		line-height: 32px;
+		border-top: solid 1px #a7b5bc;
+		border-left: solid 1px #a7b5bc;
+		border-right: solid 1px #ced9df;
+		border-bottom: solid 1px #ced9df;
+		opacity:1;
+		margin-bottom: 10px;
+	}
+    </style>
+</head>
+
+
+<body>
+<div class="formbody">
+	<div class="formtitle"><span>基本信息</span></div>
+	<form id="submitFrom" method="post" class="form-horizontal form-validate">
+		<input type="hidden" name="id" th:if="${org.id}" th:value="${org.id}" />
+		<input type="hidden" name="upId" th:value="${org.upId}" />
+		<input type="hidden" name="subCount" th:if="${org.id}" th:value="${org.subCount}" />
+		<ul class="forminfo">
+			<li>
+				<label>名称<b>*</b></label>
+				<input type="text" name="agentName" th:value="${org.agentName}" class="dfinput" />
+			</li>
+			<li>
+				<label>编码<b>*</b></label>
+				<input type="text" name="code" th:value="${org.code}" class="dfinput" th:readonly="${org.id}" />
+			</li>
+			<li class="clearfix">
+				<label>类型</label>
+				<div class="vocation" style="margin-right: 5px; width: 346px">
+					<select name="type" id="type" class="select1">
+						<option th:selected="${ org.type eq 1 }" value="1" >销售</option>
+						<option th:selected="${ org.type eq 2 }" value="2" >管理</option>
+						<option th:selected="${ org.type eq 3 }" value="3" >机构</option>
+					</select>
+				</div>
+			</li>
+			<li>
+				<label>&nbsp;</label>
+				<button type="submit" class="btn">保存</button>
+				<button type="button" class="btn" onclick="closeWin();">取消</button>
+			</li>
+		</ul>
+	</form>
+</div>
+<script type="text/javascript">
+
+$(function(){
+	
+	
+	$(function(){
+		$("#submitFrom").validate({
+			rules : {
+
+				agentName : {
+					required : true,
+					maxlength: 300
+				},
+				code : {
+					required : true,
+					maxlength: 300
+				}
+			},
+			messages: {
+				agentName : {
+					required : "名称不能为空",
+					maxlength : "最多300个字符"
+				},
+				code : {
+					required : "CODE不能为空",
+					maxlength : "最多300个字符"
+				}
+			},
+			errorPlacement : function(error, element) {
+					error.appendTo(element.parent()); 
+			},
+			submitHandler : function(form) {
+				roleFrom();
+			}
+		});
+		
+	});
+	function roleFrom(){
+		var url="[[${sysUrl}]]/sys/agent/save";
+		var params = $("#submitFrom").serialize();
+		var id="";
+		if($("#submitFrom").find("input[name='id']").val() != undefined){
+			id = $("#submitFrom").find("input[name='id']").val();
+		}
+		var pid = $("#submitFrom").find("input[name='upId']").val();
+		var name =$("#submitFrom").find("input[name='agentName']").val();
+		$.post(url,params,function(data){
+			if(data != null){
+					if(data.meta.success){
+						parent.layer.msg('操作成功',{icon:1});
+						refreshTree(id, pid, name);
+				    	setTimeout(function(){
+				    		parent.refreshList();
+							closeWin();
+						},1000);
+					}else{
+						layer.msg(data.meta.message,{icon:11});
+					}
+			}
+			
+		});
+	}
+});
+
+function refreshTree(id, pid, name){
+	parent.refreshNode(id, pid, name);
+}
+
+function closeWin(){
+	parent.layer.close(parent.layer.getFrameIndex(window.name));
+}
+</script>
+</body>
+</html>

+ 106 - 0
src/main/resources/templates/sys/agent/list.html

@@ -0,0 +1,106 @@
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+<title>私塾家</title>
+<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
+<script th:include="sys/common/metaJS" th:remove="tag"></script> 
+</head>
+<body>
+	<div class="rightinfo">
+		<form id="seachform" th:action="@{/sys/agent/list.html}" method="post">
+		       <input type="hidden" name="EQ_upId" th:value="${search.get('EQ_upId')}" />
+				<ul class="seachform">
+					<li>
+						<label>名称</label>
+						<input name="LIKE_agentName" type="text" class="scinput" th:value="${search.get('LIKE_agentName')}"/>
+					</li>
+					<li>
+						<label>&nbsp;</label>
+						<input type="button" class="scbtn" value="查询" />
+					</li>
+					<li th:if="${ #httpSession.getAttribute('admin') !=null  && #httpSession.getAttribute('admin').loginName eq 'admin'  } " >
+							<ul class="toolbar">
+							<a href="javascript:void(0);"  th:onclick="'openEdit(-2,\''+${search.get('EQ_upId')}+'\',1)'"  ><li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>添加</li></a>
+							</ul>
+					</li>
+
+				</ul>
+		</form>
+	
+		
+		<table class="imgtable">
+	        <thead>
+	            <tr>
+	                <th style="width: 50px;">序号</th>
+	                <th>名称</th>
+	                <th>编码</th>
+	                <th>创建时间</th>
+	                <th>操作</th>
+	            </tr>
+	        </thead>
+            <tbody>
+				
+				<tr th:each="item:${list}" >
+					<td th:text="${itemStat.count}" ></td>
+					<td th:text="${item.agentName}" ></td>
+					<td th:text="${item.code}" ></td>
+					<td><p th:text="''+${#calendars.format(item.createTime,'yyyy-MM-dd HH:mm:ss')}"></p></td>
+					<td>
+						<a th:if="${ #httpSession.getAttribute('admin') !=null  && #httpSession.getAttribute('admin').loginName eq 'admin'  } "  href="javascript:;" th:onclick="'deleteById(\''+${item.id}+'\' ,\''+${item.upId}+'\',\''+${item.agentName}+'\')'"  class="tablelink" >删除</a>
+						<a href="javascript:void(0);"  th:onclick="'openEdit(\''+${item.id}+'\',\''+${search.get('EQ_upId')}+'\',2)'" class="tablelink" >修改</a>
+					</td>
+			   </tr>
+			
+             </tbody>
+        </table>
+          <!-- 分页 -->
+		<div class="pagin">
+	    	<div class="message">共<i class="blue">[[${page.rowCnt}]]</i>条记录,当前显示第&nbsp;<i class="blue">[[${page.pageNo }]]&nbsp;</i>页</div>
+	    	<div th:utext='${listNavigatHtml}' th:remove="tag" ></div>
+	   	</div>
+	</div>
+	
+<script type="text/javascript">
+
+function openEdit(id,pId,title){
+	parent.layer.open({
+		type: 2,
+		title: title ==1 ? '新增' :'修改',
+		shadeClose: false,
+		shade: 0.8,
+		offset: '60px',
+		area: ['670px', '520px'],
+		content: '[[${sysUrl}]]/sys/agent/edit.html?id='+id+'&pId='+pId
+	});
+}
+
+//删除
+function deleteById(id, pid, name){
+	parent.layer.confirm("您确定要删除"+name+"吗?", {
+		icon: 4, btn: ['确定','取消'] //按钮
+	}, function(){
+		$.ajax({
+			url: '[[${sysUrl}]]/sys/agent/delete',
+			type : "post",
+			data:{
+				'id': id,
+				'pId':pid
+			},
+			dataType : "json",
+			success : function(data) {
+				if(data.meta.success){
+					parent.layer.msg("删除成功",{icon:1});
+					parent.refreshNode(id, pid , name, "delete");
+					setTimeout(function() {
+						location.reload()
+					}, 1000);
+				}else{
+					parent.layer.msg(data.meta.message,{icon:11});
+				}
+			}
+		});
+	});
+}
+
+</script>
+</body>
+</html>

+ 202 - 0
src/main/resources/templates/sys/agent/main.html

@@ -0,0 +1,202 @@
+<html xmlns:th="http://www.thymeleaf.org">
+  <head>
+<title>私塾家</title>
+<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
+<script th:include="sys/common/metaJS" th:remove="tag"></script> 
+<link href="sys/css/bootstrap.css" th:href="@{/static/sys/css/bootstrap.css}" rel="stylesheet"/>
+<link href="sys/css/zTree/zTreeStyle.css" th:href="@{/static/sys/css/zTree/zTreeStyle.css}" rel="stylesheet"/>
+<script src="js/jquery-2.2.4.min.js" th:src="@{/static/js/jquery-2.2.4.min.js}"></script>
+<script src="sys/js/zTree/jquery.ztree.all-3.5.min.js" th:src="@{/static/sys/js/zTree/jquery.ztree.all-3.5.min.js}"></script>
+<style type="text/css">
+    	span{margin:0;padding:0;display: inline-block;}
+    	@media (min-width: 1200px){
+			.row-fluid [class*="span"] {
+			    margin-left: 0px;
+			}
+		}
+    </style>
+</head>
+<body>
+<div class="place">
+	<span>位置:</span>
+	<ul class="placeul">
+		<li><a href="#">代理</a></li>
+	</ul>
+</div>
+<div class="rightinfo container-fluid">
+	<div class="row-fluid">
+		<div class="span2" style="border-right: #999999 1px dashed;">
+			<ul id="columnsTree" class="ztree" style="min-height:560px; overflow: auto;"></ul>
+		</div>
+		<div class="span10">
+			<iframe id="listIframe" scrolling="auto" frameborder="0" style="width:100%;height:100%;"></iframe>
+		</div>
+	</div>
+</div>
+<script type="text/javascript">
+function addTab(url) {
+	$("#listIframe").attr("src",url);
+	startInit("listIframe", 560);
+}
+
+function refreshList(){
+	$("#listIframe").attr("src", $("#listIframe").attr("src"));
+}
+
+var setting = {
+	async : {
+		enable : true,
+		autoParam : [ "id" ],
+		url : "[[${sysUrl}]]/sys/agent/mainTree",
+		dataFilter : filter
+	},
+	data : {
+		key : {
+			name : "agentName"
+		},
+		simpleData : {
+			enable : true,
+			pIdKey : "upId"
+		}
+	},
+	callback : {
+		onClick : clickNode,
+		onAsyncSuccess : renderIcon
+	}
+};
+
+function filter(treeId, parentNode, childNodes) {
+	if (!childNodes)
+		return null;
+	for (var i = 0, l = childNodes.length; i < l; i++) {
+		childNodes[i].agentName = childNodes[i].agentName.replace(/\.n/g, '.');
+	}
+	return childNodes;
+}
+
+function clickNode(event, treeId, treeNode, clickFlag) {
+	var url = "[[${sysUrl}]]/sys/agent/list.html?EQ_pId=" + treeNode.id;
+	addTab(url);
+	event.preventDefault();
+}
+
+function renderIcon(event, treeId, treeNode, msg){
+	var ztree = $.fn.zTree.getZTreeObj(treeId);
+	var nodes = null;
+	if(treeNode){
+		nodes = treeNode.children;
+	}
+	if(nodes){
+		for(var i = 0; i < nodes.length; i++){
+			nodes[i].icon="[[${imgUrl}]]/resources/images/menu_1.png";
+			ztree.updateNode(nodes[i]);
+		}
+	}
+	zTreeOnAsyncSuccess(event, treeId, treeNode, msg, ztree);
+}
+
+var firstAsyncSuccessFlag = 0;
+function zTreeOnAsyncSuccess(event, treeId, treeNode, msg, zTree) {
+	if (firstAsyncSuccessFlag == 0) {  
+	      try {  
+	             //调用默认展开第一个结点  
+	             var selectedNode = zTree.getSelectedNodes();  
+	             var nodes = zTree.getNodes();  
+	             zTree.expandNode(nodes[0], true);
+	             
+	             var childNodes = zTree.transformToArray(nodes[0]);  
+                 zTree.selectNode(childNodes[0]);  
+	          	 
+	             clickNode(event, treeId, treeNode, true);
+	             firstAsyncSuccessFlag = 1;
+	       } catch (err) {  
+	          
+	       }  
+	   }  
+}
+
+// 增删改节点之后,刷新局部
+function refreshNode(id, pid, name, op) {
+	var ztree = $.fn.zTree.getZTreeObj("columnsTree");
+	var pNode = ztree.getNodeByParam("id", pid, null);
+	console.log(pNode);
+	// 添加一级节点
+	if (pNode == null) {
+		ztree.refresh();
+	}
+	// 父节点是叶子节点,只能是新增
+	if (!pNode.isParent) {
+		pNode.isParent = true;
+		ztree.reAsyncChildNodes(pNode, "refresh");
+	}
+	// 父节点未展开,直接返回
+	if (!pNode.open)
+		return;
+	// 新增节点,重新展开父节点
+	if (id == "") {
+		pNode.open = false;
+		ztree.reAsyncChildNodes(pNode, "refresh");
+		return;
+	}
+	// 删除
+	var treeNode = ztree.getNodeByParam("id", id, null);
+	if (op == "delete") {
+		ztree.removeNode(treeNode);
+	} else {
+		// 修改
+		treeNode.name = name;
+		ztree.updateNode(treeNode);
+	}
+}
+
+$(document).ready(function() {
+	$.fn.zTree.init($("#columnsTree"), setting);
+});
+
+var browserVersion = window.navigator.userAgent.toUpperCase();
+var isOpera = false;
+var isFireFox = false;
+var isChrome = false;
+var isSafari = false;
+var isIE = false;
+var iframeTime;
+function reinitIframe(iframeId, minHeight) {
+    try {
+    	if (typeof(reValue) == "undefined") {
+    		browserVersion = window.navigator.userAgent.toUpperCase();
+    	}
+        var iframe = document.getElementById(iframeId);
+        var bHeight = 0;
+        if (isChrome == false && isSafari == false)
+            bHeight = iframe.contentWindow.document.body.scrollHeight;
+
+        var dHeight = 0;
+        if (isFireFox == true)
+            dHeight = iframe.contentWindow.document.documentElement.offsetHeight + 2;
+        else if (isIE == false && isOpera == false)
+            dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
+        else
+            bHeight += 3;
+        var height = Math.max(bHeight, dHeight);
+        if (height < minHeight) height = minHeight;
+        iframe.style.height = height + "px";
+    } catch (ex) { }
+}
+function startInit(iframeId, minHeight) {
+	if (typeof(reValue) == "undefined") {
+		browserVersion = window.navigator.userAgent.toUpperCase();
+	}
+    isOpera = browserVersion.indexOf("OPERA") > -1 ? true : false;
+    isFireFox = browserVersion.indexOf("FIREFOX") > -1 ? true : false;
+    isChrome = browserVersion.indexOf("CHROME") > -1 ? true : false;
+    isSafari = browserVersion.indexOf("SAFARI") > -1 ? true : false;
+    if (!!window.ActiveXObject || "ActiveXObject" in window)
+        isIE = true;
+    reinitIframe(iframeId, minHeight);
+    if (iframeTime != null)
+        clearInterval(iframeTime)
+    iframeTime = window.setInterval("reinitIframe('" + iframeId + "'," + minHeight + ")", 100);
+}
+</script>
+</body>
+</html>

+ 99 - 0
src/main/resources/templates/sys/agent/monthList.html

@@ -0,0 +1,99 @@
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+<title>私塾家</title>
+<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
+<script th:include="sys/common/metaJS" th:remove="tag"></script> 
+</head>
+<style>
+	.tablelink{margin-right:10px;}
+	.stylecss{
+	      color: red;
+	}
+	.select_width{
+	     width: 70px;
+	}
+	.date_width{
+	     width: 100px;
+	}
+	td div{
+     word-break:break-all;
+	}
+</style>
+<body>
+<div class="place">
+	<span>位置:</span>
+	<ul class="placeul">
+		<li><a href="#">销售管理</a></li>
+		<li><a th:href="@{/sys/agent/agentMonthList.html}">明细</a></li>
+	</ul>
+</div>
+<div class="rightinfo">
+	<form id="seachform" th:action="@{/sys/agent/agentMonthList.html}" method="post">
+	 <input id="url" name="url" type="hidden">
+	 <input id="leagueName" name="leagueName" type="hidden">
+	<ul class="seachform">
+		<li>
+			<label>开始时间</label>
+			<input type="text" id="beginDate" name="beginDate"  onclick="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')}'})" th:value="${search.beginDate }" class="scinput date_width " placeholder="开始时间">
+		</li>
+
+
+		<li>
+			<label>结束时间</label>
+			<input type="text" id="endDate" name="endDate"  onclick="WdatePicker({minDate:'#F{$dp.$D(\'beginDate\')}'})" th:value="${search.endDate }" class="scinput date_width" placeholder="结束时间">
+		</li>
+		<li>
+			<label>&nbsp;</label>
+			<input type="button" class="scbtn" value="查询" />
+		</li>
+		<li th:if="${ #httpSession.getAttribute('admin') !=null   } " >
+				<ul class="toolbar">
+					<a href="javascript:;" onclick="qrCodeDown();"><li class="click"><span><img th:src="@{/static/sys/images/generate.png}" /></span>导出</li></a>
+					
+				</ul>
+		</li>
+	</ul>
+	</form>
+	<table class="tablelist">
+		<thead>
+		    <tr>
+		        <th style="width: 40px;">序号</th>
+		        <th>学校</th>
+		        <th>人数</th>
+		        <th>年份</th>
+		        <th>个人</th>
+		        <th>管理</th>
+		        <th>培训</th>
+		    </tr>
+		</thead>
+		<tbody>
+			<tr th:each="item:${list}" >
+				<td th:text="${itemStat.count}" ></td>
+					<td th:title="${item.league_name}" th:text="${item.league_name} ">
+					</td>
+					<td th:text="${item.lib_service}" ></td>
+					<td th:text="${item.year}" ></td>
+					<td th:text="${item.agentMoney}"></td>
+					<td th:text="${item.managerMoney}"></td>
+					<td th:text="${item.trainMoney}"></td>
+
+			</tr>
+		</tbody>
+	</table>
+	<!-- 分页 -->
+	<div class="pagin">
+    	<div class="message">共<i class="blue">[[${page.rowCnt}]]</i>条记录,当前显示第&nbsp;<i class="blue">[[${page.pageNo }]]&nbsp;</i>页</div>
+    	<div th:utext='${listNavigatHtml}' th:remove="tag" ></div>
+   	</div>
+</div>
+</body>
+<script type="text/javascript">
+
+function qrCodeDown(){
+	
+	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/agent/exportExcel";
+	$("#seachform").submit();
+	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/agent/agentMonthList.html";
+};
+</script>
+</html>

+ 116 - 4
src/main/resources/templates/sys/fx/merchantMealScAdd.html

@@ -360,7 +360,23 @@
 		        <td height="20"></td>
 		        <td></td>
 		      </tr>
-		      
+
+				<tr valign="top" th:if="${merchant.posType ==3}">
+					<td align="right" width="70" style="line-height: 30px;font-weight: 700">销售人员:</td>
+					<td>
+						<ul class="nmb_jj">
+							<li>
+								<input name="agentName" id="agentName" type="text"  class="srkk" style="width: 115px;" autocomplete="off" onfocus="funcblurlibId()" placeholder="请选择绑定销售">
+								<input name="agentId" type="hidden" id="agentId"   class="srkk" >
+							</li>
+						</ul>
+					</td>
+				</tr>
+				<tr>
+					<td height="20"></td>
+					<td></td>
+				</tr>
+
 		      <tr>
 		        <td></td>
 		        <td><a style="margin-left: 20px;" class="ty_but ml20" href="javascript:#" onclick="save();">购  买</a></td>
@@ -371,7 +387,35 @@
 	</div>
 <br/>
 <br/>
+	<div class="formbody" id="likejoinlist" style="display: none">
+		<div class="rightinfo">
+			<ul class="seachform">
+				<li>
+					<label>销售名称:</label>
+					<input name="likename" id="likename" type="text" class="scinput" />
+				</li>
+				<li>
+					<input type="button" class="scbtn" value="全局查询" onclick="funcblurlibIdlist()" style="height: 32px;"/>
+				</li>
+			</ul>
 
+			<ul class="seachform joinseachform">
+
+			</ul>
+			<br/><br/>
+		</div>
+		<div class="pagin" style="float: left;width: 90%;">
+			<div class="message">共<i class="blue countNum">0</i>条记录,当前显示第&nbsp;<i class="blue pageNo">0</i>页</div>
+			<form id="splitFrom" name="splitFrom" >
+				<input type="hidden" id="pageNo" name="pageNo" value="1">
+				<input type="hidden" id="pageSize" name="pageSize" value="20">
+				<ul class="paginList joinpaginList">
+
+				</ul>
+			</form>
+			<br/><br/>
+		</div>
+	</div>
 <table class="tablelist">
 	<thead>
 	    <tr>
@@ -407,7 +451,7 @@
 </table> 
 <br/>
 <br/>
-	
+
 
 </body>
 
@@ -466,6 +510,7 @@
 				var endActiveTime=$("#endActiveTime").val();
 				var price=$("#price").val();
 				var unitPrice=$("#unitPrice").val();
+				var agentId = $("#agentId").val();
 				
 				var url="[[${sysUrl}]]/sys/fx/saveMerchantMealSc";
 				var params ={
@@ -475,7 +520,8 @@
 			        'startActiveTime':startActiveTime,
 			        'endActiveTime':endActiveTime,
 			        'unitPrice':unitPrice,
-			        'price':price
+			        'price':price,
+					'agentId':agentId
 			    };
 				$.post(url,params,function(data){
 					if(data.meta.success){
@@ -490,7 +536,73 @@
 				});
 		});
 	}
-	
+	var likejoinUrl="[[${sysUrl}]]/sys/agent/agentList";
+	function funcblurlibIdlist(pageNo){
+		$(".joinseachform").html("");
+		var params ={
+			'name' : $("#likename").val(),
+			'pageNo' : pageNo,
+			'pageSize':16
+		}
+
+		$.post(likejoinUrl,params,function(data){
+			if(data.meta.success){
+				var html=[];
+				for (var i = 0; i < data.data.jsonList.length; i++) {
+					html.push("<li><label><input name='radiolib' value='"+data.data.jsonList[i].id+"' type='radio' onchange='funcblurlibIdradio(this)' >"+data.data.jsonList[i].agentName+"</label></li>");
+				}
+
+				var countPage=data.data.countPage;
+				var pageNo=data.data.pageNo;
+				$(".countNum").html(data.data.countNum);
+				$(".pageNo").html(data.data.pageNo);
+
+				var pagehtml=[];
+				if(pageNo>1){
+					pagehtml.push('<li class="paginItem"><a href="javascript:;" onclick="javascript:funcblurlibIdlist('+(pageNo-1)+');"><span class="pagepre"></span></a></li>');
+				}
+				for (var i = 1; i <= countPage; i++) {
+					if(i==pageNo){
+						pagehtml.push('<li class="paginItem  current"><a href="javascript:;" onclick="javascript:funcblurlibIdlist(\''+i+'\');return false;">'+i+'</a></li>' );
+					}else{
+						pagehtml.push('<li class="paginItem"><a href="javascript:;" onclick="javascript:funcblurlibIdlist(\''+i+'\');return false;">'+i+'</a></li>' );
+					}
+				}
+				if(countPage>pageNo){
+					pagehtml.push('<li class="paginItem"><a href="javascript:;" onclick="javascript:funcblurlibIdlist('+(pageNo+1)+');"><span class="pagenxt"></span></a></li>');
+				}
+
+				$(".joinpaginList").html(pagehtml.join(''));
+				$(".joinseachform").append(html.join(""));
+			}else{
+
+			}
+		});
+	}
+	function  funcblurlibIdradio(obj) {
+		var data = $(obj);
+		var dataValue = data.val();
+		$("#agentId").val(dataValue);
+		var libText = $("input[name=radiolib]:checked").parent("label").text();
+		$("#agentName").val(libText);
+		layer.close(likejoinlistindex);
+	}
+
+	var likejoinlistindex=null;
+	function funcblurlibId(){
+		funcblurlibIdlist();
+		if($(".layui-layer-shade").length<=0){
+			likejoinlistindex =layer.open({
+				type: 1,
+				title: '选择销售',
+				closeBtn: 1, //不显示关闭按钮
+				shift: 0.8,
+				offset: '150px',
+				area: ['80%', '60%'],
+				content: $("#likejoinlist")
+			});
+		}
+	}
 	
 </script>
 

+ 26 - 15
src/main/resources/templates/sys/lib/libUserHistorylist.html

@@ -4,6 +4,7 @@
 <script th:include="sys/common/metaCSS" th:remove="tag"></script> 
 <script th:include="sys/common/metaJS" th:remove="tag"></script> 
 <script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>
+<script th:include="sys/common/selectSearchJS" th:remove="tag"></script>
 </head>
 <style>
 	.tablelink{margin-right:10px;}
@@ -30,22 +31,18 @@
 	<ul class="seachform">
 		<li>
 			<label>书名</label>
-			<input name="title" type="text" class="scinput" th:value="${search.get('title')}"/>
+			<input name="title" type="text" class="scinput" th:value="${search.get('title')}" autocomplete="off"/>
 		</li>
 		
 		<li>
 			<label>借书人</label>
-			<input name="child_name" type="text" class="scinput" th:value="${search.get('child_name')}"/>	
+			<input name="child_name" type="text" class="scinput" th:value="${search.get('child_name')}" autocomplete="off"/>
 			</li>
 			<li>
 				<label>借书时间</label>
-				<input type="text" id="beginDate" name="beginDate"  onclick="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')}'})" th:value="${search.beginDate }" class="scinput date_width " placeholder="开始时间">
-			</li>
-			
-			
-			<li>
-				<label>借书时间</label>
-				<input type="text" id="endDate" name="endDate"  onclick="WdatePicker({minDate:'#F{$dp.$D(\'beginDate\')}'})" th:value="${search.endDate }" class="scinput date_width" placeholder="结束时间">
+				<input type="text" id="beginDate" name="beginDate" autocomplete="off"  onclick="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')}'})" th:value="${search.beginDate }" class="scinput date_width " placeholder="开始时间">
+				--
+				<input type="text" id="endDate" name="endDate" autocomplete="off"  onclick="WdatePicker({minDate:'#F{$dp.$D(\'beginDate\')}'})" th:value="${search.endDate }" class="scinput date_width" placeholder="结束时间">
 			</li>
 		<li th:if="${#lists.size(libList) gt 1 }">
 				<label>图书馆</label>
@@ -67,12 +64,19 @@
 			<label>&nbsp;</label>
 			<input type="button" class="scbtn" value="查询" />
 		</li>
+		<li >
+			<ul class="toolbar">
+				<a href="javascript:;" onclick="qrCodeDown();"><li class="click"><span><img th:src="@{/static/sys/images/generate.png}" /></span>导出</li></a>
+
+			</ul>
+		</li>
 	</ul>
 	</form>
 	<table class="tablelist">
 		<thead>
 		    <tr>
 		        <th style="width: 50px;">序号</th>
+		        <th>图书馆名</th>
 		        <th>书名</th>
 		        <th>封面</th>
 		        <th>状态</th>
@@ -81,20 +85,18 @@
 		        <th>卡号</th>
 		        <th>借书时间</th>
 		        <th>还书时间</th>
+		        <th>应还书时间</th>
 		    </tr>
 		</thead>
 		<tbody>
 			<tr th:each="liblist:${list}" >
 				<td th:text="${liblistStat.count}" ></td>
+				<td th:text="${liblist.get('league_name')}"></td>
 				<td th:text="${liblist.get('title')}"></td>
 				<td  class="imgtd">
-							<img  th:if="${liblist.get('local_image')}!=null" th:src="${imgUrl}+''+${liblist.get('local_image')}" style="width: 50px;height: 50px;" />
+							<img  th:if="${liblist.get('book_img')}!=null" th:src="${imgUrl}+''+${liblist.get('book_img')}" style="width: 50px;height: 50px;" />
 					</td>
-				<td th:switch="${liblist.get('state')}" >
-					    <span th:case="1" >在借</span>
-					    <span th:case="2" >逾期</span>
-					    <span th:case="3" >已还</span>
-				   </td>
+				<td th:text="${liblist.get('state')}" ></td>
 				   <td  class="imgtd">
 							<img  th:if="${liblist.get('qr_url')}!=null" th:src="${imgUrl}+''+${liblist.get('qr_url')}" style="width: 50px;height: 50px;" />
 					</td>	
@@ -102,6 +104,7 @@
 				<td th:text="${liblist.get('flow_id')}"></td>
 				<td th:text="${#calendars.format(liblist.get('create_time'),'yyyy-MM-dd HH:mm:ss')}" ></td>
 				<td th:text="${#calendars.format(liblist.get('update_time'),'yyyy-MM-dd HH:mm:ss')}" ></td>
+				<td th:text="${#calendars.format(liblist.get('back_book_time'),'yyyy-MM-dd HH:mm:ss')}" ></td>
 			</tr>
 		</tbody>
 	</table>
@@ -111,4 +114,12 @@
     	<div th:utext='${listNavigatHtml}' th:remove="tag" ></div>
    	</div>
 </div>
+<script type="text/javascript">
+	function qrCodeDown(){
+
+		document.getElementById("seachform").action = "[[${sysUrl}]]/sys/lib/exportExcel";
+		$("#seachform").submit();
+		document.getElementById("seachform").action = "[[${sysUrl}]]/sys/lib/libUserHistorylist.html";
+	};
+</script>
 </body>

+ 1 - 1
src/main/resources/templates/sys/login/index.html

@@ -68,7 +68,7 @@
 	  if(typeof($.cookie('sys_menu_url')) == "undefined"){
 
 		  var url= $("ul.submenu").find('li').eq(0).attr('data-url');
-	  	if(url == "undefined"){
+	  	if(url == "undefined" || url ==='#' ){
 		 	 $("#mainFrame").attr("src", "[[${sysUrl}]]/sys/login/home.html");
 	  	}else{
 		  	$("#mainFrame").attr("src", "[[${sysUrl}]]"+url);

+ 17 - 18
src/main/resources/templates/sys/sales/libVipServiceList.html

@@ -2,7 +2,8 @@
 <head>
 <title>私塾家</title>
 <script th:include="sys/common/metaCSS" th:remove="tag"></script> 
-<script th:include="sys/common/metaJS" th:remove="tag"></script> 
+<script th:include="sys/common/metaJS" th:remove="tag"></script>
+<script th:include="sys/common/selectSearchJS" th:remove="tag"></script>
 </head>
 <style>
 	.tablelink{margin-right:10px;}
@@ -42,25 +43,15 @@
 					</select>
 		</li>
 		<li>
-		<label>会员类型</label>
-					<select class="scinput select_width" name="level" >
-					    <option value=""  th:selected="${ search.get('level') eq '' }"  >全部</option>
-						<option value="1" th:selected="${ search.get('level') eq '1' }" >会员卡</option>
-						<option value="5" th:selected="${ search.get('level') eq '5' }" >尊享卡</option>
-						<option value="4" th:selected="${ search.get('level') eq '4' }" >联名卡</option>
-					</select>
-		</li>
-		<li>
-		<label>购卡服务</label>
-					<select class="scinput select_width" name="type"   >
-					    <option value=""  th:selected="${ search.get('type') eq '' }"  >全部</option>
-						<option th:value="${sort.code}" th:each="sort:${cardType}" th:selected="${ search.get('type') eq sort.code }" >[[${sort.name}]]</option>
-					</select>
-		</li>
-		<li>
 			<label>&nbsp;</label>
 			<input type="button" class="scbtn" value="查询" />
 		</li>
+		<li >
+			<ul class="toolbar">
+				<a href="javascript:;" onclick="qrCodeDown();"><li class="click"><span><img th:src="@{/static/sys/images/generate.png}" /></span>导出</li></a>
+
+			</ul>
+		</li>
 	</ul>
 	</form>
 	<table class="tablelist">
@@ -159,5 +150,13 @@
 			});
 		});
 	}
-</script> 
+
+ function qrCodeDown(){
+
+	 document.getElementById("seachform").action = "[[${sysUrl}]]/sys/sales/exportExcel";
+	 $("#seachform").submit();
+	 document.getElementById("seachform").action = "[[${sysUrl}]]/sys/sales/libVipServiceList.html";
+ };
+</script>
+</body>
 </html>