|
@@ -7,6 +7,11 @@ import com.shigongli.common.BaseController;
|
7
|
7
|
import com.shigongli.common.ResponseBean;
|
8
|
8
|
import com.shigongli.common.StringUtils;
|
9
|
9
|
import com.shigongli.constants.StatusConstant;
|
|
10
|
+import com.shigongli.entity.TaHouseOrder;
|
|
11
|
+import com.shigongli.entity.TaHouseSetting;
|
|
12
|
+import com.shigongli.entity.TaPerson;
|
|
13
|
+import com.shigongli.service.ITaHouseOrderService;
|
|
14
|
+import com.shigongli.service.ITaHouseSettingService;
|
10
|
15
|
import com.shigongli.vo.HousePersonParams;
|
11
|
16
|
import io.swagger.annotations.Api;
|
12
|
17
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -23,6 +28,7 @@ import com.shigongli.service.ITaHousePersonService;
|
23
|
28
|
import com.shigongli.entity.TaHousePerson;
|
24
|
29
|
import org.springframework.web.bind.annotation.RestController;
|
25
|
30
|
|
|
31
|
+import javax.servlet.http.HttpServletRequest;
|
26
|
32
|
import java.util.ArrayList;
|
27
|
33
|
import java.util.List;
|
28
|
34
|
|
|
@@ -45,6 +51,12 @@ public class TaHousePersonController extends BaseController {
|
45
|
51
|
@Autowired
|
46
|
52
|
public ITaHousePersonService iTaHousePersonService;
|
47
|
53
|
|
|
54
|
+ @Autowired
|
|
55
|
+ ITaHouseOrderService iTaHouseOrderService;
|
|
56
|
+
|
|
57
|
+ @Autowired
|
|
58
|
+ ITaHouseSettingService iTaHouseSettingService;
|
|
59
|
+
|
48
|
60
|
|
49
|
61
|
/**
|
50
|
62
|
* 分页查询列表
|
|
@@ -72,7 +84,8 @@ public class TaHousePersonController extends BaseController {
|
72
|
84
|
*/
|
73
|
85
|
@RequestMapping(value="/ma/taHousePerson",method= RequestMethod.POST)
|
74
|
86
|
@ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
75
|
|
- public ResponseBean taHousePersonAdd(@ApiParam("保存内容") @RequestBody HousePersonParams housePersonParams) throws Exception{
|
|
87
|
+ public ResponseBean taHousePersonAdd(@ApiParam("保存内容") @RequestBody HousePersonParams housePersonParams,
|
|
88
|
+ HttpServletRequest request) throws Exception{
|
76
|
89
|
|
77
|
90
|
if (null == housePersonParams) {
|
78
|
91
|
return ResponseBean.error("请设置入住人员信息", ResponseBean.ERROR_MISSING_PARAMS);
|
|
@@ -86,6 +99,34 @@ public class TaHousePersonController extends BaseController {
|
86
|
99
|
return ResponseBean.error("请设置入住人员信息", ResponseBean.ERROR_MISSING_PARAMS);
|
87
|
100
|
}
|
88
|
101
|
|
|
102
|
+ // 订单
|
|
103
|
+ TaHouseOrder taHouseOrder = iTaHouseOrderService.getById(housePersonParams.getOrderId());
|
|
104
|
+ if (null == taHouseOrder) {
|
|
105
|
+ return ResponseBean.error("校验订单信息出错", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
106
|
+ }
|
|
107
|
+
|
|
108
|
+ if (!StringUtils.isEmpty(taHouseOrder.getPersonId())) {
|
|
109
|
+ return ResponseBean.error("该分享房源已经存在入住信息", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ // 设置
|
|
113
|
+ TaHouseSetting taHouseSetting = iTaHouseSettingService.getById(taHouseOrder.getSettingId());
|
|
114
|
+ if (null == taHouseSetting) {
|
|
115
|
+ return ResponseBean.error("校验房源配置出错", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
116
|
+ }
|
|
117
|
+
|
|
118
|
+ // 填写的入住人员数量必须与设置的人数一致
|
|
119
|
+ if (housePersonParams.getPersonList().size() != taHouseSetting.getPersonNum()) {
|
|
120
|
+ return ResponseBean.error("填写入住人员数量出错", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
121
|
+ }
|
|
122
|
+
|
|
123
|
+ // 更新订单
|
|
124
|
+ TaPerson taPerson = getPerson(request);
|
|
125
|
+ taHouseOrder.setPersonId(taPerson.getPersonId());
|
|
126
|
+ taHouseOrder.setStatus(StatusConstant.NORMAL);
|
|
127
|
+ iTaHouseOrderService.updateById(taHouseOrder);
|
|
128
|
+
|
|
129
|
+ // 插入入住人
|
89
|
130
|
List<TaHousePerson> taHousePersonList = new ArrayList<>();
|
90
|
131
|
for (HousePersonParams.Person person: housePersonParams.getPersonList()) {
|
91
|
132
|
TaHousePerson taHousePerson = new TaHousePerson();
|