Browse Source

fleat: contact 3

igb 3 weeks ago
parent
commit
470c3c375d
9 changed files with 778 additions and 183 deletions
  1. 120 26
      abnormal.php
  2. 6 5
      claimRecord.php
  3. 11 0
      customerEdit.php
  4. 6 0
      customerSave.php
  5. 108 38
      customersFollow.php
  6. 106 37
      customersNew.php
  7. 127 14
      highSeas.php
  8. 163 45
      silentCustomer.php
  9. 131 18
      teamSeas.php

+ 120 - 26
abnormal.php

@@ -30,13 +30,16 @@ $act = $_GET['act'] ?? '';
 $page = $_GET['Page'] ?? '';
 $keys = urlencode($_GET['Keys'] ?? '');
 $hrefstr = "?keys=" . $keys;
+
+// 使用SQL拼接方式
+$employee_id = intval($_SESSION['employee_id']);
 ?>
     <form id="form1" method="post" action="?act=postchk&Keys=<?= $keys ?>&Page=<?= $page ?>" onSubmit="return false">
     <div class="fastSelect clear">
         <H1>异常客户</H1>
     </div>
 
-    <div width="100%" border="0" cellpadding="3" cellspacing="1" class="table2 em<?= $_SESSION['employee_id'] ?>">
+    <div width="100%" border="0" cellpadding="3" cellspacing="1" class="table2 em<?= $employee_id ?>">
         <div class="theader">
             <div class="col1"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></div>
             <div class="col2">序号</div>
@@ -51,15 +54,53 @@ $hrefstr = "?keys=" . $keys;
         </div>
 
 <?php
-$sqlStr = "SELECT c.id, c.cs_code, c.cs_from, c.cs_country, c.cs_type, c.cs_deal, c.cs_addtime, 
-           c.colortag, c.cs_note, c.cs_claimFrom, cc.tel as cs_tel, cc.email as cs_email, 
-           cc.whatsapp as cs_whatsapp, cc.wechat as cs_wechat, cc.linkedin as cs_linkedin, 
-           cc.facebook as cs_facebook, cc.alibaba as cs_alibaba
-           FROM customer c 
-           LEFT JOIN customer_contact cc ON c.id = cc.customer_id
-           WHERE (cc.alibaba = '' AND (c.cs_code LIKE '%阿里%' OR c.cs_code LIKE '%1688%') AND c.cs_belong = " . $_SESSION['employee_id'] . ") 
-           OR (c.cs_from = 8 AND cc.wechat = '' AND c.cs_belong = " . $_SESSION['employee_id'] . ") 
-           ORDER BY c.colortag DESC, c.id DESC";
+// 适配新的customer_contact表结构并使用SQL拼接方式
+$sqlStr = "SELECT c.id, 
+          MAX(c.cs_code) as cs_code, 
+          MAX(c.cs_from) as cs_from, 
+          MAX(c.cs_country) as cs_country, 
+          MAX(c.cs_type) as cs_type, 
+          MAX(c.cs_deal) as cs_deal, 
+          MAX(c.cs_addtime) as cs_addtime, 
+          MAX(c.colortag) as colortag, 
+          MAX(c.cs_note) as cs_note, 
+          MAX(c.cs_claimFrom) as cs_claimFrom,
+          GROUP_CONCAT(DISTINCT cc.id) as contact_ids,
+          GROUP_CONCAT(DISTINCT cc.contact_name) as contact_names,
+          GROUP_CONCAT(DISTINCT cc.tel_1) as tel_1_list,
+          GROUP_CONCAT(DISTINCT cc.tel_2) as tel_2_list,
+          GROUP_CONCAT(DISTINCT cc.tel_3) as tel_3_list,
+          GROUP_CONCAT(DISTINCT cc.email_1) as email_1_list,
+          GROUP_CONCAT(DISTINCT cc.email_2) as email_2_list,
+          GROUP_CONCAT(DISTINCT cc.email_3) as email_3_list,
+          GROUP_CONCAT(DISTINCT cc.whatsapp_1) as whatsapp_1_list,
+          GROUP_CONCAT(DISTINCT cc.whatsapp_2) as whatsapp_2_list,
+          GROUP_CONCAT(DISTINCT cc.whatsapp_3) as whatsapp_3_list,
+          GROUP_CONCAT(DISTINCT cc.wechat_1) as wechat_1_list,
+          GROUP_CONCAT(DISTINCT cc.wechat_2) as wechat_2_list,
+          GROUP_CONCAT(DISTINCT cc.wechat_3) as wechat_3_list,
+          GROUP_CONCAT(DISTINCT cc.linkedin_1) as linkedin_1_list,
+          GROUP_CONCAT(DISTINCT cc.linkedin_2) as linkedin_2_list,
+          GROUP_CONCAT(DISTINCT cc.linkedin_3) as linkedin_3_list,
+          GROUP_CONCAT(DISTINCT cc.facebook_1) as facebook_1_list,
+          GROUP_CONCAT(DISTINCT cc.facebook_2) as facebook_2_list,
+          GROUP_CONCAT(DISTINCT cc.facebook_3) as facebook_3_list,
+          GROUP_CONCAT(DISTINCT cc.alibaba_1) as alibaba_1_list,
+          GROUP_CONCAT(DISTINCT cc.alibaba_2) as alibaba_2_list,
+          GROUP_CONCAT(DISTINCT cc.alibaba_3) as alibaba_3_list
+          FROM customer c 
+          LEFT JOIN customer_contact cc ON c.id = cc.customer_id
+          WHERE (
+              (NOT EXISTS (SELECT 1 FROM customer_contact WHERE customer_id = c.id AND alibaba_1 <> '') 
+               AND (c.cs_code LIKE '%阿里%' OR c.cs_code LIKE '%1688%') 
+               AND c.cs_belong = " . $employee_id . ")
+              OR 
+              (c.cs_from = 8 
+               AND NOT EXISTS (SELECT 1 FROM customer_contact WHERE customer_id = c.id AND wechat_1 <> '') 
+               AND c.cs_belong = " . $employee_id . ")
+          ) 
+          GROUP BY c.id
+          ORDER BY MAX(c.colortag) DESC, c.id DESC";
 
 $result = $conn->query($sqlStr);
 
