Merge remote-tracking branch 'origin/master'

new
Agoni 1 year ago
commit b42059e119

@ -91,6 +91,8 @@ public class ExpenseApplyServiceImpl extends MPJBaseServiceImpl<ExpenseApplyMapp
if (expenseApply.getStatus().equals(ExpenseApplyStatusEnum.PROCESS.getValue())) { if (expenseApply.getStatus().equals(ExpenseApplyStatusEnum.PROCESS.getValue())) {
Map<String, Object> variables = new HashMap<>(); Map<String, Object> variables = new HashMap<>();
variables.put("billType", expenseApply.getBillType()); variables.put("billType", expenseApply.getBillType());
variables.put("billId", expenseApply.getId());
variables.put("billName", BillTypeEnum.getNameByValue(expenseApply.getBillType()));
variables.put("amount", expenseApply.getAmount()); variables.put("amount", expenseApply.getAmount());
variables.put("deptId", expenseApply.getDeptId()); variables.put("deptId", expenseApply.getDeptId());
String processInstanceId = processInstanceApi.createProcessInstance(expenseApply.getUserId(), String processInstanceId = processInstanceApi.createProcessInstance(expenseApply.getUserId(),

@ -104,6 +104,8 @@ public class ExpenseClaimServiceImpl extends MPJBaseServiceImpl<ExpenseClaimMapp
if (expenseClaim.getStatus().equals(ExpenseApplyStatusEnum.PROCESS.getValue())) { if (expenseClaim.getStatus().equals(ExpenseApplyStatusEnum.PROCESS.getValue())) {
Map<String, Object> variables = new HashMap<>(); Map<String, Object> variables = new HashMap<>();
variables.put("billType", expenseClaim.getBillType()); variables.put("billType", expenseClaim.getBillType());
variables.put("billId", expenseClaim.getId());
variables.put("billName", BillTypeEnum.getNameByValue(expenseClaim.getBillType()));
variables.put("amount", expenseClaim.getAmount()); variables.put("amount", expenseClaim.getAmount());
variables.put("deptId", expenseClaim.getDeptId()); variables.put("deptId", expenseClaim.getDeptId());
String processInstanceId = processInstanceApi.createProcessInstance(expenseClaim.getUserId(), String processInstanceId = processInstanceApi.createProcessInstance(expenseClaim.getUserId(),

@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcess
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Map;
/** /**
* BPM Service * BPM Service
@ -26,8 +27,9 @@ public interface BpmMessageService {
* *
* *
* @param reqDTO * @param reqDTO
* @param variables
*/ */
void sendMessageWhenProcessInstanceReject(@Valid BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO); void sendMessageWhenProcessInstanceReject(@Valid BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO, Map<String, Object> variables);
/** /**
* *

@ -1,18 +1,19 @@
package cn.iocoder.yudao.module.bpm.service.message; package cn.iocoder.yudao.module.bpm.service.message;
import cn.iocoder.yudao.framework.web.config.WebProperties; import cn.iocoder.yudao.framework.web.config.WebProperties;
import cn.iocoder.yudao.module.bpm.convert.message.BpmMessageConvert;
import cn.iocoder.yudao.module.bpm.enums.message.BpmMessageEnum;
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO; import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO;
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO; 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.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.sms.SmsSendApi;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.RuntimeService;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
@ -30,9 +31,15 @@ public class BpmMessageServiceImpl implements BpmMessageService {
@Resource @Resource
private WebProperties webProperties; private WebProperties webProperties;
@Resource
@Lazy
private NotifyMessageSendApi notifyMessageSendApi;
@Resource
@Lazy
private RuntimeService runtimeService;
@Override @Override
public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) { public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) {
sendNotifyMessage(reqDTO.getProcessInstanceId(), reqDTO.getStartUserId(), "_PASS", null);
// Map<String, Object> templateParams = new HashMap<>(); // Map<String, Object> templateParams = new HashMap<>();
// templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); // templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
// templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); // templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
@ -41,7 +48,8 @@ public class BpmMessageServiceImpl implements BpmMessageService {
} }
@Override @Override
public void sendMessageWhenProcessInstanceReject(BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO) { public void sendMessageWhenProcessInstanceReject(BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO, Map<String, Object> variables) {
sendNotifyMessage(reqDTO.getProcessInstanceId(), reqDTO.getStartUserId(), "_NOPASS",variables);
// Map<String, Object> templateParams = new HashMap<>(); // Map<String, Object> templateParams = new HashMap<>();
// templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); // templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
// templateParams.put("reason", reqDTO.getReason()); // templateParams.put("reason", reqDTO.getReason());
@ -52,6 +60,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
@Override @Override
public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) { public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) {
// sendNotifyMessage(reqDTO.getProcessInstanceId(), reqDTO.getStartUserId(), "_UNDEAL", null);
// Map<String, Object> templateParams = new HashMap<>(); // Map<String, Object> templateParams = new HashMap<>();
// templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); // templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
// templateParams.put("taskName", reqDTO.getTaskName()); // templateParams.put("taskName", reqDTO.getTaskName());
@ -61,6 +70,23 @@ public class BpmMessageServiceImpl implements BpmMessageService {
// BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams)); // BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams));
} }
private void sendNotifyMessage(String reqDTO, Long reqDTO1, String type, Map<String, Object> variables) {
if (variables == null) {
variables = runtimeService.getVariables(reqDTO);
}
if (variables.containsKey("billType")) {
String billType = variables.get("billType").toString();
NotifySendSingleToUserReqDTO notifyReq = new NotifySendSingleToUserReqDTO();
notifyReq.setUserId(reqDTO1);
notifyReq.setTemplateCode(billType+ type);
notifyReq.setTemplateParams(variables);
notifyReq.setBillType(billType);
notifyReq.setExtraData(variables);
notifyReq.setJumpFlag("1");
notifyMessageSendApi.sendSingleMessageToAdmin(notifyReq);
}
}
private String getProcessInstanceDetailUrl(String taskId) { private String getProcessInstanceDetailUrl(String taskId) {
return webProperties.getAdminUi().getUrl() + "/bpm/process-instance/detail?id=" + taskId; return webProperties.getAdminUi().getUrl() + "/bpm/process-instance/detail?id=" + taskId;
} }

@ -22,10 +22,13 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
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.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.HistoryService; import org.flowable.engine.HistoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService; import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
@ -33,6 +36,7 @@ import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery; import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery; import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronization;
@ -74,7 +78,12 @@ public class BpmTaskServiceImpl implements BpmTaskService {
private BpmTaskExtMapper taskExtMapper; private BpmTaskExtMapper taskExtMapper;
@Resource @Resource
private BpmMessageService messageService; private BpmMessageService messageService;
@Resource
@Lazy
private RuntimeService runtimeService;
@Resource
@Lazy
private NotifyMessageSendApi notifyMessageSendApi;
@Override @Override
public PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) { public PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) {
// 查询待办任务 // 查询待办任务
@ -253,6 +262,18 @@ public class BpmTaskServiceImpl implements BpmTaskService {
BpmTaskExtDO taskExtDO = BpmTaskExtDO taskExtDO =
BpmTaskConvert.INSTANCE.convert2TaskExt(task).setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); BpmTaskConvert.INSTANCE.convert2TaskExt(task).setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
taskExtMapper.insert(taskExtDO); taskExtMapper.insert(taskExtDO);
Map<String, Object> variables = runtimeService.getVariables(task.getProcessInstanceId());
if (variables.containsKey("billType")) {
String billType = variables.get("billType").toString();
NotifySendSingleToUserReqDTO notifyReq = new NotifySendSingleToUserReqDTO();
notifyReq.setUserId(taskExtDO.getAssigneeUserId());
notifyReq.setTemplateCode(billType + "_UNDEAL");
notifyReq.setTemplateParams(variables);
notifyReq.setBillType(billType);
notifyReq.setExtraData(variables);
notifyReq.setJumpFlag("1");
notifyMessageSendApi.sendSingleMessageToAdmin(notifyReq);
}
} }
@Override @Override

@ -31,5 +31,12 @@ public enum BillTypeEnum {
*/ */
private final String name; private final String name;
public static String getNameByValue(String targetValue) {
for (BillTypeEnum billTypeEnum : BillTypeEnum.values()) {
if (billTypeEnum.getValue().equals(targetValue)) {
return billTypeEnum.getName();
}
}
return null;
}
} }

@ -99,6 +99,12 @@ public class SupplierCompanyDO extends BaseDO {
* id * id
*/ */
private Long correlationUserId; private Long correlationUserId;
/**
*
*/
private Long tenantId;
/** /**
* *
*/ */

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.bs.service.suppliercompany; package cn.iocoder.yudao.module.bs.service.suppliercompany;
import cn.iocoder.yudao.framework.common.util.date.DateUtils; import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.UserCreateReqDTO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -32,6 +34,9 @@ public class SupplierCompanyServiceImpl implements SupplierCompanyService {
@Resource @Resource
private SupplierCompanyMapper supplierCompanyMapper; private SupplierCompanyMapper supplierCompanyMapper;
@Resource
private AdminUserApi adminUserApi;
@Override @Override
public Long createSupplierCompany(SupplierCompanyCreateReqVO createReqVO) { public Long createSupplierCompany(SupplierCompanyCreateReqVO createReqVO) {
@ -40,7 +45,13 @@ public class SupplierCompanyServiceImpl implements SupplierCompanyService {
String companyNumber = numberCreate(); String companyNumber = numberCreate();
supplierCompany.setCompanyNumber(companyNumber); supplierCompany.setCompanyNumber(companyNumber);
supplierCompanyMapper.insert(supplierCompany); supplierCompanyMapper.insert(supplierCompany);
UserCreateReqDTO userCreateReqDTO=new UserCreateReqDTO();
userCreateReqDTO.setPassword("123456Aa@");
userCreateReqDTO.setUsername(supplierCompany.getPhone());
userCreateReqDTO.setNickname(supplierCompany.getBankName());
userCreateReqDTO.setMobile(supplierCompany.getPhone());
// userCreateReqDTO.setTenantId(supplierCompany.getCompanyNumber());
adminUserApi.addUser(userCreateReqDTO);
// 返回 // 返回
return supplierCompany.getId(); return supplierCompany.getId();
} }

@ -30,4 +30,18 @@ public class NotifySendSingleToUserReqDTO {
* *
*/ */
private Map<String, Object> templateParams; private Map<String, Object> templateParams;
/**
*
*/
private String billType;
/**
* ,ID
*/
private Map<String, Object> extraData;
/**
*
*/
private String jumpFlag = "0";
} }

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.api.user;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.UserCreateReqDTO;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -66,4 +67,10 @@ public interface AdminUserApi {
*/ */
void validateUserList(Collection<Long> ids); void validateUserList(Collection<Long> ids);
/**
*
* @param createReqVO
*/
void addUser(UserCreateReqDTO createReqVO);
} }

@ -0,0 +1,48 @@
package cn.iocoder.yudao.module.system.api.user.dto;
import cn.iocoder.yudao.framework.common.validation.Mobile;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Set;
@Data
public class UserCreateReqDTO {
@NotBlank(message = "用户账号不能为空")
@Pattern(regexp = "^[a-zA-Z0-9]{4,30}$", message = "用户账号由 数字、字母 组成")
@Size(min = 4, max = 30, message = "用户账号长度为 4-30 个字符")
private String username;
@Size(max = 30, message = "用户昵称长度不能超过30个字符")
private String nickname;
private String remark;
private Long deptId;
private Set<Long> postIds;
@Email(message = "邮箱格式不正确")
@Size(max = 50, message = "邮箱长度不能超过 50 个字符")
private String email;
@Mobile
private String mobile;
private Integer sex;
private String avatar;
private String password;
/**
*
*/
// private Long tenantId;
}

@ -1,11 +1,11 @@
package cn.iocoder.yudao.module.system.api.notify; package cn.iocoder.yudao.module.system.api.notify;
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
import cn.iocoder.yudao.module.system.service.notify.NotifySendService; import cn.iocoder.yudao.module.system.service.notify.NotifySendService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap;
/** /**
* API * API
@ -21,7 +21,7 @@ public class NotifyMessageSendApiImpl implements NotifyMessageSendApi {
@Override @Override
public Long sendSingleMessageToAdmin(NotifySendSingleToUserReqDTO reqDTO) { public Long sendSingleMessageToAdmin(NotifySendSingleToUserReqDTO reqDTO) {
return notifySendService.sendSingleNotifyToAdmin(reqDTO.getUserId(), return notifySendService.sendSingleNotifyToAdmin(reqDTO.getUserId(),
reqDTO.getTemplateCode(), reqDTO.getTemplateParams()); reqDTO.getTemplateCode(), reqDTO.getTemplateParams(), reqDTO.getBillType(), reqDTO.getExtraData(), reqDTO.getJumpFlag());
} }
@Override @Override

@ -1,9 +1,12 @@
package cn.iocoder.yudao.module.system.api.user; package cn.iocoder.yudao.module.system.api.user;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.UserCreateReqDTO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserCreateReqVO;
import cn.iocoder.yudao.module.system.convert.user.UserConvert; import cn.iocoder.yudao.module.system.convert.user.UserConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.service.user.AdminUserService; import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -50,4 +53,11 @@ public class AdminUserApiImpl implements AdminUserApi {
userService.validateUserList(ids); userService.validateUserList(ids);
} }
@Override
public void addUser(UserCreateReqDTO createReqVO) {
UserCreateReqVO reqVO = new UserCreateReqVO();
BeanUtils.copyProperties(createReqVO, reqVO);
userService.createUser(reqVO);
}
} }

@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.HashMap;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 站内信模版") @Tag(name = "管理后台 - 站内信模版")
@ -77,7 +79,7 @@ public class NotifyTemplateController {
@PreAuthorize("@ss.hasPermission('system:notify-template:send-notify')") @PreAuthorize("@ss.hasPermission('system:notify-template:send-notify')")
public CommonResult<Long> sendNotify(@Valid @RequestBody NotifyTemplateSendReqVO sendReqVO) { public CommonResult<Long> sendNotify(@Valid @RequestBody NotifyTemplateSendReqVO sendReqVO) {
return success(notifySendService.sendSingleNotifyToAdmin(sendReqVO.getUserId(), return success(notifySendService.sendSingleNotifyToAdmin(sendReqVO.getUserId(),
sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams())); sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams(), null, new HashMap<String, Object>(), "0"));
} }
} }

@ -56,5 +56,28 @@ public class NotifyMessageBaseVO {
@Schema(description = "阅读时间") @Schema(description = "阅读时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime readTime; private LocalDateTime readTime;
/**
*
*/
private LocalDateTime startTime;
/**
*
*/
private LocalDateTime endTime;
/**
*
*/
private String billType;
/**
* ID
*/
private Long billId;
/**
* ,ID
*/
private Map<String, Object> extraData;
/**
*
*/
private String jumpFlag;
} }

@ -97,5 +97,30 @@ public class NotifyMessageDO extends BaseDO {
* *
*/ */
private LocalDateTime readTime; private LocalDateTime readTime;
/**
*
*/
private LocalDateTime startTime;
/**
*
*/
private LocalDateTime endTime;
/**
*
*/
private String billType;
/**
* ID
*/
private Long billId;
/**
* ,ID
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Map<String, Object> extraData;
/**
*
*/
private String jumpFlag;
} }

@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -25,10 +26,13 @@ public interface NotifyMessageService {
* @param template * @param template
* @param templateContent * @param templateContent
* @param templateParams * @param templateParams
* @param billType
* @param extraData
* @param jumpFlag
* @return * @return
*/ */
Long createNotifyMessage(Long userId, Integer userType, Long createNotifyMessage(Long userId, Integer userType,
NotifyTemplateDO template, String templateContent, Map<String, Object> templateParams); NotifyTemplateDO template, String templateContent, Map<String, Object> templateParams, String billType, Map<String, Object> extraData, String jumpFlag);
/** /**
* *

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.system.service.notify; package cn.iocoder.yudao.module.system.service.notify;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO; import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
@ -10,7 +12,9 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -30,12 +34,24 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
@Override @Override
public Long createNotifyMessage(Long userId, Integer userType, public Long createNotifyMessage(Long userId, Integer userType,
NotifyTemplateDO template, String templateContent, Map<String, Object> templateParams) { NotifyTemplateDO template, String templateContent, Map<String, Object> templateParams, String billType, Map<String, Object> extraData, String jumpFlag) {
NotifyMessageDO message = new NotifyMessageDO().setUserId(userId).setUserType(userType) NotifyMessageDO message = new NotifyMessageDO().setUserId(userId).setUserType(userType)
.setTemplateId(template.getId()).setTemplateCode(template.getCode()) .setTemplateId(template.getId()).setTemplateCode(template.getCode())
.setTemplateType(template.getType()).setTemplateNickname(template.getNickname()) .setTemplateType(template.getType()).setTemplateNickname(template.getNickname())
.setTemplateContent(templateContent).setTemplateParams(templateParams).setReadStatus(false); .setTemplateContent(templateContent).setTemplateParams(templateParams).setReadStatus(false).setBillType(billType).setStartTime(LocalDateTime.now()).setExtraData(extraData).setJumpFlag(jumpFlag);
if (extraData.containsKey("billId")) {
message.setBillId(Long.valueOf(extraData.get("billId").toString()));
}
notifyMessageMapper.insert(message); notifyMessageMapper.insert(message);
if (billType != null && (template.getCode().contains("_PASS") || template.getCode().contains("_NOPASS"))) {
//如果同意和驳回需要将先前的待办删除
if (extraData.containsKey("billId")) {
LambdaQueryWrapperX<NotifyMessageDO> queryWrapperX = new LambdaQueryWrapperX<>();
queryWrapperX.eqIfPresent(NotifyMessageDO::getBillId, Long.valueOf(extraData.get("billId").toString()));
queryWrapperX.eqIfPresent(NotifyMessageDO::getTemplateCode, billType + "_UNDEAL");
notifyMessageMapper.delete(queryWrapperX);
}
}
return message.getId(); return message.getId();
} }

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.system.service.notify; package cn.iocoder.yudao.module.system.service.notify;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -18,10 +19,13 @@ public interface NotifySendService {
* @param userId * @param userId
* @param templateCode * @param templateCode
* @param templateParams * @param templateParams
* @param billType
* @param extraData
* @param jumpFlag
* @return * @return
*/ */
Long sendSingleNotifyToAdmin(Long userId, Long sendSingleNotifyToAdmin(Long userId,
String templateCode, Map<String, Object> templateParams); String templateCode, Map<String, Object> templateParams, String billType, Map<String, Object> extraData, String jumpFlag);
/** /**
* APP * APP
* *
@ -42,10 +46,13 @@ public interface NotifySendService {
* @param userType * @param userType
* @param templateCode * @param templateCode
* @param templateParams * @param templateParams
* @param billType
* @param extraData
* @param jumpFlag
* @return * @return
*/ */
Long sendSingleNotify( Long userId, Integer userType, Long sendSingleNotify(Long userId, Integer userType,
String templateCode, Map<String, Object> templateParams); String templateCode, Map<String, Object> templateParams, String billType, Map<String, Object> extraData, String jumpFlag);
default void sendBatchNotify(List<String> mobiles, List<Long> userIds, Integer userType, default void sendBatchNotify(List<String> mobiles, List<Long> userIds, Integer userType,
String templateCode, Map<String, Object> templateParams) { String templateCode, Map<String, Object> templateParams) {

@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -32,17 +33,16 @@ public class NotifySendServiceImpl implements NotifySendService {
private NotifyMessageService notifyMessageService; private NotifyMessageService notifyMessageService;
@Override @Override
public Long sendSingleNotifyToAdmin(Long userId, String templateCode, Map<String, Object> templateParams) { public Long sendSingleNotifyToAdmin(Long userId, String templateCode, Map<String, Object> templateParams, String billType, Map<String, Object> extraData, String jumpFlag) {
return sendSingleNotify(userId, UserTypeEnum.ADMIN.getValue(), templateCode, templateParams); return sendSingleNotify(userId, UserTypeEnum.ADMIN.getValue(), templateCode, templateParams, billType, extraData, jumpFlag);
} }
@Override @Override
public Long sendSingleNotifyToMember(Long userId, String templateCode, Map<String, Object> templateParams) { public Long sendSingleNotifyToMember(Long userId, String templateCode, Map<String, Object> templateParams) {
return sendSingleNotify(userId, UserTypeEnum.MEMBER.getValue(), templateCode, templateParams); return sendSingleNotify(userId, UserTypeEnum.MEMBER.getValue(), templateCode, templateParams, null, new HashMap<String, Object>(), "0");
} }
@Override public Long sendSingleNotify(Long userId, Integer userType, String templateCode, Map<String, Object> templateParams, String billType, Map<String, Object> extraData, String jumpFlag) {
public Long sendSingleNotify(Long userId, Integer userType, String templateCode, Map<String, Object> templateParams) {
// 校验模版 // 校验模版
NotifyTemplateDO template = validateNotifyTemplate(templateCode); NotifyTemplateDO template = validateNotifyTemplate(templateCode);
if (Objects.equals(template.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { if (Objects.equals(template.getStatus(), CommonStatusEnum.DISABLE.getStatus())) {
@ -54,7 +54,7 @@ public class NotifySendServiceImpl implements NotifySendService {
// 发送站内信 // 发送站内信
String content = notifyTemplateService.formatNotifyTemplateContent(template.getContent(), templateParams); String content = notifyTemplateService.formatNotifyTemplateContent(template.getContent(), templateParams);
return notifyMessageService.createNotifyMessage(userId, userType, template, content, templateParams); return notifyMessageService.createNotifyMessage(userId, userType, template, content, templateParams, billType, extraData, jumpFlag);
} }
@VisibleForTesting @VisibleForTesting

@ -15,10 +15,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Arrays; import java.util.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import static cn.hutool.core.util.RandomUtil.randomEle; import static cn.hutool.core.util.RandomUtil.randomEle;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
@ -54,7 +51,7 @@ public class NotifyMessageServiceImplTest extends BaseDbUnitTest {
// 调用 // 调用
Long messageId = notifyMessageService.createNotifyMessage(userId, userType, Long messageId = notifyMessageService.createNotifyMessage(userId, userType,
template, templateContent, templateParams); template, templateContent, templateParams, "xx", new HashMap<String, Object>(), "xxx");
// 断言 // 断言
NotifyMessageDO message = notifyMessageMapper.selectById(messageId); NotifyMessageDO message = notifyMessageMapper.selectById(messageId);
assertNotNull(message); assertNotNull(message);

@ -53,10 +53,10 @@ class NotifySendServiceImplTest extends BaseMockitoUnitTest {
// mock NotifyMessageService 的方法 // mock NotifyMessageService 的方法
Long messageId = randomLongId(); Long messageId = randomLongId();
when(notifyMessageService.createNotifyMessage(eq(userId), eq(UserTypeEnum.ADMIN.getValue()), when(notifyMessageService.createNotifyMessage(eq(userId), eq(UserTypeEnum.ADMIN.getValue()),
eq(template), eq(content), eq(templateParams))).thenReturn(messageId); eq(template), eq(content), eq(templateParams), "xx", new HashMap<String, Object>(), "xxx")).thenReturn(messageId);
// 调用 // 调用
Long resultMessageId = notifySendService.sendSingleNotifyToAdmin(userId, templateCode, templateParams); Long resultMessageId = notifySendService.sendSingleNotifyToAdmin(userId, templateCode, templateParams, null, new HashMap<String, Object>(), "0");
// 断言 // 断言
assertEquals(messageId, resultMessageId); assertEquals(messageId, resultMessageId);
} }
@ -81,7 +81,7 @@ class NotifySendServiceImplTest extends BaseMockitoUnitTest {
// mock NotifyMessageService 的方法 // mock NotifyMessageService 的方法
Long messageId = randomLongId(); Long messageId = randomLongId();
when(notifyMessageService.createNotifyMessage(eq(userId), eq(UserTypeEnum.MEMBER.getValue()), when(notifyMessageService.createNotifyMessage(eq(userId), eq(UserTypeEnum.MEMBER.getValue()),
eq(template), eq(content), eq(templateParams))).thenReturn(messageId); eq(template), eq(content), eq(templateParams), "xx", new HashMap<String, Object>(), "xxx")).thenReturn(messageId);
// 调用 // 调用
Long resultMessageId = notifySendService.sendSingleNotifyToMember(userId, templateCode, templateParams); Long resultMessageId = notifySendService.sendSingleNotifyToMember(userId, templateCode, templateParams);
@ -113,10 +113,10 @@ class NotifySendServiceImplTest extends BaseMockitoUnitTest {
// mock NotifyMessageService 的方法 // mock NotifyMessageService 的方法
Long messageId = randomLongId(); Long messageId = randomLongId();
when(notifyMessageService.createNotifyMessage(eq(userId), eq(userType), when(notifyMessageService.createNotifyMessage(eq(userId), eq(userType),
eq(template), eq(content), eq(templateParams))).thenReturn(messageId); eq(template), eq(content), eq(templateParams), "xx", new HashMap<String, Object>(), "xxx")).thenReturn(messageId);
// 调用 // 调用
Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams); Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams, "xx", new HashMap<String, Object>(), "xxx");
// 断言 // 断言
assertEquals(messageId, resultMessageId); assertEquals(messageId, resultMessageId);
} }
@ -141,11 +141,11 @@ class NotifySendServiceImplTest extends BaseMockitoUnitTest {
when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
// 调用 // 调用
Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams); Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams, "xx", new HashMap<String, Object>(), "xxx");
// 断言 // 断言
assertNull(resultMessageId); assertNull(resultMessageId);
verify(notifyTemplateService, never()).formatNotifyTemplateContent(anyString(), anyMap()); verify(notifyTemplateService, never()).formatNotifyTemplateContent(anyString(), anyMap());
verify(notifyMessageService, never()).createNotifyMessage(anyLong(), anyInt(), any(), anyString(), anyMap()); verify(notifyMessageService, never()).createNotifyMessage(anyLong(), anyInt(), any(), anyString(), anyMap(), "xx", new HashMap<String, Object>(), "xxx");
} }
@Test @Test

Loading…
Cancel
Save