Forráskód Böngészése

我的资源模块 跟进部分和精准匹配

yuxy 2 hónapja
szülő
commit
22cdeecc20

+ 124 - 50
LiangZhiYUMao/pages/matchmaker-workbench/precise-match.vue

@@ -12,30 +12,8 @@
 			<text class="loading-text">正在匹配中...</text>
 		</view>
 
-		<!-- 资源跟进状态 -->
-		<view class="follow-status-section" v-if="!loading && resourceFollowInfo">
-			<!-- 匹配状态 -->
-			<view class="follow-status-group">
-				<text class="status-label">匹配状态</text>
-				<view class="status-tags">
-					<text class="status-tag" :class="{ 'active': resourceFollowInfo.isMatch === 1 }">
-						{{ resourceFollowInfo.isMatch === 1 ? '已匹配' : '未匹配' }}
-					</text>
-				</view>
-			</view>
-			<!-- 跟进进度 -->
-			<view class="follow-status-group">
-				<text class="status-label">跟进进度</text>
-				<view class="status-tags">
-					<text class="status-tag" :class="{ 'active': resourceFollowInfo.isInvitation === 1 }">
-						{{ resourceFollowInfo.isInvitation === 1 ? '已邀约' : '未邀约' }}
-					</text>
-				</view>
-			</view>
-		</view>
-
 		<!-- 匹配客户列表 -->
-		<scroll-view scroll-y class="match-list" v-else>
+		<scroll-view scroll-y class="match-list" v-if="!loading">
 			<view class="match-client" v-for="(client, index) in matchClients" :key="client.id || index">
 				<!-- 匹配度标签 -->
 				<view class="match-score-badge" v-if="client.matchScore">
@@ -65,8 +43,8 @@
 						</view>
 						<view class="contact-info">
 							<text class="contact-label">联系方式:</text>
-							<text class="contact-number">{{ client.contact }}</text>
-							<text class="copy-btn" @click="handleCopy(client.contact)">复制</text>
+							<text class="contact-number">{{ client.contact || '暂无' }}</text>
+							<text class="copy-btn" @click="handleCopy(index)">复制</text>
 						</view>
 					</view>
 				</view>
