From a40c2eb885bcdb697c2e16dae4f43cb6cd718973 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期一, 22 一月 2024 11:28:03 +0800
Subject: [PATCH] 优化小区数据

---
 service-job/src/main/java/com/java110/job/msgNotify/wechat/WechatMsgNotifyImpl.java |  508 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 445 insertions(+), 63 deletions(-)

diff --git a/service-job/src/main/java/com/java110/job/msgNotify/wechat/WechatMsgNotifyImpl.java b/service-job/src/main/java/com/java110/job/msgNotify/wechat/WechatMsgNotifyImpl.java
index 96ade6e..07cacc4 100644
--- a/service-job/src/main/java/com/java110/job/msgNotify/wechat/WechatMsgNotifyImpl.java
+++ b/service-job/src/main/java/com/java110/job/msgNotify/wechat/WechatMsgNotifyImpl.java
@@ -2,15 +2,16 @@
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.java110.core.client.RestTemplate;
 import com.java110.core.log.LoggerFactory;
 import com.java110.dto.mapping.Mapping;
-import com.java110.dto.mapping.MappingDto;
 import com.java110.dto.owner.OwnerAppUserDto;
+import com.java110.dto.privilege.RoleCommunityDto;
 import com.java110.dto.user.StaffAppAuthDto;
 import com.java110.dto.wechat.Content;
-import com.java110.dto.wechat.Data;
 import com.java110.dto.wechat.PropertyFeeTemplateMessage;
 import com.java110.intf.user.IOwnerAppUserInnerServiceSMO;
+import com.java110.intf.user.IRoleCommunityV1InnerServiceSMO;
 import com.java110.intf.user.IStaffAppAuthInnerServiceSMO;
 import com.java110.job.msgNotify.IMsgNotify;
 import com.java110.job.msgNotify.IWechatTemplate;
@@ -18,12 +19,12 @@
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.MappingConstant;
 import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
 
 import java.util.HashMap;
 import java.util.List;
@@ -57,9 +58,15 @@
     private static final Map<String, String[]> templateKeys = new HashMap<>();
 
     static {
-        templateKeys.put(SPEC_CD_OWE_FEE_TEMPLATE, new String[]{"缂磋垂绫诲瀷","鎴垮彿","鎬婚噾棰�","缂磋垂鍛ㄦ湡"});
+        templateKeys.put(SPEC_CD_OWE_FEE_TEMPLATE, new String[]{"缂磋垂绫诲瀷", "鎴垮彿", "鎬婚噾棰�", "缂磋垂鍛ㄦ湡"});
         templateKeys.put(SPEC_CD_WECHAT_PROCESS_TEMPLATE, new String[]{"娴佺▼鍚嶇О", "鍙戣捣鏃堕棿", "鍙戣捣浜�"});
-        templateKeys.put(SPEC_CD_WECHAT_SUCCESS_TEMPLATE, new String[]{"缂磋垂鎴块棿", "璐圭敤绫诲瀷", "缂磋垂鏃堕棿", "缂磋垂閲戦"});
+        templateKeys.put(SPEC_CD_WECHAT_SUCCESS_TEMPLATE, new String[]{"缂磋垂鎴块棿", "璐圭敤绫诲瀷", "璐圭敤鍛ㄦ湡", "缂磋垂閲戦"});
+        templateKeys.put(SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE, new String[]{"鎶ヤ慨绫诲瀷", "鎶ヤ慨鍦板潃", "鎶ヤ慨闂"});
+        templateKeys.put(SPEC_CD_WECHAT_DISPATCH_REMIND_TEMPLATE, new String[]{"鑱旂郴浜�", "鎵嬫満鍙�", "鎶ヤ慨鏃堕棿", "缁翠慨鍦板潃"});
+        templateKeys.put(SPEC_CD_WECHAT_SCHEDULE_TEMPLATE, new String[]{"骞冲彴鍙楃悊浜�", "鑱旂郴鐢佃瘽", "鍙楃悊鏃堕棿"});
+        templateKeys.put(SPEC_CD_WECHAT_WORK_ORDER_END_TEMPLATE, new String[]{"鎴垮眿鍦板潃", "缁翠慨宸ョ▼甯�", "缁翠慨瀹屾垚鏃堕棿"});
+        templateKeys.put(SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_TEMPLATE, new String[]{"娴佺▼鍚嶇О", "鍙戣捣浜�", "鍙戣捣鏃堕棿"});
+        templateKeys.put(SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_FINISH_TEMPLATE, new String[]{"娴佺▼鍚嶇О", "娴佺▼鐘舵��"});
 
 
     }
