|
|
@@ -6,9 +6,7 @@ import com.uas.platform.b2c.common.account.model.*;
|
|
|
import com.uas.platform.b2c.common.account.service.UserService;
|
|
|
import com.uas.platform.b2c.core.config.MessageConf;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
-import com.uas.platform.b2c.core.utils.ThreadUtils;
|
|
|
import com.uas.platform.b2c.trade.util.BoundedExecutor;
|
|
|
-import com.uas.platform.core.concurrent.IRunnable;
|
|
|
import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.exception.SystemException;
|
|
|
import com.uas.platform.core.model.PageInfo;
|
|
|
@@ -16,6 +14,7 @@ import com.uas.platform.core.model.PageParams;
|
|
|
import com.uas.platform.core.util.AgentUtils;
|
|
|
import com.uas.platform.core.util.encry.Md5Utils;
|
|
|
import com.uas.sso.entity.UserView;
|
|
|
+import com.uas.sso.util.AccountUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
@@ -24,7 +23,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
-import com.uas.sso.util.AccountUtils;
|
|
|
+
|
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
@@ -77,6 +76,13 @@ public class UserServiceImpl implements UserService {
|
|
|
@Autowired
|
|
|
private UserLoginTimeDao userLoginTimeDao;
|
|
|
|
|
|
+ private BoundedExecutor executor;
|
|
|
+
|
|
|
+ {
|
|
|
+ ExecutorService executorService = Executors.newCachedThreadPool();
|
|
|
+ executor = new BoundedExecutor(executorService, 1000);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public User findUserByUserUU(Long uu) {
|
|
|
List<User> users = userDao.findUserByUserUU(uu);
|
|
|
@@ -201,10 +207,17 @@ public class UserServiceImpl implements UserService {
|
|
|
enterpriseDao.callInitProcedure(SystemSession.getUser().getEnterprise().getUu());
|
|
|
}
|
|
|
userDao.save(user);
|
|
|
+ Enterprise enterprise = SystemSession.getUser().getEnterprise();
|
|
|
+
|
|
|
+ //判断是否个人用户
|
|
|
+ if(enterprise == null){
|
|
|
+ throw new RuntimeException("个人账户不能新增企业用户");
|
|
|
+ }
|
|
|
+ // 同步账户中心
|
|
|
try {
|
|
|
- postToAccountCenter(user);
|
|
|
+ postToAccountCenter(user, enterprise);
|
|
|
} catch (Exception e) {
|
|
|
- throw new SystemException(e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
@Override
|
|
|
@@ -278,8 +291,16 @@ public class UserServiceImpl implements UserService {
|
|
|
userOld.setUserEmail(user.getUserEmail());
|
|
|
userOld.setUserTel(user.getUserTel());
|
|
|
userOld.setUserName(user.getUserName());
|
|
|
+
|
|
|
+ Enterprise enterprise = SystemSession.getUser().getEnterprise();
|
|
|
+
|
|
|
+ //判断是否个人用户
|
|
|
+ if(enterprise == null){
|
|
|
+ throw new RuntimeException("个人账户不能新增企业用户");
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
- postToAccountCenter(userOld);
|
|
|
+ postToAccountCenter(userOld, enterprise);
|
|
|
} catch (Exception e) {
|
|
|
// throw new RuntimeException(e.getMessage());
|
|
|
}
|
|
|
@@ -415,12 +436,21 @@ public class UserServiceImpl implements UserService {
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
- public void postToAccountCenter(User user) throws Exception {
|
|
|
- //判断是否个人用户
|
|
|
- if(SystemSession.getUser().getEnterprise()==null){
|
|
|
- throw new RuntimeException("个人账户不能新增企业用户");
|
|
|
- }else{
|
|
|
- AccountUtils.addUser(user.getUserUU(),SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ public void postToAccountCenter(final User user, final Enterprise enterprise) throws Exception {
|
|
|
+ // 同步账户中心
|
|
|
+ try {
|
|
|
+ executor.submitTask(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ AccountUtils.addUser(user.getUserUU(),enterprise.getUu());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new SystemException(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@Override
|
|
|
@@ -432,9 +462,6 @@ public class UserServiceImpl implements UserService {
|
|
|
userDao.flush();
|
|
|
final Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
// 同步账户中心
|
|
|
- ExecutorService executorService = Executors.newCachedThreadPool();
|
|
|
- BoundedExecutor executor = new BoundedExecutor(executorService, 1000);
|
|
|
-
|
|
|
try {
|
|
|
executor.submitTask(new Runnable() {
|
|
|
@Override
|