@@ -109,8 +87,7 @@ export default {
 			return {
 				resourceId: null,
 				matchClients: [],
-				loading: false,
-				resourceFollowInfo: null // 资源跟进信息
+				loading: false
 			}
 		},
 	onLoad(options) {
@@ -138,14 +115,99 @@ export default {
 			uni.navigateBack()
 		},
 		// 复制联系方式
-		handleCopy(contact) {
+		handleCopy(index) {
+			console.log('=== 复制联系方式 ===')
+			console.log('传入的index:', index)
+			
+			// 从matchClients数组中获取client对象
+			if (index === undefined || index === null || index < 0 || index >= this.matchClients.length) {
+				console.error('❌ index无效:', index)
+				console.log('当前matchClients数组长度:', this.matchClients.length)
+				uni.showToast({
+					title: '数据错误',
+					icon: 'none'
+				})
+				return
+			}
+			
+			const client = this.matchClients[index]
+			console.log('从数组获取的client:', client)
+			
+			if (!client) {
+				console.error('❌ client对象为空')
+				console.log('当前matchClients数组:', this.matchClients)
+				uni.showToast({
+					title: '数据错误',
+					icon: 'none'
+				})
+				return
+			}
+			
+			console.log('client.contact:', client.contact)
+			console.log('client.originalPhone:', client.originalPhone)
+			console.log('client.originalPhone类型:', typeof client.originalPhone)
+			console.log('client的所有属性:', Object.keys(client))
+			
+			// 优先使用完整手机号(originalPhone),如果没有则使用脱敏的手机号
+			let phoneToCopy = ''
+			
+			// 优先使用originalPhone(完整手机号)
+			const originalPhone = client.originalPhone || client.original_phone || client.originalphone
+			console.log('尝试获取originalPhone:', originalPhone)
+			if (originalPhone && typeof originalPhone === 'string' && originalPhone.trim() !== '') {
+				phoneToCopy = originalPhone.trim()
+				console.log('✅ 使用originalPhone:', phoneToCopy.substring(0, 3) + '****')
+			} else {
+				console.log('❌ originalPhone为空或无效,尝试使用contact')
+				// 如果没有originalPhone,尝试从脱敏的手机号中提取(但这样无法获取完整号码)
+				if (client.contact) {
+					try {
+						const contactStr = String(client.contact || '')
+						console.log('尝试从contact提取:', contactStr)
+						if (contactStr && contactStr.trim() !== '') {
+							// 去除星号(但这样只能得到部分号码,不是完整号码)
+							const extracted = contactStr.replace(/\*+/g, '').trim()
+							if (extracted.length >= 11) {
+								phoneToCopy = extracted
+								console.log('⚠️ 从脱敏号码提取:', phoneToCopy.substring(0, 3) + '****')
+							} else {
+								console.log('❌ 提取的号码长度不足:', extracted.length)
+							}
+						}
+					} catch (e) {
+						console.error('处理联系方式时出错:', e)
+					}
+				}
+			}
+			
+			console.log('最终要复制的号码:', phoneToCopy ? phoneToCopy.substring(0, 3) + '****' : '空')
+			
+			// 检查是否为空
+			if (!phoneToCopy || phoneToCopy === '') {
+				console.error('❌ 联系方式为空,无法复制')
+				uni.showToast({
+					title: '联系方式为空',
+					icon: 'none'
+				})
+				return
+			}
+			
+			// 复制到剪贴板
 			uni.setClipboardData({
-				data: contact.replace(/\*+/g, ''),
+				data: phoneToCopy,
 				success: () => {
+					console.log('✅ 复制成功:', phoneToCopy.substring(0, 3) + '****')
 					uni.showToast({
 						title: '复制成功',
 						icon: 'success'
 					})
+				},
+				fail: () => {
+					console.error('❌ 复制失败')
+					uni.showToast({
+						title: '复制失败',
+						icon: 'none'
+					})
 				}
 			})
 		},
@@ -172,31 +234,14 @@ export default {
 					? 'http://localhost:8083/api'  // 开发环境 - 通过网关
 					: 'https://your-domain.com/api'  // 生产环境
 				
-				// 同时加载匹配结果和资源跟进信息
+				// 加载匹配结果
 				const [matchError, matchRes] = await uni.request({
 					url: `${baseUrl}/my-resource/precise-match/${resourceId}`,
 					method: 'GET'
 				})
 				
-				// 加载资源跟进信息
-				const [followError, followRes] = await uni.request({
-					url: `${baseUrl}/my-resource/client-detail/${resourceId}`,
-					method: 'GET'
-				})
-				
 				this.loading = false
 				
-				// 处理跟进信息
-				if (!followError && followRes.statusCode === 200 && followRes.data && followRes.data.code === 200) {
-					const followData = followRes.data.data
-					this.resourceFollowInfo = {
-						isMatch: followData.isMatch !== null && followData.isMatch !== undefined ? followData.isMatch : 
-						        (followData.is_match !== null && followData.is_match !== undefined ? followData.is_match : 0),
-						isInvitation: followData.isInvitation !== null && followData.isInvitation !== undefined ? followData.isInvitation : 
-						             (followData.is_Invitation !== null && followData.is_Invitation !== undefined ? followData.is_Invitation : 0)
-					}
-				}
-				
 				if (matchError) {
 					console.error('加载匹配客户失败:', matchError)
 					uni.showToast({
@@ -209,9 +254,26 @@ export default {
 				if (matchRes.statusCode === 200 && matchRes.data && matchRes.data.code === 200) {
 					const matchList = matchRes.data.data || []
 					
+					console.log('=== 后端返回的匹配列表 ===')
+					console.log('匹配列表长度:', matchList.length)
+					if (matchList.length > 0) {
+						console.log('第一个匹配项原始数据:', JSON.stringify(matchList[0], null, 2))
+						console.log('第一个匹配项的phone字段:', matchList[0].phone)
+						console.log('第一个匹配项的originalPhone字段:', matchList[0].originalPhone)
+						console.log('第一个匹配项的所有字段:', Object.keys(matchList[0]))
+					}
+					
 					// 转换数据格式
-					this.matchClients = matchList.map(item => {
-						return {
+					this.matchClients = matchList.map((item, index) => {
+						// 确保 originalPhone 被正确映射
+						let originalPhoneValue = ''
+						if (item.originalPhone !== null && item.originalPhone !== undefined) {
+							originalPhoneValue = String(item.originalPhone).trim()
+						} else if (item.original_phone !== null && item.original_phone !== undefined) {
+							originalPhoneValue = String(item.original_phone).trim()
+						}
+						
+						const mappedItem = {
 							id: item.userId,
 							name: item.nickname || '未知',
 							gender: item.gender === 1 ? '男' : item.gender === 2 ? '女' : '未知',
@@ -219,7 +281,8 @@ export default {
 							tags: item.tags || [],
 							avatar: item.avatarUrl || 'https://via.placeholder.com/150',
 							requirement: item.requirement || '暂无要求',
-							contact: item.phone || '',
+							contact: (item.phone && typeof item.phone === 'string') ? item.phone : (item.phone ? String(item.phone) : ''),
+							originalPhone: originalPhoneValue,
 							matchScore: item.matchScore || 0,
 							age: item.age,
 							height: item.height,
@@ -228,6 +291,17 @@ export default {
 							occupation: item.occupation,
 							address: item.address
 						}
+						
+						if (index === 0) {
+							console.log('=== 第一个匹配项映射后 ===')
+							console.log('contact:', mappedItem.contact)
+							console.log('originalPhone:', mappedItem.originalPhone)
+							console.log('originalPhone类型:', typeof mappedItem.originalPhone)
+							console.log('originalPhone是否为空:', !mappedItem.originalPhone || mappedItem.originalPhone === '')
+							console.log('映射后的完整对象:', mappedItem)
+						}
+						
+						return mappedItem
 					})
 					
 					console.log('匹配结果:', this.matchClients)

+ 13 - 0
service/homePage/src/main/java/com/zhentao/controller/MyResourceController.java

@@ -313,6 +313,19 @@ public class MyResourceController {
                 return Result.success("未找到匹配的用户", new java.util.ArrayList<>());
             }
             
+            // 验证返回数据中的 originalPhone 字段
+            System.out.println("=== Controller返回数据验证 ===");
+            for (int i = 0; i < matchResults.size() && i < 3; i++) {
+                com.zhentao.vo.MatchResultVO result = matchResults.get(i);
+                System.out.println("匹配结果 " + i + ":");
+                System.out.println("  - userId: " + result.getUserId());
+                System.out.println("  - nickname: " + result.getNickname());
+                System.out.println("  - phone: " + result.getPhone());
+                System.out.println("  - originalPhone: " + result.getOriginalPhone());
+                System.out.println("  - originalPhone是否为null: " + (result.getOriginalPhone() == null));
+                System.out.println("  - originalPhone是否为空字符串: " + (result.getOriginalPhone() != null && result.getOriginalPhone().isEmpty()));
+            }
+            
             System.out.println("匹配成功,返回 " + matchResults.size() + " 个结果");
             return Result.success(matchResults);
         } catch (Exception e) {

+ 33 - 3
service/homePage/src/main/java/com/zhentao/service/impl/MyResourceServiceImpl.java

@@ -430,12 +430,18 @@ public class MyResourceServiceImpl extends ServiceImpl<MyResourceMapper, MyResou
         // 3. 确定目标性别(异性)
         Integer targetGender = (resourceGender == 1) ? 2 : 1; // 1-男找女, 2-女找男
         
-        // 4. 查询所有异性用户
+        // 4. 查询所有异性用户(确保查询phone字段)
         QueryWrapper<User> userQuery = new QueryWrapper<>();
         userQuery.eq("gender", targetGender);
         userQuery.eq("status", 1); // 只查询正常状态的用户
+        // 不限制查询字段,查询所有字段(包括phone)
         List<User> allUsers = userMapper.selectList(userQuery);
         
+        System.out.println("查询到的用户数量: " + allUsers.size());
+        if (!allUsers.isEmpty()) {
+            System.out.println("第一个用户的phone: " + (allUsers.get(0).getPhone() != null ? allUsers.get(0).getPhone() : "null"));
+        }
+        
         System.out.println("找到 " + allUsers.size() + " 个异性用户");
         
         if (allUsers.isEmpty()) {
@@ -495,8 +501,32 @@ public class MyResourceServiceImpl extends ServiceImpl<MyResourceMapper, MyResou
                 matchResult.setAddress((String) profileMap.get("company"));
             }
             
-            // 查询用户手机号(脱敏)
-            matchResult.setPhone(user.getPhone() != null ? maskPhone(user.getPhone()) : "");
+            // 查询用户手机号(从users表通过userId查询,脱敏)
+            // 如果user对象中的phone为空,通过userId重新查询users表获取完整信息
+            String phone = user.getPhone();
+            if (phone == null || phone.trim().isEmpty()) {
+                // 如果user对象中没有phone,通过userId重新查询users表
+                User fullUser = userMapper.selectById(user.getUserId());
+                if (fullUser != null && fullUser.getPhone() != null && !fullUser.getPhone().trim().isEmpty()) {
+                    phone = fullUser.getPhone();
+                    System.out.println("通过userId重新查询获取到手机号: " + (phone != null ? maskPhone(phone) : "null"));
+                } else {
+                    System.out.println("警告: 用户ID " + user.getUserId() + " 在users表中没有手机号");
+                }
+            }
+            // 设置脱敏手机号(用于显示)
+            String maskedPhone = phone != null && !phone.trim().isEmpty() ? maskPhone(phone) : "";
+            matchResult.setPhone(maskedPhone);
+            
+            // 设置完整手机号(用于复制,红娘端有权限查看)
+            String originalPhone = phone != null && !phone.trim().isEmpty() ? phone : "";
+            matchResult.setOriginalPhone(originalPhone);
+            
+            System.out.println("用户 " + user.getUserId() + " 手机号设置:");
+            System.out.println("  - 脱敏手机号(phone): " + maskedPhone);
+            System.out.println("  - 完整手机号(originalPhone): " + (originalPhone != null && !originalPhone.isEmpty() ? originalPhone : "空"));
+            System.out.println("  - 完整手机号长度: " + (originalPhone != null ? originalPhone.length() : 0));
+            System.out.println("  - MatchResultVO对象originalPhone值: " + matchResult.getOriginalPhone());
             
             // 查询标签
             List<String> tags = new java.util.ArrayList<>();

+ 7 - 1
service/homePage/src/main/java/com/zhentao/vo/MatchResultVO.java

@@ -80,10 +80,16 @@ public class MatchResultVO implements Serializable {
     private Integer car;
     
     /**
-     * 手机号(脱敏)
+     * 手机号(脱敏,用于显示
      */
     private String phone;
     
+    /**
+     * 完整手机号(用于复制,红娘端有权限查看)
+     */
+    @JsonProperty("originalPhone")
+    private String originalPhone;
+    
     /**
      * 匹配度分数 (0-100)
      */