Просмотр исходного кода

客户信息表新增导入重复数据下载+同步聚好麦平台不存在的用户就新增

cgp 1 день назад
Родитель
Сommit
d77b36210f

+ 40 - 5
fs-admin/src/main/java/com/fs/his/task/JhmTask.java

@@ -79,15 +79,44 @@ public class JhmTask {
         Map<String, FsCompanyCustomer> phoneCustomerMap = existingCustomers.stream()
         Map<String, FsCompanyCustomer> phoneCustomerMap = existingCustomers.stream()
                 .collect(Collectors.toMap(FsCompanyCustomer::getPhone, c -> c, (a, b) -> b));
                 .collect(Collectors.toMap(FsCompanyCustomer::getPhone, c -> c, (a, b) -> b));
 
 
-        List<FsCompanyCustomer> toUpdateList = new ArrayList<>();
+        List<FsCompanyCustomer> toUpdateList = new ArrayList<>();  //待更新列表
+        List<FsCompanyCustomer> toInsertList = new ArrayList<>();  //待新增列表
+
         for (JHMOrderDetail order : dedupOrders) {
         for (JHMOrderDetail order : dedupOrders) {
             String phone = order.getBuyer().getReceivePhone();
             String phone = order.getBuyer().getReceivePhone();
             FsCompanyCustomer customer = phoneCustomerMap.get(phone);
             FsCompanyCustomer customer = phoneCustomerMap.get(phone);
             if (customer == null) {
             if (customer == null) {
-                log.debug("手机号[{}]无对应客户,跳过", phone);
+                // ========== 客户不存在,创建新客户 ==========
+                FsCompanyCustomer newCustomer = new FsCompanyCustomer();
+                newCustomer.setPhone(phone);
+                newCustomer.setCustomerName(order.getBuyer().getConsignee());
+                newCustomer.setAddress(order.getBuyer().getAddress());
+
+                // 成交状态:订单状态为4(已完成)设为1,否则0
+                Integer kdzlMakeStatus = (order.getStatus() != null && order.getStatus() == 4) ? 1 : 0;
+                newCustomer.setKdzlMakeStatus(kdzlMakeStatus);
+
+                // 创建时间:使用订单创建时间
+                if (order.getCreatedAt() != null) {
+                    newCustomer.setCreateTime(Date.from(Instant.ofEpochSecond(order.getCreatedAt())));
+                } else {
+                    newCustomer.setCreateTime(new Date());
+                }
+                newCustomer.setUserSource(1);// 来源:1-聚好麦
+
+                // 默认字段
+                newCustomer.setClaimStatus(0);          // 未认领
+                newCustomer.setCompleteStatus(0);       // 未完善
+                newCustomer.setKdzlAddWechatStatus(0);  // 未加微
+                newCustomer.setKdzlCallStatus("2");     // 未接听
+                newCustomer.setProcessStatus(0);        // 待完善
+
+                toInsertList.add(newCustomer);
+                log.debug("新增客户,手机号[{}]", phone);
                 continue;
                 continue;
             }
             }
 
 
+            // ========== 客户已存在,判断是否需要更新 ==========
             Integer kdzlMakeStatus = (order.getStatus() != null && order.getStatus() == 4) ? 1 : 0;
             Integer kdzlMakeStatus = (order.getStatus() != null && order.getStatus() == 4) ? 1 : 0;
             String address = order.getBuyer().getAddress();
             String address = order.getBuyer().getAddress();
             String customerName = order.getBuyer().getConsignee();
             String customerName = order.getBuyer().getConsignee();
@@ -117,13 +146,19 @@ public class JhmTask {
             }
             }
         }
         }
 
 
