|
@@ -29,6 +29,9 @@ import com.yc.ship.module.ota.dal.mysql.distributor.DistributorMapper;
|
|
|
import com.yc.ship.module.ota.enums.DistributorTypeEnum;
|
|
|
import com.yc.ship.module.ota.service.distributorauditlog.DistributorAuditLogService;
|
|
|
import com.yc.ship.module.ota.service.distributortype.DistributorTypeService;
|
|
|
+import com.yc.ship.module.system.api.permission.PermissionApi;
|
|
|
+import com.yc.ship.module.system.api.user.AdminUserApi;
|
|
|
+import com.yc.ship.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.redisson.api.RLock;
|
|
|
import org.redisson.api.RedissonClient;
|
|
@@ -68,6 +71,12 @@ public class DistributorServiceImpl implements DistributorService {
|
|
|
@Resource
|
|
|
private DistributorMapper distributorMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private AdminUserApi adminUserApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PermissionApi permissionApi;
|
|
|
+
|
|
|
|
|
|
@Resource
|
|
|
private DistributorTypeService distributorTypeService;
|
|
@@ -118,23 +127,24 @@ public class DistributorServiceImpl implements DistributorService {
|
|
|
if (createReqVO.getType() == 2) {
|
|
|
//若为旅行社,则创建新租户
|
|
|
try {
|
|
|
- tenantId = createSystemTenant(createReqVO);
|
|
|
- //创建默认seller角色菜单,内部为118套餐,外部为119套餐
|
|
|
- createSystemTenantRoleMenu(tenantId,createReqVO.getSelfSupport() == 1?118L:119L);
|
|
|
- //创建默认门店、设备
|
|
|
- createDefaultStore(tenantId);
|
|
|
+ Long userId = createSystemUser(createReqVO);
|
|
|
+ if (userId==null) {
|
|
|
+ throw exception(OTA_TENANT_EXISTS);
|
|
|
+ } else {
|
|
|
+ //创建分销商默认绑定分销商角色
|
|
|
+ createSystemUserRole(userId, "otc");
|
|
|
+
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
throw exception(DISTRIBUTOR_TENANT_EXISTS);
|
|
|
}
|
|
|
} else {
|
|
|
- //创建用户
|
|
|
- CommonResult<Long> result = createSystemUser(createReqVO);
|
|
|
- if (result.getCode() == 400) {
|
|
|
+ Long userId = createSystemUser(createReqVO);
|
|
|
+ if (userId==null) {
|
|
|
throw exception(OTA_TENANT_EXISTS);
|
|
|
} else {
|
|
|
//创建分销商默认绑定分销商角色
|
|
|
- Long userId = result.getData();
|
|
|
- createSystemUserRole(userId, "otaSystem");
|
|
|
+ createSystemUserRole(userId, "ota");
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -209,17 +219,6 @@ public class DistributorServiceImpl implements DistributorService {
|
|
|
updateObj.setTeamType("");
|
|
|
}
|
|
|
//修改租户套餐
|
|
|
-// TenantDTO reqDTO = new TenantDTO();
|
|
|
-// DistributorDO distributor = distributorMapper.selectById(updateReqVO.getId());
|
|
|
-// reqDTO.setId(distributor.getAccountTenantId());
|
|
|
-// if(distributor.getType()!=null && distributor.getType()==2) {
|
|
|
-// if (updateReqVO.getSelfSupport() == 1) {
|
|
|
-// reqDTO.setPackageId(112L);
|
|
|
-// } else {
|
|
|
-// reqDTO.setPackageId(113L);
|
|
|
-// }
|
|
|
-// tenantApi.updateTenantPackage(reqDTO);
|
|
|
-// }
|
|
|
//修改信息
|
|
|
distributorMapper.updateById(updateObj);
|
|
|
}
|
|
@@ -415,23 +414,17 @@ public class DistributorServiceImpl implements DistributorService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- CommonResult<Long> createSystemUser(DistributorSaveReqVO createReqVO) {
|
|
|
-// AdminUserSaveReqDTO reqDTO = new AdminUserSaveReqDTO();
|
|
|
-// reqDTO.setUsername(createReqVO.getLoginName());
|
|
|
-// reqDTO.setPassword(createReqVO.getPassword());
|
|
|
-// String nickName = createReqVO.getContactPerson();
|
|
|
-// if (StringUtils.isBlank(nickName)) {
|
|
|
-// nickName = createReqVO.getName();
|
|
|
-// }
|
|
|
-// reqDTO.setNickname(nickName);
|
|
|
-// return adminUserApi.createUser(reqDTO);
|
|
|
- return null;
|
|
|
+ Long createSystemUser(DistributorSaveReqVO createReqVO) {
|
|
|
+ AdminUserRespDTO reqDTO = new AdminUserRespDTO();
|
|
|
+ reqDTO.setUsername(createReqVO.getLoginName());
|
|
|
+ reqDTO.setPassword(createReqVO.getPassword());
|
|
|
+ reqDTO.setNickname(createReqVO.getName());
|
|
|
+ return adminUserApi.createUser(reqDTO);
|
|
|
}
|
|
|
|
|
|
//OTA用户默认绑定角色
|
|
|
- CommonResult<Long> createSystemUserRole(Long userId, String code) {
|
|
|
-// return adminUserApi.createSystemUserRole(userId, code);
|
|
|
- return null;
|
|
|
+ void createSystemUserRole(Long userId, String code) {
|
|
|
+ permissionApi.savePermissions(userId, code);
|
|
|
}
|
|
|
|
|
|
void updateSystemUserPassword(DistributorUpdatePasswordReqVO updateReqVO) {
|