Browse Source

Merge branch 'dev'

# Conflicts:
#	src/main/resources/mapper/TaRecommendCustomerMapper.xml
傅行帆 5 years ago
parent
commit
f042c23597
24 changed files with 3535 additions and 3336 deletions
  1. 5
    0
      src/main/java/com/huiju/estateagents/bo/request/ActivityStatisticResponseBO.java
  2. 558
    544
      src/main/java/com/huiju/estateagents/center/taUser/controller/TaUserController.java
  3. 244
    238
      src/main/java/com/huiju/estateagents/center/taUser/entity/TaUser.java
  4. 4
    4
      src/main/java/com/huiju/estateagents/center/taUser/service/impl/TaUserServiceImpl.java
  5. 263
    249
      src/main/java/com/huiju/estateagents/controller/TaChannelController.java
  6. 29
    20
      src/main/java/com/huiju/estateagents/controller/TaPersonController.java
  7. 11
    9
      src/main/java/com/huiju/estateagents/controller/TaRecommendCustomerController.java
  8. 4
    4
      src/main/java/com/huiju/estateagents/entity/TaPerson.java
  9. 2
    0
      src/main/java/com/huiju/estateagents/entity/TaRecommendCustomer.java
  10. 42
    40
      src/main/java/com/huiju/estateagents/mapper/TaChannelMapper.java
  11. 2
    0
      src/main/java/com/huiju/estateagents/mapper/TaPersonMapper.java
  12. 14
    2
      src/main/java/com/huiju/estateagents/mapper/TaRecommendCustomerMapper.java
  13. 2
    0
      src/main/java/com/huiju/estateagents/mapper/TsConsultantKpiMapper.java
  14. 3
    3
      src/main/java/com/huiju/estateagents/service/ITaRecommendCustomerService.java
  15. 138
    110
      src/main/java/com/huiju/estateagents/service/impl/TaPersonServiceImpl.java
  16. 90
    21
      src/main/java/com/huiju/estateagents/service/impl/TaRecommendCustomerServiceImpl.java
  17. 14
    8
      src/main/resources/mapper/ActivityManageMapper.xml
  18. 748
    748
      src/main/resources/mapper/TaBuildingMapper.xml
  19. 21
    3
      src/main/resources/mapper/TaChannelMapper.xml
  20. 728
    722
      src/main/resources/mapper/TaPersonMapper.xml
  21. 446
    446
      src/main/resources/mapper/TaPersonVisitRecordMapper.xml
  22. 158
    158
      src/main/resources/mapper/TaUserMapper.xml
  23. 5
    4
      src/main/resources/mapper/TsConsultantKpiMapper.xml
  24. 4
    3
      src/main/resources/mapper/statistic/TaActivityStaticMapper.xml

+ 5
- 0
src/main/java/com/huiju/estateagents/bo/request/ActivityStatisticResponseBO.java View File

@@ -41,4 +41,9 @@ public class ActivityStatisticResponseBO {
41 41
      */
42 42
     private Integer newCustomers;
43 43
 
44
+    /**
45
+     * 活动名称
46
+     */
47
+    private String activityName;
48
+
44 49
 }

+ 558
- 544
src/main/java/com/huiju/estateagents/center/taUser/controller/TaUserController.java
File diff suppressed because it is too large
View File


+ 244
- 238
src/main/java/com/huiju/estateagents/center/taUser/entity/TaUser.java View File

@@ -1,238 +1,244 @@
1
-package com.huiju.estateagents.center.taUser.entity;
2
-
3
-import com.baomidou.mybatisplus.annotation.FieldStrategy;
4
-import com.baomidou.mybatisplus.annotation.IdType;
5
-import com.baomidou.mybatisplus.annotation.TableField;
6
-import com.baomidou.mybatisplus.annotation.TableId;
7
-import com.huiju.estateagents.entity.*;
8
-import lombok.Data;
9
-import lombok.EqualsAndHashCode;
10
-import lombok.experimental.Accessors;
11
-
12
-import java.io.Serializable;
13
-import java.time.LocalDateTime;
14
-import java.util.ArrayList;
15
-import java.util.List;
16
-
17
-/**
18
- * <p>
19
- * 用户表 
20
- * </p>
21
- *
22
- * @author jobob
23
- * @since 2019-09-11
24
- */
25
-@Data
26
-@EqualsAndHashCode(callSuper = false)
27
-@Accessors(chain = true)
28
-public class TaUser implements Serializable {
29
-
30
-    private static final long serialVersionUID = 1L;
31
-
32
-    /**
33
-     * 用户ID
34
-     */
35
-    @TableId(value = "user_id", type = IdType.AUTO)
36
-    private Integer userId;
37
-
38
-    /**
39
-     * 公司id
40
-     */
41
-    private Integer orgId;
42
-
43
-    /**
44
-     * 用户名称
45
-     */
46
-    private String userName;
47
-
48
-    /**
49
-     * 登录账户
50
-     */
51
-    private String loginName;
52
-
53
-    /**
54
-     * 手机号
55
-     */
56
-    private String phone;
57
-
58
-    /**
59
-     * 登录密码
60
-     */
61
-    private String loginPassword;
62
-
63
-    /**
64
-     * 用户头像
65
-     */
66
-    private String avatar;
67
-
68
-    /**
69
-     * 用户状态
70
-     */
71
-    private Integer status;
72
-
73
-    /**
74
-     * 创建时间
75
-     */
76
-    private LocalDateTime createDate;
77
-
78
-    /**
79
-     * 账户过期时间
80
-     */
81
-    private LocalDateTime expDate;
82
-
83
-    /**
84
-     * 是否管理员
85
-     */
86
-    private Boolean isAdmin;
87
-
88
-    /**
89
-     * 公司名称
90
-     */
91
-    private String orgName;
92
-
93
-    /**
94
-     * 部门
95
-     */
96
-    private String department;
97
-
98
-    /**
99
-     * 职位
100
-     */
101
-    private String position;
102
-
103
-    /**
104
-     * 邮箱
105
-     */
106
-    private String email;
107
-
108
-    /**
109
-     * 身份证号
110
-     */
111
-    private String idNo;
112
-    
113
-    private String address;
114
-    private String photo;
115
-    private String description;
116
-
117
-    /**
118
-     * 权重
119
-     */
120
-    @TableField(strategy= FieldStrategy.IGNORED)
121
-    private String weight;
122
-
123
-    /**
124
-     * 是否置业顾问
125
-     */
126
-    private Boolean isConsultant;
127
-
128
-    /**
129
-     * 公司水印
130
-     */
131
-    @TableField(exist = false)
132
-    private String waterMark;
133
-
134
-    /**
135
-     * 关联小程序
136
-     */
137
-    @TableField(exist = false)
138
-    private TaMiniapp miniapp;
139
-
140
-    /**
141
-     * 授权角色列表
142
-     */
143
-    @TableField(exist = false)
144
-    private List<TaRole> roles;
145
-
146
-    /**
147
-     * 授权菜单列表
148
-     */
149
-    @TableField(exist = false)
150
-    private List<SysMenu> menus;
151
-
152
-    /**
153
-     * 授权按钮列表
154
-     */
155
-    @TableField(exist = false)
156
-    private List<SysButtonInMenu> buttons;
157
-    
158
-    @TableField(exist = false)
159
-    private List<TaTags> taTagsList = new ArrayList<TaTags>();
160
-    
161
-    @TableField(exist = false)
162
-    private List<Integer> taTags = new ArrayList<Integer>();
163
-    
164
-    @TableField(exist = false)
165
-    private List<Integer> roleIds = new ArrayList<Integer>();
166
-    
167
-    @TableField(exist = false)
168
-    private String buildingId;
169
-
170
-    @TableField(exist = false)
171
-    private List<String> projects;
172
-
173
-    /**
174
-     * ta_org/orgNum楼盘最大数
175
-     */
176
-  @TableField(exist = false)
177
-    private int orgNum;
178
-
179
-    // 所有省份城市
180
-    @TableField(exist = false)
181
-    List<TdCity> tdCityList;
182
-
183
-    /**
184
-     * 前台传值城市
185
-     */
186
-    @TableField(exist = false)
187
-    private ArrayList<String> selectCityTree;
188
-
189
-    /**
190
-     * 城市ID
191
-     */
192
-    @TableField(exist = false)
193
-    private Integer cityId;
194
-
195
-    /**
196
-     * 默认城市
197
-     */
198
-    @TableField(exist = false)
199
-    private Integer defaultCityId;
200
-
201
-    /**
202
-     * 小程序绑定状态
203
-     *
204
-     * 0 未绑定 1 绑定
205
-     */
206
-    @TableField(exist = false)
207
-    private Integer miniStatus;
208
-
209
-    @TableField(exist = false)
210
-    private List<String> buildingIds = new ArrayList<String>();
211
-
212
-    /**
213
-     * 新密码
214
-     */
215
-    @TableField(exist = false)
216
-    private String newPassword;
217
-
218
-    /**
219
-     * 确认新密码
220
-     */
221
-    @TableField(exist = false)
222
-    private String confirmPassword;
223
-
224
-    /**
225
-     * 置业顾问的personid
226
-     */
227
-    @TableField(exist = false)
228
-    private String consultantPersonId;
229
-
230
-    /**
231
-     * personId集合
232
-     */
233
-    @TableField(exist = false)
234
-    private List<TaPerson> personIds;
235
-
236
-    @TableField(exist = false)
237
-    private String miniAppName;
238
-}
1
+package com.huiju.estateagents.center.taUser.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
4
+import com.baomidou.mybatisplus.annotation.IdType;
5
+import com.baomidou.mybatisplus.annotation.TableField;
6
+import com.baomidou.mybatisplus.annotation.TableId;
7
+import com.huiju.estateagents.entity.*;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.io.Serializable;
13
+import java.time.LocalDateTime;
14
+import java.util.ArrayList;
15
+import java.util.List;
16
+
17
+/**
18
+ * <p>
19
+ * 用户表 
20
+ * </p>
21
+ *
22
+ * @author jobob
23
+ * @since 2019-09-11
24
+ */
25
+@Data
26
+@EqualsAndHashCode(callSuper = false)
27
+@Accessors(chain = true)
28
+public class TaUser implements Serializable {
29
+
30
+    private static final long serialVersionUID = 1L;
31
+
32
+    /**
33
+     * 用户ID
34
+     */
35
+    @TableId(value = "user_id", type = IdType.AUTO)
36
+    private Integer userId;
37
+
38
+    /**
39
+     * 公司id
40
+     */
41
+    private Integer orgId;
42
+
43
+    /**
44
+     * 用户名称
45
+     */
46
+    private String userName;
47
+
48
+    /**
49
+     * 登录账户
50
+     */
51
+    private String loginName;
52
+
53
+    /**
54
+     * 手机号
55
+     */
56
+    private String phone;
57
+
58
+    /**
59
+     * 登录密码
60
+     */
61
+    private String loginPassword;
62
+
63
+    /**
64
+     * 用户头像
65
+     */
66
+    private String avatar;
67
+
68
+    /**
69
+     * 用户状态
70
+     */
71
+    private Integer status;
72
+
73
+    /**
74
+     * 创建时间
75
+     */
76
+    private LocalDateTime createDate;
77
+
78
+    /**
79
+     * 账户过期时间
80
+     */
81
+    private LocalDateTime expDate;
82
+
83
+    /**
84
+     * 是否管理员
85
+     */
86
+    private Boolean isAdmin;
87
+
88
+    /**
89
+     * 公司名称
90
+     */
91
+    private String orgName;
92
+
93
+    /**
94
+     * 部门
95
+     */
96
+    private String department;
97
+
98
+    /**
99
+     * 职位
100
+     */
101
+    private String position;
102
+
103
+    /**
104
+     * 邮箱
105
+     */
106
+    private String email;
107
+
108
+    /**
109
+     * 身份证号
110
+     */
111
+    private String idNo;
112
+    
113
+    private String address;
114
+    private String photo;
115
+    private String description;
116
+
117
+    /**
118
+     * 权重
119
+     */
120
+    @TableField(strategy= FieldStrategy.IGNORED)
121
+    private String weight;
122
+
123
+    /**
124
+     * 是否置业顾问
125
+     */
126
+    private Boolean isConsultant;
127
+
128
+    /**
129
+     * 公司水印
130
+     */
131
+    @TableField(exist = false)
132
+    private String waterMark;
133
+
134
+    /**
135
+     * 关联小程序
136
+     */
137
+    @TableField(exist = false)
138
+    private TaMiniapp miniapp;
139
+
140
+    /**
141
+     * 授权角色列表
142
+     */
143
+    @TableField(exist = false)
144
+    private List<TaRole> roles;
145
+
146
+    /**
147
+     * 授权菜单列表
148
+     */
149
+    @TableField(exist = false)
150
+    private List<SysMenu> menus;
151
+
152
+    /**
153
+     * 授权按钮列表
154
+     */
155
+    @TableField(exist = false)
156
+    private List<SysButtonInMenu> buttons;
157
+    
158
+    @TableField(exist = false)
159
+    private List<TaTags> taTagsList = new ArrayList<TaTags>();
160
+    
161
+    @TableField(exist = false)
162
+    private List<Integer> taTags = new ArrayList<Integer>();
163
+    
164
+    @TableField(exist = false)
165
+    private List<Integer> roleIds = new ArrayList<Integer>();
166
+    
167
+    @TableField(exist = false)
168
+    private String buildingId;
169
+
170
+    @TableField(exist = false)
171
+    private List<String> projects;
172
+
173
+    /**
174
+     * ta_org/orgNum楼盘最大数
175
+     */
176
+  @TableField(exist = false)
177
+    private int orgNum;
178
+
179
+    // 所有省份城市
180
+    @TableField(exist = false)
181
+    List<TdCity> tdCityList;
182
+
183
+    /**
184
+     * 前台传值城市
185
+     */
186
+    @TableField(exist = false)
187
+    private ArrayList<String> selectCityTree;
188
+
189
+    /**
190
+     * 城市ID
191
+     */
192
+    @TableField(exist = false)
193
+    private Integer cityId;
194
+
195
+    /**
196
+     * 默认城市
197
+     */
198
+    @TableField(exist = false)
199
+    private Integer defaultCityId;
200
+
201
+    /**
202
+     * 小程序绑定状态
203
+     *
204
+     * 0 未绑定 1 绑定
205
+     */
206
+    @TableField(exist = false)
207
+    private Integer miniStatus;
208
+
209
+    @TableField(exist = false)
210
+    private List<String> buildingIds = new ArrayList<String>();
211
+
212
+    /**
213
+     * 新密码
214
+     */
215
+    @TableField(exist = false)
216
+    private String newPassword;
217
+
218
+    /**
219
+     * 确认新密码
220
+     */
221
+    @TableField(exist = false)
222
+    private String confirmPassword;
223
+
224
+    /**
225
+     * 置业顾问的personid
226
+     */
227
+    @TableField(exist = false)
228
+    private String consultantPersonId;
229
+
230
+    /**
231
+     * personId集合
232
+     */
233
+    @TableField(exist = false)
234
+    private List<TaPerson> personIds;
235
+
236
+    /**
237
+     * customerId集合
238
+     */
239
+    @TableField(exist = false)
240
+    private List<TaRecommendCustomer> customerIds;
241
+
242
+    @TableField(exist = false)
243
+    private String miniAppName;
244
+}

+ 4
- 4
src/main/java/com/huiju/estateagents/center/taUser/service/impl/TaUserServiceImpl.java View File

@@ -357,16 +357,15 @@ public class TaUserServiceImpl extends ServiceImpl<TaUserMapper, TaUser> impleme
357 357
         if (!isOn){
358 358
             //查看是否置业顾问
359 359
             if (taUser.getIsConsultant()){
360
-                taUser.setIsConsultant(false);
361
-                taUserMapper.updateById(taUser);
360
+//                taUser.setIsConsultant(false);
361
+//                taUserMapper.updateById(taUser);
362 362
                 //小程序端调整为普通客户
363 363
                 QueryWrapper<TaPerson> taPersonQueryWrapper = new QueryWrapper<>();
364 364
                 taPersonQueryWrapper.eq("user_id",id);
365 365
                 taPersonQueryWrapper.eq("org_id",taUser.getOrgId());
366 366
                 TaPerson taPerson = taPersonMapper.selectOne(taPersonQueryWrapper);
367 367
                 if (null != taPerson){
368
-                    taPerson.setPersonType(CommConstant.PERSON_ESTATE_CUSTOMER);
369
-                    taPersonMapper.updateById(taPerson);
368
+                    taPersonMapper.cancelConsulatant(taPerson.getPersonId());
370 369
                 }
371 370
             }
372 371
         }
@@ -374,6 +373,7 @@ public class TaUserServiceImpl extends ServiceImpl<TaUserMapper, TaUser> impleme
374 373
         Integer status = isOn ? CommConstant.STATUS_NORMAL : CommConstant.STATUS_CLOSED;
375 374
         TaUser user = new TaUser();
376 375
         user.setStatus(status);
376
+        user.setWeight(taUser.getWeight());
377 377
 
378 378
         QueryWrapper<TaUser> taUserQueryWrapper = new QueryWrapper<>();
379 379
         if (CommConstant.LOGIN_TYPE_ADMIN.equals(plat)) {

+ 263
- 249
src/main/java/com/huiju/estateagents/controller/TaChannelController.java View File

@@ -1,249 +1,263 @@
1
-package com.huiju.estateagents.controller;
2
-
3
-import com.alibaba.fastjson.JSONObject;
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;
7
-import com.huiju.estateagents.base.BaseController;
8
-import com.huiju.estateagents.base.ResponseBean;
9
-import io.swagger.annotations.ApiOperation;
10
-import com.huiju.estateagents.common.JWTUtils;
11
-import com.huiju.estateagents.common.StringUtils;
12
-import com.huiju.estateagents.entity.TaChannel;
13
-import com.huiju.estateagents.entity.TaPerson;
14
-import com.huiju.estateagents.mapper.TaChannelMapper;
15
-import com.huiju.estateagents.service.ITaPersonService;
16
-import com.huiju.estateagents.service.TaChannelService;
17
-import io.swagger.annotations.Api;
18
-import io.swagger.annotations.ApiImplicitParam;
19
-import io.swagger.annotations.ApiImplicitParams;
20
-import org.apache.http.HttpRequest;
21
-import org.slf4j.Logger;
22
-import org.slf4j.LoggerFactory;
23
-import org.springframework.beans.factory.annotation.Autowired;
24
-import org.springframework.web.bind.annotation.PathVariable;
25
-import org.springframework.web.bind.annotation.RequestBody;
26
-import org.springframework.web.bind.annotation.RequestMapping;
27
-import org.springframework.web.bind.annotation.RequestMethod;
28
-import org.springframework.web.bind.annotation.RequestParam;
29
-import org.springframework.web.bind.annotation.ResponseBody;
30
-import org.springframework.web.bind.annotation.RestController;
31
-
32
-import javax.servlet.http.HttpServletRequest;
33
-import java.util.HashMap;
34
-import java.util.List;
35
-
36
-
37
-/**
38
- * <p>
39
-    *   前端控制器
40
-    * </p>
41
- *
42
- * @author jobob
43
- * @since 2019-09-17
44
- */
45
-@RestController
46
-@RequestMapping("/api")
47
-@Api(value = "渠道管理", tags = "渠道管理")
48
-public class TaChannelController extends BaseController {
49
-
50
-    private final Logger logger = LoggerFactory.getLogger(TaChannelController.class);
51
-
52
-    @Autowired
53
-    public TaChannelService taChannelService;
54
-
55
-    @Autowired
56
-    public ITaPersonService taPersonService;
57
-
58
-    @Autowired
59
-    public TaChannelMapper taChannelMapper;
60
-
61
-
62
-    /**
63
-     * 渠道管理列表
64
-     * @param pageNum
65
-     * @param pageSize
66
-     * @return
67
-     */
68
-    @ApiOperation(value = "渠道管理列表", notes = "渠道管理列表")
69
-    @ApiImplicitParams({
70
-            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageNum", paramType = "query",value = "第几页"),
71
-            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageSize", paramType = "query",value = "一页多少行"),
72
-            @ApiImplicitParam(dataTypeClass = String.class, name = "channelId", paramType = "query",value = "渠道Id"),
73
-    })
74
-    @RequestMapping(value="/admin/channel",method= RequestMethod.GET)
75
-    public ResponseBean channelList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
76
-                                    @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
77
-                                    @RequestParam(value ="channelId",required = false) Integer channelId,
78
-                                    HttpServletRequest request){
79
-        ResponseBean responseBean = new ResponseBean();
80
-        Integer orgId = getOrgId(request);
81
-        try {
82
-            //使用分页插件
83
-		    IPage<TaChannel> pg = new Page<>(pageNum, pageSize);
84
-            IPage<TaChannel> result = taChannelMapper.pageTaChannel(pg,orgId,channelId);
85
-            HashMap hashMap  = new HashMap<>();
86
-            hashMap.put("result",result);
87
-            // 下拉列表的数据 all
88
-            List<TaChannel> taChannelList = taChannelMapper.selectChannelList(orgId);
89
-            hashMap.put("channelNmae",taChannelList);
90
-            responseBean.addSuccess(hashMap);
91
-        }catch (Exception e){
92
-            e.printStackTrace();
93
-            logger.error("channelList -=- {}",e.toString());
94
-            responseBean.addError(e.getMessage());
95
-        }
96
-        return responseBean;
97
-    }
98
-
99
-    /**
100
-     * 渠道保存
101
-     * @param channel 实体对象
102
-     * @return
103
-     */
104
-    @ApiOperation(value = "渠道保存", notes = "渠道保存")
105
-    @ApiImplicitParams({
106
-            @ApiImplicitParam(dataTypeClass = TaChannel.class, name = "channel", paramType = "body",value = "当前对象"),
107
-    })
108
-    @RequestMapping(value="/admin/channel",method= RequestMethod.POST)
109
-    public ResponseBean channelAdd(@RequestBody TaChannel channel ,HttpServletRequest request){
110
-        Integer orgId = getOrgId(request);
111
-        ResponseBean responseBean = new ResponseBean();
112
-        try {
113
-            // 生成6位数的渠道码
114
-            int channelCode= taChannelMapper.channelCode();
115
-            channel.setChannelCode(String.valueOf(channelCode));
116
-            channel.setOrgId(orgId);
117
-            if (taChannelService.save(channel)){
118
-                responseBean.addSuccess(channel);
119
-            }else {
120
-                responseBean.addError("fail");
121
-            }
122
-        }catch (Exception e){
123
-            e.printStackTrace();
124
-            logger.error("channelAdd -=- {}",e.toString());
125
-            responseBean.addError(e.getMessage());
126
-        }
127
-        return responseBean;
128
-    }
129
-
130
-    /**
131
-     * 根据id删除对象
132
-     * @param id  实体ID
133
-     */
134
-    @ApiOperation(value = "根据渠道ID删除", notes = "根据渠道ID删除")
135
-    @ApiImplicitParams({
136
-            @ApiImplicitParam(dataTypeClass = Integer.class, name = "id", paramType = "query",value = "渠道id"),
137
-    })
138
-    @ResponseBody
139
-    @RequestMapping(value="/channel/{id}", method= RequestMethod.DELETE)
140
-    public ResponseBean channelDelete(@PathVariable Integer id){
141
-        ResponseBean responseBean = new ResponseBean();
142
-        try {
143
-            if(taChannelService.removeById(id)){
144
-                responseBean.addSuccess("success");
145
-            }else {
146
-                responseBean.addError("fail");
147
-            }
148
-        }catch (Exception e){
149
-            e.printStackTrace();
150
-            logger.error("channelDelete -=- {}",e.toString());
151
-            responseBean.addError(e.getMessage());
152
-        }
153
-        return responseBean;
154
-    }
155
-
156
-    /**
157
-     * 修改对象
158
-     * @param id  实体ID
159
-     * @param channel 实体对象
160
-     * @return
161
-     */
162
-    @ApiOperation(value = "根据渠道ID修改", notes = "根据渠道ID修改")
163
-    @ApiImplicitParams({
164
-            @ApiImplicitParam(dataTypeClass = Integer.class, name = "id", paramType = "query",value = "渠道id"),
165
-    })
166
-    @RequestMapping(value="/admin/channel/{id}",method= RequestMethod.PUT)
167
-    public ResponseBean channelUpdate(@PathVariable Integer id,
168
-                                        @RequestBody TaChannel channel){
169
-        ResponseBean responseBean = new ResponseBean();
170
-        try {
171
-            channel.setChannelId(id);
172
-            if (taChannelService.updateById(channel)){
173
-                responseBean.addSuccess(channel);
174
-            }else {
175
-                responseBean.addError("fail");
176
-            }
177
-        }catch (Exception e){
178
-            e.printStackTrace();
179
-            logger.error("channelUpdate -=- {}",e.toString());
180
-            responseBean.addError(e.getMessage());
181
-        }
182
-        return responseBean;
183
-    }
184
-
185
-    /**
186
-     * 根据id查询对象
187
-     * @param id  实体ID
188
-     */
189
-    @ApiOperation(value = "根据渠道ID查询", notes = "根据渠道ID查询")
190
-    @ApiImplicitParams({
191
-            @ApiImplicitParam(dataTypeClass = Integer.class, name = "id", paramType = "query",value = "渠道id"),
192
-    })
193
-    @RequestMapping(value="/admin/channel/{id}",method= RequestMethod.GET)
194
-    public ResponseBean channelGet(@PathVariable Integer id){
195
-        ResponseBean responseBean = new ResponseBean();
196
-        try {
197
-            responseBean.addSuccess(taChannelService.getById(id));
198
-        }catch (Exception e){
199
-            e.printStackTrace();
200
-            logger.error("channelDelete -=- {}",e.toString());
201
-            responseBean.addError(e.getMessage());
202
-        }
203
-        return responseBean;
204
-    }
205
-
206
-    /**
207
-     * 渠道管理下的经纪人
208
-     */
209
-    @ApiOperation(value = "渠道管理下的经纪人", notes = "渠道管理下的经纪人")
210
-    @ApiImplicitParams({
211
-            @ApiImplicitParam(dataTypeClass = String.class, name = "name", paramType = "query",value = "姓名"),
212
-            @ApiImplicitParam(dataTypeClass = String.class, name = "phone", paramType = "query",value = "电话"),
213
-            @ApiImplicitParam(dataTypeClass = Integer.class, name = "channelId", paramType = "query",value = "渠道id"),
214
-            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageNum", paramType = "query",value = "多少页"),
215
-            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageSize", paramType = "query",value = "每页多少条"),
216
-    })
217
-    @RequestMapping(value="/admin/channel/broker",method= RequestMethod.GET)
218
-    public  ResponseBean channelBrokerList(@RequestParam(value="name",required = false) String name,
219
-                                           @RequestParam(value="phone",required = false) String phone,
220
-                                           @RequestParam(value="channelId",required = false) Integer channelId,
221
-                                           @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
222
-                                           @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
223
-                                           HttpServletRequest request){
224
-        Integer orgid = getOrgId(request);
225
-        ResponseBean taPerson =  taPersonService.channelBrokerList(name,phone,pageNum,pageSize,orgid,channelId);
226
-        return taPerson;
227
-    }
228
-
229
-    /**
230
-     * 渠道邀请经纪人列表
231
-     */
232
-    @ApiOperation(value = "渠道邀请经纪人列表", notes = "渠道邀请经纪人列表")
233
-    @ApiImplicitParams({
234
-            @ApiImplicitParam(dataTypeClass = String.class, name = "id", paramType = "query",value = "姓名"),
235
-            @ApiImplicitParam(dataTypeClass = String.class, name = "phone", paramType = "query",value = "电话"),
236
-            @ApiImplicitParam(dataTypeClass = Integer.class, name = "channelId", paramType = "query",value = "渠道id"),
237
-            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageNum", paramType = "query",value = "多少页"),
238
-            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageSize", paramType = "query",value = "每页多少条"),
239
-    })
240
-    @RequestMapping(value="/admin/channel/InviteClientsList",method= RequestMethod.GET)
241
-    public  ResponseBean InviteClientsList(@RequestParam(value="id",required = false) String id,
242
-                                           @RequestParam(value="phone",required = false) String phone,
243
-                                           @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
244
-                                           @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
245
-                                           HttpServletRequest request){
246
-        ResponseBean taPerson =  taPersonService.InviteClientsList(id,phone,pageNum,pageSize);
247
-        return taPerson;
248
-    }
249
-}
1
+package com.huiju.estateagents.controller;
2
+
3
+import com.alibaba.fastjson.JSONObject;
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;
7
+import com.huiju.estateagents.base.BaseController;
8
+import com.huiju.estateagents.base.ResponseBean;
9
+import io.swagger.annotations.ApiOperation;
10
+import com.huiju.estateagents.common.JWTUtils;
11
+import com.huiju.estateagents.common.StringUtils;
12
+import com.huiju.estateagents.entity.TaBuildingReport;
13
+import com.huiju.estateagents.entity.TaChannel;
14
+import com.huiju.estateagents.entity.TaPerson;
15
+import com.huiju.estateagents.mapper.TaChannelMapper;
16
+import com.huiju.estateagents.service.ITaPersonService;
17
+import com.huiju.estateagents.service.TaChannelService;
18
+import io.swagger.annotations.Api;
19
+import io.swagger.annotations.ApiImplicitParam;
20
+import io.swagger.annotations.ApiImplicitParams;
21
+import org.apache.http.HttpRequest;
22
+import org.slf4j.Logger;
23
+import org.slf4j.LoggerFactory;
24
+import org.springframework.beans.factory.annotation.Autowired;
25
+import org.springframework.web.bind.annotation.PathVariable;
26
+import org.springframework.web.bind.annotation.RequestBody;
27
+import org.springframework.web.bind.annotation.RequestMapping;
28
+import org.springframework.web.bind.annotation.RequestMethod;
29
+import org.springframework.web.bind.annotation.RequestParam;
30
+import org.springframework.web.bind.annotation.ResponseBody;
31
+import org.springframework.web.bind.annotation.RestController;
32
+
33
+import javax.servlet.http.HttpServletRequest;
34
+
35
+import java.time.LocalDateTime;
36
+import java.util.HashMap;
37
+import java.util.List;
38
+import java.util.stream.Collectors;
39
+
40
+
41
+/**
42
+ * <p>
43
+    *   前端控制器
44
+    * </p>
45
+ *
46
+ * @author jobob
47
+ * @since 2019-09-17
48
+ */
49
+@RestController
50
+@RequestMapping("/api")
51
+@Api(value = "渠道管理", tags = "渠道管理")
52
+public class TaChannelController extends BaseController {
53
+
54
+    private final Logger logger = LoggerFactory.getLogger(TaChannelController.class);
55
+
56
+    @Autowired
57
+    public TaChannelService taChannelService;
58
+
59
+    @Autowired
60
+    public ITaPersonService taPersonService;
61
+
62
+    @Autowired
63
+    public TaChannelMapper taChannelMapper;
64
+
65
+
66
+    /**
67
+     * 渠道管理列表
68
+     * @param pageNum
69
+     * @param pageSize
70
+     * @return
71
+     */
72
+    @ApiOperation(value = "渠道管理列表", notes = "渠道管理列表")
73
+    @ApiImplicitParams({
74
+            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageNum", paramType = "query",value = "第几页"),
75
+            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageSize", paramType = "query",value = "一页多少行"),
76
+            @ApiImplicitParam(dataTypeClass = String.class, name = "channelId", paramType = "query",value = "渠道Id"),
77
+    })
78
+    @RequestMapping(value="/admin/channel",method= RequestMethod.GET)
79
+    public ResponseBean channelList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
80
+                                    @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
81
+                                    @RequestParam(value ="channelId",required = false) Integer channelId,
82
+                                    HttpServletRequest request){
83
+        ResponseBean responseBean = new ResponseBean();
84
+        Integer orgId = getOrgId(request);
85
+        try {
86
+            //使用分页插件
87
+		    IPage<TaChannel> pg = new Page<>(pageNum, pageSize);
88
+            IPage<TaChannel> result = taChannelMapper.pageTaChannel(pg,orgId,channelId);
89
+            List<TaChannel> recommendCount = taChannelMapper.recommendCount(orgId, channelId);
90
+
91
+            result.getRecords().stream().forEach(e -> {
92
+                for(TaChannel channel : recommendCount){
93
+                    if (channel.getChannelId().equals(e.getChannelId())){
94
+                        e.setRecommendCount(channel.getRecommendCount());
95
+                    }
96
+                }
97
+            });
98
+
99
+            HashMap hashMap  = new HashMap<>();
100
+            hashMap.put("result",result);
101
+            // 下拉列表的数据 all
102
+            List<TaChannel> taChannelList = taChannelMapper.selectChannelList(orgId);
103
+            hashMap.put("channelNmae",taChannelList);
104
+            responseBean.addSuccess(hashMap);
105
+        }catch (Exception e){
106
+            e.printStackTrace();
107
+            logger.error("channelList -=- {}",e.toString());
108
+            responseBean.addError(e.getMessage());
109
+        }
110
+        return responseBean;
111
+    }
112
+
113
+    /**
114
+     * 渠道保存
115
+     * @param channel 实体对象
116
+     * @return
117
+     */
118
+    @ApiOperation(value = "渠道保存", notes = "渠道保存")
119
+    @ApiImplicitParams({
120
+            @ApiImplicitParam(dataTypeClass = TaChannel.class, name = "channel", paramType = "body",value = "当前对象"),
121
+    })
122
+    @RequestMapping(value="/admin/channel",method= RequestMethod.POST)
123
+    public ResponseBean channelAdd(@RequestBody TaChannel channel ,HttpServletRequest request){
124
+        Integer orgId = getOrgId(request);
125
+        ResponseBean responseBean = new ResponseBean();
126
+        try {
127
+            // 生成6位数的渠道码
128
+            int channelCode= taChannelMapper.channelCode();
129
+            channel.setChannelCode(String.valueOf(channelCode));
130
+            channel.setOrgId(orgId);
131
+            if (taChannelService.save(channel)){
132
+                responseBean.addSuccess(channel);
133
+            }else {
134
+                responseBean.addError("fail");
135
+            }
136
+        }catch (Exception e){
137
+            e.printStackTrace();
138
+            logger.error("channelAdd -=- {}",e.toString());
139
+            responseBean.addError(e.getMessage());
140
+        }
141
+        return responseBean;
142
+    }
143
+
144
+    /**
145
+     * 根据id删除对象
146
+     * @param id  实体ID
147
+     */
148
+    @ApiOperation(value = "根据渠道ID删除", notes = "根据渠道ID删除")
149
+    @ApiImplicitParams({
150
+            @ApiImplicitParam(dataTypeClass = Integer.class, name = "id", paramType = "query",value = "渠道id"),
151
+    })
152
+    @ResponseBody
153
+    @RequestMapping(value="/channel/{id}", method= RequestMethod.DELETE)
154
+    public ResponseBean channelDelete(@PathVariable Integer id){
155
+        ResponseBean responseBean = new ResponseBean();
156
+        try {
157
+            if(taChannelService.removeById(id)){
158
+                responseBean.addSuccess("success");
159
+            }else {
160
+                responseBean.addError("fail");
161
+            }
162
+        }catch (Exception e){
163
+            e.printStackTrace();
164
+            logger.error("channelDelete -=- {}",e.toString());
165
+            responseBean.addError(e.getMessage());
166
+        }
167
+        return responseBean;
168
+    }
169
+
170
+    /**
171
+     * 修改对象
172
+     * @param id  实体ID
173
+     * @param channel 实体对象
174
+     * @return
175
+     */
176
+    @ApiOperation(value = "根据渠道ID修改", notes = "根据渠道ID修改")
177
+    @ApiImplicitParams({
178
+            @ApiImplicitParam(dataTypeClass = Integer.class, name = "id", paramType = "query",value = "渠道id"),
179
+    })
180
+    @RequestMapping(value="/admin/channel/{id}",method= RequestMethod.PUT)
181
+    public ResponseBean channelUpdate(@PathVariable Integer id,
182
+                                        @RequestBody TaChannel channel){
183
+        ResponseBean responseBean = new ResponseBean();
184
+        try {
185
+            channel.setChannelId(id);
186
+            if (taChannelService.updateById(channel)){
187
+                responseBean.addSuccess(channel);
188
+            }else {
189
+                responseBean.addError("fail");
190
+            }
191
+        }catch (Exception e){
192
+            e.printStackTrace();
193
+            logger.error("channelUpdate -=- {}",e.toString());
194
+            responseBean.addError(e.getMessage());
195
+        }
196
+        return responseBean;
197
+    }
198
+
199
+    /**
200
+     * 根据id查询对象
201
+     * @param id  实体ID
202
+     */
203
+    @ApiOperation(value = "根据渠道ID查询", notes = "根据渠道ID查询")
204
+    @ApiImplicitParams({
205
+            @ApiImplicitParam(dataTypeClass = Integer.class, name = "id", paramType = "query",value = "渠道id"),
206
+    })
207
+    @RequestMapping(value="/admin/channel/{id}",method= RequestMethod.GET)
208
+    public ResponseBean channelGet(@PathVariable Integer id){
209
+        ResponseBean responseBean = new ResponseBean();
210
+        try {
211
+            responseBean.addSuccess(taChannelService.getById(id));
212
+        }catch (Exception e){
213
+            e.printStackTrace();
214
+            logger.error("channelDelete -=- {}",e.toString());
215
+            responseBean.addError(e.getMessage());
216
+        }
217
+        return responseBean;
218
+    }
219
+
220
+    /**
221
+     * 渠道管理下的经纪人
222
+     */
223
+    @ApiOperation(value = "渠道管理下的经纪人", notes = "渠道管理下的经纪人")
224
+    @ApiImplicitParams({
225
+            @ApiImplicitParam(dataTypeClass = String.class, name = "name", paramType = "query",value = "姓名"),
226
+            @ApiImplicitParam(dataTypeClass = String.class, name = "phone", paramType = "query",value = "电话"),
227
+            @ApiImplicitParam(dataTypeClass = Integer.class, name = "channelId", paramType = "query",value = "渠道id"),
228
+            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageNum", paramType = "query",value = "多少页"),
229
+            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageSize", paramType = "query",value = "每页多少条"),
230
+    })
231
+    @RequestMapping(value="/admin/channel/broker",method= RequestMethod.GET)
232
+    public  ResponseBean channelBrokerList(@RequestParam(value="name",required = false) String name,
233
+                                           @RequestParam(value="phone",required = false) String phone,
234
+                                           @RequestParam(value="channelId",required = false) Integer channelId,
235
+                                           @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
236
+                                           @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
237
+                                           HttpServletRequest request){
238
+        Integer orgid = getOrgId(request);
239
+        ResponseBean taPerson =  taPersonService.channelBrokerList(name,phone,pageNum,pageSize,orgid,channelId);
240
+        return taPerson;
241
+    }
242
+
243
+    /**
244
+     * 渠道邀请经纪人列表
245
+     */
246
+    @ApiOperation(value = "渠道邀请经纪人列表", notes = "渠道邀请经纪人列表")
247
+    @ApiImplicitParams({
248
+            @ApiImplicitParam(dataTypeClass = String.class, name = "id", paramType = "query",value = "姓名"),
249
+            @ApiImplicitParam(dataTypeClass = String.class, name = "phone", paramType = "query",value = "电话"),
250
+            @ApiImplicitParam(dataTypeClass = Integer.class, name = "channelId", paramType = "query",value = "渠道id"),
251
+            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageNum", paramType = "query",value = "多少页"),
252
+            @ApiImplicitParam(dataTypeClass = Integer.class, name = "pageSize", paramType = "query",value = "每页多少条"),
253
+    })
254
+    @RequestMapping(value="/admin/channel/InviteClientsList",method= RequestMethod.GET)
255
+    public  ResponseBean InviteClientsList(@RequestParam(value="id",required = false) String id,
256
+                                           @RequestParam(value="phone",required = false) String phone,
257
+                                           @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
258
+                                           @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
259
+                                           HttpServletRequest request){
260
+        ResponseBean taPerson =  taPersonService.InviteClientsList(id,phone,pageNum,pageSize);
261
+        return taPerson;
262
+    }
263
+}

