Kaynağa Gözat

Merge remote-tracking branch 'origin/master'

zyp 1 hafta önce
ebeveyn
işleme
2578bccd17
27 değiştirilmiş dosya ile 1146 ekleme ve 17 silme
  1. 138 0
      fs-admin/src/main/java/com/fs/qw/controller/QwExternalContactController.java
  2. 41 0
      fs-admin/src/main/java/com/fs/qw/controller/QwTagGroupController.java
  3. 10 0
      fs-admin/src/main/java/com/fs/qw/controller/QwUserController.java
  4. 39 0
      fs-qwhook-sop/src/main/java/com/fs/app/controller/QwStatisticsController.java
  5. 69 0
      fs-qwhook-sop/src/main/java/com/fs/app/controller/QwUserController.java
  6. 92 0
      fs-qwhook-sop/src/main/java/com/fs/app/controller/QwWorkTaskController.java
  7. 132 0
      fs-qwhook/src/main/java/com/fs/app/controller/ApisCommonController.java
  8. 39 0
      fs-qwhook/src/main/java/com/fs/app/controller/ApisQwStatisticsController.java
  9. 101 0
      fs-qwhook/src/main/java/com/fs/app/controller/ApisQwUserController.java
  10. 95 0
      fs-qwhook/src/main/java/com/fs/app/controller/ApisQwWorkTaskController.java
  11. 39 0
      fs-qwhook/src/main/java/com/fs/app/controller/QwStatisticsController.java
  12. 69 0
      fs-qwhook/src/main/java/com/fs/app/controller/QwUserController.java
  13. 92 0
      fs-qwhook/src/main/java/com/fs/app/controller/QwWorkTaskController.java
  14. 9 0
      fs-service/src/main/java/com/fs/company/domain/Company.java
  15. 42 7
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java
  16. 40 0
      fs-service/src/main/java/com/fs/his/domain/FsUserWx.java
  17. 7 0
      fs-service/src/main/java/com/fs/his/mapper/FsUserWxMapper.java
  18. 7 0
      fs-service/src/main/java/com/fs/his/service/IFsUserWxService.java
  19. 13 0
      fs-service/src/main/java/com/fs/his/service/impl/FsUserWxServiceImpl.java
  20. 1 0
      fs-service/src/main/java/com/fs/qw/mapper/QwExternalContactMapper.java
  21. 5 0
      fs-service/src/main/java/com/fs/qw/param/QwExternalContactParam.java
  22. 5 0
      fs-service/src/main/java/com/fs/qw/param/QwFsUserParam.java
  23. 7 0
      fs-service/src/main/java/com/fs/qw/service/IQwUserService.java
  24. 17 0
      fs-service/src/main/java/com/fs/qw/service/impl/QwUserServiceImpl.java
  25. 11 1
      fs-service/src/main/resources/mapper/company/CompanyMapper.xml
  26. 7 0
      fs-service/src/main/resources/mapper/his/FsUserWxMapper.xml
  27. 19 9
      fs-user-app/src/main/java/com/fs/app/controller/WxUserController.java

+ 138 - 0
fs-admin/src/main/java/com/fs/qw/controller/QwExternalContactController.java

