|
|
@@ -2,6 +2,8 @@ package com.fs.qw.service.impl;
|
|
|
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
@@ -9,8 +11,11 @@ import com.fs.company.domain.CompanyDept;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyDeptMapper;
|
|
|
import com.fs.his.domain.FsImportMember;
|
|
|
+import com.fs.his.domain.FsPrescribeDataScrm;
|
|
|
import com.fs.his.mapper.FsImportMemberMapper;
|
|
|
+import com.fs.his.mapper.FsPrescribeDataScrmMapper;
|
|
|
import com.fs.his.service.IFsUserAddressService;
|
|
|
+import com.fs.his.vo.CustomerQuestionAnswerVO;
|
|
|
import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
|
import com.fs.hisStore.param.FsCompanyCustomerOrderParam;
|
|
|
import com.fs.hisStore.vo.FsStoreOrderItemVO;
|
|
|
@@ -29,9 +34,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 客户基础信息Service业务层处理
|
|
|
@@ -60,9 +64,15 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
|
|
|
@Autowired
|
|
|
private FsCompanyExternalPayReceiptMapper externalPayReceiptMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FsPrescribeDataScrmMapper prescribeDataScrmMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IFsUserAddressService fsUserAddressService;
|
|
|
|
|
|
+ private static final Set<Integer> ALLOWED_STATUSES =
|
|
|
+ Collections.unmodifiableSet(new HashSet<>(Arrays.asList(0, 5, 6))); // 允许操作完善客户信息的状态
|
|
|
+
|
|
|
@Override
|
|
|
public FsCompanyCustomer selectFsCompanyCustomerById(Long id) {
|
|
|
return fsCompanyCustomerMapper.selectFsCompanyCustomerById(id);
|
|
|
@@ -70,7 +80,19 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
|
|
|
|
|
|
@Override
|
|
|
public List<FsCompanyCustomer> selectFsCompanyCustomerList(FsCompanyCustomer fsCompanyCustomer) {
|
|
|
- return fsCompanyCustomerMapper.selectFsCompanyCustomerList(fsCompanyCustomer);
|
|
|
+ List<FsCompanyCustomer> companyCustomers = fsCompanyCustomerMapper.selectFsCompanyCustomerList(fsCompanyCustomer);
|
|
|
+ if (CollectionUtils.isEmpty(companyCustomers)) {
|
|
|
+ return companyCustomers;
|
|
|
+ }
|
|
|
+ //收集处方id
|
|
|
+ List<Long> prescriptionIds = companyCustomers.stream().map(FsCompanyCustomer::getPrescribeId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(prescriptionIds)) {
|
|
|
+ return companyCustomers;
|
|
|
+ }
|
|
|
+ //批量获取处方信息
|
|
|
+ List<FsPrescribeDataScrm> fsPrescribeDataScrms = prescribeDataScrmMapper.selectFsPrescribeDataScrmListByIds(prescriptionIds);
|
|
|
+ //TODO 后续可能会在客户信息列表展示商城处方信息
|
|
|
+ return companyCustomers;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -270,7 +292,7 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
|
|
|
if (customer == null) {
|
|
|
throw new CustomException("客户信息不存在");
|
|
|
}
|
|
|
- if (customer.getProcessStatus() != 0) {
|
|
|
+ if (!ALLOWED_STATUSES.contains(customer.getProcessStatus())) {
|
|
|
throw new CustomException("客户正在处理中,请勿重复操作");
|
|
|
}
|
|
|
customer.setProcessStatus(1);
|
|
|
@@ -278,4 +300,42 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
|
|
|
customer.setJsonInfo(fsCompanyCustomer.getJsonInfo());
|
|
|
return fsCompanyCustomerMapper.updateFsCompanyCustomer(customer);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CustomerQuestionAnswerVO> getCustomerQuestionAnswer(Long companyCustomerId) {
|
|
|
+ FsCompanyCustomer fsCompanyCustomer = fsCompanyCustomerMapper.selectFsCompanyCustomerById(companyCustomerId);
|
|
|
+ if (fsCompanyCustomer == null) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ String jsonStr = fsCompanyCustomer.getJsonInfo();
|
|
|
+ if (StringUtils.isBlank(jsonStr)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ // 使用 TypeReference 安全解析
|
|
|
+ List<Map<String, Object>> list = JSON.parseObject(jsonStr, new TypeReference<List<Map<String, Object>>>() {});
|
|
|
+ List<CustomerQuestionAnswerVO> result = new ArrayList<>();
|
|
|
+ for (Map<String, Object> item : list) {
|
|
|
+ String title = (String) item.get("title");
|
|
|
+ List<Integer> values = (List<Integer>) item.get("value");
|
|
|
+ List<Map<String, Object>> options = (List<Map<String, Object>>) item.get("options");
|
|
|
+
|
|
|
+ List<String> answerNames = new ArrayList<>();
|
|
|
+ if (values != null && options != null) {
|
|
|
+ for (Integer val : values) {
|
|
|
+ for (Map<String, Object> opt : options) {
|
|
|
+ if (opt.get("value").equals(val)) {
|
|
|
+ answerNames.add((String) opt.get("name"));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String answerText = String.join("、", answerNames);
|
|
|
+ CustomerQuestionAnswerVO vo = new CustomerQuestionAnswerVO();
|
|
|
+ vo.setTitle(title);
|
|
|
+ vo.setAnswerText(answerText);
|
|
|
+ result.add(vo);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|