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