+        // 批量插入新客户
+        if (!toInsertList.isEmpty()) {
+            int insertRows = fsCompanyCustomerMapper.batchInsertCompanyCustomer(toInsertList);
+            log.info("店铺[{}]新增客户完成,新增数量: {}", config.getStoreName(), insertRows);
+        }
+
+        // 批量更新已有客户
         if (toUpdateList.isEmpty()) {
         if (toUpdateList.isEmpty()) {
             log.info("店铺[{}]无客户信息需要更新", config.getStoreName());
             log.info("店铺[{}]无客户信息需要更新", config.getStoreName());
             return;
             return;
         }
         }
-        // 批量更新
-        int rows = fsCompanyCustomerMapper.batchUpdateForJhmTask(toUpdateList);
-        log.info("店铺[{}]更新完成,成功: {}", config.getStoreName(), rows);
+        int updateRows = fsCompanyCustomerMapper.batchUpdateForJhmTask(toUpdateList);
+        log.info("店铺[{}]更新完成,更新数量: {}", config.getStoreName(), updateRows);
     }
     }
 
 
     private List<JHMOrderDetail> fetchAllOrders(JHMThirdApiClient apiClient, String fullUrl) {
     private List<JHMOrderDetail> fetchAllOrders(JHMThirdApiClient apiClient, String fullUrl) {

+ 13 - 0
fs-company/src/main/java/com/fs/company/controller/qw/FsCompanyCustomerController.java

@@ -565,6 +565,19 @@ public class FsCompanyCustomerController extends BaseController {
         return AjaxResult.success(fsCompanyCustomerService.canClaimCustomer(id, user));
         return AjaxResult.success(fsCompanyCustomerService.canClaimCustomer(id, user));
     }
     }
 
 
+    /**
+     * 获取认领限制配置
+     */
+    @GetMapping("/getCompanyCustomerDynamicConfig")
+    public AjaxResult getCompanyCustomerDynamicConfig() {
+        CompanyUser user = SecurityUtils.getLoginUser().getUser();
+        if (user == null) {
+            log.error("获取当前登录用户信息失败");
+            throw new CustomException("登录信息已过期,请重新登录");
+        }
+        return AjaxResult.success(fsCompanyCustomerService.getCompanyCustomerDynamicConfig());
+    }
+
     /**
     /**
      * 快捷认领并完善信息
      * 快捷认领并完善信息
      * */
      * */

+ 1 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsImportMemberServiceImpl.java

@@ -199,7 +199,7 @@ public class FsImportMemberServiceImpl extends ServiceImpl<FsImportMemberMapper,
         List<FsCompanyCustomer> willAddCustomers = importCustomers.stream()
         List<FsCompanyCustomer> willAddCustomers = importCustomers.stream()
                 .filter(item -> !existedImportIds.contains(item.getImportMemberId()))
                 .filter(item -> !existedImportIds.contains(item.getImportMemberId()))
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
-
+        willAddCustomers.forEach(item -> item.setUserSource(2));//来源:口袋助理
         // 执行更新
         // 执行更新
         int batchUpdateSize = 500;
         int batchUpdateSize = 500;
         int totalUpdateCount = 0; // 记录总共成功更新了多少条
         int totalUpdateCount = 0; // 记录总共成功更新了多少条

+ 7 - 0
fs-service/src/main/java/com/fs/his/vo/QrcRedPackageConfigVO.java

@@ -8,7 +8,14 @@ import java.math.BigDecimal;
  * */
  * */
 @Data
 @Data
 public class QrcRedPackageConfigVO {
 public class QrcRedPackageConfigVO {
+    /**
+     * 1:开启 红包,0:关闭 红包
+     * */
     private Integer open;
     private Integer open;
     private Integer type;
     private Integer type;
     private BigDecimal amount;
     private BigDecimal amount;
+    /**
+     * 1:开启 "已成交"状态才可被认领,0:关闭 "已成交"状态才可被认领
+     * */
+    private Integer enable;
 }
 }

+ 5 - 0
fs-service/src/main/java/com/fs/qw/domain/FsCompanyCustomer.java

@@ -123,6 +123,11 @@ public class FsCompanyCustomer extends BaseEntity {
     @Excel(name = "流程状态", readConverterExp = "0=待完善,1=待开方,2=开方中,3=待审核,4=已开方,5=已拒方,6=已完成")
     @Excel(name = "流程状态", readConverterExp = "0=待完善,1=待开方,2=开方中,3=待审核,4=已开方,5=已拒方,6=已完成")
     private Integer processStatus;
     private Integer processStatus;
 
 
+    /**
+     * 用户来源 (0:自建,1:聚好麦,2:口袋助理,3:excel导入)
+     */
+    private Integer userSource;
+
     /**
     /**
      * 处方ID
      * 处方ID
      */
      */

+ 4 - 1
fs-service/src/main/java/com/fs/qw/mapper/FsCompanyCustomerMapper.java

@@ -108,5 +108,8 @@ public interface FsCompanyCustomerMapper {
     List<FsCompanyCustomer> selectByPhones(@Param("phones") List<String> phones);
     List<FsCompanyCustomer> selectByPhones(@Param("phones") List<String> phones);
 
 
     /** 批量更新客户(只更新指定字段) */
     /** 批量更新客户(只更新指定字段) */
-    int batchUpdateForJhmTask(@Param("list")List<FsCompanyCustomer> list);
+    int batchUpdateForJhmTask(@Param("list") List<FsCompanyCustomer> list);
+
+    /** 聚好麦批量新增客户 */
+    int batchInsertCompanyCustomer(@Param("toInsertList") List<FsCompanyCustomer> toInsertList);
 }
 }

+ 6 - 0
fs-service/src/main/java/com/fs/qw/service/IFsCompanyCustomerService.java

@@ -4,6 +4,7 @@ import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.R;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.domain.CompanyUser;
 import com.fs.his.vo.CustomerInfoVO;
 import com.fs.his.vo.CustomerInfoVO;
+import com.fs.his.vo.QrcRedPackageConfigVO;
 import com.fs.hisStore.dto.CreatePhoneQRCodeDTO;
 import com.fs.hisStore.dto.CreatePhoneQRCodeDTO;
 import com.fs.hisStore.param.FsCompanyCustomerOrderParam;
 import com.fs.hisStore.param.FsCompanyCustomerOrderParam;
 import com.fs.hisStore.vo.FsStoreOrderVO;
 import com.fs.hisStore.vo.FsStoreOrderVO;
@@ -87,4 +88,9 @@ public interface IFsCompanyCustomerService {
      * @return 认领结果
      * @return 认领结果
      */
      */
     int quickClaimAndImprove(FsCompanyCustomer customer, CompanyUser user);
     int quickClaimAndImprove(FsCompanyCustomer customer, CompanyUser user);
+
+    /**
+     *  获取客户信息表动态配置
+     * */
+    QrcRedPackageConfigVO getCompanyCustomerDynamicConfig();
 }
 }

