ParkLotController.java
7.51 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package com.rnt.controller;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.aop.Duang;
import com.jfinal.core.Controller;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Page;
import com.rnt.commo.enums.ErrorType;
import com.rnt.model.zf.ParkCardCoupons;
import com.rnt.service.IRainQueryService;
import com.rnt.service.ParkCardCouponsService;
import com.rnt.service.ParkLotService;
import com.rnt.service.PersonCardCouponsService;
import com.rnt.utils.IntToSmallChineseNumber;
import com.rnt.utils.TLWXUser;
import com.rnt.vo.BizResult;
import com.rnt.vo.CustCardVO;
import com.rnt.vo.ParkLotCardVO;
import com.rnt.vo.ParkLotListVO;
import com.rnt.vo.PsersonCustCardVO;
import com.xiaoleilu.hutool.date.DateUtil;
/**
* Copyright: Copyright (c) 2017 zteits
*
* @ClassName: com.rnt.controller
* @Description:
* @version: v1.0.0
* @author: atao
* @date: 2017/6/7 上午10:02
* Modification History:
* Date Author Version Description
* ---------------------------------------------------------*
* 2017/6/7 atao v1.0.0 创建
*/
public class ParkLotController extends Controller {
private static final Log logger = Log.getLog(ParkLotController.class);
/**
* 跳转停车场卡类型页面.<br/>
*/
public void card() {
String pklNo = this.getPara("pklNo"); //停车场编码
//pklNo="12313123";
this.getRequest().setAttribute("pklNo", pklNo);
render("card.html");
}
/**
* 跳转到我的停车场卡券视图
*/
public void myParkCardView() {
render("mine.html");
}
/**
* 获取我的停车场卡数量
*/
public void getCustCardNum() {
String custId = TLWXUser.getCustId();
ParkLotService parkLotService = Duang.duang(ParkLotService.class);
Long num = parkLotService.queryCustCardNum(custId);
Map<String, Object> map = new HashMap<>();
map.put("num", num);
map.put("numStr", IntToSmallChineseNumber.ToCH(num.intValue()));
BizResult<Map<String, Object>> result = new BizResult<>();
result.setData(map);
renderJson(result);
}
/**
* 获取我的停车卡券数据
*/
public void myParkCardList() {
String custId = TLWXUser.getCustId();
ParkLotService plService = Duang.duang(ParkLotService.class);
BizResult<Map<String, List<CustCardVO>>> result = new BizResult<>();
Map<String, List<CustCardVO>> mapResult = plService.queryCustParkCard(custId);
result.setData(mapResult);
renderJson(result);
}
public void parkListView() {
this.getResponse().setHeader("Access-Control-Allow-Origin", "*");
logger.info("获取到的微信用户为:wxuser=" + JSONObject.toJSONString(TLWXUser.getWXUser()));
setAttr("openId", TLWXUser.getOpenId());
render("mylist.html");
}
public void parkList() {
Integer pageNum = getParaToInt("pageNum");
Integer pageSize = getParaToInt("pageSize");
pageNum = pageNum == null ? 1 : pageNum;
pageSize = pageSize == null ? 10 : pageSize;
ParkLotService parkLotService = Duang.duang(ParkLotService.class);
Page<ParkLotListVO> page = parkLotService.listParkLot(pageNum, pageSize, Arrays.asList(2L));
BizResult<Page<ParkLotListVO>> result = new BizResult<Page<ParkLotListVO>>();
result.setData(page);
renderJson(result);
}
//public void initData() {
// List<ParkingLot> parkingLotList = ParkingLot.dao.find("select * from parking_lot");
// for (ParkingLot parkingLot : parkingLotList) {
// String parkNum = parkingLot.getPlNo();
// ParkCardCoupons parkCardCoupons = intPark(parkNum);
// parkCardCoupons.setGoodsType(20L);
// parkCardCoupons.save();
// parkCardCoupons = intPark(parkNum);
// parkCardCoupons.setGoodsType(21L);
// parkCardCoupons.save();
// parkCardCoupons = intPark(parkNum);
// parkCardCoupons.setGoodsType(22L);
// parkCardCoupons.save();
// parkCardCoupons = intPark(parkNum);
// parkCardCoupons.setGoodsType(23L);
// parkCardCoupons.save();
//
// }
//
//}
private ParkCardCoupons intPark(String parkNum) {
ParkCardCoupons parkCardCoupons = new ParkCardCoupons();
parkCardCoupons.setCreateDate(new Date());
parkCardCoupons.setCreateEmpid("-1");
parkCardCoupons.setDataState(1);
parkCardCoupons.setEffDate(new Date());
parkCardCoupons.setGoodsAmount(new BigDecimal("100.00"));
parkCardCoupons.setGoodsBigType(1);
parkCardCoupons.setGoodsState(1L);
parkCardCoupons.setModfiyDate(new Date());
parkCardCoupons.setModfiyEmpid("-1");
parkCardCoupons.setParkId(parkNum);
parkCardCoupons.setExpDate(DateUtil.offsetMonth(new Date(), 24 * 99));
return parkCardCoupons;
}
/**
* 查询停车场信息.<br/>
* 1.查询停车场信息.<br/>
* 2.查询停车卡信息.<br/>
*/
public void queryParkLotCard() {
BizResult<ParkLotCardVO> result = new BizResult<ParkLotCardVO>();
String pklNo = this.getPara("pklNo");
ParkLotService parkLotService = Duang.duang(ParkLotService.class);
ParkCardCouponsService parkCardCouponsService = Duang.duang(ParkCardCouponsService.class);
try {
//1.查询停车场信息
result = parkLotService.queryParkLotForpklNo(pklNo);
//2.查询停车卡信息
List<ParkCardCoupons> list = parkCardCouponsService.queryParkCardCouponsBypklNo(pklNo);
if (list != null && list.size() > 0) {
result.getData().setParkCardCouponsList(list);
}
} catch (Exception e) {
result.setErrorMessage(ErrorType.SYSTEM_ERROR, "业务错误");
e.printStackTrace();
}
this.renderJson(result);
}
/**
* 校验输入的车牌号是否已经办理对应的月/年卡.<br/>
* 步骤:通过车牌号+客户卡券id 查询.<br/>
*/
public void checkIsbuyCard() {
BizResult<String> result = new BizResult<String>();
String carNum = this.getPara("carNum");
String parkCardId = this.getPara("parkCardId"); //停车场卡券id
PersonCardCouponsService personCardCouponsService = Duang.duang(PersonCardCouponsService.class);
PsersonCustCardVO psersonCustCardVO = new PsersonCustCardVO();
psersonCustCardVO.setCarNumber(carNum);
psersonCustCardVO.setParkCardId(parkCardId);
String perSonCardId = personCardCouponsService.queryPsersonCard(psersonCustCardVO);
result.setData(perSonCardId);
this.renderJson(result);
}
/**
* 抬杆通知走车
*/
public void passHandrail() {
String orderId = getPara("orderId");
BizResult<String> result = new BizResult<>();
IRainQueryService service = Duang.duang(IRainQueryService.class);
try {
result = service.passHandrail(orderId);
} catch (Exception e) {
result.setErrorMessage(ErrorType.APP_ERROR, "抬杆通知失败!");
logger.error("支付成功,抬杆通知失败!", e);
}
logger.info("支付成功,抬杆通知 result=" + JSONObject.toJSONString(result));
renderJson(result);
}
}