WxOrderController.java
5.97 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/**
* Copyright © 2015-2018 <a href="#">J-Site</a> All rights reserved.
*/
package com.thinkgem.jeesite.modules.wechat.web;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.interfaces.service.WXService;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import com.thinkgem.jeesite.modules.wechat.entity.WxOrder;
import com.thinkgem.jeesite.modules.wechat.service.WxOrderService;
/**
* 微信预约Controller
* @author lzj
* @version 2020-03-06
*/
@Controller
@RequestMapping(value = "${adminPath}/wechat/wxOrder")
public class WxOrderController extends BaseController {
@Autowired
private WxOrderService wxOrderService;
@Autowired
private WXService wxService;
@ModelAttribute
public WxOrder get(@RequestParam(required=false) String id) {
WxOrder entity = null;
if (StringUtils.isNotBlank(id)){
entity = wxOrderService.get(id);
}
if (entity == null){
entity = new WxOrder();
}
return entity;
}
@RequiresPermissions("wechat:wxOrder:view")
@RequestMapping(value = {"list", ""})
public String list(WxOrder wxOrder, HttpServletRequest request, HttpServletResponse response, Model model) {
User user = UserUtils.getUser();
String office = user.getOffice().getName();
if(StringUtils.isNotBlank(office)) {
if(office.indexOf("权证") != -1) {
wxOrder.setYwdl("10");
}else if(office.indexOf("抵押") != -1) {
wxOrder.setYwdl("20");
}else if(office.indexOf("预告") != -1) {
wxOrder.setYwdl("30");
}else if(office.indexOf("农林") != -1) {
wxOrder.setYwdl("40");
}else {
wxOrder.setYwdl("-");
}
List<WxOrder> list = wxOrderService.findList(wxOrder);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
if(list.size()>0) {
for(int i=0;i<list.size();i++) {
wxOrder = list.get(i);
String sj = wxOrder.getYydate()+" "+wxOrder.getYysjd().substring(wxOrder.getYysjd().indexOf("-")+1);
logger.info(sj);
try {
if(!(wxOrder.getSign().equals("1")) && !(wxOrder.getSign().equals("4")) && !(wxOrder.getSign().equals("3")) && (sdf.parse(sj).before(new Date()))) {
wxOrder.setSign("3");
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
model.addAttribute("list", list);
}
return "modules/wechat/wxOrderList";
}
@RequiresPermissions("wechat:wxOrder:view")
@RequestMapping(value = "form")
public String form(WxOrder wxOrder, Model model) {
model.addAttribute("wxOrder", wxOrder);
return "modules/wechat/wxOrderForm";
}
@RequiresPermissions("wechat:wxOrder:edit")
@RequestMapping(value = "save")
public String save(WxOrder wxOrder, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, wxOrder)){
return form(wxOrder, model);
}
wxOrderService.save(wxOrder);
addMessage(redirectAttributes, "保存微信预约成功");
return "redirect:"+Global.getAdminPath()+"/wechat/wxOrder/?repage";
}
@RequiresPermissions("wechat:wxOrder:view")
@RequestMapping(value = "sign")
public String sign(WxOrder wxOrder, Model model, RedirectAttributes redirectAttributes) {
wxOrder.setSign("1");
String ckbh = UserUtils.getUser().getCkbh();
wxOrder.setBlck(ckbh);
wxOrderService.save(wxOrder);
Map map = new HashMap();
try {
map = wxService.sign(wxOrder);
}catch(Exception e){
e.printStackTrace();
map.put("success", false);
map.put("resultMsg", e.getMessage());
}
addMessage(redirectAttributes, "签到成功");
return "redirect:"+Global.getAdminPath()+"/wechat/wxOrder/?repage";
}
@ResponseBody
@RequestMapping(value = "call")
public Map call(WxOrder wxOrder, Model model, HttpServletRequest request) {
Map map = new HashMap();
try {
map = wxService.call(request);
}catch(Exception e){
e.printStackTrace();
map.put("success", false);
map.put("resultMsg", e.getMessage());
}
return map;
}
@ResponseBody
@RequestMapping(value = "send")
public Map send(WxOrder wxOrder, Model model, HttpServletRequest request) {
Map map = new HashMap();
try {
map = wxService.send(request);
}catch(Exception e){
e.printStackTrace();
map.put("success", false);
map.put("resultMsg", e.getMessage());
}
return map;
}
@RequiresPermissions("wechat:wxOrder:view")
@RequestMapping(value = "ckwindow")
public String ckwindow(WxOrder wxOrder, Model model, RedirectAttributes redirectAttributes) {
model.addAttribute("wxOrder", wxOrder);
return "modules/wechat/ckwindow";
}
@RequiresPermissions("wechat:wxOrder:view")
@RequestMapping(value = "windowsave")
public void windowsave(WxOrder wxOrder, Model model, RedirectAttributes redirectAttributes) {
wxOrderService.save(wxOrder);
}
@RequiresPermissions("wechat:wxOrder:edit")
@RequestMapping(value = "delete")
public String delete(WxOrder wxOrder, RedirectAttributes redirectAttributes) {
wxOrderService.delete(wxOrder);
addMessage(redirectAttributes, "删除微信预约成功");
return "redirect:"+Global.getAdminPath()+"/wechat/wxOrder/?repage";
}
}