java110
2023-07-18 cdc459d70949f091ef5e928d74e8b5503b1df24e
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
package com.java110.user.api;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.utils.StringUtils;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.dto.renting.RentingConfigDto;
import com.java110.dto.renting.RentingPoolDto;
import com.java110.dto.renting.RentingPoolAttrDto;
import com.java110.po.renting.RentingConfigPo;
import com.java110.po.renting.RentingPoolPo;
import com.java110.po.renting.RentingPoolAttrPo;
import com.java110.po.renting.RentingPoolFlowPo;
import com.java110.user.bmo.rentingConfig.IDeleteRentingConfigBMO;
import com.java110.user.bmo.rentingConfig.IGetRentingConfigBMO;
import com.java110.user.bmo.rentingConfig.ISaveRentingConfigBMO;
import com.java110.user.bmo.rentingConfig.IUpdateRentingConfigBMO;
import com.java110.user.bmo.rentingPool.*;
import com.java110.user.bmo.rentingPoolAttr.IDeleteRentingPoolAttrBMO;
import com.java110.user.bmo.rentingPoolAttr.IGetRentingPoolAttrBMO;
import com.java110.user.bmo.rentingPoolAttr.ISaveRentingPoolAttrBMO;
import com.java110.user.bmo.rentingPoolAttr.IUpdateRentingPoolAttrBMO;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
 
 
@RestController
@RequestMapping(value = "/renting")
public class RentingApi {
 
    @Autowired
    private ISaveRentingConfigBMO saveRentingConfigBMOImpl;
    @Autowired
    private IUpdateRentingConfigBMO updateRentingConfigBMOImpl;
    @Autowired
    private IDeleteRentingConfigBMO deleteRentingConfigBMOImpl;
 
    @Autowired
    private IGetRentingConfigBMO getRentingConfigBMOImpl;
 
 
    @Autowired
    private ISaveRentingPoolBMO saveRentingPoolBMOImpl;
    @Autowired
    private IUpdateRentingPoolBMO updateRentingPoolBMOImpl;
    @Autowired
    private IDeleteRentingPoolBMO deleteRentingPoolBMOImpl;
 
    @Autowired
    private IGetRentingPoolBMO getRentingPoolBMOImpl;
 
    @Autowired
    private ISaveRentingPoolAttrBMO saveRentingPoolAttrBMOImpl;
    @Autowired
    private IUpdateRentingPoolAttrBMO updateRentingPoolAttrBMOImpl;
    @Autowired
    private IDeleteRentingPoolAttrBMO deleteRentingPoolAttrBMOImpl;
 
    @Autowired
    private IGetRentingPoolAttrBMO getRentingPoolAttrBMOImpl;
 
    @Autowired
    private IAuditRentingBMO auditRentingBMOImpl;
 
