|
|
@ -30,6 +30,7 @@ import com.epmet.commons.tools.redis.RedisKeys; |
|
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.CpUserDetailRedis; |
|
|
|
import com.epmet.constant.PaConstant; |
|
|
|
import com.epmet.dao.PaCustomerDao; |
|
|
|
import com.epmet.dao.PaUserDao; |
|
|
@ -40,13 +41,14 @@ import com.epmet.dto.PaUserDTO; |
|
|
|
import com.epmet.dto.PaUserWechatDTO; |
|
|
|
import com.epmet.dto.form.CreateAgencyFormDTO; |
|
|
|
import com.epmet.dto.form.RegisterFormDTO; |
|
|
|
import com.epmet.dto.result.AgencyLevelListResultDTO; |
|
|
|
import com.epmet.dto.result.CreateAgencyResultDTO; |
|
|
|
import com.epmet.entity.PaCustomerEntity; |
|
|
|
import com.epmet.entity.PaUserEntity; |
|
|
|
import com.epmet.entity.PaUserVisitedEntity; |
|
|
|
import com.epmet.entity.PaUserWechatEntity; |
|
|
|
import com.epmet.entity.*; |
|
|
|
import com.epmet.redis.PaCustomerRedis; |
|
|
|
import com.epmet.service.CustomerMpService; |
|
|
|
import com.epmet.service.PaCustomerAgencyService; |
|
|
|
import com.epmet.service.PaCustomerService; |
|
|
|
import com.epmet.service.PaCustomerUserAgencyService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.logging.log4j.LogManager; |
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
@ -54,6 +56,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@ -78,6 +81,14 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust |
|
|
|
private PaUserVisitedDao paUserVisitedDao; |
|
|
|
@Autowired |
|
|
|
private RedisUtils redisUtils; |
|
|
|
@Autowired |
|
|
|
private PaCustomerAgencyService paCustomerAgencyService; |
|
|
|
@Autowired |
|
|
|
private PaCustomerUserAgencyService paCustomerUserAgencyService; |
|
|
|
@Autowired |
|
|
|
private CustomerMpService customerMpService; |
|
|
|
@Autowired |
|
|
|
private CpUserDetailRedis cpUserDetailRedis; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<PaCustomerDTO> page(Map<String, Object> params) { |
|
|
@ -95,8 +106,8 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust |
|
|
|
return ConvertUtils.sourceToTarget(entityList, PaCustomerDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<PaCustomerEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<PaCustomerEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<PaCustomerEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
@ -177,6 +188,33 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust |
|
|
|
paUserVisitedDao.insert(visitedEntity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 公众号-查询组织级别 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public List<AgencyLevelListResultDTO> agencyLevelList() { |
|
|
|
List<AgencyLevelListResultDTO> list = new ArrayList<>(); |
|
|
|
AgencyLevelListResultDTO dto1 = new AgencyLevelListResultDTO(); |
|
|
|
dto1.setLevelKey(PaConstant.PROVINCE_KEY); |
|
|
|
dto1.setLevelName(PaConstant.PROVINCE_NAME); |
|
|
|
list.add(dto1); |
|
|
|
AgencyLevelListResultDTO dto2 = new AgencyLevelListResultDTO(); |
|
|
|
dto2.setLevelKey(PaConstant.CITY_KEY); |
|
|
|
dto2.setLevelName(PaConstant.CITY_NAME); |
|
|
|
list.add(dto2); |
|
|
|
AgencyLevelListResultDTO dto3 = new AgencyLevelListResultDTO(); |
|
|
|
dto3.setLevelKey(PaConstant.STREET_KEY); |
|
|
|
dto3.setLevelName(PaConstant.STREET_NAME); |
|
|
|
list.add(dto3); |
|
|
|
AgencyLevelListResultDTO dto4 = new AgencyLevelListResultDTO(); |
|
|
|
dto4.setLevelKey(PaConstant.COMMUNITY_KEY); |
|
|
|
dto4.setLevelName(PaConstant.COMMUNITY_NAME); |
|
|
|
list.add(dto4); |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
@ -184,15 +222,64 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust |
|
|
|
* @Description 公众号-创建组织 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO) { |
|
|
|
//1.客户表初始化数据
|
|
|
|
PaCustomerEntity entity = new PaCustomerEntity(); |
|
|
|
entity.setCustomerName(formDTO.getAgencyName()); |
|
|
|
baseDao.insert(entity); |
|
|
|
|
|
|
|
//2.客户组织表初始化数据
|
|
|
|
//3.
|
|
|
|
//4.
|
|
|
|
//5.
|
|
|
|
PaCustomerAgencyEntity agencyEntity = new PaCustomerAgencyEntity(); |
|
|
|
agencyEntity.setCustomerId(entity.getId()); |
|
|
|
agencyEntity.setAgencyName(formDTO.getAgencyName()); |
|
|
|
agencyEntity.setLevel(formDTO.getLevel()); |
|
|
|
agencyEntity.setAreaCode(formDTO.getAreaCode()); |
|
|
|
agencyEntity.setProvince(formDTO.getProvince()); |
|
|
|
agencyEntity.setCity(formDTO.getCity()); |
|
|
|
agencyEntity.setDistrict(formDTO.getDistrict()); |
|
|
|
agencyEntity.setPartybranchnum(formDTO.getPartyBranchNum()); |
|
|
|
paCustomerAgencyService.insert(agencyEntity); |
|
|
|
|
|
|
|
//3.客户组织用户关系表初始化数据
|
|
|
|
PaCustomerUserAgencyEntity cuaEntity = new PaCustomerUserAgencyEntity(); |
|
|
|
cuaEntity.setCustomerId(entity.getId()); |
|
|
|
cuaEntity.setAgencyId(agencyEntity.getId()); |
|
|
|
cuaEntity.setUserId(tokenDTO.getUserId()); |
|
|
|
paCustomerUserAgencyService.insert(cuaEntity); |
|
|
|
|
|
|
|
return null; |
|
|
|
//4.客户小程序关系表初始化数据
|
|
|
|
List<CustomerMpEntity> listEntity = new ArrayList<>(); |
|
|
|
CustomerMpEntity mpEntity1 = new CustomerMpEntity(); |
|
|
|
mpEntity1.setCustomerId(entity.getId()); |
|
|
|
mpEntity1.setAuthorizationFlag(NumConstant.ZERO); |
|
|
|
mpEntity1.setClient(PaConstant.RESI_CLIENT); |
|
|
|
listEntity.add(mpEntity1); |
|
|
|
CustomerMpEntity mpEntity2 = ConvertUtils.sourceToTarget(mpEntity1, CustomerMpEntity.class); |
|
|
|
mpEntity2.setClient(PaConstant.WORK_CLIENT); |
|
|
|
listEntity.add(mpEntity2); |
|
|
|
customerMpService.insertBatch(listEntity); |
|
|
|
|
|
|
|
//5.token中添加customerId
|
|
|
|
//5-1.获取redis中的token
|
|
|
|
//获取缓存中的token
|
|
|
|
TokenDto redisTokenDTO = cpUserDetailRedis.get(LoginConstant.APP_PUBLIC, LoginConstant.CLIENT_MP, tokenDTO.getUserId(), TokenDto.class); |
|
|
|
if (redisTokenDTO == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
//5-2.添加customerId
|
|
|
|
redisTokenDTO.setCustomerId(entity.getId()); |
|
|
|
//获取key的剩余过期时间
|
|
|
|
String key = RedisKeys.getCpUserKey(LoginConstant.APP_PUBLIC, LoginConstant.CLIENT_MP, tokenDTO.getUserId()); |
|
|
|
long expire = redisUtils.getExpire(key); |
|
|
|
cpUserDetailRedis.set(redisTokenDTO, expire); |
|
|
|
|
|
|
|
//6.接口返参
|
|
|
|
CreateAgencyResultDTO resultDTO = new CreateAgencyResultDTO(); |
|
|
|
resultDTO.setCustomerId(entity.getId()); |
|
|
|
resultDTO.setToken(redisTokenDTO.getToken()); |
|
|
|
|
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -207,5 +294,4 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |