顾绍勇 преди 5 години
родител
ревизия
7cea80782f

+ 43
- 11
src/main/java/com/huiju/estateagents/controller/TaPreselectionController.java Целия файл

@@ -11,6 +11,7 @@ import com.huiju.estateagents.entity.TaPreselection;
11 11
 import com.huiju.estateagents.entity.TaSalesBatch;
12 12
 import com.huiju.estateagents.service.ITaPreselectionService;
13 13
 import com.huiju.estateagents.service.impl.TaSalesBatchServiceImpl;
14
+import org.apache.commons.lang3.StringUtils;
14 15
 import org.slf4j.Logger;
15 16
 import org.slf4j.LoggerFactory;
16 17
 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,7 +41,7 @@ public class TaPreselectionController extends BaseController {
40 41
     private TaSalesBatchServiceImpl taSalesBatchService;
41 42
 
42 43
     /**
43
-     * 获取销售批次列表-预选
44
+     * 条件查询预选列表
44 45
      *
45 46
      * @param pageNum
46 47
      * @param pageSize
@@ -50,18 +51,18 @@ public class TaPreselectionController extends BaseController {
50 51
      * @param request
51 52
      * @return
52 53
      */
53
-    @RequestMapping(value = "/admin/listSalesBatchForPreselect", method = RequestMethod.GET)
54
-    public ResponseBean listSalesBatchForPreselect(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
55
-                                                   @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
56
-                                                   String buildingId, String salesBatchName, Integer status,
57
-                                                   HttpServletRequest request) {
54
+    @RequestMapping(value = "/admin/listPresecretByCondition", method = RequestMethod.GET)
55
+    public ResponseBean listPresecretByCondition(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
56
+                                                 @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
57
+                                                 String buildingId, String salesBatchName, Integer status,
58
+                                                 HttpServletRequest request) {
58 59
         ResponseBean responseBean = new ResponseBean();
59 60
 
60 61
         try {
61 62
             Integer orgId = getOrgId(request);
62 63
             List<TaPersonBuilding> personBuildingList = getTaPersonBuildingListByUserId(request);
63 64
 
64
-            responseBean = taSalesBatchService.listSalesBatchForPreselect(pageSize, pageNum, salesBatchName, buildingId, orgId, status, personBuildingList);
65
+            responseBean = iTaPreselectionService.listPresecretByCondition(pageSize, pageNum, salesBatchName, buildingId, orgId, status, personBuildingList);
65 66
             logger.info("listSalesBatchForPreselect 返回结果:{}", JSONObject.toJSONString(responseBean));
66 67
         } catch (Exception e) {
67 68
             logger.error("listSalesBatchForPreselect -=- {}", e);
@@ -204,9 +205,40 @@ public class TaPreselectionController extends BaseController {
204 205
      */
205 206
     @RequestMapping(value = "/taPreselection/{id}", method = RequestMethod.PUT)
206 207
     public ResponseBean taPreselectionUpdate(@PathVariable Integer id,
207
-                                             @RequestBody TaPreselection taPreselection) {
208
+                                             @RequestBody TaPreselection taPreselection,
209
+                                             HttpServletRequest request) {
208 210
         ResponseBean responseBean = new ResponseBean();
209 211
         try {
212
+
213
+            if (taPreselection.getSalesBatchId() == null) {
214
+                responseBean.addError("销售批次为空");
215
+                return responseBean;
216
+            }
217
+
218
+            Integer orgId = getOrgId(request);
219
+            // 校验是否预选过
220
+            QueryWrapper<TaPreselection> queryWrapper = new QueryWrapper<>();
221
+            queryWrapper.eq("org_id", orgId);
222
+            queryWrapper.eq("sales_batch_id", taPreselection.getSalesBatchId());
223
+            TaPreselection record = iTaPreselectionService.getOne(queryWrapper);
224
+            if (record != null) {
225
+                responseBean.addError("销售批次已新增过预选");
226
+                return responseBean;
227
+            }
228
+
229
+            if (StringUtils.isNotBlank(taPreselection.getPreselectionStartTime()) && StringUtils.isNotBlank(taPreselection.getPreselectionEndTime())) {
230
+                // 更新批次表信息
231
+                TaSalesBatch taSalesBatch = new TaSalesBatch();
232
+                taSalesBatch.setSalesBatchId(taPreselection.getSalesBatchId());
233
+                taSalesBatch.setPreselectionStartTime(taPreselection.getPreselectionStartTime());
234
+                taSalesBatch.setPreselectionEndTime(taPreselection.getPreselectionEndTime());
235
+                Boolean updateResult = taSalesBatchService.updateById(taSalesBatch);
236
+                if (!updateResult) {
237
+                    responseBean.addError("fail");
238
+                    return responseBean;
239
+                }
240
+            }
241
+
210 242
             if (iTaPreselectionService.updateById(taPreselection)) {
211 243
                 responseBean.addSuccess(taPreselection);
212 244
             } else {
@@ -225,11 +257,11 @@ public class TaPreselectionController extends BaseController {
225 257
      *
226 258
      * @param id 实体ID
227 259
      */
228
-    @RequestMapping(value = "/taPreselection/{id}", method = RequestMethod.GET)
229
-    public ResponseBean taPreselectionGet(@PathVariable Integer id) {
260
+    @RequestMapping(value = "/admin/taPreselection/{id}", method = RequestMethod.GET)
261
+    public ResponseBean taPreselectionGet(@PathVariable Integer id, HttpServletRequest request) {
230 262
         ResponseBean responseBean = new ResponseBean();
231 263
         try {
232
-            responseBean.addSuccess(iTaPreselectionService.getById(id));
264
+            responseBean = iTaPreselectionService.getPresecretById(id, getOrgId(request));
233 265
         } catch (Exception e) {
234 266
             e.printStackTrace();
235 267
             logger.error("taPreselectionDelete -=- {}", e.toString());

+ 29
- 0
src/main/java/com/huiju/estateagents/entity/TaPreselection.java Целия файл

@@ -1,6 +1,7 @@
1 1
 package com.huiju.estateagents.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
4 5
 import com.baomidou.mybatisplus.annotation.TableId;
5 6
 import lombok.Data;
6 7
 import lombok.EqualsAndHashCode;
@@ -60,5 +61,33 @@ public class TaPreselection implements Serializable {
60 61
      */
61 62
     private LocalDateTime createDate;
62 63
 
64
+    /**
65
+     * 出售房源数
66
+     */
67
+    @TableField(exist = false)
68
+    private Integer salesNumber;
63 69
 
70
+    /**
71
+     * 楼盘名
72
+     */
73
+    @TableField(exist = false)
74
+    private String buildingName;
75
+
76
+    /**
77
+     * 销售批次名
78
+     */
79
+    @TableField(exist = false)
80
+    private String salesBatchName;
81
+
82
+    /**
83
+     * 二维码
84
+     */
85
+    @TableField(exist = false)
86
+    private String qrCode;
87
+
88
+    /**
89
+     * 预选实际热度
90
+     */
91
+    @TableField(exist = false)
92
+    private Integer realHeat;
64 93
 }

+ 31
- 0
src/main/java/com/huiju/estateagents/mapper/TaPreselectionMapper.java Целия файл

@@ -1,8 +1,14 @@
1 1
 package com.huiju.estateagents.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.huiju.estateagents.entity.TaPersonBuilding;
4 6
 import com.huiju.estateagents.entity.TaPreselection;
5 7
 import org.apache.ibatis.annotations.Mapper;
8
+import org.apache.ibatis.annotations.Param;
9
+import org.springframework.stereotype.Component;
10
+
11
+import java.util.List;
6 12
 
7 13
 /**
8 14
  * <p>
@@ -13,6 +19,31 @@ import org.apache.ibatis.annotations.Mapper;
13 19
  * @since 2020-02-26
14 20
  */
15 21
 @Mapper
22
+@Component
16 23
 public interface TaPreselectionMapper extends BaseMapper<TaPreselection> {
17 24
 
25
+    /**
26
+     * 条件查询预选
27
+     *
28
+     * @param page
29
+     * @param salesBatchName
30
+     * @param buildingId
31
+     * @param orgId
32
+     * @param status
33
+     * @param personBuildingList
34
+     * @return
35
+     */
36
+    IPage<TaPreselection> listPresecretByCondition(IPage<TaPreselection> page,
37
+                                                   @Param("salesBatchName") String salesBatchName,
38
+                                                   @Param("buildingId") String buildingId,
39
+                                                   @Param("orgId") Integer orgId,
40
+                                                   @Param("status") Integer status,
41
+                                                   @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
42
+
43
+    /**
44
+     * @param id
45
+     * @param orgId
46
+     * @return
47
+     */
48
+    TaPreselection getPresecretById(@Param("id") Integer id, @Param("orgId") Integer orgId);
18 49
 }

+ 0
- 8
src/main/java/com/huiju/estateagents/mapper/TaSalesBatchMapper.java Целия файл

@@ -41,14 +41,6 @@ public interface TaSalesBatchMapper extends BaseMapper<TaSalesBatch> {
41 41
      */
42 42
     Map<String, Object> getTotalHousesAndHeat(@Param("salesBatchId") Integer salesBatchId);
43 43
 
44
-    IPage<TaSalesBatch> listSalesBatchForPreselect(IPage<TaSalesBatch> page,
45
-                                                   @Param("salesBatchName") String salesBatchName,
46
-                                                   @Param("buildingId") String buildingId,
47
-                                                   @Param("orgId") Integer orgId,
48
-                                                   @Param("status") Integer status,
49
-                                                   @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
50
-
51
-
52 44
     IPage<TaSalesBatch> listSalesBatchForRaise(IPage<TaSalesBatch> page,
53 45
                                                @Param("salesBatchName") String salesBatchName,
54 46
                                                @Param("buildingId") String buildingId,

+ 24
- 0
src/main/java/com/huiju/estateagents/service/ITaPreselectionService.java Целия файл

@@ -2,6 +2,7 @@ package com.huiju.estateagents.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.huiju.estateagents.base.ResponseBean;
5
+import com.huiju.estateagents.entity.TaPersonBuilding;
5 6
 import com.huiju.estateagents.entity.TaPreselection;
6 7
 
7 8
 import java.util.List;
@@ -16,6 +17,20 @@ import java.util.List;
16 17
  */
17 18
 public interface ITaPreselectionService extends IService<TaPreselection> {
18 19
 
20
+    /**
21
+     * 获取预选列表
22
+     *
23
+     * @param pageSize
24
+     * @param pageNum
25
+     * @param salesBatchName
26
+     * @param buildingId
27
+     * @param orgId
28
+     * @param status
29
+     * @return
30
+     */
31
+    ResponseBean listPresecretByCondition(Integer pageSize, Integer pageNum, String salesBatchName, String buildingId,
32
+                                          Integer orgId, Integer status, List<TaPersonBuilding> taPersonBuildingListByUserId);
33
+
19 34
     /**
20 35
      * 批量删除
21 36
      *
@@ -25,4 +40,13 @@ public interface ITaPreselectionService extends IService<TaPreselection> {
25 40
      */
26 41
     ResponseBean batchDelete(List<TaPreselection> taPreselectionList, Integer orgId);
27 42
 
43
+
44
+    /**
45
+     *
46
+     * @param id
47
+     * @param orgId
48
+     * @return
49
+     */
50
+    ResponseBean getPresecretById(Integer id, Integer orgId);
51
+
28 52
 }

+ 0
- 14
src/main/java/com/huiju/estateagents/service/ITaSalesBatchService.java Целия файл

@@ -37,20 +37,6 @@ public interface ITaSalesBatchService extends IService<TaSalesBatch> {
37 37
      */
38 38
     ResponseBean getSalesBatchById(Integer salesBatchId);
39 39
 
40
-    /**
41
-     * 获取销售批次列表 - 预选
42
-     *
43
-     * @param pageSize
44
-     * @param pageNum
45
-     * @param salesBatchName
46
-     * @param buildingId
47
-     * @param orgId
48
-     * @param status
49
-     * @return
50
-     */
51
-    ResponseBean listSalesBatchForPreselect(Integer pageSize, Integer pageNum, String salesBatchName, String buildingId,
52
-                                            Integer orgId, Integer status, List<TaPersonBuilding> taPersonBuildingListByUserId);
53
-
54 40
     /**
55 41
      * 获取销售批次列表 - 认筹
56 42
      *

+ 20
- 1
src/main/java/com/huiju/estateagents/service/impl/TaPreselectionServiceImpl.java Целия файл

@@ -2,8 +2,11 @@ package com.huiju.estateagents.service.impl;
2 2
 
3 3
 import com.alibaba.fastjson.JSONObject;
4 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6 8
 import com.huiju.estateagents.base.ResponseBean;
9
+import com.huiju.estateagents.entity.TaPersonBuilding;
7 10
 import com.huiju.estateagents.entity.TaPreselection;
8 11
 import com.huiju.estateagents.entity.TaPreselectionRecord;
9 12
 import com.huiju.estateagents.mapper.TaPreselectionMapper;
@@ -37,6 +40,17 @@ public class TaPreselectionServiceImpl extends ServiceImpl<TaPreselectionMapper,
37 40
     @Autowired
38 41
     private TaPreselectionRecordMapper taPreselectionRecordMapper;
39 42
 
43
+    @Override
44
+    public ResponseBean listPresecretByCondition(Integer pageSize, Integer pageNum, String salesBatchName, String buildingId, Integer orgId, Integer status, List<TaPersonBuilding> taPersonBuildingListByUserId) {
45
+        logger.info("listPresecretByCondition 接收参数:pageSize:{},pageNum:{},salesBatchName:{},buildilgId:{},orgId:{},status:{},taPersonBuildingListByUserId:{}",
46
+                pageSize, pageNum, salesBatchName, buildingId, orgId, status, JSONObject.toJSONString(taPersonBuildingListByUserId));
47
+
48
+        ResponseBean responseBean = new ResponseBean();
49
+        IPage<TaPreselection> pg = new Page<>(pageNum, pageSize);
50
+        responseBean.addSuccess(taPreselectionMapper.listPresecretByCondition(pg, salesBatchName, buildingId, orgId, status, taPersonBuildingListByUserId));
51
+        return responseBean;
52
+    }
53
+
40 54
     @Override
41 55
     public ResponseBean batchDelete(List<TaPreselection> taPreselectionList, Integer orgId) {
42 56
         logger.info("TaPreselectionServiceImpl.batchDelete 接收参数:list:{},orgId:{}", JSONObject.toJSONString(taPreselectionList), orgId);
@@ -44,7 +58,6 @@ public class TaPreselectionServiceImpl extends ServiceImpl<TaPreselectionMapper,
44 58
         ResponseBean responseBean = new ResponseBean();
45 59
 
46 60
         for (TaPreselection tp : taPreselectionList) {
47
-
48 61
             // 校验是否有用户预选
49 62
             QueryWrapper<TaPreselectionRecord> preselectionRecordQueryWrapper = new QueryWrapper<>();
50 63
             preselectionRecordQueryWrapper.eq("org_id", orgId);
@@ -67,7 +80,13 @@ public class TaPreselectionServiceImpl extends ServiceImpl<TaPreselectionMapper,
67 80
         } else {
68 81
             responseBean.addError("fail");
69 82
         }
83
+        return responseBean;
84
+    }
70 85
 
86
+    @Override
87
+    public ResponseBean getPresecretById(Integer id, Integer orgId) {
88
+        ResponseBean responseBean = new ResponseBean();
89
+        responseBean.addSuccess(taPreselectionMapper.getPresecretById(id, orgId));
71 90
         return responseBean;
72 91
     }
73 92
 }

+ 0
- 23
src/main/java/com/huiju/estateagents/service/impl/TaSalesBatchServiceImpl.java Целия файл

@@ -196,29 +196,6 @@ public class TaSalesBatchServiceImpl extends ServiceImpl<TaSalesBatchMapper, TaS
196 196
         return responseBean;
197 197
     }
198 198
 
199
-    /**
200
-     * @param pageSize
201
-     * @param pageNum
202
-     * @param salesBatchName
203
-     * @param buildingId
204
-     * @param orgId
205
-     * @param status
206
-     * @return
207
-     */
208
-    @Override
209
-    public ResponseBean listSalesBatchForPreselect(Integer pageSize, Integer pageNum, String salesBatchName, String buildingId,
210
-                                                   Integer orgId, Integer status, List<TaPersonBuilding> taPersonBuildingListByUserId) {
211
-
212
-        logger.info("listSalesBatchForPreselect 接收参数:pageSize:{},pageNum:{},salesBatchName:{},buildilgId:{},orgId:{},status:{},taPersonBuildingListByUserId:{}",
213
-                pageSize, pageNum, salesBatchName, buildingId, orgId, status,JSONObject.toJSONString(taPersonBuildingListByUserId));
214
-
215
-        ResponseBean responseBean = new ResponseBean();
216
-
217
-        IPage<TaSalesBatch> pg = new Page<>(pageNum, pageSize);
218
-        responseBean.addSuccess(taSalesBatchMapper.listSalesBatchForPreselect(pg, salesBatchName, buildingId, orgId, status, taPersonBuildingListByUserId));
219
-        return responseBean;
220
-    }
221
-
222 199
     @Override
223 200
     public ResponseBean listSalesBatchForRaise(Integer pageSize, Integer pageNum, String salesBatchName, String buildingId,
224 201
                                                Integer orgId, Integer status, List<TaPersonBuilding> taPersonBuildingListByUserId) {

+ 54
- 0
src/main/resources/mapper/TaPreselectionMapper.xml Целия файл

@@ -2,4 +2,58 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.huiju.estateagents.mapper.TaPreselectionMapper">
4 4
 
5
+    <select id="listPresecretByCondition" resultType="com.huiju.estateagents.entity.TaPreselection">
6
+        SELECT
7
+        t.*,
8
+        t2.sales_number,
9
+        t3.building_name,
10
+        ( SELECT sum( th.real_heat ) FROM ta_housing_resources th WHERE th.sales_batch_id = t2.sales_batch_id AND th.`status` = 1 ) real_heat
11
+        FROM
12
+        ta_preselection t
13
+        LEFT JOIN ta_sales_batch t2 ON t.sales_batch_id = t2.sales_batch_id
14
+        LEFT JOIN ta_building t3 ON t2.building_id = t3.building_id
15
+        WHERE
16
+        t.org_id = #{orgId}
17
+        AND t.STATUS != - 1
18
+        <if test="buildingId != null and buildingId != ''">
19
+            and t2.building_id = #{buildingId}
20
+        </if>
21
+        <if test="salesBatchName != null and salesBatchName != ''">
22
+            and t2.sales_batch_name like CONCAT('%',#{salesBatchName}, '%')
23
+        </if>
24
+        <if test="status != null">
25
+            and t.status = #{status}
26
+        </if>
27
+        <if test="personBuildingList != null and personBuildingList.size > 0">
28
+            AND t2.building_id in
29
+            <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
30
+                #{personBuilding.buildingId}
31
+            </foreach>
32
+        </if>
33
+        ORDER BY
34
+        t.create_date DESC
35
+    </select>
36
+
37
+    <select id="getPresecretById" resultType="com.huiju.estateagents.entity.TaPreselection">
38
+        SELECT
39
+            t3.*,
40
+            t4.building_name
41
+        FROM
42
+            (
43
+        SELECT
44
+            t.*,
45
+            t2.qr_code,
46
+            t2.sales_batch_name,
47
+            t2.building_id
48
+        FROM
49
+            ta_preselection t,
50
+            ta_sales_batch t2
51
+        WHERE
52
+            t.sales_batch_id = t2.sales_batch_id
53
+            AND t.preselection_id = #{id}
54
+            AND t.org_id = #{orgId}
55
+            ) t3
56
+            LEFT JOIN ta_building t4 ON t3.building_id = t4.building_id
57
+    </select>
58
+
5 59
 </mapper>

+ 0
- 32
src/main/resources/mapper/TaSalesBatchMapper.xml Целия файл

@@ -51,38 +51,6 @@
51 51
             t.STATUS = 1 and t.sales_batch_id = #{salesBatchId}
52 52
     </select>
53 53
 
54
-    <select id="listSalesBatchForPreselect" resultType="com.huiju.estateagents.entity.TaSalesBatch">
55
-            SELECT
56
-                t.*,
57
-                a.building_name,
58
-                a.real_heat preselectCount
59
-            FROM
60
-                ta_sales_batch t
61
-            LEFT JOIN ta_housing_resources a ON t.building_id = a.building_id
62
-            WHERE
63
-                t.org_id = #{orgId}
64
-                AND t.STATUS != - 1
65
-                AND t.preselection_start_time IS NOT NULL
66
-                AND t.preselection_end_time IS NOT NULL
67
-            <if test="buildingId != null and buildingId != ''">
68
-                and t.building_id = #{buildingId}
69
-            </if>
70
-            <if test="salesBatchName != null and salesBatchName != ''">
71
-                and t.sales_batch_name like CONCAT('%',#{salesBatchName}, '%')
72
-            </if>
73
-            <if test="status != null">
74
-                and t.status = #{status}
75
-            </if>
76
-            <if test="personBuildingList != null and personBuildingList.size > 0">
77
-                AND t.building_id in
78
-                <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
79
-                    #{personBuilding.buildingId}
80
-                </foreach>
81
-            </if>
82
-            ORDER BY
83
-              t.create_date DESC
84
-    </select>
85
-
86 54
     <select id="listSalesBatchForRaise" resultType="com.huiju.estateagents.entity.TaSalesBatch">
87 55
         SELECT
88 56
             t.*,