Bladeren bron

Merge remote-tracking branch 'origin/dev' into dev

顾绍勇 5 jaren geleden
bovenliggende
commit
48b8a6b44c

+ 5
- 0
src/main/java/com/huiju/estateagents/common/CommConstant.java Bestand weergeven

@@ -651,6 +651,11 @@ public class CommConstant {
651 651
      */
652 652
     public static final String HOUSE_LOCKING_TYPE_AUTO = "auto";
653 653
 
654
+    /**
655
+     * 手动锁房
656
+     */
657
+    public static final String HOUSE_LOCKING_TYPE_MANUAL = "manual";
658
+
654 659
     /**
655 660
      * 正在缴费
656 661
      */

+ 1
- 0
src/main/java/com/huiju/estateagents/controller/TaPreselectionController.java Bestand weergeven

@@ -233,6 +233,7 @@ public class TaPreselectionController extends BaseController {
233 233
                 }
234 234
             }
235 235
 
236
+            taPreselection.setPreselectionId(id);
236 237
             if (iTaPreselectionService.updateById(taPreselection)) {
237 238
                 responseBean.addSuccess(taPreselection);
238 239
             } else {

+ 70
- 0
src/main/java/com/huiju/estateagents/controller/TaRaiseRecordController.java Bestand weergeven

@@ -8,7 +8,13 @@ import com.huiju.estateagents.bo.request.HousingRaiseRequestBO;
8 8
 import com.huiju.estateagents.bo.request.RaiseOrderRequestBO;
9 9
 import com.huiju.estateagents.bo.request.RaiseRecordRequestBO;
10 10
 import com.huiju.estateagents.common.CommConstant;
11
+import com.huiju.estateagents.entity.TaHousingResources;
12
+import com.huiju.estateagents.entity.TaOrder;
13
+import com.huiju.estateagents.entity.TaRaiseHouse;
11 14
 import com.huiju.estateagents.entity.TaRaiseRecord;
15
+import com.huiju.estateagents.service.ITaHousingResourcesService;
16
+import com.huiju.estateagents.service.ITaOrderService;
17
+import com.huiju.estateagents.service.ITaRaiseHouseService;
12 18
 import com.huiju.estateagents.service.ITaRaiseRecordService;
13 19
 import org.apache.commons.collections.CollectionUtils;
14 20
 import org.apache.commons.lang3.StringUtils;
@@ -19,7 +25,10 @@ import org.springframework.web.bind.annotation.*;
19 25
 
20 26
 import javax.servlet.http.HttpServletRequest;
21 27
 import java.time.LocalDateTime;
28
+import java.util.HashMap;
22 29
 import java.util.List;
30
+import java.util.Map;
31
+import java.util.stream.Collectors;
23 32
 
24 33
 /**
25 34
  * <p>
@@ -38,6 +47,15 @@ public class TaRaiseRecordController extends BaseController {
38 47
     @Autowired
39 48
     public ITaRaiseRecordService iTaRaiseRecordService;
40 49
 
50
+    @Autowired
51
+    public ITaRaiseHouseService taRaiseHouseService;
52
+
53
+    @Autowired
54
+    public ITaHousingResourcesService taHousingResourcesService;
55
+
56
+    @Autowired
57
+    public ITaOrderService taOrderService;
58
+
41 59
     /**
42 60
      * 条件查询房源认筹记录
43 61
      *
@@ -411,4 +429,56 @@ public class TaRaiseRecordController extends BaseController {
411 429
         }
412 430
         return responseBean;
413 431
     }
432
+
433
+    /**
434
+     * 微信端下认筹单
435
+     *
436
+     * @param taRaiseRecord 实体对象
437
+     * @return
438
+     */
439
+    @RequestMapping(value = "/wx/taRaiseRecord", method = RequestMethod.POST)
440
+    public ResponseBean wxRaiseRecordAdd(@RequestBody TaRaiseRecord taRaiseRecord,HttpServletRequest request) {
441
+        ResponseBean responseBean = new ResponseBean();
442
+        try {
443
+            responseBean.addSuccess(iTaRaiseRecordService.saveRaiseInfo(taRaiseRecord,getOrgId(request),getPersonId(request)));
444
+        } catch (Exception e) {
445
+            logger.error("微信端下认筹单 -=- {}", e.toString());
446
+            responseBean.addError(e.getMessage());
447
+        }
448
+        return responseBean;
449
+    }
450
+
451
+
452
+    /**
453
+     * 微信端获取认筹单详细信息
454
+     *
455
+     * @param raiseRecordId 认筹旦id
456
+     * @return
457
+     */
458
+    @RequestMapping(value = "/wx/taRaiseRecord/{raiseRecordId}", method = RequestMethod.POST)
459
+    public ResponseBean wxGetRaiseRecordById(@PathVariable Integer raiseRecordId,HttpServletRequest request) {
460
+        ResponseBean responseBean = new ResponseBean();
461
+        try {
462
+            //获取认筹单信息
463
+            TaRaiseRecord taRaiseRecord = iTaRaiseRecordService.getById(raiseRecordId);
464
+            //房源与认筹单关系图
465
+            List<TaRaiseHouse> taRaiseHouseList = taRaiseHouseService.list(new QueryWrapper<TaRaiseHouse>().eq("raise_record_id", taRaiseRecord.getRaiseRecordId()));
466
+            //房源信息
467
+            List<TaHousingResources> houseList = (List<TaHousingResources>) taHousingResourcesService.listByIds(taRaiseHouseList.stream().map(TaRaiseHouse::getHouseId).collect(Collectors.toList()));
468
+            //订单信息
469
+            TaOrder taOrder = taOrderService.getById(taRaiseRecord.getOrderId());
470
+
471
+            Map<String,Object> map = new HashMap<>();
472
+            map.put("taRaiseRecord",taRaiseRecord);
473
+            map.put("taRaiseHouseList",taRaiseHouseList);
474
+            map.put("houseList",houseList);
475
+            map.put("taOrder",taOrder);
476
+            responseBean.addSuccess(map);
477
+        } catch (Exception e) {
478
+            e.printStackTrace();
479
+            logger.error("微信端获取认筹单详细信息 -=- {}", e.toString());
480
+            responseBean.addError(e.getMessage());
481
+        }
482
+        return responseBean;
483
+    }
414 484
 }