@@ -72,6 +79,8 @@
 
     @Autowired
     private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMOImpl;
+
+
 
     @Autowired
     private RestTemplate outRestTemplate;
@@ -106,13 +115,13 @@
 
         String url = sendMsgUrl + accessToken;
 
-        Data data = new Data();
+        JSONObject data = new JSONObject();
         PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
         templateMessage.setTemplate_id(templateId);
         templateMessage.setTouser(openId);
-        data.setKeyword1(new Content("閫�璐圭敵璇峰鎵�"));
-        data.setKeyword2(new Content(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B)));
-        data.setKeyword3(new Content(content.getString("name")));
+        data.put("thing2", new Content("閫�璐圭敵璇峰鎵�"));
+        data.put("time10", new Content(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B)));
+        data.put("thing9", new Content(content.getString("name")));
         templateMessage.setData(data);
         //鑾峰彇鍛樺伐鍏紬鍙峰湴鍧�
         String wechatUrl = MappingCache.getValue(MappingConstant.URL_DOMAIN, "STAFF_WECHAT_URL");
@@ -127,21 +136,264 @@
 
     /**
      * 娆犺垂閫氱煡
+     *
      * @param communityId 灏忓尯
-     * @param userId 鐢ㄦ埛
-     * @param content {
+     * @param userId      鐢ㄦ埛
+     * @param contents    [{
      *                    "feeTypeName",
-     *                     "payerObjName",
-     *                     "billAmountOwed",
-     *                     "date",
-     *                url
-     * }
+     *                    "payerObjName",
+     *                    "billAmountOwed",
+     *                    "date",
+     *                    url
+     *                    }]
      * @return
      */
     @Override
-    public ResultVo sendOweFeeMsg(String communityId, String userId, JSONObject content) {
+    public ResultVo sendOweFeeMsg(String communityId, String userId, String ownerId, List<JSONObject> contents) {
+
+        if (StringUtil.isEmpty(userId) || userId.startsWith("-")) {
+            throw new IllegalArgumentException("涓氫富鏈粦瀹氾紝娌℃湁鑾峰彇鍒板井淇penId");
+        }
 
         String accessToken = wechatTemplateImpl.getAccessToken(communityId);
+
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setCommunityId(communityId);
+        ownerAppUserDto.setAppType(OwnerAppUserDto.APP_TYPE_WECHAT);
+        ownerAppUserDto.setUserId(userId);
+        List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
+        if (ownerAppUserDtos == null || ownerAppUserDtos.isEmpty()) {
+            throw new IllegalArgumentException("涓氫富鏈粦瀹氾紝娌℃湁鑾峰彇鍒板井淇penId");
+        }
+
+        String openId = ownerAppUserDtos.get(0).getOpenId();
+
+        if (StringUtil.isEmpty(openId) || openId.startsWith("-")) {
+            throw new IllegalArgumentException("娌℃湁鑾峰彇鍒板井淇penId");
+        }
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_OWE_FEE_TEMPLATE);
+
+        if (mapping == null) {
+            throw new IllegalArgumentException("寮�鍙戣�呰处鎴风紪鐮佹槧灏勬湭閰嶇疆鍩熶负=" + MappingConstant.WECHAT_DOMAIN + ",閿负=" + SPEC_CD_OWE_FEE_TEMPLATE);
+        }
+        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_OWE_FEE_TEMPLATE));
+
+        String url = sendMsgUrl + accessToken;
+        JSONObject paramOut = null;
+        for (JSONObject content : contents) {
+            JSONObject data = new JSONObject();
+            PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
+            templateMessage.setTemplate_id(templateId);
+            templateMessage.setTouser(openId);
+            data.put("thing2", new Content(content.getString("feeTypeName")));
+            String payerObjName = content.getString("payerObjName");
+            if (!StringUtil.isEmpty(payerObjName) && payerObjName.length() > 20) {
+                payerObjName = payerObjName.substring(0, 20);
+            }
+            data.put("thing12", new Content(payerObjName));
+            data.put("amount3", new Content(content.getString("billAmountOwed")));
+            data.put("time19", new Content(content.getString("date")));
+            templateMessage.setData(data);
+            templateMessage.setUrl(content.getString("url") + "&wAppId=" + wechatTemplateImpl.getAppId(communityId));
+            logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
+            ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
+            logger.info("寰俊妯℃澘杩斿洖鍐呭:{}", responseEntity);
+            paramOut = JSONObject.parseObject(responseEntity.getBody());
+            if (paramOut.getIntValue("errcode") != 0) {
+                return new ResultVo(paramOut.getIntValue("errcode"), paramOut.getString("errmsg"));
+            }
+        }
+        return new ResultVo(ResultVo.CODE_OK, "鎴愬姛");
+    }
+
+    @Override
+    public ResultVo sendPayFeeMsg(String communityId, String userId, JSONObject content, String role) {
+
+        String accessToken = wechatTemplateImpl.getAccessToken(communityId);
+        String url = sendMsgUrl + accessToken;
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_SUCCESS_TEMPLATE);
+
+        if (mapping == null) {
+            throw new IllegalArgumentException("寮�鍙戣�呰处鎴风紪鐮佹槧灏勬湭閰嶇疆鍩熶负=" + MappingConstant.WECHAT_DOMAIN + ",閿负=" + SPEC_CD_WECHAT_SUCCESS_TEMPLATE);
+        }
+        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_SUCCESS_TEMPLATE));
+        String openId = "";
+        if (MsgNotifyFactory.ROLE_OWNER.equals(role)) {
+            OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+            ownerAppUserDto.setCommunityId(communityId);
+            ownerAppUserDto.setAppType(OwnerAppUserDto.APP_TYPE_WECHAT);
+            ownerAppUserDto.setUserId(userId);
+            List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
+            if (ownerAppUserDtos == null || ownerAppUserDtos.size() < 1) {
+                throw new IllegalArgumentException("涓氫富鏈粦瀹氾紝娌℃湁鑾峰彇鍒板井淇penId");
+            }
+            openId = ownerAppUserDtos.get(0).getOpenId();
+        } else {
+            StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
+            staffAppAuthDto.setStaffId(userId);
+            staffAppAuthDto.setAppType("WECHAT");
+            List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMOImpl.queryStaffAppAuths(staffAppAuthDto);
+            if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) {
+                throw new IllegalArgumentException("鍛樺伐鏈璇侊紝娌℃湁鑾峰彇鍒板井淇penId");
+            }
+
+
+
+
+            openId = staffAppAuthDtos.get(0).getOpenId();
+        }
+        JSONObject data = new JSONObject();
+        PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
+        templateMessage.setTemplate_id(templateId);
+        templateMessage.setTouser(openId);
+        // data.put("thing2", new Content(content.getString("feeTypeCdName")));
+        data.put("thing2", new Content(content.getString("feeName")));
+        data.put("thing10", new Content(content.getString("payFeeRoom")));
+        data.put("time18", new Content(content.getString("payFeeTime")));
+        data.put("amount6", new Content(content.getString("receivedAmount")));
+        templateMessage.setData(data);
+        templateMessage.setUrl(content.getString("url"));
+        logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
+        ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
+        logger.info("寰俊妯℃澘杩斿洖鍐呭:{}", responseEntity);
+
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+        return new ResultVo(paramOut.getIntValue("errcode"), paramOut.getString("errmsg"));
+
+
+    }
+
+    /**
+     * 涓氫富鎶ヤ慨鏃�
+     *
+     * @param communityId 灏忓尯
+     * @param userId      鐢ㄦ埛
+     * @param content     {
+     *                    repairTypeName锛�
+     *                    repairObjName锛�
+     *                    repairName锛�
+     *                    url
+     *                    }
+     * @return
+     */
+    @Override
+    public ResultVo sendAddOwnerRepairMsg(String communityId, String userId, JSONObject content) {
+        String accessToken = wechatTemplateImpl.getAccessToken(communityId);
+
+        StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
+        staffAppAuthDto.setStaffId(userId);
+        staffAppAuthDto.setAppType("WECHAT");
+        List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMOImpl.queryStaffAppAuths(staffAppAuthDto);
+        if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) {
+            throw new IllegalArgumentException("鍛樺伐鏈璇侊紝娌℃湁鑾峰彇鍒板井淇penId");
+        }
+        String openId = staffAppAuthDtos.get(0).getOpenId();
+
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE);
+
+        if (mapping == null) {
+            throw new IllegalArgumentException("寮�鍙戣�呰处鎴风紪鐮佹槧灏勬湭閰嶇疆鍩熶负=" + MappingConstant.WECHAT_DOMAIN + ",閿负=" + SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE);
+        }
+        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE));
+
+        String url = sendMsgUrl + accessToken;
+        JSONObject data = new JSONObject();
+        PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
+        templateMessage.setTemplate_id(templateId);
+        templateMessage.setTouser(openId);
+        data.put("thing8", new Content(content.getString("repairTypeName")));
+        data.put("thing11", new Content(content.getString("repairObjName")));
+        String context = content.getString("context");
+        if (!StringUtil.isEmpty(context) && context.length() > 20) {
+            context = context.substring(0, 20);
+        }
+        data.put("thing10", new Content(context));
+        templateMessage.setData(data);
+        templateMessage.setUrl(content.getString("url"));
+        logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
+        ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
+        logger.info("寰俊妯℃澘杩斿洖鍐呭:{}", responseEntity);
+
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+        return new ResultVo(paramOut.getIntValue("errcode"), paramOut.getString("errmsg"));
+    }
+
+    /**
+     * 娲惧崟缁欑淮淇笀鍌�
+     *
+     * @param communityId 灏忓尯
+     * @param userId      鐢ㄦ埛
+     * @param content     {
+     *                    repairName锛�
+     *                    tel锛�
+     *                    time锛�
+     *                    address
+     *                    }
+     * @return
+     */
+    @Override
+    public ResultVo sendDistributeRepairStaffMsg(String communityId, String userId, JSONObject content) {
+        String accessToken = wechatTemplateImpl.getAccessToken(communityId);
+
+        StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
+        staffAppAuthDto.setStaffId(userId);
+        staffAppAuthDto.setAppType("WECHAT");
+        List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMOImpl.queryStaffAppAuths(staffAppAuthDto);
+        if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) {
+            throw new IllegalArgumentException("鍛樺伐鏈璇侊紝娌℃湁鑾峰彇鍒板井淇penId");
+        }
+        String openId = staffAppAuthDtos.get(0).getOpenId();
+
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_DISPATCH_REMIND_TEMPLATE);
+
+        if (mapping == null) {
+            throw new IllegalArgumentException("寮�鍙戣�呰处鎴风紪鐮佹槧灏勬湭閰嶇疆鍩熶负=" + MappingConstant.WECHAT_DOMAIN + ",閿负=" + SPEC_CD_WECHAT_DISPATCH_REMIND_TEMPLATE);
+        }
+        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_DISPATCH_REMIND_TEMPLATE));
+
+        String url = sendMsgUrl + accessToken;
+        JSONObject data = new JSONObject();
+        PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
+        templateMessage.setTemplate_id(templateId);
+        templateMessage.setTouser(openId);
+        data.put("thing7", new Content(content.getString("repairName")));
+        data.put("phone_number3", new Content(content.getString("tel")));
+        data.put("time13", new Content(content.getString("time")));
+        data.put("thing9", new Content(content.getString("address")));
+        templateMessage.setData(data);
+        templateMessage.setUrl(content.getString("url"));
+        logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
+        ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
+        logger.info("寰俊妯℃澘杩斿洖鍐呭:{}", responseEntity);
+
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+        return new ResultVo(paramOut.getIntValue("errcode"), paramOut.getString("errmsg"));
+    }
+
+    /**
+     * 娲惧崟缁欎笟涓婚�氱煡
+     *
+     * @param communityId 灏忓尯
+     * @param userId      鐢ㄦ埛
+     * @param content     {
+     *                    name锛�
+     *                    tel锛�
+     *                    time锛�
+     *                    url
+     *                    }
+     * @return
+     */
+    @Override
+    public ResultVo sendDistributeRepairOwnerMsg(String communityId, String userId, JSONObject content) {
+        String accessToken = wechatTemplateImpl.getAccessToken(communityId);
+        String url = sendMsgUrl + accessToken;
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_SCHEDULE_TEMPLATE);
+
+        if (mapping == null) {
+            throw new IllegalArgumentException("寮�鍙戣�呰处鎴风紪鐮佹槧灏勬湭閰嶇疆鍩熶负=" + MappingConstant.WECHAT_DOMAIN + ",閿负=" + SPEC_CD_WECHAT_SCHEDULE_TEMPLATE);
+        }
+        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_SCHEDULE_TEMPLATE));
+        String openId = "";
 
         OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
         ownerAppUserDto.setCommunityId(communityId);
@@ -151,24 +403,68 @@
         if (ownerAppUserDtos == null || ownerAppUserDtos.size() < 1) {
             throw new IllegalArgumentException("涓氫富鏈粦瀹氾紝娌℃湁鑾峰彇鍒板井淇penId");
         }
+        openId = ownerAppUserDtos.get(0).getOpenId();
 
-        String openId = ownerAppUserDtos.get(0).getOpenId();
-        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_OWE_FEE_TEMPLATE);
-
-        if (mapping == null) {
-            throw new IllegalArgumentException("寮�鍙戣�呰处鎴风紪鐮佹槧灏勬湭閰嶇疆鍩熶负=" + MappingConstant.WECHAT_DOMAIN + ",閿负=" + SPEC_CD_OWE_FEE_TEMPLATE);
-        }
-        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_OWE_FEE_TEMPLATE));
-
-        String url = sendMsgUrl + accessToken;
-        Data data = new Data();
+        JSONObject data = new JSONObject();
         PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
         templateMessage.setTemplate_id(templateId);
         templateMessage.setTouser(openId);
-        data.setKeyword1(new Content(content.getString("feeTypeName")));
-        data.setKeyword2(new Content(content.getString("payerObjName")));
-        data.setKeyword3(new Content(content.getString("billAmountOwed")));
-        data.setKeyword4(new Content(content.getString("date")));
+        data.put("thing6", new Content(content.getString("name")));
+        data.put("phone_number9", new Content(content.getString("tel")));
+        data.put("time3", new Content(content.getString("time")));
+        templateMessage.setData(data);
+        templateMessage.setUrl(content.getString("url"));
+        logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
+        ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
+        logger.info("寰俊妯℃澘杩斿洖鍐呭:{}", responseEntity);
+
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+        return new ResultVo(paramOut.getIntValue("errcode"), paramOut.getString("errmsg"));
+    }
+
+
+    /**
+     * 鎶ヤ慨瀹屾垚缁欎笟涓婚�氱煡
+     *
+     * @param communityId 灏忓尯
+     * @param userId      鐢ㄦ埛
+     * @param content     {
+     *                    repairObjName锛�
+     *                    staffName锛�
+     *                    time锛�
+     *                    url
+     *                    }
+     * @return
+     */
+    @Override
+    public ResultVo sendFinishRepairOwnerMsg(String communityId, String userId, JSONObject content) {
+        String accessToken = wechatTemplateImpl.getAccessToken(communityId);
+        String url = sendMsgUrl + accessToken;
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_WORK_ORDER_END_TEMPLATE);
+
+        if (mapping == null) {
+            throw new IllegalArgumentException("寮�鍙戣�呰处鎴风紪鐮佹槧灏勬湭閰嶇疆鍩熶负=" + MappingConstant.WECHAT_DOMAIN + ",閿负=" + SPEC_CD_WECHAT_WORK_ORDER_END_TEMPLATE);
+        }
+        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_WORK_ORDER_END_TEMPLATE));
+        String openId = "";
+
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setCommunityId(communityId);
+        ownerAppUserDto.setAppType(OwnerAppUserDto.APP_TYPE_WECHAT);
+        ownerAppUserDto.setUserId(userId);
+        List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
+        if (ownerAppUserDtos == null || ownerAppUserDtos.size() < 1) {
+            throw new IllegalArgumentException("涓氫富鏈粦瀹氾紝娌℃湁鑾峰彇鍒板井淇penId");
+        }
+        openId = ownerAppUserDtos.get(0).getOpenId();
+
+        JSONObject data = new JSONObject();
+        PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
+        templateMessage.setTemplate_id(templateId);
+        templateMessage.setTouser(openId);
+        data.put("thing9", new Content(content.getString("repairObjName")));
+        data.put("thing10", new Content(content.getString("staffName")));
+        data.put("time5", new Content(content.getString("time")));
         templateMessage.setData(data);
         templateMessage.setUrl(content.getString("url"));
         logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
