|
|
@@ -279,63 +279,47 @@ public class SysUserOrderAuthorServiceImpl implements ISysUserOrderAuthorService
|
|
|
|
|
|
@Override
|
|
|
public void initUserAuthor() {
|
|
|
- List<SysUserOrderAuthor> userOrderAuthorList=new ArrayList<>();
|
|
|
- List<SysUserOrderAuthor> userOrderAuthorDiyList=sysUserOrderAuthorMapper.selectAuthorIdByCode("tuc_diy");
|
|
|
- List<SysUserOrderAuthor> userOrderAuthorCwList=sysUserOrderAuthorMapper.selectAuthorIdByCode("tuc_cw");
|
|
|
- List<SysUserOrderAuthor> userOrderAuthorYSLList=sysUserOrderAuthorMapper.selectAuthorIdByCode("YSL");
|
|
|
+ List<SysUserOrderAuthor> userOrderAuthorList = new ArrayList<>();
|
|
|
+ List<SysUserOrderAuthor> userOrderAuthorDiyList = sysUserOrderAuthorMapper.selectAuthorIdByCode("tuc_diy");
|
|
|
+ List<SysUserOrderAuthor> userOrderAuthorCwList = sysUserOrderAuthorMapper.selectAuthorIdByCode("tuc_cw");
|
|
|
+ List<SysUserOrderAuthor> userOrderAuthorYSLList = sysUserOrderAuthorMapper.selectAuthorIdByCode("YSL");
|
|
|
userExtMapper.selectUserExtList().forEach(sysUserExt -> {
|
|
|
- String sales=sysUserExt.getSalesLevel();
|
|
|
- if(sales==null){
|
|
|
- sales="diy_level";
|
|
|
+ String sales = sysUserExt.getSalesLevel();
|
|
|
+ if (sales == null) {
|
|
|
+ sales = "diy_level";
|
|
|
}
|
|
|
int index = sales.indexOf("_");
|
|
|
- String intNumber = sales.substring(0,index);
|
|
|
- if(intNumber.equals("cw")){
|
|
|
+ String intNumber = sales.substring(0, index);
|
|
|
+ if (intNumber.equals("cw")) {
|
|
|
+ userOrderAuthorList.clear();
|
|
|
userOrderAuthorList.addAll(userOrderAuthorCwList);
|
|
|
- }else if(intNumber.equals("diy")){
|
|
|
+ } else if (intNumber.equals("diy")) {
|
|
|
+ userOrderAuthorList.clear();
|
|
|
userOrderAuthorList.addAll(userOrderAuthorDiyList);
|
|
|
- }else if(intNumber.equals("ysl")){
|
|
|
+ } else if (intNumber.equals("ysl")) {
|
|
|
+ userOrderAuthorList.clear();
|
|
|
userOrderAuthorList.addAll(userOrderAuthorYSLList);
|
|
|
}
|
|
|
- List<SysUserOrderAuthor> ordList=new ArrayList<>();
|
|
|
- for (int i = 0; i < userOrderAuthorList.size(); i++) {
|
|
|
- if( !userOrderAuthorList.get(i).getAuthorId().equals(userOrderAuthorList.get(0).getParentId())){
|
|
|
- if(i==0){
|
|
|
- List<SysUserAuthorRel> user=userAuthorRelMapper.selectSysUserAuthorRelListById(sysUserExt.getUserId());
|
|
|
- if(user.size()>0){
|
|
|
- break;
|
|
|
- }
|
|
|
- SysUserOrderAuthor userOrderAuthor=new SysUserOrderAuthor();
|
|
|
- userOrderAuthor.setAuthorId(userOrderAuthorList.get(0).getParentId());
|
|
|
- userOrderAuthor.setParentId(userOrderAuthorList.get(0).getParentId());
|
|
|
- ordList.add(userOrderAuthor);
|
|
|
- ordList.removeAll(userOrderAuthorList);
|
|
|
- ordList.addAll(userOrderAuthorList);
|
|
|
- }
|
|
|
-
|
|
|
- List<SysUserOrderAuthor> OrderAuthorList= sysUserOrderAuthorMapper.selectAuthorIdByParentId(userOrderAuthorList.get(i).getAuthorId());
|
|
|
- if(OrderAuthorList.size()>0){
|
|
|
- HashSet<SysUserOrderAuthor> set = new HashSet<>(ordList);
|
|
|
- ordList.clear();
|
|
|
- set.addAll(OrderAuthorList);
|
|
|
- ArrayList list=new ArrayList<>(set);
|
|
|
- ordList.addAll(list);
|
|
|
- }
|
|
|
- }else{
|
|
|
- continue;
|
|
|
+ List<SysUserAuthorRel> user = userAuthorRelMapper.selectSysUserAuthorRelListById(sysUserExt.getUserId());
|
|
|
+ if (user.size() == 0) {
|
|
|
+ SysUserAuthorRel role = new SysUserAuthorRel();
|
|
|
+ role.setUserId(sysUserExt.getUserId());
|
|
|
+ role.setAuthorId(userOrderAuthorList.get(0).getParentId());
|
|
|
+ userAuthorRelMapper.insertSysUserAuthorRel(role);
|
|
|
+ List<SysUserOrderAuthor> OrderAuthorList = sysUserOrderAuthorMapper.selectAuthorIdByParentId(userOrderAuthorList.get(0).getParentId());
|
|
|
+ if (OrderAuthorList.size() > 0) {
|
|
|
+ for (SysUserOrderAuthor sys : OrderAuthorList
|
|
|
+ ) {
|
|
|
+ SysUserAuthorRel roleUser = new SysUserAuthorRel();
|
|
|
+ roleUser.setUserId(sysUserExt.getUserId());
|
|
|
+ roleUser.setAuthorId(sys.getAuthorId());
|
|
|
+ userAuthorRelMapper.insertSysUserAuthorRel(roleUser);
|
|
|
}
|
|
|
}
|
|
|
- if(ordList.size()>0){
|
|
|
- ordList.forEach(author->{
|
|
|
- SysUserAuthorRel role=new SysUserAuthorRel();
|
|
|
- role.setUserId(sysUserExt.getUserId());
|
|
|
- role.setAuthorId(author.getAuthorId());
|
|
|
- userAuthorRelMapper.insertSysUserAuthorRel(role);
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
});
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
+
|