@@ -0,0 +1,138 @@
+package com.fs.qw.controller;
+
+import java.util.List;
+import java.util.Objects;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.fs.common.exception.ServiceException;
+import com.fs.qw.param.QwExternalContactParam;
+import com.fs.qw.param.QwTagSearchParam;
+import com.fs.qw.service.IQwTagService;
+import com.fs.qw.vo.QwExternalContactVO;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.enums.BusinessType;
+import com.fs.qw.domain.QwExternalContact;
+import com.fs.qw.service.IQwExternalContactService;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.core.page.TableDataInfo;
+
+/**
+ * 企业微信客户Controller
+ * 
+ * @author fs
+ * @date 2025-06-13
+ */
+@RestController
+@RequestMapping("/qw/externalContact")
+public class QwExternalContactController extends BaseController
+{
+    private IQwExternalContactService qwExternalContactService;
+    private IQwTagService iQwTagService;
+
+    QwExternalContactController(IQwExternalContactService qwExternalContactService,IQwTagService iQwTagService){
+        this.qwExternalContactService=qwExternalContactService;
+        this.iQwTagService=iQwTagService;
+    }
+
+
+    /**
+     * 查询企业微信客户列表
+     */
+    @PreAuthorize("@ss.hasPermi('qw:externalContact:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(QwExternalContactParam qwExternalContact)
+    {
+        if(ObjectUtil.isEmpty(qwExternalContact.getCompanyId())){
+            throw new ServiceException("操作失败,请选择企业!");
+        }
+        startPage();
+        List<QwExternalContactVO> list = qwExternalContactService.selectQwExternalContactListVO(qwExternalContact);
+        list.forEach(item->{
+
+            if (!Objects.equals(item.getTagIds(), "[]") && item.getTagIds()!=null) {
+                QwTagSearchParam param = new QwTagSearchParam();
+                Gson gson = new Gson();
+                List<String> tagIds = gson.fromJson(
+                        item.getTagIds(),
+                        new TypeToken<List<String>>() {
+                        }.getType()
+                );
+
+                param.setTagIds(tagIds);
+
+                item.setTagIdsName(iQwTagService.selectQwTagListByTagIds(param));
+            }
+        });
+
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出企业微信客户列表
+     */
+    @PreAuthorize("@ss.hasPermi('qw:externalContact:export')")
+    @Log(title = "企业微信客户", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(QwExternalContact qwExternalContact)
+    {
+        List<QwExternalContact> list = qwExternalContactService.selectQwExternalContactList(qwExternalContact);
+        ExcelUtil<QwExternalContact> util = new ExcelUtil<QwExternalContact>(QwExternalContact.class);
+        return util.exportExcel(list, "企业微信客户数据");
+    }
+
+    /**
+     * 获取企业微信客户详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('qw:externalContact:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(qwExternalContactService.selectQwExternalContactById(id));
+    }
+
+    /**
+     * 新增企业微信客户
+     */
+    @PreAuthorize("@ss.hasPermi('qw:externalContact:add')")
+    @Log(title = "企业微信客户", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody QwExternalContact qwExternalContact)
+    {
+        return toAjax(qwExternalContactService.insertQwExternalContact(qwExternalContact));
+    }
+
+    /**
+     * 修改企业微信客户
+     */
+    @PreAuthorize("@ss.hasPermi('qw:externalContact:edit')")
+    @Log(title = "企业微信客户", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody QwExternalContact qwExternalContact)
+    {
+        return toAjax(qwExternalContactService.updateQwExternalContact(qwExternalContact));
+    }
+
+    /**
+     * 删除企业微信客户
+     */
+    @PreAuthorize("@ss.hasPermi('qw:externalContact:remove')")
+    @Log(title = "企业微信客户", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(qwExternalContactService.deleteQwExternalContactByIds(ids));
+    }
+}

+ 41 - 0
fs-admin/src/main/java/com/fs/qw/controller/QwTagGroupController.java

@@ -0,0 +1,41 @@
+package com.fs.qw.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.qw.domain.QwTagGroup;
+import com.fs.qw.service.IQwTagGroupService;
+import com.fs.qw.vo.QwTagGroupListVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 企微客户标签组Controller
+ *
+ * @author fs
+ * @date 2024-06-20
+ */
+@RestController
+@RequestMapping("/qw/tagGroup")
+public class QwTagGroupController extends BaseController
+{
+    @Autowired
+    private IQwTagGroupService qwTagGroupService;
+
+    @Autowired
+    private RedisTemplate redisTemplate;
+
+    /**
+    * 所有标签列表
+    */
+    @GetMapping("/allList")
+    public TableDataInfo allList(QwTagGroup qwTagGroup)
+    {
+        startPage();
+
+        List<QwTagGroupListVO> list = qwTagGroupService.selectQwTagGroupListVO(qwTagGroup);
+        return getDataTable(list);
+    }
+}

+ 10 - 0
fs-admin/src/main/java/com/fs/qw/controller/QwUserController.java

@@ -1,7 +1,9 @@
 package com.fs.qw.controller;
 
+import com.baomidou.mybatisplus.extension.api.R;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
+import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.service.IQwUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -24,4 +26,12 @@ public class QwUserController extends BaseController {
     public AjaxResult getQwUserAll(){
         return AjaxResult.success(qwUserService.getQwUserAll());
     }
+
+    /**
+     * 获取企微信息
+     * **/
+    @GetMapping("/getQwUserInfo")
+    public R getQwUserInfo(QwFsUserParam param){
+        return R.ok(qwUserService.getQwUserInfo(param));
+    }
 }

+ 39 - 0
fs-qwhook-sop/src/main/java/com/fs/app/controller/QwStatisticsController.java

@@ -0,0 +1,39 @@
+package com.fs.app.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.common.exception.CustomException;
+import com.fs.statistics.dto.WatchCourseStatisticsDTO;
+import com.fs.statistics.param.WatchCourseStatisticsParam;
+import com.fs.statistics.service.IStatisticsService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 企微统计数据
+ */
+@RestController
+@RequestMapping("/app/qw/statistics")
+public class QwStatisticsController extends BaseController {
+    @Autowired
+    private IStatisticsService statisticsService;
+
+
+//    @Login
+    @PostMapping("/course/watch")
+    @ApiOperation("会员看课详情")
+    public R queryCourseWatchStatistics(@RequestBody WatchCourseStatisticsParam param) {
+        if(param.getQwExternalContactId() == null) {
+            throw new CustomException("外部联系人id为空!");
+        }
+
+        WatchCourseStatisticsDTO watchCourseStatisticsDTO = statisticsService.queryWatchCourse(param);
+
+        return R.ok().put("data",watchCourseStatisticsDTO);
+    }
+
+}

+ 69 - 0
fs-qwhook-sop/src/main/java/com/fs/app/controller/QwUserController.java

@@ -0,0 +1,69 @@
+package com.fs.app.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.common.exception.CustomException;
+import com.fs.qw.domain.QwExternalContactInfo;
+import com.fs.qw.param.ExternalContactDetailsParam;
+import com.fs.qw.service.IQwExternalContactInfoService;
+import com.fs.qw.service.IQwExternalContactService;
+import com.fs.qw.vo.ExternalContactDetailsVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Slf4j
+@Api(tags = "企微会员相关接口")
+@RestController
+@RequestMapping("/app/qw/user")
+public class QwUserController extends BaseController {
+
+    @Autowired
+    private IQwExternalContactService qwExternalContactService;
+
+    @Autowired
+    private IQwExternalContactInfoService qwExternalContactInfoService;
+
+    @GetMapping("/details")
+    @ApiOperation("会员看课详情")
+    public R getUserDetails(@ApiParam(value = "外部联系人id", required = true) @RequestParam Long contactId,
+                            @ApiParam(value = "时间tab,不传表示查询全部,分别是:今天、昨天、前天、近七天", required = true) String dateTag) {
+        ExternalContactDetailsParam param = new ExternalContactDetailsParam();
+        param.setUserId(getUserId());
+        param.setContactId(contactId);
+        param.setDateTag(dateTag);
+        ExternalContactDetailsVO userDetails = qwExternalContactService.getUserDetails(param);
+        Map<String, Object> map = new HashMap<>();
+        map.put("userDetails", userDetails);
+        return R.ok(map);
+    }
+
+
+    @GetMapping("/getQwUserInfo")
+    @ApiOperation("获取企微用户信息")
+    public R getQwUserInfo(@RequestParam(value = "qwExternalContactId",required = false) Long qwExternalContactId){
+        if(qwExternalContactId == null) {
+            throw new CustomException("企微外部联系人id不能为空!");
+        }
+
+        QwExternalContactInfo qwExternalContactInfo = qwExternalContactInfoService.selectQwExternalContactInfoByExternalContactId(qwExternalContactId);
+        return R.ok().put("data",qwExternalContactService.selectQwExternalContactById(qwExternalContactId)).put("moreInfo",qwExternalContactInfo);
+    }
+
+    @PostMapping("/updateQwUserInfo")
+    @ApiOperation("更新企微用户信息")
+    public R updateQwUserInfo(@RequestBody QwExternalContactInfo qwExternalContactInfo){
+        if(qwExternalContactInfo.getExternalContactId() == null) {
+            throw new CustomException("企微外部联系人id不能为空!");
+        }
+        qwExternalContactInfoService.updateQwExternalContactInfoByExternalContactId(qwExternalContactInfo);
+        return R.ok();
+    }
+
+}

+ 92 - 0
fs-qwhook-sop/src/main/java/com/fs/app/controller/QwWorkTaskController.java

@@ -0,0 +1,92 @@
+package com.fs.app.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.company.service.ICompanyUserService;
+import com.fs.course.mapper.FsCourseWatchLogMapper;
+import com.fs.qw.domain.QwUser;
+import com.fs.qw.domain.QwWorkTask;
+import com.fs.qw.param.SelectQwWorkTaskListParam;
+import com.fs.qw.service.IQwExternalContactService;
+import com.fs.qw.service.IQwUserService;
+import com.fs.qw.service.IQwWorkTaskService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Slf4j
+@Api(tags = "企微任务看板接口")
+@RestController
+@RequestMapping("/app/qw/workTask")
+@AllArgsConstructor
+public class QwWorkTaskController extends BaseController {
+
+    private final IQwWorkTaskService qwWorkTaskService;
+    private final IQwUserService qwUserService;
+
+    @Autowired
+    ICompanyUserService companyUserService;
+
+    @Autowired
+    private FsCourseWatchLogMapper fsCourseWatchLogMapper;
+
+    @Autowired
+    private IQwExternalContactService qwExternalContactService;
+
+    @PostMapping("/list")
+    @ApiOperation("企微任务看板列表")
+    public R selectQwWorkTaskList(@RequestBody SelectQwWorkTaskListParam param) {
+
+        log.info("企微任务看板列表: {}",param);
+
+        QwUser qwUser = qwExternalContactService.getQwUserByRedis(param.getCorpId().trim(), param.getQwUserId().trim());
+
+        if (qwUser == null || qwUser.getCompanyId() == null) {
+            return R.error("员工未绑定 销售公司 或 未获取到员工信息,请重试!");
+        }
+
+        param.setUserId(qwUser.getId());
+
+        PageHelper.startPage(param.getPageNum(), param.getPageSize());
+        List<QwWorkTask> list = qwUserService.selectQwWorkTaskList(param);
+
+        for (QwWorkTask qwWorkTask : list) {
+            List<Integer> logs = fsCourseWatchLogMapper.selectFsCourseWatchLog7DayByExtId(qwWorkTask.getExtId());
+            qwWorkTask.setLogs(logs);
+        }
+
+        PageInfo<QwWorkTask> pageInfo = new PageInfo<>(list);
+        return R.ok().put("data",pageInfo);
+    }
+
+    /**
+     * 处理催课
+     */
+    @GetMapping("/updateWorkTaskStatus/{id}")
+    public R updateWorkTaskStatus(@PathVariable("id") Long id) {
+
+        try {
+            QwWorkTask qwWorkTask=new QwWorkTask();
+            qwWorkTask.setId(id);
+            qwWorkTask.setStatus(1);
+            int i = qwWorkTaskService.updateQwWorkTask(qwWorkTask);
+            if (i>0) {
+                return R.ok();
+            }else {
+                return R.error("更新失败,请重试!");
+            }
+        }catch (Exception e){
+            return R.error("更新失败,请重试!");
+        }
+    }
+
+
+
+}

+ 132 - 0
fs-qwhook/src/main/java/com/fs/app/controller/ApisCommonController.java

@@ -0,0 +1,132 @@
+package com.fs.app.controller;
+
+
+import com.fs.common.core.domain.R;
+import com.fs.common.core.redis.RedisCache;
+import com.fs.course.mapper.FsCourseWatchLogMapper;
+import com.fs.course.mapper.FsUserCourseVideoMapper;
+import com.fs.fastGpt.mapper.FastgptChatVoiceHomoMapper;
+import com.fs.his.domain.FsAppVersion;
+import com.fs.his.service.IFsAppVersionService;
+import com.fs.qw.domain.QwUser;
+import com.fs.qw.mapper.QwCompanyMapper;
+import com.fs.qw.mapper.QwExternalContactCrmMapper;
+import com.fs.qw.mapper.QwUserMapper;
+import com.fs.qw.param.QwConfigSignatureParam;
+import com.fs.qw.service.IQwJsApiService;
+import com.fs.qw.service.IQwUserService;
+import com.fs.qw.service.IQwUserVideoService;
+import com.fs.qw.vo.QwHookAuthVO;
+import com.fs.qwApi.param.QwExternalContactHParam;
+import com.fs.qwApi.service.QwApiService;
+import com.fs.qwHookApi.param.QwHookSendMsgParam;
+import com.fs.qwHookApi.service.QwHookApiService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+
+@Api("公共接口")
+@RestController
+@RequestMapping(value="/apis/app/common")
+@Slf4j
+public class ApisCommonController {
+
+    @Autowired
+    private QwHookApiService qwHookApiService;
+
+    @Autowired
+    private IQwUserService qwUserService;
+
+    @Autowired
+    QwApiService qwApiService;
+    @Autowired
+    QwCompanyMapper qwCompanyMapper;
+
+    @Autowired
+    FsCourseWatchLogMapper fsCourseWatchLogMapper;
+    @Autowired
+    FsUserCourseVideoMapper fsUserCourseVideoMapper;
+    @Autowired
+    FsCourseWatchLogMapper   watchLogMapper;
+    @Autowired
+    IQwJsApiService qwGetJsapiTicketService;
+
+    @Autowired
+    QwUserMapper qwUserMapper;
+    @Autowired
+    FastgptChatVoiceHomoMapper fastgptChatVoiceHomoMapper;
+
+    @Autowired
+    QwExternalContactCrmMapper qwExternalContactCrmMapper;
+    @Autowired
+    private IFsAppVersionService appVersionService;
+    @Autowired
+    RedisCache redisCache;
+
+
+    @Autowired
+    private IQwUserVideoService qwUserVideoService;
+
+
+    @PostMapping("/qwHookSendMsg")
+    public R qwHookSendMsg(@RequestBody QwHookSendMsgParam param ) {
+        param.setClientId(2);
+        return qwHookApiService.sendMsg(param);
+    }
+
+    @GetMapping("/qwHookAuth")
+    public R qwHookAuth(@RequestParam(value = "key", required = false) String key) {
+        QwHookAuthVO qwHookAuthVO = qwUserService.selectQwUserByAppKeyAuth(key);
+        if(qwHookAuthVO!=null){
+            return R.ok().put("data",qwHookAuthVO);
+        }
+        else {
+            return R.error("查询到相关成员信息");
+        }
+    }
+
+    @GetMapping("/qwHookCheck")
+    public R qwHookCheckCorpId(@RequestParam(value = "key", required = false) String key,
+                               @RequestParam(value = "qwHookId", required = false) String qwHookId,
+                               @RequestParam(value = "corpId", required = false) String corpId) {
+        QwUser user=qwUserService.selectQwUserByAppKey(key);
+        if(user.getCorpId().equals(corpId)){
+            if(user.getQwHookId().equals(qwHookId)){
+                return R.ok();
+            }
+            else{
+                return R.error("此帐号绑定的企业微信未授权");
+            }
+        }
+        else{
+           return R.error("此帐号绑定的企业微信未授权");
+        }
+    }
+
+    //获取企业微信签名
+    @PostMapping("/getConfigSignature")
+    public R getConfigSignature(@RequestBody QwConfigSignatureParam qwConfigSignatureParam) throws Exception {
+        return qwGetJsapiTicketService.getQwJsapiTicket(qwConfigSignatureParam);
+    }
+
+    //根据userid和外部联系人id获取到客户详情
+    @PostMapping("/getQwExternalContactDetails")
+    public R getQwExternalContactDetails(@RequestBody QwExternalContactHParam param){
+        return qwGetJsapiTicketService.getQwExternalContactDetails(param);
+    }
+
+    @ApiOperation("获取最新版本")
+    @GetMapping("/getNewAppVersion")
+    public R getNewAppVersion(@RequestParam("appType")Integer appType)
+    {
+        FsAppVersion version=appVersionService.getNewVersion(appType,3);
+        return R.ok().put("data",version);
+    }
+
+
+
+
+}

+ 39 - 0
fs-qwhook/src/main/java/com/fs/app/controller/ApisQwStatisticsController.java

@@ -0,0 +1,39 @@
+package com.fs.app.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.common.exception.CustomException;
+import com.fs.statistics.dto.WatchCourseStatisticsDTO;
+import com.fs.statistics.param.WatchCourseStatisticsParam;
+import com.fs.statistics.service.IStatisticsService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 企微统计数据
+ */
+@RestController
+@RequestMapping("/apis/app/qw/statistics")
+public class ApisQwStatisticsController extends BaseController {
+    @Autowired
+    private IStatisticsService statisticsService;
+
+
+//    @Login
+    @PostMapping("/course/watch")
+    @ApiOperation("会员看课详情")
+    public R queryCourseWatchStatistics(@RequestBody WatchCourseStatisticsParam param) {
+        if(param.getQwExternalContactId() == null) {
+            throw new CustomException("外部联系人id为空!");
+        }
+
+        WatchCourseStatisticsDTO watchCourseStatisticsDTO = statisticsService.queryWatchCourse(param);
+
+        return R.ok().put("data",watchCourseStatisticsDTO);
+    }
+
+}

+ 101 - 0
fs-qwhook/src/main/java/com/fs/app/controller/ApisQwUserController.java

@@ -0,0 +1,101 @@
+package com.fs.app.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.common.exception.CustomException;
+import com.fs.course.param.FsCourseListBySidebarParam;
+import com.fs.qw.domain.QwExternalContactInfo;
+import com.fs.qw.domain.QwUser;
+import com.fs.qw.param.ExternalContactDetailsParam;
+import com.fs.qw.service.IQwExternalContactInfoService;
+import com.fs.qw.service.IQwExternalContactService;
+import com.fs.qw.vo.ExternalContactDetailsVO;
+import com.fs.qw.vo.QwExternalListByHeavyVO;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Api(tags = "企微会员相关接口")
+@RestController
+@RequestMapping("/apis/app/qw/user")
+public class ApisQwUserController extends BaseController {
+
+    @Autowired
+    private IQwExternalContactService qwExternalContactService;
+
+    @Autowired
+    private IQwExternalContactInfoService qwExternalContactInfoService;
+
+    @GetMapping("/details")
+    @ApiOperation("会员看课详情")
+    public R getUserDetails(@ApiParam(value = "外部联系人id", required = true) @RequestParam Long contactId,
+                            @ApiParam(value = "时间tab,不传表示查询全部,分别是:今天、昨天、前天、近七天", required = true) String dateTag) {
+        ExternalContactDetailsParam param = new ExternalContactDetailsParam();
+        param.setUserId(getUserId());
+        param.setContactId(contactId);
+        param.setDateTag(dateTag);
+        ExternalContactDetailsVO userDetails = qwExternalContactService.getUserDetails(param);
+        Map<String, Object> map = new HashMap<>();
+        map.put("userDetails", userDetails);
+        return R.ok(map);
+    }
+
+
+    @GetMapping("/getQwUserInfo")
+    @ApiOperation("获取企微用户信息")
+    public R getQwUserInfo(@RequestParam(value = "qwExternalContactId",required = false) Long qwExternalContactId){
+        if(qwExternalContactId == null) {
+            throw new CustomException("企微外部联系人id不能为空!");
+        }
+//        QwExternalContact qwExternalContact = qwExternalContactService.selectQwExternalContactById(qwExternalContactId);
+        QwExternalContactInfo contactInfo = qwExternalContactInfoService.selectQwExternalContactInfoByExternalContactId(qwExternalContactId);
+        if (contactInfo==null){
+
+            contactInfo = new QwExternalContactInfo();
+            contactInfo.setExternalContactId(qwExternalContactId);
+            qwExternalContactInfoService.insertQwExternalContactInfo(contactInfo);
+
+        }
+
+//        return R.ok().put("data",qwExternalContact).put("moreInfo",contactInfo);
+        return R.ok().put("moreInfo",contactInfo);
+    }
+
+    @PostMapping("/updateQwUserInfo")
+    @ApiOperation("更新企微用户信息")
+    public R updateQwUserInfo(@RequestBody QwExternalContactInfo qwExternalContactInfo){
+        if(qwExternalContactInfo.getExternalContactId() == null) {
+            throw new CustomException("企微外部联系人id不能为空!");
+        }
+        qwExternalContactInfoService.updateQwExternalContactInfoByExternalContactId(qwExternalContactInfo);
+        return R.ok();
+    }
+
+    /**
+    * 获取客户是否加了其他的销售(重粉)
+    */
+    @PostMapping("/getQwExternalListByHeavy")
+    @ApiOperation("获取客户是否加了其他的销售")
+    public R getQwExternalListByHeavy(@RequestBody FsCourseListBySidebarParam param){
+        QwUser qwUser = qwExternalContactService.getQwUserByRedis(param.getCorpId().trim(),param.getQwUserId().trim());
+
+        if (qwUser == null) {
+            return R.error("未查询到企业微信账号信息!请重试");
+        }
+
+        PageHelper.startPage(param.getPageNum(), param.getPageSize());
+        List<QwExternalListByHeavyVO> qwExternalListByHeavy = qwExternalContactService.getQwExternalListByHeavy(param);
+        PageInfo<QwExternalListByHeavyVO> result = new PageInfo<>(qwExternalListByHeavy);
+        return R.ok().put("data", result);
+    }
+}

+ 95 - 0
fs-qwhook/src/main/java/com/fs/app/controller/ApisQwWorkTaskController.java

@@ -0,0 +1,95 @@
+package com.fs.app.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.company.service.ICompanyUserService;
+import com.fs.course.mapper.FsCourseWatchLogMapper;
+import com.fs.qw.domain.QwUser;
+import com.fs.qw.domain.QwWorkTask;
+import com.fs.qw.param.SelectQwWorkTaskListParam;
+import com.fs.qw.service.IQwExternalContactService;
+import com.fs.qw.service.IQwUserService;
+import com.fs.qw.service.IQwWorkTaskService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Slf4j
+@Api(tags = "企微任务看板接口")
+@RestController
+@RequestMapping("/apis/app/qw/workTask")
+@AllArgsConstructor
+public class ApisQwWorkTaskController extends BaseController {
+
+    @Autowired
+    private  IQwWorkTaskService qwWorkTaskService;
+    @Autowired
+    private  IQwUserService qwUserService;
+
+    @Autowired
+    ICompanyUserService companyUserService;
+
+    @Autowired
+    private FsCourseWatchLogMapper fsCourseWatchLogMapper;
+
+    @Autowired
+    private IQwExternalContactService qwExternalContactService;
+
+
+//    @Login
+    @PostMapping("/list")
+    @ApiOperation("企微任务看板列表")
+    public R selectQwWorkTaskList(@RequestBody SelectQwWorkTaskListParam param) {
+
+        log.info("企微任务看板列表: {}",param);
+
+
+        QwUser qwUser = qwExternalContactService.getQwUserByRedis(param.getCorpId().trim(), param.getQwUserId().trim());
+
+        if (qwUser == null || qwUser.getCompanyId() == null) {
+            return R.error("员工未绑定 销售公司 或 未获取到员工信息,请重试!");
+        }
+
+        param.setUserId(qwUser.getId());
+
+        PageHelper.startPage(param.getPageNum(), param.getPageSize());
+        List<QwWorkTask> list = qwUserService.selectQwWorkTaskList(param);
+        for (QwWorkTask qwWorkTask : list) {
+            List<Integer> logs = fsCourseWatchLogMapper.selectFsCourseWatchLog7DayByExtId(qwWorkTask.getExtId());
+            qwWorkTask.setLogs(logs);
+        }
+
+        PageInfo<QwWorkTask> pageInfo = new PageInfo<>(list);
+        return R.ok().put("data",pageInfo);
+    }
+
+    /**
+    * 处理催课
+    */
+    @GetMapping("/updateWorkTaskStatus/{id}")
+    public R updateWorkTaskStatus(@PathVariable("id") Long id) {
+
+        try {
+            QwWorkTask qwWorkTask=new QwWorkTask();
+            qwWorkTask.setId(id);
+            qwWorkTask.setStatus(1);
+            int i = qwWorkTaskService.updateQwWorkTask(qwWorkTask);
+            if (i>0) {
+                return R.ok();
+            }else {
+                return R.error("更新失败,请重试!");
+            }
+        }catch (Exception e){
+            return R.error("更新失败,请重试!");
+        }
+    }
+
+
+}

+ 39 - 0
fs-qwhook/src/main/java/com/fs/app/controller/QwStatisticsController.java

@@ -0,0 +1,39 @@
+package com.fs.app.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.common.exception.CustomException;
+import com.fs.statistics.dto.WatchCourseStatisticsDTO;
+import com.fs.statistics.param.WatchCourseStatisticsParam;
+import com.fs.statistics.service.IStatisticsService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 企微统计数据
+ */
+@RestController
+@RequestMapping("/app/qw/statistics")
+public class QwStatisticsController extends BaseController {
+    @Autowired
+    private IStatisticsService statisticsService;
+
+
+//    @Login
+    @PostMapping("/course/watch")
+    @ApiOperation("会员看课详情")
+    public R queryCourseWatchStatistics(@RequestBody WatchCourseStatisticsParam param) {
+        if(param.getQwExternalContactId() == null) {
+            throw new CustomException("外部联系人id为空!");
+        }
+
+        WatchCourseStatisticsDTO watchCourseStatisticsDTO = statisticsService.queryWatchCourse(param);
+
+        return R.ok().put("data",watchCourseStatisticsDTO);
+    }
+
+}

+ 69 - 0
fs-qwhook/src/main/java/com/fs/app/controller/QwUserController.java

@@ -0,0 +1,69 @@
+package com.fs.app.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.common.exception.CustomException;
+import com.fs.qw.domain.QwExternalContactInfo;
+import com.fs.qw.param.ExternalContactDetailsParam;
+import com.fs.qw.service.IQwExternalContactInfoService;
+import com.fs.qw.service.IQwExternalContactService;
+import com.fs.qw.vo.ExternalContactDetailsVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Slf4j
+@Api(tags = "企微会员相关接口")
+@RestController
+@RequestMapping("/app/qw/user")
+public class QwUserController extends BaseController {
+
+    @Autowired
+    private IQwExternalContactService qwExternalContactService;
+
+    @Autowired
+    private IQwExternalContactInfoService qwExternalContactInfoService;
+
+    @GetMapping("/details")
+    @ApiOperation("会员看课详情")
+    public R getUserDetails(@ApiParam(value = "外部联系人id", required = true) @RequestParam Long contactId,
+                            @ApiParam(value = "时间tab,不传表示查询全部,分别是:今天、昨天、前天、近七天", required = true) String dateTag) {
+        ExternalContactDetailsParam param = new ExternalContactDetailsParam();
+        param.setUserId(getUserId());
+        param.setContactId(contactId);
+        param.setDateTag(dateTag);
+        ExternalContactDetailsVO userDetails = qwExternalContactService.getUserDetails(param);
+        Map<String, Object> map = new HashMap<>();
+        map.put("userDetails", userDetails);
+        return R.ok(map);
+    }
+
+
+    @GetMapping("/getQwUserInfo")
+    @ApiOperation("获取企微用户信息")
+    public R getQwUserInfo(@RequestParam(value = "qwExternalContactId",required = false) Long qwExternalContactId){
+        if(qwExternalContactId == null) {
+            throw new CustomException("企微外部联系人id不能为空!");
+        }
+
+        QwExternalContactInfo qwExternalContactInfo = qwExternalContactInfoService.selectQwExternalContactInfoByExternalContactId(qwExternalContactId);
+        return R.ok().put("data",qwExternalContactService.selectQwExternalContactById(qwExternalContactId)).put("moreInfo",qwExternalContactInfo);
+    }
+
+    @PostMapping("/updateQwUserInfo")
+    @ApiOperation("更新企微用户信息")
+    public R updateQwUserInfo(@RequestBody QwExternalContactInfo qwExternalContactInfo){
+        if(qwExternalContactInfo.getExternalContactId() == null) {
+            throw new CustomException("企微外部联系人id不能为空!");
+        }
+        qwExternalContactInfoService.updateQwExternalContactInfoByExternalContactId(qwExternalContactInfo);
+        return R.ok();
+    }
+
+}

+ 92 - 0
fs-qwhook/src/main/java/com/fs/app/controller/QwWorkTaskController.java

@@ -0,0 +1,92 @@
+package com.fs.app.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.company.service.ICompanyUserService;
+import com.fs.course.mapper.FsCourseWatchLogMapper;
+import com.fs.qw.domain.QwUser;
+import com.fs.qw.domain.QwWorkTask;
+import com.fs.qw.param.SelectQwWorkTaskListParam;
+import com.fs.qw.service.IQwExternalContactService;
+import com.fs.qw.service.IQwUserService;
+import com.fs.qw.service.IQwWorkTaskService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Slf4j
+@Api(tags = "企微任务看板接口")
+@RestController
+@RequestMapping("/app/qw/workTask")
+@AllArgsConstructor
+public class QwWorkTaskController extends BaseController {
+
+    private final IQwWorkTaskService qwWorkTaskService;
+    private final IQwUserService qwUserService;
+
+    @Autowired
+    ICompanyUserService companyUserService;
+
+    @Autowired
+    private FsCourseWatchLogMapper fsCourseWatchLogMapper;
+
+    @Autowired
+    private IQwExternalContactService qwExternalContactService;
+
+    @PostMapping("/list")
+    @ApiOperation("企微任务看板列表")
+    public R selectQwWorkTaskList(@RequestBody SelectQwWorkTaskListParam param) {
+
+        log.info("企微任务看板列表: {}",param);
+
+        QwUser qwUser = qwExternalContactService.getQwUserByRedis(param.getCorpId().trim(), param.getQwUserId().trim());
+
+        if (qwUser == null || qwUser.getCompanyId() == null) {
+            return R.error("员工未绑定 销售公司 或 未获取到员工信息,请重试!");
+        }
+
+        param.setUserId(qwUser.getId());
+
+        PageHelper.startPage(param.getPageNum(), param.getPageSize());
+        List<QwWorkTask> list = qwUserService.selectQwWorkTaskList(param);
+
+        for (QwWorkTask qwWorkTask : list) {
+            List<Integer> logs = fsCourseWatchLogMapper.selectFsCourseWatchLog7DayByExtId(qwWorkTask.getExtId());
+            qwWorkTask.setLogs(logs);
+        }
+
+        PageInfo<QwWorkTask> pageInfo = new PageInfo<>(list);
+        return R.ok().put("data",pageInfo);
+    }
+
+    /**
+     * 处理催课
+     */
+    @GetMapping("/updateWorkTaskStatus/{id}")
+    public R updateWorkTaskStatus(@PathVariable("id") Long id) {
+
+        try {
+            QwWorkTask qwWorkTask=new QwWorkTask();
+            qwWorkTask.setId(id);
+            qwWorkTask.setStatus(1);
+            int i = qwWorkTaskService.updateQwWorkTask(qwWorkTask);
+            if (i>0) {
+                return R.ok();
+            }else {
+                return R.error("更新失败,请重试!");
+            }
+        }catch (Exception e){
+            return R.error("更新失败,请重试!");
+        }
+    }
+
+
+
+}

+ 9 - 0
fs-service/src/main/java/com/fs/company/domain/Company.java

@@ -102,6 +102,15 @@ public class Company extends BaseEntity
     @TableField(exist = false)
     private List<String> rules;
 
+    /**
+     * 点播配置-公众号appId
+     */
+    private String courseMaAppId;
+    /**
+     * 点播配置-小程序appId
+     */
+    private String courseMiniAppId;
+
 //    public String getDoctorIds() {
 //        return doctorIds;
 //    }

+ 42 - 7
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -1,18 +1,23 @@
 package com.fs.course.service.impl;
 
-import cn.hutool.core.util.NumberUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fs.common.BeanCopyUtils;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.ResponseResult;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.date.DateUtil;
+import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyUser;
+import com.fs.company.mapper.CompanyMapper;
 import com.fs.company.mapper.CompanyUserMapper;
 import com.fs.course.config.CourseConfig;
 import com.fs.course.domain.*;
@@ -29,11 +34,13 @@ import com.fs.course.vo.FsUserCourseVideoVO;
 import com.fs.course.vo.newfs.*;
 import com.fs.his.domain.FsUser;
 import com.fs.his.domain.FsUserIntegralLogs;
+import com.fs.his.domain.FsUserWx;
 import com.fs.his.mapper.FsUserIntegralLogsMapper;
 import com.fs.his.mapper.FsUserMapper;
 import com.fs.his.param.WxSendRedPacketParam;
 import com.fs.his.service.IFsStorePaymentService;
 import com.fs.his.service.IFsUserService;
+import com.fs.his.service.IFsUserWxService;
 import com.fs.his.vo.OptionsVO;
 import com.fs.qw.domain.QwCompany;
 import com.fs.qw.domain.QwExternalContact;
@@ -64,7 +71,6 @@ import org.springframework.transaction.annotation.Transactional;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.LocalDateTime;
-import java.time.LocalTime;
 import java.time.ZoneId;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
@@ -172,6 +178,10 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
     private IQwExternalContactService qwExternalContactService;
     @Autowired
     private IQwCompanyService iQwCompanyService;
+    @Autowired
+    private CompanyMapper companyMapper;
+    @Autowired
+    private IFsUserWxService fsUserWxService;
 
 
     /**
@@ -841,11 +851,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
         // 准备发送红包参数
         WxSendRedPacketParam packetParam = new WxSendRedPacketParam();
-        packetParam.setOpenId(user.getMpOpenId());
-        // 来源是小程序切换openId
-        if (param.getSource() == 2) {
-            packetParam.setOpenId(user.getCourseMaOpenId());
-        }
+        packetParam.setOpenId(getOpenId(user.getUserId(), param.getCompanyId(), param.getSource()));
         packetParam.setAmount(amount);
         packetParam.setSource(param.getSource());
         packetParam.setRedPacketMode(config.getRedPacketMode());
@@ -890,6 +896,35 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         }
     }
 
+    /**
+     * 获取用户openId
+     *
+     * @param userId    用户ID
+     * @param companyId 公司ID
+     * @param source    来源 1公众号 2小程序
+     * @return openId
+     */
+    private String getOpenId(Long userId, Long companyId, Integer source) {
+        Company company = companyMapper.selectCompanyById(companyId);
+        String appId = source == 1 ? company.getCourseMaAppId() : company.getCourseMiniAppId();
+
+        // 公司配置为空时获取默认配置
+        if (StringUtils.isBlank(appId)) {
+            String json = configService.selectConfigByKey("course.config");
+            CourseConfig config = JSON.parseObject(json, CourseConfig.class);
+            appId = source == 1 ? config.getMpAppId() : config.getMiniprogramAppid();
+        }
+
+        // 查询openId
+        Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery().eq(FsUserWx::getFsUserId, userId).eq(FsUserWx::getAppId, appId);
+        FsUserWx fsUserWx = fsUserWxService.getOne(queryWrapper);
+        if (Objects.isNull(fsUserWx)) {
+            throw new CustomException("获取openId失败");
+        }
+
+        return fsUserWx.getOpenId();
+    }
+
     /**
      * 发放积分奖励
      *

+ 40 - 0
fs-service/src/main/java/com/fs/his/domain/FsUserWx.java

@@ -0,0 +1,40 @@
+package com.fs.his.domain;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+@TableName("fs_user_wx")
+public class FsUserWx {
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    /**
+     * 用户ID
+     */
+    private Long fsUserId;
+    /**
+     * 小程序/公众号appId
+     */
+    private String appId;
+    /**
+     * 微信unionId
+     */
+    private String unionId;
+    /**
+     * 微信openId
+     */
+    private String openId;
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+    /**
+     * 修改时间
+     */
+    private LocalDateTime updateTime;
+}

+ 7 - 0
fs-service/src/main/java/com/fs/his/mapper/FsUserWxMapper.java

@@ -0,0 +1,7 @@
+package com.fs.his.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.his.domain.FsUserWx;
+
+public interface FsUserWxMapper extends BaseMapper<FsUserWx> {
+}

+ 7 - 0
fs-service/src/main/java/com/fs/his/service/IFsUserWxService.java

@@ -0,0 +1,7 @@
+package com.fs.his.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.his.domain.FsUserWx;
+
+public interface IFsUserWxService extends IService<FsUserWx> {
+}

+ 13 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsUserWxServiceImpl.java

@@ -0,0 +1,13 @@
+package com.fs.his.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.his.domain.FsUserWx;
+import com.fs.his.mapper.FsUserWxMapper;
+import com.fs.his.service.IFsUserWxService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class FsUserWxServiceImpl extends ServiceImpl<FsUserWxMapper, FsUserWx> implements IFsUserWxService {
+}

+ 1 - 0
fs-service/src/main/java/com/fs/qw/mapper/QwExternalContactMapper.java

@@ -251,6 +251,7 @@ public interface QwExternalContactMapper extends BaseMapper<QwExternalContact> {
             "            <if test=\"delTime != null \"> and DATE(ec.del_time) = DATE(#{delTime})</if>\n" +
             "            <if test=\"sTime != null \">  and DATE(ec.create_time) &gt;= DATE(#{sTime})</if>\n" +
             "            <if test=\"eTime != null \">  and DATE(ec.create_time) &lt;= DATE(#{eTime})</if>\n" +
+            "            <if test=\"companyUserName != null  and companyUserName != ''\"> and cu.user_name = #{companyUserName}</if>\n" +
 
             "<if test ='companyUser!=null'> " +
                 "and (cu.nick_name like concat('%', #{companyUser}, '%') or cu.phonenumber= #{companyUser})"+

+ 5 - 0
fs-service/src/main/java/com/fs/qw/param/QwExternalContactParam.java

@@ -32,6 +32,11 @@ public class QwExternalContactParam {
      */
     private String companyUser;
 
+    /**
+     * 销售账号
+     * **/
+    private String companyUserName;
+
 
     private Long customerId;
 

+ 5 - 0
fs-service/src/main/java/com/fs/qw/param/QwFsUserParam.java

@@ -10,4 +10,9 @@ public class QwFsUserParam {
 
     /** 手机号码 */
     private String phone;
+
+    /**
+     * 企业ID
+     * **/
+    private String companyId;
 }

+ 7 - 0
fs-service/src/main/java/com/fs/qw/service/IQwUserService.java

@@ -171,4 +171,11 @@ public interface IQwUserService
      * @return
      */
     R restartCloudHost(String IP);
+
+    /**
+     * 获取企微用户信息
+     * @param param 查询参数
+     * @return list
+     * **/
+    List<QwUser> getQwUserInfo(QwFsUserParam param);
 }

+ 17 - 0
fs-service/src/main/java/com/fs/qw/service/impl/QwUserServiceImpl.java

@@ -1,8 +1,10 @@
 package com.fs.qw.service.impl;
 
 import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.http.HttpRequest;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.cloud.host.CloudHostConfig;
 import com.cloud.host.PoolInfoEnum;
 import com.ecloud.sdk.ecs.v1.Client;
@@ -1357,6 +1359,21 @@ public class QwUserServiceImpl implements IQwUserService
         }
     }
 
+    @Override
+    public List<QwUser> getQwUserInfo(QwFsUserParam param) {
+        LambdaQueryWrapper<QwUser> qw=buildQuery(param);
+        return qwUserMapper.selectList(qw);
+    }
+
+    /**
+     * 构建查询条件
+     * **/
+    public LambdaQueryWrapper buildQuery(QwFsUserParam param){
+        LambdaQueryWrapper<QwUser> queryWrapper=new LambdaQueryWrapper<>();
+        queryWrapper.eq(ObjectUtil.isNotNull(param.getCompanyId()),QwUser::getCompanyId,param.getCompanyId());
+        return queryWrapper;
+    }
+
     /**
      *  获取文件名
      */

+ 11 - 1
fs-service/src/main/resources/mapper/company/CompanyMapper.xml

@@ -33,10 +33,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="doctorIds"    column="doctor_ids"    />
         <result property="restartTime"    column="restart_time"    />
         <result property="packageCateIds"    column="package_cate_ids"    />
+        <result property="courseMaAppId"    column="course_ma_app_id"    />
+        <result property="courseMiniAppId"    column="course_mini_app_id"    />
     </resultMap>
 
     <sql id="selectCompanyVo">
-        select company_id,follow_doctor_ids,doctor_ids, company_name,manager, company_mobile, company_address, create_time, update_time, status, start_time, limit_time, money ,tui_money, voice_api_id,company_type,user_id,app_id,app_key,remark,link_name,limit_user_count,is_del,voice_caller_number,oms_code,restart_time,package_cate_ids from company
+        select company_id,follow_doctor_ids,doctor_ids, company_name,manager, company_mobile, company_address, create_time, update_time, status, start_time, limit_time, money ,tui_money, voice_api_id,company_type,user_id,app_id,app_key,remark,link_name,limit_user_count,is_del,voice_caller_number,oms_code,restart_time,package_cate_ids,course_ma_app_id,course_mini_app_id from company
     </sql>
 
     <select id="selectCompanyList" parameterType="Company" resultMap="CompanyResult">
@@ -51,6 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="voiceApiId != null "> and voice_api_id = #{voiceApiId}</if>
             <if test="restartTime != null "> and restart_time = #{restartTime}</if>
             <if test="packageCateIds != null "> and package_cate_ids = #{packageCateIds}</if>
+            <if test="courseMaAppId != null "> and course_ma_app_id = #{courseMaAppId}</if>
+            <if test="courseMiniAppId != null "> and course_mini_app_id = #{courseMiniAppId}</if>
         </where>
     </select>
 
@@ -87,6 +91,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="doctorIds != null">doctor_ids,</if>
             <if test="restartTime != null">restart_time,</if>
             <if test="packageCateIds != null">package_cate_ids,</if>
+            <if test="courseMaAppId != null">course_ma_app_id,</if>
+            <if test="courseMiniAppId != null">course_mini_app_id,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="companyName != null">#{companyName},</if>
@@ -114,6 +120,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="doctorIds != null">#{doctorIds},</if>
             <if test="restartTime != null">#{restartTime},</if>
             <if test="packageCateIds != null">#{packageCateIds},</if>
+            <if test="courseMaAppId != null">#{courseMaAppId},</if>
+            <if test="courseMiniAppId != null">#{courseMiniAppId},</if>
          </trim>
     </insert>
 
@@ -146,6 +154,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="doctorIds != null">doctor_ids = #{doctorIds},</if>
             <if test="restartTime != null">restart_time = #{restartTime},</if>
             <if test="packageCateIds != null">package_cate_ids = #{packageCateIds},</if>
+            <if test="courseMaAppId != null">course_ma_app_id = #{courseMaAppId},</if>
+            <if test="courseMiniAppId != null">course_mini_app_id = #{courseMiniAppId},</if>
         </trim>
         where company_id = #{companyId}
     </update>

+ 7 - 0
fs-service/src/main/resources/mapper/his/FsUserWxMapper.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.his.mapper.FsUserWxMapper">
+
+</mapper>

+ 19 - 9
fs-user-app/src/main/java/com/fs/app/controller/WxUserController.java

@@ -18,12 +18,10 @@ import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.config.WxMpConfiguration;
 import com.fs.course.config.CourseMaConfig;
 import com.fs.his.config.FsSysConfig;
-import com.fs.his.domain.FsAgreementConfig;
-import com.fs.his.domain.FsStoreSysConfig;
-import com.fs.his.domain.FsUser;
-import com.fs.his.domain.FsUserLoginLog;
+import com.fs.his.domain.*;
 import com.fs.his.mapper.FsUserLoginLogMapper;
 import com.fs.his.service.IFsUserService;
+import com.fs.his.service.IFsUserWxService;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
@@ -44,6 +42,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -77,7 +76,8 @@ public class WxUserController extends AppBaseController{
 
     @Autowired
     private WxMpService wxMpService;
-
+    @Autowired
+    private IFsUserWxService userWxService;
 
 
 
@@ -198,24 +198,24 @@ public class WxUserController extends AppBaseController{
         }
         CourseMaConfig courseMaConfig = courseMaConfigs.get(0);
         return handleCourseLogin(param,
-                () -> WxMaConfiguration.getMaService(courseMaConfig.getAppid()),
+                courseMaConfig.getAppid(),
                 courseMaConfig.getName());
     }
 
     /**
      * 公共登录处理方法
      * @param param 登录参数
-     * @param wxServiceSupplier 微信服务提供函数(差异化点1:不同方式获取WxMaService)
+     * @param appId appId(差异化点1:不同方式获取WxMaService)
      * @param logName 日志名称(差异化点2:不同场景标识)
      */
-    private R handleCourseLogin(LoginParam param, Supplier<WxMaService> wxServiceSupplier, String logName) {
+    private R handleCourseLogin(LoginParam param, String appId, String logName) {
         if (StringUtils.isBlank(param.getCode())) {
             return R.error("code不存在");
         }
 
         try {
             // 通过函数式接口获取不同的微信服务实例
-            final WxMaService wxService = wxServiceSupplier.get();
+            final WxMaService wxService = WxMaConfiguration.getMaService(appId);
             WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
             this.logger.info("获取{} Session:{}", logName, session);
 
@@ -243,6 +243,16 @@ public class WxUserController extends AppBaseController{
                 isNewUser = true;
             }
 
+            // 保存用户openId
+            FsUserWx wx = new FsUserWx();
+            wx.setFsUserId(user.getUserId());
+            wx.setAppId(appId);
+            wx.setOpenId(session.getOpenid());
+            wx.setUnionId(session.getUnionid());
+            wx.setCreateTime(LocalDateTime.now());
+            wx.setUpdateTime(LocalDateTime.now());
+            userWxService.saveOrUpdate(wx);
+
             // 生成Token
             String token = jwtUtils.generateToken(user.getUserId());
             Map<String,Object> map = new HashMap<>();