@@ -180,45 +476,33 @@
     }
 
     @Override
-    public ResultVo sendPayFeeMsg(String communityId, String userId, JSONObject content,String role) {
-
+    public ResultVo sendReturnRepairMsg(String communityId, String userId, JSONObject content) {
         String accessToken = wechatTemplateImpl.getAccessToken(communityId);
-        String url = sendMsgUrl + accessToken;
-        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_SUCCESS_TEMPLATE);
+
+        StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
+        staffAppAuthDto.setStaffId(userId);
+        staffAppAuthDto.setAppType("WECHAT");
+        List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMOImpl.queryStaffAppAuths(staffAppAuthDto);
+        if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) {
+            throw new IllegalArgumentException("鍛樺伐鏈璇侊紝娌℃湁鑾峰彇鍒板井淇penId");
+        }
+        String openId = staffAppAuthDtos.get(0).getOpenId();
+
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE);
 
         if (mapping == null) {
-            throw new IllegalArgumentException("寮�鍙戣�呰处鎴风紪鐮佹槧灏勬湭閰嶇疆鍩熶负=" + MappingConstant.WECHAT_DOMAIN + ",閿负=" + SPEC_CD_WECHAT_SUCCESS_TEMPLATE);
+            throw new IllegalArgumentException("寮�鍙戣�呰处鎴风紪鐮佹槧灏勬湭閰嶇疆鍩熶负=" + MappingConstant.WECHAT_DOMAIN + ",閿负=" + SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE);
         }