+ 13
- 2
src/main/java/com/huiju/estateagents/entity/TaPreselection.java Bestand weergeven

@@ -56,6 +56,11 @@ public class TaPreselection implements Serializable {
56 56
      */
57 57
     private Integer status;
58 58
 
59
+    /**
60
+     * 项目id
61
+     */
62
+    private String buildingId;
63
+
59 64
     /**
60 65
      * 创建时间
61 66
      */
@@ -79,6 +84,12 @@ public class TaPreselection implements Serializable {
79 84
     @TableField(exist = false)
80 85
     private String salesBatchName;
81 86
 
87
+    /**
88
+     * 备注
89
+     */
90
+    @TableField(exist = false)
91
+    private String remark;
92
+
82 93
     /**
83 94
      * 二维码
84 95
      */
@@ -92,8 +103,8 @@ public class TaPreselection implements Serializable {
92 103
     private Integer realHeat;
93 104
 
94 105
     /**
95
-     * 销售批次备注
106
+     * 预选实际热度
96 107
      */
97 108
     @TableField(exist = false)
98
-    private Integer remark;
109
+    private Integer preNum;
99 110
 }

+ 2
- 2
src/main/java/com/huiju/estateagents/entity/TaPreselectionRecord.java Bestand weergeven

@@ -76,7 +76,7 @@ public class TaPreselectionRecord implements Serializable {
76 76
     private String buildingId;
77 77
 
78 78
     /**
79
-     * 预选id
79
+     * 预选idtaSalesBatch
80 80
      */
81
-    private String preselectId;
81
+    private String preselectionId;
82 82
 }

+ 8
- 0
src/main/java/com/huiju/estateagents/entity/TaRaiseRecord.java Bestand weergeven

@@ -9,6 +9,8 @@ import lombok.experimental.Accessors;
9 9
 
10 10
 import java.io.Serializable;
11 11
 import java.time.LocalDateTime;
12
+import java.util.ArrayList;
13
+import java.util.List;
12 14
 
13 15
 /**
14 16
  * <p>
@@ -171,4 +173,10 @@ public class TaRaiseRecord implements Serializable {
171 173
      */
172 174
     @TableField(exist = false)
173 175
     private String totalFee;
176
+
177
+    /**
178
+     *  小程序端提交的房源的id的集合
179
+     */
180
+    @TableField(exist = false)
181
+    private List<Integer> houseList = new ArrayList<>();
174 182
 }

+ 9
- 0
src/main/java/com/huiju/estateagents/service/ITaRaiseRecordService.java Bestand weergeven

@@ -51,4 +51,13 @@ public interface ITaRaiseRecordService extends IService<TaRaiseRecord> {
51 51
      * @return
52 52
      */
53 53
     ResponseBean listRaiseOrderByCondition(RaiseOrderRequestBO orderRequestBO, Integer pageNumber, Integer pageSize);
54
+
55
+    /**
56
+     * 小程序端保存认筹单信息
57
+     * @param taRaiseRecord
58
+     * @param orgId
59
+     * @param personId
60
+     * @return
61
+     */
62
+    TaRaiseRecord saveRaiseInfo(TaRaiseRecord taRaiseRecord, Integer orgId, String personId) throws Exception;
54 63
 }

+ 8
- 2
src/main/java/com/huiju/estateagents/service/impl/TaPreselectionServiceImpl.java Bestand weergeven

@@ -47,7 +47,13 @@ public class TaPreselectionServiceImpl extends ServiceImpl<TaPreselectionMapper,
47 47
 
48 48
         ResponseBean responseBean = new ResponseBean();
49 49
         IPage<TaPreselection> pg = new Page<>(pageNum, pageSize);
50
-        responseBean.addSuccess(taPreselectionMapper.listPresecretByCondition(pg, salesBatchName, buildingId, orgId, status, taPersonBuildingListByUserId));
50
+        IPage<TaPreselection>  taPreselectionIPage = taPreselectionMapper.listPresecretByCondition(pg, salesBatchName, buildingId, orgId, status, taPersonBuildingListByUserId);
51
+        taPreselectionIPage.getRecords().forEach(e->{
52
+            QueryWrapper<TaPreselectionRecord> taPreselectionRecordQueryWrapper = new QueryWrapper<>();
53
+            taPreselectionRecordQueryWrapper.eq("sales_batch_id", e.getSalesBatchId());
54
+            e.setPreNum(taPreselectionRecordMapper.selectCount(taPreselectionRecordQueryWrapper));
55
+        });
56
+        responseBean.addSuccess(taPreselectionIPage);
51 57
         return responseBean;
52 58
     }
53 59
 
@@ -65,7 +71,7 @@ public class TaPreselectionServiceImpl extends ServiceImpl<TaPreselectionMapper,
65 71
             preselectionRecordQueryWrapper.eq("status", 1);
66 72
             List<TaPreselectionRecord> tpList = taPreselectionRecordMapper.selectList(preselectionRecordQueryWrapper);
67 73
             if (CollectionUtils.isNotEmpty(tpList)) {
68
-                responseBean.addError(String.format("销售批次%s已有用户预选,请先删除预选记录。", tp.getSalesBatchId()));
74
+                responseBean.addError(String.format("销售批次%s已有用户预选,请先删除预选记录。", tp.getSalesBatchName()));
69 75
                 return responseBean;
70 76
             }
71 77
         }

+ 109
- 2
src/main/java/com/huiju/estateagents/service/impl/TaRaiseRecordServiceImpl.java Bestand weergeven

@@ -8,8 +8,9 @@ import com.huiju.estateagents.base.ResponseBean;
8 8
 import com.huiju.estateagents.bo.request.HousingRaiseRequestBO;
9 9
 import com.huiju.estateagents.bo.request.RaiseOrderRequestBO;
10 10
 import com.huiju.estateagents.bo.request.RaiseRecordRequestBO;
11
-import com.huiju.estateagents.entity.TaRaiseRecord;
12
-import com.huiju.estateagents.mapper.TaRaiseRecordMapper;
11
+import com.huiju.estateagents.common.CommConstant;
12
+import com.huiju.estateagents.entity.*;
13
+import com.huiju.estateagents.mapper.*;
13 14
 import com.huiju.estateagents.po.TaHousingResourcesPO;
