|  | @@ -1,6 +1,7 @@
 | 
											
												
													
														|  |  package com.fs.company.controller.company;
 |  |  package com.fs.company.controller.company;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import cn.hutool.core.util.ObjectUtil;
 |  |  import cn.hutool.core.util.ObjectUtil;
 | 
											
												
													
														|  | 
 |  | +import cn.hutool.http.HttpRequest;
 | 
											
												
													
														|  |  import cn.hutool.json.JSONUtil;
 |  |  import cn.hutool.json.JSONUtil;
 | 
											
												
													
														|  |  import com.baidu.dev2.thirdparty.jackson.databind.ObjectMapper;
 |  |  import com.baidu.dev2.thirdparty.jackson.databind.ObjectMapper;
 | 
											
												
													
														|  |  import com.fs.common.annotation.Log;
 |  |  import com.fs.common.annotation.Log;
 | 
											
										
											
												
													
														|  | @@ -21,6 +22,7 @@ import com.fs.company.param.CompanyUserCodeParam;
 | 
											
												
													
														|  |  import com.fs.company.param.CompanyUserQwParam;
 |  |  import com.fs.company.param.CompanyUserQwParam;
 | 
											
												
													
														|  |  import com.fs.company.service.*;
 |  |  import com.fs.company.service.*;
 | 
											
												
													
														|  |  import com.fs.company.utils.DomainUtil;
 |  |  import com.fs.company.utils.DomainUtil;
 | 
											
												
													
														|  | 
 |  | +import com.fs.company.vo.CompanyUserImportVO;
 | 
											
												
													
														|  |  import com.fs.company.vo.CompanyUserQwListVO;
 |  |  import com.fs.company.vo.CompanyUserQwListVO;
 | 
											
												
													
														|  |  import com.fs.company.vo.CompanyUserVO;
 |  |  import com.fs.company.vo.CompanyUserVO;
 | 
											
												
													
														|  |  import com.fs.course.config.CourseConfig;
 |  |  import com.fs.course.config.CourseConfig;
 | 
											
										
											
												
													
														|  | @@ -29,6 +31,8 @@ import com.fs.framework.security.SecurityUtils;
 | 
											
												
													
														|  |  import com.fs.framework.service.TokenService;
 |  |  import com.fs.framework.service.TokenService;
 | 
											
												
													
														|  |  import com.fs.his.utils.qrcode.QRCodeUtils;
 |  |  import com.fs.his.utils.qrcode.QRCodeUtils;
 | 
											
												
													
														|  |  import com.fs.his.vo.OptionsVO;
 |  |  import com.fs.his.vo.OptionsVO;
 | 
											
												
													
														|  | 
 |  | +import com.fs.hisStore.vo.FsStoreProductExportVO;
 | 
											
												
													
														|  | 
 |  | +import com.fs.im.service.OpenIMService;
 | 
											
												
													
														|  |  import com.fs.qw.domain.QwCompany;
 |  |  import com.fs.qw.domain.QwCompany;
 | 
											
												
													
														|  |  import com.fs.qw.service.IQwCompanyService;
 |  |  import com.fs.qw.service.IQwCompanyService;
 | 
											
												
													
														|  |  import com.fs.qw.vo.CompanyUserQwVO;
 |  |  import com.fs.qw.vo.CompanyUserQwVO;
 | 
											
										
											
												
													
														|  | @@ -37,6 +41,9 @@ import com.fs.system.service.ISysConfigService;
 | 
											
												
													
														|  |  import com.fs.voice.utils.StringUtil;
 |  |  import com.fs.voice.utils.StringUtil;
 | 
											
												
													
														|  |  import com.github.pagehelper.PageHelper;
 |  |  import com.github.pagehelper.PageHelper;
 | 
											
												
													
														|  |  import com.github.pagehelper.PageInfo;
 |  |  import com.github.pagehelper.PageInfo;
 | 
											
												
													
														|  | 
 |  | +import io.swagger.annotations.ApiOperation;
 | 
											
												
													
														|  | 
 |  | +import org.json.JSONArray;
 | 
											
												
													
														|  | 
 |  | +import org.json.JSONObject;
 | 
											
												
													
														|  |  import org.springframework.beans.factory.annotation.Autowired;
 |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
											
												
													
														|  |  import org.springframework.security.access.prepost.PreAuthorize;
 |  |  import org.springframework.security.access.prepost.PreAuthorize;
 | 
											
												
													
														|  |  import org.springframework.validation.annotation.Validated;
 |  |  import org.springframework.validation.annotation.Validated;
 | 
											
										
											
												
													
														|  | @@ -78,7 +85,8 @@ public class CompanyUserController extends BaseController
 | 
											
												
													
														|  |      private ISysConfigService configService;
 |  |      private ISysConfigService configService;
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private RedisCache redisCache;
 |  |      private RedisCache redisCache;
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    private OpenIMService openIMService;
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      IQwCompanyService iQwCompanyService;
 |  |      IQwCompanyService iQwCompanyService;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -133,7 +141,7 @@ public class CompanyUserController extends BaseController
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          return getDataTable(list);
 |  |          return getDataTable(list);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    @Log(title = "用户管理", businessType = BusinessType.EXPORT)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    @Log(title = "用户管理导出", businessType = BusinessType.EXPORT)
 | 
											
												
													
														|  |      @PreAuthorize("@ss.hasPermi('company:user:export')")
 |  |      @PreAuthorize("@ss.hasPermi('company:user:export')")
 | 
											
												
													
														|  |      @GetMapping("/export")
 |  |      @GetMapping("/export")
 | 
											
												
													
														|  |      public AjaxResult export(CompanyUser user)
 |  |      public AjaxResult export(CompanyUser user)
 | 
											
										
											
												
													
														|  | @@ -146,6 +154,26 @@ public class CompanyUserController extends BaseController
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    @Log(title = "销售信息导入", businessType = BusinessType.IMPORT,isStoreLog = true,logParam = {"销售","信息导入"})
 | 
											
												
													
														|  | 
 |  | +    @PreAuthorize("@ss.hasPermi('company:user:import')")
 | 
											
												
													
														|  | 
 |  | +    @PostMapping("/importCompanyUser")
 | 
											
												
													
														|  | 
 |  | +    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
 | 
											
												
													
														|  | 
 |  | +    {
 | 
											
												
													
														|  | 
 |  | +        ExcelUtil<CompanyUserImportVO> util = new ExcelUtil<>(CompanyUserImportVO.class);
 | 
											
												
													
														|  | 
 |  | +        List<CompanyUserImportVO> list = util.importExcel(file.getInputStream());
 | 
											
												
													
														|  | 
 |  | +        String message = companyUserService.importCompanyUser(list, updateSupport);
 | 
											
												
													
														|  | 
 |  | +        return AjaxResult.success(message);
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @GetMapping("/importTemplate")
 | 
											
												
													
														|  | 
 |  | +    public AjaxResult importTemplate()
 | 
											
												
													
														|  | 
 |  | +    {
 | 
											
												
													
														|  | 
 |  | +        ExcelUtil<CompanyUserImportVO> util = new ExcelUtil<>(CompanyUserImportVO.class);
 | 
											
												
													
														|  | 
 |  | +        return util.importTemplateExcel("销售数据");
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      /**
 |  |      /**
 | 
											
												
													
														|  |       * 根据用户编号获取详细信息
 |  |       * 根据用户编号获取详细信息
 | 
											
										
											
												
													
														|  | @@ -255,7 +283,7 @@ public class CompanyUserController extends BaseController
 | 
											
												
													
														|  |          String encodedStatus = URLEncoder.encode(status, StandardCharsets.UTF_8.toString());
 |  |          String encodedStatus = URLEncoder.encode(status, StandardCharsets.UTF_8.toString());
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          String url="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+user.getCorpId()+"&redirect_uri=" +
 |  |          String url="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+user.getCorpId()+"&redirect_uri=" +
 | 
											
												
													
														|  | -                "http://"+qwCompany.getRealmNameUrl()+"/qwh5/pages/user/index?corpId="+user.getCorpId() +
 |  | 
 | 
											
												
													
														|  | 
 |  | +                "http://"+qwCompany.getRealmNameUrl()+"/loginqw/pages/companyLogin/index?corpId="+user.getCorpId() +
 | 
											
												
													
														|  |                  "&response_type=code&scope=snsapi_base&state="+encodedStatus+"&agentid="+qwCompany.getServerAgentId()+"#wechat_redirect";
 |  |                  "&response_type=code&scope=snsapi_base&state="+encodedStatus+"&agentid="+qwCompany.getServerAgentId()+"#wechat_redirect";
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          R andUpload = QRCodeUtils.createAndUpload(url);
 |  |          R andUpload = QRCodeUtils.createAndUpload(url);
 | 
											
										
											
												
													
														|  | @@ -536,4 +564,72 @@ public class CompanyUserController extends BaseController
 | 
											
												
													
														|  |      public R unBindDoctorId(@RequestBody CompanyUser companyUser){
 |  |      public R unBindDoctorId(@RequestBody CompanyUser companyUser){
 | 
											
												
													
														|  |          return companyUserService.bindDoctor(companyUser);
 |  |          return companyUserService.bindDoctor(companyUser);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @ApiOperation("校验客服是否注册新的im")
 | 
											
												
													
														|  | 
 |  | +    @PostMapping("/accountCheck")
 | 
											
												
													
														|  | 
 |  | +    public R accountCheck(@RequestBody Map<String, String> userIdMap){
 | 
											
												
													
														|  | 
 |  | +        //获取管理员token
 | 
											
												
													
														|  | 
 |  | +        String userId = userIdMap.get("userId");
 | 
											
												
													
														|  | 
 |  | +        String adminToken = openIMService.getAdminToken();
 | 
											
												
													
														|  | 
 |  | +        JSONObject requestBody = new JSONObject();
 | 
											
												
													
														|  | 
 |  | +        // 解析响应
 | 
											
												
													
														|  | 
 |  | +        if (StringUtils.isNotEmpty(adminToken)) {
 | 
											
												
													
														|  | 
 |  | +            //查询用户是否注册
 | 
											
												
													
														|  | 
 |  | +            ArrayList<String> userIds = new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +            requestBody = new JSONObject();
 | 
											
												
													
														|  | 
 |  | +            userIds.add(userId);
 | 
											
												
													
														|  | 
 |  | +            requestBody.put("checkUserIDs", userIds);
 | 
											
												
													
														|  | 
 |  | +            String body = HttpRequest.post("https://web.im.cdwjyyh.com/api/user/account_check")
 | 
											
												
													
														|  | 
 |  | +                    .header("operationID", String.valueOf(System.currentTimeMillis()))
 | 
											
												
													
														|  | 
 |  | +                    .header("token", adminToken)
 | 
											
												
													
														|  | 
 |  | +                    .body(requestBody.toString())
 | 
											
												
													
														|  | 
 |  | +                    .execute()
 | 
											
												
													
														|  | 
 |  | +                    .body();
 | 
											
												
													
														|  | 
 |  | +            JSONObject jsonObject = new JSONObject(body);
 | 
											
												
													
														|  | 
 |  | +            JSONArray results = jsonObject.getJSONObject("data").getJSONArray("results");
 | 
											
												
													
														|  | 
 |  | +            if (results != null && results.length() > 0) {
 | 
											
												
													
														|  | 
 |  | +                JSONObject resultObj = results.getJSONObject(0);
 | 
											
												
													
														|  | 
 |  | +                int accountStatus = resultObj.getInt("accountStatus");
 | 
											
												
													
														|  | 
 |  | +                //未注册自动注册
 | 
											
												
													
														|  | 
 |  | +                if (accountStatus==0){
 | 
											
												
													
														|  | 
 |  | +                    String s = userId.replaceFirst("^C", "");
 | 
											
												
													
														|  | 
 |  | +                    CompanyUser companyUser = companyUserService.selectCompanyUserById(Long.parseLong(s));
 | 
											
												
													
														|  | 
 |  | +                    if (null==companyUser){
 | 
											
												
													
														|  | 
 |  | +                        return R.error("用户不存在");
 | 
											
												
													
														|  | 
 |  | +                    }
 | 
											
												
													
														|  | 
 |  | +                    ArrayList<Object> users = new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +                    HashMap<String, String> map = new HashMap<>();
 | 
											
												
													
														|  | 
 |  | +                    map.put("userID",userId);
 | 
											
												
													
														|  | 
 |  | +                    map.put("nickname",companyUser.getImNickName());
 | 
											
												
													
														|  | 
 |  | +                    map.put("faceURL",companyUser.getAvatar());
 | 
											
												
													
														|  | 
 |  | +                    users.add(map);
 | 
											
												
													
														|  | 
 |  | +                    requestBody = new JSONObject();
 | 
											
												
													
														|  | 
 |  | +                    userIds.add(userId);
 | 
											
												
													
														|  | 
 |  | +                    requestBody.put("users", users);
 | 
											
												
													
														|  | 
 |  | +                    HttpRequest.post("https://web.im.cdwjyyh.com/api/user/user_register")
 | 
											
												
													
														|  | 
 |  | +                            .header("operationID", String.valueOf(System.currentTimeMillis()))
 | 
											
												
													
														|  | 
 |  | +                            .header("token", adminToken).body(requestBody.toString()).execute().body();
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +            } else {
 | 
											
												
													
														|  | 
 |  | +                return R.error("返回结果为空");
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +           /* HashMap<String, String> tokenMap = new HashMap<>();
 | 
											
												
													
														|  | 
 |  | +            tokenMap.put("platformID","1");
 | 
											
												
													
														|  | 
 |  | +            tokenMap.put("userID",userId);*/
 | 
											
												
													
														|  | 
 |  | +            requestBody = new JSONObject();
 | 
											
												
													
														|  | 
 |  | +            requestBody.put("platformID",5);
 | 
											
												
													
														|  | 
 |  | +            requestBody.put("userID",userId);
 | 
											
												
													
														|  | 
 |  | +            String body1 = HttpRequest.post("https://web.im.cdwjyyh.com/api/auth/get_user_token")
 | 
											
												
													
														|  | 
 |  | +                    .header("operationID", String.valueOf(System.currentTimeMillis()))
 | 
											
												
													
														|  | 
 |  | +                    .header("token", adminToken)
 | 
											
												
													
														|  | 
 |  | +                    .body(requestBody.toString()).execute().body();
 | 
											
												
													
														|  | 
 |  | +            JSONObject userJson = new JSONObject(body1);
 | 
											
												
													
														|  | 
 |  | +            JSONObject userData = userJson.getJSONObject("data");
 | 
											
												
													
														|  | 
 |  | +            String userToken = userData.getString("token");
 | 
											
												
													
														|  | 
 |  | +            return R.ok().put("token", userToken);
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            return R.error("获取管理员token失败");
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  }
 |  |  }
 |