Compare commits
5 Commits
1924cc6cb3
...
86966e75d9
| Author | SHA1 | Date |
|---|---|---|
|
|
86966e75d9 | |
|
|
9dbe015e0c | |
|
|
b25ea618ee | |
|
|
c96663187e | |
|
|
852f52a2b3 |
|
|
@ -0,0 +1,13 @@
|
|||
package com.kakarote.core.feign.crm.service;
|
||||
|
||||
import com.kakarote.core.common.Result;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@FeignClient(name = "crm" , contextId = "UserAnalyse")
|
||||
public interface CrmUserAnalyseService {
|
||||
|
||||
@PostMapping("/crmGetV3Data/getTaxPreCheckUsage")
|
||||
Result getTaxPreCheckUsage();
|
||||
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ public class EncryptionService {
|
|||
// 解码Base64密文
|
||||
byte[] decoded = Base64.getDecoder().decode(ciphertext);
|
||||
|
||||
// 提取IV
|
||||
// 提取IV(固定取前12字节)
|
||||
byte[] iv = new byte[GCM_IV_LENGTH];
|
||||
System.arraycopy(decoded, 0, iv, 0, iv.length);
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ public class SensitiveDataConverter extends AbstractJsonTypeHandler<String> impl
|
|||
@Override
|
||||
public void setNonNullParameter(PreparedStatement preparedStatement, int i, String s, JdbcType jdbcType) throws SQLException {
|
||||
if (s != null && !s.isEmpty() && !s.startsWith(Const.ENCRYPTED_PREFIX)) {
|
||||
s = getEncryptionService().encryptAes(s);
|
||||
// 加密后添加前缀标识
|
||||
s = Const.ENCRYPTED_PREFIX + getEncryptionService().encryptAes(s);
|
||||
}
|
||||
preparedStatement.setString(i, s);
|
||||
}
|
||||
|
|
@ -57,7 +58,8 @@ public class SensitiveDataConverter extends AbstractJsonTypeHandler<String> impl
|
|||
public String getNullableResult(ResultSet resultSet, String s) throws SQLException {
|
||||
String value = resultSet.getString(s);
|
||||
if (value != null && value.startsWith(Const.ENCRYPTED_PREFIX)) {
|
||||
value = getEncryptionService().decryptAes(value);
|
||||
// 修复:移除前缀后再解密
|
||||
value = getEncryptionService().decryptAes(value.substring(Const.ENCRYPTED_PREFIX.length()));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
|
@ -66,7 +68,8 @@ public class SensitiveDataConverter extends AbstractJsonTypeHandler<String> impl
|
|||
public String getNullableResult(ResultSet resultSet, int i) throws SQLException {
|
||||
String value = resultSet.getString(i);
|
||||
if (value != null && value.startsWith(Const.ENCRYPTED_PREFIX)) {
|
||||
value = getEncryptionService().decryptAes(value);
|
||||
// 修复:移除前缀后再解密
|
||||
value = getEncryptionService().decryptAes(value.substring(Const.ENCRYPTED_PREFIX.length()));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
|
@ -75,7 +78,8 @@ public class SensitiveDataConverter extends AbstractJsonTypeHandler<String> impl
|
|||
public String getNullableResult(CallableStatement callableStatement, int i) throws SQLException {
|
||||
String value = callableStatement.getString(i);
|
||||
if (value != null && value.startsWith(Const.ENCRYPTED_PREFIX)) {
|
||||
value = getEncryptionService().decryptAes(value);
|
||||
// 修复:移除前缀后再解密
|
||||
value = getEncryptionService().decryptAes(value.substring(Const.ENCRYPTED_PREFIX.length()));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ public enum CrmCodeEnum implements ResultCode {
|
|||
THE_FIELD_DETAIL_TABLE_FORMAT_ERROR(2089,"清设置表格内的具体字段!"),
|
||||
CRM_RECEIVABLES_PLAN_ADD_ERROR(2090,"只有审核通过或审核中的合同才可以添加回款计划!"),
|
||||
CRM_CUSTOMER_POOL_NOT_IS_ADMIN(2091, "没有该公海权限,不能进行操作"),
|
||||
CUSTOMER_XX_Y(2092, "客户信息已存在,无法重复添加"),
|
||||
;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.kakarote.crm.entity.PO;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.kakarote.core.security.converter.SensitiveDataConverter;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
|
@ -37,12 +39,17 @@ public class CrmContacts implements Serializable {
|
|||
private Date nextTime;
|
||||
|
||||
@ApiModelProperty(value = "手机")
|
||||
@TableField(typeHandler = SensitiveDataConverter.class, jdbcType = JdbcType.VARCHAR)
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "电话")
|
||||
@TableField(typeHandler = SensitiveDataConverter.class, jdbcType = JdbcType.VARCHAR)
|
||||
|
||||
private String telephone;
|
||||
|
||||
@ApiModelProperty(value = "电子邮箱")
|
||||
@TableField(typeHandler = SensitiveDataConverter.class, jdbcType = JdbcType.VARCHAR)
|
||||
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "职务")
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ public interface ICrmOpenApiService {
|
|||
|
||||
Integer openAddCustomerBo(CrmAddCustomerBo crmAddCustomerBo);
|
||||
//添加用户
|
||||
void crmAddCustomer(CrmBusinessSaveBO crmModel,String source);
|
||||
Integer crmAddCustomer(CrmBusinessSaveBO crmModel, String source);
|
||||
|
||||
CrmBusinessSaveBO assemblyRequestData(CrmQdInfoBo crmModel);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,8 +334,7 @@ public class CrmCustomerServiceImpl extends BaseServiceImpl<CrmCustomerMapper, C
|
|||
CrmModel crmModel;
|
||||
if (id != null) {
|
||||
crmModel = getBaseMapper().queryById(id, UserUtil.getUserId());
|
||||
// 添加解密逻辑
|
||||
decryptSensitiveData(crmModel);
|
||||
// 添加解密逻辑decryptSensitiveData(crmModel);
|
||||
crmModel.setLabel(CrmEnum.CUSTOMER.getType());
|
||||
crmModel.setOwnerUserName(UserCacheUtil.getUserName(crmModel.getOwnerUserId()));
|
||||
crmCustomerDataService.setDataByBatchId(crmModel);
|
||||
|
|
@ -378,9 +377,16 @@ public class CrmCustomerServiceImpl extends BaseServiceImpl<CrmCustomerMapper, C
|
|||
String[] sensitiveFields = {"mobile", "email", "idCard", "bankCard"};
|
||||
for (String field : sensitiveFields) {
|
||||
Object value = model.get(field);
|
||||
if (value instanceof String) {
|
||||
model.put(field, encryptionService.decryptAes((String) value));
|
||||
System.out.println(encryptionService.decryptAes((String) value));
|
||||
if (value instanceof String && ((String) value).startsWith(Const.ENCRYPTED_PREFIX)) {
|
||||
try {
|
||||
String decryptedValue = encryptionService.decryptAes((String) value);
|
||||
model.put(field, decryptedValue);
|
||||
// 移除调试输出
|
||||
// System.out.println(decryptedValue);
|
||||
} catch (Exception e) {
|
||||
log.error("解密 {} 字段失败: {}, 原始值: {}", field, model.get("customerId"), value, e);
|
||||
model.put(field, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1125,7 +1131,39 @@ public class CrmCustomerServiceImpl extends BaseServiceImpl<CrmCustomerMapper, C
|
|||
public BasePage<CrmContacts> queryContacts(CrmContactsPageBO pageEntity) {
|
||||
BasePage<CrmContacts> contactsBasePage = pageEntity.parse();
|
||||
String conditions = AuthUtil.getCrmAuthSql(CrmEnum.CONTACTS, 1,CrmAuthEnum.READ);
|
||||
return getBaseMapper().queryContacts(contactsBasePage, pageEntity.getCustomerId(), pageEntity.getSearch(), conditions);
|
||||
BasePage<CrmContacts> result = getBaseMapper().queryContacts(contactsBasePage, pageEntity.getCustomerId(), pageEntity.getSearch(), conditions);
|
||||
|
||||
// 手动解密敏感数据
|
||||
for (CrmContacts contacts : result.getList()) {
|
||||
// 恢复前缀检查并增加异常处理
|
||||
if (contacts.getMobile() != null && contacts.getMobile().startsWith(Const.ENCRYPTED_PREFIX)) {
|
||||
try {
|
||||
contacts.setMobile(encryptionService.decryptAes(contacts.getMobile()));
|
||||
} catch (Exception e) {
|
||||
log.error("解密mobile失败: {}", contacts.getContactsId(), e);
|
||||
contacts.setMobile(null); // 或保留原始值
|
||||
}
|
||||
}
|
||||
// 对telephone和email字段执行相同修复
|
||||
if (contacts.getTelephone() != null && contacts.getTelephone().startsWith(Const.ENCRYPTED_PREFIX)) {
|
||||
try {
|
||||
contacts.setTelephone(encryptionService.decryptAes(contacts.getTelephone()));
|
||||
} catch (Exception e) {
|
||||
log.error("解密telephone失败: {}", contacts.getContactsId(), e);
|
||||
contacts.setTelephone(null);
|
||||
}
|
||||
}
|
||||
if (contacts.getEmail() != null && contacts.getEmail().startsWith(Const.ENCRYPTED_PREFIX)) {
|
||||
try {
|
||||
contacts.setEmail(encryptionService.decryptAes(contacts.getEmail()));
|
||||
} catch (Exception e) {
|
||||
log.error("解密email失败: {}", contacts.getContactsId(), e);
|
||||
contacts.setEmail(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
package com.kakarote.crm.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.kakarote.core.exception.CrmException;
|
||||
import com.kakarote.crm.entity.BO.CrmAddCustomerBo;
|
||||
import com.kakarote.crm.entity.BO.CrmBusinessSaveBO;
|
||||
import com.kakarote.crm.entity.BO.CrmCustomerPoolBO;
|
||||
import com.kakarote.crm.entity.BO.CrmQdInfoBo;
|
||||
import com.kakarote.crm.entity.PO.CrmCustomer;
|
||||
import com.kakarote.crm.entity.BO.*;
|
||||
import com.kakarote.crm.entity.VO.CrmModelFiledVO;
|
||||
import com.kakarote.crm.mapper.CrmFieldMapper;
|
||||
import com.kakarote.crm.service.ICrmContactsService;
|
||||
import com.kakarote.crm.service.ICrmCustomerService;
|
||||
import com.kakarote.crm.service.ICrmOpenApiService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -18,6 +13,7 @@ import org.springframework.stereotype.Service;
|
|||
import java.util.*;
|
||||
|
||||
import static com.kakarote.core.common.SystemCodeEnum.SYSTEM_NO_AUTH;
|
||||
import static com.kakarote.crm.constant.CrmCodeEnum.CUSTOMER_XX_Y;
|
||||
import static com.kakarote.crm.constant.CrmPoolEnum.GSMGWZKH;
|
||||
import static com.kakarote.crm.constant.CrmPoolEnum.PXQDMDPOOL;
|
||||
|
||||
|
|
@ -27,6 +23,9 @@ public class CrmOpenApiServiceImpl implements ICrmOpenApiService {
|
|||
@Autowired
|
||||
private ICrmCustomerService customerService;
|
||||
|
||||
@Autowired
|
||||
private ICrmContactsService contactsService;
|
||||
|
||||
//V1
|
||||
@Override
|
||||
public Integer openAddCustomerBo(CrmAddCustomerBo crmAddCustomerBo) {
|
||||
|
|
@ -174,16 +173,50 @@ public class CrmOpenApiServiceImpl implements ICrmOpenApiService {
|
|||
list.add(fliedBcethz);
|
||||
crmBusinessSaveBO.setField(list);
|
||||
//添加数据
|
||||
crmAddCustomer(crmBusinessSaveBO,crmModel.getSource());
|
||||
Integer customerId = crmAddCustomer(crmBusinessSaveBO, crmModel.getSource());
|
||||
//添加联系人
|
||||
CrmContactsSaveBO contactsSaveBO = new CrmContactsSaveBO();
|
||||
Map<String,Object> contacts = new HashMap<>();
|
||||
contacts.put("customerId",customerId);
|
||||
contacts.put("name",crmModel.getUserName());
|
||||
contacts.put("mobile",crmModel.getMobile());
|
||||
contacts.put("telephone",crmModel.getMobile());
|
||||
contacts.put("address",crmModel.getAddress());
|
||||
contacts.put("email","");
|
||||
contacts.put("post","");
|
||||
contacts.put("nextTime","");
|
||||
contacts.put("remark","");
|
||||
contactsSaveBO.setEntity(contacts);
|
||||
|
||||
List<CrmModelFiledVO> modelFileds = new ArrayList<>();
|
||||
|
||||
CrmModelFiledVO policymakers =new CrmModelFiledVO();
|
||||
policymakers.setFieldId(1101853);
|
||||
policymakers.setFieldName("policymakers");
|
||||
policymakers.setName("是否关键决策人");
|
||||
policymakers.setFieldType(2);
|
||||
policymakers.setType(3);
|
||||
modelFileds.add(policymakers);
|
||||
|
||||
CrmModelFiledVO sex =new CrmModelFiledVO();
|
||||
sex.setFieldId(1101857);
|
||||
sex.setFieldName("sex");
|
||||
sex.setName("性别");
|
||||
sex.setFieldType(2);
|
||||
sex.setType(3);
|
||||
modelFileds.add(sex);
|
||||
|
||||
contactsSaveBO.setField(modelFileds);
|
||||
contactsService.addOrUpdate(contactsSaveBO,false);
|
||||
return crmBusinessSaveBO;
|
||||
}
|
||||
|
||||
public void crmAddCustomer(CrmBusinessSaveBO crmModel,String source){
|
||||
public Integer crmAddCustomer(CrmBusinessSaveBO crmModel, String source){
|
||||
//判断企业是否存在
|
||||
Integer customerByQyjbxx = customerService.getCustomerByQyjbxx(crmModel);
|
||||
//存在用户
|
||||
if (customerByQyjbxx >0){
|
||||
|
||||
throw new CrmException(CUSTOMER_XX_Y);
|
||||
}else {
|
||||
//添加客户
|
||||
Map<String, Object> stringObjectMap = customerService.addOrUpdate(crmModel, false, null);
|
||||
|
|
@ -199,6 +232,7 @@ public class CrmOpenApiServiceImpl implements ICrmOpenApiService {
|
|||
poolBO.setPoolId(GSMGWZKH.getId());
|
||||
}
|
||||
customerService.updateCustomerByIds(poolBO);
|
||||
return customerId;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.kakarote.crm.service.impl;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.kakarote.core.feign.crm.entity.BiParams;
|
||||
import com.kakarote.core.servlet.BaseServiceImpl;
|
||||
import com.kakarote.crm.entity.DTO.CrmTaxPreCheckUsageDTO;
|
||||
|
|
@ -33,16 +34,19 @@ public class CrmUserAnalyseServiceImpl extends BaseServiceImpl<CrmUserAnalyseMap
|
|||
@Value("${app.base_url}")
|
||||
private String BASE_URL;
|
||||
|
||||
private String getUrl() {
|
||||
return BASE_URL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addUserAnalyse() throws IOException {
|
||||
|
||||
//测试数据
|
||||
//LocalDate today = LocalDate.of(2023, 9, 28);
|
||||
// 每天凌晨一点把昨天的数据存入数据库中
|
||||
|
||||
//获取当天凌晨1点的日期
|
||||
// 获取当天凌晨1点的日期
|
||||
LocalDate today = LocalDate.now();
|
||||
|
||||
//再获取昨天的日期
|
||||
// 再获取昨天的日期
|
||||
LocalDate queryDate = today.minusDays(1);
|
||||
|
||||
CrmUserAnalyse userAnalyse = getCrmUserAnalyse(queryDate);
|
||||
|
|
@ -52,7 +56,14 @@ public class CrmUserAnalyseServiceImpl extends BaseServiceImpl<CrmUserAnalyseMap
|
|||
|
||||
public CrmUserAnalyse getCrmUserAnalyse(LocalDate queryDate) throws IOException {
|
||||
|
||||
String json = OkHttpClientUtil.get(BASE_URL, queryDate);
|
||||
String url = getUrl();
|
||||
|
||||
String json = OkHttpClientUtil.get(url, queryDate);
|
||||
|
||||
// 检查是否是有效的JSON对象
|
||||
if (json == null || json.trim().isEmpty()) {
|
||||
throw new JsonParseException("响应内容为空");
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
CrmTaxPreCheckUsageVO vo = gson.fromJson(json, CrmTaxPreCheckUsageVO.class);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package com.kakarote.crm.webService.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Body {
|
||||
|
||||
private String sid;
|
||||
private String params;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.kakarote.job.crm;
|
||||
|
||||
|
||||
import com.kakarote.core.common.Result;
|
||||
import com.kakarote.core.feign.crm.service.CrmUserAnalyseService;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CrmTaxPreCheckUsageJob {
|
||||
|
||||
@Autowired
|
||||
private CrmUserAnalyseService crmUserAnalyseService;
|
||||
|
||||
@XxlJob("CrmTaxPreCheckUsageJob")
|
||||
ReturnT<String> crmTaxPreCheckUsageJobHandler(String param){
|
||||
|
||||
Result result = crmUserAnalyseService.getTaxPreCheckUsage();
|
||||
|
||||
if (!result.hasSuccess()) {
|
||||
ReturnT<String> fail = ReturnT.FAIL;
|
||||
fail.setMsg(result.getMsg());
|
||||
return fail;
|
||||
}
|
||||
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue