From 69a34e1f21eaa53011bca056d12b30db1e968ff6 Mon Sep 17 00:00:00 2001 From: smj <739045908@qq.com> Date: Wed, 27 Jul 2022 14:16:13 +0800 Subject: [PATCH] =?UTF-8?q?V1.17.0=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/common/ShortUrlController.java | 49 +++ .../wechatopen/WechatOpenController.java | 55 ++++ .../wecom/WeDepartmentController.java | 4 +- .../wecom/radar/WeRadarChannelController.java | 89 ++++++ .../radar/WeRadarClickRecordController.java | 96 ++++++ .../wecom/radar/WeRadarController.java | 100 ++++++ .../src/main/resources/application.yml | 23 ++ .../common/config/WechatOpenConfig.java | 71 ++++ .../common/constant/GenConstants.java | 4 + .../common/constant/UserConstants.java | 6 +- .../easywecom/common/constant/WeConstans.java | 54 ---- .../common/constant/radar/RadarConstants.java | 108 +++++++ .../common/constant/redeemcode/Constants.java | 17 - .../redeemcode/RedeemCodeConstants.java | 77 +++++ .../conversation/msgtype/MsgTypeEnum.java | 1 + .../common/enums/AttachmentTypeEnum.java | 8 +- .../common/enums/CustomerTrajectoryEnums.java | 1 + .../common/enums/GroupMessageType.java | 8 +- .../com/easywecom/common/enums/ResultTip.java | 21 ++ .../common/enums/WeCategoryMediaTypeEnum.java | 1 + .../enums/moment/MomentSelectUserEnum.java | 32 ++ .../common/enums/radar/RadarChannelEnum.java | 55 ++++ .../common/enums/radar/RadarTypeEnum.java | 46 +++ .../mapper/SysShortUrlMappingMapper.java | 18 ++ .../common/service/ISysDeptService.java | 13 +- .../service/impl/SysDeptServiceImpl.java | 16 + .../common/shorturl/ShortUrlAppendInfo.java | 42 +++ .../common/shorturl/SysShortUrlMapping.java | 75 +++++ .../shorturl/service/ShortUrlAdaptor.java | 93 ++++++ .../shorturl/service/ShortUrlService.java | 30 ++ .../service/impl/ShortUrlServiceImpl.java | 137 ++++++++ .../common/utils/ConvertUrlUtil.java | 71 ++++ .../com/easywecom/common/utils/DateUtils.java | 2 +- .../system/SysShortUrlMappingMapper.xml | 14 + .../task/WeOperationsCenterSopTask.java | 65 +++- .../wecom/client/WeCustomerClient.java | 6 + .../wecom/client/WeExternalContactClient.java | 2 + .../wecom/client/WechatOpenClient.java | 81 +++++ .../wecom/domain/AllocateLeaveUserResp.java | 45 --- .../wecom/domain/AllocateWeCustomerResp.java | 39 --- .../wecom/domain/AllocateWeGroupResp.java | 41 --- .../wecom/domain/WeCustomerSeedMessage.java | 4 + .../easywecom/wecom/domain/WeEmpleCode.java | 5 + .../easywecom/wecom/domain/WeMaterial.java | 8 +- .../wecom/domain/WeMsgTlpMaterial.java | 15 +- .../wecom/domain/WeWordsDetailEntity.java | 12 +- .../wecom/domain/dto/AddWeMaterialDTO.java | 7 +- .../wecom/domain/dto/WeAppDetailDTO.java | 64 ---- .../wecom/domain/dto/WePageBaseReq.java | 72 ----- .../wecom/domain/dto/WePageBaseResp.java | 41 --- .../domain/dto/common/AttachmentParam.java | 38 ++- .../wecom/domain/dto/message/Attachment.java | 2 + .../domain/dto/message/RadarMessageDTO.java | 30 ++ .../domain/dto/moment/MomentAttachment.java | 9 + .../dto/radar/DeleteRadarChannelDTO.java | 22 ++ .../domain/dto/radar/DeleteRadarDTO.java | 25 ++ .../domain/dto/radar/GetRadarShortUrlDTO.java | 27 ++ .../domain/dto/radar/RadarChannelDTO.java | 46 +++ .../domain/dto/radar/RadarClickRecordDTO.java | 63 ++++ .../wecom/domain/dto/radar/RadarDTO.java | 94 ++++++ .../dto/radar/SearchChannelRecordDTO.java | 25 ++ .../radar/SearchChannelRecordDetailDTO.java | 31 ++ .../dto/radar/SearchCustomerRecordDTO.java | 35 ++ .../radar/SearchCustomerRecordDetailDTO.java | 27 ++ .../dto/radar/SearchRadarAnalyseDTO.java | 33 ++ .../dto/radar/SearchRadarChannelDTO.java | 25 ++ .../domain/dto/radar/SearchRadarDTO.java | 39 +++ .../wecom/domain/entity/radar/WeRadar.java | 98 ++++++ .../domain/entity/radar/WeRadarChannel.java | 48 +++ .../entity/radar/WeRadarClickRecord.java | 83 +++++ .../wecom/domain/entity/radar/WeRadarTag.java | 31 ++ .../wecom/domain/entity/radar/WeRadarUrl.java | 43 +++ .../entity/wechatopen/WeOpenConfig.java | 42 +++ .../wecom/domain/req/GenerateUrlLinkReq.java | 78 +++++ .../domain/req/UnionId2ExternalUserIdReq.java | 21 ++ .../domain/resp/GenerateUrlLinkResp.java | 18 ++ .../wecom/domain/resp/GetAccessTokenResp.java | 22 ++ .../domain/resp/GetOfficialAuthInfoResp.java | 27 ++ .../domain/resp/GetUnionUserInfoResp.java | 53 +++ .../wecom/domain/resp/SnsUserInfoResp.java | 63 ++++ .../resp/UnionId2ExternalUserIdResp.java | 19 ++ .../wecom/domain/resp/WechatOpenBaseResp.java | 32 ++ .../easywecom/wecom/domain/vo/AppIdVO.java | 27 ++ .../vo/SelectWeEmplyCodeWelcomeMsgVO.java | 5 + .../wecom/domain/vo/WeMaterialVO.java | 7 + .../domain/vo/radar/RadarAnalyseCountVO.java | 33 ++ .../wecom/domain/vo/radar/RadarAnalyseVO.java | 29 ++ .../vo/radar/RadarChannelRecordDetailVO.java | 34 ++ .../domain/vo/radar/RadarChannelRecordVO.java | 30 ++ .../domain/vo/radar/RadarChannelSortVO.java | 27 ++ .../RadarCustomerClickRecordDetailVO.java | 49 +++ .../vo/radar/RadarCustomerRecordVO.java | 39 +++ .../domain/vo/radar/RadarRecordTotalVO.java | 29 ++ .../vo/radar/RadarSumClickRecordVO.java | 21 ++ .../domain/vo/radar/WeRadarChannelVO.java | 48 +++ .../wecom/domain/vo/radar/WeRadarVO.java | 69 ++++ .../wecom/domain/vo/sop/SopAttachmentVO.java | 9 +- .../WeCallBackAddExternalContactImpl.java | 58 ++-- .../interceptor/WechatOpenInterceptor.java | 55 ++++ .../mapper/radar/WeRadarChannelMapper.java | 28 ++ .../radar/WeRadarClickRecordMapper.java | 77 +++++ .../wecom/mapper/radar/WeRadarMapper.java | 78 +++++ .../mapper/wechatopen/WeOpenConfigMapper.java | 23 ++ .../service/WeCustomerMessagePushService.java | 23 +- .../service/WeCustomerTrajectoryService.java | 12 +- .../wecom/service/WeDepartmentService.java | 10 +- .../wecom/service/WeEmpleCodeService.java | 17 + .../WeCustomerMessagePushServiceImpl.java | 22 +- .../impl/WeCustomerMessageServiceImpl.java | 49 ++- .../WeCustomerSeedMessageServiceImpl.java | 4 + .../impl/WeCustomerTrajectoryServiceImpl.java | 26 ++ .../service/impl/WeDepartmentServiceImpl.java | 21 +- .../service/impl/WeEmpleCodeServiceImpl.java | 192 +++++++---- .../impl/WeMsgTlpMaterialServiceImpl.java | 19 +- .../service/impl/WeMsgTlpServiceImpl.java | 39 ++- .../impl/WeWordsDetailServiceImpl.java | 14 +- .../impl/moment/WeMomentTaskServiceImpl.java | 9 +- .../impl/radar/WeRadarChannelServiceImpl.java | 152 +++++++++ .../radar/WeRadarClickRecordServiceImpl.java | 228 +++++++++++++ .../impl/radar/WeRadarServiceImpl.java | 301 +++++++++++++++++ .../WeRedeemCodeActivityServiceImpl.java | 19 +- .../redeemcode/WeRedeemCodeServiceImpl.java | 62 ++-- .../radar/MiniAppQrCodeUrlHandler.java | 90 ++++++ .../wecom/service/radar/RadarUrlHandler.java | 302 ++++++++++++++++++ .../service/radar/WeRadarChannelService.java | 70 ++++ .../radar/WeRadarClickRecordService.java | 92 ++++++ .../wecom/service/radar/WeRadarService.java | 81 +++++ .../service/wechatopen/WechatOpenService.java | 62 ++++ .../impl/WechatOpenServiceImpl.java | 185 +++++++++++ .../wecom/utils/AttachmentService.java | 17 + .../mapper/wecom/WeCustomerMapper.xml | 3 +- .../mapper/wecom/WeEmpleCodeMapper.xml | 297 ++++++++--------- .../mapper/wecom/WeMaterialMapper.xml | 50 ++- .../resources/mapper/wecom/WeMsgTlpMapper.xml | 1 + .../mapper/wecom/WeMsgTlpMaterialMapper.xml | 3 +- .../mapper/wecom/WeWordsDetailMapper.xml | 53 ++- .../wecom/radar/WeRadarChannelMapper.xml | 41 +++ .../wecom/radar/WeRadarClickRecordMapper.xml | 138 ++++++++ .../mapper/wecom/radar/WeRadarMapper.xml | 179 +++++++++++ .../redeemcode/WeRedeemCodeActivityMapper.xml | 12 +- .../wecom/redeemcode/WeRedeemCodeMapper.xml | 6 +- .../wecom/weopen/WeOpenConfigMapper.xml | 82 +++++ sql/init/easyWecom.sql | 194 +++++++++-- sql/update/update-V1.17.0.sql | 233 ++++++++++++++ 144 files changed, 6592 insertions(+), 786 deletions(-) create mode 100644 easywecom-admin/src/main/java/com/easywecom/web/controller/common/ShortUrlController.java create mode 100644 easywecom-admin/src/main/java/com/easywecom/web/controller/wechatopen/WechatOpenController.java create mode 100644 easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarChannelController.java create mode 100644 easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarClickRecordController.java create mode 100644 easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarController.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/config/WechatOpenConfig.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/constant/radar/RadarConstants.java delete mode 100644 easywecom-common/src/main/java/com/easywecom/common/constant/redeemcode/Constants.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/constant/redeemcode/RedeemCodeConstants.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/enums/moment/MomentSelectUserEnum.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/enums/radar/RadarChannelEnum.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/enums/radar/RadarTypeEnum.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/mapper/SysShortUrlMappingMapper.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/shorturl/ShortUrlAppendInfo.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/shorturl/SysShortUrlMapping.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/shorturl/service/ShortUrlAdaptor.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/shorturl/service/ShortUrlService.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/shorturl/service/impl/ShortUrlServiceImpl.java create mode 100644 easywecom-common/src/main/java/com/easywecom/common/utils/ConvertUrlUtil.java create mode 100644 easywecom-common/src/main/resources/mapper/system/SysShortUrlMappingMapper.xml create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/client/WechatOpenClient.java delete mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateLeaveUserResp.java delete mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateWeCustomerResp.java delete mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateWeGroupResp.java delete mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WeAppDetailDTO.java delete mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WePageBaseReq.java delete mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WePageBaseResp.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/message/RadarMessageDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/DeleteRadarChannelDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/DeleteRadarDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/GetRadarShortUrlDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarChannelDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarClickRecordDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchChannelRecordDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchChannelRecordDetailDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchCustomerRecordDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchCustomerRecordDetailDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarAnalyseDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarChannelDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarDTO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadar.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarChannel.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarClickRecord.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarTag.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarUrl.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/wechatopen/WeOpenConfig.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/req/GenerateUrlLinkReq.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/req/UnionId2ExternalUserIdReq.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GenerateUrlLinkResp.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetAccessTokenResp.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetOfficialAuthInfoResp.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetUnionUserInfoResp.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/SnsUserInfoResp.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/UnionId2ExternalUserIdResp.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/WechatOpenBaseResp.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/AppIdVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarAnalyseCountVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarAnalyseVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelRecordDetailVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelRecordVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelSortVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarCustomerClickRecordDetailVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarCustomerRecordVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarRecordTotalVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarSumClickRecordVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/WeRadarChannelVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/WeRadarVO.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/interceptor/WechatOpenInterceptor.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarChannelMapper.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarClickRecordMapper.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarMapper.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/wechatopen/WeOpenConfigMapper.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarChannelServiceImpl.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarClickRecordServiceImpl.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarServiceImpl.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/MiniAppQrCodeUrlHandler.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/RadarUrlHandler.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarChannelService.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarClickRecordService.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarService.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/service/wechatopen/WechatOpenService.java create mode 100644 easywecom-wecom/src/main/java/com/easywecom/wecom/service/wechatopen/impl/WechatOpenServiceImpl.java create mode 100644 easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarChannelMapper.xml create mode 100644 easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarClickRecordMapper.xml create mode 100644 easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarMapper.xml create mode 100644 easywecom-wecom/src/main/resources/mapper/wecom/weopen/WeOpenConfigMapper.xml create mode 100644 sql/update/update-V1.17.0.sql diff --git a/easywecom-admin/src/main/java/com/easywecom/web/controller/common/ShortUrlController.java b/easywecom-admin/src/main/java/com/easywecom/web/controller/common/ShortUrlController.java new file mode 100644 index 0000000..ba29b52 --- /dev/null +++ b/easywecom-admin/src/main/java/com/easywecom/web/controller/common/ShortUrlController.java @@ -0,0 +1,49 @@ +package com.easywecom.web.controller.common; + +import com.easywecom.common.core.domain.AjaxResult; +import com.easywecom.wecom.service.radar.MiniAppQrCodeUrlHandler; +import com.easywecom.wecom.service.radar.RadarUrlHandler; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.constraints.NotBlank; + +/** + * 类名: 短链相关接口 + * + * @author : silver_chariot + * @date : 2022/7/18 17:08 + **/ +@RestController +@RequestMapping("/url") +@Api(value = "ShortUrlController", tags = "短链相关") +public class ShortUrlController { + + + private final MiniAppQrCodeUrlHandler miniAppQrCodeUrlHandler; + private final RadarUrlHandler radarUrlHandler; + + public ShortUrlController(MiniAppQrCodeUrlHandler miniAppQrCodeUrlHandler, RadarUrlHandler radarUrlHandler) { + this.miniAppQrCodeUrlHandler = miniAppQrCodeUrlHandler; + this.radarUrlHandler = radarUrlHandler; + } + + @GetMapping("/empleCode") + @ApiOperation("根据短链获取员工活码") + public AjaxResult empleCode(@ApiParam("短链后缀的code") @Validated @NotBlank(message = "missing param") String code) { + return AjaxResult.success("success", miniAppQrCodeUrlHandler.getQrCode(code)); + } + + @GetMapping("/radar") + @ApiOperation("根据短链获取雷达链接并记录") + public AjaxResult radar(@ApiParam("短链后缀的code") String shortCode, @ApiParam("用户的公众号openid") String openId) { + return AjaxResult.success("success", radarUrlHandler.getOriginUrlAndRecord(shortCode, openId)); + } + + +} diff --git a/easywecom-admin/src/main/java/com/easywecom/web/controller/wechatopen/WechatOpenController.java b/easywecom-admin/src/main/java/com/easywecom/web/controller/wechatopen/WechatOpenController.java new file mode 100644 index 0000000..e8d003b --- /dev/null +++ b/easywecom-admin/src/main/java/com/easywecom/web/controller/wechatopen/WechatOpenController.java @@ -0,0 +1,55 @@ +package com.easywecom.web.controller.wechatopen; + +import com.easywecom.common.core.controller.BaseController; +import com.easywecom.common.core.domain.AjaxResult; +import com.easywecom.common.core.domain.model.LoginUser; +import com.easywecom.wecom.domain.entity.wechatopen.WeOpenConfig; +import com.easywecom.wecom.domain.vo.AppIdVO; +import com.easywecom.wecom.login.util.LoginTokenService; +import com.easywecom.wecom.service.wechatopen.WechatOpenService; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.web.bind.annotation.*; + +/** + * 类名: 微信小程序/公众号相关接口 + * + * @author : silver_chariot + * @date : 2022/7/20 10:03 + **/ +@RestController +@RequestMapping("/wechatopen") +public class WechatOpenController extends BaseController { + + private final WechatOpenService wechatOpenService; + + public WechatOpenController(WechatOpenService wechatOpenService) { + this.wechatOpenService = wechatOpenService; + } + + @GetMapping("/appId") + @ApiOperation("获取公众号的appId") + public AjaxResult getAppId(String shortCode) { + return AjaxResult.success("操作成功", wechatOpenService.getAppId(shortCode)); + } + + @GetMapping("/openId") + @ApiOperation("获取公众号Openid") + public AjaxResult getOpenId(@ApiParam("用户的code") String code ,@ApiParam("corpId")String corpId) { + return AjaxResult.success("操作成功", wechatOpenService.getOpenId(code,corpId)); + } + + @GetMapping("/config") + @ApiOperation("获取企业的公众号配置") + public AjaxResult getConfig() { + LoginUser user = LoginTokenService.getLoginUser(); + return AjaxResult.success(wechatOpenService.getConfig(user.getCorpId())); + } + + @PostMapping("/config") + @ApiOperation("修改企业的公众号配置") + public AjaxResult updateConfig(@RequestBody WeOpenConfig config) { + wechatOpenService.updateConfig(config); + return AjaxResult.success(); + } +} diff --git a/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/WeDepartmentController.java b/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/WeDepartmentController.java index 9a07a84..09e59be 100644 --- a/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/WeDepartmentController.java +++ b/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/WeDepartmentController.java @@ -41,8 +41,8 @@ public class WeDepartmentController extends BaseController { @ApiOperation("获取部门列表") public AjaxResult list(Integer isActivate) { LoginUser loginUser = LoginTokenService.getLoginUser(); - List list = weDepartmentService.selectWeDepartmentList(loginUser.getCorpId(), isActivate); - return AjaxResult.success(sysDeptService.filterDataScope(list, loginUser)); + List list = weDepartmentService.selectWeDepartmentList(loginUser.getCorpId(), isActivate, loginUser); + return AjaxResult.success(list); } diff --git a/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarChannelController.java b/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarChannelController.java new file mode 100644 index 0000000..40abeba --- /dev/null +++ b/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarChannelController.java @@ -0,0 +1,89 @@ +package com.easywecom.web.controller.wecom.radar; + +import com.easywecom.common.annotation.Log; +import com.easywecom.common.constant.radar.RadarConstants; +import com.easywecom.common.core.controller.BaseController; +import com.easywecom.common.core.domain.AjaxResult; +import com.easywecom.common.core.page.TableDataInfo; +import com.easywecom.common.enums.BusinessType; +import com.easywecom.common.enums.radar.RadarChannelEnum; +import com.easywecom.wecom.domain.dto.common.AttachmentParam; +import com.easywecom.wecom.domain.dto.radar.DeleteRadarChannelDTO; +import com.easywecom.wecom.domain.dto.radar.GetRadarShortUrlDTO; +import com.easywecom.wecom.domain.dto.radar.RadarChannelDTO; +import com.easywecom.wecom.domain.dto.radar.SearchRadarChannelDTO; +import com.easywecom.wecom.domain.vo.radar.WeRadarChannelVO; +import com.easywecom.wecom.login.util.LoginTokenService; +import com.easywecom.wecom.service.radar.WeRadarChannelService; +import io.swagger.annotations.Api; + +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * ClassName: weRadarChannelController + * + * @author wx + * @date 2022/7/19 14:48 + */ +@Api(tags = "雷达渠道Controller") +@RestController +@RequestMapping("/wecom/radar/channel") +public class WeRadarChannelController extends BaseController { + + private final WeRadarChannelService radarChannelService; + + @Autowired + public WeRadarChannelController(WeRadarChannelService radarChannelService) { + this.radarChannelService = radarChannelService; + } + + @Log(title = "新增雷达渠道", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ApiOperation("新增雷达渠道") +// @PreAuthorize("@ss.hasPermi('redeeomCode:activity:add')") + public AjaxResult add(@RequestBody @Validated RadarChannelDTO radarChannelDTO) { + radarChannelService.saveRadarChannel(radarChannelDTO); + return AjaxResult.success(); + } + + @GetMapping("/list") + @ApiOperation("查询雷达渠道序列") + public TableDataInfo list(SearchRadarChannelDTO radarChannelDTO) { + startPage(); + List list = radarChannelService.getRadarChannelList(radarChannelDTO); + return getDataTable(list); + } + + //@PreAuthorize("@ss.hasPermi('wecom:redeemcode:remove')") + @Log(title = "删除雷达渠道", businessType = BusinessType.DELETE) + @DeleteMapping("/remove") + @ApiOperation("删除雷达渠道") + public AjaxResult remove(@Validated @RequestBody DeleteRadarChannelDTO deleteDTO) { + radarChannelService.batchRemoveRadarChannel(deleteDTO); + return AjaxResult.success(); + } + + + @GetMapping("/get") + @ApiOperation("获取雷达渠道详情") + public AjaxResult get(@RequestParam("id") Long id) { + String corpId = LoginTokenService.getLoginUser().getCorpId(); + return AjaxResult.success(radarChannelService.getRadarChannel(corpId, id)); + } + + //@PreAuthorize("@ss.hasPermi('wecom:redeemcode:edit')") + @Log(title = "修改雷达渠道", businessType = BusinessType.UPDATE) + @PutMapping("/update") + @ApiOperation("修改雷达渠道") + // @PreAuthorize("@ss.hasPermi('redeeomCode:activity:edit')") + public AjaxResult edit(@Validated @RequestBody RadarChannelDTO radarChannelDTO) { + radarChannelService.updateRadarChannel(radarChannelDTO); + return AjaxResult.success(); + } + +} diff --git a/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarClickRecordController.java b/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarClickRecordController.java new file mode 100644 index 0000000..7cb6ea7 --- /dev/null +++ b/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarClickRecordController.java @@ -0,0 +1,96 @@ +package com.easywecom.web.controller.wecom.radar; + +import com.easywecom.common.annotation.Log; +import com.easywecom.common.core.controller.BaseController; +import com.easywecom.common.core.domain.AjaxResult; +import com.easywecom.common.core.page.TableDataInfo; +import com.easywecom.common.enums.BusinessType; +import com.easywecom.wecom.domain.dto.radar.*; +import com.easywecom.wecom.domain.vo.moment.MomentTotalVO; +import com.easywecom.wecom.domain.vo.radar.*; +import com.easywecom.wecom.login.util.LoginTokenService; +import com.easywecom.wecom.service.radar.WeRadarClickRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * ClassName: WeRadarClickRecordController + * + * @author wx + * @date 2022/7/19 19:54 + */ +@Api(tags = "雷达点击记录Controller") +@RestController +@RequestMapping("/wecom/radar/record") +public class WeRadarClickRecordController extends BaseController { + + private final WeRadarClickRecordService radarClickRecordService; + + + @Autowired + public WeRadarClickRecordController(WeRadarClickRecordService radarClickRecordService) { + this.radarClickRecordService = radarClickRecordService; + } + + @Log(title = "新增雷达点击记录", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ApiOperation("新增雷达点击记录") +// @PreAuthorize("@ss.hasPermi('redeeomCode:activity:add')") + public AjaxResult add(@RequestBody @Validated RadarClickRecordDTO clickRecordDTO) { + radarClickRecordService.saveClickRecord(clickRecordDTO); + return AjaxResult.success(); + } + + @GetMapping("/getTotal") + @ApiOperation("雷达详情数据总览") + public AjaxResult getTotal(@RequestParam("radarId") Long radarId) { + return AjaxResult.success(radarClickRecordService.getTotal(radarId)); + } + + @GetMapping("/getTimeRangeAnalyseCount") + @ApiOperation("时间段内雷达点击数据统计") + public AjaxResult getTimeRangeAnalyseCount(SearchRadarAnalyseDTO radarAnalyseDTO) { + return AjaxResult.success(radarClickRecordService.getTimeRangeAnalyseCount(radarAnalyseDTO)); + } + + @GetMapping("/getChannelSort") + @ApiOperation("获得渠道排序") + public AjaxResult getChannelSort(@RequestParam("radarId") Long radarId) { + return AjaxResult.success(radarClickRecordService.getChannelSort(radarId)); + } + + + @GetMapping("/getCustomerClickRecord") + @ApiOperation("获取客户点击记录") + public TableDataInfo getCustomerClickRecord(SearchCustomerRecordDTO customerRecordDTO) { + startPage(); + return getDataTable(radarClickRecordService.getCustomerClickRecord(customerRecordDTO)); + } + + @GetMapping("/getCustomerClickRecordDetail") + @ApiOperation("获取客户点击记录详情") + public AjaxResult getCustomerClickRecordDetail(SearchCustomerRecordDetailDTO customerRecordDTO) { + return AjaxResult.success(radarClickRecordService.getCustomerClickRecordDetail(customerRecordDTO)); + } + + + @GetMapping("/getChannelClickRecord") + @ApiOperation("获取渠道点击记录") + public TableDataInfo getChannelClickRecord(SearchChannelRecordDTO channelRecordDTO) { + startPage(); + return getDataTable(radarClickRecordService.getChannelClickRecord(channelRecordDTO)); + } + + @GetMapping("/getChannelClickRecordDetail") + @ApiOperation("获取渠道点击记录详情") + public TableDataInfo getChannelClickRecordDetail(SearchChannelRecordDetailDTO channelRecordDetailDTO) { + startPage(); + return getDataTable(radarClickRecordService.getChannelClickRecordDetail(channelRecordDetailDTO)); + } + +} diff --git a/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarController.java b/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarController.java new file mode 100644 index 0000000..d053ebd --- /dev/null +++ b/easywecom-admin/src/main/java/com/easywecom/web/controller/wecom/radar/WeRadarController.java @@ -0,0 +1,100 @@ +package com.easywecom.web.controller.wecom.radar; + +import com.easywecom.common.annotation.Log; +import com.easywecom.common.constant.radar.RadarConstants; +import com.easywecom.common.core.controller.BaseController; +import com.easywecom.common.core.domain.AjaxResult; +import com.easywecom.common.core.page.TableDataInfo; +import com.easywecom.common.enums.BusinessType; +import com.easywecom.common.enums.radar.RadarChannelEnum; +import com.easywecom.wecom.domain.dto.common.AttachmentParam; +import com.easywecom.wecom.domain.dto.radar.DeleteRadarDTO; +import com.easywecom.wecom.domain.dto.radar.GetRadarShortUrlDTO; +import com.easywecom.wecom.domain.dto.radar.RadarDTO; +import com.easywecom.wecom.domain.dto.radar.SearchRadarDTO; +import com.easywecom.wecom.domain.vo.radar.WeRadarVO; +import com.easywecom.wecom.login.util.LoginTokenService; +import com.easywecom.wecom.service.radar.WeRadarChannelService; +import com.easywecom.wecom.service.radar.WeRadarService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * ClassName: WeRadarController + * + * @author wx + * @date 2022/7/18 14:57 + */ + +@Api(tags = "雷达Controller") +@RestController +@RequestMapping("/wecom/radar") +public class WeRadarController extends BaseController { + + private final WeRadarService weRadarService; + private final WeRadarChannelService radarChannelService; + + @Autowired + public WeRadarController(WeRadarService weRadarService, WeRadarChannelService radarChannelService) { + this.weRadarService = weRadarService; + this.radarChannelService = radarChannelService; + } + + @Log(title = "新增雷达", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ApiOperation("新增雷达") + //@PreAuthorize("@ss.hasPermi('redeeomCode:activity:add')") + public AjaxResult add(@RequestBody @Validated RadarDTO radarDTO) { + radarDTO.setCorpId(LoginTokenService.getLoginUser().getCorpId()); + weRadarService.saveRadar(radarDTO); + return AjaxResult.success(); + } + + @GetMapping("/list") + @ApiOperation("查询雷达列表") + public TableDataInfo list(SearchRadarDTO radarDTO) { + radarDTO.setCorpId(LoginTokenService.getLoginUser().getCorpId()); + List list = weRadarService.getRadarList(radarDTO); + return getDataTable(list); + } + + @GetMapping("/get") + @ApiOperation("获取雷达详情") + public AjaxResult get(@RequestParam("id") Long id) { + String corpId = LoginTokenService.getLoginUser().getCorpId(); + WeRadarVO weRadarVO = weRadarService.getRadar(corpId, id); + return AjaxResult.success(weRadarVO); + } + + @Log(title = "更新雷达", businessType = BusinessType.UPDATE) + @PutMapping("/update") + @ApiOperation("修改雷达") + //@PreAuthorize("@ss.hasPermi('redeeomCode:activity:edit')") + public AjaxResult edit(@RequestBody @Validated RadarDTO radarDTO) { + radarDTO.setCorpId(LoginTokenService.getLoginUser().getCorpId()); + weRadarService.updateRadar(radarDTO); + return AjaxResult.success(); + } + + @Log(title = "删除雷达", businessType = BusinessType.DELETE) + @DeleteMapping("/remove") + @ApiOperation("删除雷达") + //@PreAuthorize("@ss.hasPermi('redeeomCode:activity:del')") + public AjaxResult remove(@Validated @RequestBody DeleteRadarDTO deleteDTO) { + String corpId = LoginTokenService.getLoginUser().getCorpId(); + return toAjax(weRadarService.batchRemoveRadar(corpId, deleteDTO)); + } + + @GetMapping("/getRadarShortUrl") + @ApiOperation("侧边栏获取雷达短链") + public AjaxResult getRadarShortUrl(GetRadarShortUrlDTO radarShortUrlDTO) { + String corpId = LoginTokenService.getLoginUser().getCorpId(); + return AjaxResult.success(weRadarService.getRadarShortUrl(radarShortUrlDTO.getRadarId(), RadarChannelEnum.SIDE_BAR.getTYPE(), radarShortUrlDTO.getUserId(), corpId, RadarConstants.RadarCustomerClickRecord.EMPTY_SCENARIO)); + } + +} diff --git a/easywecom-admin/src/main/resources/application.yml b/easywecom-admin/src/main/resources/application.yml index f63322d..4acade9 100644 --- a/easywecom-admin/src/main/resources/application.yml +++ b/easywecom-admin/src/main/resources/application.yml @@ -93,6 +93,10 @@ ruoyi: - /wecom/plus/** - /wecom/order/login - /wecom/order/getNetworkList + - /url/** + - /wechatopen/appId + - /wechatopen/openId + - /test/** # 开发环境配置 @@ -368,6 +372,7 @@ wecome: - /externalcontact/groupchat/get_join_way - /externalcontact/groupchat/update_join_way - /externalcontact/groupchat/del_join_way + - /externalcontact/unionid_to_external_userid needContactTokenUrl: - /user/get - /user/create @@ -409,6 +414,24 @@ chatrsakey: publicKey: ${CHAT_RSA_PUBLIC_KEY:} privateKey: ${CHAT_RSA_PRIVATE_KEY:} +## 微信小程序和公众号配置(小程序活码与雷达链接需要配置) +wechatopen: + miniApp: + appId: ${MINI_APP_ID:} + appSecret: ${MINI_APP_SECRET:} + domain: ${MINI_APP_DOMAIN:} + codePath: ${MINI_APP_CODE_PATH:} + ## 要打开的小程序版本。正式版为 "release",体验版为"trial",开发版为"develop",仅在微信外打开时生效。 + envVersion: ${MINI_APP_ENV_VERSION:} + officialAccount: + domain: ${OFFICIAL_ACCOUNT_DOMAIN:} + appId: ${OFFICIAL_ACCOUNT_APPID:} + appSecret: ${OFFICIAL_ACCOUNT_SECRET:} + needTokenUrl: + - /cgi-bin/user/info + - /wxa/generate_urllink + - /sns/oauth2/access_token + diff --git a/easywecom-common/src/main/java/com/easywecom/common/config/WechatOpenConfig.java b/easywecom-common/src/main/java/com/easywecom/common/config/WechatOpenConfig.java new file mode 100644 index 0000000..238955a --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/config/WechatOpenConfig.java @@ -0,0 +1,71 @@ +package com.easywecom.common.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * 类名: 微信公开平台配置 + * + * @author : silver_chariot + * @date : 2022/7/19 18:04 + **/ +@Component +@Data +@ConfigurationProperties(prefix = "wechatopen") +public class WechatOpenConfig { + /** + * 小程序配置 + */ + private MiniApp miniApp; + /** + * 公众号配置 + */ + private OfficialAccount officialAccount; + + @Data + public static class MiniApp { + /** + * 小程序appid + */ + private String appId; + /** + * 小程序秘钥 + */ + private String appSecret; + /** + * 域名 + */ + private String domain; + /** + * 小程序页面路径 + */ + private String codePath; + /** + * 所属环境 要打开的小程序版本。正式版为 "release", + * 体验版为"trial",开发版为"develop",仅在微信外打开时生效。 + */ + private String envVersion; + } + + @Data + public static class OfficialAccount { + /** + * 域名 + */ + private String domain; + /** + * appId + */ + private String appId; + /** + * appSecret + */ + private String appSecret; + + /** + * 需要token的接口 + */ + private String[] needTokenUrl; + } +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/constant/GenConstants.java b/easywecom-common/src/main/java/com/easywecom/common/constant/GenConstants.java index 50eacc5..e38bd14 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/constant/GenConstants.java +++ b/easywecom-common/src/main/java/com/easywecom/common/constant/GenConstants.java @@ -210,6 +210,10 @@ public class GenConstants { * 属性值占位符 */ public static final String PROPERTY_VALUE = "${propertyValue}"; + /** + * 雷达标题占位符 + */ + public static final String RADAR_TITLE = "${radarTitle}"; /** * 客户信息动态记录模板 */ diff --git a/easywecom-common/src/main/java/com/easywecom/common/constant/UserConstants.java b/easywecom-common/src/main/java/com/easywecom/common/constant/UserConstants.java index d816b72..7e03cdc 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/constant/UserConstants.java +++ b/easywecom-common/src/main/java/com/easywecom/common/constant/UserConstants.java @@ -134,15 +134,15 @@ public class UserConstants { /** * 初始化的管理员默认所有菜单id */ - public static final String ADMIN_DEFAULT_MENU_IDS = "1,2,101,102,108,109,110,111,112,500,501,1009,1010,1011,1014,1015,1016,1018,1019,1020,1041,1044,1048,1050,1051,1052,1053,1054,2001,2002,2003,2004,2005,2006,2007,2010,2013,2014,2015,2016,2020,2021,2022,2023,2024,2025,2026,2028,2029,2051,2052,2053,2056,2060,2062,2071,2072,2073,2074,2076,2079,2080,2081,2082,2083,2084,2085,2086,2100,2101,2102,2105,2106,2107,2120,2124,2127,2131,2133,2134,2135,2138,2139,2141,2142,2151,2152,2153,2156,2157,2158,2159,2160,2163,2164,2165,2166,2179,2188,2189,2196,2201,2205,2206,2207,2208,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2221,2222,2223,2224,2226,2227,2228,2229,2230,2231,2232,2233,2234,2235,2236,2237,2238,2239,2240,2241,2242,2243,2245,2247,2248,2249,2250,2251,2252,2256,2257,2258,2259,2260,2261,2262,2263,2264,2265,2266,2267,2268,2269,2270,2271,2272,2273,2274,2275,2276,2277,2280,2281,2282,2283,2284,2285,2286,2287,2288,2289,2292,2293,2296,2297,2298"; + public static final String ADMIN_DEFAULT_MENU_IDS = "1,2,101,102,108,109,110,111,112,500,501,1009,1010,1011,1014,1015,1016,1018,1019,1020,1041,1044,1048,1050,1051,1052,1053,1054,2001,2002,2003,2004,2005,2006,2007,2010,2013,2014,2015,2016,2020,2021,2022,2023,2024,2025,2026,2028,2029,2051,2052,2053,2056,2060,2062,2071,2072,2073,2074,2076,2079,2080,2081,2082,2083,2084,2085,2086,2100,2101,2102,2105,2106,2107,2120,2124,2127,2131,2133,2134,2135,2138,2139,2141,2142,2151,2152,2153,2156,2157,2158,2159,2160,2163,2164,2165,2166,2179,2188,2189,2196,2201,2205,2206,2207,2208,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2221,2222,2223,2224,2226,2227,2228,2229,2230,2231,2232,2233,2234,2235,2236,2237,2238,2239,2240,2241,2242,2243,2245,2247,2248,2249,2250,2251,2252,2256,2257,2258,2259,2260,2261,2262,2263,2264,2265,2266,2267,2268,2269,2270,2271,2272,2273,2274,2275,2276,2277,2280,2281,2282,2283,2284,2285,2286,2287,2288,2289,2292,2293,2296,2297,2298,2299,2301,2302"; /** * 初始化的部门管理员默认的所有菜单id */ - public static final String DEPARTMENT_ADMIN_DEFAULT_IDS = "1,1018,1019,1020,2001,2002,2003,2004,2005,2006,2007,2013,2014,2015,2016,2020,2021,2022,2023,2024,2025,2026,2028,2029,2052,2053,2056,2060,2062,2074,2079,2080,2081,2082,2083,2084,2085,2086,2100,2101,2102,2105,2106,2107,2120,2124,2127,2131,2133,2134,2135,2138,2139,2141,2142,2151,2152,2153,2156,2157,2158,2160,2163,2164,2179,2188,2201,2205,2206,2207,2208,2210,2211,2212,2213,2214,2215,2217,2218,2219,2221,2222,2223,2224,2236,2238,2243,2245,2247,2248,2250,2251,2252,2256,2257,2258,2259,2260,2261,2262,2263,2264,2265,2266,2267,2268,2272,2273,2274,2275,2276,2277,2280,2282,2283,2285,2286,2287,2288,2289,2292,2293,2296,2297,2298"; + public static final String DEPARTMENT_ADMIN_DEFAULT_IDS = "1,1018,1019,1020,2001,2002,2003,2004,2005,2006,2007,2013,2014,2015,2016,2020,2021,2022,2023,2024,2025,2026,2028,2029,2052,2053,2056,2060,2062,2074,2079,2080,2081,2082,2083,2084,2085,2086,2100,2101,2102,2105,2106,2107,2120,2124,2127,2131,2133,2134,2135,2138,2139,2141,2142,2151,2152,2153,2156,2157,2158,2160,2163,2164,2179,2188,2201,2205,2206,2207,2208,2210,2211,2212,2213,2214,2215,2217,2218,2219,2221,2222,2223,2224,2236,2238,2243,2245,2247,2248,2250,2251,2252,2256,2257,2258,2259,2260,2261,2262,2263,2264,2265,2266,2267,2268,2272,2273,2274,2275,2276,2277,2280,2282,2283,2285,2286,2287,2288,2289,2292,2293,2296,2297,2298,2299,2302"; /** * 初始化的员工默认的所有菜单id */ - public static final String EMPLOYEE_DEFAULT_IDS = "2001,2002,2003,2006,2007,2014,2015,2016,2020,2021,2022,2028,2074,2079,2080,2105,2106,2107,2160,2163,2164,2188,2224,2236,2243,2280,2062,2282"; + public static final String EMPLOYEE_DEFAULT_IDS = "2001,2002,2003,2006,2007,2014,2015,2016,2020,2021,2022,2028,2074,2079,2080,2105,2106,2107,2160,2163,2164,2188,2224,2236,2243,2280,2062,2282,2299"; /** * 三方应用需要屏蔽的菜单 */ diff --git a/easywecom-common/src/main/java/com/easywecom/common/constant/WeConstans.java b/easywecom-common/src/main/java/com/easywecom/common/constant/WeConstans.java index 0f7957e..15ce9eb 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/constant/WeConstans.java +++ b/easywecom-common/src/main/java/com/easywecom/common/constant/WeConstans.java @@ -680,10 +680,6 @@ public class WeConstans { */ public static final String EMPLOYEE_NAME = "#员工姓名#"; - /** - * 兑换码 - */ - public static final String REDEEM_CODE = "#兑换码#"; /** * 群欢迎语客户昵称占位符 */ @@ -729,22 +725,6 @@ public class WeConstans { */ public static final Integer WE_GROUP_MEMBER_TYPE_CUSTOMER = 2; - /** - * 告警员工信息模板 - */ - public static final String REDEEM_CODE_ALARM_MESSAGE_INFO = "【兑换码活动库存告警提醒】\n" + - "\n" + - "兑换码活动名称:【活动名称】\n" + - "\n" + - "兑换码库存数:【库存个数】\n" + - "\n" + - "请及时前往该活动中添加库存"; - - public static final String REDEEM_CODE_ACTIVITY_NAME = "【活动名称】"; - - public static final String REDEEM_CODE_REAMIN_INVENTORY = "【库存个数】"; - - /** * 发送信息模板 */ @@ -900,41 +880,7 @@ public class WeConstans { */ public static final int AUTO_TAG_ADD_DEPARTMENT_TYPE = 1; - /** - * 兑换码告警员工选择员工 - */ - public static final int REDEEM_CODE_USE_USER = 2; - - /** - * 兑换码告警员工选择部门 - */ - public static final int REDEEM_CODE_USE_DEPARTMENT = 1; - /** - * 兑换码员工告警 - */ - public static final Integer REDEEM_CODE_USER_ALARM = 1; - - /** - * 兑换码活动限制参与 - */ - public static final Integer REDEEM_CODE_ACTIVITY_LIMITED = 1; - - /** - * 兑换码已领取 - */ - public static final int REDEEM_CODE_RECEIVED = 1; - - /** - * 兑换码未领取 - */ - - public static final int REDEEM_CODE_NOT_RECEIVED = 0; - - /** - * 兑换码默认空时间 - */ - public static final String REDEEM_CODE_EMPTY_TIME = "0000-00-00"; } diff --git a/easywecom-common/src/main/java/com/easywecom/common/constant/radar/RadarConstants.java b/easywecom-common/src/main/java/com/easywecom/common/constant/radar/RadarConstants.java new file mode 100644 index 0000000..daba5c1 --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/constant/radar/RadarConstants.java @@ -0,0 +1,108 @@ +package com.easywecom.common.constant.radar; + +import com.easywecom.common.enums.radar.RadarChannelEnum; +import com.easywecom.common.utils.StringUtils; + +/** + * ClassName: RadarConstants + * + * @author wx + * @date 2022/7/18 17:30 + */ +public class RadarConstants { + + + /** + * 参数校验异常 + */ + public static class ParamVerify { + /** + * 传输参数为空 + */ + public static final String PARAM_NULL = "传输参数为空"; + } + + /** + * 提示客户,自定义抛出异常给前端使用 + */ + public static class PromptCus { + /** + * 未选择标签 + */ + public static final String NOT_USE_TAG = "未选择客户标签"; + /** + * 渠道名称重复 + */ + public static final String RADAR_CHANNEL_REPEAT = "渠道名称重复"; + + public static final String RADAR_SHORT_PARAM_ERROR = "生成雷达短链参数错误"; + + public static final String RADAR_SHORT_ERROR = "雷达不存在"; + } + + /** + * 新增/更新通知员工 + */ + public static class UpdateNoticeToUser { + /** + * 发送消息,企业雷达库已更新 + */ + public static final String CORP_RADAR_UPDATE = "企业雷达库已更新"; + + /** + * 发送消息,部门雷达库已更新 + */ + public static final String DEPARTMENT_RADAR_UPDATE = "部门雷达库已更新"; + + // “{雷达标题}” + public static final String getUpdateMessage(String title) { + return "“{" + title + "}”"; + } + + public static final String SEND_ALL = "@all"; + } + + public static class RadarAnalyseCount { + /** + * 如果不传日期默认为7天的数据 + */ + public static final Integer DEFAULT_DAY = 7; + + /** + * 数量为0 + */ + public static final Integer ZERO = 0; + } + + /** + * 客户点击记录 + */ + public static class RadarCustomerClickRecord { + + public static String COMMON_MSG = "普通欢迎语"; + + public static String EMPTY_USERID = StringUtils.EMPTY; + + public static String EMPTY_SCENARIO = StringUtils.EMPTY; + /** + * 替换渠道来源内容 + */ + public static String REPlACR_WORD = "【替换内容】"; + + public static String getRecordText(String customerName, String userName, String detail, int type, String channelName) { + String msg = "客户“" + customerName + "”" + "点击了员工“" + userName + "”" + "在【" + RadarChannelEnum.getChannelByType(type) + REPlACR_WORD + "】发出的雷达链接"; + if (RadarChannelEnum.CUSTOMIZE.getTYPE().equals(type)) { + return msg.replace(REPlACR_WORD, "-{" + channelName + "}"); + } + if (StringUtils.isNotBlank(detail) + && !RadarChannelEnum.MOMENT.getTYPE().equals(type) + && !RadarChannelEnum.SIDE_BAR.getTYPE().equals(type) + && !RadarChannelEnum.WELCOME_MSG.getTYPE().equals(type)) { + return msg.replace(REPlACR_WORD, "-{" + detail + "}"); + } else { + return msg.replace(REPlACR_WORD, StringUtils.EMPTY); + } + } + } + +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/constant/redeemcode/Constants.java b/easywecom-common/src/main/java/com/easywecom/common/constant/redeemcode/Constants.java deleted file mode 100644 index 132bfef..0000000 --- a/easywecom-common/src/main/java/com/easywecom/common/constant/redeemcode/Constants.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.easywecom.common.constant.redeemcode; - -/** - * ClassName: Constants - * - * @author wx - * @date 2022/7/12 9:41 - */ -public class Constants { - - /** - * 零库存 - */ - public static Integer ZERO_STOCK = 0; - - -} diff --git a/easywecom-common/src/main/java/com/easywecom/common/constant/redeemcode/RedeemCodeConstants.java b/easywecom-common/src/main/java/com/easywecom/common/constant/redeemcode/RedeemCodeConstants.java new file mode 100644 index 0000000..32f739b --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/constant/redeemcode/RedeemCodeConstants.java @@ -0,0 +1,77 @@ +package com.easywecom.common.constant.redeemcode; + +/** + * ClassName: Constants + * + * @author wx + * @date 2022/7/12 9:41 + */ +public class RedeemCodeConstants { + + /** + * 兑换码锁 + */ + public static String REDEEM_CODE_KEY = "redeemCode"; + + public static long CODE_WAIT_TIME = 5L; + + public static long CODE_LEASE_TIME = 5L; + + /** + * 获取兑换码活动锁,用来处理分配兑换码所引发的并发操作 + * + * @param corpId + * @param activityId + * @return + */ + public static String getRedeemCodeKey(String corpId, String activityId) { + return REDEEM_CODE_KEY + ":" + corpId + ":" + activityId; + } + + /** + * 兑换码 + */ + public static final String REDEEM_CODE = "#兑换码#"; + + /** + * 告警员工信息模板 + */ + public static final String REDEEM_CODE_ALARM_MESSAGE_INFO = "【兑换码活动库存告警提醒】\n" + + "\n" + + "兑换码活动名称:【活动名称】\n" + + "\n" + + "兑换码库存数:【库存个数】\n" + + "\n" + + "请及时前往该活动中添加库存"; + + public static final String REDEEM_CODE_ACTIVITY_NAME = "【活动名称】"; + + public static final String REDEEM_CODE_REAMIN_INVENTORY = "【库存个数】"; + + /** + * 兑换码员工告警 + */ + public static final Integer REDEEM_CODE_USER_ALARM = 1; + + /** + * 兑换码活动限制参与 + */ + public static final Integer REDEEM_CODE_ACTIVITY_LIMITED = 1; + + /** + * 兑换码已领取 + */ + public static final int REDEEM_CODE_RECEIVED = 1; + + /** + * 兑换码未领取 + */ + + public static final int REDEEM_CODE_NOT_RECEIVED = 0; + + /** + * 兑换码默认空时间 + */ + public static final String REDEEM_CODE_EMPTY_TIME = "0000-00-00"; + +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/core/domain/conversation/msgtype/MsgTypeEnum.java b/easywecom-common/src/main/java/com/easywecom/common/core/domain/conversation/msgtype/MsgTypeEnum.java index 5f86c0e..ec49db0 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/core/domain/conversation/msgtype/MsgTypeEnum.java +++ b/easywecom-common/src/main/java/com/easywecom/common/core/domain/conversation/msgtype/MsgTypeEnum.java @@ -34,6 +34,7 @@ public enum MsgTypeEnum { AGREE("agree"), DISAGREE("disagree"), LINK("link"), + RADAR("radar"), WEAPP("weapp"), VOTE("vote"), COLLECT("collect"), diff --git a/easywecom-common/src/main/java/com/easywecom/common/enums/AttachmentTypeEnum.java b/easywecom-common/src/main/java/com/easywecom/common/enums/AttachmentTypeEnum.java index b12fb03..e4ce55f 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/enums/AttachmentTypeEnum.java +++ b/easywecom-common/src/main/java/com/easywecom/common/enums/AttachmentTypeEnum.java @@ -34,8 +34,12 @@ public enum AttachmentTypeEnum { /** * 视频媒体文件素材 */ - VIDEO(5, "video"); + VIDEO(5, "video"), + /** + * 雷达链接 + */ + RADAR(7, "radar"); /** * 素材类型 @@ -107,6 +111,8 @@ public enum AttachmentTypeEnum { return LINK; case 6: return MINIPROGRAM; + case 7: + return RADAR; default: return null; } diff --git a/easywecom-common/src/main/java/com/easywecom/common/enums/CustomerTrajectoryEnums.java b/easywecom-common/src/main/java/com/easywecom/common/enums/CustomerTrajectoryEnums.java index 0bfb2b4..2af0def 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/enums/CustomerTrajectoryEnums.java +++ b/easywecom-common/src/main/java/com/easywecom/common/enums/CustomerTrajectoryEnums.java @@ -209,6 +209,7 @@ public class CustomerTrajectoryEnums { * 退出群聊 */ QUIT_GROUP("quit_group", "${customer}退出了群聊【${groupName}】"), + CLICK_RADAR("click_radar", "${customer}打开了雷达链接“${radarTitle}”"), UNKNOWN("un_known", ""), ; /** diff --git a/easywecom-common/src/main/java/com/easywecom/common/enums/GroupMessageType.java b/easywecom-common/src/main/java/com/easywecom/common/enums/GroupMessageType.java index 1707d1e..8104a90 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/enums/GroupMessageType.java +++ b/easywecom-common/src/main/java/com/easywecom/common/enums/GroupMessageType.java @@ -9,7 +9,7 @@ import java.util.Optional; import java.util.stream.Stream; /** - * 群发消息 0 图片消息 2视频 3文件 4 文本消息 5 链接消息 6 小程序消息 用逗号隔开 + * 群发消息 0 图片消息 2视频 3文件 4 文本消息 5 链接消息 6 小程序消息 7 雷达 用逗号隔开 * 注意:修改type请修改 {@link AttachmentTypeEnum#mappingFromGroupMessageType(java.lang.Integer)} */ @SuppressWarnings("all") @@ -41,8 +41,12 @@ public enum GroupMessageType { /** * 小程序消息 */ - MINIPROGRAM("6", "miniprogram"); + MINIPROGRAM("6", "miniprogram"), + /** + * 雷达消息 + */ + RADAR("7", "radar"); /** * 媒体类型 */ diff --git a/easywecom-common/src/main/java/com/easywecom/common/enums/ResultTip.java b/easywecom-common/src/main/java/com/easywecom/common/enums/ResultTip.java index 4a74b25..0d9d2b7 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/enums/ResultTip.java +++ b/easywecom-common/src/main/java/com/easywecom/common/enums/ResultTip.java @@ -21,6 +21,7 @@ public enum ResultTip { * 报表模块错误码: 6xxx * 三方错误码: 7xxx * 应用中心错误码:8xxx + * 其他第三方接口错误码: 9xxx */ //通用返回码 TIP_GENERAL_SUCCESS(200, "操作成功"), @@ -39,6 +40,17 @@ public enum ResultTip { TIP_MISS_APPID(601, "获取应用信息异常,请重新登录或联系管理员配置应用ID"), TIP_MISS_PROVIDER_CONFIG(602, "没有找到企业服务商配置"), TIP_MISS_SUITE_TICKET(603, "缺失服务商Ticket,请检查缓存或者在服务商后台重新获取"), + + TIP_NO_SHORT_CODE(604, "shortCode不能为空"), + TIP_CANNOT_FIND_PAGE(605, "找不到指定页面"), + TIP_ERROR_CREATE_SHORT_URL(606, "生成短链失败"), + + TIP_NO_MINI_APP_CONFIG(607, "没有配置小程序,请联系管理员"), + TIP_NO_OFFICAIL_ACCOUNT_CONFIG(608, "没有配置公众号配置,请联系管理员"), + + TIP_NEED_SHORT_CODE(609, "缺失code"), + TIP_CANNOT_FIND_LONG_URL(610, "找不到对应的原始链接"), + TIP_MISSING_LONG_URL (611,"缺失长链接"), TIP_NOT_CONFIG_CONTACT(1000, "所在企业未配置通讯录,请联系企业管理员登录系统并完善配置!"), TIP_NOT_AUTH_CORP(1001, "所在企业未授权当前应用,请联系企业管理员进行授权"), TIP_SERVER_NOT_SUPPORT(1002, "当前环境不支持通过该二维码登录,请联系客服或技术人员"), @@ -177,6 +189,7 @@ public enum ResultTip { TIP_AUTO_TAG_SCENE_TAG_NUM_LIMIT(4023, "最多可设置10个标签"), TIP_AUTO_TAG_MATCH_KEYWORD_NOT_BOTH_NULL(4024, "模糊匹配和精确匹配类型的关键词不能同时为空"), TIP_DELETE_TAG_NOT_PERMISSIONS(4025, "无权限操作标签,若标签不是在本系统创建,请前往企微后台操作"), + TIP_FAIL_TO_GET_CUSTOMER_INFO(4026,"无法获取客户详情"), //三方错误码 TIP_MISSING_LOGIN_INFO(7000, "所在企业未开通「壹鸽快递工单助手」,请联系管理员"), @@ -193,6 +206,14 @@ public enum ResultTip { TIP_YIGE_CHAT_BIND_ERROR(8005, "该群已绑定其它客户"), TIP_YIGE_CHAT_NOT_BIND_ERROR(8006, "该群未绑定客户"), TIP_YIGE_USER_NOT_BIND_ERROR(8007, "该员工未绑定客户"), + TIP_NO_APP_ID_CONFIG(9001, "没有配置公众号的appId"), + TIP_MISSING_USER_CODE(9002, "缺失公众号用户code"), + TIP_NO_APP_SECRET(9003,"没有配置公众号秘钥"), + TIP_WECHAT_OPEN_GET_AUTH_ERROR(9004,"获取用户授权信息异常"), + TIP_WECHAT_OPEN_OFFICIAL_NO_DOMAIN(9005,"未配置公众号域名"), + TIP_ERROR_GET_UNION_ID(9007,"获取unionId异常"), + TIP_OPEN_ID_CANNOT_BE_NULL (9008,"缺失openId"), + TIP_CANNOT_FIND_USER_BY_UNION_ID(9009,"无法通过union_id匹配到员工,请重新同步员工后再重试"), ; @Getter diff --git a/easywecom-common/src/main/java/com/easywecom/common/enums/WeCategoryMediaTypeEnum.java b/easywecom-common/src/main/java/com/easywecom/common/enums/WeCategoryMediaTypeEnum.java index f719170..7cbed5b 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/enums/WeCategoryMediaTypeEnum.java +++ b/easywecom-common/src/main/java/com/easywecom/common/enums/WeCategoryMediaTypeEnum.java @@ -20,6 +20,7 @@ public enum WeCategoryMediaTypeEnum { FILE(3, "文件"), LINK(5, "链接"), MINI_APP(6, "小程序"), + RADAR(7, "雷达") ; /** * 素材类型 diff --git a/easywecom-common/src/main/java/com/easywecom/common/enums/moment/MomentSelectUserEnum.java b/easywecom-common/src/main/java/com/easywecom/common/enums/moment/MomentSelectUserEnum.java new file mode 100644 index 0000000..21487be --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/enums/moment/MomentSelectUserEnum.java @@ -0,0 +1,32 @@ +package com.easywecom.common.enums.moment; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * ClassName: MomentSelectUserEnum + * + * @author wx + * @date 2022/7/15 15:05 + */ +@AllArgsConstructor +@Getter +public enum MomentSelectUserEnum { + /** + * 未选择员工 + */ + NOT_SELECT_USER(0, "未选择员工"), + /** + * 已选择员工 + */ + SELECT_USER(1, "已选择员工"), + ; + /** + * 状态码 + */ + public final Integer type; + /** + * 含义 + */ + private final String desc; +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/enums/radar/RadarChannelEnum.java b/easywecom-common/src/main/java/com/easywecom/common/enums/radar/RadarChannelEnum.java new file mode 100644 index 0000000..1286bf6 --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/enums/radar/RadarChannelEnum.java @@ -0,0 +1,55 @@ +package com.easywecom.common.enums.radar; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * 类名: 雷达渠道枚举 + * + * @author : silver_chariot + * @date : 2022/7/19 10:45 + **/ +@AllArgsConstructor +@Getter +public enum RadarChannelEnum { + UNKNOWN(0, "未知渠道"), + EMPLE_CODE(1, "员工活码"), + MOMENT(2, "朋友圈"), + GROUP_TASK(3, "客户群发"), + SIDE_BAR(4, "侧边栏-雷达库"), + WELCOME_MSG(5, "好友欢迎语"), + CUSTOMER_SOP(6, "客户SOP"), + GROUP_SOP(7, "群SOP"), + NEW_IN_GROUP(8, "新客进群"), + GROUP_CALENDAR(9, "群日历"), + CUSTOMIZE(10, "自定义渠道"); + private final Integer TYPE; + private final String NAME; + + /** + * 根据类型获取系统默认的渠道 + * + * @param type 类型 + * @return 渠道 + */ + public static String getChannelByType(int type) { + + RadarChannelEnum channel = Arrays.stream(values()).filter(a -> type == a.TYPE).findFirst().orElse(UNKNOWN); + return channel.NAME; + } + + /** + * 判断是否是系统默认的渠道类型 + * + * @param type 类型 + * @return true 是系统默认的渠道 false 不是 + */ + public static boolean isSysChannel(int type) { + if (type == UNKNOWN.TYPE ||type == CUSTOMIZE.TYPE) { + return false; + } + return true; + } +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/enums/radar/RadarTypeEnum.java b/easywecom-common/src/main/java/com/easywecom/common/enums/radar/RadarTypeEnum.java new file mode 100644 index 0000000..31daee6 --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/enums/radar/RadarTypeEnum.java @@ -0,0 +1,46 @@ +package com.easywecom.common.enums.radar; + +import lombok.Getter; + +import java.util.Arrays; + +/** + * ClassName: RadarTypeEnum 雷达类型 + * + * @author wx + * @date 2022/7/19 10:59 + */ + +public enum RadarTypeEnum { + + //企业 + CORP(3, "企业雷达库已更新“${radarTitle}"), + //部门 + DEPARTMENT(2, "部门雷达库已更新“${radarTitle}”"), + //个人 + SELF(1, ""), + /** + * 未知 + */ + UNKNOWN(0, ""), + + ; + @Getter + private final Integer type; + @Getter + private final String updateNotice; + + RadarTypeEnum(Integer type, String updateNotice) { + this.type = type; + this.updateNotice = updateNotice; + } + + public static RadarTypeEnum getByType(Integer type) { + if (type == null) { + return UNKNOWN; + } + return Arrays.stream(values()).filter(a -> type.equals(a.getType())).findFirst().orElse(UNKNOWN); + } + + +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/mapper/SysShortUrlMappingMapper.java b/easywecom-common/src/main/java/com/easywecom/common/mapper/SysShortUrlMappingMapper.java new file mode 100644 index 0000000..df21e16 --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/mapper/SysShortUrlMappingMapper.java @@ -0,0 +1,18 @@ +package com.easywecom.common.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.easywecom.common.shorturl.SysShortUrlMapping; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** + * 类名: 短链映射持久层接口 + * + * @author : silver_chariot + * @date : 2022/7/18 16:49 + **/ +@Mapper +@Repository +public interface SysShortUrlMappingMapper extends BaseMapper { + +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/service/ISysDeptService.java b/easywecom-common/src/main/java/com/easywecom/common/service/ISysDeptService.java index 77afe35..19db7be 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/service/ISysDeptService.java +++ b/easywecom-common/src/main/java/com/easywecom/common/service/ISysDeptService.java @@ -113,11 +113,22 @@ public interface ISysDeptService { int deleteDeptById(Long deptId); /** - * 过滤部门数据权限范围 + * 过滤部门数据权限,留下有权限的部门 * * @param list 部门集合 * @param loginUser 登录用户实体 * @return 过滤后的部门集合 */ + List filterDepartmentDataScope(List list, LoginUser loginUser); + + + /** + * 为部门设置权限标识 + * + * @param list 部门集合 + * @param loginUser 登录用户实体 + * @return 返回所有部门,在每个部门中设置权限 + */ List filterDataScope(List list, LoginUser loginUser); + } diff --git a/easywecom-common/src/main/java/com/easywecom/common/service/impl/SysDeptServiceImpl.java b/easywecom-common/src/main/java/com/easywecom/common/service/impl/SysDeptServiceImpl.java index a929348..b62c317 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/service/impl/SysDeptServiceImpl.java +++ b/easywecom-common/src/main/java/com/easywecom/common/service/impl/SysDeptServiceImpl.java @@ -312,4 +312,20 @@ public class SysDeptServiceImpl implements ISysDeptService { return list; } + /** + * 过滤部门数据权限范围 + * + * @param list 部门集合 + * @param loginUser 登录用户实体 + * @return 过滤后的部门集合 + */ + @Override + public List filterDepartmentDataScope(List list, LoginUser loginUser) { + String deptScope = loginUser.getDepartmentDataScope(); + if (StringUtils.isBlank(deptScope)) { + return list; + } + List deptScopeList = Arrays.asList(deptScope.split(",")); + return list.stream().filter(item -> inDeptScope(deptScopeList, item.getId())).collect(Collectors.toList()); + } } diff --git a/easywecom-common/src/main/java/com/easywecom/common/shorturl/ShortUrlAppendInfo.java b/easywecom-common/src/main/java/com/easywecom/common/shorturl/ShortUrlAppendInfo.java new file mode 100644 index 0000000..5e5d5ab --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/shorturl/ShortUrlAppendInfo.java @@ -0,0 +1,42 @@ +package com.easywecom.common.shorturl; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 类名: 短链附加信息 + * + * @author : silver_chariot + * @date : 2022/7/21 11:40 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ShortUrlAppendInfo { + /** + * 使用雷达的员工id + */ + private String userId; + /** + * 雷达id + */ + private Long radarId; + /** + * 渠道id ,如果是系统默认的渠道使用{@link com.easywecom.common.enums.radar.RadarChannelEnum} + */ + private Integer channelType; + + /** + * 详情(如果是员工活码,则为员工活码使用场景,如果是新客进群则为新客进群的活码名称,如果是SOP则为SOP名称,如果是群日历,则为日历名称,如果是自定义渠道则为自定义渠道的渠道名) + */ + private String detail; + /** + * 企业id ( 主要用于获取appid配置,如果后续改成后端直接跳转则可去除) + */ + private String corpId; + + +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/shorturl/SysShortUrlMapping.java b/easywecom-common/src/main/java/com/easywecom/common/shorturl/SysShortUrlMapping.java new file mode 100644 index 0000000..9ad705a --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/shorturl/SysShortUrlMapping.java @@ -0,0 +1,75 @@ +package com.easywecom.common.shorturl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.util.Date; + +/** + * 类名: 短链长链映射实体 + * + * @author : silver_chariot + * @date : 2022/7/18 16:41 + **/ +@Data +@ApiModel("长链-短链映射表实体") +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class SysShortUrlMapping { + @TableField("id") + @ApiModelProperty(value = "id,短链 ") + private Long id; + + @TableField("short_code") + @ApiModelProperty(value = "短链后面的唯一字符串(用于和域名拼接成短链) ") + private String shortCode; + + @TableField("long_url") + @ApiModelProperty(value = "原链接(长链接) ") + private String longUrl; + + @TableField("append_info") + @ApiModelProperty(value = "附加信息") + private String appendInfo; + + @TableField("create_time") + @ApiModelProperty(value = "创建时间 ") + private Date createTime; + + @TableField("create_by") + @ApiModelProperty(value = "创建人 ") + private String createBy; + + /** + * 设置附加信息 + * + * @param appendInfo 附加信息 实体{@link ShortUrlAppendInfo} + */ + public void setAppend(ShortUrlAppendInfo appendInfo) { + if (appendInfo != null) { + this.appendInfo = JSON.toJSONString(appendInfo); + } + } + + /** + * 获取附加信息 + * + * @return 附件信息 {@link ShortUrlAppendInfo } + */ + public ShortUrlAppendInfo getAppend() { + if (StringUtils.isBlank(this.appendInfo)) { + return null; + } + return JSON.parseObject(this.appendInfo, ShortUrlAppendInfo.class); + } + + +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/shorturl/service/ShortUrlAdaptor.java b/easywecom-common/src/main/java/com/easywecom/common/shorturl/service/ShortUrlAdaptor.java new file mode 100644 index 0000000..a8160d8 --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/shorturl/service/ShortUrlAdaptor.java @@ -0,0 +1,93 @@ +package com.easywecom.common.shorturl.service; + +import com.easywecom.common.constant.WeConstans; +import com.easywecom.common.shorturl.ShortUrlAppendInfo; +import com.easywecom.common.shorturl.SysShortUrlMapping; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * 类名: 短链服务适配器 (对应业务继承后 可依据自身业务实现创建短链和获取长链) + * + * @author : silver_chariot + * @date : 2022/7/19 17:50 + **/ +@Component("shortUrlAdaptor") +public class ShortUrlAdaptor { + + @Resource(name = "shortUrlService") + private ShortUrlService shortUrlService; + + /** + * 创建短链 + * + * @param longUrl 长链接 + * @param createBy 创建人,如果是员工则是userId,管理员为admin + * @return 短链接 + */ + public String createShortCode(String longUrl, String createBy) { + return shortUrlService.createShortCode(longUrl, createBy, null); + } + + /** + * 创建短链 + * + * @param longUrl 长链接 + * @param createBy 创建人,如果是员工则是userId,管理员为admin + * @param appendInfo 附件信息{@link ShortUrlAppendInfo} + * @return 短链接 + */ + public String createShortCode(String longUrl, String createBy, ShortUrlAppendInfo appendInfo) { + return shortUrlService.createShortCode(longUrl, createBy, appendInfo); + } + + /** + * 创建短链 + * + * @param longUrl 长链接 + * @return 短链接 + */ + public String createShortCode(String longUrl) { + return shortUrlService.createShortCode(longUrl, "admin", null); + + } + + /** + * 根据短链后面的字符串 获取其原有的长链接映射详情 + * + * @param shortCode 短链接后面的字符串 + * @return 对应的原有的长链接映射 {@link SysShortUrlMapping } + */ + public SysShortUrlMapping getLongUrlMapping(String shortCode) { + return shortUrlService.getUrlByMapping(shortCode); + } + + /** + * 根据短链后面的字符串 获取其原有的长链接 + * + * @param shortCode 短链接后面的字符串 + * @return 对应的原有的长链接 + */ + public String getLongUrl(String shortCode) { + SysShortUrlMapping mapping = getLongUrlMapping(shortCode); + if (mapping != null && StringUtils.isNotBlank(mapping.getLongUrl())) { + return mapping.getLongUrl(); + } + return null; + } + + /** + * 生成完整的短链 + * + * @param domain 域名 + * @param code 短链后缀的字符串 + * @return 完整的短链 + */ + public String genShortUrl(String domain, String code) { + return domain + WeConstans.SLASH + code; + } + + +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/shorturl/service/ShortUrlService.java b/easywecom-common/src/main/java/com/easywecom/common/shorturl/service/ShortUrlService.java new file mode 100644 index 0000000..5e9522d --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/shorturl/service/ShortUrlService.java @@ -0,0 +1,30 @@ +package com.easywecom.common.shorturl.service; + +import com.easywecom.common.shorturl.ShortUrlAppendInfo; +import com.easywecom.common.shorturl.SysShortUrlMapping; + +/** + * 类名: 短链处理接口 + * + * @author : silver_chariot + * @date : 2022/7/18 16:42 + **/ +public interface ShortUrlService { + /** + * 创建短链 + * + * @param longUrl 长链接 + * @param createBy 创建人,如果是员工则是userId,管理员为admin + * @param appendInfo 附加信息(用于埋点,非必传) {@link ShortUrlAppendInfo } + * @return 短链接 + */ + String createShortCode(String longUrl, String createBy, ShortUrlAppendInfo appendInfo); + + /** + * 根据短链后面的字符串 获取其原有的长链接 + * + * @param shortCode 短链接后面的字符串 + * @return 对应的原有的长链接 + */ + SysShortUrlMapping getUrlByMapping(String shortCode); +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/shorturl/service/impl/ShortUrlServiceImpl.java b/easywecom-common/src/main/java/com/easywecom/common/shorturl/service/impl/ShortUrlServiceImpl.java new file mode 100644 index 0000000..f2301a9 --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/shorturl/service/impl/ShortUrlServiceImpl.java @@ -0,0 +1,137 @@ +package com.easywecom.common.shorturl.service.impl; + +import cn.hutool.bloomfilter.BitMapBloomFilter; +import cn.hutool.bloomfilter.BloomFilterUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.easywecom.common.constant.GenConstants; +import com.easywecom.common.core.redis.RedisCache; +import com.easywecom.common.enums.ResultTip; +import com.easywecom.common.exception.CustomException; +import com.easywecom.common.mapper.SysShortUrlMappingMapper; +import com.easywecom.common.shorturl.ShortUrlAppendInfo; +import com.easywecom.common.shorturl.SysShortUrlMapping; +import com.easywecom.common.shorturl.service.ShortUrlService; +import com.easywecom.common.utils.ConvertUrlUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.concurrent.TimeUnit; + +/** + * 类名: 短链处理接口实现类 + * + * @author : silver_chariot + * @date : 2022/7/18 16:43 + **/ +@Service("shortUrlService") +@Slf4j +public class ShortUrlServiceImpl implements ShortUrlService { + + private final SysShortUrlMappingMapper sysShortUrlMappingMapper; + private final RedisCache redisCache; + /** + * 布隆过滤器 + */ + private static final BitMapBloomFilter BLOOM_FILTER = BloomFilterUtil.createBitMap(16); + /** + * 存储短链长链的redis映射 + */ + private static final String SHORT_URL_REDIS_KEY = "shortUrl:"; + /** + * 如果已有重复的短链code,给长链接拼接额外字符再生成code所需要增加的字符串 + */ + private final static String DUPLICATE_SUB = "*"; + /** + * 缓存存储时间 单位分钟 + */ + private final static int REDIS_TIME_OUT = 2; + + public ShortUrlServiceImpl(SysShortUrlMappingMapper sysShortUrlMappingMapper, RedisCache redisCache) { + this.sysShortUrlMappingMapper = sysShortUrlMappingMapper; + this.redisCache = redisCache; + } + + @Override + public String createShortCode(String longUrl, String createBy, ShortUrlAppendInfo appendInfo) { + if (StringUtils.isBlank(longUrl)) { + log.info("[创建短链]长连接为空,创建失败 "); + return null; + } + String code = null; + // 用于生成短链的长链url,由于生成的短链可能重复,如果重复则需要添加占位符后重新生成 + String genLongUrl = BLOOM_FILTER.contains(longUrl) ? longUrl + DUPLICATE_SUB : longUrl; + boolean success = false; + do { + try { + // 生成短链的code + code = ConvertUrlUtil.getShortCode(genLongUrl); + // 保存映射 + SysShortUrlMapping mapping = SysShortUrlMapping.builder().shortCode(code).longUrl(longUrl).createBy(createBy).createTime(new Date()).build(); + mapping.setAppend(appendInfo); + success = sysShortUrlMappingMapper.insert(mapping) > 0; + // 增加至布隆过滤器 + BLOOM_FILTER.add(code); + log.info("[创建短链]创建成功,longUrl:{},shortCode:{},createBy:{}", longUrl, code, createBy); + } catch (DuplicateKeyException e) { + log.error("[创建短链]生成的code,db中已有重复的,重新生成,url:{},code:{}", longUrl, code); + genLongUrl = genLongUrl + DUPLICATE_SUB; + } catch (Exception e) { + log.error("[创建短链]生成短链异常,url:{},e:{}", longUrl, ExceptionUtils.getStackTrace(e)); + throw new CustomException(ResultTip.TIP_ERROR_CREATE_SHORT_URL); + } + } while (!success); + return code; + } + + public static void main(String[] args) { + String url = "http://lianluoyi.net?id=1314515&type=23&channel=1&userId=1414151faafa&faf=raewtatoraewt&ids=1414151515135515"; + String code = ConvertUrlUtil.getShortCode(url); + System.out.println(code); + + String test = "测试"; + String str = String.format("jkhaod1是的1dfag%s", test); + System.out.println(str); + + } + + @Override + public SysShortUrlMapping getUrlByMapping(String shortCode) { + if (StringUtils.isBlank(shortCode)) { + log.info("[获取长链]短链接code为空,获取失败"); + throw new CustomException(ResultTip.TIP_NO_SHORT_CODE); + } + // 先从缓存获取 + String redisKey = getRedisKey(shortCode); + String cacheMappingStr = redisCache.getCacheObject(redisKey); + if (StringUtils.isNotBlank(cacheMappingStr)) { + SysShortUrlMapping cacheMapping = JSON.parseObject(cacheMappingStr, SysShortUrlMapping.class); + redisCache.expire(redisKey, REDIS_TIME_OUT, TimeUnit.MINUTES); + log.info("[获取长链]缓存中获取成功code:{},mapping:{}", shortCode, cacheMapping); + return cacheMapping; + } + // 查询db中的映射 + SysShortUrlMapping mapping = sysShortUrlMappingMapper.selectOne(new LambdaQueryWrapper().eq(SysShortUrlMapping::getShortCode, shortCode).last(GenConstants.LIMIT_1)); + if (mapping == null || StringUtils.isBlank(mapping.getLongUrl())) { + throw new CustomException(ResultTip.TIP_CANNOT_FIND_PAGE); + } + // 缓存并返回 + redisCache.setCacheObject(redisKey, JSON.toJSONString(mapping), REDIS_TIME_OUT, TimeUnit.MINUTES); + log.info("[获取长链]获取成功code:{},mapping:{}", shortCode, mapping); + return mapping; + } + + /** + * redis获取 + * + * @param shortCode 短链code + * @return 获取长链的 redisKey + */ + public String getRedisKey(String shortCode) { + return SHORT_URL_REDIS_KEY + shortCode; + } +} diff --git a/easywecom-common/src/main/java/com/easywecom/common/utils/ConvertUrlUtil.java b/easywecom-common/src/main/java/com/easywecom/common/utils/ConvertUrlUtil.java new file mode 100644 index 0000000..e3dd3db --- /dev/null +++ b/easywecom-common/src/main/java/com/easywecom/common/utils/ConvertUrlUtil.java @@ -0,0 +1,71 @@ +package com.easywecom.common.utils; + +import cn.hutool.core.lang.hash.MurmurHash; + +/** + * 类名: 短链转换工具 + * + * @author : silver_chariot + * @date : 2022/7/18 18:10 + **/ + +public class ConvertUrlUtil { + + private static final char[] CHARS = new char[]{ + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' + }; + private static final int SIZE = CHARS.length; + /** + * 短链code长度 + */ + private static final int CODE_SIZE = 6; + /** + * 占位符 + */ + private static final char SUB = '0'; + + /** + * 转62进制 + * + * @param num 数字 + * @return 62进制字符 + */ + private static String convert2Base62(long num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + int i = (int) (num % SIZE); + sb.append(CHARS[i]); + num /= SIZE; + } + return sb.reverse().toString(); + } + + /** + * 字符串 转成 base62 (先通过murhash 再转 62进制) + * + * @param str 字符串 + * @return base62进制字符 + */ + public static String url2hash2Base62(String str) { + int i = MurmurHash.hash32(str); + long num = i < 0 ? Integer.MAX_VALUE - (long) i : i; + return convert2Base62(num); + } + + /** + * 根据长链获取短链code + * + * @param str 长链 + * @return 短链code + */ + public static String getShortCode(String str) { + String code = url2hash2Base62(str); + return StringUtils.leftPad(code, CODE_SIZE, SUB); + + } + +} + + diff --git a/easywecom-common/src/main/java/com/easywecom/common/utils/DateUtils.java b/easywecom-common/src/main/java/com/easywecom/common/utils/DateUtils.java index 09118d1..ee2cf31 100644 --- a/easywecom-common/src/main/java/com/easywecom/common/utils/DateUtils.java +++ b/easywecom-common/src/main/java/com/easywecom/common/utils/DateUtils.java @@ -424,7 +424,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { //使用给定的 Date 设置此 Calendar 的时间。 rightNow.setTime(date); // 日期减 - rightNow.add(Calendar.MONTH, -subDay); + rightNow.add(Calendar.DAY_OF_YEAR, -subDay); //返回一个表示此 Calendar 时间值的 Date 对象。 return rightNow.getTime(); } diff --git a/easywecom-common/src/main/resources/mapper/system/SysShortUrlMappingMapper.xml b/easywecom-common/src/main/resources/mapper/system/SysShortUrlMappingMapper.xml new file mode 100644 index 0000000..7b1ac3e --- /dev/null +++ b/easywecom-common/src/main/resources/mapper/system/SysShortUrlMappingMapper.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/easywecom-quartz/src/main/java/com/easywecom/quartz/task/WeOperationsCenterSopTask.java b/easywecom-quartz/src/main/java/com/easywecom/quartz/task/WeOperationsCenterSopTask.java index 010d83a..c2b836e 100644 --- a/easywecom-quartz/src/main/java/com/easywecom/quartz/task/WeOperationsCenterSopTask.java +++ b/easywecom-quartz/src/main/java/com/easywecom/quartz/task/WeOperationsCenterSopTask.java @@ -5,20 +5,23 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.dtflys.forest.exceptions.ForestRuntimeException; import com.easywecom.common.constant.GenConstants; -import com.easywecom.common.enums.CommunityTaskType; -import com.easywecom.common.enums.CustomerTrajectoryEnums; -import com.easywecom.common.enums.ResultTip; -import com.easywecom.common.enums.WeOperationsCenterSop; +import com.easywecom.common.enums.*; +import com.easywecom.common.enums.radar.RadarChannelEnum; import com.easywecom.common.exception.CustomException; import com.easywecom.common.utils.DateUtils; import com.easywecom.common.utils.SnowFlakeUtil; +import com.easywecom.common.utils.spring.SpringUtils; import com.easywecom.wecom.domain.*; +import com.easywecom.wecom.domain.dto.common.AttachmentParam; import com.easywecom.wecom.domain.vo.sop.SopAttachmentVO; import com.easywecom.wecom.domain.vo.sop.WeSopUserIdAndTargetIdVO; import com.easywecom.wecom.service.*; +import com.easywecom.wecom.service.radar.WeRadarChannelService; +import com.easywecom.wecom.service.radar.WeRadarService; import com.easywecom.wecom.utils.ApplicationMessageUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.BeanUtils; @@ -134,7 +137,7 @@ public class WeOperationsCenterSopTask { return; } //3、满足规则的客户,加入执行任务 - executeGroupSopTask(sopType, content, sopEntity.getName(), corpId, sopId, customerList, sopRules, nowDate); + executeGroupSopTask(sopType, content, sopEntity.getName(), corpId, sopId, customerList, sopRules, nowDate, RadarChannelEnum.CUSTOMER_SOP.getTYPE()); } /** @@ -191,7 +194,11 @@ public class WeOperationsCenterSopTask { return; } //3、满足规则的客户,加入执行任务 - executeGroupSopTask(sopType,content, sopEntity.getName(), corpId, sopId, groupSopScopeList, sopRules, nowDate); + if (GROUP_CALENDAR.getSopType().equals(sopType)) { + executeGroupSopTask(sopType, content, sopEntity.getName(), corpId, sopId, groupSopScopeList, sopRules, nowDate, RadarChannelEnum.GROUP_CALENDAR.getTYPE()); + } else { + executeGroupSopTask(sopType, content, sopEntity.getName(), corpId, sopId, groupSopScopeList, sopRules, nowDate, RadarChannelEnum.GROUP_SOP.getTYPE()); + } } /** @@ -206,7 +213,7 @@ public class WeOperationsCenterSopTask { * @param sopRules sop规则 * @param nowDate 当前时间 */ - private void executeGroupSopTask(Integer sopType, String content, String name, String corpId, Long sopId, List groupSopScopeList, List sopRules, Date nowDate) { + private void executeGroupSopTask(Integer sopType, String content, String name, String corpId, Long sopId, List groupSopScopeList, List sopRules, Date nowDate, int radarChannelType) { if (StringUtils.isBlank(corpId) || sopId == null || CollectionUtils.isEmpty(groupSopScopeList) || CollectionUtils.isEmpty(sopRules)) { log.error("weOperationsCenterSopTask.executeGroupSopTask 数据为空!不再继续执行.corpId={},sopId={},groupSopScopeList={},sopRules={}", corpId, sopId, JSONObject.toJSONString(groupSopScopeList), JSONObject.toJSONString(sopRules)); return; @@ -259,35 +266,63 @@ public class WeOperationsCenterSopTask { if (CollectionUtils.isNotEmpty(detailList)) { sopDetailService.saveBatch(detailList); } - saveSopTask(detailList, corpId, saveRuleNameMap); + saveSopTask(detailList, corpId, saveRuleNameMap, radarChannelType); } /** * 保存sop待办任务 - * @param detailList 任务详情 - * @param corpId 企业id + * + * @param detailList 任务详情 + * @param corpId 企业id * @param saveRuleNameMap 规则名称对应map + * @param channelType 对应雷达渠道的SOP type */ - private void saveSopTask(List detailList, String corpId, Map saveRuleNameMap) { + private void saveSopTask(List detailList, String corpId, Map saveRuleNameMap, int channelType) { for (WeOperationsCenterSopDetailEntity sopDetailEntity : detailList) { List taskEntityList = new ArrayList<>(); List sopAttachmentVos = weWordsDetailService.listOfRuleId(sopDetailEntity.getRuleId()); - sopAttachmentVos.forEach(sopAttachmentVO -> { + String userId = sopDetailEntity.getUserId(); + final String sopRuleName = saveRuleNameMap.get(userId + sopDetailEntity.getRuleId()); + for (SopAttachmentVO sopAttachmentVO : sopAttachmentVos) { WeOperationsCenterSopTaskEntity sopTask = new WeOperationsCenterSopTaskEntity(); + if (AttachmentTypeEnum.RADAR.getMessageType().equals(sopAttachmentVO.getMediaType())) { + buildRadarAttachment(sopAttachmentVO, channelType, userId, corpId, sopRuleName); + } BeanUtils.copyProperties(sopAttachmentVO, sopTask); sopTask.setId(SnowFlakeUtil.nextId()); taskEntityList.add(sopTask); - }); + } if (CollectionUtils.isNotEmpty(taskEntityList)) { sopTaskService.saveBatch(taskEntityList); - String userId = sopDetailEntity.getUserId(); //插入客户轨迹待办消息 List taskIds = taskEntityList.stream().filter(task -> task.getId() != null).map(task -> task.getId().toString()).collect(Collectors.toList()); - saveCustomerTrajectorySopTask(sopDetailEntity.getAlertTime(),saveRuleNameMap.get(userId+sopDetailEntity.getRuleId()), corpId, sopDetailEntity.getId(), String.join(StrUtil.COMMA, taskIds), userId,sopDetailEntity.getTargetId()); + saveCustomerTrajectorySopTask(sopDetailEntity.getAlertTime(), saveRuleNameMap.get(userId + sopDetailEntity.getRuleId()), corpId, sopDetailEntity.getId(), String.join(StrUtil.COMMA, taskIds), userId, sopDetailEntity.getTargetId()); } } } + + /** + * 构建雷达附件 + * + * @param sopAttachmentVO + * @param channelType + * @param userId + * @param corpId + * @param sopRuleName + */ + private void buildRadarAttachment(SopAttachmentVO sopAttachmentVO, int channelType, String userId, String corpId, String sopRuleName) { + final AttachmentParam radarAttachment = SpringUtils.getBean(WeRadarService.class).getRadarShortUrl(sopAttachmentVO.getRadarId(), channelType, userId, corpId, sopRuleName); + if (ObjectUtils.isEmpty(radarAttachment)) { + return; + } + sopAttachmentVO.setTitle(radarAttachment.getContent()); + sopAttachmentVO.setContent(radarAttachment.getDescription()); + sopAttachmentVO.setCoverUrl(radarAttachment.getPicUrl()); + sopAttachmentVO.setUrl(radarAttachment.getUrl()); + sopAttachmentVO.setMediaType(WeCategoryMediaTypeEnum.LINK.getMediaType()); + } + /** * 插入客户轨迹待办消息 * @param alertTime diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/client/WeCustomerClient.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/client/WeCustomerClient.java index 08c2fc3..c6b545c 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/client/WeCustomerClient.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/client/WeCustomerClient.java @@ -7,6 +7,8 @@ import com.easywecom.wecom.domain.dto.customer.req.GetByUserReq; import com.easywecom.wecom.domain.dto.customer.resp.GetByUserResp; import com.easywecom.wecom.domain.query.GroupChatStatisticQuery; import com.easywecom.wecom.domain.query.UserBehaviorDataQuery; +import com.easywecom.wecom.domain.req.UnionId2ExternalUserIdReq; +import com.easywecom.wecom.domain.resp.UnionId2ExternalUserIdResp; import com.easywecom.wecom.interceptor.WeAccessTokenInterceptor; import org.springframework.stereotype.Component; @@ -118,4 +120,8 @@ public interface WeCustomerClient { */ @Post(url = "/externalcontact/groupchat/statistic_group_by_day") GroupChatStatisticDTO getGroupChatStatisticGroupByDay(@JSONBody GroupChatStatisticQuery query, @Header("corpid") String corpId); + + + @Post("/externalcontact/unionid_to_external_userid") + UnionId2ExternalUserIdResp unionId2ExternalUserId (@Body("unionid")String unionid ,@Body("openid")String openid) ; } diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/client/WeExternalContactClient.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/client/WeExternalContactClient.java index b7d9790..6bc3ad2 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/client/WeExternalContactClient.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/client/WeExternalContactClient.java @@ -88,4 +88,6 @@ public interface WeExternalContactClient { */ @Post(url = "/externalcontact/groupchat/transfer") TransferResignedGroupChatResp transferResignedGroup(@Body TransferResignedGroupChatReq req, @Header("corpId") String corpId); + + } diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/client/WechatOpenClient.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/client/WechatOpenClient.java new file mode 100644 index 0000000..31635ae --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/client/WechatOpenClient.java @@ -0,0 +1,81 @@ +package com.easywecom.wecom.client; + +import com.dtflys.forest.annotation.*; +import com.easywecom.wecom.domain.req.GenerateUrlLinkReq; +import com.easywecom.wecom.domain.resp.*; +import com.easywecom.wecom.interceptor.WechatOpenInterceptor; +import org.springframework.stereotype.Component; + +/** + * 类名: 公众号请求客户端 + * + * @author : silver_chariot + * @date : 2022/7/20 10:38 + **/ +@Component +@BaseRequest(baseURL = "https://api.weixin.qq.com", interceptor = WechatOpenInterceptor.class) +public interface WechatOpenClient { + /** + * 【公众号】获取用户授权信息 + * + * @param appId 公众号appid + * @param secret 公众号secret + * @param code 前端传来的code + * @param grantType 默认值 authorization_code + * @param corpId + * @return {@link GetOfficialAuthInfoResp} + */ + @Get("/sns/oauth2/access_token") + GetOfficialAuthInfoResp getAuthInfo(@Query("appid") String appId, @Query("secret") String secret, @Query("code") String code, @Query("grant_type") String grantType,@Header("corpId") String corpId); + + + + + + /** + * 【小程序】生成小程序的跳转链接 + * + * @param req 请求{@link GenerateUrlLinkReq} + * @return {@link GenerateUrlLinkResp } + */ + @Post("/wxa/generate_urllink") + GenerateUrlLinkResp generateUrlLink(@Body GenerateUrlLinkReq req); + + /** + * 【小程序】 获取accessToken + * + * @param grant_type 填写 client_credential + * @param appid 小程序唯一凭证,即 AppID,可在「微信公众平台 - 设置 - 开发设置」页中获得。(需要已经成为开发者,且帐号没有异常状态) + * @param secret 小程序唯一凭证密钥,即 AppSecret,获取方式同 appid + * @return {@link GetAccessTokenResp} + */ + + @Get("/cgi-bin/token") + GetAccessTokenResp getAccessToken(@Query("grant_type") String grant_type, + @Query("appid") String appid, + @Query("secret") String secret); + + /** + * 【公众号】获取unionId详情 + * + * @param openid 用户公众号openid + * @param lang 语言 国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语 + * @return {@link GetUnionUserInfoResp } + */ + @Get("/cgi-bin/user/info") + GetUnionUserInfoResp getUnionUserInfo(@Query("openid") String openid, @Query("lang") String lang); + + /** + * 网页链接获取用户信息 (unionid )_ + * + * @param accessToken accessToken 由接口 {@link WechatOpenClient#getAccessToken(String, String, String) 返回的accessToken 与全局的accessToken不同 } + * @param openId openId + * @param lang 语言 + * @return {@link SnsUserInfoResp } + */ + @Get("/sns/userinfo") + SnsUserInfoResp snsUserInfo(@Query("access_token") String accessToken, + @Query("openid") String openId, + @Query("lang") String lang); + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateLeaveUserResp.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateLeaveUserResp.java deleted file mode 100644 index 0cbdccb..0000000 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateLeaveUserResp.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.easywecom.wecom.domain; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; - -import java.util.List; - -/** - * 类名: AllocateLeaveUserRESP - * - * @author 佚名 - * @date 2021/10/8 19:15 - */ -@Data -@Builder -@AllArgsConstructor -@ApiModel("离职分配结果") -public class AllocateLeaveUserResp { - - @ApiModelProperty("客户分配成功数量") - private Integer weCustomerSucceedNum; - - @ApiModelProperty("客户分配失败数量") - private Integer weCustomerFailNum; - - @ApiModelProperty("客户群分配成功数量") - private Integer weGroupSucceedNum; - - @ApiModelProperty("客户群分配失败数量") - private Integer weGroupFailNum; - - @ApiModelProperty("员工客户群今日分配已达上限员工列表") - private List list; - - public AllocateLeaveUserResp(AllocateWeCustomerResp allocateWeCustomerRESP, AllocateWeGroupResp resp) { - this.weCustomerFailNum = allocateWeCustomerRESP.getFailNum(); - this.weCustomerSucceedNum = allocateWeCustomerRESP.getSucceedNum(); - this.weGroupFailNum = resp.getFailNum(); - this.weGroupSucceedNum = resp.getSucceedNum(); - this.list = resp.getList(); - } -} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateWeCustomerResp.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateWeCustomerResp.java deleted file mode 100644 index 047d66c..0000000 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateWeCustomerResp.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.easywecom.wecom.domain; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; - -/** - * 类名: AllocateWeCustomerRESP - * - * @author 佚名 - * @date 2021/10/8 19:16 - */ -@Data -@Builder -@AllArgsConstructor -@ApiModel("分配群聊结果") -public class AllocateWeCustomerResp { - /** - * 成功数量 - */ - @ApiModelProperty("成功数量") - private Integer succeedNum; - /** - * 失败数量 - */ - @ApiModelProperty("失败数量") - private Integer failNum; - - - @ApiModelProperty("待分配数量") - private Integer allocateNum; - - public AllocateWeCustomerResp() { - this.succeedNum = 0; - this.failNum = 0; - } -} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateWeGroupResp.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateWeGroupResp.java deleted file mode 100644 index 6d94060..0000000 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/AllocateWeGroupResp.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.easywecom.wecom.domain; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; - -import java.util.ArrayList; -import java.util.List; - -/** - * 类名: AllocateWeGroupRESP - * - * @author 佚名 - * @date 2021/10/8 19:15 - */ -@Data -@Builder -@AllArgsConstructor -@ApiModel("分配单个群聊结果") -public class AllocateWeGroupResp { - - @ApiModelProperty("成功数量") - private Integer succeedNum; - - @ApiModelProperty("失败数量") - private Integer failNum; - - @ApiModelProperty("员工客户群今日分配已达上限员工列表") - private List list; - - @ApiModelProperty("待分配数量") - private Integer allocateNum; - - public AllocateWeGroupResp() { - this.succeedNum = 0; - this.failNum = 0; - this.list = new ArrayList<>(); - } -} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeCustomerSeedMessage.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeCustomerSeedMessage.java index 8bde86c..73378a4 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeCustomerSeedMessage.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeCustomerSeedMessage.java @@ -111,4 +111,8 @@ public class WeCustomerSeedMessage extends BaseEntity { @TableField("seed_message_id") private Long seedMessageId; + @ApiModelProperty(value = "雷达id") + @TableField("radar_id") + private Long radarId; + } diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeEmpleCode.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeEmpleCode.java index 8657946..21de274 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeEmpleCode.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeEmpleCode.java @@ -186,6 +186,11 @@ public class WeEmpleCode extends BaseEntity { private List codeRepeatMaterialList; + @ApiModelProperty(value = "小程序活码短链url") + @TableField("app_link") + private String appLink; + + public void buildCodeMsg() { this.codeSuccessMsg = Optional.ofNullable(this.codeSuccessMsg).orElseGet(() -> StringUtils.EMPTY); this.codeSuccessMaterialSort = Optional.ofNullable(codeSuccessMaterialSort).orElseGet(() -> new String[]{}); diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeMaterial.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeMaterial.java index 1ddbf7b..650f043 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeMaterial.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeMaterial.java @@ -63,7 +63,6 @@ public class WeMaterial extends BaseEntity { @TableField("audio_time") private String audioTime; - @ApiModelProperty(value = "过期时间") @TableField("expire_time") private String expireTime; @@ -80,4 +79,11 @@ public class WeMaterial extends BaseEntity { @TableField("is_defined") private Boolean isDefined; + @ApiModelProperty(value = "链接时使用(0,不转化为雷达,1:转化为雷达)") + @TableField("enable_convert_radar") + private Boolean enableConvertRadar; + + @ApiModelProperty(value = "保存雷达时使用,使用员工活码,新客进群时") + @TableField("radar_id") + private Long radarId; } diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeMsgTlpMaterial.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeMsgTlpMaterial.java index 89c59c9..0a1d094 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeMsgTlpMaterial.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeMsgTlpMaterial.java @@ -8,6 +8,7 @@ import com.easywecom.common.constant.WeConstans; import com.easywecom.common.enums.AttachmentTypeEnum; import com.easywecom.common.enums.ResultTip; import com.easywecom.common.exception.CustomException; +import com.easywecom.wecom.domain.vo.radar.WeRadarVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; @@ -31,7 +32,6 @@ import org.springframework.util.ObjectUtils; @ApiModel("欢迎语素材表") public class WeMsgTlpMaterial { - @ApiModelProperty(value = "主键id", hidden = true) @TableId(type = IdType.AUTO) @TableField("id") @@ -45,7 +45,7 @@ public class WeMsgTlpMaterial { @TableField("special_msg_id") private Long specialMsgId; - @ApiModelProperty(value = "素材类型 0:文本 1:图片 2:链接 3:小程序 4:文件 5:视频媒体文件") + @ApiModelProperty(value = "素材类型 0:文本 1:图片 2:链接 3:小程序 4:文件 5:视频媒体文件, 7:雷达") @TableField("type") private Integer type; @@ -69,6 +69,13 @@ public class WeMsgTlpMaterial { @TableField("sort_no") private Integer sortNo; + @ApiModelProperty(value = "雷达id,存储雷达时使用") + @TableField("radar_id") + private Long radarId; + + @ApiModelProperty(value = "雷达VO") + @TableField(exist = false) + private WeRadarVO radar; public WeMsgTlpMaterial(Integer type, String content) { this.type = type; @@ -100,6 +107,10 @@ public class WeMsgTlpMaterial { if (checkNotEmpty(this.content, this.picUrl, this.description, this.url)) { break; } + case RADAR: + if (!ObjectUtils.isEmpty(this.radarId)) { + break; + } case MINIPROGRAM: if (checkNotEmpty(this.content, this.picUrl, this.description, this.url)) { break; diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeWordsDetailEntity.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeWordsDetailEntity.java index 5adb25c..31456dd 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeWordsDetailEntity.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/WeWordsDetailEntity.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.easywecom.common.constant.WeConstans; import com.easywecom.common.enums.GroupMessageType; import com.easywecom.common.utils.spring.SpringUtils; +import com.easywecom.wecom.domain.vo.radar.WeRadarVO; import com.easywecom.wecom.service.WeCustomerMessageService; import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModel; @@ -51,7 +52,7 @@ public class WeWordsDetailEntity { /** * 0:海报,1:语音,2:视频,3:普通文件,4:文本,5:图文链接,6:小程序 */ - @ApiModelProperty(value = "0:海报,1:语音,2:视频,3:普通文件,4:文本,5:图文链接,6:小程序",required = true) + @ApiModelProperty(value = "0:海报,1:语音,2:视频,3:普通文件,4:文本,5:图文链接,6:小程序,7:雷达", required = true) @TableField("media_type") @NotNull private Integer mediaType; @@ -94,6 +95,13 @@ public class WeWordsDetailEntity { @TableField(exist = false) private String mediaid; + @ApiModelProperty("雷达id") + @TableField("radar_id") + private Long radarId; + + @ApiModelProperty("雷达VO") + @TableField(exist = false) + private WeRadarVO radar; public WeWordsDetailEntity(String corpId, Integer mediaType, String content) { this.corpId = corpId; @@ -101,7 +109,7 @@ public class WeWordsDetailEntity { this.content = content; } - public void initMediaId(String corpId){ + public void initMediaId(String corpId) { WeCustomerMessageService weCustomerMessageService = SpringUtils.getBean(WeCustomerMessageService.class); if (GroupMessageType.IMAGE.getType().equals(this.getMediaType().toString())) { String mediaId = weCustomerMessageService.buildMediaId(this.getUrl(), GroupMessageType.IMAGE.getMessageType(), this.getTitle(), corpId); diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/AddWeMaterialDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/AddWeMaterialDTO.java index 0602657..b119744 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/AddWeMaterialDTO.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/AddWeMaterialDTO.java @@ -1,6 +1,8 @@ package com.easywecom.wecom.domain.dto; import com.easywecom.wecom.domain.WeMaterial; +import com.easywecom.wecom.domain.dto.radar.RadarDTO; +import com.easywecom.wecom.domain.vo.radar.WeRadarVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -21,10 +23,13 @@ public class AddWeMaterialDTO extends WeMaterial { /** * WeCategoryMediaTypeEnum */ - @ApiModelProperty(value = "素材类型:0海报、1语音、2视频、3普通文件、4文本、5链接、6小程序", required = true) + @ApiModelProperty(value = "素材类型:0海报、1语音、2视频、3普通文件、4文本、5链接、6小程序、7雷达", required = true) @NotNull(message = "mediaType不能为空") private Integer mediaType; @ApiModelProperty(value = "标签") private List tagIdList; + + @ApiModelProperty(value = "雷达VO") + private WeRadarVO radar; } diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WeAppDetailDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WeAppDetailDTO.java deleted file mode 100644 index d6a8b48..0000000 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WeAppDetailDTO.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.easywecom.wecom.domain.dto; - - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 企业应用详情接口 - */ -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class WeAppDetailDTO extends WeResultDTO { - //企业应用id - private String agentid; - //企业应用名称 - private String name; - //企业应用方形头像 - private String square_logo_url; - //企业应用详情 - private String description; - //企业应用是否被停用 - private Boolean close; - //企业应用可信域名 - private String redirect_domain; - //企业应用是否打开地理位置上报 0:不上报;1:进入会话上报; - private Integer report_location_flag; - //是否上报用户进入应用事件。0:不接收;1:接收 - private Integer isreportenter; - //应用主页url - private String home_url; - //企业应用头像的mediaid,通过素材管理接口上传图片获得mediaid,上传后会自动裁剪成方形和圆形两个头像 - private String logo_mediaid; - - //企业应用可见范围(人员) - private AllowUserinfos allow_userinfos; - - //企业应用可见范围(部门) - private AllowPartys allow_partys; - - - //可见部门 - @Data - public class AllowPartys { - private String[] partyid; - - } - - - @Data - public class AllowUserinfos { - private user[] user; - } - - @Data - public class user { - private String userid; - } - - -} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WePageBaseReq.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WePageBaseReq.java deleted file mode 100644 index 5c949d7..0000000 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WePageBaseReq.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.easywecom.wecom.domain.dto; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.Data; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * 类名: 企微API基本分页请求实体 - * - * @author : silver_chariot - * @date : 2021/11/1 11:34 - */ -@Data -public abstract class WePageBaseReq { - /** - * 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 - */ - private String cursor; - - protected WePageBaseReq() { - } - - /** - * 执行一次需要分页的企微API 请求, 实现类需要重写并调用相应的企微API - * - * @param corpId 企业ID - * @return {@link WePageBaseResp} - */ - public abstract WePageBaseResp execute(String corpId); - - /** - * 执行多次需要分页的企微API 请求 ,直到没有下一页 - * - * @param corpId 企业ID - * @return {@link WePageBaseResp} 接口响应 - */ - public WePageBaseResp executeTillNoNextPage(String corpId) { - // 待返回的分页列表 - List totalList = new ArrayList<>(); - // 接口单次的响应数据 - WePageBaseResp resp = null; - do { - setCursorIfExist(resp); - resp = this.execute(corpId); - if (resp == null || CollectionUtils.isEmpty(resp.getPageList())) { - break; - } - totalList.addAll(resp.getPageList()); - } while (StringUtils.isNotBlank(resp.getNext_cursor())); - resp.setTotalList(totalList); - return resp; - } - - /** - * 设置游标 - * - * @param resp {@link WePageBaseResp} 上一次的接口响应,如第一次可传null - */ - @JsonIgnore - public void setCursorIfExist(WePageBaseResp resp) { - if (resp == null || StringUtils.isBlank(resp.getNext_cursor())) { - return; - } - setCursor(resp.getNext_cursor()); - } - - -} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WePageBaseResp.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WePageBaseResp.java deleted file mode 100644 index 62390da..0000000 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/WePageBaseResp.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.easywecom.wecom.domain.dto; - -import lombok.Data; - -import java.util.List; - - -/** - * 类名: 企业微信分页接口返回通用参数 - * - * @author : silver_chariot - * @date : 2021/11/1 11:17 - */ -@Data -public abstract class WePageBaseResp extends WeResultDTO { - /** - * 分页游标,再下次请求时填写以获取之后分页的记录,如果已经没有更多的数据则返回空 - */ - private String next_cursor; - /** - * 全部分页数据列表 - */ - private List totalList; - - /** - * 获取企微API分页 单次请求结果的集合 - * - * @return 单次请求后的分页数据 - */ - public abstract List getPageList(); - - /** - * 对返回的数据进行处理 - * - * @param corpId 企业ID - */ - public abstract void handleData(String corpId); - - - -} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/common/AttachmentParam.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/common/AttachmentParam.java index 2e261e9..7c4a918 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/common/AttachmentParam.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/common/AttachmentParam.java @@ -1,16 +1,27 @@ package com.easywecom.wecom.domain.dto.common; +import com.easywecom.common.constant.radar.RadarConstants; +import com.easywecom.common.core.domain.wecom.WeUser; import com.easywecom.common.enums.AttachmentTypeEnum; +import com.easywecom.common.enums.radar.RadarChannelEnum; import com.easywecom.common.utils.StringUtils; +import com.easywecom.common.utils.spring.SpringUtils; import com.easywecom.wecom.domain.WeMaterial; import com.easywecom.wecom.domain.WeMsgTlpMaterial; import com.easywecom.wecom.domain.dto.message.Attachment; +import com.easywecom.wecom.service.WeUserService; +import com.easywecom.wecom.service.radar.WeRadarChannelService; +import com.easywecom.wecom.service.radar.WeRadarService; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; + +import static com.easywecom.common.constant.radar.RadarConstants.RadarCustomerClickRecord.EMPTY_USERID; /** @@ -45,21 +56,38 @@ public class AttachmentParam { /** * 将WeMsgTlpMaterial对象转化为该对象 */ - public static AttachmentParam costFromWeMsgTlpMaterial(WeMsgTlpMaterial weMsgTlpMaterial, AttachmentTypeEnum typeEnum) { + public static AttachmentParam costFromWeMsgTlpMaterial(Long radarId, String userId, String corpId, WeMsgTlpMaterial weMsgTlpMaterial, AttachmentTypeEnum typeEnum) { if (weMsgTlpMaterial == null) { return null; } AttachmentParam attachmentParam = new AttachmentParam(); BeanUtils.copyProperties(weMsgTlpMaterial, attachmentParam); attachmentParam.setTypeEnum(typeEnum); + if (AttachmentTypeEnum.RADAR.equals(attachmentParam.getTypeEnum())) { + return buildRadarAttachment(radarId, RadarChannelEnum.WELCOME_MSG.getTYPE(), userId, corpId, RadarConstants.RadarCustomerClickRecord.COMMON_MSG); + } return attachmentParam; + } + /** + * 获取短链id + * + * @param radarId + * @param channelType + * @param userId + * @param corpId + * @param scenario 场景名称 + * @return + */ + private static AttachmentParam buildRadarAttachment(Long radarId, Integer channelType, String userId, String corpId, String scenario) { + final WeRadarService radarService = SpringUtils.getBean(WeRadarService.class); + return radarService.getRadarShortUrl(radarId, channelType, userId, corpId, scenario); } /** * 将WeMaterial对象转化为该对象 */ - public static AttachmentParam costFromWeMaterialByType(WeMaterial weMaterial, AttachmentTypeEnum typeEnum) { + public static AttachmentParam costFromWeMaterialByType(String scenario, String userId, String corpId, WeMaterial weMaterial, AttachmentTypeEnum typeEnum) { if (weMaterial == null || typeEnum == null) { return null; } @@ -73,6 +101,8 @@ public class AttachmentParam { .picUrl(weMaterial.getCoverUrl()) .description(weMaterial.getDigest()) .url(weMaterial.getMaterialUrl()).typeEnum(typeEnum).build(); + case RADAR: + return buildRadarAttachment(weMaterial.getRadarId(), RadarChannelEnum.EMPLE_CODE.getTYPE(), userId, corpId, scenario); case MINIPROGRAM: return builder.content(weMaterial.getMaterialName()) .picUrl(weMaterial.getCoverUrl()) @@ -88,7 +118,7 @@ public class AttachmentParam { /** * 将{@link Attachment}对象转化为该对象 */ - public static AttachmentParam costFromAttachment(Attachment attachment) { + public static AttachmentParam costFromAttachment(String sender, String corpId, String taskName, Attachment attachment) { if (attachment == null || StringUtils.isEmpty(attachment.getMsgtype())) { return null; } @@ -113,6 +143,8 @@ public class AttachmentParam { .picUrl(attachment.getLinkMessage().getPicurl()) .description(attachment.getLinkMessage().getDesc()) .url(attachment.getLinkMessage().getUrl()).typeEnum(typeEnum).build(); + case RADAR: + return buildRadarAttachment(attachment.getRadarMessage().getRadarId(), RadarChannelEnum.GROUP_TASK.getTYPE(), sender, corpId, taskName); case MINIPROGRAM: return builder.picUrl(attachment.getMiniprogramMessage().getPicUrl()) .content(attachment.getMiniprogramMessage().getTitle()) diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/message/Attachment.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/message/Attachment.java index d22738e..a626d29 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/message/Attachment.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/message/Attachment.java @@ -31,5 +31,7 @@ public class Attachment { @ApiModelProperty("视频") private VideoDTO videoDTO; + @ApiModelProperty("雷达") + private RadarMessageDTO radarMessage; } diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/message/RadarMessageDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/message/RadarMessageDTO.java new file mode 100644 index 0000000..5dcd7a3 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/message/RadarMessageDTO.java @@ -0,0 +1,30 @@ +package com.easywecom.wecom.domain.dto.message; + +import com.easywecom.wecom.domain.vo.radar.WeRadarVO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * ClassName: RadarMessageDTO + * + * @author wx + * @date 2022/7/23 9:54 + */ +@Data +@ApiModel("雷达链接DTO 《RadarMessageDTO》") +@NoArgsConstructor +public class RadarMessageDTO { + + @ApiModelProperty("雷达id") + private Long radarId; + + @ApiModelProperty("雷达VO") + private WeRadarVO radar; + + public RadarMessageDTO(Long radarId) { + this.radarId = radarId; + + } +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/moment/MomentAttachment.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/moment/MomentAttachment.java index cfec248..ea4cf6c 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/moment/MomentAttachment.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/moment/MomentAttachment.java @@ -8,6 +8,7 @@ import com.easywecom.common.utils.spring.SpringUtils; import com.easywecom.wecom.domain.WeWordsDetailEntity; import com.easywecom.wecom.domain.dto.message.ImageMessageDTO; import com.easywecom.wecom.domain.dto.message.LinkMessageDTO; +import com.easywecom.wecom.domain.dto.message.RadarMessageDTO; import com.easywecom.wecom.domain.dto.message.VideoDTO; import com.easywecom.wecom.service.WeCustomerMessageService; import io.swagger.annotations.ApiModel; @@ -41,9 +42,17 @@ public class MomentAttachment { @ApiModelProperty("链接消息") private LinkMessageDTO link; + @ApiModelProperty("链接消息") + private RadarMessageDTO radar; + @ApiModelProperty("视频") private VideoDTO video; + private MomentAttachment(RadarMessageDTO radarMessageDTO) { + this.radar = radarMessageDTO; + this.setMsgtype(GroupMessageType.RADAR.getMessageType()); + } + private MomentAttachment(VideoDTO videoDTO) { this.video = videoDTO; this.setMsgtype(GroupMessageType.VIDEO.getMessageType()); diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/DeleteRadarChannelDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/DeleteRadarChannelDTO.java new file mode 100644 index 0000000..84fd502 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/DeleteRadarChannelDTO.java @@ -0,0 +1,22 @@ +package com.easywecom.wecom.domain.dto.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import java.util.List; + +/** + * ClassName: DeleteRadarChannelDTO + * + * @author wx + * @date 2022/7/19 17:23 + */ +@Data +@ApiModel("雷达渠道批量删除DTO") +public class DeleteRadarChannelDTO { + @NotEmpty(message = "请至少选择一个删除的目标") + @ApiModelProperty("渠道id序列") + private List idList; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/DeleteRadarDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/DeleteRadarDTO.java new file mode 100644 index 0000000..55143a3 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/DeleteRadarDTO.java @@ -0,0 +1,25 @@ +package com.easywecom.wecom.domain.dto.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import java.util.List; + +/** + * ClassName: DeleteRadarDTO + * + * @author wx + * @date 2022/7/18 19:57 + */ + +@Data +@ApiModel("雷达批量删除DTO") +public class DeleteRadarDTO { + @NotEmpty(message = "请至少选择一个删除的目标") + @ApiModelProperty("雷达id序列") + private List idList; +} + + diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/GetRadarShortUrlDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/GetRadarShortUrlDTO.java new file mode 100644 index 0000000..c8d03dc --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/GetRadarShortUrlDTO.java @@ -0,0 +1,27 @@ +package com.easywecom.wecom.domain.dto.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * ClassName: GetRadarShortUrlDTO + * + * @author wx + * @date 2022/7/24 16:17 + */ +@Data +@ApiModel("侧边栏获取雷达短链DTO") +public class GetRadarShortUrlDTO { + + @ApiModelProperty("雷达id") + @NotNull + private Long radarId; + + @ApiModelProperty("员工id") + @NotBlank + private String userId; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarChannelDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarChannelDTO.java new file mode 100644 index 0000000..2daaf56 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarChannelDTO.java @@ -0,0 +1,46 @@ +package com.easywecom.wecom.domain.dto.radar; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.easywecom.common.utils.SnowFlakeUtil; +import com.easywecom.common.utils.bean.BeanUtils; +import com.easywecom.wecom.domain.entity.radar.WeRadarChannel; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * ClassName: RadarChannelDTO + * + * @author wx + * @date 2022/7/19 16:11 + */ +@Data +@ApiModel("雷达渠道DTO") +public class RadarChannelDTO { + + @ApiModelProperty(value = "渠道id, 主键id") + private Long id; + + @ApiModelProperty(value = "雷达id") + @NotNull + private Long radarId; + + @ApiModelProperty(value = "渠道名称") + @NotBlank(message = "请填写渠道名称") + @Size(max = 32, message = "渠道名称,最长32字符") + private String name; + + @ApiModelProperty(value = "渠道的短链url") + private String shortUrl; + + public WeRadarChannel buildWeRadarChannel() { + WeRadarChannel radarChannel = new WeRadarChannel(); + BeanUtils.copyProperties(this, radarChannel); + return radarChannel; + } +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarClickRecordDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarClickRecordDTO.java new file mode 100644 index 0000000..abea472 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarClickRecordDTO.java @@ -0,0 +1,63 @@ +package com.easywecom.wecom.domain.dto.radar; + + +import com.easywecom.common.utils.bean.BeanUtils; +import com.easywecom.wecom.domain.entity.radar.WeRadarClickRecord; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * ClassName: RadarClickRecordDTO + * + * @author wx + * @date 2022/7/20 9:18 + */ +@Data +@ApiModel("雷达点击记录DTO") +public class RadarClickRecordDTO { + + @ApiModelProperty("雷达点击记录表ID,主键id") + private Long id; + + @ApiModelProperty(value = "雷达id") + private String radarId; + + @ApiModelProperty(value = "发送活码用户id") + private String userId; + + @ApiModelProperty(value = "发送雷达链接的用户名称") + private String userName; + + @ApiModelProperty(value = "客户id") + private String externalUserId; + + @ApiModelProperty(value = "用户头像") + private String headImageUrl; + + @ApiModelProperty(value = "客户名称") + private String externalUserName; + + @ApiModelProperty(value = "渠道类型((0未知渠道,1员工活码,2朋友圈,3群发,4侧边栏,5欢迎语,6 客户SOP,7群SOP,8新客进群,9群日历,10自定义渠道)") + private Integer channelType; + + @ApiModelProperty(value = "未知渠道 COMMENT 渠道名") + private String channelName; + + @ApiModelProperty(value = "外部联系人在微信开放平台的唯一身份标识,通过此字段企业可将外部联系人与公众号/小程序用户关联起来") + private String unionId; + + @ApiModelProperty(value = "公众号/小程序open_id") + private String openId; + + /** + * 构造雷达点击记录实体 + * + * @return + */ + public WeRadarClickRecord buildData() { + WeRadarClickRecord radarClickRecord = new WeRadarClickRecord(); + BeanUtils.copyProperties(this, radarClickRecord, "id"); + return radarClickRecord; + } +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarDTO.java new file mode 100644 index 0000000..7357bdc --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/RadarDTO.java @@ -0,0 +1,94 @@ +package com.easywecom.wecom.domain.dto.radar; + +import cn.hutool.core.util.ObjectUtil; +import com.easywecom.common.core.domain.BaseEntity; +import com.easywecom.common.utils.bean.BeanUtils; +import com.easywecom.wecom.domain.entity.radar.WeRadar; +import com.easywecom.wecom.domain.entity.radar.WeRadarTag; +import com.easywecom.wecom.domain.entity.radar.WeRadarUrl; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.StringUtils; + + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * ClassName: AddRadarDTO + * + * @author wx + * @date 2022/7/18 15:27 + */ +@Data +@ApiModel("雷达DTO") +public class RadarDTO { + + @ApiModelProperty(value = "雷达id") + private Long id; + + @ApiModelProperty(value = "雷达类型(1个人雷达,2部门雷达,3企业雷达)") + private Integer type; + + @ApiModelProperty(value = "corpId") + @JsonIgnore + private String corpId; + + @ApiModelProperty(value = "雷达标题") + @NotBlank(message = "雷达标题不得为空") + @Size(max = 32, message = "标题长度超过限制,最多32个字符") + private String radarTitle; + + @ApiModelProperty("雷达链接实体") + @Valid + @NotNull(message = "雷达链接不能为空") + private WeRadarUrl weRadarUrl; + + @ApiModelProperty(value = "是否开启行为通知(1[true]是0[false]否)") + private Boolean enableClickNotice; + + @ApiModelProperty(value = "是否允许轨迹记录(1[true]是 0[false]否)") + private Boolean enableBehaviorRecord; + + @ApiModelProperty(value = "是否允许打上客户标签( 1[true]是 0[false]否)") + private Boolean enableCustomerTag; + + @ApiModelProperty(value = "更新后是否通知员工(true[1]是 false[0]否)") + private Boolean enableUpdateNotice; + + @ApiModelProperty(value = "雷达标签") + private List radarTagList; + + @ApiModelProperty(value = "员工主部门") + @JsonIgnore + private Long mainDepartment; + + public WeRadar buildRadarData() { + WeRadar radar = new WeRadar(); + BeanUtils.copyProperties(this, radar, "id"); + final WeRadarUrl weRadarUrl = this.getWeRadarUrl(); + radar.setUrl(weRadarUrl.getUrl()); + radar.setIsDefined(weRadarUrl.getIsDefined()); + radar.setCoverUrl(ObjectUtil.isNotEmpty(weRadarUrl.getCoverUrl()) ? weRadarUrl.getCoverUrl() : StringUtils.EMPTY); + radar.setTitle(ObjectUtil.isNotEmpty(weRadarUrl.getTitle()) ? weRadarUrl.getTitle() : StringUtils.EMPTY); + radar.setContent(ObjectUtil.isNotEmpty(weRadarUrl.getContent()) ? weRadarUrl.getContent() : StringUtils.EMPTY); + return radar; + } + + public List buildRadarTags(Long radarId) { + if (Boolean.TRUE.equals(this.getEnableCustomerTag())) { + this.getRadarTagList().forEach(item -> item.setRadarId(radarId)); + return this.getRadarTagList(); + } + return Collections.emptyList(); + } + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchChannelRecordDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchChannelRecordDTO.java new file mode 100644 index 0000000..1aef76f --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchChannelRecordDTO.java @@ -0,0 +1,25 @@ +package com.easywecom.wecom.domain.dto.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * ClassName: SearchChannelRecordDTO + * + * @author wx + * @date 2022/7/20 21:36 + */ +@Data +@ApiModel("查询渠道点击记录DTO") +public class SearchChannelRecordDTO { + + @ApiModelProperty(value = "雷达id") + @NotNull(message = "雷达id不得为空") + private Long radarId; + + @ApiModelProperty(value = "渠道名称") + private String channelName; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchChannelRecordDetailDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchChannelRecordDetailDTO.java new file mode 100644 index 0000000..addfefe --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchChannelRecordDetailDTO.java @@ -0,0 +1,31 @@ +package com.easywecom.wecom.domain.dto.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * ClassName: SearchChannelRecordDetailDTO + * + * @author wx + * @date 2022/7/20 21:10 + */ +@Data +@ApiModel("查询渠道点击记录详情DTO") +public class SearchChannelRecordDetailDTO { + + @ApiModelProperty(value = "选择渠道名称") + @NotBlank(message = "渠道名不得为空") + private String channelName; + + @ApiModelProperty(value = "雷达id") + @NotNull(message = "雷达id不得为空") + private Long radarId; + + @ApiModelProperty(value = "客户昵称") + private String customerName; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchCustomerRecordDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchCustomerRecordDTO.java new file mode 100644 index 0000000..6d49a73 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchCustomerRecordDTO.java @@ -0,0 +1,35 @@ +package com.easywecom.wecom.domain.dto.radar; + +import com.easywecom.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * ClassName: SearchCustomerRecordDTO + * + * @author wx + * @date 2022/7/20 21:30 + */ +@Data +@ApiModel("客户点击记录DTO") +public class SearchCustomerRecordDTO { + + @ApiModelProperty(value = "雷达id") + @NotNull(message = "雷达id不得为空") + private Long radarId; + + @ApiModelProperty(value = "客户昵称") + private String customerName; + + @ApiModelProperty("排序按钮 true:正序 ,false:逆序") + private Boolean enableSort; + + @ApiModelProperty("开始时间") + private String beginTime; + + @ApiModelProperty("结束时间") + private String endTime; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchCustomerRecordDetailDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchCustomerRecordDetailDTO.java new file mode 100644 index 0000000..c5e6fa6 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchCustomerRecordDetailDTO.java @@ -0,0 +1,27 @@ +package com.easywecom.wecom.domain.dto.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * ClassName: SearchCustomerRecordDetailDTO + * + * @author wx + * @date 2022/7/20 21:43 + */ +@Data +@ApiModel("查询客户点击记录详情DTO") +public class SearchCustomerRecordDetailDTO { + @ApiModelProperty(value = "雷达id") + @NotNull(message = "雷达id不得为空") + private Long radarId; + + @ApiModelProperty(value = "externalId") + @NotBlank(message = "客户externalId不得为空") + private String externalId; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarAnalyseDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarAnalyseDTO.java new file mode 100644 index 0000000..63b4e2d --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarAnalyseDTO.java @@ -0,0 +1,33 @@ +package com.easywecom.wecom.domain.dto.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + + +/** + * ClassName: SearchRadarAnalyseDTO + * + * @author wx + * @date 2022/7/20 15:36 + */ +@Data +@ApiModel("搜索雷达数据统计DTO") +public class SearchRadarAnalyseDTO { + + @ApiModelProperty(value = "选择渠道名称") + private String channelName; + + @ApiModelProperty(value = "雷达id") + private Long radarId; + + @ApiModelProperty(value = "开始时间", required = true) + private String beginTime; + + @ApiModelProperty(value = "结束时间", required = true) + private String endTime; + + @ApiModelProperty(value = "员工ID") + private String userId; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarChannelDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarChannelDTO.java new file mode 100644 index 0000000..0f9a7fc --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarChannelDTO.java @@ -0,0 +1,25 @@ +package com.easywecom.wecom.domain.dto.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * ClassName: SearchRadarChannelDTO + * + * @author wx + * @date 2022/7/19 16:30 + */ +@Data +@ApiModel("查询雷达渠道DTO") +public class SearchRadarChannelDTO { + + @ApiModelProperty("雷达ID") + private String radarId; + + @ApiModelProperty(value = "渠道名称") + private String name; + + @ApiModelProperty(value = "corpId") + private String corpId; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarDTO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarDTO.java new file mode 100644 index 0000000..783b49d --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/dto/radar/SearchRadarDTO.java @@ -0,0 +1,39 @@ +package com.easywecom.wecom.domain.dto.radar; + +import com.easywecom.common.core.domain.BaseEntity; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * ClassName: SearchRadarDTO + * + * @author wx + * @date 2022/7/19 11:42 + */ +@Data +@ApiModel("搜索雷达DTO") +@EqualsAndHashCode(callSuper = true) +public class SearchRadarDTO extends BaseEntity { + + @ApiModelProperty("雷达/链接标题") + private String searchTitle; + + @ApiModelProperty(value = "雷达类型(1个人雷达,2部门雷达,3企业雷达)") + private Integer type; + + @ApiModelProperty(value = "员工idList") + @JsonIgnore + private List userIds; + + @ApiModelProperty(value = "corpId,同时代表企业雷达传值") + @JsonIgnore + private String corpId; + + @ApiModelProperty("排序按钮 true:正序 ,false:逆序") + private Boolean enableSort; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadar.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadar.java new file mode 100644 index 0000000..7f6bfb2 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadar.java @@ -0,0 +1,98 @@ +package com.easywecom.wecom.domain.entity.radar; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.easywecom.common.utils.SnowFlakeUtil; +import com.easywecom.common.utils.StringUtils; +import com.easywecom.common.utils.bean.BeanUtils; +import com.easywecom.wecom.domain.dto.radar.RadarDTO; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * ClassName: WeRadar + * + * @author wx + * @date 2022/7/18 14:59 + */ +@Data +@TableName("we_radar") +@ApiModel("雷达") +public class WeRadar { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "雷达id, 主键id") + @TableId + @TableField("id") + private Long id = SnowFlakeUtil.nextId(); + + @ApiModelProperty(value = "授权企业ID", hidden = true) + @TableField("corp_id") + private String corpId; + + @ApiModelProperty(value = "雷达类型(1个人雷达,2部门雷达,3企业雷达)") + @TableField("type") + private Integer type; + + @ApiModelProperty(value = "雷达标题") + @TableField("radar_title") + private String radarTitle; + + @ApiModelProperty(value = "雷达原始路径url") + @TableField("url") + private String url; + + @ApiModelProperty(value = "雷达链接封面图") + @TableField("cover_url") + private String coverUrl; + + @ApiModelProperty(value = "链接标题") + @TableField("title") + private String title; + + @ApiModelProperty(value = "雷达链接摘要") + @TableField("content") + private String content; + + @ApiModelProperty(value = "链接时使用:0 默认,1 自定义") + @TableField("is_defined") + private Boolean isDefined; + + @ApiModelProperty(value = "是否开启行为通知(1[true]是0[false]否)") + @TableField("enable_click_notice") + private Boolean enableClickNotice; + + @ApiModelProperty(value = "是否允许轨迹记录(1[true]是 0[false]否)") + @TableField("enable_behavior_record") + private Boolean enableBehaviorRecord; + + @ApiModelProperty(value = "是否允许打上客户标签( 1[true]是 0[false]否)") + @TableField("enable_customer_tag") + private Boolean enableCustomerTag; + + @ApiModelProperty(value = "更新后是否通知员工(true[1]是 false[0]否)") + @TableField("enable_update_notice") + private Boolean enableUpdateNotice; + + @ApiModelProperty(value = "创建时间") + @TableField("create_time") + private String createTime; + + @ApiModelProperty(value = "创建人") + @TableField("create_by") + private String createBy; + + @ApiModelProperty(value = "更新时间") + @TableField("update_time") + private String updateTime; + + @ApiModelProperty(value = "更新人") + @TableField("update_by") + private String updateBy; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarChannel.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarChannel.java new file mode 100644 index 0000000..8d5b3c3 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarChannel.java @@ -0,0 +1,48 @@ +package com.easywecom.wecom.domain.entity.radar; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.easywecom.common.utils.SnowFlakeUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * ClassName: WeRadarChannel + * + * @author wx + * @date 2022/7/19 14:56 + */ +@Data +@TableName("we_radar_channel") +@ApiModel("雷达渠道") +public class WeRadarChannel { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "渠道id, 主键id") + @TableId + @TableField("id") + private Long id = SnowFlakeUtil.nextId(); + + @ApiModelProperty(value = "雷达id") + @TableField("radar_id") + private Long radarId; + + @ApiModelProperty(value = "渠道名称") + @TableField("name") + private String name; + + @ApiModelProperty(value = "渠道的短链url") + @TableField("short_url") + private String shortUrl; + + @ApiModelProperty(value = "创建时间") + @TableField("create_time") + private String createTime; + + @ApiModelProperty(value = "创建人") + @TableField("create_by") + private String createBy; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarClickRecord.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarClickRecord.java new file mode 100644 index 0000000..fac3d62 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarClickRecord.java @@ -0,0 +1,83 @@ +package com.easywecom.wecom.domain.entity.radar; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.easywecom.common.utils.SnowFlakeUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * ClassName: WeRadarClickRecord + * + * @author wx + * @date 2022/7/19 19:46 + */ +@Data +@ApiModel("雷达点击实体") +@TableName("we_radar_click_record") +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WeRadarClickRecord { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("雷达点击记录表ID,主键id") + @TableId + @TableField("id") + private Long id = SnowFlakeUtil.nextId(); + + @ApiModelProperty(value = "雷达Id", hidden = true) + @TableField("radar_id") + private Long radarId; + + @ApiModelProperty(value = "发送活码用户id") + @TableField("user_id") + private String userId; + + @ApiModelProperty(value = "发送雷达链接的用户名称") + @TableField("user_name") + private String userName; + + @ApiModelProperty(value = "客户id") + @TableField("external_user_id") + private String externalUserId; + + @ApiModelProperty(value = "用户头像") + @TableField("external_user_head_image") + private String externalUserHeadImage; + + @ApiModelProperty(value = "客户名称") + @TableField("external_user_name") + private String externalUserName; + + @ApiModelProperty(value = "渠道类型((0未知渠道,1员工活码,2朋友圈,3群发,4侧边栏,5欢迎语,6 客户SOP,7群SOP,8新客进群,9群日历)") + @TableField("channel_type") + private Integer channelType; + + @ApiModelProperty(value = "未知渠道 COMMENT 渠道名") + @TableField("channel_name") + private String channelName; + + @ApiModelProperty(value = "外部联系人在微信开放平台的唯一身份标识,通过此字段企业可将外部联系人与公众号/小程序用户关联起来") + @TableField("union_id") + private String unionId; + + @ApiModelProperty(value = "公众号/小程序open_id") + @TableField("open_id") + private String openId; + + @ApiModelProperty(value = "创建时间") + @TableField("create_time") + private Date createTime; + + @ApiModelProperty(value = "创建日期(格式yyyy-mm-dd)") + @TableField("create_date") + private String createDate; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarTag.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarTag.java new file mode 100644 index 0000000..f9bd3f8 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarTag.java @@ -0,0 +1,31 @@ +package com.easywecom.wecom.domain.entity.radar; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * ClassName: WeRadarTag + * + * @author wx + * @date 2022/7/18 17:23 + */ +@Data +@TableName("we_radar") +@ApiModel("客户标签") +public class WeRadarTag { + @ApiModelProperty("雷达id") + @TableField("radar_id") + @JsonIgnore + private Long radarId; + + @ApiModelProperty("标签id") + @TableField("tag_id") + private String tagId; + + @ApiModelProperty("标签名") + private String tagName; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarUrl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarUrl.java new file mode 100644 index 0000000..f22f94b --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/radar/WeRadarUrl.java @@ -0,0 +1,43 @@ +package com.easywecom.wecom.domain.entity.radar; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * ClassName: WeRadarUrl + * + * @author wx + * @date 2022/7/18 15:13 + */ +@Getter +@Setter +public class WeRadarUrl { + + @ApiModelProperty(value = "雷达原始路径url,真实链接") + @Valid + @NotBlank(message = "雷达链接访问地址不得为空") + @Size(max = 3000, message = "雷达链接过长最多3000") + private String url; + + @ApiModelProperty(value = "雷达链接封面图") + @Size(max = 1200, message = "雷达封面图链接过长最多") + private String coverUrl; + + @ApiModelProperty(value = "链接标题") + @Valid + @Size(max = 16, message = "链接标题长度超过限制,最长16个字符") + private String title; + + @ApiModelProperty(value = "雷达链接摘要") + @Valid + @Size(max = 64, message = "摘要长度超过限制,最长64字符") + private String content; + + @ApiModelProperty(value = "链接时使用:0 默认,1 自定义") + private Boolean isDefined; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/wechatopen/WeOpenConfig.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/wechatopen/WeOpenConfig.java new file mode 100644 index 0000000..8b961e0 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/entity/wechatopen/WeOpenConfig.java @@ -0,0 +1,42 @@ +package com.easywecom.wecom.domain.entity.wechatopen; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.easywecom.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 类名: 企业公众号配置表实体 + * + * @author : wangzimo + * @date : 2022-07-25 14:01:57 + */ +@Data +@ApiModel("企业公众号配置表实体") +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WeOpenConfig extends BaseEntity { + @TableField("corp_id") + @ApiModelProperty(value = "企业id ") + private String corpId; + + @TableField("official_account_app_id") + @ApiModelProperty(value = "公众号appid ") + private String officialAccountAppId; + + @TableField("official_account_app_secret") + @ApiModelProperty(value = "公众号secret ") + private String officialAccountAppSecret; + + @TableField("official_account_domain") + @ApiModelProperty(value = "公众号域名 ") + private String officialAccountDomain; + + + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/req/GenerateUrlLinkReq.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/req/GenerateUrlLinkReq.java new file mode 100644 index 0000000..049f427 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/req/GenerateUrlLinkReq.java @@ -0,0 +1,78 @@ +package com.easywecom.wecom.domain.req; + +import com.easywecom.common.config.WechatOpenConfig; +import lombok.Data; + +/** + * 类名: 生成小程序跳转链接请求 + * + * @author : silver_chariot + * @date : 2022/7/20 13:59 + **/ +@Data +public class GenerateUrlLinkReq { + /** + * (是)接口调用凭证 + */ + private String access_token; + /** + * (否)通过 URL Link 进入的小程序页面路径,必须是已经发布的小程序存在的页面, + * 不可携带 query 。path 为空时会跳转小程序主页 + */ + private String path; + /** + * (否)通过 URL Link 进入小程序时的query,最大1024个字符, + * 只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~% + */ + private String query; + /** + * (否) 要打开的小程序版本。正式版为 "release", + * 体验版为"trial",开发版为"develop",仅在微信外打开时生效。 + */ + private String env_version; + /** + * (是) 小程序 URL Link 失效类型,失效时间:0, + * 失效间隔天数:1 + */ + private Integer expire_type; + /** + * 到期失效的 URL Link 的失效时间,为 Unix 时间戳。 + * 生成的到期失效 URL Link 在该时间前有效。 + * 最长有效期为30天。expire_type 为 0 必填 + */ + private Integer expire_time; + /** + * 到期失效的URL Link的失效间隔天数。生成的到期失效URL Link在该间隔时间到达前有效。 + * 最长间隔天数为30天。expire_type 为 1 必填 + */ + private Integer expire_interval; + + public GenerateUrlLinkReq token(String accessToken) { + this.access_token = accessToken; + return this; + } + public GenerateUrlLinkReq query(String query) { + this.query = query; + return this; + } + + public GenerateUrlLinkReq path(String path) { + this.path = path; + return this; + } + + public GenerateUrlLinkReq version(String version) { + this.env_version = version; + return this; + } + + public GenerateUrlLinkReq buildReq() { + // 失效间隔天数类型 + this.expire_type = 1; + // 设置失效天数为30 + this.expire_interval = 30; + return this; + } + + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/req/UnionId2ExternalUserIdReq.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/req/UnionId2ExternalUserIdReq.java new file mode 100644 index 0000000..857a9c9 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/req/UnionId2ExternalUserIdReq.java @@ -0,0 +1,21 @@ +package com.easywecom.wecom.domain.req; + +import lombok.Data; + +/** + * 类名: unionid转客户id请求 + * + * @author : silver_chariot + * @date : 2022/7/21 16:37 + **/ +@Data +public class UnionId2ExternalUserIdReq { + /** + * 微信客户unionid + */ + private String unionid; + /** + * 微信客户openid + */ + private String openid; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GenerateUrlLinkResp.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GenerateUrlLinkResp.java new file mode 100644 index 0000000..2e7900c --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GenerateUrlLinkResp.java @@ -0,0 +1,18 @@ +package com.easywecom.wecom.domain.resp; + +import lombok.Data; + +/** + * 类名: 生成小程序urllink响应参数 + * + * @author : silver_chariot + * @date : 2022/7/20 14:21 + **/ +@Data +public class GenerateUrlLinkResp extends WechatOpenBaseResp { + + /** + * 小程序 URL Link + */ + private String url_link; +} \ No newline at end of file diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetAccessTokenResp.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetAccessTokenResp.java new file mode 100644 index 0000000..55244d5 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetAccessTokenResp.java @@ -0,0 +1,22 @@ +package com.easywecom.wecom.domain.resp; + +import lombok.Data; + +/** + * 类名: 获取小程序accessToken响应实体 + * + * @author : silver_chariot + * @date : 2022/7/20 14:58 + **/ +@Data +public class GetAccessTokenResp extends WechatOpenBaseResp { + /** + * 获取到的凭证 + */ + private String access_token; + /** + * 凭证有效时间,单位:秒。目前是7200秒之内的值。 + */ + private Integer expires_in; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetOfficialAuthInfoResp.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetOfficialAuthInfoResp.java new file mode 100644 index 0000000..c1e8421 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetOfficialAuthInfoResp.java @@ -0,0 +1,27 @@ +package com.easywecom.wecom.domain.resp; + +import com.easywecom.common.utils.StringUtils; +import lombok.Data; + +/** + * 类名: 获取公众号用户信息响应 + * + * @author : silver_chariot + * @date : 2022/7/20 10:42 + **/ +@Data +public class GetOfficialAuthInfoResp extends WechatOpenBaseResp { + /** + * 用户在公众号唯一标识 + */ + private String openId; + /** + * access_token接口调用凭证超时时间,单位(秒) + */ + private Integer expires_in; + /** + * 对应openid的access_token + */ + private String access_token; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetUnionUserInfoResp.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetUnionUserInfoResp.java new file mode 100644 index 0000000..49ae98a --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/GetUnionUserInfoResp.java @@ -0,0 +1,53 @@ +package com.easywecom.wecom.domain.resp; + +import lombok.Data; + +/** + * 类名: 获取公众号用户信息响应 + * + * @author : silver_chariot + * @date : 2022/7/21 16:04 + **/ +@Data +public class GetUnionUserInfoResp extends WechatOpenBaseResp{ + /** + * 用户是否订阅该公众号标识,值为0时,代表此用户没有关注该公众号,拉取不到其余信息。 + */ + private Integer subscribe; + /** + * 用户的标识,对当前公众号唯一 + */ + private String openid ; + /** + * 用户的语言,简体中文为zh_CN + */ + private String language; + /** + * 用户关注时间,为时间戳。如果用户曾多次关注,则取最后关注时间 + */ + private Long subscribe_time; + /** + * 只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。 + */ + private String unionid; + /** + * 公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注 + */ + private String remark; + /** + * 用户所在的分组ID(兼容旧的用户分组接口) + */ + private Integer groupid; + /** + * 返回用户关注的渠道来源,ADD_SCENE_SEARCH 公众号搜索, + * ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移, + * ADD_SCENE_PROFILE_CARD 名片分享, + * ADD_SCENE_QR_CODE 扫描二维码, + * ADD_SCENE_PROFILE_LINK 图文页内名称点击, + * ADD_SCENE_PROFILE_ITEM 图文页右上角菜单, + * ADD_SCENE_PAID 支付后关注,ADD_SCENE_WECHAT_ADVERTISEMENT 微信广告,ADD_SCENE_REPRINT 他人转载 ,ADD_SCENE_LIVESTREAM 视频号直播,ADD_SCENE_CHANNELS 视频号 , ADD_SCENE_OTHERS 其他 + */ + private String subscribe_scene; + + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/SnsUserInfoResp.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/SnsUserInfoResp.java new file mode 100644 index 0000000..422c839 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/SnsUserInfoResp.java @@ -0,0 +1,63 @@ +package com.easywecom.wecom.domain.resp; + +import lombok.Data; + +/** + * 类名: 页面用户授权响应 例: + * { + * "openid": "oqL2307pDxHtihTAPrQjxQ", + * "nickname": "MX", + * "sex": 0, + * "language": "", + * "city": "", + * "province": "", + * "country": "", + * "headimgurl": "https://thirdTfd31LA/132", + * "privilege": [], + * "unionid": "o3bNmo0KmfI" + * } + * + * @author : silver_chariot + * @date : 2022/7/22 18:31 + **/ + +@Data +public class SnsUserInfoResp extends WechatOpenBaseResp { + /** + * openid + */ + private String openid; + /** + * 昵称 + */ + private String nickname; + /** + * 性别 + */ + private Integer sex; + /** + * 语言 + */ + private String language; + /** + * 城市 + */ + private String city; + /** + * 省份 + */ + private String province; + /** + * 国家 + */ + private String country; + /** + * 头像url + */ + private String headimgurl; + /** + * unionid + */ + private String unionid; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/UnionId2ExternalUserIdResp.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/UnionId2ExternalUserIdResp.java new file mode 100644 index 0000000..45107e6 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/UnionId2ExternalUserIdResp.java @@ -0,0 +1,19 @@ +package com.easywecom.wecom.domain.resp; + +import com.easywecom.wecom.domain.dto.WeResultDTO; +import lombok.Data; + +/** + * 类名: unionid转客户id响应 + * + * @author : silver_chariot + * @date : 2022/7/21 16:38 + **/ +@Data +public class UnionId2ExternalUserIdResp extends WeResultDTO { + + /** + * 该企业的外部联系人ID + */ + private String external_userid; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/WechatOpenBaseResp.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/WechatOpenBaseResp.java new file mode 100644 index 0000000..db890bd --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/resp/WechatOpenBaseResp.java @@ -0,0 +1,32 @@ +package com.easywecom.wecom.domain.resp; + +import lombok.Data; + +/** + * 类名: 微信公众平台基础响应实体 + * + * @author : silver_chariot + * @date : 2022/7/20 14:22 + **/ +@Data +public class WechatOpenBaseResp { + + /** + * 错误码 (只有错误的时候返回) 默认为 + */ + private Integer errcode; + /** + * 错误消息 (只有错误的时候返回) + */ + private String errmsg; + + + /** + * 是否返回错误信息 + * + * @return true 是 + */ + public boolean isError() { + return errcode != null || errmsg != null; + } +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/AppIdVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/AppIdVO.java new file mode 100644 index 0000000..de48ad4 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/AppIdVO.java @@ -0,0 +1,27 @@ +package com.easywecom.wecom.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 类名: 获取appid结果 + * + * @author : silver_chariot + * @date : 2022/7/25 17:54 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AppIdVO { + /** + * appid + */ + private String appId; + /** + * 企业id + */ + private String corpId; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/SelectWeEmplyCodeWelcomeMsgVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/SelectWeEmplyCodeWelcomeMsgVO.java index 09bffaa..aa0eb5e 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/SelectWeEmplyCodeWelcomeMsgVO.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/SelectWeEmplyCodeWelcomeMsgVO.java @@ -22,6 +22,11 @@ public class SelectWeEmplyCodeWelcomeMsgVO { */ private String empleCodeId; + /** + * 活码场景(活码名称) + */ + private String scenario; + /** * 欢迎语-文本 */ diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/WeMaterialVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/WeMaterialVO.java index 50e3e24..f27471b 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/WeMaterialVO.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/WeMaterialVO.java @@ -1,5 +1,6 @@ package com.easywecom.wecom.domain.vo; +import com.easywecom.wecom.domain.vo.radar.WeRadarVO; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -96,4 +97,10 @@ public class WeMaterialVO { private List tagList; private String tagIds; + + @ApiModelProperty("保存雷达时使用") + private Long radarId; + + @ApiModelProperty("链接时使用(0,不转化为雷达,1:转化为雷达)") + private Boolean enableConvertRadar; } \ No newline at end of file diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarAnalyseCountVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarAnalyseCountVO.java new file mode 100644 index 0000000..08e0970 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarAnalyseCountVO.java @@ -0,0 +1,33 @@ +package com.easywecom.wecom.domain.vo.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * ClassName: RadarAnalyseCountVO + * + * @author wx + * @date 2022/7/20 15:35 + */ +@Data +@ApiModel("员工活码数据统计") +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class RadarAnalyseCountVO { + @ApiModelProperty(value = "日期") + private String createDate; + + @ApiModelProperty(value = "点击人数") + private Integer clickPersonNum; + + @ApiModelProperty(value = "点击次数") + private Integer sumClickNum; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarAnalyseVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarAnalyseVO.java new file mode 100644 index 0000000..5125d59 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarAnalyseVO.java @@ -0,0 +1,29 @@ +package com.easywecom.wecom.domain.vo.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * ClassName: RadarAnalyseVO + * + * @author wx + * @date 2022/7/20 15:27 + */ +@Data +@ApiModel("雷达点击记录分析表") +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class RadarAnalyseVO { + @ApiModelProperty("点击人数") + private List list; + + @ApiModelProperty("总数") + private Integer total; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelRecordDetailVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelRecordDetailVO.java new file mode 100644 index 0000000..f75c2d5 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelRecordDetailVO.java @@ -0,0 +1,34 @@ +package com.easywecom.wecom.domain.vo.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * ClassName: RadarChannelRecordDetailVO + * + * @author wx + * @date 2022/7/20 21:04 + */ +@Data +@ApiModel("渠道点击记录详情") +@AllArgsConstructor +@NoArgsConstructor +public class RadarChannelRecordDetailVO { + @ApiModelProperty("客户externalId") + private String externalId; + + @ApiModelProperty("客户名称") + private String name; + + @ApiModelProperty("点击次数") + private Integer clickNum; + + @ApiModelProperty("最近点击渠道") + private String channelName; + + @ApiModelProperty("最近点击时间") + private String clickTime; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelRecordVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelRecordVO.java new file mode 100644 index 0000000..6a33fc8 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelRecordVO.java @@ -0,0 +1,30 @@ +package com.easywecom.wecom.domain.vo.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * ClassName: RadarChannelRecordVO + * + * @author wx + * @date 2022/7/20 20:53 + */ +@Data +@ApiModel("渠道点击记录") +@AllArgsConstructor +@NoArgsConstructor +public class RadarChannelRecordVO { + + @ApiModelProperty("渠道名称") + private String channelName; + + @ApiModelProperty("点击次数") + private Integer clickNum; + + @ApiModelProperty("点击人数") + private String clickPersonNum; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelSortVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelSortVO.java new file mode 100644 index 0000000..c856f07 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarChannelSortVO.java @@ -0,0 +1,27 @@ +package com.easywecom.wecom.domain.vo.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * ClassName: RadarChannelSortVO + * + * @author wx + * @date 2022/7/20 17:21 + */ +@Data +@ApiModel("雷达渠道点击人数排行") +@AllArgsConstructor +@NoArgsConstructor +public class RadarChannelSortVO { + + @ApiModelProperty("渠道名称") + private String channelName; + + @ApiModelProperty("点击数量") + private Integer clickNum; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarCustomerClickRecordDetailVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarCustomerClickRecordDetailVO.java new file mode 100644 index 0000000..982495e --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarCustomerClickRecordDetailVO.java @@ -0,0 +1,49 @@ +package com.easywecom.wecom.domain.vo.radar; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * ClassName: RadarCustomerClickRecordDetailVO + * + * @author wx + * @date 2022/7/20 21:47 + */ +@Data +@ApiModel("客户点击记录详情") +@AllArgsConstructor +@NoArgsConstructor +public class RadarCustomerClickRecordDetailVO { + + @ApiModelProperty(value = "客户id") + private String externalId; + + @ApiModelProperty(value = "客户记录") + private String recordText; + + @ApiModelProperty(value = "点击时间") + private String clickTime; + + @ApiModelProperty(value = "客户名称") + @JsonIgnore + private String customerName; + + @ApiModelProperty(value = "渠道类型") + @JsonIgnore + private Integer channelType; + + @ApiModelProperty(value = "渠道名字") + private String channelName; + + @ApiModelProperty(value = "员工名称") + @JsonIgnore + private String userName; + + @ApiModelProperty(value = "详情(如果是员工活码,则为员工活码使用场景,如果是新客进群则为新客进群的活码名称,如果是SOP则为SOP名称,如果是群日历,则为日历名称)") + @JsonIgnore + private String detail; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarCustomerRecordVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarCustomerRecordVO.java new file mode 100644 index 0000000..90e6de7 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarCustomerRecordVO.java @@ -0,0 +1,39 @@ +package com.easywecom.wecom.domain.vo.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * ClassName: RadarCustomerRecordVO + * + * @author wx + * @date 2022/7/20 20:21 + */ +@Data +@ApiModel("客户点击记录") +@AllArgsConstructor +@NoArgsConstructor +public class RadarCustomerRecordVO { + + @ApiModelProperty("客户externalId") + private String externalId; + + @ApiModelProperty("客户名称") + private String customerName; + + @ApiModelProperty("客户头像") + private String headImageUrl; + + @ApiModelProperty("点击次数") + private Integer clickNum; + + @ApiModelProperty("最近点击渠道") + private String channelName; + + @ApiModelProperty("最近点击时间") + private String clickTime; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarRecordTotalVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarRecordTotalVO.java new file mode 100644 index 0000000..52cbb7e --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarRecordTotalVO.java @@ -0,0 +1,29 @@ +package com.easywecom.wecom.domain.vo.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * ClassName: RadarRecordTotalVO + * + * @author wx + * @date 2022/7/20 13:48 + */ +@Data +@ApiModel("雷达点击记录数据总览") +public class RadarRecordTotalVO { + + @ApiModelProperty("总点击人数") + private Integer sumClickPersonNum; + + @ApiModelProperty("总点击次数") + private Integer sumClickNum; + + @ApiModelProperty("今日点击人数") + private Integer nowadaysClickPersonNum; + + @ApiModelProperty("今日总点击次数") + private Integer nowadaysClickNum; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarSumClickRecordVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarSumClickRecordVO.java new file mode 100644 index 0000000..732488e --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/RadarSumClickRecordVO.java @@ -0,0 +1,21 @@ +package com.easywecom.wecom.domain.vo.radar; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * ClassName: RadarSumClickRecordVO + * + * @author wx + * @date 2022/7/21 14:01 + */ +@Data +@ApiModel("雷达总的点击记录") +public class RadarSumClickRecordVO { + @ApiModelProperty("总点击人数") + private Integer sumClickPersonNum; + + @ApiModelProperty("总点击次数") + private Integer sumClickNum; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/WeRadarChannelVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/WeRadarChannelVO.java new file mode 100644 index 0000000..a9452b0 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/WeRadarChannelVO.java @@ -0,0 +1,48 @@ +package com.easywecom.wecom.domain.vo.radar; + + +import com.easywecom.common.utils.bean.BeanUtils; +import com.easywecom.wecom.domain.entity.radar.WeRadarChannel; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * ClassName: WeRadarChannelVO + * + * @author wx + * @date 2022/7/19 16:33 + */ +@Data +@ApiModel("雷达渠道VO") +public class WeRadarChannelVO { + + @ApiModelProperty(value = "渠道id") + private Long id; + + @ApiModelProperty(value = "雷达id") + private Long radarId; + + @ApiModelProperty(value = "渠道名称") + private String name; + + @ApiModelProperty(value = "渠道的短链url") + private String shortUrl; + + @ApiModelProperty(value = "创建时间") + private String createTime; + + @ApiModelProperty("创建人id") + private String createId; + + @ApiModelProperty("创建人姓名") + private String createName; + + @ApiModelProperty("创建人所属部门id") + private String departmentId; + + @ApiModelProperty("创建人所属部门姓名") + private String departmentName; + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/WeRadarVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/WeRadarVO.java new file mode 100644 index 0000000..a48d0b8 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/radar/WeRadarVO.java @@ -0,0 +1,69 @@ +package com.easywecom.wecom.domain.vo.radar; + +import com.easywecom.wecom.domain.entity.radar.WeRadarTag; +import com.easywecom.wecom.domain.entity.radar.WeRadarUrl; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * ClassName: WeRadarVO + * + * @author wx + * @date 2022/7/18 17:13 + */ +@Data +@ApiModel("雷达VO") +@NoArgsConstructor +@AllArgsConstructor +public class WeRadarVO { + + @ApiModelProperty(value = "雷达id") + private Long radarId; + + @ApiModelProperty(value = "雷达标题") + private String radarTitle; + + @ApiModelProperty(value = "雷达类型") + private Integer type; + + @ApiModelProperty("雷达内容") + private WeRadarUrl weRadarUrl; + + @ApiModelProperty("客户标签") + private List radarTagList; + + @ApiModelProperty("总点击人数") + private Integer clickNum; + + @ApiModelProperty("创建人id") + private String createId; + + @ApiModelProperty("创建人姓名") + private String createName; + + @ApiModelProperty("创建人所属部门id") + private String departmentId; + + @ApiModelProperty("创建人所属部门姓名") + private String departmentName; + + @ApiModelProperty("创建时间") + private String createTime; + + @ApiModelProperty(value = "是否开启行为通知(1[true]是0[false]否)") + private Boolean enableClickNotice; + + @ApiModelProperty(value = "是否允许轨迹记录(1[true]是 0[false]否)") + private Boolean enableBehaviorRecord; + + @ApiModelProperty(value = "是否允许打上客户标签( 1[true]是 0[false]否)") + private Boolean enableCustomerTag; + + @ApiModelProperty(value = "更新后是否通知员工(true[1]是 false[0]否)") + private Boolean enableUpdateNotice; +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/sop/SopAttachmentVO.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/sop/SopAttachmentVO.java index a853242..229d449 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/sop/SopAttachmentVO.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/domain/vo/sop/SopAttachmentVO.java @@ -1,5 +1,6 @@ package com.easywecom.wecom.domain.vo.sop; +import com.easywecom.wecom.domain.vo.radar.WeRadarVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -16,7 +17,7 @@ public class SopAttachmentVO { @ApiModelProperty(value = "话术库附件ID") private Long id; - @ApiModelProperty(value = "0:海报,1:语音,2:视频,3:普通文件,4:文本,5:图文链接,6:小程序") + @ApiModelProperty(value = "0:海报,1:语音,2:视频,3:普通文件,4:文本,5:图文链接,6:小程序,7雷达") private Integer mediaType; @ApiModelProperty(value = "话术内容") @@ -41,4 +42,10 @@ public class SopAttachmentVO { */ @ApiModelProperty(value = "链接时使用:0 默认,1 自定义") private Boolean isDefined; + + @ApiModelProperty(value = "雷达id") + private Long radarId; + + @ApiModelProperty(value = "雷达VO") + private WeRadarVO radar; } diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/factory/impl/customer/WeCallBackAddExternalContactImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/factory/impl/customer/WeCallBackAddExternalContactImpl.java index d41aad6..9d0dcf4 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/factory/impl/customer/WeCallBackAddExternalContactImpl.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/factory/impl/customer/WeCallBackAddExternalContactImpl.java @@ -9,11 +9,12 @@ import com.easywecom.common.config.RuoYiConfig; import com.easywecom.common.constant.Constants; import com.easywecom.common.constant.GenConstants; import com.easywecom.common.constant.WeConstans; -import com.easywecom.common.core.domain.entity.WeCorpAccount; +import com.easywecom.common.constant.redeemcode.RedeemCodeConstants; import com.easywecom.common.core.redis.RedisCache; import com.easywecom.common.enums.*; import com.easywecom.common.enums.code.WelcomeMsgTypeEnum; import com.easywecom.common.exception.CustomException; +import com.easywecom.common.lock.LockUtil; import com.easywecom.common.utils.ExceptionUtil; import com.easywecom.common.utils.StringUtils; import com.easywecom.wecom.client.WeMessagePushClient; @@ -49,6 +50,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -90,23 +92,8 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { @Autowired private WeAutoTagRuleHitCustomerRecordService weAutoTagRuleHitCustomerRecordService; @Autowired - private WeMaterialMapper weMaterialMapper; - @Autowired private WeRedeemCodeService weRedeemCodeService; - @Autowired - private WeRedeemCodeActivityService weRedeemCodeActivityService; - private final WeCorpAccountService corpAccountService; - private final WeMessagePushClient messagePushClient; - private final WeRedeemCodeMapper weRedeemCodeMapper; - private final WeUserService weUserService; - @Autowired - public WeCallBackAddExternalContactImpl(WeCorpAccountService corpAccountService, WeMessagePushClient messagePushClient, WeRedeemCodeMapper weRedeemCodeMapper, WeUserService weUserService) { - this.corpAccountService = corpAccountService; - this.messagePushClient = messagePushClient; - this.weRedeemCodeMapper = weRedeemCodeMapper; - this.weUserService = weUserService; - } @Override @@ -228,16 +215,35 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { //更新活码添加方式 weFlowerCustomerRel.setState(state); weFlowerCustomerRelService.updateById(weFlowerCustomerRel); - - //给好友发送消息 - CompletableFuture.runAsync(() -> { + if (WelcomeMsgTypeEnum.COMMON_WELCOME_MSG_TYPE.getType().equals(messageMap.getWelcomeMsgType())) { + weEmpleCodeService.buildCommonWelcomeMsg(messageMap, corpId, externalUserId); + //给好友发送消息 + CompletableFuture.runAsync(() -> { + try { + sendMessageToNewExternalUserId(weWelcomeMsgBuilder, messageMap, weFlowerCustomerRel.getRemark(), corpId, userId, externalUserId, state); + } catch (Exception e) { + log.error("异步发送欢迎语消息异常:ex:{}", ExceptionUtil.getExceptionMessage(e)); + } + }); + } else if (WelcomeMsgTypeEnum.REDEEM_CODE_WELCOME_MSG_TYPE.getType().equals(messageMap.getWelcomeMsgType())) { try { - sendMessageToNewExternalUserId(weWelcomeMsgBuilder, messageMap, weFlowerCustomerRel.getRemark(), corpId, userId, externalUserId, state); + final String redeemCodeKey = RedeemCodeConstants.getRedeemCodeKey(corpId, messageMap.getCodeActivityId()); + if (LockUtil.tryLock(redeemCodeKey, RedeemCodeConstants.CODE_WAIT_TIME, RedeemCodeConstants.CODE_LEASE_TIME, TimeUnit.SECONDS)) { + weEmpleCodeService.buildRedeemCodeActivityWelcomeMsg(messageMap, corpId, externalUserId); + //同步发送消息 + sendMessageToNewExternalUserId(weWelcomeMsgBuilder, messageMap, weFlowerCustomerRel.getRemark(), corpId, userId, externalUserId, state); + log.info("[欢迎语回调]活动欢迎语处理完成,活动id:{},corpId:{}}", messageMap.getCodeActivityId(), corpId); + //发送欢迎语且更新兑换码信息后,释放锁 + LockUtil.unlock(RedeemCodeConstants.getRedeemCodeKey(corpId, messageMap.getCodeActivityId())); + } + } catch (InterruptedException e) { + log.error("[欢迎语回调]活动欢迎语获取锁失败,e:{},活动id:{},corpId:{}", ExceptionUtils.getStackTrace(e), messageMap.getCodeActivityId(), corpId); } catch (Exception e) { - log.error("异步发送欢迎语消息异常:ex:{}", ExceptionUtil.getExceptionMessage(e)); + log.error("[欢迎语回调]拼装活动欢迎语 或 同步发送欢迎语消息异常,e:{},活动id:{},corpId:{}", ExceptionUtils.getStackTrace(e), messageMap.getCodeActivityId(), corpId); + //内部处理逻辑报错,释放锁 + LockUtil.unlock(RedeemCodeConstants.getRedeemCodeKey(corpId, messageMap.getCodeActivityId())); } - }); - + } //为外部联系人添加员工活码标签 setEmplyCodeTag(weFlowerCustomerRel, empleCodeId, messageMap.getTagFlag()); @@ -369,7 +375,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { if (messageMap.getMaterialList().size() > WeConstans.MAX_ATTACHMENT_NUM) { throw new CustomException(ResultTip.TIP_ATTACHMENT_OVER); } - buildWeEmplyWelcomeMsg(state, corpId, weWelcomeMsgBuilder, messageMap.getMaterialList(), attachmentList); + buildWeEmplyWelcomeMsg(messageMap.getScenario(), userId, state, corpId, weWelcomeMsgBuilder, messageMap.getMaterialList(), attachmentList); } // 3.调用企业微信接口发送欢迎语 @@ -409,7 +415,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { } - private void buildWeEmplyWelcomeMsg(String state, String corpId, WeWelcomeMsg.WeWelcomeMsgBuilder builder, List weMaterialList, List attachmentList) { + private void buildWeEmplyWelcomeMsg(String scenario, String userId, String state, String corpId, WeWelcomeMsg.WeWelcomeMsgBuilder builder, List weMaterialList, List attachmentList) { if (StringUtils.isBlank(corpId) || CollectionUtils.isEmpty(weMaterialList) || builder == null) { throw new CustomException(ResultTip.TIP_MISS_CORP_ID); } @@ -420,7 +426,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { log.error("type is error!!!, type: {}", weMaterialVO.getMediaType()); continue; } - AttachmentParam param = AttachmentParam.costFromWeMaterialByType(weMaterialVO, typeEnum); + AttachmentParam param = AttachmentParam.costFromWeMaterialByType(scenario, userId, corpId, weMaterialVO, typeEnum); attachments = attachmentService.buildAttachment(param, corpId); // attachments = weMsgTlpMaterialService.buildByWelcomeMsgType(param.getContent(), param.getPicUrl(), param.getDescription(), param.getUrl(), typeEnum, corpId); if (attachments != null) { diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/interceptor/WechatOpenInterceptor.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/interceptor/WechatOpenInterceptor.java new file mode 100644 index 0000000..4e92dc2 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/interceptor/WechatOpenInterceptor.java @@ -0,0 +1,55 @@ +package com.easywecom.wecom.interceptor; + + +import com.dtflys.forest.exceptions.ForestRuntimeException; +import com.dtflys.forest.http.ForestRequest; +import com.dtflys.forest.http.ForestResponse; +import com.dtflys.forest.interceptor.Interceptor; +import com.easywecom.common.config.WechatOpenConfig; +import com.easywecom.wecom.service.wechatopen.WechatOpenService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; +import org.springframework.util.PatternMatchUtils; + +/** + * 类名: 微信公众平台接口访问拦截器 + * + * @author : silver_chariot + * @date : 2022/7/20 11:12 + **/ +@Component +@Slf4j +public class WechatOpenInterceptor implements Interceptor { + + + private final WechatOpenService wechatOpenService; + private final WechatOpenConfig wechatOpenConfig; + private final static String API_PREFIX = "https://api.weixin.qq.com"; + + @Lazy + public WechatOpenInterceptor(WechatOpenService wechatOpenService, WechatOpenConfig wechatOpenConfig) { + this.wechatOpenService = wechatOpenService; + this.wechatOpenConfig = wechatOpenConfig; + } + + @Override + public boolean beforeExecute(ForestRequest request) { + String uri = request.getUrl().replace(API_PREFIX, ""); + if (PatternMatchUtils.simpleMatch(wechatOpenConfig.getOfficialAccount().getNeedTokenUrl(), uri)) { + // 为请求设置access_token + wechatOpenService.setAccessToken(request); + } + return true; + } + + @Override + public void onSuccess(Object data, ForestRequest request, ForestResponse response) { + log.info("url:【{}】,result:【{}】", request.getUrl(), response.getContent()); + } + + @Override + public void onError(ForestRuntimeException ex, ForestRequest request, ForestResponse response) { + log.error("请求失败url:【{}】,result:【{}】", request.getUrl(), response.getContent()); + } +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarChannelMapper.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarChannelMapper.java new file mode 100644 index 0000000..fa8e44a --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarChannelMapper.java @@ -0,0 +1,28 @@ +package com.easywecom.wecom.mapper.radar; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.easywecom.wecom.domain.dto.radar.SearchRadarChannelDTO; +import com.easywecom.wecom.domain.entity.radar.WeRadarChannel; +import com.easywecom.wecom.domain.vo.radar.WeRadarChannelVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * ClassName: WeRadarChannelMapper + * + * @author wx + * @date 2022/7/19 15:46 + */ +@Mapper +public interface WeRadarChannelMapper extends BaseMapper { + /** + * 查询渠道列表 + * + * @param radarChannelDTO + * @param isSuperAdmin + * @return + */ + List list(@Param("channel") SearchRadarChannelDTO radarChannelDTO, @Param("isSuperAdmin") boolean isSuperAdmin); +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarClickRecordMapper.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarClickRecordMapper.java new file mode 100644 index 0000000..ae6baf8 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarClickRecordMapper.java @@ -0,0 +1,77 @@ +package com.easywecom.wecom.mapper.radar; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.easywecom.wecom.domain.dto.radar.*; +import com.easywecom.wecom.domain.entity.radar.WeRadarClickRecord; +import com.easywecom.wecom.domain.vo.radar.*; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * ClassName: WeRadarClickRecordMapper + * + * @author wx + * @date 2022/7/19 19:57 + */ +@Mapper +public interface WeRadarClickRecordMapper extends BaseMapper { + + /** + * 获取雷达数据总览 + * + * @param radarId + * @param nowDate + * @return + */ + RadarRecordTotalVO getTotal(@Param("radarId") Long radarId, @Param("nowDate") String nowDate); + + /** + * 查询雷达数据统计(折线图) + * + * @param radarAnalyseDTO + * @return + */ + List selectCountList(@Param("radarAnalyse") SearchRadarAnalyseDTO radarAnalyseDTO); + + /** + * 查询雷达渠道点击数排序 + * + * @param radarId + * @return + */ + List selectChannelSort(@Param("radarId") Long radarId); + + /** + * 获得客户点击记录 + * + * @param customerRecordDTO + * @return + */ + List getCustomerClickRecord(@Param("customerRecord") SearchCustomerRecordDTO customerRecordDTO); + + /** + * 获取渠道点击记录 + * + * @param channelRecordDTO + * @return + */ + List getChannelClickRecord(@Param("channelRecord") SearchChannelRecordDTO channelRecordDTO); + + /** + * 获取渠道点击记录详情 + * + * @param channelRecordDetailDTO + * @return + */ + List getChannelClickRecordDetail(@Param("channelRecordDetail") SearchChannelRecordDetailDTO channelRecordDetailDTO); + + /** + * 获取客户点击记录详情 + * + * @param customerRecordDTO + * @return + */ + List getCustomerClickRecordDetail(@Param("customerRecord") SearchCustomerRecordDetailDTO customerRecordDTO); +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarMapper.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarMapper.java new file mode 100644 index 0000000..7b2cfbe --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/radar/WeRadarMapper.java @@ -0,0 +1,78 @@ +package com.easywecom.wecom.mapper.radar; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.easywecom.wecom.domain.WeTag; +import com.easywecom.wecom.domain.dto.radar.RadarDTO; +import com.easywecom.wecom.domain.dto.radar.SearchRadarDTO; +import com.easywecom.wecom.domain.entity.radar.WeRadar; +import com.easywecom.wecom.domain.entity.radar.WeRadarTag; +import com.easywecom.wecom.domain.vo.radar.WeRadarVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * ClassName: WeRadarMapper + * + * @author wx + * @date 2022/7/18 15:36 + */ +@Mapper +public interface WeRadarMapper extends BaseMapper { + + /** + * 查询雷达列表 + * + * @param radarDTO + * @param isSuperAdmin + * @return + */ + List list(@Param("radar") SearchRadarDTO radarDTO, @Param("isSuperAdmin") boolean isSuperAdmin); + + + /** + * 获取详情 + * + * @param corpId + * @param id 雷达id + * @return + */ + WeRadarVO getOne(@Param("corpId") String corpId, @Param("id") Long id); + + /** + * 保存雷达客户标签 + * + * @param weRadarTagList + */ + void saveRadarTags(@Param("list") List weRadarTagList); + + /** + * 批量删除雷达客户标签 + * + * @param ids 雷达id序列 + */ + void batchDeleteRadarTags(@Param("ids") List ids); + + /** + * 删除雷达客户标签 + * + * @param radarId + */ + void deleteRadarTags(@Param("radarId") Long radarId); + + /** + * 获得长链 + * + * @param radarId + * @return + */ + String getRadarUrl(@Param("id") Long radarId); + /** + * 根据雷达id获取需要打上的标签 + * + * @param id 雷达id + * @return 需要打上的标签列表 + */ + List getTagListByRadarId(@Param("id") Long id); +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/wechatopen/WeOpenConfigMapper.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/wechatopen/WeOpenConfigMapper.java new file mode 100644 index 0000000..c0bfc8d --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/mapper/wechatopen/WeOpenConfigMapper.java @@ -0,0 +1,23 @@ +package com.easywecom.wecom.mapper.wechatopen; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.easywecom.wecom.domain.entity.wechatopen.WeOpenConfig; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** + * 类名: 微信公众平台设置持久层接口 + * + * @author : silver_chariot + * @date : 2022/7/25 14:07 + **/ +@Repository +@Mapper +public interface WeOpenConfigMapper extends BaseMapper { + /** + * 更新或者修改 + * + * @param config {@link WeOpenConfig} + */ + void insertOrUpdate(WeOpenConfig config); +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeCustomerMessagePushService.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeCustomerMessagePushService.java index fec2e8e..714981a 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeCustomerMessagePushService.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeCustomerMessagePushService.java @@ -2,6 +2,7 @@ package com.easywecom.wecom.service; import com.easywecom.common.core.domain.model.LoginUser; +import com.easywecom.wecom.domain.WeCustomer; import com.easywecom.wecom.domain.dto.WeCustomerMessageDTO; import com.easywecom.wecom.domain.dto.WeCustomerMessageToUserDTO; import com.easywecom.wecom.domain.dto.message.CustomerMessagePushDTO; @@ -10,6 +11,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import org.springframework.validation.annotation.Validated; import java.text.ParseException; +import java.util.Date; import java.util.List; /** @@ -20,12 +22,27 @@ import java.util.List; */ public interface WeCustomerMessagePushService { + + /** + * 客户的外部联系人id列表,仅在chat_type为single时有效,不可与sender同时为空,最多可传入1万个客户 + * + * @param corpId 企业id + * @param pushRange 消息范围 0 全部客户 1 指定客户 + * @param staffId 员工id + * @param tag 客户标签id列表 + * @param filterTags 过滤用的标签 + * @param gender 性别 + * @return {@link List} 客户的外部联系人id列表 + */ + List getExternalUserIds(String corpId, String pushRange, String staffId, String departmentIds, String tag, String filterTags, Integer gender, Date startTime, Date endTime); + /** * 新增群发消息发送 - * @param loginUser 登录用户 + * + * @param loginUser 登录用户 * @param customerMessagePush 原始数据信息 - * @throws JsonProcessingException JsonProcessingException - * @throws ParseException ParseException + * @throws JsonProcessingException JsonProcessingException + * @throws ParseException ParseException * @throws CloneNotSupportedException CloneNotSupportedException */ void addWeCustomerMessagePush(CustomerMessagePushDTO customerMessagePush, LoginUser loginUser) throws JsonProcessingException, ParseException, CloneNotSupportedException; diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeCustomerTrajectoryService.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeCustomerTrajectoryService.java index faff414..42e0ed7 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeCustomerTrajectoryService.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeCustomerTrajectoryService.java @@ -2,10 +2,13 @@ package com.easywecom.wecom.service; import com.baomidou.mybatisplus.extension.service.IService; import com.easywecom.common.core.domain.wecom.BaseExtendPropertyRel; +import com.easywecom.common.core.domain.wecom.WeUser; +import com.easywecom.wecom.domain.WeCustomer; import com.easywecom.wecom.domain.WeCustomerTrajectory; import com.easywecom.wecom.domain.WeGroupMember; import com.easywecom.wecom.domain.WeTag; import com.easywecom.wecom.domain.dto.customer.EditCustomerDTO; +import com.easywecom.wecom.domain.entity.radar.WeRadar; import java.util.List; @@ -83,5 +86,12 @@ public interface WeCustomerTrajectoryService extends IService listOfTrajectory(String corpId, String externalUserid, Integer trajectoryType, String userId); - + /** + * 记录活动轨迹(点击雷达链接) + * + * @param radar 雷达{@link WeRadar} + * @param user 员工 {@link WeUser} + * @param customer 客户 {@link WeCustomer} + */ + void recordRadarClickOperation(WeRadar radar, WeUser user, WeCustomer customer); } diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeDepartmentService.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeDepartmentService.java index 409ffd1..ba89245 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeDepartmentService.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeDepartmentService.java @@ -1,6 +1,7 @@ package com.easywecom.wecom.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.easywecom.common.core.domain.model.LoginUser; import com.easywecom.common.core.domain.wecom.WeDepartment; import com.easywecom.wecom.domain.vo.sop.DepartmentVO; @@ -17,12 +18,12 @@ public interface WeDepartmentService extends IService { /** * 查询企业微信组织架构相关列表 * - * - * @param corpId 公司id + * @param corpId 公司id * @param isActivate 激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业,6=删除 + * @param loginUser * @return 企业微信组织架构相关集合 */ - List selectWeDepartmentList(String corpId, Integer isActivate); + List selectWeDepartmentList(String corpId, Integer isActivate, LoginUser loginUser); /** * 根据用户ID获取部门名字 ,隔开 @@ -40,9 +41,10 @@ public interface WeDepartmentService extends IService { * * @param corpId 公司ID * @param isActivate 成员的激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业,6=删除 + * @param loginUser * @return 企业微信组织架构详情列表 */ - List selectWeDepartmentDetailList(String corpId, Integer isActivate); + List selectWeDepartmentDetailList(String corpId, Integer isActivate, LoginUser loginUser); /** * 新增企业微信组织架构相关 diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeEmpleCodeService.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeEmpleCodeService.java index 2d38300..b1a8cdb 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeEmpleCodeService.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/WeEmpleCodeService.java @@ -123,4 +123,21 @@ public interface WeEmpleCodeService extends IService { */ List getUserByEmplyCode(String corpId, Long id); + /** + * 构建普通欢迎语及附件 + * + * @param messageMap + * @param corpId + * @param externalUserId + */ + void buildCommonWelcomeMsg(SelectWeEmplyCodeWelcomeMsgVO messageMap, String corpId, String externalUserId); + + /** + * 构建兑换码活动欢迎语及附件 + * + * @param messageMap + * @param corpId + * @param externalUserId + */ + void buildRedeemCodeActivityWelcomeMsg(SelectWeEmplyCodeWelcomeMsgVO messageMap, String corpId, String externalUserId); } diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeCustomerMessagePushServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeCustomerMessagePushServiceImpl.java index ece3000..65d09b8 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeCustomerMessagePushServiceImpl.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeCustomerMessagePushServiceImpl.java @@ -15,6 +15,7 @@ import com.easywecom.common.utils.DateUtils; import com.easywecom.common.utils.ExceptionUtil; import com.easywecom.common.utils.SnowFlakeUtil; import com.easywecom.common.utils.StringUtils; +import com.easywecom.common.utils.spring.SpringUtils; import com.easywecom.wecom.client.WeMessagePushClient; import com.easywecom.wecom.domain.*; import com.easywecom.wecom.domain.dto.WeCustomerMessageDTO; @@ -25,6 +26,7 @@ import com.easywecom.wecom.domain.dto.message.*; import com.easywecom.wecom.domain.vo.CustomerMessagePushVO; import com.easywecom.wecom.mapper.WeCustomerMessageTimeTaskMapper; import com.easywecom.wecom.service.*; +import com.easywecom.wecom.service.radar.WeRadarService; import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; @@ -149,7 +151,7 @@ public class WeCustomerMessagePushServiceImpl implements WeCustomerMessagePushSe // 发给客户 if (WeConstans.SEND_MESSAGE_CUSTOMER.equals(customerMessagePushDTO.getPushType())) { //查询客户信息列表 - customers.addAll(externalUserIds(corpId, customerMessagePushDTO.getPushRange(), customerMessagePushDTO.getStaffId(), customerMessagePushDTO.getDepartment(), customerMessagePushDTO.getTag(), customerMessagePushDTO.getFilterTags(), customerMessagePushDTO.getGender(), customerMessagePushDTO.getCustomerStartTime(), customerMessagePushDTO.getCustomerEndTime())); + customers.addAll(getExternalUserIds(corpId, customerMessagePushDTO.getPushRange(), customerMessagePushDTO.getStaffId(), customerMessagePushDTO.getDepartment(), customerMessagePushDTO.getTag(), customerMessagePushDTO.getFilterTags(), customerMessagePushDTO.getGender(), customerMessagePushDTO.getCustomerStartTime(), customerMessagePushDTO.getCustomerEndTime())); if (CollectionUtils.isEmpty(customers)) { throw new CustomException(ResultTip.TIP_NO_CUSTOMER); } @@ -375,7 +377,15 @@ public class WeCustomerMessagePushServiceImpl implements WeCustomerMessagePushSe } private WeCustomerMessageTimeTask getTimeTask(Long messageId) { - return customerMessageTimeTaskMapper.getTimeTask(messageId); + final WeCustomerMessageTimeTask timeTask = customerMessageTimeTaskMapper.getTimeTask(messageId); + if (CollectionUtils.isNotEmpty(timeTask.getMessageInfo().getAttachments())) { + timeTask.getMessageInfo().getAttachments().forEach(item -> { + if (GroupMessageType.RADAR.getType().equals(item.getMsgtype())) { + item.getRadarMessage().setRadar(SpringUtils.getBean(WeRadarService.class).getRadar(timeTask.getMessageInfo().getCorpId(), item.getRadarMessage().getRadarId())); + } + }); + } + return timeTask; } /** @@ -389,7 +399,8 @@ public class WeCustomerMessagePushServiceImpl implements WeCustomerMessagePushSe * @param gender 性别 * @return {@link List} 客户的外部联系人id列表 */ - private List externalUserIds(String corpId, String pushRange, String staffId, String departmentIds, String tag, String filterTags, Integer gender, Date startTime, Date endTime) { + @Override + public List getExternalUserIds(String corpId, String pushRange, String staffId, String departmentIds, String tag, String filterTags, Integer gender, Date startTime, Date endTime) { //校验CorpId StringUtils.checkCorpId(corpId); if (pushRange.equals(WeConstans.SEND_MESSAGE_CUSTOMER_ALL)) { @@ -452,6 +463,11 @@ public class WeCustomerMessagePushServiceImpl implements WeCustomerMessagePushSe linkMessage.setDesc(customerSeedMessage.getLinDesc()); linkMessage.setPicurl(customerSeedMessage.getPicUrl()); attachment.setLinkMessage(linkMessage); + } else if (GroupMessageType.RADAR.getType().equals(msgtype)) { + RadarMessageDTO radarMessage = new RadarMessageDTO(); + radarMessage.setRadarId(customerSeedMessage.getRadarId()); + radarMessage.setRadar(SpringUtils.getBean(WeRadarService.class).getRadar(customerMessagePushDTO.getCorpId(), radarMessage.getRadarId())); + attachment.setRadarMessage(radarMessage); } //视频 else if (GroupMessageType.VIDEO.getType().equals(msgtype)) { diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeCustomerMessageServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeCustomerMessageServiceImpl.java index 6efb55c..14f0f99 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeCustomerMessageServiceImpl.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeCustomerMessageServiceImpl.java @@ -11,6 +11,7 @@ import com.easywecom.common.core.redis.RedisCache; import com.easywecom.common.enums.*; import com.easywecom.common.exception.CustomException; import com.easywecom.common.utils.StringUtils; +import com.easywecom.common.utils.spring.SpringUtils; import com.easywecom.wecom.client.WeCustomerMessagePushClient; import com.easywecom.wecom.domain.WeCustomer; import com.easywecom.wecom.domain.WeCustomerMessage; @@ -21,20 +22,19 @@ import com.easywecom.wecom.domain.dto.common.Attachments; import com.easywecom.wecom.domain.dto.message.*; import com.easywecom.wecom.login.util.LoginTokenService; import com.easywecom.wecom.mapper.WeCustomerMessageMapper; -import com.easywecom.wecom.service.WeCustomerMessageService; -import com.easywecom.wecom.service.WeCustomerMessgaeResultService; -import com.easywecom.wecom.service.WeMaterialService; -import com.easywecom.wecom.service.WeMsgTlpMaterialService; +import com.easywecom.wecom.service.*; import com.easywecom.wecom.utils.AttachmentService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -134,11 +134,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl externalUserIds = customers.stream().map(WeCustomer::getExternalUserid).collect(Collectors.toList()); - messagePushDto.setExternal_userid(externalUserIds); - childMessage(messagePushDto, customerMessagePushDTO); - //调用企微接口发送 - sendMessage(messagePushDto, customerMessagePushDTO.getCorpId(), messageId, msgid); + singleSendMessage(customerMessagePushDTO, messagePushDto, messageId, msgid, customers); } else { //发给客户群 messagePushDto.setChat_type(ChatType.of(customerMessagePushDTO.getPushType()).getName()); @@ -154,6 +150,36 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl msgId, List customers) { + final Set userIds = customers.stream().map(WeCustomer::getUserId).collect(Collectors.toSet()); + for (String userId : userIds) { + messagePushDto.setSender(userId); + //查找该员工对应的客户 + messagePushDto.setExternal_userid(SpringUtils.getBean(WeCustomerMessagePushService.class).getExternalUserIds(customerMessagePushDTO.getCorpId(), + customerMessagePushDTO.getPushRange(), + userId, + customerMessagePushDTO.getDepartment(), + customerMessagePushDTO.getTag(), + customerMessagePushDTO.getFilterTags(), + customerMessagePushDTO.getGender(), + customerMessagePushDTO.getCustomerStartTime(), + customerMessagePushDTO.getCustomerEndTime()).stream().map(WeCustomer::getExternalUserid).collect(Collectors.toList())); + childMessage(messagePushDto, customerMessagePushDTO); + //调用企微接口发送 + sendMessage(messagePushDto, customerMessagePushDTO.getCorpId(), messageId, msgId); + } + } + @Override public int deleteByMessageId(Long messageId, String corpId) { StringUtils.checkCorpId(corpId); @@ -216,7 +242,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl { - AttachmentParam param = AttachmentParam.costFromAttachment(attachment); + AttachmentParam param = AttachmentParam.costFromAttachment(weCustomerMessagePushDTO.getSender(), customerMessagePushDTO.getCorpId(), customerMessagePushDTO.getTaskName(), attachment); Attachments attach = null; try { attach = attachmentService.buildAttachment(param, customerMessagePushDTO.getCorpId()); @@ -269,6 +295,9 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl taskEntityList, WeCustomerTrajectory weCustomerTrajectory) { List materialList = new ArrayList<>(); for (WeOperationsCenterSopTaskEntity taskEntity : taskEntityList) { diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeDepartmentServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeDepartmentServiceImpl.java index 0dd5ddd..a0672e6 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeDepartmentServiceImpl.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeDepartmentServiceImpl.java @@ -6,10 +6,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.easywecom.common.constant.WeConstans; +import com.easywecom.common.core.domain.model.LoginUser; import com.easywecom.common.core.domain.wecom.WeDepartment; import com.easywecom.common.core.domain.wecom.WeUser; import com.easywecom.common.enums.WeExceptionTip; import com.easywecom.common.exception.CustomException; +import com.easywecom.common.service.ISysDeptService; import com.easywecom.common.utils.StringUtils; import com.easywecom.wecom.client.WeDepartMentClient; import com.easywecom.wecom.domain.dto.WeDepartMentDTO; @@ -28,7 +30,9 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * 企业微信组织架构相关Service业务层处理 @@ -47,21 +51,23 @@ public class WeDepartmentServiceImpl extends ServiceImpl selectWeDepartmentList(String corpId, Integer isActivate) { + public List selectWeDepartmentList(String corpId, Integer isActivate, LoginUser loginUser) { if (StringUtils.isBlank(corpId)) { return Collections.emptyList(); } - return this.selectWeDepartmentDetailList(corpId, isActivate); + return this.selectWeDepartmentDetailList(corpId, isActivate, loginUser); } /** @@ -77,11 +83,14 @@ public class WeDepartmentServiceImpl extends ServiceImpl selectWeDepartmentDetailList(String corpId, Integer isActivate) { + public List selectWeDepartmentDetailList(String corpId, Integer isActivate, LoginUser loginUser) { List list = this.baseMapper.selectWeDepartmentList(corpId); - list.forEach(d -> { + final List departments = sysDeptService.filterDepartmentDataScope(list, loginUser); + //key:departmentId value: departmentId + final Map map = departments.stream().collect(Collectors.toMap(WeDepartment::getId, WeDepartment::getId)); + departments.forEach(d -> { //查询出该部门和其所有下级部门ID - List deptAndChildren = this.baseMapper.selectDepartmentAndChildList(d); + List deptAndChildren = this.baseMapper.selectDepartmentAndChildList(d).stream().filter(a -> map.containsKey(a.getId())).collect(Collectors.toList()); //查询所有用户数 if (CollectionUtils.isEmpty(deptAndChildren)) { d.setTotalUserCount(0); diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeEmpleCodeServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeEmpleCodeServiceImpl.java index 1995c9d..62d0707 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeEmpleCodeServiceImpl.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeEmpleCodeServiceImpl.java @@ -5,11 +5,13 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.easywecom.common.constant.WeConstans; +import com.easywecom.common.constant.redeemcode.RedeemCodeConstants; import com.easywecom.common.core.redis.RedisCache; import com.easywecom.common.enums.*; import com.easywecom.common.enums.code.WelcomeMsgTypeEnum; import com.easywecom.common.exception.CustomException; import com.easywecom.common.utils.DateUtils; +import com.easywecom.common.utils.spring.SpringUtils; import com.easywecom.wecom.client.WeExternalContactClient; import com.easywecom.wecom.domain.*; import com.easywecom.wecom.domain.dto.AddWeMaterialDTO; @@ -25,9 +27,10 @@ import com.easywecom.wecom.domain.vo.WeEmplyCodeScopeUserVO; import com.easywecom.wecom.domain.vo.redeemcode.WeRedeemCodeActivityVO; import com.easywecom.wecom.login.util.LoginTokenService; import com.easywecom.wecom.mapper.WeEmpleCodeMapper; -import com.easywecom.wecom.mapper.redeemcode.WeRedeemCodeActivityMapper; import com.easywecom.wecom.mapper.redeemcode.WeRedeemCodeMapper; import com.easywecom.wecom.service.*; +import com.easywecom.wecom.service.radar.MiniAppQrCodeUrlHandler; +import com.easywecom.wecom.service.radar.WeRadarService; import com.easywecom.wecom.service.redeemcode.WeRedeemCodeActivityService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -61,13 +64,14 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl { //设置活码使用人/部门对象 - setUserData(employCode,useScopeList,departmentScopeList); + setUserData(employCode, useScopeList, departmentScopeList); //员工活码标签对象 employCode.setWeEmpleCodeTags(tagList.stream().filter(tag -> tag.getEmpleCodeId().equals(employCode.getId())).collect(Collectors.toList())); //组装数据(员工活码=>素材数据,新客建群=>添加人数、群活码数据、群实际数据) @@ -161,6 +166,14 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl materialList, String corpId) { + materialList.forEach(item -> { + if (AttachmentTypeEnum.RADAR.getMessageType().equals(item.getMediaType())) { + item.setRadar(SpringUtils.getBean(WeRadarService.class).getRadar(corpId, item.getRadarId())); + } + }); + } + /** * 根据附件排序查找添加素材 * @@ -171,6 +184,7 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl materialList = weMaterialService.getListByMaterialSort(employCode.getMaterialSort(), corpId); + buildRadarDate(materialList, corpId); employCode.setMaterialList(materialList); } else { employCode.setMaterialList(Collections.emptyList()); @@ -180,12 +194,15 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl successMaterialList = weMaterialService.getRedeemCodeListByMaterialSort(employCode.getCodeSuccessMaterialSort(), corpId); + buildRadarDate(successMaterialList, corpId); employCode.setCodeSuccessMaterialList(successMaterialList); List failMaterialList = weMaterialService.getRedeemCodeListByMaterialSort(employCode.getCodeFailMaterialSort(), corpId); + buildRadarDate(failMaterialList, corpId); employCode.setCodeFailMaterialList(failMaterialList); List repeatMaterialList = weMaterialService.getRedeemCodeListByMaterialSort(employCode.getCodeRepeatMaterialSort(), corpId); + buildRadarDate(repeatMaterialList, corpId); employCode.setCodeRepeatMaterialList(repeatMaterialList); } } @@ -237,9 +254,14 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl useScopeList, List departmentScopeList) { List setUseScopeList = new LinkedList<>(); - if(CollUtil.isNotEmpty(useScopeList)){ + if (CollUtil.isNotEmpty(useScopeList)) { StringBuilder userUserName = new StringBuilder(); StringBuilder mobile = new StringBuilder(); - useScopeList.forEach(useScope->{ - if(useScope.getEmpleCodeId().equals(employCode.getId()) + useScopeList.forEach(useScope -> { + if (useScope.getEmpleCodeId().equals(employCode.getId()) && WeConstans.USE_SCOP_BUSINESSID_TYPE_USER.equals(useScope.getBusinessIdType()) - && StringUtils.isNotEmpty(useScope.getBusinessName())){ + && StringUtils.isNotEmpty(useScope.getBusinessName())) { userUserName.append(useScope.getBusinessName()).append(WeConstans.COMMA); mobile.append(useScope.getMobile()).append(WeConstans.COMMA); setUseScopeList.add(useScope); } }); - if(StringUtils.isNotEmpty(userUserName)){ + if (StringUtils.isNotEmpty(userUserName)) { //删除最后一个"," - userUserName.deleteCharAt(userUserName.length()-1); + userUserName.deleteCharAt(userUserName.length() - 1); } - if(StringUtils.isNotEmpty(mobile)){ + if (StringUtils.isNotEmpty(mobile)) { //删除最后一个"," - mobile.deleteCharAt(mobile.length()-1); + mobile.deleteCharAt(mobile.length() - 1); } employCode.setUseUserName(userUserName.toString()); employCode.setMobile(mobile.toString()); } - if(CollUtil.isNotEmpty(departmentScopeList)){ + if (CollUtil.isNotEmpty(departmentScopeList)) { StringBuilder departmentName = new StringBuilder(); - departmentScopeList.forEach(departScope->{ - if(departScope.getEmpleCodeId().equals(employCode.getId()) + departmentScopeList.forEach(departScope -> { + if (departScope.getEmpleCodeId().equals(employCode.getId()) && WeConstans.USE_SCOP_BUSINESSID_TYPE_ORG.equals(departScope.getBusinessIdType()) - && StringUtils.isNotEmpty(departScope.getBusinessName())){ + && StringUtils.isNotEmpty(departScope.getBusinessName())) { departmentName.append(departScope.getBusinessName()).append(WeConstans.COMMA); setUseScopeList.add(departScope); } }); - if(StringUtils.isNotEmpty(departmentName)){ + if (StringUtils.isNotEmpty(departmentName)) { //删除最后一个"," - departmentName.deleteCharAt(departmentName.length()-1); + departmentName.deleteCharAt(departmentName.length() - 1); } employCode.setDepartmentName(departmentName.toString()); } diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeMsgTlpMaterialServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeMsgTlpMaterialServiceImpl.java index 48bb7f7..ad39c3b 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeMsgTlpMaterialServiceImpl.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeMsgTlpMaterialServiceImpl.java @@ -5,16 +5,17 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.easywecom.common.constant.WeConstans; +import com.easywecom.common.constant.redeemcode.RedeemCodeConstants; +import com.easywecom.common.core.domain.wecom.WeUser; import com.easywecom.common.enums.MediaType; import com.easywecom.common.enums.ResultTip; import com.easywecom.common.enums.AttachmentTypeEnum; +import com.easywecom.common.enums.radar.RadarChannelEnum; import com.easywecom.common.exception.CustomException; import com.easywecom.common.utils.StringUtils; +import com.easywecom.common.utils.spring.SpringUtils; import com.easywecom.wecom.client.WeWelcomeMsgClient; -import com.easywecom.wecom.domain.WeCustomer; -import com.easywecom.wecom.domain.WeMsgTlp; -import com.easywecom.wecom.domain.WeMsgTlpMaterial; -import com.easywecom.wecom.domain.WeMsgTlpSpecialRule; +import com.easywecom.wecom.domain.*; import com.easywecom.wecom.domain.dto.WeMediaDTO; import com.easywecom.wecom.domain.dto.WeWelcomeMsg; import com.easywecom.wecom.domain.dto.common.*; @@ -25,6 +26,7 @@ import com.easywecom.wecom.domain.dto.welcomemsg.GroupWelcomeMsgUpdateDTO; import com.easywecom.wecom.domain.vo.WeUserVO; import com.easywecom.wecom.mapper.WeMsgTlpMaterialMapper; import com.easywecom.wecom.service.*; +import com.easywecom.wecom.service.radar.WeRadarChannelService; import com.easywecom.wecom.utils.AttachmentService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -297,7 +299,7 @@ public class WeMsgTlpMaterialServiceImpl extends ServiceImpl i if (StringUtils.isEmpty(weMsgTlp.getCorpId())) { throw new CustomException(ResultTip.TIP_GENERAL_BAD_REQUEST); } - return weMsgTlpMapper.selectWeMsgTlpList(weMsgTlp); + List list = weMsgTlpMapper.selectWeMsgTlpList(weMsgTlp); + list.forEach(item -> { + buildRadarDate(item.getDefaultMaterialList(), weMsgTlp.getCorpId()); + //特殊规则附件 + item.getWeMsgTlpSpecialRules().forEach(specialRule -> buildRadarDate(specialRule.getSpecialMaterialList(), weMsgTlp.getCorpId())); + }); + + return list; } /** @@ -186,7 +198,30 @@ public class WeMsgTlpServiceImpl extends ServiceImpl i if (StringUtils.isEmpty(weMsgTlp.getCorpId()) || weMsgTlp.getId() == null) { throw new CustomException(ResultTip.TIP_GENERAL_BAD_REQUEST); } - return weMsgTlpMapper.selectWeMsgTlpList(weMsgTlp).get(0); + final WeMsgTlpListVO weMsgTlpListVO = weMsgTlpMapper.selectWeMsgTlpList(weMsgTlp).get(0); + buildRadarDate(weMsgTlpListVO.getDefaultMaterialList(), weMsgTlp.getCorpId()); + //特殊规则附件 + weMsgTlpListVO.getWeMsgTlpSpecialRules().forEach(item -> { + buildRadarDate(item.getSpecialMaterialList(), weMsgTlp.getCorpId()); + }); + return weMsgTlpListVO; + } + + /** + * 组装雷达数据 + * + * @param materialList + * @param corpId + */ + private void buildRadarDate(List materialList, String corpId) { + if (CollectionUtils.isEmpty(materialList)) { + return; + } + materialList.forEach(item -> { + if (AttachmentTypeEnum.RADAR.getMessageType().equals(item.getType())) { + item.setRadar(SpringUtils.getBean(WeRadarService.class).getRadar(corpId, item.getRadarId())); + } + }); } /** diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeWordsDetailServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeWordsDetailServiceImpl.java index 67238a9..0cd64c3 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeWordsDetailServiceImpl.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/WeWordsDetailServiceImpl.java @@ -142,6 +142,9 @@ public class WeWordsDetailServiceImpl extends ServiceImpl ATTACHMENT_TITLE_SIZE) { throw new CustomException(ResultTip.TIP_WORDS_OVER_TITLE); } + + if (WeCategoryMediaTypeEnum.RADAR.getMediaType().equals(weWordsDetailEntity.getMediaType())) { + if (StringUtils.isNotBlank(weWordsDetailEntity.getTitle()) && weWordsDetailEntity.getTitle().length() > LINK_TITLE_SIZE) { + throw new CustomException(ResultTip.TIP_WORDS_OVER_TITLE); + } + } else if (weWordsDetailEntity.getTitle().length() > ATTACHMENT_TITLE_SIZE) { + throw new CustomException(ResultTip.TIP_WORDS_OVER_TITLE); + } + } } } \ No newline at end of file diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/moment/WeMomentTaskServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/moment/WeMomentTaskServiceImpl.java index 9ba16fb..4abda4d 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/moment/WeMomentTaskServiceImpl.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/moment/WeMomentTaskServiceImpl.java @@ -103,14 +103,17 @@ public class WeMomentTaskServiceImpl extends ServiceImpl userScope = getUserScope(loginUser, createMomentTaskDTO.getUsers(), departmentScope); - WeMomentTaskEntity weMomentTaskEntity = new WeMomentTaskEntity(createMomentTaskDTO,new ArrayList<>(userScope), departmentScope, loginUser.getUserId()); + WeMomentTaskEntity weMomentTaskEntity = new WeMomentTaskEntity(createMomentTaskDTO, new ArrayList<>(userScope), departmentScope, loginUser.getUserId()); + if (CollectionUtils.isNotEmpty(createMomentTaskDTO.getUsers()) || CollectionUtils.isNotEmpty(createMomentTaskDTO.getDepartments())) { + weMomentTaskEntity.setSelectUser(MomentSelectUserEnum.SELECT_USER.getType()); + } //先上传一遍素材判断是否合法 if (CollectionUtils.isNotEmpty(createMomentTaskDTO.getAttachments())) { buildMomentAttachment(createMomentTaskDTO.getAttachments(), weMomentTaskEntity.getCorpId()); } //保存任务附件 - saveMomentDetail(createMomentTaskDTO.getCorpId(),createMomentTaskDTO.getAttachments()); - if (createMomentTaskDTO.getText() != null &&StringUtils.isNotBlank(createMomentTaskDTO.getText().getContent())){ + saveMomentDetail(createMomentTaskDTO.getCorpId(), createMomentTaskDTO.getAttachments()); + if (createMomentTaskDTO.getText() != null && StringUtils.isNotBlank(createMomentTaskDTO.getText().getContent())) { weMomentTaskEntity.setContent(createMomentTaskDTO.getText().getContent()); } //保存we_moment_detail_rel附件关联表 diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarChannelServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarChannelServiceImpl.java new file mode 100644 index 0000000..e9e1eac --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarChannelServiceImpl.java @@ -0,0 +1,152 @@ +package com.easywecom.wecom.service.impl.radar; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.easywecom.common.constant.Constants; +import com.easywecom.common.constant.radar.RadarConstants; +import com.easywecom.common.enums.radar.RadarChannelEnum; +import com.easywecom.common.exception.CustomException; +import com.easywecom.common.shorturl.ShortUrlAppendInfo; +import com.easywecom.common.utils.DateUtils; +import com.easywecom.common.utils.bean.BeanUtils; +import com.easywecom.wecom.domain.dto.radar.DeleteRadarChannelDTO; +import com.easywecom.wecom.domain.dto.radar.RadarChannelDTO; +import com.easywecom.wecom.domain.dto.radar.SearchRadarChannelDTO; +import com.easywecom.wecom.domain.entity.radar.WeRadarChannel; +import com.easywecom.wecom.domain.vo.radar.WeRadarChannelVO; +import com.easywecom.wecom.login.util.LoginTokenService; +import com.easywecom.wecom.mapper.radar.WeRadarChannelMapper; +import com.easywecom.wecom.mapper.radar.WeRadarMapper; +import com.easywecom.wecom.service.radar.RadarUrlHandler; +import com.easywecom.wecom.service.radar.WeRadarChannelService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * ClassName: WeRadarChannelServiceImpl + * + * @author wx + * @date 2022/7/19 15:44 + */ +@Slf4j +@Service +public class WeRadarChannelServiceImpl extends ServiceImpl implements WeRadarChannelService { + + + private final RadarUrlHandler radarUrlHandler; + private final WeRadarMapper weRadarMapper; + + @Autowired + @Lazy + public WeRadarChannelServiceImpl(RadarUrlHandler radarUrlHandler, WeRadarMapper weRadarMapper) { + this.radarUrlHandler = radarUrlHandler; + this.weRadarMapper = weRadarMapper; + } + + /** + * 生成短链 + * + * @param corpId + * @param radarId + * @param userName + * @param channelType + * @param detail + * @return + */ + @Override + public String createShortUrl(String corpId, Long radarId, String userName, Integer channelType, String detail) { + //长链 + String url = weRadarMapper.getRadarUrl(radarId); + final ShortUrlAppendInfo shortUrlAppendInfo = radarUrlHandler.buildAppendInfo(radarId, userName, channelType, detail); + return radarUrlHandler.createRadarUrl(corpId, url, userName, shortUrlAppendInfo); + } + + /** + * 新增雷达渠道 + * + * @param radarChannelDTO + */ + @Override + public void saveRadarChannel(RadarChannelDTO radarChannelDTO) { + final WeRadarChannel selectRadarChannel = this.baseMapper.selectOne(new LambdaQueryWrapper() + .eq(WeRadarChannel::getRadarId, radarChannelDTO.getRadarId()) + .eq(WeRadarChannel::getName, radarChannelDTO.getName())); + if (ObjectUtils.isNotEmpty(selectRadarChannel)) { + throw new CustomException(RadarConstants.PromptCus.RADAR_CHANNEL_REPEAT); + } + WeRadarChannel radarChannel = radarChannelDTO.buildWeRadarChannel(); + radarChannel.setCreateTime(DateUtils.getTime()); + final boolean superAdmin = LoginTokenService.getLoginUser().isSuperAdmin(); + if (superAdmin) { + radarChannel.setCreateBy(LoginTokenService.getUsername()); + } else { + radarChannel.setCreateBy(LoginTokenService.getLoginUser().getWeUser().getUserId()); + } + + //长链 + //设置短链 + radarChannel.setShortUrl(createShortUrl(LoginTokenService.getLoginUser().getCorpId(), radarChannel.getRadarId(), radarChannel.getCreateBy(), RadarChannelEnum.CUSTOMIZE.getTYPE(), radarChannel.getName())); + this.baseMapper.insert(radarChannel); + } + + /** + * 查询雷达渠道列表 + * + * @param radarChannelDTO + * @return + */ + @Override + public List getRadarChannelList(SearchRadarChannelDTO radarChannelDTO) { + final boolean isSuperAdmin = LoginTokenService.getLoginUser().isSuperAdmin(); + radarChannelDTO.setCorpId(LoginTokenService.getLoginUser().getCorpId()); + List list = this.baseMapper.list(radarChannelDTO, isSuperAdmin); + list.forEach(item -> { + if (Constants.SUPER_ADMIN.equals(item.getCreateId())) { + item.setCreateName(Constants.SUPER_ADMIN); + } + }); + return list; + } + + /** + * 批量删除雷达渠道 + * + * @param deleteDTO + * @return + */ + @Override + public void batchRemoveRadarChannel(DeleteRadarChannelDTO deleteDTO) { + this.removeByIds(deleteDTO.getIdList()); + } + + /** + * 获取渠道详情 + * + * @param corpId + * @param id + * @return + */ + @Override + public WeRadarChannelVO getRadarChannel(String corpId, Long id) { + final WeRadarChannel radarChannel = this.baseMapper.selectById(id); + WeRadarChannelVO weRadarChannelVO = new WeRadarChannelVO(); + BeanUtils.copyProperties(radarChannel, weRadarChannelVO); + return weRadarChannelVO; + } + + /** + * 修改渠道 + * + * @param radarChannelDTO + */ + @Override + public void updateRadarChannel(RadarChannelDTO radarChannelDTO) { + final WeRadarChannel radarChannel = radarChannelDTO.buildWeRadarChannel(); + this.baseMapper.updateById(radarChannel); + } +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarClickRecordServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarClickRecordServiceImpl.java new file mode 100644 index 0000000..4c80ce9 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarClickRecordServiceImpl.java @@ -0,0 +1,228 @@ +package com.easywecom.wecom.service.impl.radar; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.easywecom.common.constant.radar.RadarConstants; +import com.easywecom.common.core.domain.wecom.WeUser; +import com.easywecom.common.enums.ResultTip; +import com.easywecom.common.enums.radar.RadarChannelEnum; +import com.easywecom.common.exception.CustomException; +import com.easywecom.common.shorturl.ShortUrlAppendInfo; +import com.easywecom.common.utils.DateUtils; +import com.easywecom.wecom.domain.WeCustomer; +import com.easywecom.wecom.domain.dto.radar.*; +import com.easywecom.wecom.domain.entity.radar.WeRadarClickRecord; +import com.easywecom.wecom.domain.vo.radar.*; +import com.easywecom.wecom.mapper.radar.WeRadarClickRecordMapper; +import com.easywecom.wecom.service.radar.WeRadarChannelService; +import com.easywecom.wecom.service.radar.WeRadarClickRecordService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * ClassName: WeRadarClickRecordServiceImpl + * + * @author wx + * @date 2022/7/19 19:56 + */ +@Service +@Slf4j +public class WeRadarClickRecordServiceImpl extends ServiceImpl implements WeRadarClickRecordService { + + + /** + * 保存雷达记录 + * + * @param clickRecordDTO + */ + @Override + public void saveClickRecord(RadarClickRecordDTO clickRecordDTO) { + final WeRadarClickRecord radarClickRecord = clickRecordDTO.buildData(); + this.save(radarClickRecord); + } + + @Override + public RadarRecordTotalVO getTotal(Long radarId) { + String nowDate = DateUtils.getDate(); + return this.baseMapper.getTotal(radarId, nowDate); + } + + /** + * 查询雷达数据统计(折线图) + * + * @param radarAnalyseDTO + * @return + */ + @Override + public RadarAnalyseVO getTimeRangeAnalyseCount(SearchRadarAnalyseDTO radarAnalyseDTO) { + verifyParam(radarAnalyseDTO); + + //查询两个时间内的所有日期 + List dates; + if (ObjectUtils.isNotEmpty(radarAnalyseDTO.getBeginTime())) { + Date startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD, radarAnalyseDTO.getBeginTime()); + Date endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD, radarAnalyseDTO.getEndTime()); + dates = DateUtils.findDates(startTime, endTime); + } else { + Date startTime = DateUtils.dateSubDay(DateUtils.getNowDate(), RadarConstants.RadarAnalyseCount.DEFAULT_DAY - 1); + Date endTime = DateUtils.getNowDate(); + dates = DateUtils.findDates(startTime, endTime); + } + List list = this.baseMapper.selectCountList(radarAnalyseDTO); + + + Map dataMap = new HashMap<>(list.size()); + if (CollectionUtils.isNotEmpty(list)) { + for (RadarAnalyseCountVO item : list) { + dataMap.put(item.getCreateDate(), item); + } + } + List resultList = new ArrayList<>(); + RadarAnalyseCountVO analyseCountVO; + for (Date date : dates) { + String time = DateUtils.dateTime(date); + analyseCountVO = dataMap.get(time); + if (analyseCountVO == null) { + analyseCountVO = RadarAnalyseCountVO.builder() + .createDate(time) + .clickPersonNum(RadarConstants.RadarAnalyseCount.ZERO) + .sumClickNum(RadarConstants.RadarAnalyseCount.ZERO).build(); + } + resultList.add(analyseCountVO); + } + return RadarAnalyseVO.builder() + .list(resultList) + .total(dates.size()).build(); + } + + /** + * 查询渠道排序 + * + * @param radarId + * @return + */ + @Override + public List getChannelSort(Long radarId) { + if (ObjectUtils.isEmpty(radarId)) { + throw new CustomException(RadarConstants.ParamVerify.PARAM_NULL); + } + return this.baseMapper.selectChannelSort(radarId); + } + + /** + * 获取客户点击记录 + * + * @param customerRecordDTO + * @return + */ + @Override + public List getCustomerClickRecord(SearchCustomerRecordDTO customerRecordDTO) { + if (ObjectUtils.isEmpty(customerRecordDTO)) { + throw new CustomException(RadarConstants.ParamVerify.PARAM_NULL); + } + return this.baseMapper.getCustomerClickRecord(customerRecordDTO); + } + + /** + * 获取渠道点击记录 + * + * @param channelRecordDTO + * @return + */ + @Override + public List getChannelClickRecord(SearchChannelRecordDTO channelRecordDTO) { + if (ObjectUtils.isEmpty(channelRecordDTO)) { + throw new CustomException(RadarConstants.ParamVerify.PARAM_NULL); + } + return this.baseMapper.getChannelClickRecord(channelRecordDTO); + } + + /** + * 获取渠道点击记录详情 + * + * @param channelRecordDetailDTO + * @return + */ + @Override + public List getChannelClickRecordDetail(SearchChannelRecordDetailDTO channelRecordDetailDTO) { + if (ObjectUtils.isEmpty(channelRecordDetailDTO)) { + throw new CustomException(RadarConstants.ParamVerify.PARAM_NULL); + } + return this.baseMapper.getChannelClickRecordDetail(channelRecordDetailDTO); + } + + @Override + public List getCustomerClickRecordDetail(SearchCustomerRecordDetailDTO customerRecordDTO) { + if (ObjectUtils.isEmpty(customerRecordDTO)) { + throw new CustomException(RadarConstants.ParamVerify.PARAM_NULL); + } + List list = this.baseMapper.getCustomerClickRecordDetail(customerRecordDTO); + list.forEach(item -> { + item.setRecordText(RadarConstants.RadarCustomerClickRecord.getRecordText(item.getCustomerName(), item.getUserName(), item.getDetail(), item.getChannelType(), item.getChannelName())); + }); + return list; + } + + @Override + public void createRecord(ShortUrlAppendInfo appendInfo, WeCustomer customer, String openId, WeUser user) { + if (appendInfo == null || appendInfo.getRadarId() == null || customer == null || StringUtils.isAnyBlank(customer.getUnionid())) { + log.info("[保存雷达记录]参数缺失,append:{},customer:{},openId:{},user:{}", appendInfo, customer, openId, user); + return; + } + String channelName; + Integer channelType; + // 如果是系統渠道取系統渠道名和類型 + if (RadarChannelEnum.isSysChannel(appendInfo.getChannelType())) { + channelType = appendInfo.getChannelType(); + channelName = RadarChannelEnum.getChannelByType(appendInfo.getChannelType()); + } else { + //自定义渠道,取detail为自定义渠道名称 + channelName = appendInfo.getDetail(); + channelType = RadarChannelEnum.CUSTOMIZE.getTYPE(); + } + // 设置点击时间 + Date time = new Date(); + String dateStr = DateUtils.getDate(); + // 获取活码发送用户详情 + WeRadarClickRecord record = WeRadarClickRecord.builder() + .createTime(time) + .openId(openId) + .unionId(customer.getUnionid()) + .createDate(dateStr) + .userId(user == null ? StringUtils.EMPTY : user.getUserId()) + .userName(user == null ? StringUtils.EMPTY : user.getName()) + .radarId(appendInfo.getRadarId()) + .externalUserId(customer.getExternalUserid()) + .externalUserName(customer.getName()) + .externalUserHeadImage(customer.getAvatar()) + .channelName(channelName) + .channelType(channelType) + .build(); + this.save(record); + log.info("[保存雷达记录] 保存成功,record:{}", record); + } + + + + + /** + * 校验参数 + * + * @param radarAnalyseDTO + */ + private void verifyParam(SearchRadarAnalyseDTO radarAnalyseDTO) { + if (ObjectUtils.isEmpty(radarAnalyseDTO)) { + throw new CustomException(ResultTip.TIP_GENERAL_BAD_REQUEST); + } + if (ObjectUtils.isNotEmpty(radarAnalyseDTO.getBeginTime()) && ObjectUtils.isNotEmpty(radarAnalyseDTO.getEndTime())) { + //校验开始时间和结束时间格式 + if (Boolean.TRUE.equals(!DateUtils.isMatchFormat(radarAnalyseDTO.getBeginTime(), DateUtils.YYYY_MM_DD)) || Boolean.TRUE.equals(!DateUtils.isMatchFormat(radarAnalyseDTO.getEndTime(), DateUtils.YYYY_MM_DD))) { + throw new CustomException(ResultTip.TIP_TIME_FORMAT_ERROR); + } + } + } +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarServiceImpl.java new file mode 100644 index 0000000..f53c674 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/radar/WeRadarServiceImpl.java @@ -0,0 +1,301 @@ +package com.easywecom.wecom.service.impl.radar; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.easywecom.common.constant.Constants; +import com.easywecom.common.constant.radar.RadarConstants; +import com.easywecom.common.core.domain.entity.WeCorpAccount; +import com.easywecom.common.core.page.PageDomain; +import com.easywecom.common.core.page.TableSupport; +import com.easywecom.common.enums.AttachmentTypeEnum; +import com.easywecom.common.enums.MessageType; +import com.easywecom.common.enums.ResultTip; +import com.easywecom.common.enums.radar.*; +import com.easywecom.common.exception.CustomException; +import com.easywecom.common.utils.DateUtils; +import com.easywecom.common.utils.sql.SqlUtil; +import com.easywecom.wecom.client.WeMessagePushClient; +import com.easywecom.wecom.domain.WeTag; +import com.easywecom.wecom.domain.dto.WeMessagePushDTO; +import com.easywecom.wecom.domain.dto.common.AttachmentParam; +import com.easywecom.wecom.domain.dto.message.TextMessageDTO; +import com.easywecom.wecom.domain.dto.radar.DeleteRadarDTO; +import com.easywecom.wecom.domain.dto.radar.RadarDTO; +import com.easywecom.wecom.domain.dto.radar.SearchRadarDTO; +import com.easywecom.wecom.domain.entity.radar.WeRadar; +import com.easywecom.wecom.domain.entity.radar.WeRadarChannel; +import com.easywecom.wecom.domain.entity.radar.WeRadarTag; +import com.easywecom.wecom.domain.entity.radar.WeRadarUrl; +import com.easywecom.wecom.domain.vo.radar.WeRadarVO; +import com.easywecom.wecom.login.util.LoginTokenService; +import com.easywecom.wecom.mapper.radar.WeRadarMapper; +import com.easywecom.wecom.service.WeCorpAccountService; +import com.easywecom.wecom.service.WeUserService; +import com.easywecom.wecom.service.radar.WeRadarChannelService; +import com.easywecom.wecom.service.radar.WeRadarService; +import com.github.pagehelper.PageHelper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * ClassName: WeRadarServiceImpl + * + * @author wx + * @date 2022/7/18 15:35 + */ +@Slf4j +@Service +public class WeRadarServiceImpl extends ServiceImpl implements WeRadarService { + + private final WeRadarChannelService radarChannelService; + private final WeCorpAccountService corpAccountService; + private final WeMessagePushClient messagePushClient; + private final WeUserService weUserService; + + @Autowired + @Lazy + public WeRadarServiceImpl(WeRadarChannelService radarChannelService, WeCorpAccountService corpAccountService, WeMessagePushClient messagePushClient, WeUserService weUserService) { + this.radarChannelService = radarChannelService; + this.corpAccountService = corpAccountService; + this.messagePushClient = messagePushClient; + this.weUserService = weUserService; + } + + /** + * 新增雷达 + * + * @param radarDTO + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void saveRadar(RadarDTO radarDTO) { + verifyParam(radarDTO); + WeRadar weRadar = radarDTO.buildRadarData(); + List weRadarTagList = radarDTO.buildRadarTags(weRadar.getId()); + if (LoginTokenService.getLoginUser().isSuperAdmin()) { + weRadar.setCreateBy(LoginTokenService.getUsername()); + } else { + radarDTO.setMainDepartment(LoginTokenService.getLoginUser().getWeUser().getMainDepartment()); + weRadar.setCreateBy(LoginTokenService.getLoginUser().getWeUser().getUserId()); + } + weRadar.setCreateTime(DateUtils.getTime()); + if (CollectionUtils.isNotEmpty(weRadarTagList)) { + this.baseMapper.saveRadarTags(weRadarTagList); + } + this.save(weRadar); + //发消息通知员工 + if (Boolean.TRUE.equals(radarDTO.getEnableUpdateNotice())) { + sendToUser(weRadar.getCorpId(), weRadar.getRadarTitle(), weRadar.getType()); + } + } + + /** + * 给员工发送应用消息 + * + * @param corpId + * @param radarTitle + * @param radarType + */ + private void sendToUser(String corpId, String radarTitle, Integer radarType) { + WeMessagePushDTO pushDto = new WeMessagePushDTO(); + WeCorpAccount validWeCorpAccount = corpAccountService.findValidWeCorpAccount(corpId); + String agentId = validWeCorpAccount.getAgentId(); + // 文本消息 + TextMessageDTO text = new TextMessageDTO(); + StringBuilder content = new StringBuilder(); + //设置发送者 发送给企业所有员工 + if (RadarTypeEnum.CORP.getType().equals(radarType)) { + pushDto.setTouser(RadarConstants.UpdateNoticeToUser.SEND_ALL); + content.append(RadarConstants.UpdateNoticeToUser.CORP_RADAR_UPDATE); + if (StringUtils.isNotBlank(radarTitle)) { + content.append(RadarConstants.UpdateNoticeToUser.getUpdateMessage(radarTitle)); + } + text.setContent(content.toString()); + } else if (RadarTypeEnum.DEPARTMENT.getType().equals(radarType)) { + //设置发送者 发送给部门所有员工 + pushDto.setToparty(String.valueOf(LoginTokenService.getLoginUser().getWeUser().getMainDepartment())); + content.append(RadarConstants.UpdateNoticeToUser.DEPARTMENT_RADAR_UPDATE); + if (StringUtils.isNotBlank(radarTitle)) { + content.append(RadarConstants.UpdateNoticeToUser.getUpdateMessage(radarTitle)); + } + text.setContent(content.toString()); + } else { + //没命中说明是个人雷达不发消息 + return; + } + pushDto.setAgentid(Integer.valueOf(agentId)); + pushDto.setText(text); + pushDto.setMsgtype(MessageType.TEXT.getMessageType()); + // 请求消息推送接口,获取结果 [消息推送 - 发送应用消息] + log.debug("发送雷达变更信息:toUser:{},toParty:{}", pushDto.getTouser(), pushDto.getToparty()); + messagePushClient.sendMessageToUser(pushDto, agentId, corpId); + } + + + /** + * 查询雷达列表 + * + * @param radarDTO + * @return + */ + @Override + public List getRadarList(SearchRadarDTO radarDTO) { + final boolean isSuperAdmin = LoginTokenService.getLoginUser().isSuperAdmin(); + if (isSuperAdmin) { + if (RadarTypeEnum.DEPARTMENT.getType().equals(radarDTO.getType())) { + return Collections.emptyList(); + } + if (RadarTypeEnum.CORP.getType().equals(radarDTO.getType())) { + radarDTO.setType(null); + } + } + if (!isSuperAdmin) { + if (RadarTypeEnum.DEPARTMENT.getType().equals(radarDTO.getType())) { + final List userIds = weUserService.listOfUserId(radarDTO.getCorpId(), StringUtils.join(LoginTokenService.getLoginUser().getWeUser().getMainDepartment(), StrUtil.COMMA)); + radarDTO.setUserIds(userIds); + } else if (RadarTypeEnum.SELF.getType().equals(radarDTO.getType())) { + List userIds = new ArrayList<>(); + userIds.add(LoginTokenService.getLoginUser().getWeUser().getUserId()); + radarDTO.setUserIds(userIds); + } + } + startPage(); + List list = this.baseMapper.list(radarDTO, isSuperAdmin); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + list.forEach(item -> { + if (Constants.SUPER_ADMIN.equals(item.getCreateId())) { + item.setCreateName(Constants.SUPER_ADMIN); + } + }); + return list; + } + + /** + * 设置请求分页数据 + */ + protected void startPage() { + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + if (com.easywecom.common.utils.StringUtils.isNotNull(pageNum) && com.easywecom.common.utils.StringUtils.isNotNull(pageSize)) { + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + PageHelper.startPage(pageNum, pageSize, orderBy); + } + } + + /** + * 获取详情 + * + * @param corpId + * @param id + * @return + */ + @Override + public WeRadarVO getRadar(String corpId, Long id) { + WeRadarVO radarVO = this.baseMapper.getOne(corpId, id); + if (ObjectUtils.isEmpty(radarVO)) { + return new WeRadarVO(); + } + if (Constants.SUPER_ADMIN.equals(radarVO.getCreateId())) { + radarVO.setCreateName(Constants.SUPER_ADMIN); + } + return radarVO; + } + + /** + * 更新雷达 + * + * @param radarDTO + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void updateRadar(RadarDTO radarDTO) { + verifyParam(radarDTO); + WeRadar weRadar = radarDTO.buildRadarData(); + weRadar.setId(radarDTO.getId()); + List weRadarTagList = radarDTO.buildRadarTags(weRadar.getId()); + if (LoginTokenService.getLoginUser().isSuperAdmin()) { + weRadar.setUpdateBy(LoginTokenService.getUsername()); + } else { + weRadar.setUpdateBy(LoginTokenService.getLoginUser().getWeUser().getUserId()); + } + weRadar.setUpdateTime(DateUtils.getTime()); + this.baseMapper.deleteRadarTags(radarDTO.getId()); + if (CollectionUtils.isNotEmpty(weRadarTagList)) { + this.baseMapper.saveRadarTags(weRadarTagList); + } + this.baseMapper.updateById(weRadar); + sendToUser(radarDTO.getCorpId(), radarDTO.getRadarTitle(), radarDTO.getType()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int batchRemoveRadar(String corpId, DeleteRadarDTO deleteDTO) { + if (StringUtils.isBlank(corpId)) { + throw new CustomException(ResultTip.TIP_MISS_CORP_ID); + } + this.baseMapper.batchDeleteRadarTags(deleteDTO.getIdList()); + radarChannelService.remove(new LambdaQueryWrapper() + .in(WeRadarChannel::getRadarId, deleteDTO.getIdList())); + return this.baseMapper.deleteBatchIds(deleteDTO.getIdList()); + } + + @Override + public List getTagListByRadarId(Long id) { + if (id == null) { + return Collections.emptyList(); + } + return this.baseMapper.getTagListByRadarId(id); + } + + @Override + public AttachmentParam getRadarShortUrl(Long radarId, Integer channelType, String userId, String corpId, String scenario) { + if (com.easywecom.common.utils.StringUtils.isBlank(corpId) && !ObjectUtils.allNotNull(radarId, channelType)) { + log.info("【发送雷达短链】生成雷达短链参数错误,radarId:{},channelType:{}, userId:{}, corpId:{},scenario:{}", radarId, channelType, userId, corpId, scenario); + return null; +// throw new CustomException(RADAR_SHORT_PARAM_ERROR); + } + final WeRadarUrl weRadarUrl = this.baseMapper.getOne(corpId, radarId).getWeRadarUrl(); + if (ObjectUtils.isEmpty(weRadarUrl)) { + log.info("【发送雷达短链】雷达实体查询不到,radarId:{},channelType:{}, userId:{}, corpId:{},scenario:{}", radarId, channelType, userId, corpId, scenario); +// throw new CustomException(RADAR_SHORT_ERROR); + return null; + } + AttachmentParam.AttachmentParamBuilder builder = AttachmentParam.builder(); + final AttachmentParam build = builder.content(weRadarUrl.getTitle()) + .picUrl(weRadarUrl.getCoverUrl()) + .description(weRadarUrl.getContent()) + .url(radarChannelService.createShortUrl(corpId, radarId, userId, channelType, scenario)).typeEnum(AttachmentTypeEnum.LINK).build(); + log.info("【发送雷达短链】成功生成,radarId:{},channel:{}, userId:{}, corpId:{},scenario:{}", radarId, RadarChannelEnum.getChannelByType(channelType), userId, corpId, scenario); + return build; + } + + /** + * 校验参数 + * + * @param radarDTO + */ + private void verifyParam(RadarDTO radarDTO) { + if (StringUtils.isEmpty(radarDTO.getCorpId())) { + throw new CustomException(ResultTip.TIP_MISS_CORP_ID); + } + if (Boolean.TRUE.equals(radarDTO.getEnableCustomerTag()) && CollectionUtils.isEmpty(radarDTO.getRadarTagList())) { + throw new CustomException(RadarConstants.PromptCus.NOT_USE_TAG); + } + } + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/redeemcode/WeRedeemCodeActivityServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/redeemcode/WeRedeemCodeActivityServiceImpl.java index dd413d6..0561883 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/redeemcode/WeRedeemCodeActivityServiceImpl.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/impl/redeemcode/WeRedeemCodeActivityServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.easywecom.common.annotation.DataScope; import com.easywecom.common.constant.WeConstans; +import com.easywecom.common.constant.redeemcode.RedeemCodeConstants; import com.easywecom.common.core.domain.model.LoginUser; import com.easywecom.common.enums.ResultTip; import com.easywecom.common.exception.CustomException; @@ -68,15 +69,15 @@ public class WeRedeemCodeActivityServiceImpl extends ServiceImpl weRedeemCodeActivityVOS = this.baseMapper.selectWeRedeemCodeActivityList(weRedeemCodeActivity, isSuperAdmin); weRedeemCodeActivity.setNowTime(DateUtils.getDate()); weRedeemCodeActivityVOS.forEach(item -> { - if (WeConstans.REDEEM_CODE_EMPTY_TIME.equals(item.getEffectStartTime())) { + if (RedeemCodeConstants.REDEEM_CODE_EMPTY_TIME.equals(item.getEffectStartTime())) { item.setEffectStartTime(StringUtils.EMPTY); } - if (WeConstans.REDEEM_CODE_EMPTY_TIME.equals(item.getEffectEndTime())) { + if (RedeemCodeConstants.REDEEM_CODE_EMPTY_TIME.equals(item.getEffectEndTime())) { item.setEffectEndTime(StringUtils.EMPTY); } }); @@ -129,17 +130,17 @@ public class WeRedeemCodeActivityServiceImpl extends ServiceImpl { toAlarmUser(corpId, item.getTargetId(), alarmMsg); }); @@ -377,10 +395,10 @@ public class WeRedeemCodeServiceImpl extends ServiceImpl weRedeemCodeList = this.baseMapper.selectWeRedeemCodeList(weRedeemCodeDTO); weRedeemCodeList.forEach(item -> { - if (item.getRedeemTime().contains(WeConstans.REDEEM_CODE_EMPTY_TIME)) { + if (item.getRedeemTime().contains(RedeemCodeConstants.REDEEM_CODE_EMPTY_TIME)) { item.setRedeemTime(StringUtils.EMPTY); } - if (item.getEffectiveTime().contains(WeConstans.REDEEM_CODE_EMPTY_TIME)) { + if (item.getEffectiveTime().contains(RedeemCodeConstants.REDEEM_CODE_EMPTY_TIME)) { item.setEffectiveTime(StringUtils.EMPTY); } }); diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/MiniAppQrCodeUrlHandler.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/MiniAppQrCodeUrlHandler.java new file mode 100644 index 0000000..c7a4666 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/MiniAppQrCodeUrlHandler.java @@ -0,0 +1,90 @@ +package com.easywecom.wecom.service.radar; + +import com.easywecom.common.config.WechatOpenConfig; +import com.easywecom.common.constant.WeConstans; +import com.easywecom.common.core.redis.RedisCache; +import com.easywecom.common.enums.ResultTip; +import com.easywecom.common.exception.CustomException; +import com.easywecom.common.shorturl.SysShortUrlMapping; +import com.easywecom.common.shorturl.service.ShortUrlAdaptor; +import com.easywecom.wecom.client.WechatOpenClient; +import com.easywecom.wecom.domain.req.GenerateUrlLinkReq; +import com.easywecom.wecom.domain.resp.GenerateUrlLinkResp; +import com.easywecom.wecom.login.util.LoginTokenService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 类名: 小程序活码短链处理类 + * + * @author : silver_chariot + * @date : 2022/7/19 17:44 + **/ +@Component +@Slf4j +public class MiniAppQrCodeUrlHandler extends ShortUrlAdaptor { + + private final WechatOpenConfig wechatOpenConfig; + private final WechatOpenClient wechatOpenClient; + + @Autowired + private RedisCache redisCache; + + + public MiniAppQrCodeUrlHandler(WechatOpenConfig wechatOpenConfig, WechatOpenClient wechatOpenClient) { + this.wechatOpenConfig = wechatOpenConfig; + this.wechatOpenClient = wechatOpenClient; + } + + /** + * 生成活码小程序短链 + * + * @param qrCodeUrl 长链接 + * @return 活码小程序链接 + */ + public String createShortCode(String qrCodeUrl) { + if (StringUtils.isBlank(qrCodeUrl)) { + throw new CustomException(ResultTip.TIP_GENERAL_PARAM_ERROR); + } + + if (wechatOpenConfig.getMiniApp() == null || StringUtils.isAnyBlank(wechatOpenConfig.getMiniApp().getDomain(), wechatOpenConfig.getMiniApp().getCodePath())) { + log.info("[活码小程序]生成短链,配置文件相关配置缺失{}", wechatOpenConfig.getMiniApp()); + // 考虑到不是每个企业都需要生成小程序活码,此处不作强制判断去生成短链 + return StringUtils.EMPTY; + } + // 先生成小程序的跳转link + GenerateUrlLinkReq req = new GenerateUrlLinkReq().path(wechatOpenConfig.getMiniApp().getCodePath()).version(wechatOpenConfig.getMiniApp().getEnvVersion()) + //todo 生成 query字符串 +// .query(genQueryString(qrCodeUrl)) + .token(redisCache.getCacheObject("")) + .buildReq(); + GenerateUrlLinkResp resp = wechatOpenClient.generateUrlLink(req); + if (resp == null || StringUtils.isBlank(resp.getUrl_link())) { + log.error("[活码小程序]生成小程序的跳转link失败,url:{},resp:{}", qrCodeUrl, resp); + return StringUtils.EMPTY; + } + // 生成短链 + String shorCode = createShortCode(resp.getUrl_link(), LoginTokenService.getUsername()); + + return genShortUrl(wechatOpenConfig.getMiniApp().getDomain() , shorCode); + } + + /** + * 获取活码小程序的链接 + * + * @param code 短链的code + * @return 活码链接 + */ + public String getQrCode(String code) { + if (StringUtils.isBlank(code)) { + throw new CustomException(ResultTip.TIP_NEED_SHORT_CODE); + } + String longUrl = getLongUrl(code); + if (StringUtils.isBlank(longUrl)) { + throw new CustomException(ResultTip.TIP_CANNOT_FIND_LONG_URL); + } + return longUrl; + } +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/RadarUrlHandler.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/RadarUrlHandler.java new file mode 100644 index 0000000..f09e608 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/RadarUrlHandler.java @@ -0,0 +1,302 @@ +package com.easywecom.wecom.service.radar; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.easywecom.common.config.WechatOpenConfig; +import com.easywecom.common.constant.GenConstants; +import com.easywecom.common.core.domain.entity.WeCorpAccount; +import com.easywecom.common.core.domain.wecom.WeUser; +import com.easywecom.common.enums.MessageType; +import com.easywecom.common.enums.ResultTip; +import com.easywecom.common.exception.CustomException; +import com.easywecom.common.shorturl.ShortUrlAppendInfo; +import com.easywecom.common.shorturl.SysShortUrlMapping; +import com.easywecom.common.shorturl.service.ShortUrlAdaptor; +import com.easywecom.wecom.client.WeMessagePushClient; +import com.easywecom.wecom.domain.WeCustomer; +import com.easywecom.wecom.domain.WeTag; +import com.easywecom.wecom.domain.dto.WeMessagePushDTO; +import com.easywecom.wecom.domain.dto.message.TextMessageDTO; +import com.easywecom.wecom.domain.entity.radar.WeRadar; +import com.easywecom.wecom.domain.entity.wechatopen.WeOpenConfig; +import com.easywecom.wecom.domain.vo.WeMakeCustomerTagVO; +import com.easywecom.wecom.service.WeCorpAccountService; +import com.easywecom.wecom.service.WeCustomerService; +import com.easywecom.wecom.service.WeCustomerTrajectoryService; +import com.easywecom.wecom.service.WeUserService; +import com.easywecom.wecom.service.wechatopen.WechatOpenService; +import lombok.extern.slf4j.Slf4j; +import lombok.val; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.springframework.context.annotation.Lazy; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +/** + * 类名: 雷达链接处理类 + * + * @author : silver_chariot + * @date : 2022/7/20 18:22 + **/ +@Component +@Slf4j +public class RadarUrlHandler extends ShortUrlAdaptor { + /** + * 行为通知模板 + */ + private final static String RADAR_BEHAVIOR_NOTICE = "${customer}打开了您发布的${radarTitle}雷达链接"; + + + private final WeCustomerService weCustomerService; + private final WechatOpenService wechatOpenService; + private final WeRadarClickRecordService weRadarClickRecordService; + private final WeRadarService weRadarService; + private final WeUserService weUserService; + private final WeMessagePushClient weMessagePushClient; + private final WeCorpAccountService weCorpAccountService; + private final WeCustomerTrajectoryService weCustomerTrajectoryService; + + @Lazy + public RadarUrlHandler( WeCustomerService weCustomerService, WechatOpenService wechatOpenService, WeRadarClickRecordService weRadarClickRecordService, WeRadarService weRadarService, WeUserService weUserService, WeMessagePushClient weMessagePushClient, WeCorpAccountService weCorpAccountService, WeCustomerTrajectoryService weCustomerTrajectoryService) { + this.weCustomerService = weCustomerService; + this.wechatOpenService = wechatOpenService; + this.weRadarClickRecordService = weRadarClickRecordService; + this.weRadarService = weRadarService; + this.weUserService = weUserService; + this.weMessagePushClient = weMessagePushClient; + this.weCorpAccountService = weCorpAccountService; + this.weCustomerTrajectoryService = weCustomerTrajectoryService; + } + + /** + * 构建短链附加信息 + * + * @param radarId 雷达id + * @param userId 使用雷达用户id + * @param channelType 渠道类型 {@link com.easywecom.common.enums.radar.RadarChannelEnum} + * @param detail 详情(如果是员工活码,则为员工活码使用场景, + * 如果是新客进群则为新客进群的活码名称, + * 如果是SOP则为SOP名称,如果是群日历,则为日历名称, + * 如果是自定义渠道则为自定义渠道的渠道名) + * @return {@link ShortUrlAppendInfo } + */ + public ShortUrlAppendInfo buildAppendInfo(Long radarId, String userId, Integer channelType, String detail) { + return ShortUrlAppendInfo.builder().radarId(radarId).userId(userId).channelType(channelType).detail(detail).build(); + } + + /** + * 创建雷达链接 + * + * @param corpId 企业id + * @param url 长链接url + * @param createBy 创建人 + * @param appendInfo 附件信息{@link ShortUrlAppendInfo } + * @return 雷达短链 + */ + public String createRadarUrl(String corpId, String url, String createBy, ShortUrlAppendInfo appendInfo) { + if (StringUtils.isAnyBlank(url, corpId)) { + log.info("[创建雷达链接]缺失长链接或者corpId,by:{},append:{},corpId:{}", createBy, appendInfo, corpId); + throw new CustomException(ResultTip.TIP_MISSING_LONG_URL); + } + + // 生成短链code + appendInfo.setCorpId(corpId); + String code = createShortCode(url, createBy, appendInfo); + if (StringUtils.isBlank(code)) { + throw new CustomException(ResultTip.TIP_ERROR_CREATE_SHORT_URL); + } + WeOpenConfig config = wechatOpenService.getConfig(corpId); + if (config == null || StringUtils.isBlank(config.getOfficialAccountDomain())) { + throw new CustomException(ResultTip.TIP_WECHAT_OPEN_OFFICIAL_NO_DOMAIN); + } + return genShortUrl(config.getOfficialAccountDomain(), code); + } + + /** + * 根据短链code获取原链接 并记录客户点击操作 + * + * @param shortCode 短链code + * @param openId 公众号openid + * @return 原链接 + */ + public String getOriginUrlAndRecord(String shortCode, String openId) { + if (StringUtils.isBlank(shortCode)) { + log.info("[获取雷达原链接] 短链code为空,shortCode:{},openId:{}", shortCode, openId); + throw new CustomException(ResultTip.TIP_NEED_SHORT_CODE); + } + // 1. 获取长短链映射 + SysShortUrlMapping mapping = getLongUrlMapping(shortCode); + if (StringUtils.isBlank(mapping.getLongUrl())) { + throw new CustomException(ResultTip.TIP_CANNOT_FIND_LONG_URL); + } + // 2. 异步处理 (记录点击详情) + try { + asyncRadarHandle(mapping, openId); + } catch (CustomException e) { + log.error("[雷达异步处理]出现业务异常.code:{},openId:{},errmsg:{}", shortCode, openId, e.getMessage()); + } catch (Exception e) { + log.error("[雷达异步处理]出现未知异常.code:{},openId:{},errmsg:{}", shortCode, openId, ExceptionUtils.getStackTrace(e)); + } + // 3. 返回给前端 + return mapping.getLongUrl(); + } + + @Async + public void asyncRadarHandle(SysShortUrlMapping mapping, String openId) { + if (mapping == null || StringUtils.isBlank(openId) + || mapping.getAppend() == null || mapping.getAppend().getRadarId() == null || mapping.getAppend().getChannelType() == null || StringUtils.isBlank(mapping.getAppend().getUserId())) { + log.error("[异步雷达触发记录处理]参数确实,无法记录点击记录,mapping:{},openid:{}", mapping, openId); + return; + } + ShortUrlAppendInfo appendInfo = mapping.getAppend(); + // 1.根据openid获取客户详情 + WeCustomer customer = getCustomerInfoByOpenId(openId); + if (customer == null) { + log.error("[异步雷达触发记录处理]获取客户详情,查询不到客户信息,openid:{}", openId); + throw new CustomException(ResultTip.TIP_FAIL_TO_GET_CUSTOMER_INFO); + } + // 2. 获取雷达详情 + WeRadar radar = weRadarService.getById(appendInfo.getRadarId()); + if (radar == null || StringUtils.isBlank(radar.getCorpId())) { + log.error("[异步雷达触发记录处理]找不到对应的雷达详情,无法记录点击记录,mapping:{}, customer:{}", mapping, customer); + return; + } + // 3. 获取员工详情 + WeUser user = weUserService.getUserDetail(radar.getCorpId(), appendInfo.getUserId()); + if (user == null) { + log.error("[异步雷达触发记录处理]找不到使用雷达的员工详情,radar:{},mapping:{},customer:{},appendInfo:{}", radar, mapping, customer, appendInfo); + } + // 4. 保存雷达点击记录 + weRadarClickRecordService.createRecord(appendInfo, customer, openId, user); + // 5. 执行高级设置 (行为通知、轨迹记录、客户标签) + doExtraSetting(radar, user, customer, appendInfo); + } + + /** + * 执行高级操作 + * + * @param radar 雷达 {@link WeRadar} + * @param user 员工信息 {@link WeUser} + * @param customer 客户信息 {@link WeCustomer } + * @param appendInfo 附件信息{@link ShortUrlAppendInfo } + */ + private void doExtraSetting(WeRadar radar, WeUser user, WeCustomer customer, ShortUrlAppendInfo appendInfo) { + // 获取企业应用信息 + WeCorpAccount corpAccount = weCorpAccountService.findValidWeCorpAccount(radar.getCorpId()); + if (corpAccount == null) { + log.error("[雷达高级设置处理]获取企业信息失败,radar:{}", radar); + return; + } + // 轨迹记录 + if (radar.getEnableBehaviorRecord()) { + weCustomerTrajectoryService.recordRadarClickOperation(radar, user, customer); + } + // 打上客户标签 + if (radar.getEnableCustomerTag()) { + setTagForRadarClick(radar.getId(), user, customer); + } + // 行为通知 + if (radar.getEnableClickNotice()) { + String content = genClickNoticeContent(customer.getName(), radar.getRadarTitle()); + sendNotice(content, user, corpAccount.getAgentId()); + } + } + + + /** + * 为点击雷达的客户打上标签 + * + * @param id 雷达id + * @param user 员工 + * @param customer 客户 {@link WeCustomer} + */ + private void setTagForRadarClick(Long id, WeUser user, WeCustomer customer) { + if (id == null || user == null || StringUtils.isBlank(user.getUserId())) { + log.info("[雷达高级设置处理]打标签,参数缺失,id:{},user:{},customer:{}", id, user, customer); + return; + } + // 根据雷达id 获取其标签 + List tagList = weRadarService.getTagListByRadarId(id); + if (CollectionUtils.isEmpty(tagList)) { + log.info("[雷达高级设置处理]没有需要打上的标签,radar:{},customer:{}", id, customer); + return; + } + WeMakeCustomerTagVO makeCustomerTagVO = WeMakeCustomerTagVO.builder() + .userId(user.getUserId()) + .corpId(customer.getCorpId()) + .externalUserid(customer.getExternalUserid()) + .updateBy(user.getName()) + .addTag(tagList) + .build(); + List list = new ArrayList<>(); + list.add(makeCustomerTagVO); + weCustomerService.makeLabelbatch(list,user.getUserId()); + + } + + /** + * 触发雷达的行为通知 + * + * @param name 客户名称 + * @param radarTitle 雷达标题 + * @return 通知内容 + */ + private String genClickNoticeContent(String name, String radarTitle) { + if (StringUtils.isAnyBlank(name, radarTitle)) { + return StringUtils.EMPTY; + } + return RADAR_BEHAVIOR_NOTICE.replace(GenConstants.CUSTOMER, name) + .replace(GenConstants.RADAR_TITLE, radarTitle); + } + + /** + * 发送企业通知 + * + * @param content 消息 + * @param user 员工 + * @param agentId 应用id + */ + private void sendNotice(String content, WeUser user, String agentId) { + if (user == null || StringUtils.isAnyBlank(content, user.getUserId(), user.getCorpId(), agentId)) { + log.info("[雷达高级设置处理]发送通知,参数缺失,content:{},user:{}", content, user); + return; + } + TextMessageDTO contentInfo = TextMessageDTO.builder() + .content(content) + .build(); + WeMessagePushDTO request = WeMessagePushDTO.builder() + .msgtype(MessageType.TEXT.getMessageType()) + .touser(user.getUserId()) + .text(contentInfo) + .agentid(Integer.valueOf(agentId)) + .build(); + weMessagePushClient.sendMessageToUser(request, agentId, user.getCorpId()); + } + + /** + * 根据openId获取客户详情 + * + * @param openId 公众号openid + * @return 客户详情 {@link WeCustomer} + */ + public WeCustomer getCustomerInfoByOpenId(String openId) { + if (StringUtils.isBlank(openId)) { + return null; + } + // 1. 根据openid获取unionId + String unionId = wechatOpenService.getUnionIdByOpenId(openId); + // 2. 先根据union_id去客户表查询是否有数据 + WeCustomer customer = weCustomerService.getOne(new LambdaQueryWrapper().eq(WeCustomer::getUnionid, unionId).last(GenConstants.LIMIT_1)); + if (customer == null) { + log.info("[获取雷达原链接] 获取客户详情,根据union_id在数据库中未匹配到客户,openId:{},unionId:{},customer:{}", openId, unionId); + throw new CustomException(ResultTip.TIP_CANNOT_FIND_USER_BY_UNION_ID); + } + return customer; + } + + +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarChannelService.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarChannelService.java new file mode 100644 index 0000000..1ff8bab --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarChannelService.java @@ -0,0 +1,70 @@ +package com.easywecom.wecom.service.radar; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.easywecom.wecom.domain.dto.radar.DeleteRadarChannelDTO; +import com.easywecom.wecom.domain.dto.radar.RadarChannelDTO; +import com.easywecom.wecom.domain.dto.radar.SearchRadarChannelDTO; +import com.easywecom.wecom.domain.entity.radar.WeRadarChannel; +import com.easywecom.wecom.domain.vo.radar.WeRadarChannelVO; + +import java.util.List; + +/** + * ClassName: WeRadarChannelService + * + * @author wx + * @date 2022/7/19 14:55 + */ +public interface WeRadarChannelService extends IService { + + /** + * 新增雷达渠道 + * + * @param radarChannelDTO + */ + void saveRadarChannel(RadarChannelDTO radarChannelDTO); + + /** + * 查询雷达渠道列表 + * + * @param radarChannelDTO + * @return + */ + List getRadarChannelList(SearchRadarChannelDTO radarChannelDTO); + + /** + * 批量删除雷达渠道 + * + * @param deleteDTO + * @return + */ + void batchRemoveRadarChannel(DeleteRadarChannelDTO deleteDTO); + + /** + * 获取渠道详情 + * + * @param corpId + * @param id + * @return + */ + WeRadarChannelVO getRadarChannel(String corpId, Long id); + + /** + * 修改渠道 + * + * @param radarChannelDTO + */ + void updateRadarChannel(RadarChannelDTO radarChannelDTO); + + /** + * 生成短链 + * + * @param corpId + * @param radarId + * @param userName + * @param channelType + * @param detail + * @return + */ + String createShortUrl(String corpId, Long radarId, String userName, Integer channelType, String detail); +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarClickRecordService.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarClickRecordService.java new file mode 100644 index 0000000..3a944ff --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarClickRecordService.java @@ -0,0 +1,92 @@ +package com.easywecom.wecom.service.radar; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.easywecom.common.core.domain.wecom.WeUser; +import com.easywecom.common.shorturl.ShortUrlAppendInfo; +import com.easywecom.wecom.domain.WeCustomer; +import com.easywecom.wecom.domain.dto.radar.*; +import com.easywecom.wecom.domain.entity.radar.WeRadarClickRecord; +import com.easywecom.wecom.domain.vo.radar.*; + +import java.util.List; + +/** + * ClassName: WeRadarClickRecordService + * + * @author wx + * @date 2022/7/19 19:56 + */ +public interface WeRadarClickRecordService extends IService { + /** + * 保存雷达记录 + * + * @param clickRecordDTO + */ + void saveClickRecord(RadarClickRecordDTO clickRecordDTO); + + /** + * 获取雷达点击数据总览 + * + * @param radarId + * @return + */ + RadarRecordTotalVO getTotal(Long radarId); + + /** + * 查询雷达数据统计(折线图) + * + * @param radarAnalyseDTO + * @return + */ + RadarAnalyseVO getTimeRangeAnalyseCount(SearchRadarAnalyseDTO radarAnalyseDTO); + + /** + * 查询渠道排序 + * + * @param radarId + * @return + */ + List getChannelSort(Long radarId); + + /** + * 获取客户点击记录 + * + * @param customerRecordDTO + * @return + */ + List getCustomerClickRecord(SearchCustomerRecordDTO customerRecordDTO); + + /** + * 获取渠道点击记录 + * + * @param channelRecordDTO + * @return + */ + List getChannelClickRecord(SearchChannelRecordDTO channelRecordDTO); + + /** + * 获取渠道点击记录详情 + * + * @param channelRecordDetailDTO + * @return + */ + List getChannelClickRecordDetail(SearchChannelRecordDetailDTO channelRecordDetailDTO); + + /** + * 获取客户点击记录详情 + * + * @param customerRecordDTO + * @return + */ + List getCustomerClickRecordDetail(SearchCustomerRecordDetailDTO customerRecordDTO); + + /** + * 创建雷达点击记录 + * + * @param appendInfo 附件信息 {@link ShortUrlAppendInfo } + * @param customer 客户信息 {@link WeCustomer} + * @param openId 公众号openId + * @param user 使用雷达员工信息{@link WeUser} + */ + void createRecord(ShortUrlAppendInfo appendInfo, WeCustomer customer, String openId, WeUser user); +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarService.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarService.java new file mode 100644 index 0000000..14dc454 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/radar/WeRadarService.java @@ -0,0 +1,81 @@ +package com.easywecom.wecom.service.radar; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.easywecom.wecom.domain.WeTag; +import com.easywecom.wecom.domain.dto.common.AttachmentParam; +import com.easywecom.wecom.domain.dto.radar.DeleteRadarDTO; +import com.easywecom.wecom.domain.dto.radar.RadarDTO; +import com.easywecom.wecom.domain.dto.radar.SearchRadarDTO; +import com.easywecom.wecom.domain.entity.radar.WeRadar; +import com.easywecom.wecom.domain.vo.radar.WeRadarVO; + +import java.util.List; + +/** + * ClassName: WeRadarService + * + * @author wx + * @date 2022/7/18 15:33 + */ +public interface WeRadarService extends IService { + + /** + * 新增雷达 + * + * @param radarDTO + * @return + */ + void saveRadar(RadarDTO radarDTO); + + /** + * 查询雷达列表 + * + * @param radarDTO + * @return + */ + List getRadarList(SearchRadarDTO radarDTO); + + /** + * 获取详情 + * + * @param corpId + * @param id + * @return + */ + WeRadarVO getRadar(String corpId, Long id); + + /** + * 更新雷达 + * + * @param radarDTO + */ + void updateRadar(RadarDTO radarDTO); + + /** + * 批量删除雷达 + * + * @param corpId + * @param deleteDTO + */ + int batchRemoveRadar(String corpId, DeleteRadarDTO deleteDTO); + + /** + * 根据雷达id获取需要打上的标签 + * + * @param id 雷达id + * @return 需要打上的标签列表 + */ + List getTagListByRadarId(Long id); + + /** + * 发送客户时生成雷达短链 + * + * @param radarId + * @param channelType + * @param userId + * @param corpId + * @param scenario + * @return + */ + AttachmentParam getRadarShortUrl(Long radarId, Integer channelType, String userId, String corpId, String scenario); +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/wechatopen/WechatOpenService.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/wechatopen/WechatOpenService.java new file mode 100644 index 0000000..eb2afe8 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/wechatopen/WechatOpenService.java @@ -0,0 +1,62 @@ +package com.easywecom.wecom.service.wechatopen; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.dtflys.forest.http.ForestRequest; +import com.easywecom.wecom.domain.entity.wechatopen.WeOpenConfig; +import com.easywecom.wecom.domain.vo.AppIdVO; + +/** + * 类名: 微信公众平台业务处理接口 + * + * @author : silver_chariot + * @date : 2022/7/20 10:48 + **/ +public interface WechatOpenService extends IService { + /** + * 获取系统的appId配置 + * + * @param shortCode + * + * @return appId 于配置文件配置 + */ + AppIdVO getAppId(String shortCode); + + /** + * 获取用户的openId + * + * @param code 前端传来的code + * @param corpId 企业id + * @return 获取到openId + */ + String getOpenId(String code, String corpId); + + /** + * 为企微开放平台请求设置accessToken + * + * @param request forest请求 + */ + void setAccessToken(ForestRequest request); + + /** + * 根据openid获取unionid + * + * @param openId 公众号openid + * @return unionid + */ + String getUnionIdByOpenId(String openId); + + /** + * 获取公众平台配置 + * + * @param corpId 企业id + * @return {@link WeOpenConfig} + */ + WeOpenConfig getConfig(String corpId); + + /** + * 修改企微的公众平台配置 + * + * @param config {@link WeOpenConfig } + */ + void updateConfig(WeOpenConfig config); +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/service/wechatopen/impl/WechatOpenServiceImpl.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/wechatopen/impl/WechatOpenServiceImpl.java new file mode 100644 index 0000000..bf5a1c0 --- /dev/null +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/service/wechatopen/impl/WechatOpenServiceImpl.java @@ -0,0 +1,185 @@ +package com.easywecom.wecom.service.wechatopen.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.dtflys.forest.http.ForestRequest; +import com.easywecom.common.config.WechatOpenConfig; +import com.easywecom.common.constant.GenConstants; +import com.easywecom.common.core.domain.model.LoginUser; +import com.easywecom.common.core.redis.RedisCache; +import com.easywecom.common.enums.ResultTip; +import com.easywecom.common.exception.CustomException; +import com.easywecom.common.shorturl.SysShortUrlMapping; +import com.easywecom.common.shorturl.service.ShortUrlAdaptor; +import com.easywecom.common.utils.StringUtils; +import com.easywecom.wecom.client.WechatOpenClient; +import com.easywecom.wecom.domain.entity.wechatopen.WeOpenConfig; +import com.easywecom.wecom.domain.resp.GetAccessTokenResp; +import com.easywecom.wecom.domain.resp.GetOfficialAuthInfoResp; +import com.easywecom.wecom.domain.resp.SnsUserInfoResp; +import com.easywecom.wecom.domain.vo.AppIdVO; +import com.easywecom.wecom.login.util.LoginTokenService; +import com.easywecom.wecom.mapper.wechatopen.WeOpenConfigMapper; +import com.easywecom.wecom.service.wechatopen.WechatOpenService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; + +import java.util.concurrent.TimeUnit; + +/** + * 类名: 微信公众平台业务处理接口实现类 + * + * @author : silver_chariot + * @date : 2022/7/20 10:49 + **/ +@Service +@Slf4j +public class WechatOpenServiceImpl extends ServiceImpl implements WechatOpenService { + /** + * grant_type默认传参 + */ + private static final String AUTH_CODE_GRANT_TYPE = "authorization_code"; + private static final String CLIENT_CREDENTIAL_GRANT_TYPE = "client_credential"; + private static final String ACCESS_TOKEN = "access_token"; + private final static String CN_LANG = "zh_CN"; + private final WechatOpenConfig wechatOpenConfig; + private final WechatOpenClient wechatOpenClient; + private final RedisCache redisCache; + private final ShortUrlAdaptor shortUrlAdaptor; + + @Lazy + public WechatOpenServiceImpl(WechatOpenConfig wechatOpenConfig, WechatOpenClient wechatOpenClient, RedisCache redisCache, ShortUrlAdaptor shortUrlAdaptor) { + this.wechatOpenConfig = wechatOpenConfig; + this.wechatOpenClient = wechatOpenClient; + this.redisCache = redisCache; + this.shortUrlAdaptor = shortUrlAdaptor; + } + + @Override + public AppIdVO getAppId(String shortCode) { + if (StringUtils.isBlank(shortCode)) { + throw new CustomException(ResultTip.TIP_MISS_CORP_ID); + } + // 获取长链 + SysShortUrlMapping mapping = shortUrlAdaptor.getLongUrlMapping(shortCode); + if (mapping == null || mapping.getAppendInfo() == null || StringUtils.isBlank(mapping.getAppend().getCorpId())) { + log.error("[获取appid]根据短链code获取corpId失败,{}", shortCode); + throw new CustomException(ResultTip.TIP_MISS_CORP_ID); + } + String corpId = mapping.getAppend().getCorpId(); + // 获取 + WeOpenConfig config = getConfig(corpId); + if (config == null || StringUtils.isBlank(config.getOfficialAccountAppId())) { + throw new CustomException(ResultTip.TIP_MISS_APPID); + } + return AppIdVO.builder() + .corpId(corpId) + .appId(config.getOfficialAccountAppId()) + .build(); + } + + @Override + public String getOpenId(String code, String corpId) { + if (StringUtils.isBlank(code)) { + throw new CustomException(ResultTip.TIP_MISSING_USER_CODE); + } + if (StringUtils.isBlank(corpId)) { + throw new CustomException(ResultTip.TIP_MISS_CORP_ID); + } + WeOpenConfig config = getConfig(corpId); + if (config == null || StringUtils.isAnyBlank(config.getOfficialAccountAppSecret(), config.getOfficialAccountAppId())) { + throw new CustomException(ResultTip.TIP_NO_APP_SECRET); + } + GetOfficialAuthInfoResp resp = wechatOpenClient.getAuthInfo(config.getOfficialAccountAppId(), config.getOfficialAccountAppSecret(), code, AUTH_CODE_GRANT_TYPE, corpId); + if (resp.isError() || StringUtils.isBlank(resp.getOpenId())) { + throw new CustomException(ResultTip.TIP_WECHAT_OPEN_GET_AUTH_ERROR); + } + // 保存对应openid的sns_access_token + redisCache.setCacheObject(snsRedisKey(resp.getOpenId()), resp.getAccess_token()); + return resp.getOpenId(); + } + + public String snsRedisKey(String openId) { + return "wechatOpen:accessToken:" + openId; + } + + @Override + public void setAccessToken(ForestRequest request) { + if (request == null) { + return; + } + if (wechatOpenConfig == null || wechatOpenConfig.getOfficialAccount() == null + || StringUtils.isAnyBlank(wechatOpenConfig.getOfficialAccount().getAppId(), wechatOpenConfig.getOfficialAccount().getAppSecret())) { + log.info("[微信公众平台请求]没有设置appid和appsecret,无法生成access_token"); + return; + } + String appId = wechatOpenConfig.getOfficialAccount().getAppId(); + // 先从缓存中获取 + String corpId = request.getHeader("corpId").getValue(); + String redisKey = getAccessTokenKey(appId, corpId); + String accessToken = redisCache.getCacheObject(redisKey); + if (StringUtils.isNotBlank(accessToken)) { + request.addQuery(ACCESS_TOKEN, accessToken); + return; + } + String secret = wechatOpenConfig.getOfficialAccount().getAppSecret(); + // 没有则请求开放平台重新获取 + GetAccessTokenResp resp = wechatOpenClient.getAccessToken(CLIENT_CREDENTIAL_GRANT_TYPE, appId, secret); + if (resp.isError() || StringUtils.isBlank(resp.getAccess_token())) { + log.error("[微信公众平台请求] 获取access_token失败,appId:{},resp:{}", appId, resp); + return; + } + // 响应成功则设置缓存 并设置请求的access_token + redisCache.setCacheObject(redisKey, resp.getAccess_token(), resp.getExpires_in(), TimeUnit.SECONDS); + request.addQuery(ACCESS_TOKEN, resp.getAccess_token()); + } + + @Override + public String getUnionIdByOpenId(String openId) { + if (StringUtils.isBlank(openId)) { + throw new CustomException(ResultTip.TIP_OPEN_ID_CANNOT_BE_NULL); + } + // 根据openid获取其对应的sns_access_token + String snsAccessToken = redisCache.getCacheObject(snsRedisKey(openId)); + SnsUserInfoResp snsUserInfoResp = wechatOpenClient.snsUserInfo(snsAccessToken, openId, CN_LANG); + if (snsUserInfoResp.isError() || StringUtils.isBlank(snsUserInfoResp.getUnionid())) { + log.info("[获取unionId]获取unionid失败,openid:{}.snsToken:{}", openId, snsAccessToken); + throw new CustomException(ResultTip.TIP_ERROR_GET_UNION_ID); + } + return snsUserInfoResp.getUnionid(); + } + + @Override + public WeOpenConfig getConfig(String corpId) { + if (StringUtils.isBlank(corpId)) { + throw new CustomException(ResultTip.TIP_MISS_CORP_ID); + } + WeOpenConfig config = this.baseMapper.selectOne(new LambdaQueryWrapper() + .eq(WeOpenConfig::getCorpId, corpId) + .last(GenConstants.LIMIT_1)); + return config; + } + + @Override + public void updateConfig(WeOpenConfig config) { + if (config == null || StringUtils.isBlank(config.getOfficialAccountAppId())) { + throw new CustomException(ResultTip.TIP_NO_APP_ID_CONFIG); + } + LoginUser loginUser = LoginTokenService.getLoginUser(); + // 获取原有配置 + config.setCorpId(loginUser.getCorpId()); + this.baseMapper.insertOrUpdate(config); + } + + /** + * 获取微信小程序的accessToken + * + * @param appId 小程序appId + * @param corpId 企业id + * @return + */ + public String getAccessTokenKey(String appId, String corpId) { + return "wechatOpen:" + corpId + ":accessToken:" + appId; + } +} diff --git a/easywecom-wecom/src/main/java/com/easywecom/wecom/utils/AttachmentService.java b/easywecom-wecom/src/main/java/com/easywecom/wecom/utils/AttachmentService.java index 11112ec..962556b 100644 --- a/easywecom-wecom/src/main/java/com/easywecom/wecom/utils/AttachmentService.java +++ b/easywecom-wecom/src/main/java/com/easywecom/wecom/utils/AttachmentService.java @@ -41,6 +41,8 @@ public class AttachmentService { return buildImage(param.getPicUrl(), param.getTypeEnum(), corpId); case LINK: return buildLink(param.getContent(), param.getPicUrl(), param.getDescription(), param.getUrl(), param.getTypeEnum()); + case RADAR: + return buildRadar(param.getContent(), param.getPicUrl(), param.getDescription(), param.getUrl(), param.getTypeEnum()); case MINIPROGRAM: return buildMiniprogram(param.getContent(), param.getPicUrl(), param.getDescription(), param.getUrl(), param.getTypeEnum(), corpId); case FILE: @@ -53,6 +55,21 @@ public class AttachmentService { } } + private Attachments buildRadar(String content, String picUrl, String description, String url, AttachmentTypeEnum type) { + if (StringUtils.isEmpty(content) || StringUtils.isEmpty(url)) { + return null; + } + Attachments attachments = new Attachments(); + attachments.setMsgtype(type.getTypeStr()); + attachments.setLink(Link.builder() + .title(content) + .picurl(picUrl) + .desc(description) + .url(url) + .build()); + return attachments; + } + /** * 构建视频 diff --git a/easywecom-wecom/src/main/resources/mapper/wecom/WeCustomerMapper.xml b/easywecom-wecom/src/main/resources/mapper/wecom/WeCustomerMapper.xml index f701cd0..0c1a563 100644 --- a/easywecom-wecom/src/main/resources/mapper/wecom/WeCustomerMapper.xml +++ b/easywecom-wecom/src/main/resources/mapper/wecom/WeCustomerMapper.xml @@ -503,7 +503,7 @@ ON DUPLICATE KEY UPDATE `name` = VALUES(`name`),avatar = VALUES(avatar),corp_name = VALUES(corp_name), corp_full_name = VALUES(corp_full_name),position = VALUES(position),`type` = VALUES(`type`),gender = - VALUES(gender) + VALUES(gender) , unionid = VALUES(unionid) @@ -511,6 +511,7 @@ external_userid = #{externalUserid}, name = #{name}, + unionid = #{unionid}, avatar = #{avatar}, corp_id = #{corpId}, type = #{type}, diff --git a/easywecom-wecom/src/main/resources/mapper/wecom/WeEmpleCodeMapper.xml b/easywecom-wecom/src/main/resources/mapper/wecom/WeEmpleCodeMapper.xml index 317cb00..31fbd30 100644 --- a/easywecom-wecom/src/main/resources/mapper/wecom/WeEmpleCodeMapper.xml +++ b/easywecom-wecom/src/main/resources/mapper/wecom/WeEmpleCodeMapper.xml @@ -30,6 +30,7 @@ typeHandler="com.easywecom.framework.handler.StringArrayJoinTypeHandler"/> + @@ -57,6 +58,7 @@ + @@ -78,78 +80,88 @@ - select id, code_type, skip_verify, scenario, welcome_msg, create_by, create_time, del_flag, config_id,qr_code, - state, scan_times from we_emple_code + select id, + code_type, + skip_verify, + scenario, + welcome_msg, + create_by, + create_time, + del_flag, + config_id, + qr_code, + state, + scan_times + from we_emple_code - select - wec.id, - wec.code_type, - wec.skip_verify, - wec.scenario, - wec.welcome_msg, - wec.create_by, - wec.create_time, - wec.del_flag, - wec.config_id, - wec.state, - wec.qr_code, - wec.scan_times + select wec.id, + wec.code_type, + wec.skip_verify, + wec.scenario, + wec.welcome_msg, + wec.create_by, + wec.create_time, + wec.del_flag, + wec.config_id, + wec.state, + wec.qr_code, + wec.scan_times from we_emple_code wec - left join we_emple_code_use_scop wecus on wec.id = wecus.emple_code_id - and wecus.business_id_type = 2 - and wecus.del_flag = 0 + left join we_emple_code_use_scop wecus on wec.id = wecus.emple_code_id + and wecus.business_id_type = 2 + and wecus.del_flag = 0 - select - wecode.id, - wecode.code_type, - wecode.corp_id, - wecode.skip_verify, - IF(skip_verify=0,0,1) isAutoPass, - wecode.scenario, - wecode.welcome_msg, - wecode.create_by, - wecode.create_time, - wecode.del_flag, - wecode.config_id, - wecode.qr_code, - wecode.state, - wecode.source, - wecode.remark_type, - wecode.tag_flag, - IF(wecode.remark_type = 0, 0, 1) isAutoSetRemark, - wecode.remark_name, - wecode.effect_time_open, - wecode.effect_time_close, - wecode.material_sort, - wecode.welcome_msg_type, - wecode.code_activity_id, - wecode.code_success_msg, - wecode.code_success_material_sort, - wecode.code_fail_msg, - wecode.code_fail_material_sort, - wecode.code_repeat_msg, - wecode.code_repeat_material_sort, - wecusn.business_id, - wecusn.business_name, - wecusn.business_id_type, - wecusn.mobile, - wect.tag_id, - wect.tag_name + select wecode.id, + wecode.code_type, + wecode.corp_id, + wecode.skip_verify, + IF(skip_verify = 0, 0, 1) isAutoPass, + wecode.scenario, + wecode.welcome_msg, + wecode.create_by, + wecode.create_time, + wecode.del_flag, + wecode.config_id, + wecode.qr_code, + wecode.state, + wecode.source, + wecode.remark_type, + wecode.tag_flag, + IF(wecode.remark_type = 0, 0, 1) isAutoSetRemark, + wecode.remark_name, + wecode.effect_time_open, + wecode.effect_time_close, + wecode.material_sort, + wecode.welcome_msg_type, + wecode.code_activity_id, + wecode.code_success_msg, + wecode.code_success_material_sort, + wecode.code_fail_msg, + wecode.code_fail_material_sort, + wecode.code_repeat_msg, + wecode.code_repeat_material_sort, + wecode.app_link, + wecusn.business_id, + wecusn.business_name, + wecusn.business_id_type, + wecusn.mobile, + wect.tag_id, + wect.tag_name from we_emple_code wecode - left join ( - SELECT - wecus.emple_code_id, wecus.business_id, wecus.business_id_type,wecus.business_name,wu.mobile - FROM - we_emple_code_use_scop wecus - LEFT JOIN we_user wu ON - wu.user_id = wecus.business_id - AND wu.corp_id = #{corpId} - WHERE wecus.del_flag = 0 - ) as wecusn on + left join (SELECT wecus.emple_code_id, + wecus.business_id, + wecus.business_id_type, + wecus.business_name, + wu.mobile + FROM we_emple_code_use_scop wecus + LEFT JOIN we_user wu ON + wu.user_id = wecus.business_id + AND wu.corp_id = #{corpId} + WHERE wecus.del_flag = 0) as wecusn on wecode.id = wecusn.emple_code_id left join we_emple_code_tag wect on wecode.id = wect.emple_code_id and wect.del_flag = 0 @@ -172,23 +184,23 @@ and wecode.scenario like concat('%', #{scenario}, '%') - - AND wecode.create_by like concat('%', #{createBy}, '%') - - - AND wecode.create_time >= #{beginTime} - - - AND wecode.create_time <= #{endTime} - - - AND wecusn.business_name like concat('%', #{useUserName}, '%') - - - AND wecode.source = #{source} - - group by wecode.id - order by wecode.create_time DESC + + AND wecode.create_by like concat('%', #{createBy}, '%') + + + AND wecode.create_time >= #{beginTime} + + + AND wecode.create_time <= #{endTime} + + + AND wecusn.business_name like concat('%', #{useUserName}, '%') + + + AND wecode.source = #{source} + + group by wecode.id + order by wecode.create_time DESC ) a LEFT JOIN we_user wu ON a.create_by = wu.user_name AND wu.corp_id = #{corpId} LEFT JOIN we_department wd ON wd.id = wu.main_department AND wd.corp_id = #{corpId} @@ -196,7 +208,7 @@ @@ -228,7 +240,8 @@ code_fail_material_sort, code_fail_msg, code_repeat_material_sort, - code_repeat_msg + code_repeat_msg, + app_link #{id}, @@ -265,7 +278,9 @@ #{codeRepeatMaterialSort,jdbcType=OTHER,typeHandler=com.easywecom.framework.handler.StringArrayJoinTypeHandler}, - #{codeRepeatMsg} + #{codeRepeatMsg}, + #{appLink} + @@ -320,7 +335,6 @@ - SELECT wecode.id, + wecode.scenario, wecode.welcome_msg, wecode.material_sort, wecode.source, @@ -370,81 +385,75 @@ - \ No newline at end of file diff --git a/easywecom-wecom/src/main/resources/mapper/wecom/WeMaterialMapper.xml b/easywecom-wecom/src/main/resources/mapper/wecom/WeMaterialMapper.xml index ffa09da..bc047cf 100644 --- a/easywecom-wecom/src/main/resources/mapper/wecom/WeMaterialMapper.xml +++ b/easywecom-wecom/src/main/resources/mapper/wecom/WeMaterialMapper.xml @@ -20,6 +20,8 @@ + + @@ -38,6 +40,8 @@ + + @@ -56,8 +60,12 @@ + + - + @@ -110,7 +118,13 @@ temp_flag, - is_defined + is_defined, + + + enable_convert_radar, + + + radar_id VALUES @@ -161,7 +175,13 @@ #{tempFlag}, - #{isDefined} + #{isDefined}, + + + #{enableConvertRadar}, + + + #{radarId} @@ -246,9 +266,16 @@ is_defined=#{isDefined}, + + enable_convert_radar = #{enableConvertRadar}, + + + radar_id = #{radarId}, + update_time = sysdate() where id=#{id} - and category_id in (SELECT id FROM we_category WHERE corp_id = #{corpId} AND media_type = #{mediaType} AND del_flag = ${@com.easywecom.common.constant.WeConstans@WE_CUSTOMER_MSG_RESULT_NO_DEFALE}) + and category_id in (SELECT id FROM we_category WHERE corp_id = #{corpId} AND media_type = #{mediaType} AND + del_flag = ${@com.easywecom.common.constant.WeConstans@WE_CUSTOMER_MSG_RESULT_NO_DEFALE}) UPDATE we_material @@ -271,9 +298,10 @@ SELECT wc.media_type, wm.id, - wm.material_url,wm.content,wm.material_name,wm.digest,wm.audio_time,wm.cover_url,wm.create_by,wm.create_time,wm.update_by,wm.update_time,wm.is_defined + wm.material_url,wm.content,wm.material_name,wm.digest,wm.audio_time,wm.cover_url,wm.create_by,wm.create_time,wm.update_by,wm.update_time,wm.is_defined,wm.enable_convert_radar,wm.radar_id from we_material wm left join we_category wc on wc.id = wm.category_id where @@ -319,7 +348,8 @@ - id,category_id,material_url,content,material_name,digest,cover_url,create_by,create_time,update_by,update_time,audio_time,is_defined + id + ,category_id,material_url,content,material_name,digest,cover_url,create_by,create_time,update_by,update_time,audio_time,is_defined,enable_convert_radar,radar_id @@ -417,7 +447,7 @@ + + + + + + + + + + + + + + - wwd.id + wwd + . + id , wwd.corp_id , wwd.group_id , wwd.media_type @@ -27,29 +45,31 @@ , wwd.cover_url , wwd.is_defined , wwd.size + , wwd.radar_id - SELECT FROM we_words_detail wwd @@ -74,6 +94,7 @@ ,cover_url ,is_defined ,size + ,radar_id ) VALUES @@ -88,6 +109,7 @@ ,#{item.coverUrl} ,#{item.isDefined} ,#{item.size} + ,#{item.radarId} ) ON DUPLICATE KEY UPDATE @@ -98,7 +120,8 @@ url = VALUES(url), cover_url = VALUES(cover_url), size = VALUES(size), - is_defined = VALUES(is_defined) + is_defined = VALUES(is_defined), + radar_id = VALUES(radar_id) delete diff --git a/easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarChannelMapper.xml b/easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarChannelMapper.xml new file mode 100644 index 0000000..9287a9e --- /dev/null +++ b/easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarChannelMapper.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + diff --git a/easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarClickRecordMapper.xml b/easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarClickRecordMapper.xml new file mode 100644 index 0000000..a773484 --- /dev/null +++ b/easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarClickRecordMapper.xml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarMapper.xml b/easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarMapper.xml new file mode 100644 index 0000000..65852f5 --- /dev/null +++ b/easywecom-wecom/src/main/resources/mapper/wecom/radar/WeRadarMapper.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO we_radar_tag_rel + (radar_id, tag_id) + values + + (#{item.radarId},#{item.tagId}) + + ON DUPLICATE KEY UPDATE + radar_id = VALUES(radar_id), + tag_id = VALUES(tag_id) + + + DELETE + FROM we_radar_tag_rel + WHERE radar_id = #{radarId} + + + DELETE FROM we_radar_tag_rel + + radar_id IN + + + #{id} + + + + + + + + + + + + + \ No newline at end of file diff --git a/easywecom-wecom/src/main/resources/mapper/wecom/redeemcode/WeRedeemCodeActivityMapper.xml b/easywecom-wecom/src/main/resources/mapper/wecom/redeemcode/WeRedeemCodeActivityMapper.xml index 93c3448..65455c8 100644 --- a/easywecom-wecom/src/main/resources/mapper/wecom/redeemcode/WeRedeemCodeActivityMapper.xml +++ b/easywecom-wecom/src/main/resources/mapper/wecom/redeemcode/WeRedeemCodeActivityMapper.xml @@ -70,7 +70,7 @@ WHERE activity_id = #{activityId} and status = ${@com.easywecom.common.enums.redeemcode.RedeemCodeStatusEnum@NOT_ASSIGN.getType()} AND (effective_time = ]]> #{nowDate} OR - effective_time = ${@com.easywecom.common.constant.WeConstans@REDEEM_CODE_EMPTY_TIME}) + effective_time = ${@com.easywecom.common.constant.redeemcode.RedeemCodeConstants@REDEEM_CODE_EMPTY_TIME}) diff --git a/easywecom-wecom/src/main/resources/mapper/wecom/redeemcode/WeRedeemCodeMapper.xml b/easywecom-wecom/src/main/resources/mapper/wecom/redeemcode/WeRedeemCodeMapper.xml index 5276a5c..a71fba1 100644 --- a/easywecom-wecom/src/main/resources/mapper/wecom/redeemcode/WeRedeemCodeMapper.xml +++ b/easywecom-wecom/src/main/resources/mapper/wecom/redeemcode/WeRedeemCodeMapper.xml @@ -132,11 +132,13 @@ left join we_redeem_code wrc ON wrc.activity_id = wrca.id AND wrca.corp_id = #{corpId} AND (wrca.end_time >= #{effectiveTime} OR - wrca.end_time = ${@com.easywecom.common.constant.WeConstans@REDEEM_CODE_EMPTY_TIME}) + wrca.end_time = + ${@com.easywecom.common.constant.redeemcode.RedeemCodeConstants@REDEEM_CODE_EMPTY_TIME}) WHERE wrc.activity_id = #{activityId} and status = ${@com.easywecom.common.enums.redeemcode.RedeemCodeStatusEnum@NOT_ASSIGN.getType()} AND (wrc.effective_time = ]]> #{effectiveTime} OR - wrc.effective_time = ${@com.easywecom.common.constant.WeConstans@REDEEM_CODE_EMPTY_TIME}) + wrc.effective_time = + ${@com.easywecom.common.constant.redeemcode.RedeemCodeConstants@REDEEM_CODE_EMPTY_TIME}) order by wrc.effective_time LIMIT 1