+ 40 - 8
fs-service/src/main/java/com/fs/qw/service/impl/FsCompanyCustomerServiceImpl.java

@@ -23,6 +23,7 @@ import com.fs.his.mapper.FsPrescribeDataScrmMapper;
 import com.fs.his.service.IFsUserAddressService;
 import com.fs.his.service.IFsUserAddressService;
 import com.fs.his.vo.CustomerInfoVO;
 import com.fs.his.vo.CustomerInfoVO;
 import com.fs.his.vo.CustomerQuestionAnswerVO;
 import com.fs.his.vo.CustomerQuestionAnswerVO;
+import com.fs.his.vo.QrcRedPackageConfigVO;
 import com.fs.hisStore.dto.CreatePhoneQRCodeDTO;
 import com.fs.hisStore.dto.CreatePhoneQRCodeDTO;
 import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
 import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
 import com.fs.hisStore.param.FsCompanyCustomerOrderParam;
 import com.fs.hisStore.param.FsCompanyCustomerOrderParam;
@@ -42,6 +43,7 @@ import com.fs.qw.service.IFsCompanyCustomerService;
 import com.fs.qw.vo.ImportResult;
 import com.fs.qw.vo.ImportResult;
 import com.fs.system.oss.CloudStorageService;
 import com.fs.system.oss.CloudStorageService;
 import com.fs.system.oss.OSSFactory;
 import com.fs.system.oss.OSSFactory;
