Helius
2020-12-27 8eda088db63ff198cbcd51bf0599531ed006cb84
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
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;
         
    }
  
}