| package com.matrix.system.hive.action; | 
|   | 
| import com.matrix.core.anotations.RemoveRequestToken; | 
| import com.matrix.core.anotations.SaveRequestToken; | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.core.pojo.PaginationVO; | 
| import com.matrix.core.tools.WebUtil; | 
| import com.matrix.system.common.bean.SysUsers; | 
| import com.matrix.system.common.dao.SysUsersDao; | 
| import com.matrix.system.hive.action.util.QueryUtil; | 
| import com.matrix.system.hive.bean.Onlinebooking; | 
| import com.matrix.system.hive.bean.SysShopInfo; | 
| import com.matrix.system.hive.dao.OnlinebookingDao; | 
| import com.matrix.system.hive.dao.SysShopInfoDao; | 
| import com.matrix.core.tools.DateUtil; | 
| import com.matrix.system.hive.plugin.util.ExcelUtil; | 
| import com.matrix.system.hive.service.OnlinebookingService; | 
| import com.matrix.system.shopXcx.bean.ShopProduct; | 
| import com.matrix.system.shopXcx.dao.ShopProductDao; | 
| import org.apache.poi.xssf.usermodel.XSSFWorkbook; | 
| 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.ResponseBody; | 
| import org.springframework.web.servlet.ModelAndView; | 
|   | 
| import javax.annotation.Resource; | 
| import javax.servlet.http.HttpServletRequest; | 
| import javax.servlet.http.HttpServletResponse; | 
| import java.io.IOException; | 
| import java.util.ArrayList; | 
| import java.util.List; | 
|   | 
| /** | 
|  * | 
|  * @date 2016-10-10 15:23 | 
|  */ | 
| @Controller | 
| @RequestMapping(value = "admin/onlinebooking") | 
| public class OnlinebookingController extends BaseController{ | 
|   | 
|     @Resource | 
|     private OnlinebookingService currentService; | 
|   | 
|     @Autowired | 
|     private OnlinebookingDao onlinebookingDao; | 
|   | 
|     @Autowired | 
|     private ShopProductDao productDao; | 
|   | 
|     @Autowired | 
|     SysUsersDao staffInfoDao; | 
|   | 
|     @Autowired | 
|     SysShopInfoDao shopInfoDao; | 
|   | 
|      | 
|     /** | 
|      * 列表显示 | 
|      */ | 
|     @RequestMapping(value = "/showList") | 
|     public @ResponseBody | 
|     AjaxResult showList(Onlinebooking onlinebooking, PaginationVO pageVo) { | 
|         QueryUtil.setQueryLimit(onlinebooking); | 
|         List<Onlinebooking> list = onlinebookingDao.selectInPageForWx(onlinebooking); | 
|         //相关数据赋值 | 
|         list.stream().forEach(order -> { | 
|             ShopProduct shopProduct = productDao.selectById(order.getProductId()); | 
|             order.setShopProduct(shopProduct); | 
|             if (order.getStaffId() != null) { | 
|                 SysUsers shopstaffInfo = staffInfoDao.selectById(Long.parseLong(order.getStaffId() + "")); | 
|                 order.setStaffInfo(shopstaffInfo); | 
|             } | 
|             SysShopInfo shopInfo = shopInfoDao.selectById(order.getShopId()); | 
|             order.setShopInfo(shopInfo); | 
|         }); | 
|         AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, "查询成功"); | 
|         result.setRows(list); | 
|         result.setTotal(onlinebookingDao.selectInPageForWxCount(onlinebooking)); | 
|         return result; | 
|     } | 
|         | 
|     /** | 
|      * 新增或者修改页面 | 
|      */    | 
|     @RemoveRequestToken | 
|        @RequestMapping(value = "/addOrModify") | 
|     public @ResponseBody AjaxResult addOrModify(Onlinebooking onlinebooking) { | 
|         if (onlinebooking.getId() != null) { | 
|             return modify(currentService, onlinebooking, "onlinebooking"); | 
|         } else { | 
|             return add(currentService, onlinebooking, "onlinebooking"); | 
|         } | 
|     } | 
|      | 
|        /** | 
|      * 进入修改界面 | 
|      */    | 
|     @SaveRequestToken | 
|        @RequestMapping(value = "/editForm") | 
|     public String editForm(Long id) { | 
|         Onlinebooking onlinebooking; | 
|         if (id != null) { | 
|             onlinebooking = currentService.findById(id); | 
|             WebUtil.getRequest().setAttribute("obj", onlinebooking); | 
|         } | 
|         return "admin/onlinebooking-form"; | 
|     } | 
|         | 
|         | 
|        /** | 
|      * 删除 | 
|      */   | 
|      @RequestMapping(value = "/del") | 
|     public @ResponseBody AjaxResult del(String keys) { | 
|         return remove(currentService, keys); | 
|     } | 
|       | 
|     /** | 
|      * 导出消耗统计 | 
|      *  | 
|      * @throws IOException | 
|      */ | 
|     @RequestMapping(value = "/exportOnlinebooking") | 
|     public @ResponseBody | 
|     ModelAndView report(HttpServletRequest request, HttpServletResponse response, Onlinebooking onlinebooking) throws IOException { | 
|          | 
|         onlinebooking.setShopId(getMe().getShopId()); | 
|         onlinebooking.setStatus(new String(onlinebooking.getStatus().trim().getBytes("ISO-8859-1"), "UTF-8")); | 
|         List<Onlinebooking> dataList = currentService.findByModel(onlinebooking); | 
|          | 
|         //组装excel数据 | 
|          List<List<Object>> list = new ArrayList<>(); | 
|          if(dataList.size()>0){ | 
|               for(Onlinebooking obj:dataList){ | 
|                   List<Object> temp = new ArrayList<>(); | 
|                   temp.add(obj.getVipInfo().getVipName()); | 
|                   String strDate= DateUtil.dateToString(obj.getTime(), DateUtil.DATE_FORMAT_SS); | 
|                   temp.add(strDate); | 
|                   temp.add(obj.getStatus()); | 
|                   //时间转为字符串  | 
|                   temp.add(obj.getReason()); | 
|                   temp.add(obj.getRemark()); | 
|                   temp.add(obj.getShopName()); | 
|                   String crtDate=DateUtil.dateToString(obj.getCreateTime(), DateUtil.DATE_FORMAT_SS); | 
|                   temp.add(crtDate); | 
|                   list.add(temp); | 
|               } | 
|          } | 
|           | 
|          String[] tdNames ={"会员姓名","预约时间","状态","取消原因","备注","所属门店","创建时间"}; | 
|             XSSFWorkbook workbook = ExcelUtil.createSimple2007("预约单记录",tdNames,list ); | 
|   | 
|            return null; | 
|           | 
|     } | 
|    | 
| } |