+import com.fs.system.service.ISysConfigService;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.CollectionUtils;
@@ -80,9 +82,6 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
     @Autowired
     @Autowired
     private FsStoreOrderScrmMapper fsStoreOrderScrmMapper;
     private FsStoreOrderScrmMapper fsStoreOrderScrmMapper;
 
 
-    @Autowired
-    private FsCompanyExternalPayReceiptMapper externalPayReceiptMapper;
-
     @Autowired
     @Autowired
     private FsPrescribeDataScrmMapper prescribeDataScrmMapper;
     private FsPrescribeDataScrmMapper prescribeDataScrmMapper;
 
 
@@ -93,10 +92,12 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
     private FsDoctorMapper fsDoctorMapper;
     private FsDoctorMapper fsDoctorMapper;
 
 
     @Autowired
     @Autowired
-    private CompanyUserMapper companyUserMapper;
+    private FsCompanyQrcPhoneMapper fsCompanyQrcPhoneMapper;
 
 
     @Autowired
     @Autowired
-    private FsCompanyQrcPhoneMapper fsCompanyQrcPhoneMapper;
+    private ISysConfigService sysConfigService;
+
+    private static final String QRC_RED_PACKAGE_CONFIG_KEY = "qrcRedPackage.config";
 
 
     private static final Set<Integer> ALLOWED_STATUSES =
     private static final Set<Integer> ALLOWED_STATUSES =
             Collections.unmodifiableSet(new HashSet<>(Arrays.asList(0, 5, 6))); // 允许操作完善客户信息的状态
             Collections.unmodifiableSet(new HashSet<>(Arrays.asList(0, 5, 6))); // 允许操作完善客户信息的状态
@@ -156,6 +157,7 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
             CompanyDept companyDept = companyDeptMapper.selectCompanyDeptById(companyUser.getDeptId());
             CompanyDept companyDept = companyDeptMapper.selectCompanyDeptById(companyUser.getDeptId());
             customer.setClaimStatus(BigDecimal.ONE.intValue());
             customer.setClaimStatus(BigDecimal.ONE.intValue());
             customer.setDeptId(companyUser.getDeptId());
             customer.setDeptId(companyUser.getDeptId());
+            customer.setUserSource(0);  //来源:自建
             if (companyDept!=null&&companyDept.getDeptName()!=null){
             if (companyDept!=null&&companyDept.getDeptName()!=null){
                 customer.setDeptName(companyDept.getDeptName());
                 customer.setDeptName(companyDept.getDeptName());
             }
             }
@@ -268,6 +270,7 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
         if (oldCustomer == null) {
         if (oldCustomer == null) {
             throw new CustomException("客户不存在");
             throw new CustomException("客户不存在");
         }
         }
