Browse Source

消息通知与短信通知

tudc 4 years ago
parent
commit
f9e458b211

+ 1 - 1
tianhu-system/src/main/java/com/tianhu/system/common/impl/MessageUtilsServiceImpl.java

@@ -95,7 +95,7 @@ public class MessageUtilsServiceImpl implements IMessageUtilsService
 
         //调试模式
         boolean isTest = true;
-        String regVal = RedisUtils.getDictValue("pub_verification_code", templateCode);
+        String regVal = RedisUtils.getDictValue("aliyun_message_code", templateCode);
 
         if(!isTest) {
             try {

+ 43 - 0
tianhu-system/src/main/java/com/tianhu/system/controller/MessageController.java

@@ -0,0 +1,43 @@
+package com.tianhu.system.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.keao.tianhu.core.entity.R;
+import com.tianhu.common.core.web.controller.BaseController;
+import com.tianhu.common.security.service.TokenService;
+import com.tianhu.system.common.IMessageUtilsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * 短信
+ * 
+ * @author keao
+ * @date 2020-08-25
+ */
+@RestController
+@RequestMapping("/message")
+public class MessageController extends BaseController
+{
+    @Autowired
+    private IMessageUtilsService iMessageUtilsService;
+
+    /**
+     *
+     * @param mobileNo
+     * @param templateCode
+     * @param paramString
+     * @param random
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("sendAliMessage")
+    public R sendAliMessage(String mobileNo, String templateCode, String paramString, String random)throws Exception {
+        Map<String, String> param = JSONObject.parseObject(paramString, Map.class);
+        iMessageUtilsService.sendMessageCode(mobileNo, templateCode, param, random);
+        return R.ok();
+    }
+}

+ 1 - 1
tianhu-system/src/main/java/com/tianhu/system/controller/OwnNoticeController.java

@@ -81,7 +81,7 @@ public class OwnNoticeController extends BaseController
      * @param userIds       收到信息用户id集合
      */
     @PostMapping("sendNotice")
-    public R sendNotice(String companyId, String tableId, String title, String type, String noticeType, String workType, String messageSend, List<Long> userIds, String templateCode)throws Exception {
+    public R sendNotice(String companyId, String tableId, String title, String type, String noticeType, String workType, String messageSend, String userIds, String templateCode)throws Exception {
         R r = iOwnNoticeService.sendNotice(companyId, tableId, title, type, noticeType, workType, messageSend, userIds, templateCode);
         return r;
     }

+ 1 - 1
tianhu-system/src/main/java/com/tianhu/system/service/IOwnNoticeService.java

@@ -35,5 +35,5 @@ public interface IOwnNoticeService
      * @param templateCode  短信模板(aliyun_message_code)
      * @return
      */
-    public R sendNotice(String companyId, String tableId, String title, String type, String noticeType, String workType, String messageSend, List<Long> userIds, String templateCode);
+    public R sendNotice(String companyId, String tableId, String title, String type, String noticeType, String workType, String messageSend, String userIds, String templateCode);
 }

+ 7 - 6
tianhu-system/src/main/java/com/tianhu/system/service/impl/OwnNoticeServiceImpl.java

@@ -76,14 +76,14 @@ public class OwnNoticeServiceImpl implements IOwnNoticeService
      * @param tableId       表主键
      * @param title         标题
      * @param type          类型 00待办 01消息
-     * @param noticeType    消息类型 00:平台欢迎信, 01:发起人审批结果通知, 02:经办人的平台审批结果通知, 03:融资企业经办人融信失效消息通知, 04:融资企业经办人融信生效消息通知
-     * @param workType      待办类型 00:融信审批待审批, 01:审批拒绝待编辑, 02:核心企业待确权, 03:待盖章, 04:待签收, 05:待融资, 06:待还款
+     * @param noticeType    消息类型 00:平台欢迎信, 01:发起人审批结果通知, 02:经办人的平台审批结果通知, 03:融资企业经办人融信失效消息通知, 04:融资企业经办人融信生效消息通知, 05:融信即将失效消息通知, 06:还款消息通知
+     * @param workType      待办类型 00:融信审批待审批, 01:审批拒绝待编辑, 02:核心企业待确权, 03:待盖章, 04:待签收, 05:待融资, 06:待还款, 07:平台内部待办
      * @param messageSend   是否发送短信 0不发送 1发送
      * @param userIds       收到信息用户id集合
      * @param templateCode  短信模板(aliyun_message_code)
      */
     @Override
-    public R sendNotice(String companyId, String tableId, String title, String type, String noticeType, String workType, String messageSend, List<Long> userIds, String templateCode)
+    public R sendNotice(String companyId, String tableId, String title, String type, String noticeType, String workType, String messageSend, String userIds, String templateCode)
     {
         //新增通知公告
         SysNotice notice = new SysNotice();
@@ -107,13 +107,14 @@ public class OwnNoticeServiceImpl implements IOwnNoticeService
         //发送短信手机号
         String phones = "";
         //新增通知公告接收人
-        for (Long userId : userIds) {
+        String[] userIdList = userIds.split(",");
+        for (String userId : userIdList) {
             SysNoticeUserRel sysNoticeUserRel = new SysNoticeUserRel();
             sysNoticeUserRel.setSnyrNoticeId(id);
-            sysNoticeUserRel.setSnyrUserId(userId);
+            sysNoticeUserRel.setSnyrUserId(Long.parseLong(userId));
             iSysNoticeUserRelService.insertSysNoticeUserRel(sysNoticeUserRel);
             //查询发送人手机号
-            SysUser user = iSysUserService.selectUserById(userId);
+            SysUser user = iSysUserService.selectUserById(Long.parseLong(userId));
             if (CommonUtil.isEmpty(phones)){
                 phones = user.getUserName();
             }else {

+ 0 - 1
tianhu-system/src/main/resources/mapper/system/SysNoticeMapper.xml

@@ -63,7 +63,6 @@
             <if test="messageCode != null">message_code,</if>
             <if test="remark != null">remark,</if>
             create_time
-        )
         )values(
             <if test="noticeId != null">#{noticeId},</if>
             <if test="companyId != null">#{companyId},</if>