@@ -85,15 +126,17 @@ if ($result && $result->num_rows > 0) {
     foreach ($paginatedRows as $row) {
         $tempNum++;
 ?>
-        <div class="tline color<?= $row['colorTag'] ?>">
-            <div class="col1" align="center"><input type="checkbox" name="chkbox" value="<?= $row['id'] ?>" /></div>
+        <div class="tline color<?= $row['colortag'] ?>">
+            <div class="col1" align="center"><input type="checkbox" name="chkbox[]" value="<?= $row['id'] ?>" /></div>
             <div class="col2"><?= $tempNum ?></div>
-            <div class="col3 slidepanel"><?= $row['cs_code'] ?><?php if ($row['cs_claimFrom'] > 0): ?><img src="../images/yijiao.png" class="handover" title="来自认领"><?php endif; ?></div>
+            <div class="col3 slidepanel"><?= htmlspecialcharsFix($row['cs_code']) ?><?php if ($row['cs_claimFrom'] > 0): ?><img src="../images/yijiao.png" class="handover" title="来自认领"><?php endif; ?></div>
             <div class="col4">
                 <?php
-                $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id = " . $row['cs_from']);
+                // 使用SQL拼接方式
+                $cs_from = intval($row['cs_from']);
+                $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id = " . $cs_from);
                 if ($qudaoRow = $qudaoResult->fetch_assoc()) {
-                    echo $qudaoRow['ch_name'];
+                    echo htmlspecialcharsFix($qudaoRow['ch_name']);
                 } else {
                     echo "未填写";
                 }
@@ -101,9 +144,11 @@ if ($result && $result->num_rows > 0) {
             </div>
             <div class="col5">
                 <?php
-                $countryResult = $conn->query("SELECT countryName FROM country WHERE id = " . $row['cs_country']);
+                // 使用SQL拼接方式
+                $cs_country = intval($row['cs_country']);
+                $countryResult = $conn->query("SELECT countryName FROM country WHERE id = " . $cs_country);
                 if ($countryRow = $countryResult->fetch_assoc()) {
-                    echo $countryRow['countryName'];
+                    echo htmlspecialcharsFix($countryRow['countryName']);
                 } else {
                     echo "未填写";
                 }
@@ -111,9 +156,11 @@ if ($result && $result->num_rows > 0) {
             </div>
             <div class="col6">
                 <?php
-                $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id = " . $row['cs_type']);
+                // 使用SQL拼接方式
+                $cs_type = intval($row['cs_type']);
+                $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id = " . $cs_type);
                 if ($typeRow = $typeResult->fetch_assoc()) {
-                    echo $typeRow['businessType'];
+                    echo htmlspecialcharsFix($typeRow['businessType']);
                 } else {
                     echo "未填写";
                 }
@@ -151,13 +198,60 @@ if ($result && $result->num_rows > 0) {
         <div class="notepanel clear">
             <div class="noteItem">联系方式</div>
             <div class="lx">
-                <div class="tel"><?= $row['cs_tel'] ?></div>
-                <div class="mail"><a href="mailto:<?= $row['cs_email'] ?>"><?= $row['cs_email'] ?></a></div>
-                <div class="whatsapp"><?= $row['cs_whatsapp'] ?></div>
-                <div class="wechat"><?= $row['cs_wechat'] ?></div>
-                <div class="linkedin"><?= $row['cs_linkedin'] ?></div>
-                <div class="facebook"><?= $row['cs_facebook'] ?></div>
-                <div class="alibaba"><?= $row['cs_alibaba'] ?></div>
+                <?php
+                // 显示联系人和联系方式
+                $contacts = explode(',', $row['contact_names']);
+                $contactIds = explode(',', $row['contact_ids']);
+                
+                // 处理电话
+                echo '<div class="tel">';
+                if (!empty($row['tel_1_list'])) echo htmlspecialcharsFix($row['tel_1_list']) . '<br>';
+                if (!empty($row['tel_2_list'])) echo htmlspecialcharsFix($row['tel_2_list']) . '<br>';
+                if (!empty($row['tel_3_list'])) echo htmlspecialcharsFix($row['tel_3_list']);
+                echo '</div>';
+                
+                // 处理邮箱
+                echo '<div class="mail">';
+                if (!empty($row['email_1_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_1_list']) . '">' . htmlspecialcharsFix($row['email_1_list']) . '</a><br>';
+                if (!empty($row['email_2_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_2_list']) . '">' . htmlspecialcharsFix($row['email_2_list']) . '</a><br>';
+                if (!empty($row['email_3_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_3_list']) . '">' . htmlspecialcharsFix($row['email_3_list']) . '</a>';
+                echo '</div>';
+                
+                // 处理WhatsApp
+                echo '<div class="whatsapp">';
+                if (!empty($row['whatsapp_1_list'])) echo htmlspecialcharsFix($row['whatsapp_1_list']) . '<br>';
+                if (!empty($row['whatsapp_2_list'])) echo htmlspecialcharsFix($row['whatsapp_2_list']) . '<br>';
+                if (!empty($row['whatsapp_3_list'])) echo htmlspecialcharsFix($row['whatsapp_3_list']);
+                echo '</div>';
+                
+                // 处理微信
+                echo '<div class="wechat">';
+                if (!empty($row['wechat_1_list'])) echo htmlspecialcharsFix($row['wechat_1_list']) . '<br>';
+                if (!empty($row['wechat_2_list'])) echo htmlspecialcharsFix($row['wechat_2_list']) . '<br>';
+                if (!empty($row['wechat_3_list'])) echo htmlspecialcharsFix($row['wechat_3_list']);
+                echo '</div>';
+                
+                // 处理LinkedIn
+                echo '<div class="linkedin">';
+                if (!empty($row['linkedin_1_list'])) echo htmlspecialcharsFix($row['linkedin_1_list']) . '<br>';
+                if (!empty($row['linkedin_2_list'])) echo htmlspecialcharsFix($row['linkedin_2_list']) . '<br>';
+                if (!empty($row['linkedin_3_list'])) echo htmlspecialcharsFix($row['linkedin_3_list']);
+                echo '</div>';
+                
+                // 处理Facebook
+                echo '<div class="facebook">';
+                if (!empty($row['facebook_1_list'])) echo htmlspecialcharsFix($row['facebook_1_list']) . '<br>';
+                if (!empty($row['facebook_2_list'])) echo htmlspecialcharsFix($row['facebook_2_list']) . '<br>';
+                if (!empty($row['facebook_3_list'])) echo htmlspecialcharsFix($row['facebook_3_list']);
+                echo '</div>';
+                
+                // 处理阿里巴巴
+                echo '<div class="alibaba">';
+                if (!empty($row['alibaba_1_list'])) echo htmlspecialcharsFix($row['alibaba_1_list']) . '<br>';
+                if (!empty($row['alibaba_2_list'])) echo htmlspecialcharsFix($row['alibaba_2_list']) . '<br>';
+                if (!empty($row['alibaba_3_list'])) echo htmlspecialcharsFix($row['alibaba_3_list']);
+                echo '</div>';
+                ?>
             </div>
             <div class="noteItem2">备注</div>
             <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>

+ 6 - 5
claimRecord.php

@@ -122,16 +122,17 @@ if ($result && $result->num_rows > 0) {
     foreach ($paginatedRows as $row) {
         $tempNum++;
         
-        // Get new customer code
-        $customerResult = $conn->query("SELECT cs_code FROM customer WHERE id = " . $row['cs_id']);
+        // 使用SQL拼接方式获取新的客户编码
+        $customerQuery = "SELECT cs_code FROM customer WHERE id = " . intval($row['cs_id']);
+        $customerResult = $conn->query($customerQuery);
         $customerCode = ($customerRow = $customerResult->fetch_assoc()) ? $customerRow['cs_code'] : '';
 ?>
         <tr>
             <td><?= $tempNum ?></td>
             <td><?= $row['claimTime'] ?></td>
-            <td><span style="color:#0099CC;"><?= $row['newEmp'] ?></span> 认领了 
-                <span style="color:#0099CC;"><?= $row['originalEmp'] ?></span> 的客户(<?= $row['oldCode'] ?>)</td>
-            <td><?= $customerCode ?></td>
+            <td><span style="color:#0099CC;"><?= htmlspecialcharsFix($row['newEmp']) ?></span> 认领了 
+                <span style="color:#0099CC;"><?= htmlspecialcharsFix($row['originalEmp']) ?></span> 的客户(<?= htmlspecialcharsFix($row['oldCode']) ?>)</td>
+            <td><?= htmlspecialcharsFix($customerCode) ?></td>
         </tr>
 <?php
     }

+ 11 - 0
customerEdit.php

@@ -103,6 +103,17 @@ if (!empty($id) && is_numeric($id)) {
             upMediaExt:"wmv,avi,wma,mp3,mid"
         });
         
+        // Remove contact
+        $(document).on('click', '.remove-contact-btn', function() {
+            var contactForm = $(this).closest('.contact-form');
+            contactForm.remove();
+            
+            // Renumber remaining contacts
+            $('#contacts-container .contact-form').each(function(index) {
+                $(this).find('h3').text('联系人 #' + (index + 1));
+            });
+        });
+        
         // Add contact form
         $('.add-contact-btn').click(function() {
             var contactsContainer = $('#contacts-container');

+ 6 - 0
customerSave.php

@@ -51,6 +51,7 @@ $mytag = textEncode($_POST['mytag'] ?? '');
 $mytag = str_replace(['&#60;&#47;span&#62;&#60;span&#62;', '&#60;&#47;span&#62;', '&#60;span&#62;'], [',', '', ''], $mytag);
 $mytag = explode(',', $mytag);
 
+
 // Auto-detect source from code
 if (strpos($cs_code, ';1688') !== false) {
     $cs_from = 1; // 1688
@@ -59,6 +60,9 @@ if (strpos($cs_code, ';阿里') !== false) {
     $cs_from = 2; // International station
 }
 
+
+
+
 // Get the first contact for validation (if any)
 $primary_contact = !empty($contacts) ? current($contacts) : [];
 
@@ -278,6 +282,8 @@ if ($allowedit != 1) {
 
 // Save or update customer data
 if ($act == "editSave" || $allowedit == 1) {
+
+
     $hrefstr = "/customers.php?Keys=" . $keys . "&fliterBusiness=" . $fliterBusiness . 
                "&fliterDeal=" . $fliterDeal . "&Page=" . $page;
     

+ 108 - 38
customersFollow.php

@@ -70,34 +70,34 @@ $filterStr = "";
 $urlStr = "";
 
 if (!empty($filterCountry)) {
-    $filterStr .= " AND cs_country=" . (int)$filterCountry;
+    $filterStr .= " AND c.cs_country=" . (int)$filterCountry;
     $urlStr .= "&fliterCountry=" . $filterCountry;
 }
 
 if (!empty($filterQudao)) {
-    $filterStr .= " AND cs_from=" . (int)$filterQudao;
+    $filterStr .= " AND c.cs_from=" . (int)$filterQudao;
     $urlStr .= "&fliterQudao=" . $filterQudao;
 }
 
 if (!empty($filterDeal)) {
-    $filterStr .= " AND cs_deal=" . (int)$filterDeal;
+    $filterStr .= " AND c.cs_deal=" . (int)$filterDeal;
     $urlStr .= "&fliterDeal=" . $filterDeal;
 }
 
 if (!empty($filterBusiness)) {
-    $filterStr .= " AND cs_type=" . (int)$filterBusiness;
+    $filterStr .= " AND c.cs_type=" . (int)$filterBusiness;
     $urlStr .= "&fliterBusiness=" . $filterBusiness;
 }
 
 if (!empty($filterContact)) {
     switch ($filterContact) {
-        case "1": $filterStr .= " AND cc.tel<>''"; break;
-        case "2": $filterStr .= " AND cc.wechat<>''"; break;
-        case "3": $filterStr .= " AND cc.whatsapp<>''"; break;
-        case "4": $filterStr .= " AND cc.email<>''"; break;
-        case "5": $filterStr .= " AND cc.linkedin<>''"; break;
-        case "6": $filterStr .= " AND cc.facebook<>''"; break;
-        default: $filterStr .= " AND cc.alibaba<>''";
+        case "1": $filterStr .= " AND (cc.tel_1 IS NOT NULL AND cc.tel_1 <> '' OR cc.tel_2 IS NOT NULL AND cc.tel_2 <> '' OR cc.tel_3 IS NOT NULL AND cc.tel_3 <> '')"; break;
+        case "2": $filterStr .= " AND (cc.wechat_1 IS NOT NULL AND cc.wechat_1 <> '' OR cc.wechat_2 IS NOT NULL AND cc.wechat_2 <> '' OR cc.wechat_3 IS NOT NULL AND cc.wechat_3 <> '')"; break;
+        case "3": $filterStr .= " AND (cc.whatsapp_1 IS NOT NULL AND cc.whatsapp_1 <> '' OR cc.whatsapp_2 IS NOT NULL AND cc.whatsapp_2 <> '' OR cc.whatsapp_3 IS NOT NULL AND cc.whatsapp_3 <> '')"; break;
+        case "4": $filterStr .= " AND (cc.email_1 IS NOT NULL AND cc.email_1 <> '' OR cc.email_2 IS NOT NULL AND cc.email_2 <> '' OR cc.email_3 IS NOT NULL AND cc.email_3 <> '')"; break;
+        case "5": $filterStr .= " AND (cc.linkedin_1 IS NOT NULL AND cc.linkedin_1 <> '' OR cc.linkedin_2 IS NOT NULL AND cc.linkedin_2 <> '' OR cc.linkedin_3 IS NOT NULL AND cc.linkedin_3 <> '')"; break;
+        case "6": $filterStr .= " AND (cc.facebook_1 IS NOT NULL AND cc.facebook_1 <> '' OR cc.facebook_2 IS NOT NULL AND cc.facebook_2 <> '' OR cc.facebook_3 IS NOT NULL AND cc.facebook_3 <> '')"; break;
+        default: $filterStr .= " AND (cc.alibaba_1 IS NOT NULL AND cc.alibaba_1 <> '' OR cc.alibaba_2 IS NOT NULL AND cc.alibaba_2 <> '' OR cc.alibaba_3 IS NOT NULL AND cc.alibaba_3 <> '')";
     }
     $urlStr .= "&fliterContact=" . $filterContact;
 }
@@ -195,20 +195,52 @@ $hrefstr = "?keys=" . $keys;
         </div>
 
 <?php
-$sql = "SELECT c.id, c.cs_code, c.cs_from, c.cs_country, c.cs_type, c.cs_deal, c.cs_addtime, 
-        c.colortag, c.cs_note, cc.tel as cs_tel, cc.email as cs_email, cc.whatsapp as cs_whatsapp, 
-        cc.wechat as cs_wechat, cc.linkedin as cs_linkedin, cc.facebook as cs_facebook, 
-        cc.alibaba as cs_alibaba 
+$employee_id = intval($_SESSION['employee_id']);
+$escapedKeyscode = $conn->real_escape_string($keyscode);
+
+$sql = "SELECT c.id, 
+        MAX(c.cs_code) as cs_code, 
+        MAX(c.cs_from) as cs_from, 
+        MAX(c.cs_country) as cs_country, 
+        MAX(c.cs_type) as cs_type, 
+        MAX(c.cs_deal) as cs_deal, 
+        MAX(c.cs_addtime) as cs_addtime, 
+        MAX(c.colortag) as colortag, 
+        MAX(c.cs_note) as cs_note,
+        MAX(c.cs_state) as cs_state,
+        GROUP_CONCAT(DISTINCT cc.id) as contact_ids,
+        GROUP_CONCAT(DISTINCT cc.contact_name) as contact_names,
+        GROUP_CONCAT(DISTINCT cc.tel_1) as tel_1_list,
+        GROUP_CONCAT(DISTINCT cc.tel_2) as tel_2_list,
+        GROUP_CONCAT(DISTINCT cc.tel_3) as tel_3_list,
+        GROUP_CONCAT(DISTINCT cc.email_1) as email_1_list,
+        GROUP_CONCAT(DISTINCT cc.email_2) as email_2_list,
+        GROUP_CONCAT(DISTINCT cc.email_3) as email_3_list,
+        GROUP_CONCAT(DISTINCT cc.whatsapp_1) as whatsapp_1_list,
+        GROUP_CONCAT(DISTINCT cc.whatsapp_2) as whatsapp_2_list,
+        GROUP_CONCAT(DISTINCT cc.whatsapp_3) as whatsapp_3_list,
+        GROUP_CONCAT(DISTINCT cc.wechat_1) as wechat_1_list,
+        GROUP_CONCAT(DISTINCT cc.wechat_2) as wechat_2_list,
+        GROUP_CONCAT(DISTINCT cc.wechat_3) as wechat_3_list,
+        GROUP_CONCAT(DISTINCT cc.linkedin_1) as linkedin_1_list,
+        GROUP_CONCAT(DISTINCT cc.linkedin_2) as linkedin_2_list,
+        GROUP_CONCAT(DISTINCT cc.linkedin_3) as linkedin_3_list,
+        GROUP_CONCAT(DISTINCT cc.facebook_1) as facebook_1_list,
+        GROUP_CONCAT(DISTINCT cc.facebook_2) as facebook_2_list,
+        GROUP_CONCAT(DISTINCT cc.facebook_3) as facebook_3_list,
+        GROUP_CONCAT(DISTINCT cc.alibaba_1) as alibaba_1_list,
+        GROUP_CONCAT(DISTINCT cc.alibaba_2) as alibaba_2_list,
+        GROUP_CONCAT(DISTINCT cc.alibaba_3) as alibaba_3_list
         FROM customer c 
-        LEFT JOIN customer_contact cc ON c.id = cc.customer_id
-        WHERE c.cs_deal<>3 AND DATEDIFF(NOW(), c.cs_updatetime) > 55 AND c.cs_belong=" . $_SESSION['employee_id'] . "
-        AND (c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-        OR cc.contact_name LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.email LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.tel LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.whatsapp LIKE '%" . $conn->real_escape_string($keyscode) . "%')" . 
-        $filterStr . " ORDER BY c.cs_state DESC, c.id DESC";
+        LEFT JOIN customer_contact cc ON c.id = cc.customer_id 
+        WHERE c.cs_deal<>3 AND DATEDIFF(NOW(), c.cs_updatetime) > 55 AND c.cs_belong=" . $employee_id . "
+        AND (c.cs_code LIKE '%" . $escapedKeyscode . "%' 
+        OR cc.contact_name LIKE '%" . $escapedKeyscode . "%'
+        OR cc.email_1 LIKE '%" . $escapedKeyscode . "%' OR cc.email_2 LIKE '%" . $escapedKeyscode . "%' OR cc.email_3 LIKE '%" . $escapedKeyscode . "%'
+        OR cc.wechat_1 LIKE '%" . $escapedKeyscode . "%' OR cc.wechat_2 LIKE '%" . $escapedKeyscode . "%' OR cc.wechat_3 LIKE '%" . $escapedKeyscode . "%'
+        OR cc.tel_1 LIKE '%" . $escapedKeyscode . "%' OR cc.tel_2 LIKE '%" . $escapedKeyscode . "%' OR cc.tel_3 LIKE '%" . $escapedKeyscode . "%'
+        OR cc.whatsapp_1 LIKE '%" . $escapedKeyscode . "%' OR cc.whatsapp_2 LIKE '%" . $escapedKeyscode . "%' OR cc.whatsapp_3 LIKE '%" . $escapedKeyscode . "%')" . 
+        $filterStr . " GROUP BY c.id ORDER BY cs_state DESC, c.id DESC";
 
 $result = $conn->query($sql);
 
@@ -240,19 +272,22 @@ if ($result && $result->num_rows > 0) {
             <div class="col3 slidepanel"><?= htmlspecialcharsFix($row['cs_code']) ?></div>
             <div class="col4">
                 <?php
-                $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
+                $cs_from = intval($row['cs_from']);
+                $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . $cs_from);
                 echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
                 ?>
             </div>
             <div class="col5">
                 <?php
-                $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
+                $cs_country = intval($row['cs_country']);
+                $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . $cs_country);
                 echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
                 ?>
             </div>
             <div class="col6">
                 <?php
-                $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . (int)$row['cs_type']);
+                $cs_type = intval($row['cs_type']);
+                $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . $cs_type);
                 echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialcharsFix($typeRow['businessType']) : '未填写';
                 ?>
             </div>
@@ -285,17 +320,52 @@ if ($result && $result->num_rows > 0) {
         <div class="notepanel clear">
             <div class="noteItem">联系方式</div>
             <div class="lx">
-                <div class="tel"><?= htmlspecialcharsFix($row['cs_tel']) ?></div>
-                <div class="mail">
-                    <a href="mailto:<?= htmlspecialcharsFix($row['cs_email']) ?>">
-                        <?= htmlspecialcharsFix($row['cs_email']) ?>
-                    </a>
-                </div>
-                <div class="whatapp"><?= htmlspecialcharsFix($row['cs_whatsapp']) ?></div>
-                <div class="wechat"><?= htmlspecialcharsFix($row['cs_wechat']) ?></div>
-                <div class="linkedin"><?= htmlspecialcharsFix($row['cs_linkedin']) ?></div>
-                <div class="facebook"><?= htmlspecialcharsFix($row['cs_facebook']) ?></div>
-                <div class="alibaba"><?= htmlspecialcharsFix($row['cs_alibaba']) ?></div>
+                <?php
+                $contacts = explode(',', $row['contact_names']);
+                $contactIds = explode(',', $row['contact_ids']);
+                
+                echo '<div class="tel">';
+                if (!empty($row['tel_1_list'])) echo htmlspecialcharsFix($row['tel_1_list']) . '<br>';
+                if (!empty($row['tel_2_list'])) echo htmlspecialcharsFix($row['tel_2_list']) . '<br>';
+                if (!empty($row['tel_3_list'])) echo htmlspecialcharsFix($row['tel_3_list']);
+                echo '</div>';
+                
+                echo '<div class="mail">';
+                if (!empty($row['email_1_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_1_list']) . '">' . htmlspecialcharsFix($row['email_1_list']) . '</a><br>';
+                if (!empty($row['email_2_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_2_list']) . '">' . htmlspecialcharsFix($row['email_2_list']) . '</a><br>';
+                if (!empty($row['email_3_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_3_list']) . '">' . htmlspecialcharsFix($row['email_3_list']) . '</a>';
+                echo '</div>';
+                
+                echo '<div class="whatapp">';
+                if (!empty($row['whatsapp_1_list'])) echo htmlspecialcharsFix($row['whatsapp_1_list']) . '<br>';
+                if (!empty($row['whatsapp_2_list'])) echo htmlspecialcharsFix($row['whatsapp_2_list']) . '<br>';
+                if (!empty($row['whatsapp_3_list'])) echo htmlspecialcharsFix($row['whatsapp_3_list']);
+                echo '</div>';
+                
+                echo '<div class="wechat">';
+                if (!empty($row['wechat_1_list'])) echo htmlspecialcharsFix($row['wechat_1_list']) . '<br>';
+                if (!empty($row['wechat_2_list'])) echo htmlspecialcharsFix($row['wechat_2_list']) . '<br>';
+                if (!empty($row['wechat_3_list'])) echo htmlspecialcharsFix($row['wechat_3_list']);
+                echo '</div>';
+                
+                echo '<div class="linkedin">';
+                if (!empty($row['linkedin_1_list'])) echo htmlspecialcharsFix($row['linkedin_1_list']) . '<br>';
+                if (!empty($row['linkedin_2_list'])) echo htmlspecialcharsFix($row['linkedin_2_list']) . '<br>';
+                if (!empty($row['linkedin_3_list'])) echo htmlspecialcharsFix($row['linkedin_3_list']);
+                echo '</div>';
+                
+                echo '<div class="facebook">';
+                if (!empty($row['facebook_1_list'])) echo htmlspecialcharsFix($row['facebook_1_list']) . '<br>';
+                if (!empty($row['facebook_2_list'])) echo htmlspecialcharsFix($row['facebook_2_list']) . '<br>';
+                if (!empty($row['facebook_3_list'])) echo htmlspecialcharsFix($row['facebook_3_list']);
+                echo '</div>';
+                
+                echo '<div class="alibaba">';
+                if (!empty($row['alibaba_1_list'])) echo htmlspecialcharsFix($row['alibaba_1_list']) . '<br>';
+                if (!empty($row['alibaba_2_list'])) echo htmlspecialcharsFix($row['alibaba_2_list']) . '<br>';
+                if (!empty($row['alibaba_3_list'])) echo htmlspecialcharsFix($row['alibaba_3_list']);
+                echo '</div>';
+                ?>
             </div>
             <div class="noteItem2">备注</div>
             <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>

+ 106 - 37
customersNew.php

@@ -69,34 +69,34 @@ $filterStr = "";
 $urlStr = "";
 
 if (!empty($filterCountry)) {
-    $filterStr .= " AND cs_country=" . (int)$filterCountry;
+    $filterStr .= " AND c.cs_country=" . (int)$filterCountry;
     $urlStr .= "&fliterCountry=" . $filterCountry;
 }
 
 if (!empty($filterQudao)) {
-    $filterStr .= " AND cs_from=" . (int)$filterQudao;
+    $filterStr .= " AND c.cs_from=" . (int)$filterQudao;
     $urlStr .= "&fliterQudao=" . $filterQudao;
 }
 
 if (!empty($filterDeal)) {
-    $filterStr .= " AND cs_deal=" . (int)$filterDeal;
+    $filterStr .= " AND c.cs_deal=" . (int)$filterDeal;
     $urlStr .= "&fliterDeal=" . $filterDeal;
 }
 
 if (!empty($filterBusiness)) {
-    $filterStr .= " AND cs_type=" . (int)$filterBusiness;
+    $filterStr .= " AND c.cs_type=" . (int)$filterBusiness;
     $urlStr .= "&fliterBusiness=" . $filterBusiness;
 }
 
 if (!empty($filterContact)) {
     switch ($filterContact) {
-        case "1": $filterStr .= " AND cc.tel<>''"; break;
-        case "2": $filterStr .= " AND cc.wechat<>''"; break;
-        case "3": $filterStr .= " AND cc.whatsapp<>''"; break;
-        case "4": $filterStr .= " AND cc.email<>''"; break;
-        case "5": $filterStr .= " AND cc.linkedin<>''"; break;
-        case "6": $filterStr .= " AND cc.facebook<>''"; break;
-        default: $filterStr .= " AND cc.alibaba<>''";
+        case "1": $filterStr .= " AND (cc.tel_1 IS NOT NULL AND cc.tel_1 <> '' OR cc.tel_2 IS NOT NULL AND cc.tel_2 <> '' OR cc.tel_3 IS NOT NULL AND cc.tel_3 <> '')"; break;
+        case "2": $filterStr .= " AND (cc.wechat_1 IS NOT NULL AND cc.wechat_1 <> '' OR cc.wechat_2 IS NOT NULL AND cc.wechat_2 <> '' OR cc.wechat_3 IS NOT NULL AND cc.wechat_3 <> '')"; break;
+        case "3": $filterStr .= " AND (cc.whatsapp_1 IS NOT NULL AND cc.whatsapp_1 <> '' OR cc.whatsapp_2 IS NOT NULL AND cc.whatsapp_2 <> '' OR cc.whatsapp_3 IS NOT NULL AND cc.whatsapp_3 <> '')"; break;
+        case "4": $filterStr .= " AND (cc.email_1 IS NOT NULL AND cc.email_1 <> '' OR cc.email_2 IS NOT NULL AND cc.email_2 <> '' OR cc.email_3 IS NOT NULL AND cc.email_3 <> '')"; break;
+        case "5": $filterStr .= " AND (cc.linkedin_1 IS NOT NULL AND cc.linkedin_1 <> '' OR cc.linkedin_2 IS NOT NULL AND cc.linkedin_2 <> '' OR cc.linkedin_3 IS NOT NULL AND cc.linkedin_3 <> '')"; break;
+        case "6": $filterStr .= " AND (cc.facebook_1 IS NOT NULL AND cc.facebook_1 <> '' OR cc.facebook_2 IS NOT NULL AND cc.facebook_2 <> '' OR cc.facebook_3 IS NOT NULL AND cc.facebook_3 <> '')"; break;
+        default: $filterStr .= " AND (cc.alibaba_1 IS NOT NULL AND cc.alibaba_1 <> '' OR cc.alibaba_2 IS NOT NULL AND cc.alibaba_2 <> '' OR cc.alibaba_3 IS NOT NULL AND cc.alibaba_3 <> '')";
     }
     $urlStr .= "&fliterContact=" . $filterContact;
 }
@@ -195,22 +195,53 @@ $hrefstr = "?keys=" . $keys;
         </div>
 
 <?php
-$sql = "SELECT c.id, c.cs_code, c.cs_from, c.cs_country, c.cs_type, c.cs_deal, c.cs_addtime, 
-        cc.tel as cs_tel, cc.email as cs_email, cc.whatsapp as cs_whatsapp, cc.wechat as cs_wechat, 
-        cc.linkedin as cs_linkedin, cc.facebook as cs_facebook, cc.alibaba as cs_alibaba, 
-        c.colorTag, c.cs_note 
+$employee_id = intval($_SESSION['employee_id']);
+$escapedKeyscode = $conn->real_escape_string($keyscode);
+
+$sql = "SELECT c.id, 
+        MAX(c.cs_code) as cs_code, 
+        MAX(c.cs_from) as cs_from, 
+        MAX(c.cs_country) as cs_country, 
+        MAX(c.cs_type) as cs_type, 
+        MAX(c.cs_deal) as cs_deal, 
+        MAX(c.cs_addtime) as cs_addtime, 
+        MAX(c.colorTag) as colorTag, 
+        MAX(c.cs_note) as cs_note,
+        GROUP_CONCAT(DISTINCT cc.id) as contact_ids,
+        GROUP_CONCAT(DISTINCT cc.contact_name) as contact_names,
+        GROUP_CONCAT(DISTINCT cc.tel_1) as tel_1_list,
+        GROUP_CONCAT(DISTINCT cc.tel_2) as tel_2_list,
+        GROUP_CONCAT(DISTINCT cc.tel_3) as tel_3_list,
+        GROUP_CONCAT(DISTINCT cc.email_1) as email_1_list,
+        GROUP_CONCAT(DISTINCT cc.email_2) as email_2_list,
+        GROUP_CONCAT(DISTINCT cc.email_3) as email_3_list,
+        GROUP_CONCAT(DISTINCT cc.whatsapp_1) as whatsapp_1_list,
+        GROUP_CONCAT(DISTINCT cc.whatsapp_2) as whatsapp_2_list,
+        GROUP_CONCAT(DISTINCT cc.whatsapp_3) as whatsapp_3_list,
+        GROUP_CONCAT(DISTINCT cc.wechat_1) as wechat_1_list,
+        GROUP_CONCAT(DISTINCT cc.wechat_2) as wechat_2_list,
+        GROUP_CONCAT(DISTINCT cc.wechat_3) as wechat_3_list,
+        GROUP_CONCAT(DISTINCT cc.linkedin_1) as linkedin_1_list,
+        GROUP_CONCAT(DISTINCT cc.linkedin_2) as linkedin_2_list,
+        GROUP_CONCAT(DISTINCT cc.linkedin_3) as linkedin_3_list,
+        GROUP_CONCAT(DISTINCT cc.facebook_1) as facebook_1_list,
+        GROUP_CONCAT(DISTINCT cc.facebook_2) as facebook_2_list,
+        GROUP_CONCAT(DISTINCT cc.facebook_3) as facebook_3_list,
+        GROUP_CONCAT(DISTINCT cc.alibaba_1) as alibaba_1_list,
+        GROUP_CONCAT(DISTINCT cc.alibaba_2) as alibaba_2_list,
+        GROUP_CONCAT(DISTINCT cc.alibaba_3) as alibaba_3_list
         FROM customer c 
         LEFT JOIN customer_contact cc ON c.id = cc.customer_id 
-        WHERE c.cs_belong=" . $_SESSION['employee_id'] . " 
+        WHERE c.cs_belong=" . $employee_id . " 
         AND MONTH(c.cs_addtime) = MONTH(CURRENT_DATE()) 
         AND YEAR(c.cs_addtime) = YEAR(CURRENT_DATE())
-        AND (c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-        OR cc.contact_name LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.email LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.tel LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.whatsapp LIKE '%" . $conn->real_escape_string($keyscode) . "%')" . 
-        $filterStr . " ORDER BY c.id DESC";
+        AND (c.cs_code LIKE '%" . $escapedKeyscode . "%' 
+        OR cc.contact_name LIKE '%" . $escapedKeyscode . "%'
+        OR cc.email_1 LIKE '%" . $escapedKeyscode . "%' OR cc.email_2 LIKE '%" . $escapedKeyscode . "%' OR cc.email_3 LIKE '%" . $escapedKeyscode . "%'
+        OR cc.wechat_1 LIKE '%" . $escapedKeyscode . "%' OR cc.wechat_2 LIKE '%" . $escapedKeyscode . "%' OR cc.wechat_3 LIKE '%" . $escapedKeyscode . "%'
+        OR cc.tel_1 LIKE '%" . $escapedKeyscode . "%' OR cc.tel_2 LIKE '%" . $escapedKeyscode . "%' OR cc.tel_3 LIKE '%" . $escapedKeyscode . "%'
+        OR cc.whatsapp_1 LIKE '%" . $escapedKeyscode . "%' OR cc.whatsapp_2 LIKE '%" . $escapedKeyscode . "%' OR cc.whatsapp_3 LIKE '%" . $escapedKeyscode . "%')" . 
+        $filterStr . " GROUP BY c.id ORDER BY c.id DESC";
 
 $result = $conn->query($sql);
 
@@ -242,19 +273,22 @@ if ($result && $result->num_rows > 0) {
             <div class="col3 slidepanel"><?= htmlspecialcharsFix($row['cs_code']) ?></div>
             <div class="col4">
                 <?php
-                $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
+                $cs_from = intval($row['cs_from']);
+                $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . $cs_from);
                 echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
                 ?>
             </div>
             <div class="col5">
                 <?php
-                $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
+                $cs_country = intval($row['cs_country']);
+                $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . $cs_country);
                 echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
                 ?>
             </div>
             <div class="col6">
                 <?php
-                $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . (int)$row['cs_type']);
+                $cs_type = intval($row['cs_type']);
+                $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . $cs_type);
                 echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialcharsFix($typeRow['businessType']) : '未填写';
                 ?>
             </div>
@@ -289,17 +323,52 @@ if ($result && $result->num_rows > 0) {
         <div class="notepanel clear">
             <div class="noteItem">联系方式</div>
             <div class="lx">
-                <div class="tel"><?= htmlspecialcharsFix($row['cs_tel']) ?></div>
-                <div class="mail">
-                    <a href="mailto:<?= htmlspecialcharsFix($row['cs_email']) ?>">
-                        <?= htmlspecialcharsFix($row['cs_email']) ?>
-                    </a>
-                </div>
-                <div class="whatsapp"><?= htmlspecialcharsFix($row['cs_whatsapp']) ?></div>
-                <div class="wechat"><?= htmlspecialcharsFix($row['cs_wechat']) ?></div>
-                <div class="linkedin"><?= htmlspecialcharsFix($row['cs_linkedin']) ?></div>
-                <div class="facebook"><?= htmlspecialcharsFix($row['cs_facebook']) ?></div>
-                <div class="alibaba"><?= htmlspecialcharsFix($row['cs_alibaba']) ?></div>
+                <?php
+                $contacts = explode(',', $row['contact_names']);
+                $contactIds = explode(',', $row['contact_ids']);
+                
+                echo '<div class="tel">';
+                if (!empty($row['tel_1_list'])) echo htmlspecialcharsFix($row['tel_1_list']) . '<br>';
+                if (!empty($row['tel_2_list'])) echo htmlspecialcharsFix($row['tel_2_list']) . '<br>';
+                if (!empty($row['tel_3_list'])) echo htmlspecialcharsFix($row['tel_3_list']);
+                echo '</div>';
+                
+                echo '<div class="mail">';
+                if (!empty($row['email_1_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_1_list']) . '">' . htmlspecialcharsFix($row['email_1_list']) . '</a><br>';
+                if (!empty($row['email_2_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_2_list']) . '">' . htmlspecialcharsFix($row['email_2_list']) . '</a><br>';
+                if (!empty($row['email_3_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_3_list']) . '">' . htmlspecialcharsFix($row['email_3_list']) . '</a>';
+                echo '</div>';
+                
+                echo '<div class="whatsapp">';
+                if (!empty($row['whatsapp_1_list'])) echo htmlspecialcharsFix($row['whatsapp_1_list']) . '<br>';
+                if (!empty($row['whatsapp_2_list'])) echo htmlspecialcharsFix($row['whatsapp_2_list']) . '<br>';
+                if (!empty($row['whatsapp_3_list'])) echo htmlspecialcharsFix($row['whatsapp_3_list']);
+                echo '</div>';
+                
+                echo '<div class="wechat">';
+                if (!empty($row['wechat_1_list'])) echo htmlspecialcharsFix($row['wechat_1_list']) . '<br>';
+                if (!empty($row['wechat_2_list'])) echo htmlspecialcharsFix($row['wechat_2_list']) . '<br>';
+                if (!empty($row['wechat_3_list'])) echo htmlspecialcharsFix($row['wechat_3_list']);
+                echo '</div>';
+                
+                echo '<div class="linkedin">';
+                if (!empty($row['linkedin_1_list'])) echo htmlspecialcharsFix($row['linkedin_1_list']) . '<br>';
+                if (!empty($row['linkedin_2_list'])) echo htmlspecialcharsFix($row['linkedin_2_list']) . '<br>';
+                if (!empty($row['linkedin_3_list'])) echo htmlspecialcharsFix($row['linkedin_3_list']);
+                echo '</div>';
+                
+                echo '<div class="facebook">';
+                if (!empty($row['facebook_1_list'])) echo htmlspecialcharsFix($row['facebook_1_list']) . '<br>';
+                if (!empty($row['facebook_2_list'])) echo htmlspecialcharsFix($row['facebook_2_list']) . '<br>';
+                if (!empty($row['facebook_3_list'])) echo htmlspecialcharsFix($row['facebook_3_list']);
+                echo '</div>';
+                
+                echo '<div class="alibaba">';
+                if (!empty($row['alibaba_1_list'])) echo htmlspecialcharsFix($row['alibaba_1_list']) . '<br>';
+                if (!empty($row['alibaba_2_list'])) echo htmlspecialcharsFix($row['alibaba_2_list']) . '<br>';
+                if (!empty($row['alibaba_3_list'])) echo htmlspecialcharsFix($row['alibaba_3_list']);
+                echo '</div>';
+                ?>
             </div>
             <div class="noteItem2">备注</div>
             <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>

+ 127 - 14
highSeas.php

@@ -67,6 +67,9 @@ if (!empty($filterBelong)) {
 
 $keys = urlencode($keys);
 $hrefstr = "?keys=" . $keys;
+
+// 使用SQL拼接方式
+$employee_id = intval($_SESSION['employee_id']);
 ?>
 <form id="form1" method="post" action="?act=postchk&Keys=<?= $keys ?>&Page=<?= $page ?>" onSubmit="return false">
     <div class="fastSelect clear">
@@ -147,23 +150,70 @@ $hrefstr = "?keys=" . $keys;
         </div>
 
 <?php
-$sql = "SELECT c.id, c.cs_code, c.cs_from, c.cs_country, c.cs_type, c.cs_deal, c.cs_addtime, 
-        c.cs_updatetime, c.cs_note, c.cs_claimFrom 
+// 使用SQL拼接方式,同时适配新的customer_contact表结构
+$escapedKeyscode = $conn->real_escape_string($keyscode);
+
+$sql = "SELECT c.id, 
+        MAX(c.cs_code) as cs_code, 
+        MAX(c.cs_from) as cs_from, 
+        MAX(c.cs_country) as cs_country, 
+        MAX(c.cs_type) as cs_type, 
+        MAX(c.cs_deal) as cs_deal, 
+        MAX(c.cs_addtime) as cs_addtime, 
+        MAX(c.cs_updatetime) as cs_updatetime, 
+        MAX(c.cs_note) as cs_note,
+        MAX(c.cs_claimFrom) as cs_claimFrom,
+        MAX(c.cs_state) as cs_state,
+        GROUP_CONCAT(DISTINCT cc.id) as contact_ids,
+        GROUP_CONCAT(DISTINCT cc.contact_name) as contact_names,
+        GROUP_CONCAT(DISTINCT cc.tel_1) as tel_1_list,
+        GROUP_CONCAT(DISTINCT cc.tel_2) as tel_2_list,
+        GROUP_CONCAT(DISTINCT cc.tel_3) as tel_3_list,
+        GROUP_CONCAT(DISTINCT cc.email_1) as email_1_list,
+        GROUP_CONCAT(DISTINCT cc.email_2) as email_2_list,
+        GROUP_CONCAT(DISTINCT cc.email_3) as email_3_list,
+        GROUP_CONCAT(DISTINCT cc.whatsapp_1) as whatsapp_1_list,
+        GROUP_CONCAT(DISTINCT cc.whatsapp_2) as whatsapp_2_list,
+        GROUP_CONCAT(DISTINCT cc.whatsapp_3) as whatsapp_3_list,
+        GROUP_CONCAT(DISTINCT cc.wechat_1) as wechat_1_list,
+        GROUP_CONCAT(DISTINCT cc.wechat_2) as wechat_2_list,
+        GROUP_CONCAT(DISTINCT cc.wechat_3) as wechat_3_list,
+        GROUP_CONCAT(DISTINCT cc.linkedin_1) as linkedin_1_list,
+        GROUP_CONCAT(DISTINCT cc.linkedin_2) as linkedin_2_list,
+        GROUP_CONCAT(DISTINCT cc.linkedin_3) as linkedin_3_list,
+        GROUP_CONCAT(DISTINCT cc.facebook_1) as facebook_1_list,
+        GROUP_CONCAT(DISTINCT cc.facebook_2) as facebook_2_list,
+        GROUP_CONCAT(DISTINCT cc.facebook_3) as facebook_3_list,
+        GROUP_CONCAT(DISTINCT cc.alibaba_1) as alibaba_1_list,
+        GROUP_CONCAT(DISTINCT cc.alibaba_2) as alibaba_2_list,
+        GROUP_CONCAT(DISTINCT cc.alibaba_3) as alibaba_3_list
         FROM customer c
         LEFT JOIN customer_contact cc ON c.id = cc.customer_id
         WHERE c.cs_deal<>3 AND c.cs_deal<>0 AND c.cs_type<>2 AND c.cs_belong<>13 
-        AND c.cs_belong<>" . $_SESSION['employee_id'] . " 
+        AND c.cs_belong<>" . $employee_id . " 
         AND DATEDIFF(NOW(), c.cs_updatetime) > 120 
         AND c.cs_country NOT IN (2, 229, 13, 153) 
         AND c.cs_belongclient=0 
-        AND cc.wechat NOT LIKE 'wxid%' 
-        AND (c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-        OR cc.contact_name LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.email LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.tel LIKE '%" . $conn->real_escape_string($keyscode) . "%'
-        OR cc.whatsapp LIKE '%" . $conn->real_escape_string($keyscode) . "%')" . 
-        $filterStr . " ORDER BY c.cs_state DESC, c.id DESC";
+        AND NOT EXISTS (
+            SELECT 1 FROM customer_contact 
+            WHERE customer_id = c.id 
+            AND wechat_1 LIKE 'wxid%'
+        )
+        AND (c.cs_code LIKE '%" . $escapedKeyscode . "%' 
+        OR cc.contact_name LIKE '%" . $escapedKeyscode . "%'
+        OR cc.email_1 LIKE '%" . $escapedKeyscode . "%' 
+        OR cc.email_2 LIKE '%" . $escapedKeyscode . "%' 
+        OR cc.email_3 LIKE '%" . $escapedKeyscode . "%'
+        OR cc.wechat_1 LIKE '%" . $escapedKeyscode . "%' 
+        OR cc.wechat_2 LIKE '%" . $escapedKeyscode . "%' 
+        OR cc.wechat_3 LIKE '%" . $escapedKeyscode . "%'
+        OR cc.tel_1 LIKE '%" . $escapedKeyscode . "%' 
+        OR cc.tel_2 LIKE '%" . $escapedKeyscode . "%' 
+        OR cc.tel_3 LIKE '%" . $escapedKeyscode . "%'
+        OR cc.whatsapp_1 LIKE '%" . $escapedKeyscode . "%'
+        OR cc.whatsapp_2 LIKE '%" . $escapedKeyscode . "%'
+        OR cc.whatsapp_3 LIKE '%" . $escapedKeyscode . "%')" . 
+        $filterStr . " GROUP BY c.id ORDER BY cs_state DESC, c.id DESC";
 
 $result = $conn->query($sql);
 
@@ -194,19 +244,25 @@ if ($result && $result->num_rows > 0) {
             <div class="col3 slidepanel"><?= htmlspecialcharsFix($row['cs_code']) ?></div>
             <div class="col4">
                 <?php
-                $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
+                // 使用SQL拼接方式
+                $cs_from = intval($row['cs_from']);
+                $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . $cs_from);
                 echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
                 ?>
             </div>
             <div class="col5">
                 <?php
-                $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
+                // 使用SQL拼接方式
+                $cs_country = intval($row['cs_country']);
+                $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . $cs_country);
                 echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
                 ?>
             </div>
             <div class="col6">
                 <?php
-                $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . (int)$row['cs_type']);
+                // 使用SQL拼接方式
+                $cs_type = intval($row['cs_type']);
+                $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . $cs_type);
                 echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialcharsFix($typeRow['businessType']) : '未填写';
                 ?>
             </div>
@@ -223,6 +279,63 @@ if ($result && $result->num_rows > 0) {
             <div class="col4"><span id="claim1" class="claim" data-id="<?= $row['id'] ?>">认领</span></div>
         </div>
         <div class="notepanel clear">
+            <div class="noteItem">联系方式</div>
+            <div class="lx">
+                <?php
+                // 显示联系人和联系方式
+                $contacts = explode(',', $row['contact_names']);
+                $contactIds = explode(',', $row['contact_ids']);
+                
+                // 处理电话
+                echo '<div class="tel">';
+                if (!empty($row['tel_1_list'])) echo htmlspecialcharsFix($row['tel_1_list']) . '<br>';
+                if (!empty($row['tel_2_list'])) echo htmlspecialcharsFix($row['tel_2_list']) . '<br>';
+                if (!empty($row['tel_3_list'])) echo htmlspecialcharsFix($row['tel_3_list']);
+                echo '</div>';
+                
+                // 处理邮箱
+                echo '<div class="mail">';
+                if (!empty($row['email_1_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_1_list']) . '">' . htmlspecialcharsFix($row['email_1_list']) . '</a><br>';
+                if (!empty($row['email_2_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_2_list']) . '">' . htmlspecialcharsFix($row['email_2_list']) . '</a><br>';
+                if (!empty($row['email_3_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_3_list']) . '">' . htmlspecialcharsFix($row['email_3_list']) . '</a>';
+                echo '</div>';
+                
+                // 处理WhatsApp
+                echo '<div class="whatsapp">';
+                if (!empty($row['whatsapp_1_list'])) echo htmlspecialcharsFix($row['whatsapp_1_list']) . '<br>';
+                if (!empty($row['whatsapp_2_list'])) echo htmlspecialcharsFix($row['whatsapp_2_list']) . '<br>';
+                if (!empty($row['whatsapp_3_list'])) echo htmlspecialcharsFix($row['whatsapp_3_list']);
+                echo '</div>';
+                
+                // 处理微信
+                echo '<div class="wechat">';
+                if (!empty($row['wechat_1_list'])) echo htmlspecialcharsFix($row['wechat_1_list']) . '<br>';
+                if (!empty($row['wechat_2_list'])) echo htmlspecialcharsFix($row['wechat_2_list']) . '<br>';
+                if (!empty($row['wechat_3_list'])) echo htmlspecialcharsFix($row['wechat_3_list']);
+                echo '</div>';
+                
+                // 处理LinkedIn
+                echo '<div class="linkedin">';
+                if (!empty($row['linkedin_1_list'])) echo htmlspecialcharsFix($row['linkedin_1_list']) . '<br>';
+                if (!empty($row['linkedin_2_list'])) echo htmlspecialcharsFix($row['linkedin_2_list']) . '<br>';
+                if (!empty($row['linkedin_3_list'])) echo htmlspecialcharsFix($row['linkedin_3_list']);
+                echo '</div>';
+                
+                // 处理Facebook
+                echo '<div class="facebook">';
+                if (!empty($row['facebook_1_list'])) echo htmlspecialcharsFix($row['facebook_1_list']) . '<br>';
+                if (!empty($row['facebook_2_list'])) echo htmlspecialcharsFix($row['facebook_2_list']) . '<br>';
+                if (!empty($row['facebook_3_list'])) echo htmlspecialcharsFix($row['facebook_3_list']);
+                echo '</div>';
+                
+                // 处理阿里巴巴
+                echo '<div class="alibaba">';
+                if (!empty($row['alibaba_1_list'])) echo htmlspecialcharsFix($row['alibaba_1_list']) . '<br>';
+                if (!empty($row['alibaba_2_list'])) echo htmlspecialcharsFix($row['alibaba_2_list']) . '<br>';
+                if (!empty($row['alibaba_3_list'])) echo htmlspecialcharsFix($row['alibaba_3_list']);
+                echo '</div>';
+                ?>
+            </div>
             <div class="noteItem2">备注</div>
             <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
         </div>

+ 163 - 45
silentCustomer.php

@@ -12,7 +12,7 @@ if ($act == 'postchk') {
     $sqlStr = "";
     if (isset($_POST['chkbox'])) {
         foreach ($_POST['chkbox'] as $id) {
-            $sqlStr .= ($sqlStr ? " OR id=" : " WHERE id=") . (int)$id;
+            $sqlStr .= ($sqlStr ? " OR id=" : " WHERE id=") . intval($id);
         }
     }
     
@@ -20,11 +20,11 @@ if ($act == 'postchk') {
         case "0":
         case "1":
         case "2":
-            $sqlStr = "UPDATE customer SET cs_deal=" . (int)$chkact . $sqlStr;
+            $sqlStr = "UPDATE customer SET cs_deal=" . intval($chkact) . $sqlStr;
             break;
         default:
             $chkact = str_replace('t', '', $chkact);
-            $sqlStr = "UPDATE customer SET cs_belong=" . (int)$chkact . $sqlStr;
+            $sqlStr = "UPDATE customer SET cs_belong=" . intval($chkact) . $sqlStr;
     }
     
     $conn->query($sqlStr);
@@ -47,34 +47,47 @@ $filterStr = "";
 $urlStr = "";
 
 if (!empty($filterCountry)) {
-    $filterStr .= " AND c.cs_country=" . (int)$filterCountry;
+    $filterStr .= " AND c.cs_country=" . intval($filterCountry);
     $urlStr .= "&fliterCountry=" . $filterCountry;
 }
 
 if (!empty($filterQudao)) {
-    $filterStr .= " AND c.cs_from=" . (int)$filterQudao;
+    $filterStr .= " AND c.cs_from=" . intval($filterQudao);
     $urlStr .= "&fliterQudao=" . $filterQudao;
 }
 
 if (!empty($filterDeal)) {
-    $filterStr .= " AND c.cs_deal=" . (int)$filterDeal;
+    $filterStr .= " AND c.cs_deal=" . intval($filterDeal);
     $urlStr .= "&fliterDeal=" . $filterDeal;
 }
 
 if (!empty($filterBusiness)) {
-    $filterStr .= " AND c.cs_type=" . (int)$filterBusiness;
+    $filterStr .= " AND c.cs_type=" . intval($filterBusiness);
     $urlStr .= "&fliterBusiness=" . $filterBusiness;
 }
 
 if (!empty($filterContact)) {
     switch ($filterContact) {
-        case "1": $filterStr .= " AND cc.tel<>''"; break;
-        case "2": $filterStr .= " AND cc.wechat<>''"; break;
-        case "3": $filterStr .= " AND cc.whatsapp<>''"; break;
-        case "4": $filterStr .= " AND cc.email<>''"; break;
-        case "5": $filterStr .= " AND cc.linkedin<>''"; break;
-        case "6": $filterStr .= " AND cc.facebook<>''"; break;
-        default: $filterStr .= " AND cc.alibaba<>''";
+        case "1": 
+            $filterStr .= " AND (cc.tel_1<>'' OR cc.tel_2<>'' OR cc.tel_3<>'')"; 
+            break;
+        case "2": 
+            $filterStr .= " AND (cc.wechat_1<>'' OR cc.wechat_2<>'' OR cc.wechat_3<>'')"; 
+            break;
+        case "3": 
+            $filterStr .= " AND (cc.whatsapp_1<>'' OR cc.whatsapp_2<>'' OR cc.whatsapp_3<>'')"; 
+            break;
+        case "4": 
+            $filterStr .= " AND (cc.email_1<>'' OR cc.email_2<>'' OR cc.email_3<>'')"; 
+            break;
+        case "5": 
+            $filterStr .= " AND (cc.linkedin_1<>'' OR cc.linkedin_2<>'' OR cc.linkedin_3<>'')"; 
+            break;
+        case "6": 
+            $filterStr .= " AND (cc.facebook_1<>'' OR cc.facebook_2<>'' OR cc.facebook_3<>'')"; 
+            break;
+        default: 
+            $filterStr .= " AND (cc.alibaba_1<>'' OR cc.alibaba_2<>'' OR cc.alibaba_3<>'')";
     }
     $urlStr .= "&fliterContact=" . $filterContact;
 }
@@ -194,21 +207,67 @@ $hrefstr = "?keys=" . $keys;
             </div>
 
 <?php
-$sqlStr = "SELECT c.id, c.cs_code, c.cs_from, c.cs_country, c.cs_type, c.cs_deal, c.cs_addtime, 
-           cc.tel as cs_tel, cc.email as cs_email, cc.whatsapp as cs_whatsapp, cc.wechat as cs_wechat, 
-           cc.linkedin as cs_linkedin, cc.facebook as cs_facebook, cc.alibaba as cs_alibaba, 
-           c.colortag, c.cs_note, c.cs_claimFrom, c.cs_belong, c.cs_chain 
-           FROM customer c 
-           LEFT JOIN customer_contact cc ON c.id = cc.customer_id
-           WHERE (c.is_silent=1 OR (c.cs_deal=0 AND c.cs_belong=" . $_SESSION['employee_id'] . ")) 
-           AND (c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+// 使用GROUP BY和GROUP_CONCAT来聚合多个联系人的信息
+$sqlStr = "SELECT c.id, MAX(c.cs_code) as cs_code, MAX(c.cs_from) as cs_from, 
+         MAX(c.cs_country) as cs_country, MAX(c.cs_type) as cs_type, MAX(c.cs_deal) as cs_deal, 
+         MAX(c.cs_addtime) as cs_addtime, MAX(c.colortag) as colortag, 
+         MAX(c.cs_note) as cs_note, MAX(c.cs_claimFrom) as cs_claimFrom, 
+         MAX(c.cs_belong) as cs_belong, MAX(c.cs_chain) as cs_chain,
+         GROUP_CONCAT(cc.contact_name SEPARATOR '<br>') as contact_names,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.tel_1, '') SEPARATOR '<br>') as tel_1,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.tel_2, '') SEPARATOR '<br>') as tel_2,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.tel_3, '') SEPARATOR '<br>') as tel_3,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.tel_1_format, '') SEPARATOR '<br>') as tel_1_format,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.tel_2_format, '') SEPARATOR '<br>') as tel_2_format,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.tel_3_format, '') SEPARATOR '<br>') as tel_3_format,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.email_1, '') SEPARATOR '<br>') as email_1,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.email_2, '') SEPARATOR '<br>') as email_2,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.email_3, '') SEPARATOR '<br>') as email_3,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_1, '') SEPARATOR '<br>') as whatsapp_1,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_2, '') SEPARATOR '<br>') as whatsapp_2,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_3, '') SEPARATOR '<br>') as whatsapp_3,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_1_format, '') SEPARATOR '<br>') as whatsapp_1_format,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_2_format, '') SEPARATOR '<br>') as whatsapp_2_format,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_3_format, '') SEPARATOR '<br>') as whatsapp_3_format,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.wechat_1, '') SEPARATOR '<br>') as wechat_1,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.wechat_2, '') SEPARATOR '<br>') as wechat_2,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.wechat_3, '') SEPARATOR '<br>') as wechat_3,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.linkedin_1, '') SEPARATOR '<br>') as linkedin_1,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.linkedin_2, '') SEPARATOR '<br>') as linkedin_2,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.linkedin_3, '') SEPARATOR '<br>') as linkedin_3,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.facebook_1, '') SEPARATOR '<br>') as facebook_1,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.facebook_2, '') SEPARATOR '<br>') as facebook_2,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.facebook_3, '') SEPARATOR '<br>') as facebook_3,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.alibaba_1, '') SEPARATOR '<br>') as alibaba_1,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.alibaba_2, '') SEPARATOR '<br>') as alibaba_2,
+         GROUP_CONCAT(DISTINCT NULLIF(cc.alibaba_3, '') SEPARATOR '<br>') as alibaba_3
+         FROM customer c 
+         LEFT JOIN customer_contact cc ON c.id = cc.customer_id
+         WHERE (c.is_silent=1 OR (c.cs_deal=0 AND c.cs_belong=" . intval($_SESSION['employee_id']) . "))";
+
+// 添加搜索条件
+if (!empty($keyscode)) {
+    $sqlStr .= " AND (c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
            OR cc.contact_name LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-           OR cc.email LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-           OR cc.wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-           OR cc.tel_format LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-           OR cc.whatsapp_format LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-           OR c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%')" . 
-           $filterStr . " ORDER BY c.colortag DESC, c.id DESC";
+           OR cc.email_1 LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.email_2 LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.email_3 LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.wechat_1 LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.wechat_2 LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.wechat_3 LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.tel_1_format LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.tel_2_format LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.tel_3_format LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.whatsapp_1_format LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.whatsapp_2_format LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.whatsapp_3_format LIKE '%" . $conn->real_escape_string($keyscode) . "%')";
+}
+
+// 添加其他筛选条件
+$sqlStr .= $filterStr;
+
+// 分组和排序
+$sqlStr .= " GROUP BY c.id ORDER BY MAX(c.colortag) DESC, c.id DESC";
 
 $result = $conn->query($sqlStr);
 