+        checkClaimStatus(oldCustomer);
         // 校验电话号码(完整匹配或后四位)
         // 校验电话号码(完整匹配或后四位)
         String claimPhone = fsCompanyCustomer.getClaimPhone();
         String claimPhone = fsCompanyCustomer.getClaimPhone();
         if (!claimPhone.equals(oldCustomer.getPhone())) {
         if (!claimPhone.equals(oldCustomer.getPhone())) {
@@ -398,6 +401,7 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
     public ImportResult importCustomers(List<ImportCustomerDTO> list, CompanyUser companyUser) {
     public ImportResult importCustomers(List<ImportCustomerDTO> list, CompanyUser companyUser) {
         int success = 0;
         int success = 0;
         List<String> errors = new ArrayList<>();
         List<String> errors = new ArrayList<>();
+        List<ImportCustomerDTO> duplicateList = new ArrayList<>();
 
 
         for (ImportCustomerDTO dto : list) {
         for (ImportCustomerDTO dto : list) {
             try {
             try {
@@ -421,6 +425,7 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
                     //self().addBuyTimes(existingId);
                     //self().addBuyTimes(existingId);
                     //存在就更新购买次数
                     //存在就更新购买次数
                     updateBuyCount(existingId, dto.getBuyCount());
                     updateBuyCount(existingId, dto.getBuyCount());
+                    duplicateList.add(dto);  // 记录重复数据
                 } else {
                 } else {
                     // 不存在 → 新增客户
                     // 不存在 → 新增客户
                     FsCompanyCustomer customer = new FsCompanyCustomer();
                     FsCompanyCustomer customer = new FsCompanyCustomer();
@@ -430,15 +435,17 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
                     customer.setBuyCount(Long.valueOf(dto.getBuyCount()));// 使用导入的购买次数
                     customer.setBuyCount(Long.valueOf(dto.getBuyCount()));// 使用导入的购买次数
                     customer.setCreateTime(new Date());     // 创建时间
                     customer.setCreateTime(new Date());     // 创建时间
                     customer.setClaimStatus(0);  //未认领状态
                     customer.setClaimStatus(0);  //未认领状态
+                    customer.setUserSource(3);  //来源:excel导入
                     fsCompanyCustomerMapper.insertFsCompanyCustomer(customer);
                     fsCompanyCustomerMapper.insertFsCompanyCustomer(customer);
+                    success++;
                 }
                 }
-                success++;
+
             } catch (Exception e) {
             } catch (Exception e) {
                 errors.add("手机号 " + dto.getPhone() + " 处理失败:" + e.getMessage());
                 errors.add("手机号 " + dto.getPhone() + " 处理失败:" + e.getMessage());
                 log.error("导入客户失败,手机号:{}", dto.getPhone(), e);
                 log.error("导入客户失败,手机号:{}", dto.getPhone(), e);
             }
             }
         }
         }
-        return new ImportResult(success, errors);
+        return new ImportResult(success, errors,duplicateList);
     }
     }
 
 
     @Override
     @Override
@@ -520,6 +527,7 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
         if (oldCustomer == null) {
         if (oldCustomer == null) {
             throw new CustomException("客户不存在");
             throw new CustomException("客户不存在");
         }
         }
+        checkClaimStatus(oldCustomer);
         // 查询中间表,判断是否可快捷认领
         // 查询中间表,判断是否可快捷认领
         FsCompanyQrcPhone query = new FsCompanyQrcPhone();
         FsCompanyQrcPhone query = new FsCompanyQrcPhone();
         query.setUserPhone(oldCustomer.getPhone());
         query.setUserPhone(oldCustomer.getPhone());
@@ -539,7 +547,7 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
         if (oldCustomer == null) {
         if (oldCustomer == null) {
             throw new CustomException("客户不存在");
             throw new CustomException("客户不存在");
         }
         }
-
+        checkClaimStatus(oldCustomer);
         // 2. 校验四个字段至少有一个非空
         // 2. 校验四个字段至少有一个非空
         String symptom = customer.getPatientMainComplaint();
         String symptom = customer.getPatientMainComplaint();
         String presentIllness = customer.getPresentIllness();
         String presentIllness = customer.getPresentIllness();
@@ -564,6 +572,14 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
         return 1;
         return 1;
     }
     }
 
 
