微信小程序订阅消息模版
This commit is contained in:
parent
e78e8531bc
commit
f2158491a9
@ -115,11 +115,6 @@
|
||||
<artifactId>yudao-spring-boot-starter-flowable</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId> <!-- 微信登录(小程序) -->
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<!-- 设置构建的 jar 包名 -->
|
||||
|
@ -1,10 +1,10 @@
|
||||
package cn.iocoder.yudao.module.bpm.convert.message;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
|
||||
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.subscribe.dto.MsgData;
|
||||
import cn.iocoder.yudao.module.system.api.subscribe.dto.SubscribeMessageReqDTO;
|
||||
import org.flowable.bpmn.model.UserTask;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
@ -40,36 +40,36 @@ public interface BpmMessageConvert {
|
||||
* @param miniProgramState 小程序的状态
|
||||
* @return
|
||||
*/
|
||||
default WxMaSubscribeMessage convertApprovalResultNotification(String openId, String processInstanceName, String time, String result, String reason, String miniProgramState) {
|
||||
WxMaSubscribeMessage message = new WxMaSubscribeMessage() ;
|
||||
default SubscribeMessageReqDTO convertApprovalResultNotification(String openId, String processInstanceName, String time, String result, String reason, String miniProgramState) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO() ;
|
||||
message.setToUser(openId) ;
|
||||
message.setTemplateId("OnJjp5pdjG1PHMoELYaqp3Xq8jWZ5E6ndO0clEIQ4tk") ;
|
||||
//审批类型
|
||||
WxMaSubscribeMessage.MsgData processType = new WxMaSubscribeMessage.MsgData();
|
||||
MsgData processType = new MsgData();
|
||||
processType.setName("thing1") ;
|
||||
processType.setValue(processInstanceName) ;
|
||||
message.addData(processType);
|
||||
|
||||
//发起时间
|
||||
WxMaSubscribeMessage.MsgData createTime = new WxMaSubscribeMessage.MsgData();
|
||||
MsgData createTime = new MsgData();
|
||||
createTime.setName("time2") ;
|
||||
createTime.setValue(time) ;
|
||||
message.addData(createTime);
|
||||
|
||||
//审批时间
|
||||
WxMaSubscribeMessage.MsgData approvalTime = new WxMaSubscribeMessage.MsgData();
|
||||
MsgData approvalTime = new MsgData();
|
||||
approvalTime.setName("time7") ;
|
||||
approvalTime.setValue(DateUtils.dateFormat(new Date(),DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)) ;
|
||||
message.addData(approvalTime);
|
||||
|
||||
//审批结果
|
||||
WxMaSubscribeMessage.MsgData approvalResult = new WxMaSubscribeMessage.MsgData();
|
||||
MsgData approvalResult = new MsgData();
|
||||
approvalResult.setName("phrase3") ;
|
||||
approvalResult.setValue(result) ;
|
||||
message.addData(approvalResult);
|
||||
|
||||
if(reason != null ) {
|
||||
WxMaSubscribeMessage.MsgData approvalReason = new WxMaSubscribeMessage.MsgData();
|
||||
MsgData approvalReason = new MsgData();
|
||||
approvalReason.setName("thing12") ;
|
||||
approvalReason.setValue(reason) ;
|
||||
message.addData(approvalReason);
|
||||
@ -89,30 +89,30 @@ public interface BpmMessageConvert {
|
||||
* @param miniProgramState 小程序的状态
|
||||
* @return
|
||||
*/
|
||||
default WxMaSubscribeMessage convertProcessToDoReminder(String openId, String processInstanceName,String startUserNickname, String time, String schedule, String miniProgramState) {
|
||||
WxMaSubscribeMessage message = new WxMaSubscribeMessage() ;
|
||||
default SubscribeMessageReqDTO convertProcessToDoReminder(String openId, String processInstanceName,String startUserNickname, String time, String schedule, String miniProgramState) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO() ;
|
||||
message.setToUser(openId) ;
|
||||
message.setTemplateId("3cP4btlFSSiZk65qVewN_WoT_bh0OfUkYzzTsADOrR4") ;
|
||||
//待办标题
|
||||
WxMaSubscribeMessage.MsgData processType = new WxMaSubscribeMessage.MsgData();
|
||||
MsgData processType = new MsgData();
|
||||
processType.setName("thing1") ;
|
||||
processType.setValue("您收到了一条新的待办任务:"+processInstanceName) ;
|
||||
message.addData(processType);
|
||||
|
||||
//申请人
|
||||
WxMaSubscribeMessage.MsgData applicant = new WxMaSubscribeMessage.MsgData();
|
||||
MsgData applicant = new MsgData();
|
||||
applicant.setName("thing4") ;
|
||||
applicant.setValue(startUserNickname) ;
|
||||
message.addData(applicant);
|
||||
|
||||
//申请时间
|
||||
WxMaSubscribeMessage.MsgData createTime = new WxMaSubscribeMessage.MsgData();
|
||||
MsgData createTime = new MsgData();
|
||||
createTime.setName("time5") ;
|
||||
createTime.setValue(time) ;
|
||||
message.addData(createTime);
|
||||
|
||||
//当前进度
|
||||
WxMaSubscribeMessage.MsgData currentSchedule = new WxMaSubscribeMessage.MsgData();
|
||||
MsgData currentSchedule = new MsgData();
|
||||
currentSchedule.setName("thing6") ;
|
||||
currentSchedule.setValue(schedule) ;
|
||||
message.addData(currentSchedule);
|
||||
|
@ -140,8 +140,12 @@ public interface BpmProcessInstanceConvert {
|
||||
return event;
|
||||
}
|
||||
|
||||
default BpmMessageSendWhenProcessInstanceApproveReqDTO convert2ApprovedReq(ProcessInstance instance){
|
||||
default BpmMessageSendWhenProcessInstanceApproveReqDTO convert2ApprovedReq(ProcessInstance instance, String reason){
|
||||
return new BpmMessageSendWhenProcessInstanceApproveReqDTO()
|
||||
//添加原因
|
||||
.setReason(reason)
|
||||
//添加流程实际创建时间
|
||||
.setCreateTime(DateUtils.dateFormat(instance.getStartTime(),DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) )
|
||||
.setStartUserId(NumberUtils.parseLong(instance.getStartUserId()))
|
||||
.setProcessInstanceId(instance.getId())
|
||||
.setProcessInstanceName(instance.getName());
|
||||
@ -149,6 +153,8 @@ public interface BpmProcessInstanceConvert {
|
||||
|
||||
default BpmMessageSendWhenProcessInstanceRejectReqDTO convert2RejectReq(ProcessInstance instance, String reason) {
|
||||
return new BpmMessageSendWhenProcessInstanceRejectReqDTO()
|
||||
//添加流程实际创建时间
|
||||
.setCreateTime(DateUtils.dateFormat(instance.getStartTime(),DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) )
|
||||
.setProcessInstanceName(instance.getName())
|
||||
.setProcessInstanceId(instance.getId())
|
||||
.setReason(reason)
|
||||
|
@ -10,6 +10,7 @@ import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmConstants;
|
||||
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
@ -157,9 +158,37 @@ public interface BpmTaskConvert {
|
||||
}
|
||||
|
||||
default BpmMessageSendWhenTaskCreatedReqDTO convert(ProcessInstance processInstance, AdminUserRespDTO startUser,
|
||||
Task task) {
|
||||
Task task, List<BpmTaskRespVO> BpmTaskRespVOs) {
|
||||
BpmMessageSendWhenTaskCreatedReqDTO reqDTO = new BpmMessageSendWhenTaskCreatedReqDTO();
|
||||
|
||||
//获取流程审批列表最大数-2的记录数据
|
||||
/**
|
||||
* 因为必须存在一条记录,因为流程设计的时候,第一个审批节点是自己。并且自动审核通过的。
|
||||
* 所以到真实审批人了,就会有2条审批记录
|
||||
* 如果是真实审批人,获取审批进度的话,就需要获取前一条记录的数据。
|
||||
* 因为数据下标是从0开始的, 所以需要减2
|
||||
* List<BpmTaskRespVO> BpmTaskRespVOs的数据顺序是:
|
||||
* 发起人是在最后显示的
|
||||
*/
|
||||
String schedule = "" ;
|
||||
if(BpmTaskRespVOs.size() >= 2 ) {
|
||||
//List中的第0条记录,即是当前需要审核人
|
||||
//List中最后一条记录,即是发起人的自动审核记录
|
||||
BpmTaskRespVO bpmTaskRespVO = BpmTaskRespVOs.get( 1 ) ;
|
||||
if( bpmTaskRespVO.getReason() !=null && bpmTaskRespVO.getReason().equals(BpmConstants.AUTO_APPRAVAL) ) {
|
||||
//bpmTaskRespVO.getAssigneeUser().getDeptName() + ":"+
|
||||
schedule = bpmTaskRespVO.getAssigneeUser().getNickname()+"发起审批!" ;
|
||||
}else {
|
||||
schedule = bpmTaskRespVO.getAssigneeUser().getNickname()+"已审批通过";
|
||||
}
|
||||
}else {
|
||||
schedule = startUser.getNickname()+"发起审批" ;
|
||||
}
|
||||
reqDTO.setProcessInstanceId(processInstance.getProcessInstanceId())
|
||||
//添加流程进度
|
||||
.setSchedule(schedule)
|
||||
//添加流程实际创建时间
|
||||
.setCreateTime(DateUtils.dateFormat(processInstance.getStartTime(),DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) )
|
||||
.setProcessInstanceName(processInstance.getName()).setStartUserId(startUser.getId())
|
||||
.setStartUserNickname(startUser.getNickname()).setTaskId(task.getId()).setTaskName(task.getName())
|
||||
.setAssigneeUserId(NumberUtils.parseLong(task.getAssignee()));
|
||||
|
@ -14,7 +14,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {FileApi.class,RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class, NotifyMessageSendApi.class,
|
||||
// SubscribeMessageSendApi.class
|
||||
SubscribeMessageSendApi.class
|
||||
})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.message;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
|
||||
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.framework.web.config.WebProperties;
|
||||
import cn.iocoder.yudao.module.bpm.convert.message.BpmMessageConvert;
|
||||
@ -12,7 +8,6 @@ import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcess
|
||||
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO;
|
||||
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
|
||||
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.sms.SmsSendApi;
|
||||
import cn.iocoder.yudao.module.system.api.subscribe.SubscribeMessageSendApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
@ -60,13 +55,13 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
//发送审批结果通知
|
||||
String openId = getUserOpenId(reqDTO.getStartUserId()) ;
|
||||
if(openId != null ) {
|
||||
// subscribeMessageSendApi.sendApprovalResultNotification(
|
||||
// BpmMessageConvert.INSTANCE.convertApprovalResultNotification(
|
||||
// openId,reqDTO.getProcessInstanceName(), "","通过", null,
|
||||
// /**
|
||||
// * 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
|
||||
// */
|
||||
// WxMaConstants.MiniProgramState.DEVELOPER) ) ;
|
||||
subscribeMessageSendApi.sendApprovalResultNotification(
|
||||
BpmMessageConvert.INSTANCE.convertApprovalResultNotification(
|
||||
openId,reqDTO.getProcessInstanceName(), reqDTO.getCreateTime(), "通过", reqDTO.getReason(),
|
||||
/**
|
||||
* 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
|
||||
*/
|
||||
"formal") ) ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,16 +77,16 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1(
|
||||
reqDTO.getStartUserId(), BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams));
|
||||
|
||||
//发送审批结果通知
|
||||
// //发送审批结果通知
|
||||
String openId = getUserOpenId(reqDTO.getStartUserId()) ;
|
||||
if(openId != null ) {
|
||||
// subscribeMessageSendApi.sendApprovalResultNotification(
|
||||
// BpmMessageConvert.INSTANCE.convertApprovalResultNotification(
|
||||
// openId,reqDTO.getProcessInstanceName(),"","不通过", reqDTO.getReason(),
|
||||
// /**
|
||||
// * 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
|
||||
// */
|
||||
// WxMaConstants.MiniProgramState.DEVELOPER) ) ;
|
||||
subscribeMessageSendApi.sendApprovalResultNotification(
|
||||
BpmMessageConvert.INSTANCE.convertApprovalResultNotification(
|
||||
openId,reqDTO.getProcessInstanceName(),reqDTO.getCreateTime(),"不通过", reqDTO.getReason(),
|
||||
/**
|
||||
* 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
|
||||
*/
|
||||
"formal") ) ;
|
||||
}
|
||||
|
||||
}
|
||||
@ -99,30 +94,30 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
@Override
|
||||
public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) {
|
||||
//任务分配
|
||||
Long loginUserId = SecurityFrameworkUtils.getLoginUserId() ;
|
||||
Long startUserId = reqDTO.getStartUserId();
|
||||
//如果发起人和接受人是同一个人,那么不发送站内信,否则就发送
|
||||
if(!loginUserId.toString().equals(startUserId.toString())) {
|
||||
Long startUserId = reqDTO.getStartUserId(); //流程发起人
|
||||
Long assigneeUserId = reqDTO.getAssigneeUserId() ; //任务审批人
|
||||
String taskName = reqDTO.getTaskName() ;
|
||||
//如果流程发起人和任务审批是同一个人, 那么不发送站内信,否则就发送
|
||||
if(!assigneeUserId.toString().equals(startUserId.toString())) {
|
||||
Map<String, Object> templateParams = new HashMap<>();
|
||||
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
|
||||
// templateParams.put("taskName", reqDTO.getTaskName());
|
||||
// templateParams.put("taskName", reqDTO.getTaskName());
|
||||
templateParams.put("startUserNickname", reqDTO.getStartUserNickname());
|
||||
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
|
||||
//短信
|
||||
// smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(),
|
||||
// BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams));
|
||||
//站内信
|
||||
notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1(
|
||||
reqDTO.getAssigneeUserId(), BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams));
|
||||
|
||||
//微信小程序订阅消息
|
||||
//发送OA流程待办提醒
|
||||
String openId = getUserOpenId(reqDTO.getStartUserId()) ;
|
||||
String openId = getUserOpenId(reqDTO.getStartUserId()) ; //只有在微信小程序登陆过用户才会有openid
|
||||
if(openId != null ) {
|
||||
|
||||
// subscribeMessageSendApi.sendProcessToDoReminder( BpmMessageConvert.INSTANCE.convertProcessToDoReminder(
|
||||
// openId, reqDTO.getProcessInstanceName(), reqDTO.getStartUserNickname(),"","",
|
||||
// WxMaConstants.MiniProgramState.DEVELOPER ) ) ;
|
||||
|
||||
subscribeMessageSendApi.sendProcessToDoReminder( BpmMessageConvert.INSTANCE.convertProcessToDoReminder(
|
||||
openId, reqDTO.getProcessInstanceName(), reqDTO.getStartUserNickname(),reqDTO.getCreateTime(),reqDTO.getSchedule() ,
|
||||
"formal" ) ) ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,4 +24,14 @@ public class BpmMessageSendWhenProcessInstanceApproveReqDTO {
|
||||
@NotNull(message = "发起人的用户编号")
|
||||
private Long startUserId;
|
||||
|
||||
/**
|
||||
* 流程实例创建的时间
|
||||
*/
|
||||
@NotNull(message = "流程实例创建的时间")
|
||||
private String createTime ;
|
||||
/**
|
||||
* 通过理由
|
||||
*/
|
||||
@NotEmpty(message = "通过理由不能为空")
|
||||
private String reason;
|
||||
}
|
||||
|
@ -24,6 +24,11 @@ public class BpmMessageSendWhenProcessInstanceRejectReqDTO {
|
||||
@NotNull(message = "发起人的用户编号")
|
||||
private Long startUserId;
|
||||
|
||||
/**
|
||||
* 流程实例创建的时间
|
||||
*/
|
||||
@NotNull(message = "流程实例创建的时间")
|
||||
private String createTime ;
|
||||
/**
|
||||
* 不通过理由
|
||||
*/
|
||||
|
@ -43,4 +43,14 @@ public class BpmMessageSendWhenTaskCreatedReqDTO {
|
||||
@NotNull(message = "审批人的用户编号不能为空")
|
||||
private Long assigneeUserId;
|
||||
|
||||
/**
|
||||
* 流程实例创建的时间
|
||||
*/
|
||||
private String createTime ;
|
||||
|
||||
/**
|
||||
* 流程进度
|
||||
*/
|
||||
private String schedule ;
|
||||
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -388,6 +388,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
// 只获配置的首个岗位
|
||||
Long postId = list.get(0) ;
|
||||
paramMap.put("post_id",postId.toString()) ;
|
||||
paramMap.put("approve_reason",reqVO.getReason()) ; //通过原因---因为Task任务的通过,是通过监听事件处理的,reason数据无法传递给监听函数。所以通过此中方法传递
|
||||
taskService.complete(task.getId(), paramMap);
|
||||
// 更新任务拓展表为通过
|
||||
taskExtMapper.updateByTaskId(
|
||||
@ -688,6 +689,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
BpmTaskExtDO taskExtDO =
|
||||
new BpmTaskExtDO().setAssigneeUserId(NumberUtils.parseLong(task.getAssignee())).setTaskId(task.getId());
|
||||
taskExtMapper.updateByTaskId(taskExtDO);
|
||||
|
||||
// 发送通知。在事务提交时,批量执行操作,所以直接查询会无法查询到 ProcessInstance,所以这里是通过监听事务的提交来实现。
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
||||
@Override
|
||||
@ -696,11 +698,12 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
ProcessInstance processInstance =
|
||||
processInstanceService.getProcessInstance(task.getProcessInstanceId());
|
||||
if( processInstance != null ) {
|
||||
// 获得任务列表
|
||||
List<BpmTaskRespVO> BpmTaskRespVOs = getTaskListByProcessInstanceId(processInstance.getProcessInstanceId()) ;
|
||||
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData();
|
||||
messageService.sendMessageWhenTaskAssigned(
|
||||
BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task));
|
||||
BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task, BpmTaskRespVOs));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -17,9 +17,9 @@ public interface SubscribeMessageSendApi {
|
||||
|
||||
@PostMapping(PREFIX + "/send-approval-result-notification")
|
||||
@Operation(summary = "发送审批结果通知")
|
||||
CommonResult<Long> sendApprovalResultNotification(SubscribeMessageReqDTO reqDTO);
|
||||
CommonResult<Long> sendApprovalResultNotification(@RequestBody SubscribeMessageReqDTO reqDTO);
|
||||
|
||||
@PostMapping(PREFIX + "/send-process-todo-reminder")
|
||||
@Operation(summary = "发送OA流程待办提醒")
|
||||
CommonResult<Long> sendProcessToDoReminder(SubscribeMessageReqDTO reqDTO);
|
||||
CommonResult<Long> sendProcessToDoReminder(@RequestBody SubscribeMessageReqDTO reqDTO);
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
package cn.iocoder.yudao.module.system.api.subscribe.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -28,10 +26,13 @@ public class SubscribeMessageReqDTO {
|
||||
private String templateId;
|
||||
|
||||
@Schema(description = "所需下发的模板消息的属性集合", requiredMode = Schema.RequiredMode.REQUIRED, example = "OnJjp5pdjG1PHMoELYaqp3Xq8jWZ5E6ndO0clEIQ4tk")
|
||||
private List<MsgData> data;
|
||||
private List<MsgData> data = new ArrayList<>();
|
||||
|
||||
@Schema(description = "跳转小程序类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "developer为开发版;trial为体验版;formal为正式版;默认为正式版")
|
||||
@NotNull(message = "跳转小程序类型不能为空")
|
||||
private String miniprogramState = "formal" ;
|
||||
|
||||
public void addData(MsgData data) {
|
||||
this.data.add(data) ;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,29 @@
|
||||
package cn.iocoder.yudao.module.system.api.subscribe;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaSubscribeService;
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.cache.CacheUtils;
|
||||
import cn.iocoder.yudao.module.system.api.subscribe.dto.MsgData;
|
||||
import cn.iocoder.yudao.module.system.api.subscribe.dto.SubscribeMessageReqDTO;
|
||||
import cn.iocoder.yudao.module.system.service.social.SocialClientService;
|
||||
import com.binarywang.spring.starter.wxjava.miniapp.properties.WxMaProperties;
|
||||
import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import lombok.SneakyThrows;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@ -25,27 +37,29 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class SubscribeMessageSendApiImpl implements SubscribeMessageSendApi{
|
||||
|
||||
@Resource
|
||||
private WxMaSubscribeService wxMaSubscribeService ;
|
||||
private SocialClientService socialClientService;
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public CommonResult<Long> sendApprovalResultNotification(SubscribeMessageReqDTO reqDTO) {
|
||||
wxMaSubscribeService.sendSubscribeMsg(initWxMaSubscribeMessage(reqDTO));
|
||||
socialClientService.getWxMaService().getMsgService().sendSubscribeMsg(initWxMaSubscribeMessage(reqDTO));
|
||||
return success(1L);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public CommonResult<Long> sendProcessToDoReminder(SubscribeMessageReqDTO reqDTO) {
|
||||
wxMaSubscribeService.sendSubscribeMsg(initWxMaSubscribeMessage(reqDTO));
|
||||
socialClientService.getWxMaService().getMsgService().sendSubscribeMsg(initWxMaSubscribeMessage(reqDTO));
|
||||
return success(1L);
|
||||
}
|
||||
|
||||
private WxMaSubscribeMessage initWxMaSubscribeMessage( SubscribeMessageReqDTO reqDTO ) {
|
||||
WxMaSubscribeMessage message = new WxMaSubscribeMessage() ;
|
||||
message.setToUser(reqDTO.getToUser()) ;
|
||||
message.setTemplateId(reqDTO.getTemplateId());
|
||||
WxMaSubscribeMessage message = WxMaSubscribeMessage.builder()
|
||||
.toUser(reqDTO.getToUser())
|
||||
.templateId(reqDTO.getTemplateId())
|
||||
.build();
|
||||
message.setMiniprogramState(reqDTO.getMiniprogramState());
|
||||
List<MsgData> dataList = reqDTO.getData() ;
|
||||
for (MsgData msgData : dataList) {
|
||||
@ -54,6 +68,8 @@ public class SubscribeMessageSendApiImpl implements SubscribeMessageSendApi{
|
||||
wxMsgData.setValue(msgData.getValue()) ;
|
||||
message.addData(wxMsgData) ;
|
||||
}
|
||||
message.setPage("pages/home/index") ;
|
||||
return message ;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
||||
//获取微信小程序授权手机号
|
||||
WxMaPhoneNumberInfo wxMaPhoneNumberInfo = socialClientService.getWxMaPhoneNumberInfo(2,reqVO.getCode()) ;
|
||||
String phoneNumber = wxMaPhoneNumberInfo.getPhoneNumber() ; //授权手机号
|
||||
phoneNumber = "18611845857" ;
|
||||
//phoneNumber = "18611845857" ;
|
||||
String appId = wxMaPhoneNumberInfo.getWatermark().getAppid() ; //小程序的appId
|
||||
|
||||
final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_MOBILE;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.service.social;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -69,6 +70,12 @@ public interface SocialClientService {
|
||||
*/
|
||||
WxMaJscode2SessionResult getWxMaJscode2SessionResult(String jsCode) ;
|
||||
|
||||
/**
|
||||
* 获取WxMaService
|
||||
* @return
|
||||
*/
|
||||
WxMaService getWxMaService() ;
|
||||
|
||||
// =================== 客户端管理 ===================
|
||||
|
||||
/**
|
||||
|
@ -92,6 +92,11 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
private WxMaService wxMaService;
|
||||
@Resource
|
||||
private WxMaProperties wxMaProperties;
|
||||
|
||||
@Override
|
||||
public WxMaService getWxMaService() {
|
||||
return getWxMaService(2) ;
|
||||
}
|
||||
/**
|
||||
* 缓存 WxMaService 对象
|
||||
*
|
||||
|
@ -143,8 +143,8 @@ wx:
|
||||
miniapp: # 小程序配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-miniapp-spring-boot-starter/README.md 文档
|
||||
# appid: wx62056c0d5e8db250
|
||||
# secret: 333ae72f41552af1e998fe1f54e1584a
|
||||
appid: wxd0261c48ca0c6df3 # wenhualian的接口测试号
|
||||
secret: eaa3996319c595b5ece50e4ed9261114
|
||||
appid: wx2919e237e6018bea # wenhualian的接口测试号
|
||||
secret: ad7ab17918f6defa85a9677778eb7780
|
||||
config-storage:
|
||||
type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取
|
||||
key-prefix: wa # Redis Key 的前缀
|
||||
|
@ -143,8 +143,8 @@ wx:
|
||||
miniapp: # 小程序配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-miniapp-spring-boot-starter/README.md 文档
|
||||
# appid: wx62056c0d5e8db250
|
||||
# secret: 333ae72f41552af1e998fe1f54e1584a
|
||||
appid: wx63c280fe3248a3e7 # wenhualian的接口测试号
|
||||
secret: 6f270509224a7ae1296bbf1c8cb97aed
|
||||
appid: wx2919e237e6018bea # wenhualian的接口测试号
|
||||
secret: ad7ab17918f6defa85a9677778eb7780
|
||||
config-storage:
|
||||
type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取
|
||||
key-prefix: wa # Redis Key 的前缀
|
||||
|
Loading…
Reference in New Issue
Block a user