Merge branch 'dev' of http://122.51.230.86:3000/dianliang/lanan-system into dev
This commit is contained in:
commit
95c8fb9491
@ -12,13 +12,17 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
public enum InviterTypeEnum {
|
public enum InviterTypeEnum {
|
||||||
/**
|
/**
|
||||||
* 员工邀请
|
* 自主创建
|
||||||
*/
|
*/
|
||||||
STAFF("1","员工邀请"),
|
SELF("01","自主创建"),
|
||||||
/**
|
/**
|
||||||
* 客户邀请
|
* 客户转介绍
|
||||||
*/
|
*/
|
||||||
CUSTOMER("2","客户邀请");
|
CUSTOMER("02","客户转介绍"),
|
||||||
|
/**
|
||||||
|
* 员工转介绍
|
||||||
|
*/
|
||||||
|
STAFF("03","员工转介绍");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* code
|
* code
|
||||||
|
@ -14,28 +14,32 @@ public enum SystemEnum {
|
|||||||
/**
|
/**
|
||||||
* 维修系统
|
* 维修系统
|
||||||
*/
|
*/
|
||||||
REPAIR("weixiu","维修系统"),
|
REPAIR("weixiu","04","维修系统"),
|
||||||
/**
|
/**
|
||||||
* 救援系统
|
* 救援系统
|
||||||
*/
|
*/
|
||||||
RESCUE("jiuyuan","救援系统"),
|
RESCUE("jiuyuan","02","救援系统"),
|
||||||
/**
|
/**
|
||||||
* 驾校系统
|
* 驾校系统
|
||||||
*/
|
*/
|
||||||
SCHOOL("jiaxiao","驾校系统"),
|
SCHOOL("jiaxiao","03","驾校系统"),
|
||||||
/**
|
/**
|
||||||
* 检测系统
|
* 检测系统
|
||||||
*/
|
*/
|
||||||
INSPECTION("jiance","检测系统"),
|
INSPECTION("jiance","01","检测系统"),
|
||||||
/**
|
/**
|
||||||
* 保险系统
|
* 保险系统
|
||||||
*/
|
*/
|
||||||
INSURE("baoxian","保险系统");
|
INSURE("baoxian","06","保险系统");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统标识
|
* 系统标识
|
||||||
*/
|
*/
|
||||||
private String code;
|
private String code;
|
||||||
|
/**
|
||||||
|
* 对应的客户来源字典值
|
||||||
|
*/
|
||||||
|
private String dataFrom;
|
||||||
/**
|
/**
|
||||||
* 系统名称
|
* 系统名称
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +27,7 @@ public class UserCarController {
|
|||||||
@GetMapping("/getMyCar")
|
@GetMapping("/getMyCar")
|
||||||
@Operation(summary = "查询个人车辆列表")
|
@Operation(summary = "查询个人车辆列表")
|
||||||
public CommonResult<?> getMyCar() {
|
public CommonResult<?> getMyCar() {
|
||||||
return CommonResult.success(userCarService.getMyCar());
|
return CommonResult.success(userCarService.getMyCar(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -38,8 +38,8 @@ public class UserCarController {
|
|||||||
**/
|
**/
|
||||||
@GetMapping("/empowerUserInfo")
|
@GetMapping("/empowerUserInfo")
|
||||||
@Operation(summary = "授权个人信息到某企业")
|
@Operation(summary = "授权个人信息到某企业")
|
||||||
public CommonResult<?> empowerUserInfo(@RequestParam("tenantId") Long tenantId) {
|
public CommonResult<?> empowerUserInfo(@RequestParam("tenantId") Long tenantId,@RequestParam("systemCode") String systemCode) {
|
||||||
userCarService.empowerUserInfo(tenantId);
|
userCarService.empowerUserInfo(tenantId,systemCode,null,null,null);
|
||||||
return CommonResult.success(true);
|
return CommonResult.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public class CustomerMain extends TenantBaseDO {
|
|||||||
private String memberLevelId;
|
private String memberLevelId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否挂账
|
* 是否允许挂账
|
||||||
*/
|
*/
|
||||||
private String isHangAccount;
|
private String isHangAccount;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public interface UserCarService extends IService<UserCar> {
|
|||||||
* @date 14:28 2024/10/11
|
* @date 14:28 2024/10/11
|
||||||
* @return java.util.List<cn.iocoder.yudao.module.custom.vo.UserCarVO>
|
* @return java.util.List<cn.iocoder.yudao.module.custom.vo.UserCarVO>
|
||||||
**/
|
**/
|
||||||
List<UserCarVO> getMyCar();
|
List<UserCarVO> getMyCar(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -46,6 +46,10 @@ public interface UserCarService extends IService<UserCar> {
|
|||||||
* @author PQZ
|
* @author PQZ
|
||||||
* @date 12:40 2024/10/12
|
* @date 12:40 2024/10/12
|
||||||
* @param tenantId 租户id
|
* @param tenantId 租户id
|
||||||
|
* @param dataFrom 客户来源
|
||||||
|
* @param userId 邀请者的用户ID
|
||||||
|
* @param newUserId 被邀请者的用户ID
|
||||||
|
* @param inviteType 邀请类型
|
||||||
**/
|
**/
|
||||||
void empowerUserInfo(Long tenantId);
|
void empowerUserInfo(Long tenantId,String dataFrom,Long userId,Long newUserId,String inviteType);
|
||||||
}
|
}
|
||||||
|
@ -167,37 +167,6 @@ public class CustomerMainServiceImpl extends ServiceImpl<CustomerMainMapper, Cus
|
|||||||
Set<String> roleCodes = new HashSet<>();
|
Set<String> roleCodes = new HashSet<>();
|
||||||
roleCodes.add(dict.getRemark());
|
roleCodes.add(dict.getRemark());
|
||||||
permissionApi.assignUserRole(userId, roleCodes);
|
permissionApi.assignUserRole(userId, roleCodes);
|
||||||
}else if(INVITE_CREATE.equals(sign)){
|
|
||||||
//邀请注册/授权给某个租户
|
|
||||||
//查询数据字典,根据客户类型匹配出预设角色code;
|
|
||||||
DictDataRespDTO dict = dictDataApi.getDictData(DICT_CUS_TYPE, main.getTypeCode());
|
|
||||||
if (CUS_TYPE_CORP.equals(main.getTypeCode())) {
|
|
||||||
//查询当前登录用户所属租户的政企客户部门id(父级部门)
|
|
||||||
DeptRespDTO parentDept = deptApi.getDeptByName(DEPT_NAME_CORP_NAME);
|
|
||||||
//在部门表下新增一个部门
|
|
||||||
DeptRespDTO deptRespDTO = new DeptRespDTO();
|
|
||||||
deptRespDTO.setName(main.getCusName());
|
|
||||||
deptRespDTO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
|
||||||
//上级部门为本租户顶级部门
|
|
||||||
deptRespDTO.setParentId(parentDept.getId());
|
|
||||||
Long deptId = deptApi.saveDept(deptRespDTO);
|
|
||||||
//客户信息表绑定deptCode
|
|
||||||
main.setDeptCode(deptId);
|
|
||||||
}else{
|
|
||||||
//私人客户和代办客户归属到默认的部门中
|
|
||||||
String deptName = "";
|
|
||||||
if(CUS_TYPE_PRIVATE.equals(main.getTypeCode())){
|
|
||||||
deptName =DEPT_NAME_PRIVATE_NAME;
|
|
||||||
}else if(CUS_TYPE_AGENT.equals(main.getTypeCode())){
|
|
||||||
deptName = DEPT_NAME_AGENT_NAME;
|
|
||||||
}
|
|
||||||
DeptRespDTO parentDept = deptApi.getDeptByName(deptName);
|
|
||||||
main.setDeptCode(parentDept.getId());
|
|
||||||
}
|
|
||||||
//绑定角色
|
|
||||||
Set<String> roleCodes = new HashSet<>();
|
|
||||||
roleCodes.add(dict.getRemark());
|
|
||||||
permissionApi.assignUserRole(main.getUserId(), roleCodes);
|
|
||||||
}
|
}
|
||||||
/*3、保存客户主表信息*/
|
/*3、保存客户主表信息*/
|
||||||
//暂时写死会员id TODO
|
//暂时写死会员id TODO
|
||||||
|
@ -86,9 +86,9 @@ public class UserCarServiceImpl extends ServiceImpl<UserCarMapper, UserCar> impl
|
|||||||
* @date 14:28 2024/10/11
|
* @date 14:28 2024/10/11
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public List<UserCarVO> getMyCar() {
|
public List<UserCarVO> getMyCar(Long userId) {
|
||||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
return userCarMapper.selectByUserId(loginUser.getId());
|
return userCarMapper.selectByUserId(null==userId?loginUser.getId():userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,23 +110,26 @@ public class UserCarServiceImpl extends ServiceImpl<UserCarMapper, UserCar> impl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 将客户信息授权给某个修理厂
|
* 将客户信息授权给某个修理厂
|
||||||
*
|
|
||||||
* @param tenantId 租户id
|
|
||||||
* @author PQZ
|
* @author PQZ
|
||||||
* @date 12:40 2024/10/12
|
* @date 12:40 2024/10/12
|
||||||
|
* @param tenantId 租户id
|
||||||
|
* @param dataFrom 客户来源
|
||||||
|
* @param userId 邀请者的用户ID
|
||||||
|
* @param newUserId 被邀请者的用户ID
|
||||||
|
* @param inviteType 邀请类型
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@TenantIgnore
|
@TenantIgnore
|
||||||
public void empowerUserInfo(Long tenantId) {
|
public void empowerUserInfo(Long tenantId,String dataFrom,Long userId,Long newUserId,String inviteType) {
|
||||||
/*1、基础数据准备*/
|
/*1、基础数据准备*/
|
||||||
|
if(null==newUserId){
|
||||||
|
newUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||||
|
}
|
||||||
//获取当前登录用户信息
|
//获取当前登录用户信息
|
||||||
Long userId = SecurityFrameworkUtils.getLoginUserId();
|
AdminUserRespDTO loginUser = userApi.getUser(newUserId);
|
||||||
AdminUserRespDTO loginUser = userApi.getUser(userId);
|
|
||||||
//获取当前登录用户车辆信息
|
//获取当前登录用户车辆信息
|
||||||
List<UserCarVO> carList = this.getMyCar();
|
List<UserCarVO> carList = this.getMyCar(newUserId);
|
||||||
//所有车牌号list
|
|
||||||
List<String> licenseNoList = carList.stream().map(UserCar::getLicenseNumber).collect(Collectors.toList());
|
|
||||||
//需要保存的关联关系
|
//需要保存的关联关系
|
||||||
List<CustomerCar> saveCustomerCarList = new ArrayList<>();
|
List<CustomerCar> saveCustomerCarList = new ArrayList<>();
|
||||||
//需要保存的车辆信息
|
//需要保存的车辆信息
|
||||||
@ -135,11 +138,12 @@ public class UserCarServiceImpl extends ServiceImpl<UserCarMapper, UserCar> impl
|
|||||||
final CustomerMain[] oldMain = {null};
|
final CustomerMain[] oldMain = {null};
|
||||||
//查已有的车辆信息,若有则更新,没有则插入
|
//查已有的车辆信息,若有则更新,没有则插入
|
||||||
final Map<String, CarMain>[] carMap = new Map[]{new HashMap<>()};
|
final Map<String, CarMain>[] carMap = new Map[]{new HashMap<>()};
|
||||||
|
Long finalNewUserId = newUserId;
|
||||||
TenantUtils.execute(tenantId, () -> {
|
TenantUtils.execute(tenantId, () -> {
|
||||||
//客户在这个租户下的信息
|
//客户在这个租户下的信息
|
||||||
oldMain[0] = customerMainService.getCustomerByUserId(userId);
|
oldMain[0] = customerMainService.getCustomerByUserId(finalNewUserId);
|
||||||
//客户在这个租户下的车辆信息
|
//客户在这个租户下的车辆信息
|
||||||
List<CarMain> oldCarMainList=carMainService.selectListByUserId(userId);
|
List<CarMain> oldCarMainList=carMainService.selectListByUserId(finalNewUserId);
|
||||||
carMap[0] = oldCarMainList.stream().collect(Collectors.toMap(CarMain::getLicenseNumber, Function.identity()));
|
carMap[0] = oldCarMainList.stream().collect(Collectors.toMap(CarMain::getLicenseNumber, Function.identity()));
|
||||||
});
|
});
|
||||||
String customerId;
|
String customerId;
|
||||||
@ -147,22 +151,32 @@ public class UserCarServiceImpl extends ServiceImpl<UserCarMapper, UserCar> impl
|
|||||||
/*2、数据转换,将用户表关联信息转换成客户表关联信息 */
|
/*2、数据转换,将用户表关联信息转换成客户表关联信息 */
|
||||||
//转换客户数据
|
//转换客户数据
|
||||||
if(null== oldMain[0]){
|
if(null== oldMain[0]){
|
||||||
|
//新增客户
|
||||||
customerId = UUID.randomUUID().toString().replace("-", "");
|
customerId = UUID.randomUUID().toString().replace("-", "");
|
||||||
customerMain = new CustomerMain();
|
customerMain = new CustomerMain();
|
||||||
customerMain.setId(customerId);
|
customerMain.setId(customerId);
|
||||||
|
customerMain.setUserId(newUserId);
|
||||||
|
//客户租户
|
||||||
|
customerMain.setTenantId(tenantId);
|
||||||
|
//统一为个人客户
|
||||||
|
customerMain.setTypeCode("01");
|
||||||
|
//客户初始来源系统
|
||||||
|
customerMain.setDataFrom(dataFrom);
|
||||||
|
//默认不允许挂账
|
||||||
|
customerMain.setIsHangAccount("0");
|
||||||
|
if(null!=userId){
|
||||||
|
//是被邀请的,设置邀请者信息
|
||||||
|
customerMain.setInviter(userId.toString());
|
||||||
|
customerMain.setInviterType(inviteType);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
|
//更新客户信息
|
||||||
customerId = oldMain[0].getId();
|
customerId = oldMain[0].getId();
|
||||||
customerMain = oldMain[0];
|
customerMain = oldMain[0];
|
||||||
}
|
}
|
||||||
//提前为客户id赋值
|
|
||||||
customerMain.setUserId(userId);
|
|
||||||
customerMain.setCusName(loginUser.getNickname());
|
customerMain.setCusName(loginUser.getNickname());
|
||||||
customerMain.setSex(String.valueOf(loginUser.getSex()));
|
customerMain.setSex(String.valueOf(loginUser.getSex()));
|
||||||
customerMain.setPhoneNumber(loginUser.getMobile());
|
customerMain.setPhoneNumber(loginUser.getMobile());
|
||||||
customerMain.setTenantId(tenantId);
|
|
||||||
customerMain.setTypeCode("01");
|
|
||||||
customerMain.setDataFrom("04");
|
|
||||||
customerMain.setIsHangAccount("0");
|
|
||||||
//转换车辆及关联关系数据
|
//转换车辆及关联关系数据
|
||||||
if (CollUtil.isNotEmpty(carList)){
|
if (CollUtil.isNotEmpty(carList)){
|
||||||
carList.forEach(item ->{
|
carList.forEach(item ->{
|
||||||
@ -185,7 +199,7 @@ public class UserCarServiceImpl extends ServiceImpl<UserCarMapper, UserCar> impl
|
|||||||
//车辆信息
|
//车辆信息
|
||||||
carItem.setEngineNumber(item.getEngineNumber());
|
carItem.setEngineNumber(item.getEngineNumber());
|
||||||
carItem.setVin(item.getVin());
|
carItem.setVin(item.getVin());
|
||||||
carItem.setUserId(userId);
|
carItem.setUserId(finalNewUserId);
|
||||||
carItem.setLicenseNumber(item.getLicenseNumber());
|
carItem.setLicenseNumber(item.getLicenseNumber());
|
||||||
carItem.setCarModel(item.getCarModel());
|
carItem.setCarModel(item.getCarModel());
|
||||||
carItem.setMaintenanceDate(convertToLocalDateTime(item.getMaintenanceDate()));
|
carItem.setMaintenanceDate(convertToLocalDateTime(item.getMaintenanceDate()));
|
||||||
|
@ -128,6 +128,19 @@ public class CompanyStaffController {
|
|||||||
return success(staffRespVO);
|
return success(staffRespVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 给所有没有推广码的员工设置推广码
|
||||||
|
* @author vinjor-M
|
||||||
|
* @date 17:29 2024/10/15
|
||||||
|
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO>
|
||||||
|
**/
|
||||||
|
@GetMapping("/setStaffUnicode")
|
||||||
|
@Operation(summary = "给所有没有推广码的员工设置推广码")
|
||||||
|
public CommonResult<CompanyStaffRespVO> setStaffUnicode() {
|
||||||
|
staffService.setStaffUnicode();
|
||||||
|
return CommonResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询员工单个 没有附加属性
|
* 查询员工单个 没有附加属性
|
||||||
*
|
*
|
||||||
|
@ -117,10 +117,18 @@ public interface CompanyStaffService extends IService<CompanyStaff> {
|
|||||||
* 新增推广记录
|
* 新增推广记录
|
||||||
* @author vinjor-m
|
* @author vinjor-m
|
||||||
* @date 12:26 2024/8/14
|
* @date 12:26 2024/8/14
|
||||||
|
* @param dataFrom 客户来源
|
||||||
* @param uniqueCode 推广码
|
* @param uniqueCode 推广码
|
||||||
* @param user 被推广用户
|
* @param user 被推广用户
|
||||||
* @param promotionChannel 推广渠道
|
* @param promotionChannel 推广渠道
|
||||||
* @param registerTime 被推广用户注册的时间
|
* @param registerTime 被推广用户注册的时间
|
||||||
**/
|
**/
|
||||||
Boolean createPromotion(String uniqueCode, AdminUserDO user, String promotionChannel, Date registerTime);
|
Boolean createPromotion(String dataFrom,String uniqueCode, AdminUserDO user, String promotionChannel, Date registerTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 给所有没有推广码的员工设置推广码
|
||||||
|
* @author vinjor-M
|
||||||
|
* @date 17:23 2024/10/15
|
||||||
|
**/
|
||||||
|
void setStaffUnicode();
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,10 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|||||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||||
import cn.iocoder.yudao.module.custom.entity.BasePromotion;
|
import cn.iocoder.yudao.module.custom.entity.BasePromotion;
|
||||||
|
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||||
import cn.iocoder.yudao.module.custom.service.BasePromotionService;
|
import cn.iocoder.yudao.module.custom.service.BasePromotionService;
|
||||||
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
|
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
|
||||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
|
import cn.iocoder.yudao.module.custom.service.UserCarService;
|
||||||
import cn.iocoder.yudao.module.label.entity.BusiLabel;
|
import cn.iocoder.yudao.module.label.entity.BusiLabel;
|
||||||
import cn.iocoder.yudao.module.label.entity.Label;
|
import cn.iocoder.yudao.module.label.entity.Label;
|
||||||
import cn.iocoder.yudao.module.label.service.BusiLabelService;
|
import cn.iocoder.yudao.module.label.service.BusiLabelService;
|
||||||
@ -51,7 +52,6 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.common.BaseConstants.INVITE_CREATE;
|
|
||||||
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF;
|
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF;
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
|
||||||
@ -94,6 +94,8 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
|
|||||||
private BasePromotionService basePromotionService;
|
private BasePromotionService basePromotionService;
|
||||||
@Resource
|
@Resource
|
||||||
private CustomerMainService customerMainService;
|
private CustomerMainService customerMainService;
|
||||||
|
@Resource
|
||||||
|
private UserCarService userCarService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得企业管理-员工信息表分页
|
* 获得企业管理-员工信息表分页
|
||||||
@ -530,6 +532,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
|
|||||||
/**
|
/**
|
||||||
* 新增推广记录---忽略租户
|
* 新增推广记录---忽略租户
|
||||||
*
|
*
|
||||||
|
* @param dataFrom 客户来源
|
||||||
* @param uniqueCode 推广码
|
* @param uniqueCode 推广码
|
||||||
* @param user 被推广用户
|
* @param user 被推广用户
|
||||||
* @param promotionChannel 推广渠道
|
* @param promotionChannel 推广渠道
|
||||||
@ -539,7 +542,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
|
|||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
@TenantIgnore
|
@TenantIgnore
|
||||||
public Boolean createPromotion(String uniqueCode, AdminUserDO user, String promotionChannel, Date registerTime) {
|
public Boolean createPromotion(String dataFrom,String uniqueCode, AdminUserDO user, String promotionChannel, Date registerTime) {
|
||||||
/*1.先查是否是员工推广 */
|
/*1.先查是否是员工推广 */
|
||||||
LambdaQueryWrapper<CompanyStaff> queryWrapper = new LambdaQueryWrapper<CompanyStaff>()
|
LambdaQueryWrapper<CompanyStaff> queryWrapper = new LambdaQueryWrapper<CompanyStaff>()
|
||||||
.eq(CompanyStaff::getUniqueCode,uniqueCode);
|
.eq(CompanyStaff::getUniqueCode,uniqueCode);
|
||||||
@ -547,39 +550,59 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
|
|||||||
if(!staffList.isEmpty()){
|
if(!staffList.isEmpty()){
|
||||||
//员工推广
|
//员工推广
|
||||||
CompanyStaff staff = staffList.get(0);
|
CompanyStaff staff = staffList.get(0);
|
||||||
// 插入推广记录
|
//查该客户是否已被该租户的员工推广过
|
||||||
BasePromotion basePromotion = new BasePromotion();
|
final CustomerMain[] thisCus = {null};
|
||||||
basePromotion.setOldUserId(staff.getUserId());
|
|
||||||
basePromotion.setOldUserName(staff.getName());
|
|
||||||
basePromotion.setPromotionChannel(promotionChannel);
|
|
||||||
basePromotion.setNewUserId(user.getId());
|
|
||||||
basePromotion.setNewUserName(user.getNickname());
|
|
||||||
basePromotion.setRegisterTime(registerTime);
|
|
||||||
basePromotion.setUniqueCode(uniqueCode);
|
|
||||||
basePromotionService.save(basePromotion);
|
|
||||||
//取到该员工的租户,以该租户的角度去保存客户数据
|
//取到该员工的租户,以该租户的角度去保存客户数据
|
||||||
TenantUtils.execute(staff.getTenantId(), () -> {
|
TenantUtils.execute(staff.getTenantId(), () -> {
|
||||||
CustomerMainSaveReqVO saveReqVO = new CustomerMainSaveReqVO();
|
thisCus[0] = customerMainService.getCustomerByUserId(user.getId());
|
||||||
saveReqVO.setUserId(user.getId());
|
|
||||||
saveReqVO.setPhoneNumber(user.getMobile());
|
|
||||||
saveReqVO.setSex(user.getSex().toString());
|
|
||||||
saveReqVO.setCusName(user.getNickname());
|
|
||||||
//客户类型,统一为私人客户
|
|
||||||
saveReqVO.setTypeCode("01");
|
|
||||||
//客户来源,统一为04-维修
|
|
||||||
saveReqVO.setDataFrom("04");
|
|
||||||
//注册方式,统一为自主创建
|
|
||||||
saveReqVO.setInviterType("01");
|
|
||||||
//邀请者id
|
|
||||||
saveReqVO.setInviter(staff.getUserId().toString());
|
|
||||||
//邀请者类型
|
|
||||||
saveReqVO.setInviterType(InviterTypeEnum.STAFF.getCode());
|
|
||||||
//邀请注册添加客户
|
|
||||||
customerMainService.saveCustomer(saveReqVO,INVITE_CREATE);
|
|
||||||
});
|
});
|
||||||
|
if(null==thisCus[0]){
|
||||||
|
// 插入推广记录
|
||||||
|
BasePromotion basePromotion = new BasePromotion();
|
||||||
|
basePromotion.setOldUserId(staff.getUserId());
|
||||||
|
basePromotion.setOldUserName(staff.getName());
|
||||||
|
basePromotion.setPromotionChannel(promotionChannel);
|
||||||
|
basePromotion.setNewUserId(user.getId());
|
||||||
|
basePromotion.setNewUserName(user.getNickname());
|
||||||
|
basePromotion.setRegisterTime(registerTime);
|
||||||
|
basePromotion.setUniqueCode(uniqueCode);
|
||||||
|
basePromotionService.save(basePromotion);
|
||||||
|
//将客户信息授权给员工所属的租户
|
||||||
|
userCarService.empowerUserInfo(staff.getTenantId(),dataFrom,staff.getUserId(),user.getId(),InviterTypeEnum.STAFF.getCode());
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
/*2.不是员工推广,再查是否是客户推广*/
|
/*2.不是员工推广,再查是否是客户推广*/
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 给所有没有推广码的员工设置推广码
|
||||||
|
*
|
||||||
|
* @author vinjor-M
|
||||||
|
* @date 17:23 2024/10/15
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
@TenantIgnore
|
||||||
|
public void setStaffUnicode() {
|
||||||
|
LambdaQueryWrapper<CompanyStaff> queryWrapper = new LambdaQueryWrapper<CompanyStaff>()
|
||||||
|
.isNull(CompanyStaff::getUniqueCode);
|
||||||
|
List<CompanyStaff> list = this.list(queryWrapper);
|
||||||
|
if(!list.isEmpty()){
|
||||||
|
for (CompanyStaff staff:list){
|
||||||
|
try {
|
||||||
|
// 2 生成唯一推广码
|
||||||
|
String uniqueCode = uniqueCodeService.createUniqueCode();
|
||||||
|
if (!ObjectUtil.isNotEmpty(uniqueCode)) {
|
||||||
|
throw exception(CommonErrorCodeConstants.UNIQUE_CODE_CREATE_REPEAT);
|
||||||
|
}
|
||||||
|
staff.setUniqueCode(uniqueCode);
|
||||||
|
}catch (Exception e){
|
||||||
|
//记录日志,不能影响程序执行
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.updateBatchById(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,21 +137,28 @@ public class WechatServiceImpl implements WechatService {
|
|||||||
//更新
|
//更新
|
||||||
user.setId(wxUser.getId());
|
user.setId(wxUser.getId());
|
||||||
}
|
}
|
||||||
|
String dataFrom = "";
|
||||||
//设置微信openId
|
//设置微信openId
|
||||||
if(SystemEnum.REPAIR.getCode().equals(sysCode)){
|
if(SystemEnum.REPAIR.getCode().equals(sysCode)){
|
||||||
//维修业务系统
|
//维修业务系统
|
||||||
user.setRepairOpenId(openId);
|
user.setRepairOpenId(openId);
|
||||||
|
dataFrom = SystemEnum.REPAIR.getDataFrom();
|
||||||
}else if(SystemEnum.INSPECTION.getCode().equals(sysCode)){
|
}else if(SystemEnum.INSPECTION.getCode().equals(sysCode)){
|
||||||
//检测业务系统
|
//检测业务系统
|
||||||
|
dataFrom = SystemEnum.INSPECTION.getDataFrom();
|
||||||
}else if(SystemEnum.SCHOOL.getCode().equals(sysCode)){
|
}else if(SystemEnum.SCHOOL.getCode().equals(sysCode)){
|
||||||
//驾校业务系统
|
//驾校业务系统
|
||||||
|
dataFrom = SystemEnum.SCHOOL.getDataFrom();
|
||||||
}else if(SystemEnum.RESCUE.getCode().equals(sysCode)){
|
}else if(SystemEnum.RESCUE.getCode().equals(sysCode)){
|
||||||
//救援业务系统
|
//救援业务系统
|
||||||
|
dataFrom = SystemEnum.RESCUE.getDataFrom();
|
||||||
}else if(SystemEnum.INSURE.getCode().equals(sysCode)){
|
}else if(SystemEnum.INSURE.getCode().equals(sysCode)){
|
||||||
//保险业务系统
|
//保险业务系统
|
||||||
|
dataFrom = SystemEnum.INSURE.getDataFrom();
|
||||||
}else {
|
}else {
|
||||||
//默认维修业务
|
//默认维修业务
|
||||||
user.setRepairOpenId(openId);
|
user.setRepairOpenId(openId);
|
||||||
|
dataFrom = SystemEnum.REPAIR.getDataFrom();
|
||||||
}
|
}
|
||||||
if(null!=user.getId()){
|
if(null!=user.getId()){
|
||||||
//更新
|
//更新
|
||||||
@ -167,7 +174,7 @@ public class WechatServiceImpl implements WechatService {
|
|||||||
/*如果携带了邀请码,需要插入邀请记录并自动复制用户信息到邀请者的租户下 */
|
/*如果携带了邀请码,需要插入邀请记录并自动复制用户信息到邀请者的租户下 */
|
||||||
if(!StringUtils.isEmpty(inviteId)){
|
if(!StringUtils.isEmpty(inviteId)){
|
||||||
//邀请注册,自动注册客户信息
|
//邀请注册,自动注册客户信息
|
||||||
companyStaffService.createPromotion(inviteId,wxUser, PromotionEnum.WeChat.getCode(), new Date());
|
companyStaffService.createPromotion(dataFrom,inviteId,wxUser, PromotionEnum.WeChat.getCode(), new Date());
|
||||||
}
|
}
|
||||||
return wxUser;
|
return wxUser;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user