+    /**
+     *  获取客户信息表动态配置
+     * */
+    @Override
+    public QrcRedPackageConfigVO getCompanyCustomerDynamicConfig() {
+        return sysConfigService.getConfig(QRC_RED_PACKAGE_CONFIG_KEY, QrcRedPackageConfigVO.class);
+    }
+
     /**
     /**
      * 执行认领核心逻辑(需在事务内调用)
      * 执行认领核心逻辑(需在事务内调用)
      * @param customer        行锁查询出的客户对象(将被修改并更新)
      * @param customer        行锁查询出的客户对象(将被修改并更新)
@@ -646,6 +662,9 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
      * 更新购买次数
      * 更新购买次数
      * */
      * */
     private int updateBuyCount(Long id, Integer buyCount) {
     private int updateBuyCount(Long id, Integer buyCount) {
+        if(buyCount==null||buyCount<0||buyCount==0){
+            return 0;
+        }
         FsCompanyCustomer fsCompanyCustomer = fsCompanyCustomerMapper.selectFsCompanyCustomerById(id);
         FsCompanyCustomer fsCompanyCustomer = fsCompanyCustomerMapper.selectFsCompanyCustomerById(id);
         if (fsCompanyCustomer!=null&&fsCompanyCustomer.getBuyCount()!=null){
         if (fsCompanyCustomer!=null&&fsCompanyCustomer.getBuyCount()!=null){
             fsCompanyCustomer.setBuyCount(fsCompanyCustomer.getBuyCount()+buyCount);
             fsCompanyCustomer.setBuyCount(fsCompanyCustomer.getBuyCount()+buyCount);
@@ -653,4 +672,17 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
         }
         }
         return 0;
         return 0;
     }
     }
+
+    /**
+     * 根据成交状态与配置判断是否符合认领客户条件
+     */
+    private void checkClaimStatus(FsCompanyCustomer customer) {
+        QrcRedPackageConfigVO companyCustomerDynamicConfig = getCompanyCustomerDynamicConfig();
+        if (companyCustomerDynamicConfig != null && companyCustomerDynamicConfig.getOpen() == 1) {
+            if (customer != null && customer.getKdzlMakeStatus() != null && customer.getKdzlMakeStatus() == 1) {
+                return;
+            }
+            throw new CustomException("当前客户还未成交,请待客户成交后再认领!");
+        }
+    }
 }
 }

+ 3 - 0
fs-service/src/main/java/com/fs/qw/vo/ImportResult.java

@@ -1,5 +1,6 @@
 package com.fs.qw.vo;
 package com.fs.qw.vo;
 
 
+import com.fs.qw.dto.ImportCustomerDTO;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.Data;
 import java.util.List;
 import java.util.List;
@@ -9,4 +10,6 @@ import java.util.List;
 public class ImportResult {
 public class ImportResult {
     private int success;
     private int success;
     private List<String> errors;
     private List<String> errors;
+    // 重复客户数据列表(导入文件中被跳过的记录)
+    private List<ImportCustomerDTO> duplicateList;
 }
 }

+ 42 - 1
fs-service/src/main/resources/mapper/qw/FsCompanyCustomerMapper.xml

@@ -31,6 +31,7 @@
         <result property="completeStatus"    column="complete_status"    />
         <result property="completeStatus"    column="complete_status"    />
         <result property="deptId"            column="dept_id"            />
         <result property="deptId"            column="dept_id"            />
         <result property="deptName"          column="dept_name"          />
         <result property="deptName"          column="dept_name"          />
+        <result property="userSource"        column="user_source"      />
         <!-- 口袋助理相关字段 -->
         <!-- 口袋助理相关字段 -->
         <result property="kdzlAddWechatStatus" column="kdzl_add_wechat_status" />
         <result property="kdzlAddWechatStatus" column="kdzl_add_wechat_status" />
         <result property="kdzlMakeStatus"      column="kdzl_make_status"      />
         <result property="kdzlMakeStatus"      column="kdzl_make_status"      />
@@ -49,7 +50,7 @@
                buy_count, claim_status,
                buy_count, claim_status,
                complete_status, dept_id, dept_name,
                complete_status, dept_id, dept_name,
                kdzl_add_wechat_status, kdzl_make_status, kdzl_call_status,
                kdzl_add_wechat_status, kdzl_make_status, kdzl_call_status,
-               process_status, prescribe_id, template_id, json_info
+               process_status, prescribe_id, template_id, json_info,user_source
         from fs_company_customer
         from fs_company_customer
     </sql>
     </sql>
 
 