14 15
 import com.huiju.estateagents.service.ITaRaiseRecordService;
15 16
 import org.slf4j.Logger;
@@ -17,6 +18,9 @@ import org.slf4j.LoggerFactory;
17 18
 import org.springframework.beans.factory.annotation.Autowired;
18 19
 import org.springframework.stereotype.Service;
19 20
 
21
+import java.time.LocalDateTime;
22
+import java.util.List;
23
+
20 24
 /**
21 25
  * <p>
22 26
  * 认筹单(认筹记录表)  服务实现类
@@ -33,6 +37,21 @@ public class TaRaiseRecordServiceImpl extends ServiceImpl<TaRaiseRecordMapper, T
33 37
     @Autowired
34 38
     private TaRaiseRecordMapper taRaiseRecordMapper;
35 39
 
40
+    @Autowired
41
+    private TaRaiseMapper taRaiseMapper;
42
+
43
+    @Autowired
44
+    private TaHousingResourcesMapper taHousingResourcesMapper;
45
+
46
+    @Autowired
47
+    private TaSalesBatchMapper taSalesBatchMapper;
48
+
49
+    @Autowired
50
+    private TaPersonMapper taPersonMapper;
51
+
52
+    @Autowired
53
+    private TaRaiseHouseMapper taRaiseHouseMapper;
54
+
36 55
     @Override
37 56
     public ResponseBean listHousingRaiseByCondition(HousingRaiseRequestBO requestBO, Integer pageNumber, Integer pageSize) {
38 57
         logger.info("TaRaiseRecordServiceImpl.listRaiseRecordByCondition 接收参数:bo:{},pageNumber:{},pageSize:{}", JSONObject.toJSONString(requestBO), pageNumber, pageSize);
@@ -62,4 +81,92 @@ public class TaRaiseRecordServiceImpl extends ServiceImpl<TaRaiseRecordMapper, T
62 81
         responseBean.addSuccess(taRaiseRecordMapper.listRaiseOrderByCondition(pg, orderRequestBO));
63 82
         return responseBean;
64 83
     }
84
+
85
+    /**
86
+     * 小程序端保存认筹单信息
87
+     *
88
+     * @param taRaiseRecord
89
+     * @param orgId
90
+     * @param personId
91
+     * @return
92
+     */
93
+    @Override
94
+    public TaRaiseRecord saveRaiseInfo(TaRaiseRecord taRaiseRecord, Integer orgId, String personId) throws Exception {
95
+        List<Integer> houseList = taRaiseRecord.getHouseList();
96
+        if (houseList.size() < 1){
97
+            throw new Exception("请选择房源!");
98
+        }
99
+        //获取认筹信息
100
+        TaRaise taRaise = taRaiseMapper.selectById(taRaiseRecord.getRaiseId());
101
+        //如果是自动锁房就要判断里面的房源有没有被锁住
102
+        if (taRaise.getHouseLockingType().equals(CommConstant.HOUSE_LOCKING_TYPE_AUTO)){
103
+            if (houseList.size() > 0){
104
+                throw new Exception("此认筹为自动锁房只能选择一个房源!");
105
+            }
106
+            //获取房源详细信息
107
+            TaHousingResources taHousingResources = taHousingResourcesMapper.selectById(houseList.get(0));
108
+            if (null == taHousingResources){
109
+                throw new Exception("此房源不存在!");
110
+            }
111
+            if (taHousingResources.getHouseLockingStatus().equals(CommConstant.HOUSE_LOCKING_STATUS_LOCKED)){
112
+                throw new Exception("此房源已被锁定!");
113
+            }
114
+            //检验成功的话先锁定房源
115
+            lockedHouseResources(taHousingResources);
116
+        }
117
+        //插入认筹单
118
+        saveRaiseRecord(taRaiseRecord,orgId,personId,taRaise);
119
+
120
+        return taRaiseRecord;
121
+    }
122
+
123
+    /**
124
+     * 插入认筹单
125
+     * @param taRaiseRecord
126
+     */
127
+    private void saveRaiseRecord(TaRaiseRecord taRaiseRecord, Integer orgId, String personId,TaRaise taRaise) {
128
+        List<Integer> houseList = taRaiseRecord.getHouseList();
129
+        //销售批次信息
130
+        TaSalesBatch taSalesBatch = taSalesBatchMapper.selectById(taRaiseRecord.getSalesBatchId());
131
+        //获取用户信息
132
+
133
+        taRaiseRecord.setOrgId(orgId);
134
+        taRaiseRecord.setBuildingId(taSalesBatch.getBuildingId());
135
+        taRaiseRecord.setPersonId(personId);
136
+        taRaiseRecord.setHouseNum(houseList.size());
137
+        if (taRaise.getHouseLockingType().equals(CommConstant.HOUSE_LOCKING_TYPE_AUTO)){
138
+            taRaiseRecord.setHouseLockingStatus(CommConstant.HOUSE_LOCKING_STATUS_LOCKED);
139
+        }
140
+        taRaiseRecord.setStatus(CommConstant.STATUS_NORMAL);
141
+        taRaiseRecord.setPayStatus(CommConstant.PAY_STATUS_UNPAID);
142
+        taRaiseRecord.setPayType(taRaise.getPayType());
143
+        taRaiseRecord.setCreateDate(LocalDateTime.now());
144
+        //插入认筹单信息
145
+        taRaiseRecordMapper.insert(taRaiseRecord);
146
+        
147
+        //插入房源与认筹单关系表
148
+        TaPerson taPerson = taPersonMapper.selectById(personId);
149
+        houseList.forEach(e -> {
150
+            TaRaiseHouse taRaiseHouse = new TaRaiseHouse();
151
+            taRaiseHouse.setHouseId(e);
152
+            taRaiseHouse.setCreateDate(LocalDateTime.now());
153
+            if (taRaise.getHouseLockingType().equals(CommConstant.HOUSE_LOCKING_TYPE_AUTO)){
154
+                taRaiseHouse.setHouseLockingStatus(CommConstant.HOUSE_LOCKING_STATUS_LOCKED);
155
+            }
156
+            taRaiseHouse.setOrgId(orgId);
157
+            taRaiseHouse.setPersonId(personId);
158
+            taRaiseHouse.setPersonName(taPerson.getName());
159
+            taRaiseHouse.setRaiseRecordId(taRaiseRecord.getRaiseRecordId());
160
+            taRaiseHouseMapper.insert(taRaiseHouse);
161
+        });
162
+    }
163
+
164
+    /**
165
+     * 锁定房源
166
+     * @param taHousingResources
167
+     */
168
+    private synchronized void lockedHouseResources(TaHousingResources taHousingResources) {
169
+        taHousingResources.setHouseLockingStatus(CommConstant.HOUSE_LOCKING_STATUS_LOCKED);
170
+        taHousingResourcesMapper.updateById(taHousingResources);
171
+    }
65 172
 }

