顾绍勇 il y a 5 ans
Parent
révision
7acc90dcad

+ 1
- 1
src/main/java/com/huiju/estateagents/controller/TaQrcodeController.java Voir le fichier

@@ -55,7 +55,7 @@ public class TaQrcodeController extends BaseController {
55 55
         ResponseBean responseBean = new ResponseBean();
56 56
         try {
57 57
             List<TaPersonBuilding> personBuildingList = getTaPersonBuildingListByUserId(request);
58
-            responseBean = iTaQrcodeService.listQrCodeByCondition(pageNum, pageSize, targetType, targetName, channelId, buildingId, getOrgId(request), personBuildingList);
58
+            responseBean = iTaQrcodeService.listQrCodeByCondition(pageNum, pageSize, targetType, targetName, channelId, buildingId, getUserId(request), getOrgId(request), personBuildingList);
59 59
         } catch (Exception e) {
60 60
             e.printStackTrace();
61 61
             logger.error("taQrcodeList -=- {}", e.toString());

+ 1
- 0
src/main/java/com/huiju/estateagents/mapper/TaQrcodeMapper.java Voir le fichier

@@ -34,6 +34,7 @@ public interface TaQrcodeMapper extends BaseMapper<TaQrcode> {
34 34
                                           @Param("targetName") String targetName,
35 35
                                           @Param("channelId") Integer channelId,
36 36
                                           @Param("buildingId") String buildingId,
37
+                                          @Param("userId") Integer userId,
37 38
                                           @Param("orgId") Integer orgId,
38 39
                                           @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
39 40
 

+ 1
- 1
src/main/java/com/huiju/estateagents/mapper/TaRecommendCustomerMapper.java Voir le fichier

@@ -302,5 +302,5 @@ public interface TaRecommendCustomerMapper extends BaseMapper<TaRecommendCustome
302 302
      * @param buildingId
303 303
      * @return
304 304
      */
305
-    Map<String, Number> checkCustomerBy(@Param("orgId") Integer orgId, @Param("personId") String personId, @Param("consultBuildingIds") List<String> consultBuildingIds, @Param("buildingId") String buildingId, @Param("consultPersonId")String consultPersonId, @Param("userId")Integer userId);
305
+    Map<String, Number> checkCustomerBy(@Param("orgId") Integer orgId, @Param("personId") String personId, @Param("consultBuildingIds") List<String> consultBuildingIds, @Param("buildingId") String buildingId);
306 306
 }

+ 1
- 1
src/main/java/com/huiju/estateagents/service/ITaQrcodeService.java Voir le fichier

@@ -24,7 +24,7 @@ import java.util.List;
24 24
 public interface ITaQrcodeService extends IService<TaQrcode> {
25 25
 
26 26
     ResponseBean listQrCodeByCondition(Integer pageNum, Integer pageSize, String targetType, String targetName, Integer channelId,
27
-                                       String buildingId, Integer orgId, List<TaPersonBuilding> personBuildingList);
27
+                                       String buildingId, Integer userId, Integer orgId, List<TaPersonBuilding> personBuildingList);
28 28
 
29 29
     ResponseBean saveQrcode(TaQrcode taQrcode, Integer userId, Integer orgId);
30 30
 

+ 13
- 2
src/main/java/com/huiju/estateagents/service/impl/TaQrcodeServiceImpl.java Voir le fichier

@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
7 7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
8 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9 9
 import com.huiju.estateagents.base.ResponseBean;
10
+import com.huiju.estateagents.center.taUser.entity.TaUser;
11
+import com.huiju.estateagents.center.taUser.service.impl.TaUserServiceImpl;
10 12
 import com.huiju.estateagents.common.CommConstant;
11 13
 import com.huiju.estateagents.common.WxQrCodeUtils;
12 14
 import com.huiju.estateagents.entity.TaMiniapp;
@@ -55,6 +57,9 @@ public class TaQrcodeServiceImpl extends ServiceImpl<TaQrcodeMapper, TaQrcode> i
55 57
     @Autowired
56 58
     private IMiniAppService iMiniAppService;
57 59
 
60
+    @Autowired
61
+    private TaUserServiceImpl taUserService;
62
+
58 63
     /**
59 64
      * 条件查询二维码列表
60 65
      *
@@ -69,10 +74,16 @@ public class TaQrcodeServiceImpl extends ServiceImpl<TaQrcodeMapper, TaQrcode> i
69 74
      */
70 75
     @Override
71 76
     public ResponseBean listQrCodeByCondition(Integer pageNum, Integer pageSize, String targetType, String targetName, Integer channelId,
72
-                                              String buildingId, Integer orgId, List<TaPersonBuilding> personBuildingList) {
77
+                                              String buildingId, Integer userId, Integer orgId, List<TaPersonBuilding> personBuildingList) {
73 78
         ResponseBean responseBean = new ResponseBean();
79
+
80
+        TaUser taUser = taUserService.getById(userId);
81
+        if (taUser != null && taUser.getIsAdmin()) {
82
+            userId = null;
83
+        }
84
+
74 85
         IPage<TaQrcode> pg = new Page<>(pageNum, pageSize);
75
-        responseBean.addSuccess(taQrcodeMapper.listQrCodeByCondition(pg, targetType, targetName, channelId, buildingId, orgId, personBuildingList));
86
+        responseBean.addSuccess(taQrcodeMapper.listQrCodeByCondition(pg, targetType, targetName, channelId, buildingId, userId, orgId, personBuildingList));
76 87
         return responseBean;
77 88
     }
78 89
 

+ 63
- 41
src/main/java/com/huiju/estateagents/service/impl/TaRecommendCustomerServiceImpl.java Voir le fichier

@@ -193,21 +193,27 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
193 193
         from.setPersonName(StringUtils.ifNull(person.getName(), person.getNickname()));
194 194
         from.setCreateDate(now);
195 195
 
196
-        Map<String, Number> checkNum = taRecommendCustomerMapper.checkCustomerBy(orgId, person.getPersonId(), consultBuildingIds, null != building ? building.getBuildingId() : null, consultant != null ? consultant.getPersonId() : null, consultant != null ? consultant.getUserId() : null);
196
+        Map<String, Number> checkNum = taRecommendCustomerMapper.checkCustomerBy(orgId, person.getPersonId(), consultBuildingIds, null != building ? building.getBuildingId() : null);
197
+        // 是否存在小程序客户记录
197 198
         boolean hasOrgCust = checkNum.get("orgNum").intValue() > 0;
198
-        boolean hasConsultBingBuildCust = checkNum.get("consultBindBuildingNum").intValue() > 0;
199
+        // 是否存在置业绑定的楼盘客户记录
200
+        boolean hasConsultBuildingCust = checkNum.get("consultBuildingNum").intValue() > 0;
201
+        // 是否存在置业绑定的楼盘私客记录
202
+        boolean hasConsultCust = checkNum.get("consultNum").intValue() > 0;
203
+        // 是否存在当前内容楼盘的客户记录
199 204
         boolean hasBuildingCust = checkNum.get("buildingNum").intValue() > 0;
200
-        boolean hasConstCust = checkNum.get("consultNum") == null ? true : checkNum.get("consultNum").intValue() > 0;
201 205
 
202
-        // 控制是否需要插入小程序级别公客
203
-        boolean inserted = false;
204
-        // 置业与楼盘是否有关联关系
206
+        // 置业与内容楼盘是否有关联关系
205 207
         boolean builingAssociated = false;
206 208
 
207
-        boolean personTypeFlag = CommConstant.PERSON_REALTY_CONSULTANT.equals(person.getPersonType()) ? true : false;
209
+        // 职业顾问不插入客户表
210
+        boolean personIsConsultant = CommConstant.PERSON_REALTY_CONSULTANT.equals(person.getPersonType()) ? true : false;
211
+        if (personIsConsultant) {
212
+            return result;
213
+        }
208 214
 
209
-        // 私客
210
-        if (null != consultant && hasConsultBingBuildCust && null != consultBuildings && !hasConstCust) {
215
+        // 置业项目
216
+        if (null != consultant && null != consultBuildings && !hasConsultCust) {
211 217
             TaBuilding taBuilding = null;
212 218
             if (consultBuildingIds.contains(null != building ? building.getBuildingId() : null)) {
213 219
                 taBuilding = building;
@@ -216,46 +222,62 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
216 222
                 taBuilding = consultBuildings.get(0);
217 223
             }
218 224
 
219
-            //如果公客绑定的项目和分享活动关联的项目相同,从公客列表移除该人员
220
-            QueryWrapper<TaRecommendCustomer> taRecommendCustomerQueryWrapper = new QueryWrapper<>();
221
-            taRecommendCustomerQueryWrapper.eq("building_id", taBuilding.getBuildingId());
222
-            taRecommendCustomerQueryWrapper.isNull("realty_consultant");
223
-            List<TaRecommendCustomer> taRecommendCustomers = taRecommendCustomerMapper.selectList(taRecommendCustomerQueryWrapper);
224
-            for (TaRecommendCustomer customer : taRecommendCustomers){
225
-                if (customer.getBuildingId().equals(taBuilding.getBuildingId()) && person.getPersonId().equals(customer.getPersonId())){
226
-                    delPubCust(customer.getPersonId(), customer.getBuildingId());
225
+            if (hasConsultBuildingCust) {
226
+                // 如果是项目公客
227
+                QueryWrapper<TaRecommendCustomer> taRecommendCustomerQueryWrapper = new QueryWrapper<>();
228
+                taRecommendCustomerQueryWrapper.eq("building_id", taBuilding.getBuildingId());
229
+                taRecommendCustomerQueryWrapper.gt("status", CommConstant.STATUS_DELETE);
230
+                taRecommendCustomerQueryWrapper.orderByAsc("create_date");
231
+                taRecommendCustomerQueryWrapper.last("limit 1");
232
+                TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.selectOne(taRecommendCustomerQueryWrapper);
233
+
234
+                taRecommendCustomer = copyFromPerosn(person, taRecommendCustomer);
235
+                taRecommendCustomer.setRealtyConsultant(consultant.getUserId().toString());
236
+                taRecommendCustomerMapper.updateById(taRecommendCustomer);
237
+                result.add(taRecommendCustomer);
238
+            } else {
239
+                // 如果没有任何置业及置业楼盘相关的数据, 则插入新记录
240
+                TaRecommendCustomer customer = copyFromPerosn(person, new TaRecommendCustomer());
241
+                fillSomeFieldsOfCustomer(customer, recommender, now);
242
+                customer.setBuildingId(taBuilding.getBuildingId());
243
+                customer.setBuildingName(taBuilding.getBuildingName());
244
+                customer.setRealtyConsultant(consultant.getUserId().toString());
245
+                taRecommendCustomerMapper.insert(customer);
246
+                result.add(customer);
247
+
248
+                // 如果非小程序公客, 即首次进入
249
+                if (!hasOrgCust) {
250
+                    // 如果分享内容的楼盘跟置业楼盘一致
251
+                    if (builingAssociated) {
252
+                        hasOrgCust = true;
253
+                    }
227 254
                 }
228
-            }
229
-
230
-            TaRecommendCustomer customer = copyFromPerosn(person, new TaRecommendCustomer());
231
-            fillSomeFieldsOfCustomer(customer, recommender, now);
232
-            customer.setBuildingId(taBuilding.getBuildingId());
233
-            customer.setBuildingName(taBuilding.getBuildingName());
234
-            customer.setRealtyConsultant(consultant.getUserId().toString());
235
-            taRecommendCustomerMapper.insert(customer);
236
-            result.add(customer);
237
-            inserted = true;
238 255
 
239
-            TaCustomerFrom customerFrom = copyPropertiesFrom(from);
240
-            customerFrom.setCustomerId(customer.getCustomerId());
241
-            customerFrom.setSharePersonId(recommender.getPersonId());
242
-            customerFrom.setSharePersonName(StringUtils.ifNull(recommender.getName(), recommender.getNickname()));
243
-            customerFrom.setBuildingId(taBuilding.getBuildingId());
244
-            customerFrom.setBuildingName(taBuilding.getBuildingName());
245
-            customerFrom.setIsOrgFirst(!hasOrgCust);
246
-            customerFrom.setIsProjectFirst(true);
247
-            customerFrom.setCreateDate(now);
248
-            taCustomerFromMapper.insert(customerFrom);
256
+                TaCustomerFrom customerFrom = copyPropertiesFrom(from);
257
+                customerFrom.setCustomerId(customer.getCustomerId());
258
+                customerFrom.setSharePersonId(recommender.getPersonId());
259
+                customerFrom.setSharePersonName(StringUtils.ifNull(recommender.getName(), recommender.getNickname()));
260
+                customerFrom.setBuildingId(taBuilding.getBuildingId());
261
+                customerFrom.setBuildingName(taBuilding.getBuildingName());
262
+                customerFrom.setIsOrgFirst(hasOrgCust);
263
+                customerFrom.setIsProjectFirst(true);
264
+                customerFrom.setCreateDate(now);
265
+                taCustomerFromMapper.insert(customerFrom);
266
+            }
249 267
         }
250 268
 
251 269
         // 项目公客
252
-        if (null != building && !hasBuildingCust && !builingAssociated && !personTypeFlag) {
270
+        if (null != building && !hasBuildingCust && !builingAssociated) {
253 271
             TaRecommendCustomer customer = copyFromPerosn(person, new TaRecommendCustomer());
254 272
             fillSomeFieldsOfCustomer(customer, recommender, now);
255 273
             customer.setBuildingId(building.getBuildingId());
256 274
             taRecommendCustomerMapper.insert(customer);
257 275
             result.add(customer);
258
-            inserted = true;
276
+
277
+            // 如果非小程序公客, 即首次进入
278
+            if (!hasOrgCust) {
279
+                hasOrgCust = true;
280
+            }
259 281
 
260 282
             TaCustomerFrom customerFrom = copyPropertiesFrom(from);
261 283
             customerFrom.setCustomerId(customer.getCustomerId());
@@ -263,14 +285,14 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
263 285
             customerFrom.setSharePersonName(null == recommender ? null : StringUtils.ifNull(recommender.getName(), recommender.getNickname()));
264 286
             customerFrom.setBuildingId(building.getBuildingId());
265 287
             customerFrom.setBuildingName(building.getBuildingName());
266
-            customerFrom.setIsOrgFirst(!hasOrgCust);
288
+            customerFrom.setIsOrgFirst(hasOrgCust);
267 289
             customerFrom.setIsProjectFirst(true);
268 290
             customerFrom.setCreateDate(now);
269 291
             taCustomerFromMapper.insert(customerFrom);
270 292
         }
271 293
 
272 294
         // 小程序公客
273
-        if (!hasOrgCust && !inserted && !personTypeFlag) {
295
+        if (!hasOrgCust) {
274 296
             TaRecommendCustomer customer = copyFromPerosn(person, new TaRecommendCustomer());
275 297
             fillSomeFieldsOfCustomer(customer, recommender, now);
276 298
             taRecommendCustomerMapper.insert(customer);

+ 5
- 0
src/main/resources/mapper/TaQrcodeMapper.xml Voir le fichier

@@ -26,6 +26,9 @@
26 26
         <if test = "channelId != null">
27 27
             AND t.channel_id = #{channelId}
28 28
         </if>
29
+        <if test = "userId != null">
30
+            AND t.create_user = #{userId}
31
+        </if>
29 32
         <if test="personBuildingList != null and personBuildingList.size > 0">
30 33
             AND (t.building_id in
31 34
             <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
@@ -158,6 +161,7 @@
158 161
             LEFT JOIN td_city t3 ON t2.city = t3.id
159 162
         WHERE
160 163
             t.org_id = #{orgId}
164
+            AND t.is_org_first =1
161 165
             AND t.qr_code_id = #{qrCodeId}
162 166
         GROUP BY
163 167
 	        t.customer_id
@@ -178,6 +182,7 @@
178 182
             LEFT JOIN td_city t3 ON t2.city = t3.id
179 183
         WHERE
180 184
             t.org_id = #{orgId}
185
+            AND t.is_org_first =1
181 186
             AND t.qr_code_id = #{qrCodeId}
182 187
         GROUP BY
183 188
 	        t.customer_id

+ 13
- 4
src/main/resources/mapper/TaRecommendCustomerMapper.xml Voir le fichier

@@ -951,17 +951,26 @@
951 951
                 COALESCE(sum( IF ( t.building_id IN ('****')
952 952
             </otherwise>
953 953
         </choose>
954
-            , 1, 0 ) ), 0) AS consultBindBuildingNum,
954
+            , 1, 0 ) ), 0) AS consultBuildingNum,
955
+
956
+        <choose>
957
+            <when test="consultBuildingIds != null and consultBuildingIds.size > 0">
958
+                COALESCE(sum( IF ( t.building_id IN <foreach collection="consultBuildingIds" item="id" open="(" close=")" separator=",">#{id}</foreach>
959
+            </when>
960
+            <otherwise>
961
+                COALESCE(sum( IF ( t.building_id IN ('****')
962
+            </otherwise>
963
+        </choose>
964
+
965
+              AND IFNULL(t.realty_consultant, '') != ''), 1, 0 ) ), 0) AS consultNum,
955 966
 
956 967
             COALESCE(sum( IF ( t.building_id = #{buildingId}, 1, 0 ) ), 0) AS buildingNum
957
-        <if test="userId != null and userId != ''">
958
-            ,COALESCE(sum( IF ( t.realty_consultant in (#{consultPersonId}, #{userId}), 1, 0 ) ), 0) AS consultNum
959
-        </if>
960 968
 
961 969
         FROM
962 970
             ta_recommend_customer t
963 971
         WHERE
964 972
             t.org_id = #{orgId}
965 973
             AND t.person_id = #{personId}
974
+            AND t.status > -1
966 975
     </select>
967 976
 </mapper>