+ 29
- 20
src/main/java/com/huiju/estateagents/controller/TaPersonController.java View File

@@ -5,26 +5,25 @@ import com.alibaba.fastjson.JSONObject;
5 5
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
6 6
 import com.baomidou.mybatisplus.core.metadata.IPage;
7 7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
8
+import com.huiju.estateagents.base.BaseController;
8 9
 import com.huiju.estateagents.base.ResponseBean;
9 10
 import com.huiju.estateagents.center.taUser.entity.TaUser;
10 11
 import com.huiju.estateagents.center.taUser.service.ITaUserService;
11 12
 import com.huiju.estateagents.common.CommConstant;
12
-import com.huiju.estateagents.common.JWTUtils;
13 13
 import com.huiju.estateagents.common.SMSUtils;
14 14
 import com.huiju.estateagents.common.StringUtils;
15
-import com.huiju.estateagents.entity.*;
15
+import com.huiju.estateagents.entity.TaChannel;
16
+import com.huiju.estateagents.entity.TaChannelPerson;
17
+import com.huiju.estateagents.entity.TaPerson;
18
+import com.huiju.estateagents.entity.TaPersonBuilding;
16 19
 import com.huiju.estateagents.service.ITaPersonBuildingService;
17 20
 import com.huiju.estateagents.service.ITaPersonService;
18 21
 import com.huiju.estateagents.service.TaChannelPersonService;
19 22
 import com.huiju.estateagents.service.TaChannelService;
20 23
 import com.huiju.estateagents.third.entity.TaThirdPartyMiniappConfig;
21 24
 import com.huiju.estateagents.third.service.ITaThirdPartyMiniappConfigService;
22
-import org.checkerframework.checker.units.qual.A;
23
-import org.checkerframework.checker.units.qual.C;
24 25
 import org.springframework.beans.factory.annotation.Autowired;
25 26
 import org.springframework.web.bind.annotation.*;
26
-
27
-import com.huiju.estateagents.base.BaseController;
28 27
 import org.springframework.web.client.RestTemplate;
29 28
 
30 29
 import javax.servlet.http.HttpServletRequest;
@@ -159,11 +158,18 @@ public class TaPersonController extends BaseController {
159 158
             return ResponseBean.error("您已经成为置业顾问",ResponseBean.ERROR_UNAVAILABLE);
160 159
         }
161 160
         QueryWrapper<TaUser>queryWrapper = new QueryWrapper<>();
162
-        queryWrapper.eq("phone",person.getPhone());
161
+        queryWrapper.nested(query -> query.eq("phone", person.getTel()).or().eq("phone", person.getPhone()));
163 162
         queryWrapper.eq("org_id",orgId);
164 163
         queryWrapper.eq("status",CommConstant.STATUS_NORMAL);
165 164
         queryWrapper.eq("is_consultant",true);
166 165
         List<TaUser> users = taUserService.list(queryWrapper);