@@ -120,6 +121,9 @@
         <if test="processStatus != null">
         <if test="processStatus != null">
             and process_status = #{processStatus}
             and process_status = #{processStatus}
         </if>
         </if>
+        <if test="userSource != null">
+            and user_source = #{userSource}
+        </if>
         <if test="autoAddUser != null and autoAddUser == true">
         <if test="autoAddUser != null and autoAddUser == true">
             and exists (select 1 from fs_company_qrc_phone q where q.user_phone = fs_company_customer.phone)
             and exists (select 1 from fs_company_qrc_phone q where q.user_phone = fs_company_customer.phone)
         </if>
         </if>
@@ -177,6 +181,9 @@
         <if test="importMemberId != null">
         <if test="importMemberId != null">
             and import_member_id = #{importMemberId}
             and import_member_id = #{importMemberId}
         </if>
         </if>
+        <if test="userSource != null">
+            and user_source = #{userSource}
+        </if>
         <if test="completeStatus != null">
         <if test="completeStatus != null">
             and complete_status = #{completeStatus}
             and complete_status = #{completeStatus}
         </if>
         </if>
@@ -264,6 +271,7 @@
             <if test="prescribeId != null">prescribe_id,</if>
             <if test="prescribeId != null">prescribe_id,</if>
             <if test="templateId != null">template_id,</if>
             <if test="templateId != null">template_id,</if>
             <if test="jsonInfo != null">json_info,</if>
             <if test="jsonInfo != null">json_info,</if>
+            <if test="userSource != null">user_source,</if>
             create_time
             create_time
         </trim>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -298,6 +306,7 @@
             <if test="prescribeId != null">#{prescribeId},</if>
             <if test="prescribeId != null">#{prescribeId},</if>
             <if test="templateId != null">#{templateId},</if>
             <if test="templateId != null">#{templateId},</if>
             <if test="jsonInfo != null">#{jsonInfo},</if>
             <if test="jsonInfo != null">#{jsonInfo},</if>
+            <if test="userSource != null">#{userSource},</if>
             sysdate()
             sysdate()
         </trim>
         </trim>
     </insert>
     </insert>
@@ -319,6 +328,37 @@
         </foreach>
         </foreach>
     </insert>
     </insert>
 
 
+    <insert id="batchInsertCompanyCustomer" parameterType="list">
+        INSERT INTO fs_company_customer (
+        customer_name,
+        phone,
+        address,
+        create_time,
+        claim_status,
+        complete_status,
+        kdzl_add_wechat_status,
+        kdzl_make_status,
+        kdzl_call_status,
+        process_status,
+        user_source
+        ) VALUES
+        <foreach collection="toInsertList" item="item" separator=",">
+            (
+            #{item.customerName},
+            #{item.phone},
+            #{item.address},
+            #{item.createTime},
+            #{item.claimStatus},
+            #{item.completeStatus},
+            #{item.kdzlAddWechatStatus},
+            #{item.kdzlMakeStatus},
+            #{item.kdzlCallStatus},
+            #{item.processStatus},
+            #{item.userSource}
+            )
+        </foreach>
+    </insert>
+
     <update id="updateFsCompanyCustomer" parameterType="com.fs.qw.domain.FsCompanyCustomer">
     <update id="updateFsCompanyCustomer" parameterType="com.fs.qw.domain.FsCompanyCustomer">
         update fs_company_customer
         update fs_company_customer
         <set>
         <set>
@@ -353,6 +393,7 @@
             <if test="templateId != null">template_id = #{templateId},</if>
             <if test="templateId != null">template_id = #{templateId},</if>
             <if test="jsonInfo != null">json_info = #{jsonInfo},</if>
             <if test="jsonInfo != null">json_info = #{jsonInfo},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="userSource != null">user_source = #{userSource},</if>
             update_time = sysdate()
             update_time = sysdate()
         </set>
         </set>
         where id = #{id}
         where id = #{id}