+ 3
- 3
src/main/resources/mapper/TaPreselectionMapper.xml Bestand weergeven

@@ -5,6 +5,7 @@
5 5
     <select id="listPresecretByCondition" resultType="com.huiju.estateagents.entity.TaPreselection">
6 6
         SELECT
7 7
         t.*,
8
+        t2.sales_number,t2.sales_batch_name,t2.remark,
8 9
         t2.sales_number,
9 10
         t2.remark,
10 11
         t3.building_name,
@@ -12,7 +13,7 @@
12 13
         FROM
13 14
         ta_preselection t
14 15
         LEFT JOIN ta_sales_batch t2 ON t.sales_batch_id = t2.sales_batch_id
15
-        LEFT JOIN ta_building t3 ON t2.building_id = t3.building_id
16
+        LEFT JOIN ta_building t3 ON t.building_id = t3.building_id
16 17
         WHERE
17 18
         t.org_id = #{orgId}
18 19
         AND t.STATUS != - 1
@@ -45,8 +46,7 @@
45 46
             t.*,
46 47
             t2.qr_code,
47 48
             t2.remark,
48
-            t2.sales_batch_name,
49
-            t2.building_id
49
+            t2.sales_batch_name
50 50
         FROM
51 51
             ta_preselection t,
52 52
             ta_sales_batch t2