@@ -242,19 +301,19 @@ if ($result && $result->num_rows > 0) {
             </div>
             <div class="col10">
                 <?php
-                $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
+                $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . intval($row['cs_from']));
                 echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
                 ?>
             </div>
             <div class="col10">
                 <?php
-                $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
+                $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . intval($row['cs_country']));
                 echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
                 ?>
             </div>
             <div class="col10">
                 <?php
-                $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . (int)$row['cs_type']);
+                $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . intval($row['cs_type']));
                 echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialcharsFix($typeRow['businessType']) : '未填写';
                 ?>
             </div>
@@ -281,13 +340,69 @@ if ($result && $result->num_rows > 0) {
         <div class="notepanel clear">
             <div class="noteItem">联系方式</div>
             <div class="lx">
-                <div class="tel"><?= htmlspecialcharsFix($row['cs_tel']) ?></div>
-                <div class="mail"><a href="mailto:<?= htmlspecialcharsFix($row['cs_email']) ?>"><?= htmlspecialcharsFix($row['cs_email']) ?></a></div>
-                <div class="whatsapp"><?= htmlspecialcharsFix($row['cs_whatsapp']) ?></div>
-                <div class="wechat"><?= htmlspecialcharsFix($row['cs_wechat']) ?></div>
-                <div class="linkedin"><?= htmlspecialcharsFix($row['cs_linkedin']) ?></div>
-                <div class="facebook"><?= htmlspecialcharsFix($row['cs_facebook']) ?></div>
-                <div class="alibaba"><?= htmlspecialcharsFix($row['cs_alibaba']) ?></div>
+                <div class="tel">
+                    <?php
+                    $tels = [];
+                    if (!empty($row['tel_1'])) $tels[] = htmlspecialcharsFix($row['tel_1']);
+                    if (!empty($row['tel_2'])) $tels[] = htmlspecialcharsFix($row['tel_2']);
+                    if (!empty($row['tel_3'])) $tels[] = htmlspecialcharsFix($row['tel_3']);
+                    echo implode('<br>', $tels);
+                    ?>
+                </div>
+                <div class="mail">
+                    <?php
+                    $emails = [];
+                    if (!empty($row['email_1'])) $emails[] = '<a href="mailto:' . htmlspecialcharsFix($row['email_1']) . '">' . htmlspecialcharsFix($row['email_1']) . '</a>';
+                    if (!empty($row['email_2'])) $emails[] = '<a href="mailto:' . htmlspecialcharsFix($row['email_2']) . '">' . htmlspecialcharsFix($row['email_2']) . '</a>';
+                    if (!empty($row['email_3'])) $emails[] = '<a href="mailto:' . htmlspecialcharsFix($row['email_3']) . '">' . htmlspecialcharsFix($row['email_3']) . '</a>';
+                    echo implode('<br>', $emails);
+                    ?>
+                </div>
+                <div class="whatsapp">
+                    <?php
+                    $whatsapps = [];
+                    if (!empty($row['whatsapp_1'])) $whatsapps[] = htmlspecialcharsFix($row['whatsapp_1']);
+                    if (!empty($row['whatsapp_2'])) $whatsapps[] = htmlspecialcharsFix($row['whatsapp_2']);
+                    if (!empty($row['whatsapp_3'])) $whatsapps[] = htmlspecialcharsFix($row['whatsapp_3']);
+                    echo implode('<br>', $whatsapps);
+                    ?>
+                </div>
+                <div class="wechat">
+                    <?php
+                    $wechats = [];
+                    if (!empty($row['wechat_1'])) $wechats[] = htmlspecialcharsFix($row['wechat_1']);
+                    if (!empty($row['wechat_2'])) $wechats[] = htmlspecialcharsFix($row['wechat_2']);
+                    if (!empty($row['wechat_3'])) $wechats[] = htmlspecialcharsFix($row['wechat_3']);
+                    echo implode('<br>', $wechats);
+                    ?>
+                </div>
+                <div class="linkedin">
+                    <?php
+                    $linkedins = [];
+                    if (!empty($row['linkedin_1'])) $linkedins[] = htmlspecialcharsFix($row['linkedin_1']);
+                    if (!empty($row['linkedin_2'])) $linkedins[] = htmlspecialcharsFix($row['linkedin_2']);
+                    if (!empty($row['linkedin_3'])) $linkedins[] = htmlspecialcharsFix($row['linkedin_3']);
+                    echo implode('<br>', $linkedins);
+                    ?>
+                </div>
+                <div class="facebook">
+                    <?php
+                    $facebooks = [];
+                    if (!empty($row['facebook_1'])) $facebooks[] = htmlspecialcharsFix($row['facebook_1']);
+                    if (!empty($row['facebook_2'])) $facebooks[] = htmlspecialcharsFix($row['facebook_2']);
+                    if (!empty($row['facebook_3'])) $facebooks[] = htmlspecialcharsFix($row['facebook_3']);
+                    echo implode('<br>', $facebooks);
+                    ?>
+                </div>
+                <div class="alibaba">
+                    <?php
+                    $alibabas = [];
+                    if (!empty($row['alibaba_1'])) $alibabas[] = htmlspecialcharsFix($row['alibaba_1']);
+                    if (!empty($row['alibaba_2'])) $alibabas[] = htmlspecialcharsFix($row['alibaba_2']);
+                    if (!empty($row['alibaba_3'])) $alibabas[] = htmlspecialcharsFix($row['alibaba_3']);
+                    echo implode('<br>', $alibabas);
+                    ?>
+                </div>
             </div>
             <div class="noteItem2">备注</div>
             <div class="notecontent">
@@ -296,14 +411,17 @@ if ($result && $result->num_rows > 0) {
                     <?php
                     if (!empty($row['cs_chain'])) {
                         $myArray = explode(',', $row['cs_chain']);
-                        $sqlStr = "SELECT em_user FROM employee WHERE id=" . (int)$myArray[0];
-                        for ($j = 1; $j < count($myArray); $j++) {
-                            $sqlStr .= " UNION ALL SELECT em_user FROM employee WHERE id=" . (int)$myArray[$j];
-                        }
-                        $chainResult = $conn->query($sqlStr);
-                        while ($chainRow = $chainResult->fetch_assoc()) {
-                            echo htmlspecialcharsFix($chainRow['em_user']) . " > ";
+                        $chainEmployees = [];
+                        
+                        foreach ($myArray as $employeeId) {
+                            $sqlStr = "SELECT em_user FROM employee WHERE id=" . intval($employeeId);
+                            $chainResult = $conn->query($sqlStr);
+                            if ($chainRow = $chainResult->fetch_assoc()) {
+                                $chainEmployees[] = htmlspecialcharsFix($chainRow['em_user']);
+                            }
                         }
+                        
+                        echo implode(" > ", $chainEmployees);
                     }
                     ?>
                 </div>

+ 131 - 18
teamSeas.php

@@ -46,10 +46,14 @@ $hrefstr = "?keys=" . $keys;
 
 $_SESSION['em_role'] = $_SESSION['em_role'] ?? 0;
 
-if ($_SESSION['em_role'] == 0) {
-    $memberStr = "SELECT id FROM employee WHERE em_role=" . $_SESSION['employee_id'] . " OR id=" . $_SESSION['employee_id'];
+// 使用SQL拼接方式
+$employee_id = intval($_SESSION['employee_id']);
+$em_role = intval($_SESSION['em_role']);
+
+if ($em_role == 0) {
+    $memberStr = "SELECT id FROM employee WHERE em_role=" . $employee_id . " OR id=" . $employee_id;
 } else {
-    $memberStr = "SELECT id FROM employee WHERE em_role=" . $_SESSION['em_role'] . " OR id=" . $_SESSION['em_role'];
+    $memberStr = "SELECT id FROM employee WHERE em_role=" . $em_role . " OR id=" . $em_role;
 }
 ?>
 <!DOCTYPE html>
@@ -154,24 +158,70 @@ if ($_SESSION['em_role'] == 0) {
             </div>
 
             <?php
-            $sqlStr = "SELECT c.*, cc.contact_name as cs_name, cc.tel as cs_tel, cc.email as cs_email,
-                      cc.whatsapp as cs_whatsapp, cc.wechat as cs_wechat, cc.linkedin as cs_linkedin,
-                      cc.facebook as cs_facebook, cc.alibaba as cs_alibaba
+            // 使用SQL拼接方式,同时适配新的customer_contact表结构
+            $escapedKeyscode = $conn->real_escape_string($keyscode);
+            
+            $sqlStr = "SELECT c.id, 
+                      MAX(c.cs_code) as cs_code,
+                      MAX(c.cs_from) as cs_from,
+                      MAX(c.cs_country) as cs_country,
+                      MAX(c.cs_type) as cs_type,
+                      MAX(c.cs_deal) as cs_deal,
+                      MAX(c.cs_updatetime) as cs_updatetime,
+                      MAX(c.cs_note) as cs_note,
+                      MAX(c.cs_state) as cs_state,
+                      MAX(c.cs_claimFrom) as cs_claimFrom,
+                      MAX(c.cs_belongclient) as cs_belongclient,
+                      GROUP_CONCAT(DISTINCT cc.id) as contact_ids,
+                      GROUP_CONCAT(DISTINCT cc.contact_name) as contact_names,
+                      GROUP_CONCAT(DISTINCT cc.tel_1) as tel_1_list,
+                      GROUP_CONCAT(DISTINCT cc.tel_2) as tel_2_list,
+                      GROUP_CONCAT(DISTINCT cc.tel_3) as tel_3_list,
+                      GROUP_CONCAT(DISTINCT cc.email_1) as email_1_list,
+                      GROUP_CONCAT(DISTINCT cc.email_2) as email_2_list,
+                      GROUP_CONCAT(DISTINCT cc.email_3) as email_3_list,
+                      GROUP_CONCAT(DISTINCT cc.whatsapp_1) as whatsapp_1_list,
+                      GROUP_CONCAT(DISTINCT cc.whatsapp_2) as whatsapp_2_list,
+                      GROUP_CONCAT(DISTINCT cc.whatsapp_3) as whatsapp_3_list,
+                      GROUP_CONCAT(DISTINCT cc.wechat_1) as wechat_1_list,
+                      GROUP_CONCAT(DISTINCT cc.wechat_2) as wechat_2_list,
+                      GROUP_CONCAT(DISTINCT cc.wechat_3) as wechat_3_list,
+                      GROUP_CONCAT(DISTINCT cc.linkedin_1) as linkedin_1_list,
+                      GROUP_CONCAT(DISTINCT cc.linkedin_2) as linkedin_2_list,
+                      GROUP_CONCAT(DISTINCT cc.linkedin_3) as linkedin_3_list,
+                      GROUP_CONCAT(DISTINCT cc.facebook_1) as facebook_1_list,
+                      GROUP_CONCAT(DISTINCT cc.facebook_2) as facebook_2_list,
+                      GROUP_CONCAT(DISTINCT cc.facebook_3) as facebook_3_list,
+                      GROUP_CONCAT(DISTINCT cc.alibaba_1) as alibaba_1_list,
+                      GROUP_CONCAT(DISTINCT cc.alibaba_2) as alibaba_2_list,
+                      GROUP_CONCAT(DISTINCT cc.alibaba_3) as alibaba_3_list
                       FROM customer c 
                       LEFT JOIN customer_contact cc ON c.id = cc.customer_id
                       WHERE c.cs_deal<>3 AND c.cs_type<>2 
                       AND DATEDIFF(NOW(), c.cs_updatetime) > 60 
-                      AND cc.wechat NOT LIKE 'wxid%' 
+                      AND NOT EXISTS (
+                          SELECT 1 FROM customer_contact 
+                          WHERE customer_id = c.id 
+                          AND wechat_1 LIKE 'wxid%'
+                      )
                       AND c.cs_belongclient=0 
-                      AND c.cs_belong<>" . $_SESSION['employee_id'] . " 
+                      AND c.cs_belong<>" . $employee_id . " 
                       AND c.cs_belong IN (" . $memberStr . ") 
-                      AND (c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-                      OR cc.contact_name LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-                      OR cc.email LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-                      OR cc.wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-                      OR cc.tel LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-                      OR cc.whatsapp LIKE '%" . $conn->real_escape_string($keyscode) . "%')" . 
-                      $filterStr . " ORDER BY c.cs_state DESC, c.id DESC";
+                      AND (c.cs_code LIKE '%" . $escapedKeyscode . "%' 
+                      OR cc.contact_name LIKE '%" . $escapedKeyscode . "%' 
+                      OR cc.email_1 LIKE '%" . $escapedKeyscode . "%' 
+                      OR cc.email_2 LIKE '%" . $escapedKeyscode . "%' 
+                      OR cc.email_3 LIKE '%" . $escapedKeyscode . "%' 
+                      OR cc.wechat_1 LIKE '%" . $escapedKeyscode . "%' 
+                      OR cc.wechat_2 LIKE '%" . $escapedKeyscode . "%' 
+                      OR cc.wechat_3 LIKE '%" . $escapedKeyscode . "%' 
+                      OR cc.tel_1 LIKE '%" . $escapedKeyscode . "%' 
+                      OR cc.tel_2 LIKE '%" . $escapedKeyscode . "%' 
+                      OR cc.tel_3 LIKE '%" . $escapedKeyscode . "%' 
+                      OR cc.whatsapp_1 LIKE '%" . $escapedKeyscode . "%'
+                      OR cc.whatsapp_2 LIKE '%" . $escapedKeyscode . "%'
+                      OR cc.whatsapp_3 LIKE '%" . $escapedKeyscode . "%')" . 
+                      $filterStr . " GROUP BY c.id ORDER BY cs_state DESC, c.id DESC";
 
             $result = $conn->query($sqlStr);
 
@@ -205,19 +255,25 @@ if ($_SESSION['em_role'] == 0) {
                         </div>
                         <div class="col4">
                             <?php
-                            $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
+                            // 使用SQL拼接方式
+                            $cs_from = intval($row['cs_from']);
+                            $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . $cs_from);
                             echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
                             ?>
                         </div>
                         <div class="col5">
                             <?php
-                            $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
+                            // 使用SQL拼接方式
+                            $cs_country = intval($row['cs_country']);
+                            $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . $cs_country);
                             echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
                             ?>
                         </div>
                         <div class="col6">
                             <?php
-                            $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . (int)$row['cs_type']);
+                            // 使用SQL拼接方式
+                            $cs_type = intval($row['cs_type']);
+                            $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . $cs_type);
                             echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialcharsFix($typeRow['businessType']) : '未填写';
                             ?>
                         </div>
@@ -236,6 +292,63 @@ if ($_SESSION['em_role'] == 0) {
                         <div class="col4"><span id="claim" class="claim" data-id="<?= $row['id'] ?>">认领</span></div>
                     </div>
                     <div class="notepanel clear">
+                        <div class="noteItem">联系方式</div>
+                        <div class="lx">
+                            <?php
+                            // 显示联系人和联系方式
+                            $contacts = explode(',', $row['contact_names']);
+                            $contactIds = explode(',', $row['contact_ids']);
+                            
+                            // 处理电话
+                            echo '<div class="tel">';
+                            if (!empty($row['tel_1_list'])) echo htmlspecialcharsFix($row['tel_1_list']) . '<br>';
+                            if (!empty($row['tel_2_list'])) echo htmlspecialcharsFix($row['tel_2_list']) . '<br>';
+                            if (!empty($row['tel_3_list'])) echo htmlspecialcharsFix($row['tel_3_list']);
+                            echo '</div>';
+                            
+                            // 处理邮箱
+                            echo '<div class="mail">';
+                            if (!empty($row['email_1_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_1_list']) . '">' . htmlspecialcharsFix($row['email_1_list']) . '</a><br>';
+                            if (!empty($row['email_2_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_2_list']) . '">' . htmlspecialcharsFix($row['email_2_list']) . '</a><br>';
+                            if (!empty($row['email_3_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_3_list']) . '">' . htmlspecialcharsFix($row['email_3_list']) . '</a>';
+                            echo '</div>';
+                            
+                            // 处理WhatsApp
+                            echo '<div class="whatsapp">';
+                            if (!empty($row['whatsapp_1_list'])) echo htmlspecialcharsFix($row['whatsapp_1_list']) . '<br>';
+                            if (!empty($row['whatsapp_2_list'])) echo htmlspecialcharsFix($row['whatsapp_2_list']) . '<br>';
+                            if (!empty($row['whatsapp_3_list'])) echo htmlspecialcharsFix($row['whatsapp_3_list']);
+                            echo '</div>';
+                            
+                            // 处理微信
+                            echo '<div class="wechat">';
+                            if (!empty($row['wechat_1_list'])) echo htmlspecialcharsFix($row['wechat_1_list']) . '<br>';
+                            if (!empty($row['wechat_2_list'])) echo htmlspecialcharsFix($row['wechat_2_list']) . '<br>';
+                            if (!empty($row['wechat_3_list'])) echo htmlspecialcharsFix($row['wechat_3_list']);
+                            echo '</div>';
+                            
+                            // 处理LinkedIn
+                            echo '<div class="linkedin">';
+                            if (!empty($row['linkedin_1_list'])) echo htmlspecialcharsFix($row['linkedin_1_list']) . '<br>';
+                            if (!empty($row['linkedin_2_list'])) echo htmlspecialcharsFix($row['linkedin_2_list']) . '<br>';
+                            if (!empty($row['linkedin_3_list'])) echo htmlspecialcharsFix($row['linkedin_3_list']);
+                            echo '</div>';
+                            
+                            // 处理Facebook
+                            echo '<div class="facebook">';
+                            if (!empty($row['facebook_1_list'])) echo htmlspecialcharsFix($row['facebook_1_list']) . '<br>';
+                            if (!empty($row['facebook_2_list'])) echo htmlspecialcharsFix($row['facebook_2_list']) . '<br>';
+                            if (!empty($row['facebook_3_list'])) echo htmlspecialcharsFix($row['facebook_3_list']);
+                            echo '</div>';
+                            
+                            // 处理阿里巴巴
+                            echo '<div class="alibaba">';
+                            if (!empty($row['alibaba_1_list'])) echo htmlspecialcharsFix($row['alibaba_1_list']) . '<br>';
+                            if (!empty($row['alibaba_2_list'])) echo htmlspecialcharsFix($row['alibaba_2_list']) . '<br>';
+                            if (!empty($row['alibaba_3_list'])) echo htmlspecialcharsFix($row['alibaba_3_list']);
+                            echo '</div>';
+                            ?>
+                        </div>
                         <div class="noteItem2">备注</div>
                         <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
                     </div>