-        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_SUCCESS_TEMPLATE));
-        String openId = "";
-        if(MsgNotifyFactory.ROLE_OWNER.equals(role)){
-            OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
-            ownerAppUserDto.setCommunityId(communityId);
-            ownerAppUserDto.setAppType(OwnerAppUserDto.APP_TYPE_WECHAT);
-            ownerAppUserDto.setUserId(userId);
-            List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
-            if (ownerAppUserDtos == null || ownerAppUserDtos.size() < 1) {
-                throw new IllegalArgumentException("涓氫富鏈粦瀹氾紝娌℃湁鑾峰彇鍒板井淇penId");
-            }
-            openId= ownerAppUserDtos.get(0).getOpenId();
-        }else{
-            StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
-            staffAppAuthDto.setStaffId(userId);
-            staffAppAuthDto.setAppType("WECHAT");
-            List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMOImpl.queryStaffAppAuths(staffAppAuthDto);
-            if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) {
-                throw new IllegalArgumentException("鍛樺伐鏈璇侊紝娌℃湁鑾峰彇鍒板井淇penId");
-            }
-            openId = staffAppAuthDtos.get(0).getOpenId();
-        }
-        Data data = new Data();
+        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE));
+
+        String url = sendMsgUrl + accessToken;
+        JSONObject data = new JSONObject();
         PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
         templateMessage.setTemplate_id(templateId);
         templateMessage.setTouser(openId);
-        data.setKeyword1(new Content(content.getString("feeTypeCdName")));
-        data.setKeyword2(new Content(content.getString("payFeeRoom")));
-        data.setKeyword3(new Content(content.getString("payFeeTime")));
-        data.setKeyword4(new Content(content.getString("receivedAmount")));
+        data.put("thing8", new Content(content.getString("repairTypeName")));
+        data.put("thing11", new Content(content.getString("repairObjName")));
+        data.put("thing10", new Content(content.getString("repairName")));
         templateMessage.setData(data);
         templateMessage.setUrl(content.getString("url"));
         logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
@@ -227,7 +511,105 @@
 
         JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
         return new ResultVo(paramOut.getIntValue("errcode"), paramOut.getString("errmsg"));
