|
|
@@ -11,8 +11,12 @@ import cn.hutool.crypto.digest.BCrypt;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.dromara.common.core.enums.UserType;
|
|
|
+import org.dromara.common.platform.Platform;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
+import org.dromara.common.tenant.helper.TenantHelper;
|
|
|
import org.dromara.system.api.RemoteUserService;
|
|
|
+import org.dromara.system.api.domain.bo.RemoteUserBo;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.dromara.fulfiller.domain.FlfFulfiller;
|
|
|
@@ -121,7 +125,27 @@ public class FlfFulfillerServiceImpl implements IFlfFulfillerService {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean insertByBo(FlfFulfillerBo bo) {
|
|
|
+ // 1. 先创建 sys_user 账号(用于App登录)
|
|
|
+ RemoteUserBo userBo = new RemoteUserBo();
|
|
|
+ userBo.setUserName(bo.getPhone());
|
|
|
+ userBo.setNickName(bo.getName());
|
|
|
+ // 密码需要BCrypt加密
|
|
|
+ String encryptedPwd = StringUtils.isNotBlank(bo.getPassword())
|
|
|
+ ? BCrypt.hashpw(bo.getPassword())
|
|
|
+ : BCrypt.hashpw("123456"); // 默认密码
|
|
|
+ userBo.setPassword(encryptedPwd);
|
|
|
+ userBo.setPhonenumber(bo.getPhone());
|
|
|
+ userBo.setSex(bo.getGender());
|
|
|
+ userBo.setUserType(UserType.FULFILLER_USER.getUserType());
|
|
|
+ userBo.setPlatformId(Platform.FULFILLER.getId());
|
|
|
+ userBo.setStatus("0");
|
|
|
+ userBo.setTenantId(TenantHelper.getTenantId());
|
|
|
+ Long sysUserId = remoteUserService.createUser(userBo);
|
|
|
+
|
|
|
+ // 2. 创建 flf_fulfiller 记录并关联 userId
|
|
|
FlfFulfiller add = MapstructUtils.convert(bo, FlfFulfiller.class);
|
|
|
+ add.setUserId(sysUserId);
|
|
|
+ add.setPassword(encryptedPwd);
|
|
|
validEntityBeforeSave(add);
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|