166
+
167
+        TaChannelPerson taChannelPerson = new TaChannelPerson();
168
+        taChannelPerson.setStatus(CommConstant.STATUS_DELETE);
169
+        QueryWrapper<TaChannelPerson> taChannelPersonQueryWrapper = new QueryWrapper<>();
170
+        taChannelPersonQueryWrapper.eq("person_id", person.getPersonId());
171
+        taChannelPersonService.update(taChannelPerson, taChannelPersonQueryWrapper);
172
+
167 173
         if(users.size()>0){
168 174
             TaUser user = users.get(0);
169 175
             person.setPersonType(CommConstant.PERSON_REALTY_CONSULTANT);
@@ -208,13 +214,13 @@ public class TaPersonController extends BaseController {
208 214
         if(StringUtils.isEmpty(channelCode)){
209 215
             person.setPersonType(CommConstant.PERSON_ESTATE_AGENT);
210 216
         }else {
211
-            person.setPersonType(CommConstant.PERSON_ESTATE_CHANNEL);
217
+            person.setPersonType(CommConstant.PERSON_ESTATE_AGENT);
212 218
             QueryWrapper<TaChannel> queryWrapper = new QueryWrapper();
213 219
             queryWrapper.eq("channel_code",channelCode);
214 220
             queryWrapper.eq("org_id",orgId);
215 221
             TaChannel channel = taChannelService.getOne(queryWrapper);
216 222
             if (null == channel){
217
-                return ResponseBean.error("渠道码不存在",ResponseBean.ERROR_UNAVAILABLE);
223
+                return ResponseBean.error("验证码有误,请确认后重新输入",ResponseBean.ERROR_UNAVAILABLE);
218 224
             }
219 225
             QueryWrapper<TaChannelPerson>taChannelPersonQueryWrapper = new QueryWrapper<>();
220 226
             taChannelPersonQueryWrapper.eq("person_id",person.getPersonId());
@@ -568,7 +574,7 @@ public class TaPersonController extends BaseController {
568 574
         }
569 575
         if (!StringUtils.isEmpty(phone)){
570 576
             person.setTel(phone);
571
-            person.setPhone(phone);
577
+//            person.setPhone(phone);
572 578
             if(person.getPersonType().equals(CommConstant.PERSON_REALTY_CONSULTANT)){
573 579
                 TaUser user = taUserService.getById(person.getUserId());
574 580
                 user.setPhone(phone);
@@ -664,17 +670,20 @@ public class TaPersonController extends BaseController {
664 670
                     return ResponseBean.error("渠道码错误", ResponseBean.ERROR_UNAVAILABLE);
665 671
                 }
666 672
 
667
-            }else {
668
-                QueryWrapper<TaChannelPerson>channelPersonQueryWrapper = new QueryWrapper<>();
669
-                channelPersonQueryWrapper.eq("person_id",person.getPersonId());
670
-                List<TaChannelPerson> taChannelPerson = taChannelPersonService.list(channelPersonQueryWrapper);
671
-                if (taChannelPerson.size()>0){
672
-                    for(int i=0;i<taChannelPerson.size();i++){
673
-                        taChannelPerson.get(i).setStatus(CommConstant.STATUS_DELETE);
674
-                    }
675
-                    taChannelPersonService.updateBatchById(taChannelPerson);
676
-                }
677 673
             }
674
+            //编辑个人信息暂时不修改经纪人类型
675
+//            else {
676
+//
677
+//                QueryWrapper<TaChannelPerson>channelPersonQueryWrapper = new QueryWrapper<>();
678
+//                channelPersonQueryWrapper.eq("person_id",person.getPersonId());
679
+//                List<TaChannelPerson> taChannelPerson = taChannelPersonService.list(channelPersonQueryWrapper);
680
+//                if (taChannelPerson.size()>0){
681
+//                    for(int i=0;i<taChannelPerson.size();i++){
682
+//                        taChannelPerson.get(i).setStatus(CommConstant.STATUS_DELETE);
683
+//                    }
684
+//                    taChannelPersonService.updateBatchById(taChannelPerson);
685
+//                }
686
+//            }
678 687
             person.setPersonType(personType);
679 688
             if (taPersonService.updateById(person)){
680 689
                 responseBean.addSuccess(person);

+ 11
- 9
src/main/java/com/huiju/estateagents/controller/TaRecommendCustomerController.java View File

@@ -424,10 +424,11 @@ public class TaRecommendCustomerController extends BaseController {
424 424
     public ResponseBean getIndependentAgents(HttpServletRequest request,
425 425
                                              @RequestParam(value = "name", required = false) String name,
426 426
                                              @RequestParam(value = "tel", required = false) String tel,
427
+                                             @RequestParam(value = "channelId", required = false) String channelId,
427 428
                                              @RequestParam(value = "pageNumber", defaultValue = "1") Integer pageNumber,
428 429
                                              @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
429 430
         try {
430
-            return ResponseBean.success(taRecommendCustomerService.getIndependentAgents(pageNumber, pageSize, name, tel, getOrgId(request)));
431
+            return ResponseBean.success(taRecommendCustomerService.getIndependentAgents(pageNumber, pageSize, name, tel, channelId, getOrgId(request)));
431 432
         } catch (Exception e) {
432 433
             e.printStackTrace();
433 434
             return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
@@ -441,8 +442,7 @@ public class TaRecommendCustomerController extends BaseController {
441 442
     public ResponseBean assistConsultant(@RequestBody TaUser taUser, @PathVariable String personId, HttpServletRequest request) {
442 443
         try {
443 444
             Integer orgId = getOrgId(request);
444
-            taRecommendCustomerService.consultantAssist(taUser, personId, orgId);
445
-            return ResponseBean.success("");
445
+            return taRecommendCustomerService.consultantAssist(taUser, personId, orgId);
446 446
         } catch (Exception e) {
447 447
             e.printStackTrace();
448 448
             return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
@@ -454,13 +454,12 @@ public class TaRecommendCustomerController extends BaseController {
454 454
      */
455 455
     @RequestMapping(value = "/admin/customer/consultant/batchAssist", method = RequestMethod.POST)
456 456
     public ResponseBean batchAssistConsultant(@RequestBody TaUser taUser, HttpServletRequest request) {
457
-        if (CollectionUtils.isEmpty(taUser.getPersonIds())) {
457
+        if (CollectionUtils.isEmpty(taUser.getCustomerIds())) {
458 458
             return ResponseBean.error("请至少选择一条数据", ResponseBean.ERROR_UNAVAILABLE);
459 459
         }
460 460
         try {
461 461
             Integer orgId = getOrgId(request);
462
-            taRecommendCustomerService.batchConsultantAssist(taUser, orgId);
463
-            return ResponseBean.success("");
462
+            return taRecommendCustomerService.batchConsultantAssist(taUser, orgId);
464 463
         } catch (Exception e) {
465 464
             e.printStackTrace();
466 465
             return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
@@ -672,7 +671,6 @@ public class TaRecommendCustomerController extends BaseController {
672 671
                     if (null != realtyConsultant) {
673 672
                         List<TaBuilding> taBuildings = taPersonBuildingMapper.getBuildingsOf(realtyConsultant);
674 673
                         taRecommendCustomer.setRealtyConsultant(realtyConsultant);
675
-                        taRecommendCustomer.setCreateDate(LocalDateTime.now());
676 674
                         if (taBuildings != null && taBuildings.size() > 0) {
677 675
                             TaBuilding taBuilding = taBuildings.get(0);
678 676
                             taRecommendCustomer.setBuildingId(taBuilding.getBuildingId());
@@ -681,6 +679,7 @@ public class TaRecommendCustomerController extends BaseController {
681 679
                     }
682 680
                 }
683 681
 
682
+                taRecommendCustomer.setVerifyDate(LocalDateTime.now());
684 683
                 if (taRecommendCustomerService.updateById(taRecommendCustomer)) {
685 684
 
686 685
                     // 审核通过增加积分
@@ -782,7 +781,10 @@ public class TaRecommendCustomerController extends BaseController {
782 781
      * 导出数据(经纪人)
783 782
      */
784 783
     @GetMapping("/admin/customer/recommend/agents/export")
785
-    public void agentsExport(HttpServletRequest request, HttpServletResponse response) throws IOException {
784
+    public void agentsExport(@RequestParam(value = "name", required = false) String name,
785
+                             @RequestParam(value = "tel", required = false) String tel,
786
+                             @RequestParam(value = "channelId", required = false) String channelId,
787
+                             HttpServletRequest request, HttpServletResponse response) throws IOException {
786 788
 //        response.setContentType("application/vnd.ms-excel");
787 789
         response.setContentType("application/octet-stream");
788 790
         response.setCharacterEncoding("utf-8");
@@ -800,7 +802,7 @@ public class TaRecommendCustomerController extends BaseController {
800 802
         WriteSheet writeSheet = EasyExcel.writerSheet("经纪人").build();
801 803
         List<AgentsRecommendCustomer> recCustomerExport = null;
802 804
         do {
803
-            recCustomerExport = taRecommendCustomerService.getIndependentAgentsExport(getOrgId(request), pageCode * pageSize, pageSize);
805
+            recCustomerExport = taRecommendCustomerService.getIndependentAgentsExport(name, tel, channelId, getOrgId(request), pageCode * pageSize, pageSize);
804 806
             excelWriter.write(recCustomerExport, writeSheet);
805 807
 
806 808
             pageCode++;

+ 4
- 4
src/main/java/com/huiju/estateagents/entity/TaPerson.java View File

@@ -1,9 +1,5 @@
1 1
 package com.huiju.estateagents.entity;
2 2
 
3
-import java.time.LocalDateTime;
4
-import java.io.Serializable;
5
-import java.util.List;
6
-
7 3
 import com.baomidou.mybatisplus.annotation.IdType;
8 4
 import com.baomidou.mybatisplus.annotation.TableField;
9 5
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -12,6 +8,10 @@ import lombok.Data;
12 8
 import lombok.EqualsAndHashCode;
13 9
 import lombok.experimental.Accessors;
14 10
 
11
+import java.io.Serializable;
12
+import java.time.LocalDateTime;
13
+import java.util.List;
14
+
15 15
 /**
16 16
  * <p>
17 17
  * 人员表

+ 2
- 0
src/main/java/com/huiju/estateagents/entity/TaRecommendCustomer.java View File

@@ -149,6 +149,8 @@ public class TaRecommendCustomer implements Serializable {
149 149
 
150 150
     private LocalDateTime arrivalDate;
151 151
 
152
+    private LocalDateTime verifyDate;
153
+
152 154
     @DateTimeFormat("yyyy年MM月dd日")
153 155
     private LocalDateTime createDate;
154 156
 

+ 42
- 40
src/main/java/com/huiju/estateagents/mapper/TaChannelMapper.java View File

@@ -1,40 +1,42 @@
1
-package com.huiju.estateagents.mapper;
2
-
3
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
-import com.baomidou.mybatisplus.core.metadata.IPage;
5
-import com.huiju.estateagents.entity.TaChannel;
6
-import org.apache.ibatis.annotations.Mapper;
7
-import org.apache.ibatis.annotations.Param;
8
-
9
-import java.util.List;
10
-
11
-/**
12
- * <p>
13
- *   Mapper 接口
14
- * </p>
15
- *
16
- * @author jobob
17
- * @since 2019-09-17
18
- */
19
-@Mapper
20
-public interface TaChannelMapper extends BaseMapper<TaChannel> {
21
-
22
-    /**
23
-     * 渠道码
24
-     * @return
25
-     */
26
-    int channelCode();
27
-
28
-    /**
29
-     * 渠道页面下拉列表的所有数据
30
-     * @return
31
-     */
32
-    List<TaChannel> selectChannelList(@Param("orgId")Integer orgId);
33
-
34
-    /**
35
-     * 渠道列表
36
-     * @param pg
37
-     * @return
38
-     */
39
-    IPage<TaChannel> pageTaChannel(IPage<TaChannel> pg,@Param("orgId")Integer orgId,@Param("channelId")Integer channelId);
40
-}
1
+package com.huiju.estateagents.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.huiju.estateagents.entity.TaChannel;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.util.List;
10
+
11
+/**
12
+ * <p>
13
+ *   Mapper 接口
14
+ * </p>
15
+ *
16
+ * @author jobob
17
+ * @since 2019-09-17
18
+ */
19
+@Mapper
20
+public interface TaChannelMapper extends BaseMapper<TaChannel> {
21
+
22
+    /**
23
+     * 渠道码
24
+     * @return
25
+     */
26
+    int channelCode();
27
+
28
+    /**
29
+     * 渠道页面下拉列表的所有数据
30
+     * @return
31
+     */
32
+    List<TaChannel> selectChannelList(@Param("orgId")Integer orgId);
33
+
34
+    /**
35
+     * 渠道列表
36
+     * @param pg
37
+     * @return
38
+     */
39
+    IPage<TaChannel> pageTaChannel(IPage<TaChannel> pg,@Param("orgId")Integer orgId,@Param("channelId")Integer channelId);
40
+
41
+    List<TaChannel> recommendCount(@Param("orgId")Integer orgId,@Param("channelId")Integer channelId);
42
+}

+ 2
- 0
src/main/java/com/huiju/estateagents/mapper/TaPersonMapper.java View File

@@ -256,4 +256,6 @@ public interface TaPersonMapper extends BaseMapper<TaPerson> {
256 256
     Integer selectTodayRecentlyCount(@Param("orgId") Integer orgId, @Param("nowDate") LocalDateTime nowDate);
257 257
 
258 258
     List<Map<String, Object>> selectCityPerson(@Param("orgId") Integer orgId);
259
+
260
+    Integer cancelConsulatant(@Param("personId") String personId);
259 261
 }

+ 14
- 2
src/main/java/com/huiju/estateagents/mapper/TaRecommendCustomerMapper.java View File

@@ -36,7 +36,7 @@ public interface TaRecommendCustomerMapper extends BaseMapper<TaRecommendCustome
36 36
     IPage<TaRecommendCustomer> getCustomerList(IPage<TaRecommendCustomer> page,@Param("building") String building, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex, @Param("orgId") Integer orgId,@Param("status")Integer status, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList,@Param("sceneType") String sceneType, @Param("startCreateDate") String startCreateDate, @Param("endCreateDate") String endCreateDate, @Param("sharePersonName") String sharePersonName);
37 37
     IPage<TaRecommendCustomer> getRecCustomerList(IPage<TaRecommendCustomer> page,@Param("building") String building, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex, @Param("orgId") Integer orgId, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
38 38
     IPage<TaRecommendCustomer> getRepCustomerList(IPage<TaRecommendCustomer> page,@Param("building") String building, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex, @Param("orgId") Integer orgId, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
39
-    IPage<TaPerson> getIndependentAgents(IPage<TaPerson>page, @Param("name") String name, @Param("tel") String tel, @Param("orgId") Integer orgId);
39
+    IPage<TaPerson> getIndependentAgents(IPage<TaPerson>page, @Param("name") String name, @Param("tel") String tel, @Param("channelId") String channelId, @Param("orgId") Integer orgId);
40 40
 
41 41
     /**
42 42
      * 公客
@@ -107,7 +107,7 @@ public interface TaRecommendCustomerMapper extends BaseMapper<TaRecommendCustome
107 107
      * @param pageSize
108 108
      * @return
109 109
      */
110
-    List<AgentsRecommendCustomer> getIndependentAgentsExport(@Param("orgId") Integer orgId, @Param("pageCode") Integer pageCode, @Param("pageSize") Integer pageSize);
110
+    List<AgentsRecommendCustomer> getIndependentAgentsExport(@Param("name")String name, @Param("tel")String tel, @Param("channelId")String channelId, @Param("orgId") Integer orgId, @Param("pageCode") Integer pageCode, @Param("pageSize") Integer pageSize);
111 111
 
112 112
     /**
113 113
      * 导出数据 公客总数
@@ -226,6 +226,17 @@ public interface TaRecommendCustomerMapper extends BaseMapper<TaRecommendCustome
226 226
                                                            @Param("endDate") LocalDateTime endDate,
227 227
                                                            @Param("personId") String personId);
228 228
 
229
+    /**
230
+     * 查询 person 对应 楼盘 的客户
231
+     * 如果对应的楼盘没有客户, 则返回无楼盘的, 小程序级别的客户信息
232
+     * 如果没有无小程序级别客户, 则返回最早的一条
233
+     * @param orgId
234
+     * @param personId
235
+     * @param buildingId
236
+     * @return
237
+     */
238
+    TaRecommendCustomer getCustomerByProjectOrOrg(@Param("orgId") Integer orgId, @Param("personId") String personId, @Param("buildingId") String buildingId);
239
+
229 240
     /**
230 241
      * 获取置业福问下的客户
231 242
      * @param userId
@@ -235,4 +246,5 @@ public interface TaRecommendCustomerMapper extends BaseMapper<TaRecommendCustome
235 246
      * @return
236 247
      */
237 248
     List<TaRecommendCustomer> getConsultantCustomerList(@Param("userId") Integer userId,@Param("personId") String personId,@Param("buildingId") String buildingId,@Param("orgId") Integer orgId);
249
+
238 250
 }

+ 2
- 0
src/main/java/com/huiju/estateagents/mapper/TsConsultantKpiMapper.java View File

@@ -24,6 +24,7 @@ public interface TsConsultantKpiMapper extends BaseMapper<TsConsultantKpi> {
24 24
 
25 25
     /**
26 26
      * 置业KPI 汇总
27
+     * bug #6929 要求跟时间没关系
27 28
      * @param page
28 29
      * @param orgId
29 30
      * @param buildingIds
@@ -53,6 +54,7 @@ public interface TsConsultantKpiMapper extends BaseMapper<TsConsultantKpi> {
53 54
 
54 55
     /**
55 56
      * 统计当前时间段内的, 已经固化的置业数据的所有客户
57
+     * bug #6929 要求跟时间没关系
56 58
      * @param orgId
57 59
      * @param buildingIds
58 60
      * @param startDate

+ 3
- 3
src/main/java/com/huiju/estateagents/service/ITaRecommendCustomerService.java View File

@@ -44,7 +44,7 @@ public interface ITaRecommendCustomerService extends IService<TaRecommendCustome
44 44
 
45 45
     IPage<TaRecommendCustomer> getRepCustomerList(int pageNumber, int pageSize, String building, String name, String tel, String consultName, String consultTel, String entryType, String verifyStatus, Integer sex, Integer orgId, List<TaPersonBuilding> taPersonBuildingList);
46 46
 
47
-    IPage<TaPerson> getIndependentAgents(int pageNumber, int pageSize, String name, String tel, Integer orgId);
47
+    IPage<TaPerson> getIndependentAgents(int pageNumber, int pageSize, String name, String tel, String channelId, Integer orgId);
48 48
 
49 49
 
50 50
     TaRecommendCustomer getCustomerDetail(String customerId, int pageNumber, int pageSize, List<TaPersonBuilding> taPersonBuildingList, String buildingId);
@@ -57,7 +57,7 @@ public interface ITaRecommendCustomerService extends IService<TaRecommendCustome
57 57
 
58 58
     TaRecommendCustomer newByPerson(TaPerson person);
59 59
 
60
-    ResponseBean consultantAssist(TaUser taUser, String personId, Integer orgId);
60
+    ResponseBean consultantAssist(TaUser taUser, String customerId, Integer orgId);
61 61
 
62 62
     ResponseBean batchConsultantAssist(TaUser taUser, Integer orgId);
63 63
 
@@ -111,7 +111,7 @@ public interface ITaRecommendCustomerService extends IService<TaRecommendCustome
111 111
      * @param pageSize
112 112
      * @return
113 113
      */
114
-    List<AgentsRecommendCustomer> getIndependentAgentsExport(Integer orgId, Integer pageCode, Integer pageSize);
114
+    List<AgentsRecommendCustomer> getIndependentAgentsExport(String name, String tel, String channelId, Integer orgId, Integer pageCode, Integer pageSize);
115 115
 
116 116
     /**
117 117
      * 查询我的客户人数集合

+ 138
- 110
src/main/java/com/huiju/estateagents/service/impl/TaPersonServiceImpl.java View File

@@ -21,6 +21,7 @@ import com.huiju.estateagents.service.*;
21 21
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
22 22
 import lombok.extern.slf4j.Slf4j;
23 23
 import org.apache.commons.collections.CollectionUtils;
24
+import org.checkerframework.checker.units.qual.C;
24 25
 import org.springframework.beans.factory.annotation.Autowired;
25 26
 import org.springframework.context.ApplicationContext;
26 27
 import org.springframework.stereotype.Service;
@@ -72,6 +73,12 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
72 73
     @Autowired
73 74
     private TaSaveMapper taSaveMapper;
74 75
 
76
+    @Autowired
77
+    private TaChannelPersonMapper taChannelPersonMapper;
78
+
79
+    @Autowired
80
+    private TaChannelMapper taChannelMapper;
81
+
75 82
     @Autowired
76 83
     private TaBuildingMapper taBuildingMapper;
77 84
 
@@ -437,6 +444,19 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
437 444
         result.put("personType",taPerson.getPersonType());
438 445
         result.put("userId", taPerson.getUserId());
439 446
 
447
+        //经纪人所属渠道
448
+        QueryWrapper<TaChannelPerson> taChannelPersonQueryWrapper = new QueryWrapper<>();
449
+        taChannelPersonQueryWrapper.eq("person_id", taPerson.getPersonId());
450
+        taChannelPersonQueryWrapper.eq("status", CommConstant.STATUS_NORMAL);
451
+        TaChannelPerson taChannelPerson = taChannelPersonMapper.selectOne(taChannelPersonQueryWrapper);
452
+
453
+        if (taChannelPerson != null){
454
+            QueryWrapper<TaChannel> taChannelQueryWrapper = new QueryWrapper<>();
455
+            taChannelQueryWrapper.eq("channel_id", taChannelPerson.getChannelId());
456
+            TaChannel taChannel = taChannelMapper.selectOne(taChannelQueryWrapper);
457
+            result.put("channelName", taChannel.getChannelName());
458
+        }
459
+
440 460
         return ResponseBean.success(result);
441 461
     }
442 462
 
@@ -748,7 +768,7 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
748 768
         for (TaPerson taPerson:taPersonList){
749 769
             QueryWrapper<TaRecommendCustomer> taRecommendCustomerQuery= new QueryWrapper<>();
750 770
             taRecommendCustomerQuery.eq("recommend_person",taPerson.getPersonId());
751
-            taRecommendCustomerQuery.eq("status",1);
771
+//            taRecommendCustomerQuery.eq("status",1);
752 772
             taRecommendCustomerQuery.eq("org_id", orgid);
753 773
             /*推荐客户总数*/
754 774
             int recommendCount= taRecommendCustomerMapper.selectCount(taRecommendCustomerQuery);
@@ -874,14 +894,12 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
874 894
         //
875 895
         LocalDateTime now = LocalDateTime.now();
876 896
 
877
-        // 1. 更新当前人员
897
+        // 更新人员手机号
878 898
         List<TaPerson> persons = getPersonsByOpenId(openid);
879 899
         if (null == persons || persons.size() != 1) {
880 900
             throw new Exception("当前人员 openid 异常");
881 901
         }
882 902
         TaPerson person = persons.get(0);
883
-
884
-        // 更新人员手机号
885 903
         person.setPhone(phone);
886 904
         person.setAuthPhoneTime(now);
887 905
         if (StringUtils.isEmpty(person.getBuildingId())) {
@@ -891,143 +909,154 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
891 909
             person.setPersonType(CommConstant.PERSON_ESTATE_CUSTOMER);
892 910
         }
893 911
         updateById(person);
894
-        fixCustomerPersonId(person);
895 912
 
896
-        // 2. 发放积分
913
+        // 只要授权手机号, 就是客户
914
+        // 或者 依据手机号反更新推荐客户中 person_id
915
+        // 默认场景, 普通人推荐
916
+        TaRecommendCustomer customer = newOrFixCustomerBy(person, promoter, buildingId);
917
+
918
+        // 发放积分
897 919
         applicationContext.publishEvent(new EventBus(person, EventBus.EventType.SignUpAgent, orgId));
898 920
 
899 921
         //授权手机给推广人加积分
900 922
         String sharePersonId = getSharePersonFrom(person);
901
-
902 923
         if (validateSceneId(sceneId) && !StringUtils.isEmpty(sharePersonId)){
903 924
             applicationContext.publishEvent(new EventBus(promoter != null ? promoter : sharePersonId, EventBus.EventType.SharePosterAll, orgId));
904 925
         }
905 926
 
906
-        // 3. 处理推广人
907
-        TaPerson recPerson = taPersonMapper.getById(promoter);
908
-        if (recPerson != null && CommConstant.STATUS_DELETE.equals(recPerson.getStatus())) {
909
-            recPerson = null;
910
-        }
911
-
912
-        TaUser taUser = null;
913
-        List<String> withBuildings = null;  // 推广人授权的楼盘
914
-        boolean isAssociated = false;       // 传入的楼盘与推广人是否有关联关系
915
-        boolean isConsultant = false;       // 是否置业顾问
916
-        if (!StringUtils.isEmpty(promoter)) {
917
-            taUser = taUserMapper.getUserByPerson(orgId, promoter);
918
-            if (null != taUser) {
919
-                isConsultant = taUser != null && taUser.getIsConsultant() != null && taUser.getIsConsultant();
920
-                List<TaPerson> userPerons = new ArrayList<>();
921
-                userPerons.add(recPerson);
922
-                taUser.setPersonIds(userPerons);
923
-
924
-                withBuildings = taUserMapper.getBuildingIdsOf(taUser.getUserId(), null);
925
-
926
-                if (null != taUser.getIsAdmin() && taUser.getIsAdmin()) {
927
-                    isAssociated = true;
928
-                } else {
929
-                    if (null != withBuildings && withBuildings.size() > 0 && !StringUtils.isEmpty(buildingId)) {
930
-                        isAssociated = withBuildings.contains(buildingId);
931
-                    }
932
-                }
933
-            }
934
-        }
935
-
936
-        // 楼盘
937
-        TaBuilding taBuilding = null;
938
-        if (!StringUtils.isEmpty(buildingId)) {
939
-            taBuilding = taBuildingMapper.selectById(buildingId);
940
-            if (taBuilding.getStatus().equals(CommConstant.STATUS_DELETE)) {
941
-                taBuilding = null;
942
-            }
943
-        }
944
-
945
-        // 没有置业, 也没楼盘
946
-        if ((recPerson == null || !isConsultant) && taBuilding == null) {
947
-            TaCustomerFrom customerFrom = new TaCustomerFrom();
948
-            customerFrom.setPersonId(person.getPersonId());
949
-            customerFrom.setPersonName(StringUtils.ifNull(person.getName(), person.getNickname()));
950
-            customerFrom.setTargetType(targetType);
951
-            customerFrom.setTargetId(targetId);
952
-            customerFrom.setTargetName(targetName);
953
-            customerFrom.setOrgId(orgId);
954
-            customerFrom.setSceneId(sceneId);
955
-            customerFrom.setIsOrgFirst(true);   // 授权手机号, 肯定是第一次
956
-            customerFrom.setIsProjectFirst(false);
957
-            customerFrom.setCreateDate(now);
958
-            if (null != recPerson) {
959
-                customerFrom.setSharePersonId(recPerson.getPersonId());
960
-                customerFrom.setSharePersonName(StringUtils.ifNull(recPerson.getName(), recPerson.getNickname()));
961
-            }
962
-
963
-            taCustomerFromMapper.insert(customerFrom);
964
-
965
-
966
-            TaRecommendCustomer customer = copyByPerosn(person, new TaRecommendCustomer());
967
-            customer.setVerifyStatus(CommConstant.VERIFY_READY);
968
-            customer.setStatus(CommConstant.CUSTOMER_REPORT);
969
-            customer.setEntryType(CommConstant.ENTRY_INPUT);
970
-            customer.setCreateDate(now);
971
-            customer.setReportDate(now);
972
-            customer.setRecommendPerson(promoter);
973
-            taRecommendCustomerMapper.insert(customer);
974
-
975
-            return ;
976
-        }
977
-
978
-        // 3. 修正客户信息
979
-        List<TaBuilding> withBuildingList = null;
980
-        if (null != withBuildings && withBuildings.size() > 0) {
981
-            QueryWrapper<TaBuilding> queryBuilding = new QueryWrapper<>();
982
-            queryBuilding.in("building_id", withBuildings);
983
-            withBuildingList = taBuildingMapper.selectList(queryBuilding);
984
-        }
985
-        List<TaRecommendCustomer> customers = mergeCustomerByPhone(person, taUser, taBuilding, withBuildingList, isAssociated, now);
986
-        if (null == customers || customers.size() == 0) {
987
-            throw new Exception("生成客户信息异常, 请联系技术人员");
988
-        }
989
-
990
-        // 4. 客户来源, 注意不是用户来源
927
+        // 客户来源
991 928
         TaCustomerFrom customerFrom = new TaCustomerFrom();
992 929
         customerFrom.setPersonId(person.getPersonId());
993 930
         customerFrom.setPersonName(StringUtils.ifNull(person.getName(), person.getNickname()));
931
+        customerFrom.setCustomerId(customer.getCustomerId());
994 932
         customerFrom.setTargetType(targetType);
995 933
         customerFrom.setTargetId(targetId);
996 934
         customerFrom.setTargetName(targetName);
997 935
         customerFrom.setOrgId(orgId);
998 936
         customerFrom.setSceneId(sceneId);
999 937
         customerFrom.setIsOrgFirst(true);   // 授权手机号, 肯定是第一次
938
+        customerFrom.setIsProjectFirst(false);
1000 939
         customerFrom.setCreateDate(now);
1001 940
 
1002
-        if (null != taBuilding) {
941
+        // 推广人
942
+        TaPerson recPerson = StringUtils.isEmpty(promoter) ? null : taPersonMapper.getById(promoter);
943
+        // 是否置业顾问
944
+        boolean isConsultant = null != recPerson && CommConstant.PERSON_REALTY_CONSULTANT.equals(recPerson.getPersonType());
945
+        // 推广人授权的楼盘
946
+        List<String> withBuildings = isConsultant ? taUserMapper.getBuildingIdsOf(recPerson.getUserId(), null) : null;
947
+        // 推荐楼盘
948
+        TaBuilding recBuilding = StringUtils.isEmpty(buildingId) ? null : taBuildingMapper.selectById(buildingId);
949
+
950
+        // 传入的楼盘与推广人是否有关联关系
951
+        boolean isAssociated = null != withBuildings && withBuildings.contains(buildingId);
952
+
953
+        // 如果有推荐楼盘
954
+        if (null != recBuilding) {
1003 955
             customerFrom.setBuildingId(buildingId);
1004
-            customerFrom.setBuildingName(taBuilding.getBuildingName());
1005
-            QueryWrapper<TaCustomerFrom> queryWrapper = new QueryWrapper<TaCustomerFrom>();
1006
-            queryWrapper.eq("person_id", person.getPersonId());
1007
-            queryWrapper.eq("org_id", orgId);
1008
-            queryWrapper.eq("building_id", buildingId);
1009
-            if (taCustomerFromMapper.selectList(queryWrapper).size() < 1){
1010
-                customerFrom.setIsProjectFirst(true);
1011
-            }
956
+            customerFrom.setBuildingName(recBuilding.getBuildingName());
957
+            customerFrom.setIsProjectFirst(true);
1012 958
 
1013
-            for (TaRecommendCustomer cust : customers) {
1014
-                if (buildingId.equals(cust.getBuildingId())) {
1015
-                    customerFrom.setCustomerId(cust.getCustomerId());
959
+            // 客户没楼盘 - 小程序级别公客, 则变成项目级别公客
960
+            if (StringUtils.isEmpty(customer.getBuildingId())) {
961
+                customer.setBuildingId(buildingId);
962
+
963
+                // 如果项目跟推广人是关联关系, 那么就是私客
964
+                if (isAssociated) {
965
+                    customer.setRealtyConsultant(recPerson.getUserId().toString());
1016 966
                 }
967
+
968
+                taRecommendCustomerMapper.updateById(customer);
1017 969
             }
1018
-        } else if (isConsultant && null != withBuildingList && withBuildingList.size() > 0) {
1019
-            // 没有楼盘则使用置业授权的楼盘
1020
-            customerFrom.setBuildingId(withBuildingList.get(0).getBuildingId());
1021
-            customerFrom.setBuildingName(withBuildingList.get(0).getBuildingName());
1022 970
         }
971
+
972
+        // 推荐人不为空
1023 973
         if (null != recPerson) {
1024 974
             customerFrom.setSharePersonId(recPerson.getPersonId());
1025
-            customerFrom.setSharePersonName(StringUtils.ifNull(recPerson.getName(), recPerson.getNickname()));
975
+            customerFrom.setSharePersonName(recPerson.getNickname());
976
+
977
+            // 如果没有关联关系
978
+            // 置业顾问推荐其他楼盘, 那么需要生成该置业的私客
979
+            if (isConsultant && !isAssociated) {
980
+                String consultantBuildingId = null != withBuildings ? withBuildings.get(0) : null;
981
+                if (!StringUtils.isEmpty(consultantBuildingId)) {
982
+                    TaBuilding onsultantBuilding = taBuildingMapper.selectById(consultantBuildingId);
983
+                    TaRecommendCustomer newCustomer = copyByPerosn(person, new TaRecommendCustomer());
984
+                    newCustomer.setBuildingId(onsultantBuilding.getBuildingId());
985
+                    newCustomer.setRealtyConsultant(recPerson.getUserId().toString());
986
+                    newCustomer.setRecommendPerson(recPerson.getPersonId());
987
+                    newCustomer.setVerifyStatus(CommConstant.VERIFY_AGREE);
988
+                    newCustomer.setStatus(CommConstant.CUSTOMER_REPORT);
989
+                    newCustomer.setEntryType(CommConstant.ENTRY_INPUT);
990
+                    newCustomer.setCreateDate(now);
991
+                    newCustomer.setReportDate(now);
992
+                    taRecommendCustomerMapper.insert(newCustomer);
993
+
994
+                    TaCustomerFrom customerFrom2 = new TaCustomerFrom();
995
+                    customerFrom2.setPersonId(person.getPersonId());
996
+                    customerFrom2.setPersonName(StringUtils.ifNull(person.getName(), person.getNickname()));
997
+                    customerFrom2.setCustomerId(newCustomer.getCustomerId());
998
+                    customerFrom2.setBuildingId(onsultantBuilding.getBuildingId());
999
+                    customerFrom2.setBuildingName(onsultantBuilding.getBuildingName());
1000
+                    customerFrom2.setSharePersonId(recPerson.getPersonId());
1001
+                    customerFrom2.setSharePersonName(recPerson.getNickname());
1002
+                    customerFrom2.setTargetType(targetType);
1003
+                    customerFrom2.setTargetId(targetId);
1004
+                    customerFrom2.setTargetName(targetName);
1005
+                    customerFrom2.setOrgId(orgId);
1006
+                    customerFrom2.setSceneId(sceneId);
1007
+                    customerFrom2.setIsOrgFirst(true);
1008
+                    customerFrom2.setIsProjectFirst(true);
1009
+                    customerFrom2.setCreateDate(now);
1010
+                    taCustomerFromMapper.insert(customerFrom2);
1011
+                }
1012
+            }
1026 1013
         }
1027 1014
 
1028 1015
         taCustomerFromMapper.insert(customerFrom);
1029 1016
     }
1030 1017
 
1018
+    private TaRecommendCustomer newOrFixCustomerBy(TaPerson person, String promoter, String buildingId) {
1019
+        QueryWrapper<TaRecommendCustomer> query = new QueryWrapper<>();
1020
+        query.eq("org_id", person.getOrgId());
1021
+        query.eq("phone", person.getPhone());
1022
+        query.orderByAsc("create_date");
1023
+        List<TaRecommendCustomer> customers = taRecommendCustomerMapper.selectList(query);
1024
+
1025
+        TaRecommendCustomer customer = null;
1026
+        if (null != customers && customers.size() > 0) {
1027
+            for (TaRecommendCustomer cust: customers) {
1028
+                if (null == customer && StringUtils.isEmpty(cust.getBuildingId())) {
1029
+                    customer = cust;
1030
+                }
1031
+
1032
+                if (!StringUtils.isEmpty(buildingId) && buildingId.equals(cust.getBuildingId())) {
1033
+                    customer = cust;
1034
+                }
1035
+
1036
+                // 先更新之前的数据, 有一种可能的情况, 客户是推荐的,之前未进入过小程序
1037
+                // 后面所有的查询就可以不需要 phone , 改用 person_id 了
1038
+                if (StringUtils.isEmpty(cust.getPersonId())) {
1039
+                    cust = copyByPerosn(person, cust);
1040
+                    taRecommendCustomerMapper.updateById(cust);
1041
+                }
1042
+            }
1043
+        }
1044
+
1045
+        if (null == customer) {
1046
+            LocalDateTime now = LocalDateTime.now();
1047
+            customer = copyByPerosn(person, new TaRecommendCustomer());
1048
+            customer.setVerifyStatus(CommConstant.VERIFY_AGREE);
1049
+            customer.setStatus(CommConstant.CUSTOMER_REPORT);
1050
+            customer.setEntryType(StringUtils.isEmpty(promoter) ? CommConstant.ENTRY_VOLUNTEER : CommConstant.ENTRY_INPUT);
1051
+            customer.setCreateDate(now);
1052
+            customer.setReportDate(now);
1053
+            customer.setRecommendPerson(promoter);
1054
+            taRecommendCustomerMapper.insert(customer);
1055
+        }
1056
+
1057
+        return customer;
1058
+    }
1059
+
1031 1060
     private String getSharePersonFrom(TaPerson person){
1032 1061
         QueryWrapper<TaSharePersonFrom> taSharePersonFromQueryWrapper = new QueryWrapper<>();
1033 1062
         taSharePersonFromQueryWrapper.eq("person_id", person.getPersonId());
@@ -1073,7 +1102,6 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
1073 1102
         }
1074 1103
     }
1075 1104
 
1076
-
1077 1105
     /**
1078 1106
      * 此处逻辑按照复杂流程处理
1079 1107
      * 除了新增客户外,还有修正原有数据的目的

+ 90
- 21
src/main/java/com/huiju/estateagents/service/impl/TaRecommendCustomerServiceImpl.java View File

@@ -1,5 +1,6 @@
1 1
 package com.huiju.estateagents.service.impl;
2 2
 
3
+import com.alibaba.fastjson.JSON;
3 4
 import com.alibaba.fastjson.JSONObject;
4 5
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 6
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -25,6 +26,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
25 26
 import com.huiju.estateagents.statistic.entity.TaCustomerFollowUpRecord;
26 27
 import com.huiju.estateagents.statistic.mapper.TaCustomerFollowUpRecordMapper;
27 28
 import org.apache.commons.collections.CollectionUtils;
29
+import org.slf4j.Logger;
30
+import org.slf4j.LoggerFactory;
28 31
 import org.springframework.beans.factory.annotation.Autowired;
29 32
 import org.springframework.stereotype.Service;
30 33
 
@@ -44,6 +47,8 @@ import java.util.Map;
44 47
 @Service
45 48
 public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCustomerMapper, TaRecommendCustomer> implements ITaRecommendCustomerService {
46 49
 
50
+    private Logger logger = LoggerFactory.getLogger(TaRecommendCustomerServiceImpl.class);
51
+
47 52
     @Autowired
48 53
     TaPersonMapper taPersonMapper;
49 54
 
@@ -160,7 +165,7 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
160 165
      */
161 166
     @Override
162 167
     public List<TaRecommendCustomer> getConsultantCustomerList(Integer userId, String personId, String buildingId, Integer orgId, List<TaPersonBuilding> taPersonBuildingListByUserId) {
163
-        return taRecommendCustomerMapper.getConsultantCustomerList(userId,personId,buildingId,orgId);
168
+        return taRecommendCustomerMapper.getConsultantCustomerList(userId, personId, buildingId, orgId);
164 169
     }
165 170
 
166 171
     @Override
@@ -503,7 +508,18 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
503 508
 
504 509
                 }
505 510
             }
506
-            return ResponseBean.error("您在当前项目的置业顾问是:" + conName, ResponseBean.ERROR_ILLEGAL_PARAMS);
511
+            TaRecommendCustomer oldRecomendCustomer = result.get(0);
512
+            if (!StringUtils.isEmpty(oldRecomendCustomer.getRealtyConsultant())) {
513
+                return ResponseBean.error("您在当前项目的置业顾问是:" + conName, ResponseBean.ERROR_ILLEGAL_PARAMS);
514
+            } else {
515
+                oldRecomendCustomer.setRealtyConsultant(consultantUser.getUserId().toString());
516
+                taRecommendCustomerMapper.updateById(oldRecomendCustomer);
517
+                if (null != customerFrom) {
518
+                    customerFrom.setCustomerId(oldRecomendCustomer.getCustomerId());
519
+                    taCustomerFromMapper.updateById(customerFrom);
520
+                }
521
+                return ResponseBean.success(oldRecomendCustomer);
522
+            }
507 523
         }
508 524
 
509 525
         int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
@@ -574,9 +590,9 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
574 590
     }
575 591
 
576 592
     @Override
577
-    public IPage<TaPerson> getIndependentAgents(int pageNumber, int pageSize, String name, String tel, Integer orgId) {
593
+    public IPage<TaPerson> getIndependentAgents(int pageNumber, int pageSize, String name, String tel, String channelId, Integer orgId) {
578 594
         IPage<TaPerson> page = new Page<>(pageNumber, pageSize);
579
-        return taRecommendCustomerMapper.getIndependentAgents(page, name, tel, orgId);
595
+        return taRecommendCustomerMapper.getIndependentAgents(page, name, tel, channelId, orgId);
580 596
     }
581 597
 
582 598
     @Override
@@ -824,30 +840,83 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
824 840
 
825 841
     @Override
826 842
     public ResponseBean batchConsultantAssist(TaUser taUser, Integer orgId) {
827
-        if (CollectionUtils.isNotEmpty(taUser.getPersonIds())) {
828
-            for (TaPerson taPerson : taUser.getPersonIds()) {
829
-                consultantAssist(taUser, taPerson.getPersonId(), orgId);
843
+        Integer failNum = 0;
844
+        if (CollectionUtils.isNotEmpty(taUser.getCustomerIds())) {
845
+            for (TaRecommendCustomer taRecommendCustomer : taUser.getCustomerIds()) {
846
+                ResponseBean responseBean = consultantAssist(taUser, taRecommendCustomer.getCustomerId(), orgId);
847
+                if (responseBean.getCode() != 1000) {
848
+                    failNum++;
849
+                }
830 850
             }
831 851
         }
832
-        return ResponseBean.success("操作成功");
852
+        JSONObject obj = new JSONObject();
853
+        obj.put("failNum", failNum);
854
+        obj.put("totalNum", taUser.getCustomerIds().size());
855
+        return ResponseBean.success(obj);
833 856
     }
834 857
 
835 858
     @Override
836
-    public ResponseBean consultantAssist(TaUser taUser, String personId, Integer orgId) {
837
-        TaPerson taPerson = taPersonMapper.getById(personId);
859
+    public ResponseBean consultantAssist(TaUser taUser, String customerId, Integer orgId) {
860
+        logger.info("公客分配置业顾问 接收参数,taUser={},customerId={},orgId={}",
861
+                JSONObject.toJSONString(taUser), customerId, orgId);
838 862
 
839
-        TaPerson recommendPerson = taPersonMapper.selectById(personId);
863
+        ResponseBean responseBean = new ResponseBean();
840 864
 
865
+        // 1.校验置业顾问
841 866
         QueryWrapper<TaUser> queryWrapper = new QueryWrapper();
842 867
         queryWrapper.eq("user_id", taUser.getUserId());
843 868
         TaUser userInfo = taUserMapper.selectOne(queryWrapper);
844 869
 
845 870
         QueryWrapper<TaPersonBuilding> taPersonBuildingQueryWrapper = new QueryWrapper();
846 871
         taPersonBuildingQueryWrapper.eq("user_id", taUser.getUserId());
872
+        taPersonBuildingQueryWrapper.eq(!StringUtils.isEmpty(taUser.getBuildingId()), "building_id", taUser.getBuildingId());
847 873
         TaPersonBuilding taPersonBuilding = taPersonBuildingMapper.selectOne(taPersonBuildingQueryWrapper);
848 874
 
849
-        if (null == userInfo || userInfo.getStatus() != CommConstant.STATUS_NORMAL) {
850
-            return ResponseBean.error("置业顾问不存在或已被注销", ResponseBean.ERROR_UNAVAILABLE);
875
+        if (null == userInfo || CommConstant.STATUS_NORMAL != userInfo.getStatus()) {
876
+            responseBean.addError("置业顾问不存在或已被注销");
877
+            return responseBean;
878
+        }
879
+
880
+        // 2.根据customerId获取personId
881
+        QueryWrapper<TaRecommendCustomer> customerQueryWrapper = new QueryWrapper<>();
882
+        customerQueryWrapper.eq("customer_id", customerId);
883
+        customerQueryWrapper.isNull("realty_consultant");
884
+        TaRecommendCustomer customerInfo = taRecommendCustomerMapper.selectOne(customerQueryWrapper);
885
+        if (customerInfo == null) {
886
+            logger.info("公客分配置业顾问 customerInfo为空");
887
+            responseBean.addError("分配客户失败");
888
+            return responseBean;
889
+        }
890
+
891
+        // 3.判断是否有buildingId,有则直接更新数据
892
+        if (!StringUtils.isEmpty(customerInfo.getBuildingId())) {
893
+            logger.info("公客分配置业顾问 customer={}", JSONObject.toJSONString(customerInfo));
894
+            customerInfo.setRealtyConsultant(userInfo.getUserId().toString());
895
+            responseBean.addSuccess(taRecommendCustomerMapper.updateById(customerInfo));
896
+            return responseBean;
897
+        }
898
+
899
+        // 4.校验公客是否已经是分配项目下的私客
900
+        QueryWrapper<TaRecommendCustomer> customerQueryWrapper2 = new QueryWrapper<>();
901
+        customerQueryWrapper2.eq("org_id", orgId);
902
+        customerQueryWrapper2.eq("person_id", customerInfo.getPersonId());
903
+        customerQueryWrapper2.eq("building_id", taPersonBuilding.getBuildingId());
904
+        customerQueryWrapper2.eq("status", CommConstant.CUSTOMER_REPORT);
905
+        customerQueryWrapper2.eq("verify_status", CommConstant.VERIFY_AGREE);
906
+        customerQueryWrapper2.isNotNull("realty_consultant");
907
+        TaRecommendCustomer customerInfo2 = taRecommendCustomerMapper.selectOne(customerQueryWrapper2);
908
+        if (customerInfo2 != null) {
909
+            logger.info("客户已在当前项目私客中,可以继续分配给其他项目");
910
+            responseBean.addError("客户已在当前项目私客中,可以继续分配给其他项目");
911
+            return responseBean;
912
+        }
913
+
914
+        // 5.无buildingId,新增一条私客数据
915
+        TaPerson taPerson = taPersonMapper.getById(customerInfo.getPersonId());
916
+        if (taPerson == null) {
917
+            logger.info("公客分配置业顾问 taPerson为空");
918
+            responseBean.addError("分配客户失败");
919
+            return responseBean;
851 920
         }
852 921
 
853 922
         TaRecommendCustomer taRecommendCustomer = new TaRecommendCustomer();
@@ -867,16 +936,16 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
867 936
         taRecommendCustomer.setEntryType(CommConstant.ENTRY_VERIFY);
868 937
         taRecommendCustomer.setVerifyStatus(CommConstant.VERIFY_AGREE);
869 938
         taRecommendCustomer.setStatus(CommConstant.CUSTOMER_REPORT);
870
-        taRecommendCustomer.setPersonId(personId);
871
-        taRecommendCustomer.setRecommendPerson(recommendPerson == null ? "" : recommendPerson.getRecommendPerson());
939
+        taRecommendCustomer.setPersonId(taPerson.getPersonId());
940
+        taRecommendCustomer.setRecommendPerson(taPerson.getRecommendPerson());
872 941
 
873 942
         int row = taRecommendCustomerMapper.insert(taRecommendCustomer);
874 943
         if (row < 1) {
875
-            return ResponseBean.error("分配客户失败", ResponseBean.ERROR_UNAVAILABLE);
944
+            responseBean.addError("分配客户失败");
945
+            return responseBean;
876 946
         }
877
-
878
-        return ResponseBean.success(taRecommendCustomer);
879
-
947
+        responseBean.addSuccess(taRecommendCustomer);
948
+        return responseBean;
880 949
     }
881 950
 
882 951
     private List<TaRecommendCustomer> getCustomerByPhone(String phone, Integer orgId) {
@@ -931,8 +1000,8 @@ public class TaRecommendCustomerServiceImpl extends ServiceImpl<TaRecommendCusto
931 1000
     }
932 1001
 
933 1002
     @Override
934
-    public List<AgentsRecommendCustomer> getIndependentAgentsExport(Integer orgId, Integer pageCode, Integer pageSize) {
935
-        return taRecommendCustomerMapper.getIndependentAgentsExport(orgId, pageCode, pageSize);
1003
+    public List<AgentsRecommendCustomer> getIndependentAgentsExport(String name, String tel, String channelId, Integer orgId, Integer pageCode, Integer pageSize) {
1004
+        return taRecommendCustomerMapper.getIndependentAgentsExport(name, tel, channelId, orgId, pageCode, pageSize);
936 1005
     }
937 1006
 
938 1007
     /**

+ 14
- 8
src/main/resources/mapper/ActivityManageMapper.xml View File

@@ -49,7 +49,7 @@
49 49
         ) as visit_num,
50 50
 
51 51
         -- 分享新增用户
52
-        (select count(*) from ta_share_person_from f
52
+        (select count(DISTINCT f.person_id) from ta_share_person_from f
53 53
         where	f.org_id = a.org_id
54 54
         <choose>
55 55
             <when test=" type == 'live'">
@@ -65,7 +65,7 @@
65 65
         ) as new_persons,
66 66
 
67 67
         -- 分享新增客户
68
-        (select count(*) from ta_share_person_from g
68
+        (select count(DISTINCT g.person_id) from ta_share_person_from g
69 69
         inner join ta_person h on h.person_id = g.person_id
70 70
         where	g.org_id = a.org_id
71 71
         <choose>
@@ -80,7 +80,8 @@
80 80
         AND g.`status` > 0
81 81
         AND g.is_first_time = 1
82 82
         AND h.phone is not null
83
-        ) as new_customers
83
+        ) as new_customers,
84
+        a.activityName
84 85
 
85 86
         from (
86 87
             <if test=" type == 'activity' ">
@@ -90,7 +91,8 @@
90 91
                     s.building_name,
91 92
                     t.dynamic_id AS target_id,
92 93
                     t.title AS target_name,
93
-                    'activity' AS target_type
94
+                    'activity' AS target_type,
95
+                    t.title as activityName
94 96
                 FROM
95 97
                     ta_building_dynamic t
96 98
                 LEFT JOIN ta_building s ON s.building_id = t.building_id
@@ -106,7 +108,8 @@
106 108
                     s.building_name,
107 109
                     t.drainage_id AS target_id,
108 110
                     t.`name` AS target_name,
109
-                    'h5' AS target_type
111
+                    'h5' AS target_type,
112
+                    t.name as activityName
110 113
                 FROM
111 114
                   ta_drainage t
112 115
                 LEFT JOIN ta_building s ON s.building_id = t.building_id
@@ -122,7 +125,8 @@
122 125
                     s.building_name,
123 126
                     t.help_activity_id AS target_id,
124 127
                     t.title AS target_name,
125
-                    'help' AS target_type
128
+                    'help' AS target_type,
129
+                    t.title as activityName
126 130
                 FROM
127 131
                     ta_help_activity t
128 132
                 LEFT JOIN ta_building s ON s.building_id = t.building_id
@@ -138,7 +142,8 @@
138 142
                     s.building_name,
139 143
                     t.group_activity_id AS target_id,
140 144
                     t.activity_name AS target_name,
141
-                    'group' AS target_type
145
+                    'group' AS target_type,
146
+                    t.activity_name as activityName
142 147
                 FROM
143 148
                     ta_share_activity t
144 149
                 LEFT JOIN ta_building s ON s.building_id = t.building_id
@@ -154,7 +159,8 @@
154 159
                     s.building_name,
155 160
                     t.live_activity_id AS target_id,
156 161
                     t.live_activity_title AS target_name,
157
-                    'live' AS target_type
162
+                    'live' AS target_type,
163
+                    t.live_activity_title as activityName
158 164
                 FROM
159 165
                     ta_live_activity t
160 166
                 LEFT JOIN ta_building s ON s.building_id = t.building_id

+ 748
- 748
src/main/resources/mapper/TaBuildingMapper.xml
File diff suppressed because it is too large
View File


+ 21
- 3
src/main/resources/mapper/TaChannelMapper.xml View File

@@ -31,14 +31,13 @@
31 31
     <select id="pageTaChannel" resultType="com.huiju.estateagents.entity.TaChannel">
32 32
         SELECT
33 33
         c.*,
34
-        COUNT(cp.person_id) AS brokerCount,
35
-        COUNT(rc.person_id) AS recommendCount,
34
+        count(tp.person_id) AS brokerCount,
36 35
         (SELECT COUNT(p.recommend_agent ) from ta_person p WHERE cp.person_id = p.recommend_agent) AS inviteCount,
37 36
         cp.person_id
38 37
         FROM
39 38
         ta_channel c
40 39
         LEFT JOIN ta_channel_person cp ON c.channel_id = cp.channel_id
41
-        LEFT JOIN ta_recommend_customer rc ON cp.person_id = rc.person_id AND rc.`status` = 1
40
+        LEFT JOIN ta_person tp ON cp.person_id = tp.person_id 	AND tp.person_type = 'estate agent' 	AND cp.STATUS = 1
42 41
         <where>
43 42
             <if test="channelId != null and channelId != ''">
44 43
                 c.channel_id = #{channelId}
@@ -47,4 +46,23 @@
47 46
         </where>
48 47
         GROUP BY c.channel_id
49 48
     </select>
49
+
50
+    <select id="recommendCount" resultType="com.huiju.estateagents.entity.TaChannel">
51
+        SELECT
52
+            c.channel_id,
53
+            COUNT( rc.recommend_person ) AS recommendCount
54
+        FROM
55
+        ta_channel c
56
+        LEFT JOIN ta_channel_person cp ON c.channel_id = cp.channel_id and cp.`status` = 1
57
+        LEFT JOIN ta_person t on cp.person_id = t.person_id and t.person_type = 'estate agent'
58
+        LEFT JOIN ta_recommend_customer rc ON t.person_id = rc.recommend_person AND rc.verify_status = 1
59
+        <where>
60
+            <if test="channelId != null and channelId != ''">
61
+                c.channel_id = #{channelId}
62
+            </if>
63
+            and c.org_id = #{orgId}
64
+        </where>
65
+        GROUP BY c.channel_id
66
+    </select>
67
+
50 68
 </mapper>

+ 728
- 722
src/main/resources/mapper/TaPersonMapper.xml
File diff suppressed because it is too large
View File


+ 446
- 446
src/main/resources/mapper/TaPersonVisitRecordMapper.xml View File

@@ -1,446 +1,446 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
-<mapper namespace="com.huiju.estateagents.mapper.TaPersonVisitRecordMapper">
4
-
5
-    <sql id="columnSql">
6
-        <trim suffixOverrides=",">
7
-            t.record_id,
8
-            t.person_id,
9
-            c.person_type,
10
-            t.visit_time,
11
-            t.leave_time,
12
-            t.visit_duration,
13
-            t.event,
14
-            t.data,
15
-            t.activity,
16
-            t.org_id,
17
-            t.building_id,
18
-            t.event_type,
19
-            t.target_id,
20
-            t.consultant_id,
21
-            t.share_person_id,
22
-        </trim>
23
-    </sql>
24
-
25
-    <select id="visitRecordByPersonId" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
26
-        select
27
-            t.* ,
28
-            b.parent_type_id from ta_person_visit_record t
29
-        left join td_biz_event_type b on t.event_type = b.type_id
30
-        where t.person_id = #{personId}
31
-        <if test="personBuildingList != null and personBuildingList.size > 0">
32
-            AND (b.parent_type_id = 'public' or t.building_id in
33
-            <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
34
-                #{personBuilding.buildingId}
35
-            </foreach>
36
-            )
37
-        </if>
38
-        <if test="buildingId != null and buildingId != ''">
39
-            AND (b.parent_type_id = 'public' or t.building_id = #{buildingId} )
40
-        </if>
41
-        order by t.visit_time desc
42
-    </select>
43
-
44
-    <select id="selectAll" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
45
-        SELECT
46
-            tpvr.record_id as recordId,
47
-            tpvr.person_id as personId,
48
-            tpvr.person_type as personType,
49
-            tpvr.building_id as buildingId,
50
-            tpvr.activity as activity,
51
-            tpvr.event as event,
52
-            tpvr.event_type as eventType,
53
-            tpvr.visit_duration as visitDuration,
54
-            (SELECT MIN(t.visit_time) FROM ta_person_visit_record t WHERE t.person_id = tpvr.person_id and t.event = tpvr.event and t.org_id = #{orgId} ) as visitTime,
55
-            (SELECT MAX(t.leave_time) FROM ta_person_visit_record t WHERE t.person_id = tpvr.person_id and t.event = tpvr.event and t.org_id = #{orgId} ) as leaveTime,
56
-            ifnull(tp.name, tp.nickname) as userName,
57
-            tbe.event_name as eventName,
58
-            COUNT(1) as accessCount
59
-        FROM
60
-            ta_person_visit_record tpvr
61
-            LEFT JOIN ta_person tp ON tpvr.person_id = tp.person_id
62
-            LEFT JOIN td_biz_event tbe on tpvr.event = tbe.event_code
63
-            <trim prefix="where" prefixOverrides="and | or">
64
-                tpvr.org_id = #{orgId}
65
-                and tp.org_id = #{orgId}
66
-                <if test="startDate != null and endDate != null">
67
-                    and tpvr.visit_time between #{startDate} and #{endDate}
68
-                </if>
69
-                <if test="buildingId != null and buildingId != ''">
70
-                    and tpvr.building_id = #{buildingId}
71
-                </if>
72
-                <if test="eventType != null and eventType != ''">
73
-                    and tpvr.event_type = #{eventType}
74
-                </if>
75
-                <if test="event != null and event != ''">
76
-                    and tpvr.event = #{event}
77
-                </if>
78
-                <if test="activity != null and activity != ''">
79
-                    and tpvr.activity = #{activity}
80
-                </if>
81
-            </trim>
82
-
83
-        GROUP BY tpvr.person_id, tpvr.event
84
-        ORDER BY 	accessCount DESC,tpvr.visit_time DESC
85
-    </select>
86
-    <select id="getPersonVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
87
-        SELECT
88
-            t.*,
89
-            b.building_name
90
-        FROM
91
-            ta_person_visit_record t
92
-            LEFT JOIN ta_building b ON t.building_id = b.building_id
93
-        WHERE
94
-            t.person_id = #{personId}
95
-        ORDER BY
96
-            t.visit_time DESC
97
-    </select>
98
-
99
-    <select id="getDurationByPersonId" resultType="java.lang.Integer">
100
-        select SUM(visit_duration) from ta_person_visit_record where person_id = #{personId}
101
-    </select>
102
-
103
-    <select id="getFirstVisitTimeByPersonId" resultType="java.time.LocalDateTime">
104
-        select visit_time from ta_person_visit_record where person_id = #{personId} order by visit_time asc limit 1
105
-    </select>
106
-    <select id="getWxVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
107
-        SELECT
108
-            t.* ,
109
-	        p.`name` as user_name,
110
-	        p.`nickname` as nickname,
111
-	        p.avatarurl,
112
-	        d.name as activity_name,
113
-	        d.create_date
114
-        FROM
115
-            ( SELECT * FROM ta_person_visit_record WHERE org_id = #{orgId} and event_type = #{eventType} AND consultant_id = #{userId} and person_id != #{personId} ORDER BY visit_time DESC LIMIT 999) t
116
-            left JOIN ta_person p on t.person_id = p.person_id
117
-            LEFT join ta_drainage d on t.target_id = d.drainage_id
118
-        GROUP BY
119
-            t.person_id
120
-        ORDER BY
121
-	        t.visit_time DESC
122
-    </select>
123
-
124
-    <select id="getWxActivityVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
125
-        SELECT
126
-            t.share_from_id, t.share_person as consultant_id, t.share_person_type, t.person_id, t.target_type, t.target_id, t.create_date as visit_time, t.org_id ,t.building_id, t.status, t.is_first_time,
127
-	        p.`name` as user_name,
128
-	        p.`nickname` as nickname,
129
-	        p.avatarurl
130
-        FROM
131
-            ( SELECT * FROM ta_share_person_from WHERE org_id = #{orgId} and target_id = #{targetId} AND (share_person = #{userId} or share_person = #{personId}) and target_type = #{eventType} ORDER BY create_date DESC LIMIT 999) t
132
-            left JOIN ta_person p on t.person_id = p.person_id
133
-            where t.person_id != #{personId}
134
-        GROUP BY
135
-            t.person_id
136
-        ORDER BY
137
-	        t.create_date DESC
138
-    </select>
139
-
140
-
141
-    <select id="getWxVisitRecordActivityList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
142
-            SELECT
143
-                t.*,
144
-                d.NAME AS activity_name,
145
-                d.create_date
146
-            FROM
147
-                ( SELECT * FROM ta_person_visit_record WHERE event_type = #{eventType} AND consultant_id = #{userId} AND person_id = #{personId} ORDER BY visit_time DESC ) t
148
-                LEFT JOIN ta_drainage d ON t.target_id = d.drainage_id
149
-            GROUP BY
150
-                t.target_id
151
-            ORDER BY
152
-	            t.visit_time DESC
153
-    </select>
154
-
155
-    <select id="getDrainageVisitRecord" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
156
-        select * from (
157
-            select
158
-            t.share_person as share_person_id,
159
-            t.person_id,
160
-            c.person_type,
161
-            t.create_date as visit_time,
162
-            t.target_type as event_type,
163
-            t.target_id as target_id,
164
-            b.name as drainageName,
165
-            d.building_name as buildingName,
166
-            tn.news_name as newsName,
167
-            tha.title as helpActivityName,
168
-            tsa.activity_name as groupActivityName,
169
-            tbd.title as activityName,
170
-            b.drainage_id
171
-            from ta_share_person_from t
172
-            left join ta_drainage b on t.target_id = b.drainage_id
173
-            left join ta_building d on t.target_id = d.building_id
174
-            left join ta_news tn on t.target_id = tn.news_id
175
-            left join ta_help_activity tha on t.target_id = tha.help_activity_id
176
-            left join ta_share_activity tsa on t.target_id = tsa.group_activity_id
177
-            left join ta_building_dynamic tbd on t.target_id = tbd.dynamic_id
178
-            left join ta_person c on t.org_id = c.org_id and (t.share_person = c.person_id or t.share_person = c.user_id)
179
-            where t.org_id = #{orgId}
180
-            and t.target_type in ('h5_share','group_share','help_share','news_share','dynamic_share','building_share')
181
-            <if test="eventType !=null and eventType != ''">
182
-                and t.target_type = #{eventType}
183
-            </if>
184
-            <if test="activityName !=null and activityName != ''">
185
-                and (
186
-                (b.name like concat('%',#{activityName},'%') and t.target_type = 'h5_share')or (d.name like concat('%',#{activityName},'%') and t.target_type = 'building_share') or (tn.news_name like concat('%',#{activityName},'%') and t.target_type = 'news_share')
187
-                or (tha.title like concat( '%', #{activityName}, '%' ) and t.target_type = 'help_share')  or (tsa.activity_name like concat('%',#{activityName},'%') and t.target_type = 'group_share') or (tbd.title like concat('%',#{activityName},'%') and t.target_type = 'dynamic_share')
188
-                )
189
-            </if>
190
-            <if test="shareName !=null and shareName != ''">
191
-                and c.nickname like concat('%',#{shareName},'%')
192
-            </if>
193
-            <if test="shareTel !=null and shareTel != ''">
194
-                and c.phone = #{shareTel}
195
-            </if>
196
-            <if test="personType == 'Realty Consultant'">
197
-                and c.person_type = 'Realty Consultant'
198
-            </if>
199
-            <if test="personType == 'customer'">
200
-                and c.person_type != 'Realty Consultant'
201
-            </if>
202
-            <if test="buildingId !=null and buildingId != ''">
203
-                and d.building_id = #{buildingId}
204
-            </if>
205
-            <if test="personBuildingList != null and personBuildingList.size > 0">
206
-                AND d.building_id in
207
-                <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
208
-                    #{personBuilding.buildingId}
209
-                </foreach>
210
-            </if>
211
-            order by t.create_date desc
212
-        ) t
213
-        group by t.person_id, t.target_id,t.event_type, t.share_person_id
214
-        order by t.visit_time desc
215
-    </select>
216
-
217
-    <select id="getConsultantShareInfoList" resultType="com.huiju.estateagents.entity.TaConsultantInfo">
218
-        select * From (
219
-            select * from (
220
-                select
221
-                t.be_share as target_id,
222
-                a.url as activity_img,
223
-                a.building_name as activity_name,
224
-                a.building_name,
225
-                a.address,
226
-                a.price,
227
-                a.building_type_id,
228
-                t.tagert_type as eventType,
229
-				t.create_date as visit_time
230
-                from ta_share t
231
-                left join (select b.url, a.building_name,a.address,a.price,a.building_id,a.building_type_id from ta_building a left join ta_building_img b on a.building_id = b.building_id where b.img_type = 'list') a on t.be_share = a.building_id
232
-                where t.tagert_type = 'project'
233
-                and t.person_id = #{personId} order by t.create_date desc limit 9999
234
-            ) t
235
-            group by t.target_id
236
-
237
-        union all
238
-
239
-        select * from (
240
-        select
241
-        t.be_share as target_id,
242
-        b.list_img_url as activity_img,
243
-        b.title as activity_name,
244
-        '1' as price,
245
-        '2' as building_name,
246
-        '3' as address,
247
-        1 as building_type_id,
248
-        t.tagert_type as eventType,
249
-		t.create_date as visit_time
250
-        from ta_share t
251
-        left join ta_building_dynamic b on t.be_share = b.dynamic_id
252
-        where t.tagert_type = 'activity'
253
-        and t.person_id = #{personId} order by t.create_date desc limit 9999
254
-        ) t
255
-        group by t.target_id
256
-
257
-        union all
258
-
259
-        select * from (
260
-        select
261
-        t.be_share as target_id,
262
-        c.list_img as activity_img,
263
-        c.title as activity_name,
264
-        '1' as price,
265
-        '2' as building_name,
266
-        '3' as address,
267
-        1 as building_type_id,
268
-        t.tagert_type as eventType,
269
-		t.create_date as visit_time
270
-        from ta_share t
271
-        left join ta_help_activity c on t.be_share = c.help_activity_id
272
-        where t.tagert_type = 'help'
273
-        and t.person_id = #{personId} order by t.create_date desc limit 9999
274
-        ) t
275
-        group by t.target_id
276
-
277
-        union all
278
-
279
-        select * from (
280
-        select
281
-        t.be_share as target_id,
282
-        d.list_img as activity_img,
283
-        d.activity_name as activity_name,
284
-        '1' as price,
285
-        '2' as building_name,
286
-        '3' as address,
287
-        1 as building_type_id,
288
-        t.tagert_type as eventType,
289
-		t.create_date as visit_time
290
-        from ta_share t
291
-        left join ta_share_activity d on t.be_share = d.group_activity_id
292
-        where t.tagert_type = 'group'
293
-        and t.person_id = #{personId} order by t.create_date desc limit 9999
294
-        ) t
295
-		group by t.target_id
296
-
297
-        union all
298
-
299
-        select * from (
300
-        select
301
-        t.be_share as target_id,
302
-        e.news_img as activity_img,
303
-        e.news_name as activity_name,
304
-        '1' as price,
305
-        '2' as building_name,
306
-        '3' as address,
307
-        1 as building_type_id,
308
-        t.tagert_type as eventType,
309
-		t.create_date as visit_time
310
-        from ta_share t
311
-        left join ta_news e on t.be_share = e.news_id
312
-        where t.tagert_type = 'news'
313
-        and t.person_id = #{personId} order by t.create_date desc limit 9999
314
-        ) t
315
-        group by t.target_id
316
-
317
-        union all
318
-
319
-        select * from (
320
-            select
321
-            t.be_share as target_id,
322
-            f.share_img as activity_img,
323
-            f.`name` as activity_name,
324
-            '1' as price,
325
-            '2' as building_name,
326
-            '3' as address,
327
-            1 as building_type_id,
328
-			t.tagert_type as eventType,
329
-			t.create_date as visit_time
330
-            from ta_share t
331
-            left join ta_drainage f on t.be_share = f.drainage_id
332
-            where t.tagert_type = 'h5'
333
-            and t.person_id = #{personId} order by t.create_date desc limit 9999
334
-            ) t
335
-            group by t.target_id
336
-         union all
337
-
338
-        select * from (
339
-            select
340
-            t.be_share as target_id,
341
-            g.aerial_view_img as activity_img,
342
-            g.sales_batch_name as activity_name,
343
-            '1' as price,
344
-            '2' as building_name,
345
-            '3' as address,
346
-            1 as building_type_id,
347
-			left(t.tagert_type,5) as eventType,
348
-			t.create_date as visit_time
349
-            from ta_share t
350
-            left join ta_sales_batch g on t.be_share = g.sales_batch_id
351
-            where t.tagert_type like CONCAT('house' , '%')
352
-            and t.person_id = #{personId} order by t.create_date desc limit 9999
353
-            ) t
354
-            group by t.target_id
355
-
356
-			union all
357
-				select * from (
358
-					SELECT
359
-						t.be_share AS target_id,
360
-						g.list_img AS activity_img,
361
-						g.live_activity_title AS activity_name,
362
-						'1' AS price,
363
-						'2' AS building_name,
364
-						'3' AS address,
365
-						1 AS building_type_id,
366
-						LEFT ( t.tagert_type, 4 ) AS eventType,
367
-						t.create_date AS visit_time
368
-					FROM
369
-						ta_share t
370
-						LEFT JOIN ta_live_activity g ON t.be_share = g.live_activity_id
371
-					WHERE
372
-						t.tagert_type LIKE CONCAT( 'live', '%' )
373
-							AND t.person_id = #{personId}
374
-						ORDER BY
375
-							t.create_date DESC
376
-							LIMIT 9999
377
-					) t
378
-				group by t.target_id
379
-        ) t
380
-        order by t.visit_time desc
381
-    </select>
382
-
383
-    <select id="countShareNumByEventType" resultType="java.lang.Integer">
384
-        select count(DISTINCT t.person_id)  from ta_share_person_from t
385
-        left join ta_person a on t.person_id = a.person_id
386
-        where
387
-        (t.share_person = #{personId}
388
-        <if test="userId != null and userId != ''">
389
-            or t.share_person = #{userId}
390
-        </if>
391
-        )
392
-        and t.org_id = #{orgId}
393
-        and t.target_type = #{eventType}
394
-        and t.target_id = #{targetId}
395
-        and t.status = 1
396
-        and t.person_id != #{personId}
397
-        group by t.target_type
398
-    </select>
399
-
400
-    <select id="selectData" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
401
-		select t.share_person_id, t.target_id,
402
-		if(t.target_type = 'help' and t.event_type = 'activity', 'help', if(t.target_type = 'group' and t.event_type = 'activity' , 'group', t.event_type)) as target_type,
403
-		a.nickname, a.avatarurl FROM
404
-        ta_person_visit_record t
405
-        LEFT JOIN ta_person a ON t.share_person_id = a.person_id
406
-        LEFT JOIN ta_share_person_from b ON t.target_id = b.target_id  and t.event_type = b.target_type + '_share'
407
-        WHERE
408
-        (
409
-            ( t.consultant_id IS NOT NULL AND t.consultant_id != '' )
410
-            OR ( t.share_person_id IS NOT NULL AND t.share_person_id != '' )
411
-        )
412
-        AND t.person_id != t.share_person_id
413
-        AND t.`event` = 'detail'
414
-        AND ( t.share_person_id != b.share_person OR t.consultant_id != b.share_person )
415
-        GROUP BY
416
-        t.target_id, t.event_type;
417
-    </select>
418
-
419
-    <select id="selectTapersonFromShare" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
420
-        select t.share_person_id, if (t.consultant_id != '' and t.consultant_id is not null, 'Realty Consultant', 'customer') as person_type, t.person_id, b.target_type, t.target_id,t.org_id, t.building_id  From ta_person_visit_record t
421
-        left join ta_person a on t.share_person_id = a.person_id
422
-        LEFT JOIN ta_share_person_from b ON t.target_id = b.target_id  and t.event_type = b.target_type + '_share'
423
-        where
424
-        (
425
-            ( t.consultant_id IS NOT NULL AND t.consultant_id != '' )
426
-            OR ( t.share_person_id IS NOT NULL AND t.share_person_id != '' )
427
-            )
428
-            AND t.person_id != t.share_person_id
429
-            AND t.`event` = 'detail'
430
-            AND ( t.share_person_id != b.share_person OR t.consultant_id != b.share_person )
431
-        GROUP BY
432
-            t.target_id, t.event_type;
433
-    </select>
434
-
435
-    <select id="selectTodayVisitCount" resultType="java.lang.Integer">
436
-        SELECT
437
-        COUNT(1) as visit_count
438
-        FROM
439
-        ta_person_visit_record tp
440
-        where tp.org_id = #{orgId} AND
441
-        tp.event  = 'index'
442
-        AND DATE_FORMAT(tp.visit_time,'%Y-%m-%d') = DATE_FORMAT(#{nowDate},'%Y-%m-%d')
443
-    </select>
444
-
445
-
446
-</mapper>
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.huiju.estateagents.mapper.TaPersonVisitRecordMapper">
4
+
5
+    <sql id="columnSql">
6
+        <trim suffixOverrides=",">
7
+            t.record_id,
8
+            t.person_id,
9
+            c.person_type,
10
+            t.visit_time,
11
+            t.leave_time,
12
+            t.visit_duration,
13
+            t.event,
14
+            t.data,
15
+            t.activity,
16
+            t.org_id,
17
+            t.building_id,
18
+            t.event_type,
19
+            t.target_id,
20
+            t.consultant_id,
21
+            t.share_person_id,
22
+        </trim>
23
+    </sql>
24
+
25
+    <select id="visitRecordByPersonId" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
26
+        select
27
+            t.* ,
28
+            b.parent_type_id from ta_person_visit_record t
29
+        left join td_biz_event_type b on t.event_type = b.type_id
30
+        where t.person_id = #{personId}
31
+        <if test="personBuildingList != null and personBuildingList.size > 0">
32
+            AND (b.parent_type_id = 'public' or t.building_id in
33
+            <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
34
+                #{personBuilding.buildingId}
35
+            </foreach>
36
+            )
37
+        </if>
38
+        <if test="buildingId != null and buildingId != ''">
39
+            AND (b.parent_type_id = 'public' or t.building_id = #{buildingId} )
40
+        </if>
41
+        order by t.visit_time desc
42
+    </select>
43
+
44
+    <select id="selectAll" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
45
+        SELECT
46
+            tpvr.record_id as recordId,
47
+            tpvr.person_id as personId,
48
+            tpvr.person_type as personType,
49
+            tpvr.building_id as buildingId,
50
+            tpvr.activity as activity,
51
+            tpvr.event as event,
52
+            tpvr.event_type as eventType,
53
+            tpvr.visit_duration as visitDuration,
54
+            (SELECT MIN(t.visit_time) FROM ta_person_visit_record t WHERE t.person_id = tpvr.person_id and t.event = tpvr.event and t.org_id = #{orgId} ) as visitTime,
55
+            (SELECT MAX(t.leave_time) FROM ta_person_visit_record t WHERE t.person_id = tpvr.person_id and t.event = tpvr.event and t.org_id = #{orgId} ) as leaveTime,
56
+            ifnull(tp.name, tp.nickname) as userName,
57
+            tbe.event_name as eventName,
58
+            COUNT(1) as accessCount
59
+        FROM
60
+            ta_person_visit_record tpvr
61
+            LEFT JOIN ta_person tp ON tpvr.person_id = tp.person_id
62
+            LEFT JOIN td_biz_event tbe on tpvr.event = tbe.event_code
63
+            <trim prefix="where" prefixOverrides="and | or">
64
+                tpvr.org_id = #{orgId}
65
+                and tp.org_id = #{orgId}
66
+                <if test="startDate != null and endDate != null">
67
+                    and tpvr.visit_time between #{startDate} and #{endDate}
68
+                </if>
69
+                <if test="buildingId != null and buildingId != ''">
70
+                    and tpvr.building_id = #{buildingId}
71
+                </if>
72
+                <if test="eventType != null and eventType != ''">
73
+                    and tpvr.event_type = #{eventType}
74
+                </if>
75
+                <if test="event != null and event != ''">
76
+                    and tpvr.event = #{event}
77
+                </if>
78
+                <if test="activity != null and activity != ''">
79
+                    and tpvr.activity = #{activity}
80
+                </if>
81
+            </trim>
82
+
83
+        GROUP BY tpvr.person_id, tpvr.event
84
+        ORDER BY 	accessCount DESC,tpvr.visit_time DESC
85
+    </select>
86
+    <select id="getPersonVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
87
+        SELECT
88
+            t.*,
89
+            b.building_name
90
+        FROM
91
+            ta_person_visit_record t
92
+            LEFT JOIN ta_building b ON t.building_id = b.building_id
93
+        WHERE
94
+            t.person_id = #{personId}
95
+        ORDER BY
96
+            t.visit_time DESC
97
+    </select>
98
+
99
+    <select id="getDurationByPersonId" resultType="java.lang.Integer">
100
+        select SUM(visit_duration) from ta_person_visit_record where person_id = #{personId}
101
+    </select>
102
+
103
+    <select id="getFirstVisitTimeByPersonId" resultType="java.time.LocalDateTime">
104
+        select visit_time from ta_person_visit_record where person_id = #{personId} order by visit_time asc limit 1
105
+    </select>
106
+    <select id="getWxVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
107
+        SELECT
108
+            t.* ,
109
+	        p.`name` as user_name,
110
+	        p.`nickname` as nickname,
111
+	        p.avatarurl,
112
+	        d.name as activity_name,
113
+	        d.create_date
114
+        FROM
115
+            ( SELECT * FROM ta_person_visit_record WHERE org_id = #{orgId} and event_type = #{eventType} AND consultant_id = #{userId} and person_id != #{personId} ORDER BY visit_time DESC LIMIT 999) t
116
+            left JOIN ta_person p on t.person_id = p.person_id
117
+            LEFT join ta_drainage d on t.target_id = d.drainage_id
118
+        GROUP BY
119
+            t.person_id
120
+        ORDER BY
121
+	        t.visit_time DESC
122
+    </select>
123
+
124
+    <select id="getWxActivityVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
125
+        SELECT
126
+            t.share_from_id, t.share_person as consultant_id, t.share_person_type, t.person_id, t.target_type, t.target_id, t.create_date as visit_time, t.org_id ,t.building_id, t.status, t.is_first_time,
127
+	        p.`name` as user_name,
128
+	        p.`nickname` as nickname,
129
+	        p.avatarurl
130
+        FROM
131
+            ( SELECT * FROM ta_share_person_from WHERE org_id = #{orgId} and target_id = #{targetId} AND (share_person = #{userId} or share_person = #{personId}) and target_type = #{eventType} ORDER BY create_date DESC LIMIT 999) t
132
+            left JOIN ta_person p on t.person_id = p.person_id
133
+            where t.person_id != #{personId}
134
+        GROUP BY
135
+            t.person_id
136
+        ORDER BY
137
+	        t.create_date DESC
138
+    </select>
139
+
140
+
141
+    <select id="getWxVisitRecordActivityList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
142
+            SELECT
143
+                t.*,
144
+                d.NAME AS activity_name,
145
+                d.create_date
146
+            FROM
147
+                ( SELECT * FROM ta_person_visit_record WHERE event_type = #{eventType} AND consultant_id = #{userId} AND person_id = #{personId} ORDER BY visit_time DESC ) t
148
+                LEFT JOIN ta_drainage d ON t.target_id = d.drainage_id
149
+            GROUP BY
150
+                t.target_id
151
+            ORDER BY
152
+	            t.visit_time DESC
153
+    </select>
154
+
155
+    <select id="getDrainageVisitRecord" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
156
+        select * from (
157
+            select
158
+            t.share_person as share_person_id,
159
+            t.person_id,
160
+            c.person_type,
161
+            t.create_date as visit_time,
162
+            t.target_type as event_type,
163
+            t.target_id as target_id,
164
+            b.name as drainageName,
165
+            d.building_name as buildingName,
166
+            tn.news_name as newsName,
167
+            tha.title as helpActivityName,
168
+            tsa.activity_name as groupActivityName,
169
+            tbd.title as activityName,
170
+            b.drainage_id
171
+            from ta_share_person_from t
172
+            left join ta_drainage b on t.target_id = b.drainage_id
173
+            left join ta_building d on t.target_id = d.building_id
174
+            left join ta_news tn on t.target_id = tn.news_id
175
+            left join ta_help_activity tha on t.target_id = tha.help_activity_id
176
+            left join ta_share_activity tsa on t.target_id = tsa.group_activity_id
177
+            left join ta_building_dynamic tbd on t.target_id = tbd.dynamic_id
178
+            left join ta_person c on t.org_id = c.org_id and (t.share_person = c.person_id or t.share_person = c.user_id)
179
+            where t.org_id = #{orgId}
180
+            and t.target_type in ('h5_share','group_share','help_share','news_share','dynamic_share','building_share')
181
+            <if test="eventType !=null and eventType != ''">
182
+                and t.target_type = #{eventType}
183
+            </if>
184
+            <if test="activityName !=null and activityName != ''">
185
+                and (
186
+                (b.name like concat('%',#{activityName},'%') and t.target_type = 'h5_share')or (d.name like concat('%',#{activityName},'%') and t.target_type = 'building_share') or (tn.news_name like concat('%',#{activityName},'%') and t.target_type = 'news_share')
187
+                or (tha.title like concat( '%', #{activityName}, '%' ) and t.target_type = 'help_share')  or (tsa.activity_name like concat('%',#{activityName},'%') and t.target_type = 'group_share') or (tbd.title like concat('%',#{activityName},'%') and t.target_type = 'dynamic_share')
188
+                )
189
+            </if>
190
+            <if test="shareName !=null and shareName != ''">
191
+                and c.nickname like concat('%',#{shareName},'%')
192
+            </if>
193
+            <if test="shareTel !=null and shareTel != ''">
194
+                and c.phone = #{shareTel}
195
+            </if>
196
+            <if test="personType == 'Realty Consultant'">
197
+                and c.person_type = 'Realty Consultant'
198
+            </if>
199
+            <if test="personType == 'customer'">
200
+                and c.person_type != 'Realty Consultant'
201
+            </if>
202
+            <if test="buildingId !=null and buildingId != ''">
203
+                and d.building_id = #{buildingId}
204
+            </if>
205
+            <if test="personBuildingList != null and personBuildingList.size > 0">
206
+                AND d.building_id in
207
+                <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
208
+                    #{personBuilding.buildingId}
209
+                </foreach>
210
+            </if>
211
+            order by t.create_date desc
212
+        ) t
213
+        group by t.person_id, t.target_id,t.event_type, t.share_person_id
214
+        order by t.visit_time desc
215
+    </select>
216
+
217
+    <select id="getConsultantShareInfoList" resultType="com.huiju.estateagents.entity.TaConsultantInfo">
218
+        select * From (
219
+            select * from (
220
+                select
221
+                t.be_share as target_id,
222
+                a.url as activity_img,
223
+                a.building_name as activity_name,
224
+                a.building_name,
225
+                a.address,
226
+                a.price,
227
+                a.building_type_id,
228
+                t.tagert_type as eventType,
229
+				t.create_date as visit_time
230
+                from ta_share t
231
+                left join (select b.url, a.building_name,a.address,a.price,a.building_id,a.building_type_id from ta_building a left join ta_building_img b on a.building_id = b.building_id where b.img_type = 'list') a on t.be_share = a.building_id
232
+                where t.tagert_type = 'project'
233
+                and t.person_id = #{personId} order by t.create_date desc limit 9999
234
+            ) t
235
+            group by t.target_id
236
+
237
+        union all
238
+
239
+        select * from (
240
+        select
241
+        t.be_share as target_id,
242
+        b.list_img_url as activity_img,
243
+        b.title as activity_name,
244
+        '1' as price,
245
+        '2' as building_name,
246
+        '3' as address,
247
+        1 as building_type_id,
248
+        t.tagert_type as eventType,
249
+		t.create_date as visit_time
250
+        from ta_share t
251
+        left join ta_building_dynamic b on t.be_share = b.dynamic_id
252
+        where t.tagert_type = 'activity'
253
+        and t.person_id = #{personId} order by t.create_date desc limit 9999
254
+        ) t
255
+        group by t.target_id
256
+
257
+        union all
258
+
259
+        select * from (
260
+        select
261
+        t.be_share as target_id,
262
+        c.list_img as activity_img,
263
+        c.title as activity_name,
264
+        '1' as price,
265
+        '2' as building_name,
266
+        '3' as address,
267
+        1 as building_type_id,
268
+        t.tagert_type as eventType,
269
+		t.create_date as visit_time
270
+        from ta_share t
271
+        left join ta_help_activity c on t.be_share = c.help_activity_id
272
+        where t.tagert_type = 'help'
273
+        and t.person_id = #{personId} order by t.create_date desc limit 9999
274
+        ) t
275
+        group by t.target_id
276
+
277
+        union all
278
+
279
+        select * from (
280
+        select
281
+        t.be_share as target_id,
282
+        d.list_img as activity_img,
283
+        d.activity_name as activity_name,
284
+        '1' as price,
285
+        '2' as building_name,
286
+        '3' as address,
287
+        1 as building_type_id,
288
+        t.tagert_type as eventType,
289
+		t.create_date as visit_time
290
+        from ta_share t
291
+        left join ta_share_activity d on t.be_share = d.group_activity_id
292
+        where t.tagert_type = 'group'
293
+        and t.person_id = #{personId} order by t.create_date desc limit 9999
294
+        ) t
295
+		group by t.target_id
296
+
297
+        union all
298
+
299
+        select * from (
300
+        select
301
+        t.be_share as target_id,
302
+        e.news_img as activity_img,
303
+        e.news_name as activity_name,
304
+        '1' as price,
305
+        '2' as building_name,
306
+        '3' as address,
307
+        1 as building_type_id,
308
+        t.tagert_type as eventType,
309
+		t.create_date as visit_time
310
+        from ta_share t
311
+        left join ta_news e on t.be_share = e.news_id
312
+        where t.tagert_type = 'news'
313
+        and t.person_id = #{personId} order by t.create_date desc limit 9999
314
+        ) t
315
+        group by t.target_id
316
+
317
+        union all
318
+
319
+        select * from (
320
+            select
321
+            t.be_share as target_id,
322
+            f.share_img as activity_img,
323
+            f.`name` as activity_name,
324
+            '1' as price,
325
+            '2' as building_name,
326
+            '3' as address,
327
+            1 as building_type_id,
328
+			t.tagert_type as eventType,
329
+			t.create_date as visit_time
330
+            from ta_share t
331
+            left join ta_drainage f on t.be_share = f.drainage_id
332
+            where t.tagert_type = 'h5'
333
+            and t.person_id = #{personId} order by t.create_date desc limit 9999
334
+            ) t
335
+            group by t.target_id
336
+         union all
337
+
338
+        select * from (
339
+            select
340
+            t.be_share as target_id,
341
+            g.aerial_view_img as activity_img,
342
+            g.sales_batch_name as activity_name,
343
+            '1' as price,
344
+            '2' as building_name,
345
+            '3' as address,
346
+            1 as building_type_id,
347
+			left(t.tagert_type,5) as eventType,
348
+			t.create_date as visit_time
349
+            from ta_share t
350
+            left join ta_sales_batch g on t.be_share = g.sales_batch_id
351
+            where t.tagert_type like CONCAT('house' , '%')
352
+            and t.person_id = #{personId} order by t.create_date desc limit 9999
353
+            ) t
354
+            group by t.target_id
355
+
356
+			union all
357
+				select * from (
358
+					SELECT
359
+						t.be_share AS target_id,
360
+						g.list_img AS activity_img,
361
+						g.live_activity_title AS activity_name,
362
+						'1' AS price,
363
+						'2' AS building_name,
364
+						'3' AS address,
365
+						1 AS building_type_id,
366
+						LEFT ( t.tagert_type, 4 ) AS eventType,
367
+						t.create_date AS visit_time
368
+					FROM
369
+						ta_share t
370
+						LEFT JOIN ta_live_activity g ON t.be_share = g.live_activity_id
371
+					WHERE
372
+						t.tagert_type LIKE CONCAT( 'live', '%' )
373
+							AND t.person_id = #{personId}
374
+						ORDER BY
375
+							t.create_date DESC
376
+							LIMIT 9999
377
+					) t
378
+				group by t.target_id
379
+        ) t
380
+        order by t.visit_time desc
381
+    </select>
382
+
383
+    <select id="countShareNumByEventType" resultType="java.lang.Integer">
384
+        select count(DISTINCT t.person_id)  from ta_share_person_from t
385
+        left join ta_person a on t.person_id = a.person_id
386
+        where
387
+        (t.share_person = #{personId}
388
+        <if test="userId != null and userId != ''">
389
+            or t.share_person = #{userId}
390
+        </if>
391
+        )
392
+        and t.org_id = #{orgId}
393
+        and t.target_type = #{eventType}
394
+        and t.target_id = #{targetId}
395
+        and t.status = 1
396
+        and t.person_id != #{personId}
397
+        group by t.target_type
398
+    </select>
399
+
400
+    <select id="selectData" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
401
+		select t.share_person_id, t.target_id,
402
+		if(t.target_type = 'help' and t.event_type = 'activity', 'help', if(t.target_type = 'group' and t.event_type = 'activity' , 'group', t.event_type)) as target_type,
403
+		a.nickname, a.avatarurl FROM
404
+        ta_person_visit_record t
405
+        LEFT JOIN ta_person a ON t.share_person_id = a.person_id
406
+        LEFT JOIN ta_share_person_from b ON t.target_id = b.target_id  and t.event_type = b.target_type + '_share'
407
+        WHERE
408
+        (
409
+            ( t.consultant_id IS NOT NULL AND t.consultant_id != '' )
410
+            OR ( t.share_person_id IS NOT NULL AND t.share_person_id != '' )
411
+        )
412
+        AND t.person_id != t.share_person_id
413
+        AND t.`event` = 'detail'
414
+        AND ( t.share_person_id != b.share_person OR t.consultant_id != b.share_person )
415
+        GROUP BY
416
+        t.target_id, t.event_type;
417
+    </select>
418
+
419
+    <select id="selectTapersonFromShare" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
420
+        select t.share_person_id, if (t.consultant_id != '' and t.consultant_id is not null, 'Realty Consultant', 'customer') as person_type, t.person_id, b.target_type, t.target_id,t.org_id, t.building_id  From ta_person_visit_record t
421
+        left join ta_person a on t.share_person_id = a.person_id
422
+        LEFT JOIN ta_share_person_from b ON t.target_id = b.target_id  and t.event_type = b.target_type + '_share'
423
+        where
424
+        (
425
+            ( t.consultant_id IS NOT NULL AND t.consultant_id != '' )
426
+            OR ( t.share_person_id IS NOT NULL AND t.share_person_id != '' )
427
+            )
428
+            AND t.person_id != t.share_person_id
429
+            AND t.`event` = 'detail'
430
+            AND ( t.share_person_id != b.share_person OR t.consultant_id != b.share_person )
431
+        GROUP BY
432
+            t.target_id, t.event_type;
433
+    </select>
434
+
435
+    <select id="selectTodayVisitCount" resultType="java.lang.Integer">
436
+        SELECT
437
+        COUNT(1) as visit_count
438
+        FROM
439
+        ta_person_visit_record tp
440
+        where tp.org_id = #{orgId} AND
441
+        tp.event  = 'start'
442
+        AND DATE_FORMAT(tp.visit_time,'%Y-%m-%d') = DATE_FORMAT(#{nowDate},'%Y-%m-%d')
443
+    </select>
444
+
445
+
446
+</mapper>

+ 158
- 158
src/main/resources/mapper/TaUserMapper.xml View File

@@ -1,158 +1,158 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
-<mapper namespace="com.huiju.estateagents.center.taUser.mapper.TaUserMapper">
4
-
5
-    <select id="getPageList" resultType="map">
6
-        SELECT
7
-            t.user_id AS userId,
8
-            t.org_id AS orgId,
9
-            t.user_name AS userName,
10
-            t.login_name AS loginName,
11
-            t.phone,
12
-            t.avatar,
13
-            t.create_date AS createDate,
14
-            t.status,
15
-            o.NAME AS orgName,
16
-            o.address,
17
-            o.logo,
18
-            o.remark,
19
-            m.miniapp_id AS miniappId,
20
-            m.secret,
21
-            m.token,
22
-            m.NAME AS miniappName,
23
-            m.qr_code AS qrCode,
24
-            t.exp_date as expire_date,
25
-            m.org_id
26
-        FROM
27
-            ta_user t
28
-            LEFT JOIN ta_org o ON t.org_id = o.org_id
29
-            LEFT JOIN ta_miniapp m ON o.org_id = m.org_id
30
-            left join ta_channel_app_relation n on o.org_id = n.org_id
31
-            left join ta_channel_proxy z on z.channel_id = n.channel_id
32
-        WHERE
33
-            t.is_admin =1
34
-            <if test="channelId != null and channelId != ''">
35
-                and n.channel_id = #{channelId}
36
-            </if>
37
-            <if test="miniAppName != null and miniAppName != ''">
38
-                and m.name like CONCAT('%', #{miniAppName}, '%')
39
-            </if>
40
-    </select>
41
-
42
-    <select id="getTagsList" resultType="com.huiju.estateagents.center.taUser.entity.TaTags">
43
-        SELECT
44
-            t.*
45
-        FROM
46
-            ta_tag_user u
47
-            LEFT JOIN ta_tags t ON u.tag_id = t.tag_id
48
-            AND t.org_id = #{orgId}
49
-        WHERE
50
-            u.user_id = #{userId}
51
-    </select>
52
-
53
-    <select id="getUserList" resultType="com.huiju.estateagents.center.taUser.entity.TaUser">
54
-    SELECT
55
-        *
56
-    FROM
57
-        ta_user
58
-    WHERE
59
-        org_id = #{orgId}
60
-        and phone = #{phone}
61
-    </select>
62
-    <select id="seleUserList" resultType="com.huiju.estateagents.center.taUser.entity.TaUser">
63
-        SELECT
64
-            t.*,
65
-            b.building_id,
66
-            d.person_id as consultant_person_id,
67
-            if(d.person_id,1,0) as mini_status
68
-        FROM
69
-            ta_user t
70
-            LEFT JOIN ta_person_building b ON t.user_id = b.user_id
71
-            LEFT JOIN ta_person d on t.user_id = d.user_id
72
-        WHERE
73
-            t.org_id = #{taUser.orgId} AND (t.is_admin != 1 or t.is_admin is null)
74
-            <if test="taUser.userName != null and taUser.userName != ''">
75
-                and t.user_name like CONCAT('%', #{taUser.userName}, '%')
76
-            </if>
77
-            <if test="taUser.phone != null and taUser.phone != ''">
78
-                and t.phone like CONCAT('%', #{taUser.phone}, '%')
79
-            </if>
80
-            <if test="taUser.status != null and taUser.status != ''">
81
-                and t.status = #{taUser.status}
82
-            </if>
83
-            <if test="taUser.isConsultant == 0">
84
-                and t.is_consultant = #{taUser.isConsultant}
85
-            </if>
86
-            <if test="taUser.miniStatus == 0">
87
-                and d.person_id is null
88
-            </if>
89
-            <if test="taUser.miniStatus != null and taUser.miniStatus != '' and taUser.miniStatus == 1">
90
-                and d.person_id is not null
91
-            </if>
92
-            <if test="taUser.buildingId != null and taUser.buildingId != ''">
93
-                and b.building_id = #{taUser.buildingId}
94
-            </if>
95
-            <if test="personBuildingList != null and personBuildingList.size > 0">
96
-                AND b.building_id in
97
-                <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
98
-                    #{personBuilding.buildingId}
99
-                </foreach>
100
-            </if>
101
-            GROUP BY user_id
102
-            order by t.weight desc, create_date desc
103
-    </select>
104
-
105
-    <select id="validateWeight" resultType="integer">
106
-      select count(*) from ta_user t
107
-      LEFT JOIN ta_person_building a on t.user_id = a.user_id
108
-      where 1=1
109
-      <if test="weight != null and weight != ''">
110
-          and t.weight = #{weight}
111
-      </if>
112
-      <if test="buildingIds != null and buildingIds.size() > 0 ">
113
-          and a.building_id in
114
-          <foreach collection="buildingIds" item="item" index="index" open="(" close=")" separator=",">
115
-              #{item}
116
-          </foreach>
117
-      </if>
118
-      <if test="buildingId != null and buildingId != '' ">
119
-          and a.building_id = #{buildingId}
120
-      </if>
121
-      <if test="userId != null and userId != ''">
122
-          and t.user_id != #{userId}
123
-      </if>
124
-    </select>
125
-
126
-    <select id="getAdminByAppID" resultType="com.huiju.estateagents.center.taUser.entity.TaUser">
127
-        SELECT
128
-        m.*
129
-        FROM
130
-        ta_miniapp t
131
-        JOIN ta_user m USING (org_id)
132
-        WHERE
133
-        t.miniapp_id = #{appid}
134
-        AND m.is_admin = 1
135
-    </select>
136
-
137
-    <select id="getBuildingIdsOf" resultType="java.lang.String">
138
-        select building_id from ta_person_building
139
-        where user_id = #{userId}
140
-        <if test="buildingId != null and buildingId != ''">
141
-            and building_id = #{buildingId}
142
-        </if>
143
-    </select>
144
-
145
-    <select id="getUserByPerson" resultType="com.huiju.estateagents.center.taUser.entity.TaUser">
146
-        SELECT
147
-            t.*
148
-        FROM
149
-            ta_user t
150
-        INNER JOIN ta_person s ON s.org_id = #{orgId} AND s.user_id = t.user_id
151
-        WHERE
152
-            t.org_id = #{orgId}
153
-        AND s.person_id = #{personId}
154
-        AND t.status &gt; -1
155
-        Limit 1
156
-    </select>
157
-
158
-</mapper>
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.huiju.estateagents.center.taUser.mapper.TaUserMapper">
4
+
5
+    <select id="getPageList" resultType="map">
6
+        SELECT
7
+            t.user_id AS userId,
8
+            t.org_id AS orgId,
9
+            t.user_name AS userName,
10
+            t.login_name AS loginName,
11
+            t.phone,
12
+            t.avatar,
13
+            t.create_date AS createDate,
14
+            t.status,
15
+            o.NAME AS orgName,
16
+            o.address,
17
+            o.logo,
18
+            o.remark,
19
+            m.miniapp_id AS miniappId,
20
+            m.secret,
21
+            m.token,
22
+            m.NAME AS miniappName,
23
+            m.qr_code AS qrCode,
24
+            t.exp_date as expire_date,
25
+            m.org_id
26
+        FROM
27
+            ta_user t
28
+            LEFT JOIN ta_org o ON t.org_id = o.org_id
29
+            LEFT JOIN ta_miniapp m ON o.org_id = m.org_id
30
+            left join ta_channel_app_relation n on o.org_id = n.org_id
31
+            left join ta_channel_proxy z on z.channel_id = n.channel_id
32
+        WHERE
33
+            t.is_admin =1
34
+            <if test="channelId != null and channelId != ''">
35
+                and n.channel_id = #{channelId}
36
+            </if>
37
+            <if test="miniAppName != null and miniAppName != ''">
38
+                and m.name like CONCAT('%', #{miniAppName}, '%')
39
+            </if>
40
+    </select>
41
+
42
+    <select id="getTagsList" resultType="com.huiju.estateagents.center.taUser.entity.TaTags">
43
+        SELECT
44
+            t.*
45
+        FROM
46
+            ta_tag_user u
47
+            LEFT JOIN ta_tags t ON u.tag_id = t.tag_id
48
+            AND t.org_id = #{orgId}
49
+        WHERE
50
+            u.user_id = #{userId}
51
+    </select>
52
+
53
+    <select id="getUserList" resultType="com.huiju.estateagents.center.taUser.entity.TaUser">
54
+    SELECT
55
+        *
56
+    FROM
57
+        ta_user
58
+    WHERE
59
+        org_id = #{orgId}
60
+        and phone = #{phone}
61
+    </select>
62
+    <select id="seleUserList" resultType="com.huiju.estateagents.center.taUser.entity.TaUser">
63
+        SELECT
64
+            t.*,
65
+            b.building_id,
66
+            d.person_id as consultant_person_id,
67
+            if(d.person_id is not null,1,0) as mini_status
68
+        FROM
69
+            ta_user t
70
+            LEFT JOIN ta_person_building b ON t.user_id = b.user_id
71
+            LEFT JOIN ta_person d on t.user_id = d.user_id
72
+        WHERE
73
+            t.org_id = #{taUser.orgId} AND (t.is_admin != 1 or t.is_admin is null)
74
+            <if test="taUser.userName != null and taUser.userName != ''">
75
+                and t.user_name like CONCAT('%', #{taUser.userName}, '%')
76
+            </if>
77
+            <if test="taUser.phone != null and taUser.phone != ''">
78
+                and t.phone like CONCAT('%', #{taUser.phone}, '%')
79
+            </if>
80
+            <if test="taUser.status != null and taUser.status != ''">
81
+                and t.status = #{taUser.status}
82
+            </if>
83
+            <if test="taUser.isConsultant != null">
84
+                and t.is_consultant = #{taUser.isConsultant}
85
+            </if>
86
+            <if test="taUser.miniStatus == 0">
87
+                and d.person_id is null
88
+            </if>
89
+            <if test="taUser.miniStatus != null and taUser.miniStatus != '' and taUser.miniStatus == 1">
90
+                and d.person_id is not null
91
+            </if>
92
+            <if test="taUser.buildingId != null and taUser.buildingId != ''">
93
+                and b.building_id = #{taUser.buildingId}
94
+            </if>
95
+            <if test="personBuildingList != null and personBuildingList.size > 0">
96
+                AND b.building_id in
97
+                <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
98
+                    #{personBuilding.buildingId}
99
+                </foreach>
100
+            </if>
101
+            GROUP BY user_id
102
+            order by t.weight desc, create_date desc
103
+    </select>
104
+
105
+    <select id="validateWeight" resultType="integer">
106
+      select count(*) from ta_user t
107
+      LEFT JOIN ta_person_building a on t.user_id = a.user_id
108
+      where 1=1
109
+      <if test="weight != null and weight != ''">
110
+          and t.weight = #{weight}
111
+      </if>
112
+      <if test="buildingIds != null and buildingIds.size() > 0 ">
113
+          and a.building_id in
114
+          <foreach collection="buildingIds" item="item" index="index" open="(" close=")" separator=",">
115
+              #{item}
116
+          </foreach>
117
+      </if>
118
+      <if test="buildingId != null and buildingId != '' ">
119
+          and a.building_id = #{buildingId}
120
+      </if>
121
+      <if test="userId != null and userId != ''">
122
+          and t.user_id != #{userId}
123
+      </if>
124
+    </select>
125
+
126
+    <select id="getAdminByAppID" resultType="com.huiju.estateagents.center.taUser.entity.TaUser">
127
+        SELECT
128
+        m.*
129
+        FROM
130
+        ta_miniapp t
131
+        JOIN ta_user m USING (org_id)
132
+        WHERE
133
+        t.miniapp_id = #{appid}
134
+        AND m.is_admin = 1
135
+    </select>
136
+
137
+    <select id="getBuildingIdsOf" resultType="java.lang.String">
138
+        select building_id from ta_person_building
139
+        where user_id = #{userId}
140
+        <if test="buildingId != null and buildingId != ''">
141
+            and building_id = #{buildingId}
142
+        </if>
143
+    </select>
144
+
145
+    <select id="getUserByPerson" resultType="com.huiju.estateagents.center.taUser.entity.TaUser">
146
+        SELECT
147
+            t.*
148
+        FROM
149
+            ta_user t
150
+        INNER JOIN ta_person s ON s.org_id = #{orgId} AND s.user_id = t.user_id
151
+        WHERE
152
+            t.org_id = #{orgId}
153
+        AND s.person_id = #{personId}
154
+        AND t.status &gt; -1
155
+        Limit 1
156
+    </select>
157
+
158
+</mapper>

+ 5
- 4
src/main/resources/mapper/TsConsultantKpiMapper.xml View File

@@ -27,8 +27,9 @@
27 27
                  where s.org_id = t.org_id and (s.realty_consultant = t.user_id or s.realty_consultant = m.person_id)
28 28
                  and (s.building_id = t.building_id or IFNULL(t.building_id, '') = '')
29 29
                  and s.status > 0
30
-                 AND s.create_date BETWEEN STR_TO_DATE( #{startDate}, '%Y%m%d' )
31
-                 AND  STR_TO_DATE(concat(#{endDate}, '235959'), '%Y%m%d%H%i%s')) as total_persons
30
+<!--                 AND s.create_date BETWEEN STR_TO_DATE( #{startDate}, '%Y%m%d' )-->
31
+<!--                 AND  STR_TO_DATE(concat(#{endDate}, '235959'), '%Y%m%d%H%i%s')-->
32
+                ) as total_persons
32 33
             FROM
33 34
                 ts_consultant_kpi t
34 35
             LEFT JOIN ta_person m on m.org_id = #{orgId} and m.user_id = t.user_id
@@ -145,8 +146,8 @@
145 146
         WHERE
146 147
             p.org_id = #{orgId}
147 148
             AND p.`status` > 0
148
-            AND p.create_date BETWEEN STR_TO_DATE( #{startDate}, '%Y%m%d')
149
-            AND  STR_TO_DATE(concat(#{endDate}, '235959'), '%Y%m%d%H%i%s')
149
+<!--            AND p.create_date BETWEEN STR_TO_DATE( #{startDate}, '%Y%m%d')-->
150
+<!--            AND  STR_TO_DATE(concat(#{endDate}, '235959'), '%Y%m%d%H%i%s')-->
150 151
         <if test="buildingIds != null">
151 152
             AND t.building_id in
152 153
             <foreach item="buildingId" index="index" collection="buildingIds"

+ 4
- 3
src/main/resources/mapper/statistic/TaActivityStaticMapper.xml View File

@@ -529,6 +529,7 @@
529 529
                 #{taPersonBuilding.buildingId}
530 530
             </foreach>
531 531
         </if>
532
+        group by t.person_id
532 533
         ) AS temp4
533 534
         GROUP BY
534 535
         DATE_FORMAT( temp4.create_date, '%Y-%m-%d' )
@@ -681,7 +682,7 @@
681 682
             and t.building_id = #{buildingId}
682 683
         </if>
683 684
         <if test="targetType != null and targetType != ''">
684
-            and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' else t.target_type = #{targetType}
685
+            and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' when #{targetType} = 'h5' then t.event_type = 'h5' else t.target_type = #{targetType}
685 686
             end)
686 687
         </if>
687 688
         <if test="startDate != null">
@@ -715,7 +716,7 @@
715 716
             and t.building_id = #{buildingId}
716 717
         </if>
717 718
         <if test="targetType != null and targetType != ''">
718
-            and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' else t.target_type = #{targetType}
719
+            and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' when #{targetType} = 'h5' then t.event_type = 'h5' else t.target_type = #{targetType}
719 720
             end)
720 721
         </if>
721 722
         <if test="startDate != null">
@@ -1448,8 +1449,8 @@
1448 1449
         from (
1449 1450
         SELECT t.*, f.nickname, f.phone, f.person_type
1450 1451
         FROM ta_share_count t
1451
-        LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1452 1452
         LEFT JOIN ta_share_activity b ON t.be_share = b.share_id
1453
+        LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1453 1454
         LEFT JOIN ta_live_activity c ON t.be_share = c.live_activity_id
1454 1455
         LEFT JOIN ta_drainage d ON t.be_share = d.drainage_id
1455 1456
         LEFT JOIN ta_building_dynamic e ON t.be_share = e.dynamic_id