|
@@ -1,9 +1,11 @@
|
|
|
package com.crm.custom.service.impl;
|
|
package com.crm.custom.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.crm.custom.dao.mapper.CustomFileDao;
|
|
import com.crm.custom.dao.mapper.CustomFileDao;
|
|
|
import com.crm.custom.dao.mapper.CustomInfoDao;
|
|
import com.crm.custom.dao.mapper.CustomInfoDao;
|
|
|
import com.crm.custom.dao.repository.CustomInfoRepository;
|
|
import com.crm.custom.dao.repository.CustomInfoRepository;
|
|
|
import com.crm.custom.dao.repository.CustomLoginHistoryRepository;
|
|
import com.crm.custom.dao.repository.CustomLoginHistoryRepository;
|
|
|
|
|
+import com.crm.custom.dao.repository.GoldenCustomRewardRecordRepository;
|
|
|
import com.crm.custom.dao.repository.UserInfoRepository;
|
|
import com.crm.custom.dao.repository.UserInfoRepository;
|
|
|
import com.crm.custom.service.*;
|
|
import com.crm.custom.service.*;
|
|
|
import com.crm.custom.service.impl.base.BaseUploadServiceImpl;
|
|
import com.crm.custom.service.impl.base.BaseUploadServiceImpl;
|
|
@@ -18,11 +20,13 @@ import com.crm.rely.backend.core.pojo.table.SysConfigTable;
|
|
|
import com.crm.rely.backend.core.pojo.table.SysCountryTable;
|
|
import com.crm.rely.backend.core.pojo.table.SysCountryTable;
|
|
|
import com.crm.rely.backend.model.constant.ConfigConstants;
|
|
import com.crm.rely.backend.model.constant.ConfigConstants;
|
|
|
import com.crm.rely.backend.model.constant.CustomConstants;
|
|
import com.crm.rely.backend.model.constant.CustomConstants;
|
|
|
-import com.crm.rely.backend.model.entity.custom.bank.CustomBankAddEntity;
|
|
|
|
|
|
|
+import com.crm.rely.backend.model.constant.EmailTemplateConstants;
|
|
|
|
|
+import com.crm.rely.backend.model.dto.custom.potential.CustomListDto;
|
|
|
import com.crm.rely.backend.model.entity.custom.fund.history.CustomFundHistoryAddEntity;
|
|
import com.crm.rely.backend.model.entity.custom.fund.history.CustomFundHistoryAddEntity;
|
|
|
import com.crm.rely.backend.model.entity.custom.info.*;
|
|
import com.crm.rely.backend.model.entity.custom.info.*;
|
|
|
import com.crm.rely.backend.model.entity.user.info.UserInfoEntity;
|
|
import com.crm.rely.backend.model.entity.user.info.UserInfoEntity;
|
|
|
import com.crm.rely.backend.model.pojo.table.CustomInfoTable;
|
|
import com.crm.rely.backend.model.pojo.table.CustomInfoTable;
|
|
|
|
|
+import com.crm.rely.backend.model.pojo.table.GoldenCustomRewardRecordTable;
|
|
|
import com.crm.rely.backend.model.pojo.table.UserInfoTable;
|
|
import com.crm.rely.backend.model.pojo.table.UserInfoTable;
|
|
|
import com.crm.rely.backend.model.util.CustomInfoUtil;
|
|
import com.crm.rely.backend.model.util.CustomInfoUtil;
|
|
|
import com.crm.rely.backend.service.EmailService;
|
|
import com.crm.rely.backend.service.EmailService;
|
|
@@ -33,6 +37,7 @@ import com.google.common.base.Strings;
|
|
|
import lombok.extern.log4j.Log4j;
|
|
import lombok.extern.log4j.Log4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.jms.annotation.JmsListener;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -92,7 +97,8 @@ public class CustomInfoServiceImpl extends BaseUploadServiceImpl implements Cust
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private LocaleMessage localeMessage;
|
|
private LocaleMessage localeMessage;
|
|
|
-
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private GoldenCustomRewardRecordRepository goldenCustomRewardRecordRepository;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 用户登录
|
|
* 用户登录
|
|
@@ -231,40 +237,26 @@ public class CustomInfoServiceImpl extends BaseUploadServiceImpl implements Cust
|
|
|
public void add(CustomInfoRegisterEntity entity) throws ServiceException, InterruptedException {
|
|
public void add(CustomInfoRegisterEntity entity) throws ServiceException, InterruptedException {
|
|
|
|
|
|
|
|
//打印注册信息日志
|
|
//打印注册信息日志
|
|
|
- String registerString = String.format("register email:%s,emailCode:%s,agentId:%d",entity.getEmail(),entity.getEmailCode(), entity.getAgentId());
|
|
|
|
|
|
|
+ String registerString = String.format("register email:%s,emailCode:%s,referralCode:%s",entity.getEmail(),entity.getEmailCode(), entity.getReferralCode());
|
|
|
log.info(registerString);
|
|
log.info(registerString);
|
|
|
|
|
|
|
|
//emailService.validateCode(entity.getEmail(), entity.getEmailCode());
|
|
//emailService.validateCode(entity.getEmail(), entity.getEmailCode());
|
|
|
//验证邮箱是否存在
|
|
//验证邮箱是否存在
|
|
|
existByEmail(entity.getEmail());
|
|
existByEmail(entity.getEmail());
|
|
|
|
|
|
|
|
- /*if (entity.getAgentId() != null) {
|
|
|
|
|
- UserInfoTable agent = userInfoRepository.getFirstById(entity.getAgentId());
|
|
|
|
|
- //不存在代理设置为null 外佣设置为0
|
|
|
|
|
- if (agent == null) {
|
|
|
|
|
-
|
|
|
|
|
- log.error("get agent is null,agentId:" + entity.getAgentId());
|
|
|
|
|
- entity.setAgentId(null);
|
|
|
|
|
- } else {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //如果代理链接错误或者没有代理 则将客户挂在公司名下
|
|
|
|
|
- if (entity.getAgentId() == null) {
|
|
|
|
|
- SysConfigTable sysConfigTable = sysConfigService.getByCode(GlobalConfigConstants.COMPANY_ACCOUNT_SUPER);
|
|
|
|
|
- if (sysConfigTable != null) {
|
|
|
|
|
-
|
|
|
|
|
- Long agentId = Long.parseLong(sysConfigTable.getValue());
|
|
|
|
|
- entity.setAgentId(agentId);
|
|
|
|
|
- }
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
+ CustomInfoTable pCustom = customInfoRepository.getFirstByReferralCode(entity.getReferralCode());
|
|
|
|
|
+ entity.setReferralCode(null);
|
|
|
|
|
|
|
|
//获取国家信息
|
|
//获取国家信息
|
|
|
SysCountryTable sysCountryTable = sysCountryService.getByCode(entity.getCountry());
|
|
SysCountryTable sysCountryTable = sysCountryService.getByCode(entity.getCountry());
|
|
|
|
|
|
|
|
CustomInfoTable customInfoTable = new CustomInfoTable();
|
|
CustomInfoTable customInfoTable = new CustomInfoTable();
|
|
|
BeanUtils.copyProperties(entity, customInfoTable);
|
|
BeanUtils.copyProperties(entity, customInfoTable);
|
|
|
|
|
+
|
|
|
|
|
+ if (pCustom != null) {
|
|
|
|
|
+ customInfoTable.setPId(pCustom.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//设置国家信息
|
|
//设置国家信息
|
|
|
customInfoTable.setCountryEnName(sysCountryTable.getEnName());
|
|
customInfoTable.setCountryEnName(sysCountryTable.getEnName());
|
|
|
customInfoTable.setCountryName(sysCountryTable.getName());
|
|
customInfoTable.setCountryName(sysCountryTable.getName());
|
|
@@ -272,24 +264,14 @@ public class CustomInfoServiceImpl extends BaseUploadServiceImpl implements Cust
|
|
|
customInfoTable.setPayStatus(0);
|
|
customInfoTable.setPayStatus(0);
|
|
|
//获取和设置c_id
|
|
//获取和设置c_id
|
|
|
customInfoTable.setCId(CidUtil.getCid().longValue());
|
|
customInfoTable.setCId(CidUtil.getCid().longValue());
|
|
|
|
|
+ customInfoTable.setLevelLabel(1);
|
|
|
customInfoRepository.save(customInfoTable);
|
|
customInfoRepository.save(customInfoTable);
|
|
|
customInfoTable.setAddUser(customInfoTable.getId());
|
|
customInfoTable.setAddUser(customInfoTable.getId());
|
|
|
-//
|
|
|
|
|
-// //构建实体
|
|
|
|
|
-// SysEmailSendEntity sysEmailSendEntity = createRegisterCompleteSysEmailEntity(customInfoTable);
|
|
|
|
|
-//
|
|
|
|
|
-// //发送收据
|
|
|
|
|
-// emailService.sendEmail(sysEmailSendEntity);
|
|
|
|
|
-//
|
|
|
|
|
-// WebNoticeRecordAndEmailMqEntity mqEntity = new WebNoticeRecordAndEmailMqEntity(sysEmailSendEntity,
|
|
|
|
|
-// customInfoTable.getCId(), customInfoTable.getId());
|
|
|
|
|
-// mqSendService.send(Constants.WEB_NOTICE_PUT_RECORD, mqEntity);
|
|
|
|
|
-//
|
|
|
|
|
-// //构建实体
|
|
|
|
|
-// SysEmailSendEntity sysEmailSendEntityToManger = createRegisterCompleteToMangerSysEmailEntity(customInfoTable);
|
|
|
|
|
-//
|
|
|
|
|
-// //发送收据
|
|
|
|
|
-// emailService.sendEmail(sysEmailSendEntityToManger);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (pCustom != null) {
|
|
|
|
|
+ mqSendService.send(ConfigConstants.CUSTOM_LEVEL_LABEL, pCustom);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -310,15 +292,10 @@ public class CustomInfoServiceImpl extends BaseUploadServiceImpl implements Cust
|
|
|
BeanUtils.copyProperties(entity, customInfoTable);
|
|
BeanUtils.copyProperties(entity, customInfoTable);
|
|
|
|
|
|
|
|
//获取国家信息
|
|
//获取国家信息
|
|
|
- /* SysCountryTable sysCountryTable = sysCountryService.getByCode(entity.getCountry());
|
|
|
|
|
|
|
+ SysCountryTable sysCountryTable = sysCountryService.getByCode(entity.getCountry());
|
|
|
//设置国家信息
|
|
//设置国家信息
|
|
|
customInfoTable.setCountryEnName(sysCountryTable.getEnName());
|
|
customInfoTable.setCountryEnName(sysCountryTable.getEnName());
|
|
|
customInfoTable.setCountryName(sysCountryTable.getName());
|
|
customInfoTable.setCountryName(sysCountryTable.getName());
|
|
|
- if (entity.getAddressLines() != null) {
|
|
|
|
|
- customInfoTable.setAddressLine(String.join("@#", entity.getAddressLines()));
|
|
|
|
|
- } else {
|
|
|
|
|
- customInfoTable.setAddressLine(null);
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
|
|
|
customInfoRepository.save(customInfoTable);
|
|
customInfoRepository.save(customInfoTable);
|
|
|
|
|
|
|
@@ -798,6 +775,60 @@ public class CustomInfoServiceImpl extends BaseUploadServiceImpl implements Cust
|
|
|
return infoEntity;
|
|
return infoEntity;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @JmsListener(destination = ConfigConstants.CUSTOM_LEVEL_LABEL)
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public void updateCustomLevelLabel(String content) throws ServiceException {
|
|
|
|
|
+ log.info(String.format("CUSTOM_LEVEL_LABEL,content:", content));
|
|
|
|
|
+ CustomInfoTable customTable = JSON.parseObject(content, CustomInfoTable.class);
|
|
|
|
|
+ if (customTable == null) {
|
|
|
|
|
+ log.error("CUSTOM_LEVEL_LABEL,table is null");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Integer count = customInfoRepository.countByPId(customTable.getId());
|
|
|
|
|
+ if (count == null || count < 5 ) {
|
|
|
|
|
+ log.info(String.format("CUSTOM_LEVEL_LABEL,referral num: %d",count));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ GoldenCustomRewardRecordTable recodeTable = goldenCustomRewardRecordRepository.findFirstByCustomIdAndStatus(customTable.getId(),2);
|
|
|
|
|
+ if (recodeTable == null) {
|
|
|
|
|
+ log.info("CUSTOM_LEVEL_LABEL,reward unfinished");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ sendCustomLevelLabelEmail(customTable);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void sendCustomLevelLabelEmail(CustomInfoTable customTable) throws ServiceException {
|
|
|
|
|
+ //该客户已获得奖学金,成功推荐人数5人,请将其标签调整为“传誉师”。
|
|
|
|
|
+
|
|
|
|
|
+ SysConfigTable sysConfigTable = sysConfigService.getByCode(ConfigConstants.UPDATE_LEVEL_LABEL_EMAIL);
|
|
|
|
|
+
|
|
|
|
|
+ //构建map 用于后面邮件模版替换
|
|
|
|
|
+ Map<String, String> map = new HashMap<>(6);
|
|
|
|
|
+ map.put(MapConstants.DATE_TIME, DateUtil.formatTime(new Date()));
|
|
|
|
|
+
|
|
|
|
|
+ map.put(MapConstants.C_ID, String.valueOf(customTable.getCId()));
|
|
|
|
|
+ map.put(MapConstants.EMAIL, customTable.getEmail());
|
|
|
|
|
+ map.put(MapConstants.PHONE, customTable.getPhone());
|
|
|
|
|
+ map.put(MapConstants.NAME, customTable.getName());
|
|
|
|
|
+ map.put(ConfigConstants.REFERRAL_CODE, customTable.getName());
|
|
|
|
|
+
|
|
|
|
|
+ SysEmailSendEntity sysEmailSendEntity = new SysEmailSendEntity();
|
|
|
|
|
+ sysEmailSendEntity.setSubject("Update Label Notice");
|
|
|
|
|
+ sysEmailSendEntity.setEmailSendEnum(EmailSendEnum.UPDATE_LEVEL_LABEL);
|
|
|
|
|
+ sysEmailSendEntity.setMap(map);
|
|
|
|
|
+ sysEmailSendEntity.setTemplateName(EmailTemplateConstants.UPDATE_LEVEL_LABEL);
|
|
|
|
|
+
|
|
|
|
|
+ sysEmailSendEntity.setUsers(sysConfigTable.getValue());
|
|
|
|
|
+ try {
|
|
|
|
|
+ emailService.sendEmail(sysEmailSendEntity);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void deleteInBatch(LongEntitys entitys) throws Exception {
|
|
public void deleteInBatch(LongEntitys entitys) throws Exception {
|
|
@@ -873,4 +904,14 @@ public class CustomInfoServiceImpl extends BaseUploadServiceImpl implements Cust
|
|
|
return customInfoTable.getBalance() == null ? BigDecimal.ZERO : customInfoTable.getBalance();
|
|
return customInfoTable.getBalance() == null ? BigDecimal.ZERO : customInfoTable.getBalance();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CustomListDto getLevelLabel(Long id) {
|
|
|
|
|
+ CustomInfoTable customInfoTable = customInfoRepository.getFirstById(id);
|
|
|
|
|
+
|
|
|
|
|
+ CustomListDto dto = new CustomListDto();
|
|
|
|
|
+ dto.setLevelLabel(customInfoTable.getLevelLabel());
|
|
|
|
|
+ dto.setReferralCode(customInfoTable.getReferralCode());
|
|
|
|
|
+ return dto;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|