+    }
 
+    /**
+     * oa 娴佺▼寰呭鎵归�氱煡
+     *
+     * @param communityId 灏忓尯
+     * @param userId      鐢ㄦ埛
+     * @param content     {
+     *                    flowName锛�
+     *                    create_user_name锛�
+     *                    create_time锛�
+     *                    url
+     *                    }
+     * @return
+     */
+    @Override
+    public ResultVo sendOaDistributeMsg(String communityId, String userId, JSONObject content) {
+        String accessToken = wechatTemplateImpl.getAccessToken(communityId);
 
+        StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
+        staffAppAuthDto.setStaffId(userId);
+        staffAppAuthDto.setAppType("WECHAT");
+        List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMOImpl.queryStaffAppAuths(staffAppAuthDto);
+        if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) {
+            throw new IllegalArgumentException("鍛樺伐鏈璇侊紝娌℃湁鑾峰彇鍒板井淇penId");
+        }
+        String openId = staffAppAuthDtos.get(0).getOpenId();
+
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_TEMPLATE);
+
+        if (mapping == null) {
+            throw new IllegalArgumentException("寮�鍙戣�呰处鎴风紪鐮佹槧灏勬湭閰嶇疆鍩熶负=" + MappingConstant.WECHAT_DOMAIN + ",閿负=" + SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_TEMPLATE);
+        }
+        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_TEMPLATE));
+
+        String url = sendMsgUrl + accessToken;
+        JSONObject data = new JSONObject();
+        PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
+        templateMessage.setTemplate_id(templateId);
+        templateMessage.setTouser(openId);
+        data.put("thing2", new Content(content.getString("flowName")));
+        data.put("thing9", new Content(content.getString("create_user_name")));
+        data.put("time10", new Content(content.getString("create_time")));
+        templateMessage.setData(data);
+        templateMessage.setUrl(content.getString("url"));
+        logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
+        ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
+        logger.info("寰俊妯℃澘杩斿洖鍐呭:{}", responseEntity);
+
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+        return new ResultVo(paramOut.getIntValue("errcode"), paramOut.getString("errmsg"));
+    }
+
+    /**
+     * oa 娴佺▼閫氱煡鍙戣捣浜�
+     *
+     * @param communityId 灏忓尯
+     * @param userId      鐢ㄦ埛
+     * @param content     {
+     *                    flowName锛�
+     *                    staffName锛�
+     *                    url
+     *                    }
+     * @return
+     */
+    @Override
+    public ResultVo sendOaCreateStaffMsg(String communityId, String userId, JSONObject content) {
+        String accessToken = wechatTemplateImpl.getAccessToken(communityId);
+
+        StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
+        staffAppAuthDto.setStaffId(userId);
+        staffAppAuthDto.setAppType("WECHAT");
+        List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMOImpl.queryStaffAppAuths(staffAppAuthDto);
+        if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) {
+            throw new IllegalArgumentException("鍛樺伐鏈璇侊紝娌℃湁鑾峰彇鍒板井淇penId");
+        }
+        String openId = staffAppAuthDtos.get(0).getOpenId();
+
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_FINISH_TEMPLATE);
+
+        if (mapping == null) {
+            throw new IllegalArgumentException("寮�鍙戣�呰处鎴风紪鐮佹槧灏勬湭閰嶇疆鍩熶负=" + MappingConstant.WECHAT_DOMAIN + ",閿负=" + SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_FINISH_TEMPLATE);
+        }
+        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_FINISH_TEMPLATE));
+
+        String url = sendMsgUrl + accessToken;
+        JSONObject data = new JSONObject();
+        PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
+        templateMessage.setTemplate_id(templateId);
+        templateMessage.setTouser(openId);
+        data.put("thing2", new Content(content.getString("flowName")));
+        data.put("thing6", new Content(content.getString("staffName")));
+        templateMessage.setData(data);
+        templateMessage.setUrl(content.getString("url"));
+        logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
+        ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
+        logger.info("寰俊妯℃澘杩斿洖鍐呭:{}", responseEntity);
+
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+        return new ResultVo(paramOut.getIntValue("errcode"), paramOut.getString("errmsg"));
     }
 }

--
Gitblit v1.8.0