    /**
     * 微信保存消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /renting/saveRentingConfig
     * @path /app/renting/saveRentingConfig
     */
    @RequestMapping(value = "/saveRentingConfig", method = RequestMethod.POST)
    public ResponseEntity<String> saveRentingConfig(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "rentingType", "请求报文中未包含rentingType");
        Assert.hasKeyAndValue(reqJson, "rentingFormula", "请求报文中未包含rentingFormula");
        Assert.hasKeyAndValue(reqJson, "servicePrice", "请求报文中未包含servicePrice");
        Assert.hasKeyAndValue(reqJson, "serviceOwnerRate", "请求报文中未包含serviceOwnerRate");
        Assert.hasKeyAndValue(reqJson, "serviceTenantRate", "请求报文中未包含serviceTenantRate");
        Assert.hasKeyAndValue(reqJson, "adminSeparateRate", "请求报文中未包含adminSeparateRate");
        Assert.hasKeyAndValue(reqJson, "proxySeparateRate", "请求报文中未包含proxySeparateRate");
        Assert.hasKeyAndValue(reqJson, "propertySeparateRate", "请求报文中未包含propertySeparateRate");
 
 
        RentingConfigPo rentingConfigPo = BeanConvertUtil.covertBean(reqJson, RentingConfigPo.class);
        return saveRentingConfigBMOImpl.save(rentingConfigPo);
    }
 
    /**
     * 微信修改消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /renting/updateRentingConfig
     * @path /app/renting/updateRentingConfig
     */
    @RequestMapping(value = "/updateRentingConfig", method = RequestMethod.POST)
    public ResponseEntity<String> updateRentingConfig(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "rentingType", "请求报文中未包含rentingType");
        Assert.hasKeyAndValue(reqJson, "rentingFormula", "请求报文中未包含rentingFormula");
        Assert.hasKeyAndValue(reqJson, "servicePrice", "请求报文中未包含servicePrice");
        Assert.hasKeyAndValue(reqJson, "serviceOwnerRate", "请求报文中未包含serviceOwnerRate");
        Assert.hasKeyAndValue(reqJson, "serviceTenantRate", "请求报文中未包含serviceTenantRate");
        Assert.hasKeyAndValue(reqJson, "adminSeparateRate", "请求报文中未包含adminSeparateRate");
        Assert.hasKeyAndValue(reqJson, "proxySeparateRate", "请求报文中未包含proxySeparateRate");
        Assert.hasKeyAndValue(reqJson, "propertySeparateRate", "请求报文中未包含propertySeparateRate");
        Assert.hasKeyAndValue(reqJson, "rentingConfigId", "rentingConfigId不能为空");
 
 
        RentingConfigPo rentingConfigPo = BeanConvertUtil.covertBean(reqJson, RentingConfigPo.class);
        return updateRentingConfigBMOImpl.update(rentingConfigPo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /renting/deleteRentingConfig
     * @path /app/renting/deleteRentingConfig
     */
    @RequestMapping(value = "/deleteRentingConfig", method = RequestMethod.POST)
    public ResponseEntity<String> deleteRentingConfig(@RequestBody JSONObject reqJson) {
        ;
 
        Assert.hasKeyAndValue(reqJson, "rentingConfigId", "rentingConfigId不能为空");
 
 
        RentingConfigPo rentingConfigPo = BeanConvertUtil.covertBean(reqJson, RentingConfigPo.class);
        return deleteRentingConfigBMOImpl.delete(rentingConfigPo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @return
     * @serviceCode /renting/queryRentingConfig
     * @path /app/renting/queryRentingConfig
     */
    @RequestMapping(value = "/queryRentingConfig", method = RequestMethod.GET)
    public ResponseEntity<String> queryRentingConfig(
            @RequestParam(value = "page") int page,
            @RequestParam(value = "row") int row,
            @RequestParam(value = "rentingConfigId", required = false) String rentingConfigId) {
        RentingConfigDto rentingConfigDto = new RentingConfigDto();
        rentingConfigDto.setPage(page);
        rentingConfigDto.setRow(row);
        rentingConfigDto.setRentingConfigId(rentingConfigId);
        return getRentingConfigBMOImpl.get(rentingConfigDto);
    }
 
 
    /**
     * 微信保存消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /renting/saveRentingPool
     * @path /app/renting/saveRentingPool
     */
    @RequestMapping(value = "/saveRentingPool", method = RequestMethod.POST)
    public ResponseEntity<String> saveRentingPool(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "rentingTitle", "请求报文中未包含rentingTitle");
        Assert.hasKeyAndValue(reqJson, "roomId", "请求报文中未包含roomId");
        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
        Assert.hasKeyAndValue(reqJson, "communityName", "请求报文中未包含communityName");
        Assert.hasKeyAndValue(reqJson, "price", "请求报文中未包含price");
        Assert.hasKeyAndValue(reqJson, "paymentType", "请求报文中未包含paymentType");
        Assert.hasKeyAndValue(reqJson, "checkIn", "请求报文中未包含checkIn");
        Assert.hasKeyAndValue(reqJson, "rentingConfigId", "请求报文中未包含rentingConfigId");
        Assert.hasKeyAndValue(reqJson, "ownerName", "请求报文中未包含ownerName");
        Assert.hasKeyAndValue(reqJson, "ownerTel", "请求报文中未包含ownerTel");
        JSONArray photos = null;
        if (reqJson.containsKey("photos")) {
            photos = reqJson.getJSONArray("photos");
        }else{
            photos = new JSONArray();
        }
 
 
        RentingPoolPo rentingPoolPo = BeanConvertUtil.covertBean(reqJson, RentingPoolPo.class);
        return saveRentingPoolBMOImpl.save(rentingPoolPo,photos);
    }
 
    /**
     * 微信修改消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /renting/updateRentingPool
     * @path /app/renting/updateRentingPool
     */
    @RequestMapping(value = "/updateRentingPool", method = RequestMethod.POST)
    public ResponseEntity<String> updateRentingPool(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "rentingTitle", "请求报文中未包含rentingTitle");
        Assert.hasKeyAndValue(reqJson, "roomId", "请求报文中未包含roomId");
        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
        Assert.hasKeyAndValue(reqJson, "price", "请求报文中未包含price");
        Assert.hasKeyAndValue(reqJson, "checkIn", "请求报文中未包含checkInDate");
        Assert.hasKeyAndValue(reqJson, "rentingConfigId", "请求报文中未包含rentingConfigId");
        Assert.hasKeyAndValue(reqJson, "ownerName", "请求报文中未包含ownerName");
        Assert.hasKeyAndValue(reqJson, "ownerTel", "请求报文中未包含ownerTel");
        Assert.hasKeyAndValue(reqJson, "rentingId", "rentingId不能为空");
 
 
        RentingPoolPo rentingPoolPo = BeanConvertUtil.covertBean(reqJson, RentingPoolPo.class);
        return updateRentingPoolBMOImpl.update(rentingPoolPo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /renting/deleteRentingPool
     * @path /app/renting/deleteRentingPool
     */
    @RequestMapping(value = "/deleteRentingPool", method = RequestMethod.POST)
    public ResponseEntity<String> deleteRentingPool(@RequestBody JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
 
        Assert.hasKeyAndValue(reqJson, "rentingId", "rentingId不能为空");
 
 
        RentingPoolPo rentingPoolPo = BeanConvertUtil.covertBean(reqJson, RentingPoolPo.class);
        return deleteRentingPoolBMOImpl.delete(rentingPoolPo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param communityId 小区ID
     * @return
     * @serviceCode /renting/queryRentingPool
     * @path /app/renting/queryRentingPool
     */
    @RequestMapping(value = "/queryRentingPool", method = RequestMethod.GET)
    public ResponseEntity<String> queryRentingPool(@RequestParam(value = "communityId", required = false) String communityId,
                                                   @RequestParam(value = "communityName", required = false) String communityName,
                                                   @RequestParam(value = "page") int page,
                                                   @RequestParam(value = "row") int row,
                                                   @RequestParam(value = "state", required = false) String state,
                                                   @RequestParam(value = "rentingType", required = false) String rentingType,
                                                   @RequestParam(value = "rentingId", required = false) String rentingId
    ) {
        RentingPoolDto rentingPoolDto = new RentingPoolDto();
        rentingPoolDto.setPage(page);
        rentingPoolDto.setRow(row);
        rentingPoolDto.setCommunityId(communityId);
        rentingPoolDto.setCommunityName(communityName);
        rentingPoolDto.setRentingId(rentingId);
        rentingPoolDto.setRentingType(rentingType);
        if (!StringUtils.isEmpty(state) && state.contains(",")) {
            rentingPoolDto.setStates(state.split(","));
        } else {
            rentingPoolDto.setState(state);
        }
        return getRentingPoolBMOImpl.get(rentingPoolDto);
    }
 
 
    /**
     * 微信保存消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /renting/saveRentingPoolAttr
     * @path /app/renting/saveRentingPoolAttr
     */
    @RequestMapping(value = "/saveRentingPoolAttr", method = RequestMethod.POST)
    public ResponseEntity<String> saveRentingPoolAttr(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "rentingId", "请求报文中未包含rentingId");
        Assert.hasKeyAndValue(reqJson, "specCd", "请求报文中未包含specCd");
 
 
        RentingPoolAttrPo rentingPoolAttrPo = BeanConvertUtil.covertBean(reqJson, RentingPoolAttrPo.class);
        return saveRentingPoolAttrBMOImpl.save(rentingPoolAttrPo);
    }
 
    /**
     * 微信修改消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /renting/updateRentingPoolAttr
     * @path /app/renting/updateRentingPoolAttr
     */
    @RequestMapping(value = "/updateRentingPoolAttr", method = RequestMethod.POST)
    public ResponseEntity<String> updateRentingPoolAttr(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "rentingId", "请求报文中未包含rentingId");
        Assert.hasKeyAndValue(reqJson, "specCd", "请求报文中未包含specCd");
        Assert.hasKeyAndValue(reqJson, "attrId", "attrId不能为空");
 
 
        RentingPoolAttrPo rentingPoolAttrPo = BeanConvertUtil.covertBean(reqJson, RentingPoolAttrPo.class);
        return updateRentingPoolAttrBMOImpl.update(rentingPoolAttrPo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /renting/deleteRentingPoolAttr
     * @path /app/renting/deleteRentingPoolAttr
     */
    @RequestMapping(value = "/deleteRentingPoolAttr", method = RequestMethod.POST)
    public ResponseEntity<String> deleteRentingPoolAttr(@RequestBody JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
 
        Assert.hasKeyAndValue(reqJson, "attrId", "attrId不能为空");
 
 
        RentingPoolAttrPo rentingPoolAttrPo = BeanConvertUtil.covertBean(reqJson, RentingPoolAttrPo.class);
        return deleteRentingPoolAttrBMOImpl.delete(rentingPoolAttrPo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param communityId 小区ID
     * @return
     * @serviceCode /renting/queryRentingPoolAttr
     * @path /app/renting/queryRentingPoolAttr
     */
    @RequestMapping(value = "/queryRentingPoolAttr", method = RequestMethod.GET)
    public ResponseEntity<String> queryRentingPoolAttr(@RequestParam(value = "communityId") String communityId,
                                                       @RequestParam(value = "page") int page,
                                                       @RequestParam(value = "row") int row) {
        RentingPoolAttrDto rentingPoolAttrDto = new RentingPoolAttrDto();
        rentingPoolAttrDto.setPage(page);
        rentingPoolAttrDto.setRow(row);
        rentingPoolAttrDto.setCommunityId(communityId);
        return getRentingPoolAttrBMOImpl.get(rentingPoolAttrDto);
    }
 
    /**
     * 代理商 或者运营团队审核
     *
     * @param reqJson 请求信息
     * @return
     * @serviceCode /renting/auditRenting
     * @path /app/renting/auditRenting
     */
    @RequestMapping(value = "/auditRenting", method = RequestMethod.POST)
    public ResponseEntity<String> auditRenting(@RequestBody JSONObject reqJson,
                                               @RequestHeader(value = "store-id") String storeId,
                                               @RequestHeader(value = "user-id") String userId) {
        Assert.hasKeyAndValue(reqJson, "rentingId", "请求报文中未包含出租信息");
        Assert.hasKeyAndValue(reqJson, "state", "请求报文中未包含状态");
        Assert.hasKeyAndValue(reqJson, "context", "请求报文中未包含审核内容");
        Assert.hasKeyAndValue(reqJson, "userRole", "请求报文中未包含角色");
        Assert.hasValue(storeId, "请求报文中未包含商户ID");
        Assert.hasValue(userId, "请求报文中未包含用户ID");
 
 
        RentingPoolFlowPo rentingPoolFlowPo = new RentingPoolFlowPo();
        rentingPoolFlowPo.setContext(reqJson.getString("context"));
        rentingPoolFlowPo.setDealTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
        rentingPoolFlowPo.setFlowId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_flowId));
        rentingPoolFlowPo.setRentingId(reqJson.getString("rentingId"));
        rentingPoolFlowPo.setState(reqJson.getString("state"));
        rentingPoolFlowPo.setUserRole(reqJson.getString("userRole"));
 
        return auditRentingBMOImpl.audit(rentingPoolFlowPo, userId);
    }
}