瀏覽代碼

修改 消息

java110 2 年之前
父節點
當前提交
c67f486ca5

+ 3 - 0
java110-utils/src/main/java/com/java110/utils/cache/CommonCache.java

@@ -21,6 +21,9 @@ public class CommonCache extends BaseCache {
     //支付默认回话
     public final static int PAY_DEFAULT_EXPIRE_TIME = 2 * 60 * 60;
 
+    //回话默认回话
+    public final static int TOKEN_EXPIRE_TIME = 2 * 60 * 60;
+
     public static final String RECEIPT_CODE = "_RECEIPT_CODE";// 收据编号
 
 

+ 5 - 1
java110-utils/src/main/java/com/java110/utils/cache/MappingCache.java

@@ -65,12 +65,16 @@ public class MappingCache extends BaseCache {
     }
 
     public static Mapping getMapping(String key) {
+        return getMapping(DomainContant.COMMON_DOMAIN,key);
+    }
+
+    public static Mapping getMapping(String domain,String key) {
         Jedis redis = null;
         long startTime = DateUtil.getCurrentDate().getTime();
 
         try {
             redis = getJedis();
-            Object obj = SerializeUtil.unserialize(redis.get((DomainContant.COMMON_DOMAIN + key + _SUFFIX_MAPPING).getBytes()));
+            Object obj = SerializeUtil.unserialize(redis.get((domain + key + _SUFFIX_MAPPING).getBytes()));
             if (obj instanceof Mapping) {
                 return (Mapping) obj;
             }

+ 5 - 0
java110-utils/src/main/java/com/java110/utils/constant/MappingConstant.java

@@ -6,6 +6,8 @@ package com.java110.utils.constant;
  */
 public final class MappingConstant {
 
+
+
     private MappingConstant() {
 
     }
@@ -17,6 +19,9 @@ public final class MappingConstant {
     // 短信配置
     public static final String SMS_DOMAIN = "SMS_DOMAIN";
 
+    // 微信配置
+    public static final String WECHAT_DOMAIN = "WECHAT";
+
     // 存储配置
     public static final String FILE_DOMAIN = "FILE_DOMAIN";
     public static final String DOMAIN_COMMON = "DOMAIN.COMMON";

+ 44 - 9
service-community/src/main/java/com/java110/community/cmd/floor/DeleteFloorCmd.java

@@ -7,17 +7,22 @@ import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.doc.annotation.*;
+import com.java110.dto.room.RoomDto;
 import com.java110.dto.unit.UnitDto;
 import com.java110.intf.community.IFloorInnerServiceSMO;
 import com.java110.intf.community.IFloorV1InnerServiceSMO;
+import com.java110.intf.community.IRoomV1InnerServiceSMO;
 import com.java110.intf.community.IUnitV1InnerServiceSMO;
 import com.java110.po.floor.FloorPo;
+import com.java110.po.unit.UnitPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.List;
+
 
 @Java110CmdDoc(title = "删除楼栋",
         description = "用于外系统删除楼栋信息功能",
@@ -31,7 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 
 @Java110ParamsDoc(params = {
         @Java110ParamDoc(name = "communityId", length = 30, remark = "小区ID"),
-        @Java110ParamDoc(name = "floorId",length = 30, remark = "楼栋ID"),
+        @Java110ParamDoc(name = "floorId", length = 30, remark = "楼栋ID"),
 })
 
 @Java110ResponseDoc(
@@ -42,8 +47,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 )
 
 @Java110ExampleDoc(
-        reqBody="{\"floorId\":\"123123\",\"communityId\":\"2022081539020475\"}",
-        resBody="{'code':0,'msg':'成功'}"
+        reqBody = "{\"floorId\":\"123123\",\"communityId\":\"2022081539020475\"}",
+        resBody = "{'code':0,'msg':'成功'}"
 )
 
 @Java110Cmd(serviceCode = "floor.deleteFloor")
@@ -57,18 +62,30 @@ public class DeleteFloorCmd extends Cmd {
     @Autowired
     private IUnitV1InnerServiceSMO unitV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IRoomV1InnerServiceSMO roomV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.jsonObjectHaveKey(reqJson, "floorId", "请求报文中未包含floorId");
         Assert.jsonObjectHaveKey(reqJson, "communityId", "请求报文中未包含communityId");
 
-        UnitDto unitDto = new UnitDto();
-        unitDto.setFloorId(reqJson.getString("floorId"));
-        unitDto.setCommunityId(reqJson.getString("communityId"));
-//        unitDto.setRoomUnit(UnitDto.ROOM_UNIT_Y);
-        int count = unitV1InnerServiceSMOImpl.queryUnitsCount(unitDto);
+//        UnitDto unitDto = new UnitDto();
+//        unitDto.setFloorId(reqJson.getString("floorId"));
+//        unitDto.setCommunityId(reqJson.getString("communityId"));
+////        unitDto.setRoomUnit(UnitDto.ROOM_UNIT_Y);
+//        int count = unitV1InnerServiceSMOImpl.queryUnitsCount(unitDto);
+//        if (count > 0) {
+//            throw new IllegalArgumentException("请先删除单元 再删除楼栋");
+//        }
+
+        //todo 校验 楼栋下是否有 房屋或者商铺
+        RoomDto roomDto = new RoomDto();
+        roomDto.setFloorId(reqJson.getString("floorId"));
+        roomDto.setCommunityId(reqJson.getString("communityId"));
+        int count = roomV1InnerServiceSMOImpl.queryRoomsCount(roomDto);
         if (count > 0) {
-            throw new IllegalArgumentException("请先删除单元 再删除楼栋");
+            throw new IllegalArgumentException("请先删除楼栋下的房屋或者商铺");
         }
     }
 
@@ -82,6 +99,24 @@ public class DeleteFloorCmd extends Cmd {
             throw new CmdException("删除楼栋失败");
         }
 
+        //todo 删除楼栋下的单元
+        UnitDto unitDto = new UnitDto();
+        unitDto.setFloorId(reqJson.getString("floorId"));
+        unitDto.setCommunityId(reqJson.getString("communityId"));
+        List<UnitDto> unitDtos = unitV1InnerServiceSMOImpl.queryUnits(unitDto);
+
+        if (unitDtos == null || unitDtos.size() < 1) {
+            return;
+        }
+
+        UnitPo unitPo = null;
+        for (UnitDto tmpUnitDto : unitDtos) {
+            unitPo = new UnitPo();
+            unitPo.setUnitId(tmpUnitDto.getUnitId());
+            unitV1InnerServiceSMOImpl.deleteUnit(unitPo);
+        }
+
+
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }
 }

+ 4 - 43
service-job/src/main/java/com/java110/job/adapt/fee/ReturnPayFeeAdapt.java

@@ -28,6 +28,7 @@ import com.java110.intf.user.IOwnerInnerServiceSMO;
 import com.java110.intf.user.IOwnerRoomRelInnerServiceSMO;
 import com.java110.intf.user.IStaffAppAuthInnerServiceSMO;
 import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.msgNotify.MsgNotifyFactory;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.MappingConstant;
 import com.java110.utils.util.Assert;
@@ -80,6 +81,7 @@ public class ReturnPayFeeAdapt extends DatabusAdaptImpl {
     @Autowired
     private RestTemplate outRestTemplate;
 
+
     private static Logger logger = LoggerFactory.getLogger(ReturnPayFeeAdapt.class);
 
     //模板信息推送地址
@@ -155,54 +157,13 @@ public class ReturnPayFeeAdapt extends DatabusAdaptImpl {
             logger.info("未配置微信公众号信息,定时任务执行结束");
             return;
         }
-        SmallWeChatDto weChatDto = smallWeChatDtos.get(0);
-        SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
-        smallWechatAttrDto.setCommunityId(communityDto.getCommunityId());
-        smallWechatAttrDto.setWechatId(weChatDto.getWeChatId());
-        smallWechatAttrDto.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_PROCESS_TEMPLATE);
-        List<SmallWechatAttrDto> smallWechatAttrDtos = smallWechatAttrInnerServiceSMOImpl.querySmallWechatAttrs(smallWechatAttrDto);
-        if (smallWechatAttrDtos == null || smallWechatAttrDtos.size() <= 0) {
-            logger.info("未配置微信公众号消息模板");
-            return;
-        }
-        String templateId = smallWechatAttrDtos.get(0).getValue();
-        String accessToken = WechatFactory.getAccessToken(weChatDto.getAppId(), weChatDto.getAppSecret());
-        if (StringUtil.isEmpty(accessToken)) {
-            logger.info("推送微信模板,获取accessToken失败:{}", accessToken);
-            return;
-        }
+
         // 根据特定权限查询 有该权限的 员工
         BasePrivilegeDto basePrivilegeDto = new BasePrivilegeDto();
         basePrivilegeDto.setResource("/admin.html#/pages/property/returnPayFeeManage");
         List<UserDto> userDtos = privilegeInnerServiceSMO.queryPrivilegeUsers(basePrivilegeDto);
-        String url = sendMsgUrl + accessToken;
         for (UserDto userDto : userDtos) {
-            //根据 userId 查询到openId
-            StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
-            staffAppAuthDto.setStaffId(userDto.getUserId());
-            staffAppAuthDto.setAppType("WECHAT");
-            List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto);
-            if (staffAppAuthDtos != null && staffAppAuthDtos.size() > 0) {
-                String openId = staffAppAuthDtos.get(0).getOpenId();
-                Data data = new Data();
-                PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
-                templateMessage.setTemplate_id(templateId);
-                templateMessage.setTouser(openId);
-                data.setFirst(new Content("您有新的退费申请,申请信息如下:"));
-                data.setKeyword1(new Content(paramIn.getString("detailId")));
-                data.setKeyword2(new Content("退费申请"));
-                data.setKeyword3(new Content(paramIn.getString("name")));
-                data.setKeyword4(new Content(paramIn.getString("name") + "提交的退费申请需审批"));
-                data.setKeyword5(new Content("申请退费"));
-                data.setRemark(new Content("请及时处理!"));
-                templateMessage.setData(data);
-                //获取员工公众号地址
-                String wechatUrl = MappingCache.getValue(MappingConstant.URL_DOMAIN,"STAFF_WECHAT_URL");
-                templateMessage.setUrl(wechatUrl);
-                logger.info("发送模板消息内容:{}", JSON.toJSONString(templateMessage));
-                ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
-                logger.info("微信模板返回内容:{}", responseEntity);
-            }
+            MsgNotifyFactory.sendApplyReturnFeeMsg(communityDto.getCommunityId(), userDto.getUserId(), paramIn);
         }
     }
 

+ 59 - 226
service-job/src/main/java/com/java110/job/adapt/payment/notice/MachinePaymentNoticeAdapt.java

@@ -42,6 +42,7 @@ import com.java110.intf.user.IOwnerInnerServiceSMO;
 import com.java110.intf.user.IOwnerRoomRelInnerServiceSMO;
 import com.java110.intf.user.IStaffAppAuthInnerServiceSMO;
 import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.msgNotify.MsgNotifyFactory;
 import com.java110.po.fee.PayFeeDetailPo;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.cache.UrlCache;
@@ -248,32 +249,7 @@ public class MachinePaymentNoticeAdapt extends DatabusAdaptImpl {
      * @param payFeeDetailPo
      */
     private void publishMsg(JSONObject paramIn, CommunityDto communityDto, PayFeeDetailPo payFeeDetailPo) {
-        //查询公众号配置
-        SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
-        smallWeChatDto.setWeChatType("1100");
-        smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
-        smallWeChatDto.setObjId(communityDto.getCommunityId());
-        List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
-        if (smallWeChatDto == null || smallWeChatDtos.size() <= 0) {
-            logger.info("未配置微信公众号信息,定时任务执行结束");
-            return;
-        }
-        SmallWeChatDto weChatDto = smallWeChatDtos.get(0);
-        SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
-        smallWechatAttrDto.setCommunityId(communityDto.getCommunityId());
-        smallWechatAttrDto.setWechatId(weChatDto.getWeChatId());
-        smallWechatAttrDto.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_SUCCESS_TEMPLATE);
-        List<SmallWechatAttrDto> smallWechatAttrDtos = smallWechatAttrInnerServiceSMOImpl.querySmallWechatAttrs(smallWechatAttrDto);
-        if (smallWechatAttrDtos == null || smallWechatAttrDtos.size() <= 0) {
-            logger.info("未配置微信公众号消息模板");
-            return;
-        }
-        String templateId = smallWechatAttrDtos.get(0).getValue();
-        String accessToken = WechatFactory.getAccessToken(weChatDto.getAppId(), weChatDto.getAppSecret());
-        if (StringUtil.isEmpty(accessToken)) {
-            logger.info("推送微信模板,获取accessToken失败:{}", accessToken);
-            return;
-        }
+
         FeeDto feeDto = new FeeDto();
         feeDto.setFeeId(payFeeDetailPo.getFeeId());
         feeDto.setCommunityId(payFeeDetailPo.getCommunityId());
@@ -281,54 +257,28 @@ public class MachinePaymentNoticeAdapt extends DatabusAdaptImpl {
         Assert.listOnlyOne(feeDtos, "费用不存在");
         // 根据特定权限查询 有该权限的 员工
         BasePrivilegeDto basePrivilegeDto = new BasePrivilegeDto();
-        //basePrivilegeDto.setPId("502020121454780004");
         basePrivilegeDto.setResource("/wechatNotification");
         basePrivilegeDto.setStoreId(feeDtos.get(0).getIncomeObjId());
         List<UserDto> userDtos = privilegeInnerServiceSMO.queryPrivilegeUsers(basePrivilegeDto);
-        String sendTemplate = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.SEND_TEMPLATE_URL);
-        if (StringUtil.isEmpty(sendTemplate)) {
-            sendTemplate = sendMsgUrl;
-        }
-        String url = sendTemplate + accessToken;
+        String wechatUrl = MappingCache.getValue(MappingConstant.URL_DOMAIN, "STAFF_WECHAT_URL");
+
         //获取付费对象类型
         String payerObjType = paramIn.getString("payerObjType");
-        if (userDtos != null && userDtos.size() > 0) {
-            for (UserDto userDto : userDtos) {
-                //根据 userId 查询到openId
-                try {
-                    StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
-                    staffAppAuthDto.setStaffId(userDto.getUserId());
-                    staffAppAuthDto.setAppType("WECHAT");
-                    List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto);
-                    if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) {
-                        continue;
-                    }
-                    String openId = staffAppAuthDtos.get(0).getOpenId();
-                    Data data = new Data();
-                    PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
-                    templateMessage.setTemplate_id(templateId);
-                    templateMessage.setTouser(openId);
-                    data.setFirst(new Content("本次缴费已到账"));
-                    if (payerObjType.equals("3333")) {  //房屋
-                        data.setKeyword1(new Content(paramIn.getString("payFeeRoom")));
-                        data.setKeyword2(new Content(paramIn.getString("feeTypeCdName")));
-                    } else {  //车辆
-                        data.setKeyword1(new Content(communityDto.getName() + "-" + paramIn.getString("num") + "-" + paramIn.getString("spaceNum")));
-                        data.setKeyword2(new Content(paramIn.getString("feeTypeCdName") + "-" + paramIn.getString("carNum")));
-                    }
-                    data.setKeyword3(new Content(paramIn.getString("payFeeTime")));
-                    data.setKeyword4(new Content(paramIn.getString("receivedAmount") + "元"));
-                    data.setRemark(new Content("感谢您的使用,如有疑问请联系相关物业人员"));
-                    templateMessage.setData(data);
-                    //获取员工公众号地址
-                    String wechatUrl = MappingCache.getValue(MappingConstant.URL_DOMAIN, "STAFF_WECHAT_URL");
-                    templateMessage.setUrl(wechatUrl);
-                    logger.info("发送模板消息内容:{}", JSON.toJSONString(templateMessage));
-                    ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
-                    logger.info("微信模板返回内容:{}", responseEntity);
-                } catch (Exception e) {
-                    logger.error("发送缴费信息失败", e);
-                }
+        if (userDtos == null || userDtos.size() < 1) {
+            return;
+        }
+        for (UserDto userDto : userDtos) {
+            //根据 userId 查询到openId
+            try {
+                JSONObject content = new JSONObject();
+                content.put("payFeeRoom", paramIn.getString("payFeeRoom"));
+                content.put("feeTypeCdName", paramIn.getString("feeTypeCdName"));
+                content.put("payFeeTime", paramIn.getString("payFeeTime"));
+                content.put("receivedAmount", paramIn.getString("receivedAmount") + "元");
+                content.put("url", wechatUrl);
+                MsgNotifyFactory.sendPayFeeMsg(payFeeDetailPo.getCommunityId(), userDto.getUserId(), content, MsgNotifyFactory.ROLE_STAFF);
+            } catch (Exception e) {
+                logger.error("发送缴费信息失败", e);
             }
         }
     }
@@ -341,32 +291,6 @@ public class MachinePaymentNoticeAdapt extends DatabusAdaptImpl {
      * @param payFeeDetailPo
      */
     private void sendMsg(JSONObject paramIn, CommunityDto communityDto, PayFeeDetailPo payFeeDetailPo) {
-        //查询公众号配置
-        SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
-        smallWeChatDto.setWeChatType("1100");
-        smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
-        smallWeChatDto.setObjId(communityDto.getCommunityId());
-        List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
-        if (smallWeChatDto == null || smallWeChatDtos.size() <= 0) {
-            logger.info("未配置微信公众号信息,定时任务执行结束");
-            return;
-        }
-        SmallWeChatDto weChatDto = smallWeChatDtos.get(0);
-        SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
-        smallWechatAttrDto.setCommunityId(communityDto.getCommunityId());
-        smallWechatAttrDto.setWechatId(weChatDto.getWeChatId());
-        smallWechatAttrDto.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_SUCCESS_TEMPLATE);
-        List<SmallWechatAttrDto> smallWechatAttrDtos = smallWechatAttrInnerServiceSMOImpl.querySmallWechatAttrs(smallWechatAttrDto);
-        if (smallWechatAttrDtos == null || smallWechatAttrDtos.size() <= 0) {
-            logger.info("未配置微信公众号消息模板");
-            return;
-        }
-        String templateId = smallWechatAttrDtos.get(0).getValue();
-        String accessToken = WechatFactory.getAccessToken(weChatDto.getAppId(), weChatDto.getAppSecret());
-        if (StringUtil.isEmpty(accessToken)) {
-            logger.info("推送微信模板,获取accessToken失败:{}", accessToken);
-            return;
-        }
         FeeDto feeDto = new FeeDto();
         feeDto.setFeeId(payFeeDetailPo.getFeeId());
         feeDto.setCommunityId(payFeeDetailPo.getCommunityId());
@@ -374,36 +298,16 @@ public class MachinePaymentNoticeAdapt extends DatabusAdaptImpl {
         Assert.listOnlyOne(feeDtos, "费用不存在");
         //获取创建用户,即处理结单的维修维修师傅
         String userId = feeDtos.get(0).getUserId();
-        String sendTemplate = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.SEND_TEMPLATE_URL);
-        if (StringUtil.isEmpty(sendTemplate)) {
-            sendTemplate = sendMsgUrl;
-        }
-        String url = sendTemplate + accessToken;
         //根据 userId 查询到openId
         try {
-            StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
-            staffAppAuthDto.setStaffId(userId);
-            staffAppAuthDto.setAppType("WECHAT");
-            List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto);
-            Assert.listOnlyOne(staffAppAuthDtos, "员工未认证");
-            String openId = staffAppAuthDtos.get(0).getOpenId();
-            Data data = new Data();
-            PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
-            templateMessage.setTemplate_id(templateId);
-            templateMessage.setTouser(openId);
-            data.setFirst(new Content("业主已缴纳维修费,信息如下:"));
-            data.setKeyword1(new Content(paramIn.getString("payFeeRoom")));
-            data.setKeyword2(new Content(paramIn.getString("feeTypeCdName")));
-            data.setKeyword3(new Content(paramIn.getString("payFeeTime")));
-            data.setKeyword4(new Content(paramIn.getString("receivedAmount") + "元"));
-            data.setRemark(new Content("请与客服管家核实费用"));
-            templateMessage.setData(data);
-            //获取员工公众号地址
-            String wechatUrl = MappingCache.getValue(MappingConstant.URL_DOMAIN, "STAFF_WECHAT_URL");
-            templateMessage.setUrl(wechatUrl);
-            logger.info("发送模板消息内容:{}", JSON.toJSONString(templateMessage));
-            ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
-            logger.info("微信模板返回内容:{}", responseEntity);
+            JSONObject content = new JSONObject();
+            content.put("payFeeRoom", paramIn.getString("payFeeRoom"));
+            content.put("feeTypeCdName", paramIn.getString("feeTypeCdName"));
+            content.put("payFeeTime", paramIn.getString("payFeeTime"));
+            content.put("receivedAmount", paramIn.getString("receivedAmount") + "元");
+            content.put("url", paramIn.getString("wechatUrl"));
+            MsgNotifyFactory.sendPayFeeMsg(payFeeDetailPo.getCommunityId(), userId, content, MsgNotifyFactory.ROLE_STAFF);
+
         } catch (Exception e) {
             logger.error("发送缴费信息失败", e);
         }
@@ -427,22 +331,8 @@ public class MachinePaymentNoticeAdapt extends DatabusAdaptImpl {
             logger.info("未配置微信公众号信息,定时任务执行结束");
             return;
         }
-        SmallWeChatDto weChatDto = smallWeChatDtos.get(0);
-        SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
-        smallWechatAttrDto.setCommunityId(communityDto.getCommunityId());
-        smallWechatAttrDto.setWechatId(weChatDto.getWeChatId());
-        smallWechatAttrDto.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_SUCCESS_TEMPLATE);
-        List<SmallWechatAttrDto> smallWechatAttrDtos = smallWechatAttrInnerServiceSMOImpl.querySmallWechatAttrs(smallWechatAttrDto);
-        if (smallWechatAttrDtos == null || smallWechatAttrDtos.size() <= 0) {
-            logger.info("未配置微信公众号消息模板");
-            return;
-        }
-        String templateId = smallWechatAttrDtos.get(0).getValue();
-        String accessToken = WechatFactory.getAccessToken(weChatDto.getAppId(), weChatDto.getAppSecret());
-        if (StringUtil.isEmpty(accessToken)) {
-            logger.info("推送微信模板,获取accessToken失败:{}", accessToken);
-            return;
-        }
+
+
         FeeDto feeDto = new FeeDto();
         feeDto.setFeeId(payFeeDetailPo.getFeeId());
         feeDto.setCommunityId(payFeeDetailPo.getCommunityId());
@@ -486,94 +376,37 @@ public class MachinePaymentNoticeAdapt extends DatabusAdaptImpl {
         ownerAppUserDto.setMemberId(memberId);
         ownerAppUserDto.setAppType("WECHAT");
         List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMO.queryOwnerAppUsers(ownerAppUserDto);
-        if (ownerAppUserDtos.size() > 0) {
-            //获取openId
-            String openId = ownerAppUserDtos.get(0).getOpenId();
-            String url = sendMsgUrl + accessToken;
-            Data data = new Data();
-            PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
-            templateMessage.setTemplate_id(templateId);
-            templateMessage.setTouser(openId);
-            if (!StringUtil.isEmpty(paramIn.getString("state")) && paramIn.getString("state").equals("1300")) {
-                data.setFirst(new Content("本次退费已到账"));
-            } else {
-                data.setFirst(new Content("本次缴费已到账"));
-            }
-            if (payerObjType.equals("3333")) {  //房屋
-                data.setKeyword1(new Content(paramIn.getString("payFeeRoom")));
-                data.setKeyword2(new Content(paramIn.getString("feeTypeCdName")));
-            } else {  //车辆
-                data.setKeyword1(new Content(communityDto.getName() + "-" + paramIn.getString("num") + "-" + paramIn.getString("spaceNum")));
-                data.setKeyword2(new Content(paramIn.getString("feeTypeCdName") + "-" + paramIn.getString("carNum")));
-            }
-            data.setKeyword3(new Content(paramIn.getString("payFeeTime")));
-            if (!StringUtil.isEmpty(paramIn.getString("state")) && paramIn.getString("state").equals("1300")) {
-                //获取退费金额
-                double receivedAmount = Double.parseDouble(paramIn.getString("receivedAmount"));
-                double money = receivedAmount * (-1.00);
-                data.setKeyword4(new Content("退费" + money + "元"));
-            } else {
-                data.setKeyword4(new Content(paramIn.getString("receivedAmount") + "元"));
-            }
-            data.setRemark(new Content("感谢您的使用,如有疑问请联系相关物业人员"));
-            templateMessage.setData(data);
-            //获取业主公众号地址
-            String wechatUrl = UrlCache.getOwnerUrl();
-            if (!StringUtil.isEmpty(wechatUrl) && wechatUrl.contains("?")) {
-                wechatUrl += ("&wAppId=" + smallWeChatDtos.get(0).getAppId());
-            } else {
-                wechatUrl += ("?wAppId=" + smallWeChatDtos.get(0).getAppId());
-            }
-            templateMessage.setUrl(wechatUrl);
-            logger.info("发送模板消息内容:{}", JSON.toJSONString(templateMessage));
-            ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
-            logger.info("微信模板返回内容:{}", responseEntity);
+        if (ownerAppUserDtos == null || ownerAppUserDtos.size() < 1) {
+            return;
+        }
+        JSONObject content = new JSONObject();
+        if (payerObjType.equals(FeeDto.PAYER_OBJ_TYPE_ROOM)) {  //房屋
+            content.put("payFeeRoom", paramIn.getString("payFeeRoom"));
+            content.put("feeTypeCdName", paramIn.getString("feeTypeCdName"));
+        } else {  //车辆
+            content.put("payFeeRoom", communityDto.getName() + "-" + paramIn.getString("num") + "-" + paramIn.getString("spaceNum"));
+            content.put("feeTypeCdName", paramIn.getString("feeTypeCdName") + "-" + paramIn.getString("carNum"));
+        }
+        content.put("payFeeTime", paramIn.getString("payFeeTime"));
+
+        //todo 退费
+        if (FeeDetailDto.STATE_RETURN_ORDER.equals(paramIn.getString("state"))) {
+            //获取退费金额
+            double receivedAmount = Double.parseDouble(paramIn.getString("receivedAmount"));
+            double money = receivedAmount * (-1.00);
+            content.put("receivedAmount", money + "元");
         } else {
-            //获取业主手机号
-            String tel = ownerDtos.get(0).getLink();
-            //获取业主姓名
-            String name = ownerDtos.get(0).getName();
-            //获取费用类型
-            String feeTypeCdName = paramIn.getString("feeTypeCdName");
-            //获取费用开始时间
-            String startTime = paramIn.getString("startTime");
-            //获取费用结束时间
-            String endTime = paramIn.getString("endTime");
-            //获取缴费金额
-            String receivedAmount = paramIn.getString("receivedAmount");
-            //获取房屋号
-            String payFeeRoom = paramIn.getString("payFeeRoom");
-            DefaultProfile profile = DefaultProfile.getProfile(MappingCache.getValue(ALI_SMS_DOMAIN, "region"),
-                    MappingCache.getValue(ALI_SMS_DOMAIN, "accessKeyId"),
-                    MappingCache.getValue(ALI_SMS_DOMAIN, "accessSecret"));
-            IAcsClient client = new DefaultAcsClient(profile);
-
-            CommonRequest request = new CommonRequest();
-            request.setSysMethod(MethodType.POST);
-            request.setSysDomain("dysmsapi.aliyuncs.com");
-            request.setSysVersion("2017-05-25");
-            request.setSysAction("SendSms");
-            request.putQueryParameter("RegionId", MappingCache.getValue(ALI_SMS_DOMAIN, "region"));
-            request.putQueryParameter("PhoneNumbers", tel);
-            request.putQueryParameter("SignName", MappingCache.getValue(ALI_SMS_DOMAIN, "signName"));
-            //获取模板编码(SMS_207160078为缴费成功提示模板编码)
-            String payFeeCode = MappingCache.getValue(ALI_SMS_DOMAIN, "PayFeeCode");
-            String substring = "";
-            if (!StringUtil.isEmpty(payFeeCode)) {
-                substring = payFeeCode.substring(0, 4);
-            }
-            if (substring.equals("SMS_")) {
-                request.putQueryParameter("TemplateCode", payFeeCode);
-            }
-            request.putQueryParameter("TemplateParam", "{\"user\":" + "\"" + name + "\"" + "," + "\"house\":" + "\"" + payFeeRoom + "\"" + "," + "\"feeType\":" + "\"" + feeTypeCdName + "\"" + "," + "\"startTime\":" + "\"" + startTime + "\"" + "," + "\"endTime\":" + "\"" + endTime + "\"" + "," + "\"mount\":" + "\"" + receivedAmount + "\"" + "}");
-            try {
-                CommonResponse response = client.getCommonResponse(request);
-                logger.debug("发送短信:{}", response.getData());
-            } catch (ServerException e) {
-                e.printStackTrace();
-            } catch (ClientException e) {
-                e.printStackTrace();
-            }
+            content.put("receivedAmount", paramIn.getString("receivedAmount") + "元");
         }
+        //获取业主公众号地址
+        String wechatUrl = UrlCache.getOwnerUrl();
+        if (!StringUtil.isEmpty(wechatUrl) && wechatUrl.contains("?")) {
+            wechatUrl += ("&wAppId=" + smallWeChatDtos.get(0).getAppId());
+        } else {
+            wechatUrl += ("?wAppId=" + smallWeChatDtos.get(0).getAppId());
+        }
+        content.put("url", wechatUrl);
+        MsgNotifyFactory.sendPayFeeMsg(payFeeDetailPo.getCommunityId(), ownerAppUserDtos.get(0).getUserId(), content, MsgNotifyFactory.ROLE_OWNER);
+
     }
 }

+ 0 - 59
service-job/src/main/java/com/java110/job/databus/TimeoutTest.java

@@ -1,59 +0,0 @@
-package com.java110.job.databus;
-
-import java.util.Random;
-import java.util.concurrent.*;
-
-public class TimeoutTest {
-    private static ExecutorService executorService = Executors.newSingleThreadExecutor();
-
-    /*** @param args*/
-    public static void main(String[] args) {
-// TODO Auto-generated method stub
-        long start = System.currentTimeMillis();
-        String result = timeoutMethod(5000);
-        System.out.println("方法实际耗时:" + (System.currentTimeMillis() - start) + "毫秒");
-        System.out.println("结果:" + result);
-        try {
-            Thread.sleep(8000);
-            long start1 = System.currentTimeMillis();
-            String result1 = timeoutMethod(5000);
-            System.out.println("方法实际耗时:" + (System.currentTimeMillis() - start1) + "毫秒");
-            System.out.println("结果:" + result1);
-            executorService.shutdown();
-        } catch (
-                Exception e) {// TODO: handle exception
-        }
-    }
-
-    // /*** 有超时时间的方法* @param timeout* @return*/
-    private static String timeoutMethod(int timeout) {
-        String result = "默认";
-        FutureTask<String> futureTask = new FutureTask<>(new Callable<String>() {
-            @Override
-            public String call() throws Exception {
-                return unknowMethod();
-            }
-        });
-        executorService.execute(futureTask);
-        try {
-            result = futureTask.get(timeout, TimeUnit.MILLISECONDS);
-        } catch (InterruptedException | ExecutionException |
-                 TimeoutException e) {//e.printStackTrace();
-            futureTask.cancel(true);
-            result = "默认";
-        }
-        return result;
-    }
-
-    /*** 这个方法的耗时不确定* @return*/
-    private static String unknowMethod() {
-        Random random = new Random();
-        int time = 10000;
-        System.out.println("任务将耗时: " + time + "毫秒");
-        try {
-            Thread.sleep(time);
-        } catch (Exception e) {// TODO: handle exception
-        }
-        return "获得方法执行后的返回值";
-    }
-}

+ 50 - 0
service-job/src/main/java/com/java110/job/msgNotify/IMsgNotify.java

@@ -0,0 +1,50 @@
+package com.java110.job.msgNotify;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.vo.ResultVo;
+
+/**
+ * 消息通知 接口类
+ */
+public interface IMsgNotify {
+
+    /**
+     * 发送退费申请 消息
+     *
+     * @param userId
+     * @param content
+     * @return
+     */
+    ResultVo sendApplyReturnFeeMsg(String communityId, String userId, JSONObject content);
+
+    /**
+     * 发送欠费 账单信息
+     *
+     * @param communityId 小区
+     * @param userId 用户
+     * @param content {
+     *                    "feeTypeName",
+     *                     "payerObjName",
+     *                     "billAmountOwed",
+     *                     "date",
+     *                url
+     * }
+     * @return
+     */
+    ResultVo sendOweFeeMsg(String communityId, String userId, JSONObject content);
+
+    /**
+     * 发送缴费成功提醒
+     *
+     * @param communityId 小区
+     * @param userId 用户
+     * @param content {
+     *                    "payFeeRoom",
+     *                     "feeTypeCdName",
+     *                     "payFeeTime",
+     *                     "receivedAmount",
+     *                url
+     * }
+     */
+    ResultVo sendPayFeeMsg(String communityId, String userId, JSONObject content,String role);
+}

+ 25 - 0
service-job/src/main/java/com/java110/job/msgNotify/IWechatTemplate.java

@@ -0,0 +1,25 @@
+package com.java110.job.msgNotify;
+
+/**
+ * 微信模板处理类
+ */
+public interface IWechatTemplate {
+
+
+    /**
+     * 获取模板ID
+     * @param communityId 小区ID
+     * @param templateIdShort  模板库中模板的编号
+     * @param title 模板标题
+     * @return
+     */
+    String getTemplateId(String communityId, String templateIdShort,String title,String[] keys);
+
+    /**
+     * 获取 accessToken
+     *
+     * @param communityId
+     * @return
+     */
+    String getAccessToken(String communityId);
+}

+ 114 - 0
service-job/src/main/java/com/java110/job/msgNotify/MsgNotifyFactory.java

@@ -0,0 +1,114 @@
+package com.java110.job.msgNotify;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.MappingConstant;
+import com.java110.utils.factory.ApplicationContextFactory;
+import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
+
+/**
+ * 消息通知工具类
+ */
+public class MsgNotifyFactory {
+
+    public static final String DEFAULT_MSG_NOTIFY_WAY = "DEFAULT_MSG_NOTIFY_WAY";
+
+    public static final String NOTIFY_WAY_WECHAT = "WECHAT";
+    public static final String NOTIFY_WAY_ALI = "ALI";
+    public static final String NOTIFY_WAY_TENCENT = "TENCENT";
+    public static final String ROLE_OWNER = "OWNER"; // 业主
+    public static final String ROLE_STAFF = "STAFF"; // 员工
+
+
+    /**
+     * 发送退费申请 消息
+     *
+     * @param userId
+     * @param content {
+     *                detailId:'',
+     *                name:''
+     *                }
+     * @return
+     */
+    public static ResultVo sendApplyReturnFeeMsg(String communityId, String userId, JSONObject content) {
+        IMsgNotify msgNotify = getMsgNotify();
+        return msgNotify.sendApplyReturnFeeMsg(communityId, userId, content);
+    }
+
+    /**
+     * 发送欠费 账单信息
+     *
+     * @param communityId 小区
+     * @param userId      用户
+     * @param content     {
+     *                    "feeTypeName",
+     *                    "payerObjName",
+     *                    "billAmountOwed",
+     *                    "date",
+     *                    url
+     *                    }
+     */
+    public static ResultVo sendOweFeeMsg(String communityId, String userId, JSONObject content) {
+        IMsgNotify msgNotify = getMsgNotify();
+        return msgNotify.sendOweFeeMsg(communityId, userId, content);
+    }
+
+    /**
+     * 发送缴费成功提醒
+     *
+     * @param communityId 小区
+     * @param userId      用户
+     * @param content     {
+     *                    "payFeeRoom",
+     *                    "feeTypeCdName",
+     *                    "payFeeTime",
+     *                    "receivedAmount",
+     *                    url
+     *                    }
+     */
+    public static ResultVo sendPayFeeMsg(String communityId, String userId, JSONObject content, String role) {
+        IMsgNotify msgNotify = getMsgNotify();
+        return msgNotify.sendPayFeeMsg(communityId, userId, content, role);
+    }
+
+    /**
+     * 获取通知适配器
+     *
+     * @return
+     */
+    private static IMsgNotify getMsgNotify() {
+        return getMsgNotify(null);
+    }
+
+    /**
+     * 获取通知适配器
+     *
+     * @param notifyWay
+     * @return
+     */
+    private static IMsgNotify getMsgNotify(String notifyWay) {
+        IMsgNotify notify = null;
+        if (StringUtil.isEmpty(notifyWay)) {
+            notifyWay = MappingCache.getValue(MappingConstant.ENV_DOMAIN, DEFAULT_MSG_NOTIFY_WAY);
+        }
+
+        if (StringUtil.isEmpty(notifyWay)) {
+            notifyWay = NOTIFY_WAY_WECHAT;
+        }
+
+        switch (notifyWay) {
+            case NOTIFY_WAY_TENCENT:
+                notify = ApplicationContextFactory.getBean("tencentMsgNotifyImpl", IMsgNotify.class);
+                break;
+            case NOTIFY_WAY_WECHAT:
+                notify = ApplicationContextFactory.getBean("wechatMsgNotifyImpl", IMsgNotify.class);
+                break;
+            case NOTIFY_WAY_ALI:
+                notify = ApplicationContextFactory.getBean("aliMsgNotifyImpl", IMsgNotify.class);
+                break;
+        }
+
+        return notify;
+    }
+}

+ 254 - 0
service-job/src/main/java/com/java110/job/msgNotify/WechatTemplateImpl.java

@@ -0,0 +1,254 @@
+package com.java110.job.msgNotify;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.factory.WechatFactory;
+import com.java110.core.log.LoggerFactory;
+import com.java110.dto.wechat.SmallWeChatDto;
+import com.java110.intf.store.ISmallWeChatInnerServiceSMO;
+import com.java110.utils.cache.CommonCache;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.MappingConstant;
+import com.java110.utils.constant.WechatConstant;
+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.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class WechatTemplateImpl implements IWechatTemplate {
+
+    public static final String industry_id1 = "30"; // 房地产物业
+    public static final String industry_id2 = "2"; // IT 科技 IT软件与服务
+
+
+    private static Logger logger = LoggerFactory.getLogger(WechatTemplateImpl.class);
+
+    /**
+     * 获取 行业
+     */
+    public static final String GET_INDUSTRY = "https://api.weixin.qq.com/cgi-bin/template/get_industry?access_token=ACCESS_TOKEN";
+
+
+    /**
+     * 设置 行业
+     */
+    public static final String SET_INDUSTRY = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token=ACCESS_TOKEN";
+
+
+    /**
+     * 获取模板列表
+     */
+    public static final String GET_ALL_PRIVATE_TEMPLATE = "https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token=ACCESS_TOKEN";
+
+
+    /**
+     * 添加模板
+     */
+    public static final String ADD_TEMPLATE = "https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=ACCESS_TOKEN";
+
+
+    public static final String WECHAT_TEMPLATE = "WECHAT_TEMPLATE_";
+
+
+    @Autowired
+    private ISmallWeChatInnerServiceSMO smallWeChatInnerServiceSMOImpl;
+
+    @Autowired
+    private RestTemplate outRestTemplate;
+
+    /**
+     * 设置行业为 物业
+     *
+     * @param communityId 小区ID
+     */
+    private void setIndustry(String communityId) {
+
+        //todo 查询公众号设置的行业
+        String url = GET_INDUSTRY.replace("ACCESS_TOKEN", getAccessToken(communityId));
+
+        ResponseEntity<String> responseEntity = outRestTemplate.getForEntity(url, String.class);
+
+        logger.debug("查询行业返回参数:{}", responseEntity);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            throw new IllegalArgumentException("获取公众号行业失败");
+        }
+
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+
+        String industryName = paramOut.getJSONObject("primary_industry").getString("second_class");
+
+        if ("物业".equals(industryName)) { //如果是物业 直接 返回 无需设置
+            return;
+        }
+
+        //todo 设置公众号设置的行业
+        url = SET_INDUSTRY.replace("ACCESS_TOKEN", getAccessToken(communityId));
+
+        JSONObject paramIn = new JSONObject();
+        paramIn.put("industry_id1", industry_id1);
+        paramIn.put("industry_id2", industry_id2);
+
+        responseEntity = outRestTemplate.postForEntity(url, paramIn.toJSONString(), String.class);
+
+        logger.debug("设置行业返回参数:{}", responseEntity);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            throw new IllegalArgumentException("设置公众号行业失败");
+        }
+
+    }
+
+    /**
+     * 获取模板列表
+     *
+     * @param communityId
+     * @return
+     */
+    private String getAllPrivateTemplate(String communityId) {
+        String url = GET_ALL_PRIVATE_TEMPLATE.replace("ACCESS_TOKEN", getAccessToken(communityId));
+
+        ResponseEntity<String> responseEntity = outRestTemplate.getForEntity(url, String.class);
+
+        logger.debug("查询行业返回参数:{}", responseEntity);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            throw new IllegalArgumentException("获取模板列表失败");
+        }
+
+        String templateList = responseEntity.getBody();
+        CommonCache.setValue(WECHAT_TEMPLATE + communityId, templateList, CommonCache.TOKEN_EXPIRE_TIME);
+        return templateList;
+    }
+
+    /**
+     * 添加模板
+     *
+     * @param communityId
+     * @param templateIdShort
+     * @param keys
+     */
+    private void addTemplate(String communityId, String templateIdShort, String[] keys) {
+
+        //todo 设置行业
+        setIndustry(communityId);
+
+        //todo 设置公众号设置的行业
+        String url = ADD_TEMPLATE.replace("ACCESS_TOKEN", getAccessToken(communityId));
+
+        JSONObject paramIn = new JSONObject();
+        paramIn.put("template_id_short", templateIdShort);
+        paramIn.put("keyword_name_list", keys);
+
+        ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, paramIn.toJSONString(), String.class);
+
+        logger.debug("添加模板返回参数:{}", responseEntity);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            throw new IllegalArgumentException("添加模板失败");
+        }
+
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+
+        if (paramOut.getIntValue("errcode") != 0) {
+            throw new IllegalArgumentException(paramOut.getString("errmsg"));
+        }
+
+    }
+
+    private void deletePrivateTemplate(String communityId, String templateId) {
+
+    }
+
+    /**
+     * 获取模板ID
+     *
+     * @param communityId     小区ID
+     * @param templateIdShort 模板库中模板的编号
+     * @param title           模板标题
+     * @return
+     */
+    @Override
+    public String getTemplateId(String communityId, String templateIdShort, String title, String[] keys) {
+
+        String templateList = CommonCache.getValue(WECHAT_TEMPLATE + communityId);
+        //todo 不存在 调用微信查询
+        if (StringUtil.isEmpty(templateList)) {
+            templateList = getAllPrivateTemplate(communityId);
+        }
+
+        //todo 如果还是空 则直接 添加
+        if (StringUtil.isEmpty(templateList)) {
+            addTemplate(communityId, templateIdShort, keys);
+            templateList = getAllPrivateTemplate(communityId);
+        }
+
+        //todo 循环校验
+        JSONObject templateListObj = JSONObject.parseObject(templateList);
+        if (templateListObj == null || !templateListObj.containsKey("template_list") || templateListObj.getJSONArray("template_list").size() < 1) {
+            addTemplate(communityId, templateIdShort, keys);
+            templateList = getAllPrivateTemplate(communityId);
+            templateListObj = JSONObject.parseObject(templateList);
+        }
+
+        //todo 寻找 templateId
+        JSONArray templateLists = templateListObj.getJSONArray("template_list");
+        JSONObject template = null;
+        for (int templateIndex = 0; templateIndex < templateLists.size(); templateIndex++) {
+            template = templateLists.getJSONObject(templateIndex);
+            if (title.equals(template.getString("title"))) {
+                return template.getString("template_id");
+            }
+        }
+
+        //todo 说明没有寻找到
+        addTemplate(communityId, templateIdShort, keys);
+        templateList = getAllPrivateTemplate(communityId);
+        templateListObj = JSONObject.parseObject(templateList);
+
+        templateLists = templateListObj.getJSONArray("template_list");
+        for (int templateIndex = 0; templateIndex < templateLists.size(); templateIndex++) {
+            template = templateLists.getJSONObject(templateIndex);
+            if (title.equals(template.getString("title"))) {
+                return template.getString("template_id");
+            }
+        }
+
+
+        return "-1";
+    }
+
+    public String getAccessToken(String communityId) {
+        SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
+        smallWeChatDto.setWeChatType(SmallWeChatDto.WECHAT_TYPE_PUBLIC);
+        smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
+        smallWeChatDto.setObjId(communityId);
+        List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
+
+        if (smallWeChatDtos == null || smallWeChatDtos.size() < 1) {
+            String appIdCache = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "appId");
+            String appSecretCache = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "appSecret");
+            String mchIdCache = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "mchId");
+            String keyCache = MappingCache.getValue(MappingConstant.WECHAT_STORE_DOMAIN, "key");
+            smallWeChatDto = new SmallWeChatDto();
+            smallWeChatDto.setAppId(appIdCache);
+            smallWeChatDto.setAppSecret(appSecretCache);
+            smallWeChatDto.setMchId(mchIdCache);
+            smallWeChatDto.setPayPassword(keyCache);
+        } else {
+            smallWeChatDto = smallWeChatDtos.get(0);
+        }
+
+        String accessToken = WechatFactory.getAccessToken(smallWeChatDto.getAppId(), smallWeChatDto.getAppSecret());
+
+        return accessToken;
+    }
+}

+ 24 - 0
service-job/src/main/java/com/java110/job/msgNotify/ali/AliMsgNotifyImpl.java

@@ -0,0 +1,24 @@
+package com.java110.job.msgNotify.ali;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.job.msgNotify.IMsgNotify;
+import com.java110.vo.ResultVo;
+import org.springframework.stereotype.Service;
+
+@Service("aliMsgNotifyImpl")
+public class AliMsgNotifyImpl implements IMsgNotify {
+    @Override
+    public ResultVo sendApplyReturnFeeMsg(String communityId,String userId, JSONObject content) {
+        return null;
+    }
+
+    @Override
+    public ResultVo sendOweFeeMsg(String communityId, String userId, JSONObject content) {
+        return null;
+    }
+
+    @Override
+    public ResultVo sendPayFeeMsg(String communityId, String userId, JSONObject content,String role) {
+        return null;
+    }
+}

+ 24 - 0
service-job/src/main/java/com/java110/job/msgNotify/tencent/TencentMsgNotifyImpl.java

@@ -0,0 +1,24 @@
+package com.java110.job.msgNotify.tencent;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.job.msgNotify.IMsgNotify;
+import com.java110.vo.ResultVo;
+import org.springframework.stereotype.Service;
+
+@Service("tencentMsgNotifyImpl")
+public class TencentMsgNotifyImpl implements IMsgNotify {
+    @Override
+    public ResultVo sendApplyReturnFeeMsg(String communityId,String userId, JSONObject content) {
+        return null;
+    }
+
+    @Override
+    public ResultVo sendOweFeeMsg(String communityId, String userId, JSONObject content) {
+        return null;
+    }
+
+    @Override
+    public ResultVo sendPayFeeMsg(String communityId, String userId, JSONObject content,String role) {
+        return null;
+    }
+}

+ 233 - 0
service-job/src/main/java/com/java110/job/msgNotify/wechat/WechatMsgNotifyImpl.java

@@ -0,0 +1,233 @@
+package com.java110.job.msgNotify.wechat;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+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.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.IStaffAppAuthInnerServiceSMO;
+import com.java110.job.msgNotify.IMsgNotify;
+import com.java110.job.msgNotify.IWechatTemplate;
+import com.java110.job.msgNotify.MsgNotifyFactory;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.MappingConstant;
+import com.java110.utils.util.DateUtil;
+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;
+import java.util.Map;
+
+@Service("wechatMsgNotifyImpl")
+public class WechatMsgNotifyImpl implements IMsgNotify {
+    private static final Logger logger = LoggerFactory.getLogger(WechatMsgNotifyImpl.class);
+
+    private static final String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
+
+    public static final String SPEC_CD_TOKEN = "33001";//token
+    public static final String SPEC_CD_OWE_FEE_TEMPLATE = "33002";//欠费推送模板
+    public static final String SPEC_CD_WECHAT_TEMPLATE = "33003";//欠费推送模板、装修跟踪记录通知
+    public static final String SPEC_CD_WECHAT_SUCCESS_TEMPLATE = "33004";//业主缴费成功推送模板
+    public static final String SPEC_CD_WECHAT_EXPIRE_TEMPLATE = "33005";//业主费用到期通知推送模板
+    public static final String SPEC_CD_WECHAT_PROCESS_TEMPLATE = "33006";//办公系统审批通知
+    public static final String SPEC_CD_WECHAT_ROOM_STATE_TEMPLATE = "33007";//空置房验房状态(通过和不通过)、审批状态(通过和不通过)模板
+    public static final String SPEC_CD_WECHAT_WORK_ORDER_REMIND_TEMPLATE = "33008";//报修工单提醒模板
+    public static final String SPEC_CD_WECHAT_DISPATCH_REMIND_TEMPLATE = "33009";//报修工单派单和转单提醒给维修师傅
+    public static final String SPEC_CD_WECHAT_SCHEDULE_TEMPLATE = "33010";//报修工单派单和抢单提醒给业主,安排师傅维修(进度提醒)
+    public static final String SPEC_CD_WECHAT_WORK_ORDER_END_TEMPLATE = "33011";//报修工单维修完成提醒给业主
+    public static final String SPEC_CD_WECHAT_HOUSE_DECORATION_APPLY_TEMPLATE = "33012";//装修申请提醒给业主
+    public static final String SPEC_CD_WECHAT_HOUSE_DECORATION_CHECK_TEMPLATE = "33013";//装修审核/完成提醒给物业管理人员
+    public static final String SPEC_CD_WECHAT_HOUSE_DECORATION_CHECK_RESULT_TEMPLATE = "33014";//装修审核结果提醒给业主
+    public static final String SPEC_CD_WECHAT_HOUSE_DECORATION_COMPLETED_TEMPLATE = "33015";//装修验收结果提醒给业主
+    public static final String SPEC_CD_WECHAT_REPAIR_CHARGE_SCENE_TEMPLATE = "33016";//报修通知-上门维修现场收费通知业主
+    public static final String SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_TEMPLATE = "33017";//流程待审批通知
+    public static final String SPEC_CD_WECHAT_OA_WORKFLOW_AUDIT_FINISH_TEMPLATE = "33018";//流程待审批完成通知
+
+    private static final Map<String, String[]> templateKeys = new HashMap<>();
+
+    static {
+        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[]{"缴费房间", "费用类型", "缴费时间", "缴费金额"});
+
+
+    }
+
+    @Autowired
+    private IWechatTemplate wechatTemplateImpl;
+
+    @Autowired
+    private IStaffAppAuthInnerServiceSMO staffAppAuthInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMOImpl;
+
+    @Autowired
+    private RestTemplate outRestTemplate;
+
+    /**
+     * 发送退费申请
+     *
+     * @param communityId
+     * @param userId
+     * @param content
+     * @return
+     */
+    @Override
+    public ResultVo sendApplyReturnFeeMsg(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("员工未认证,没有获取到微信openId");
+        }
+        String openId = staffAppAuthDtos.get(0).getOpenId();
+        Mapping mapping = MappingCache.getMapping(MappingConstant.WECHAT_DOMAIN, SPEC_CD_WECHAT_PROCESS_TEMPLATE);
+
+        if (mapping == null) {
+            throw new IllegalArgumentException("开发者账户编码映射未配置域为=" + MappingConstant.WECHAT_DOMAIN + ",键为=" + SPEC_CD_WECHAT_PROCESS_TEMPLATE);
+        }
+        String templateId = wechatTemplateImpl.getTemplateId(communityId, mapping.getValue(), mapping.getName(), templateKeys.get(SPEC_CD_WECHAT_PROCESS_TEMPLATE));
+
+        String url = sendMsgUrl + accessToken;
+
+        Data data = new Data();
+        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")));
+        templateMessage.setData(data);
+        //获取员工公众号地址
+        String wechatUrl = MappingCache.getValue(MappingConstant.URL_DOMAIN, "STAFF_WECHAT_URL");
+        templateMessage.setUrl(wechatUrl);
+        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 {
+     *                    "feeTypeName",
+     *                     "payerObjName",
+     *                     "billAmountOwed",
+     *                     "date",
+     *                url
+     * }
+     * @return
+     */
+    @Override
+    public ResultVo sendOweFeeMsg(String communityId, String userId, JSONObject content) {
+
+        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.size() < 1) {
+            throw new IllegalArgumentException("业主未绑定,没有获取到微信openId");
+        }
+
+        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();
+        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")));
+        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"));
+    }
+
+    @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("业主未绑定,没有获取到微信openId");
+            }
+            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("员工未认证,没有获取到微信openId");
+            }
+            openId = staffAppAuthDtos.get(0).getOpenId();
+        }
+        Data data = new Data();
+        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")));
+        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"));
+
+
+    }
+}

+ 0 - 1
service-job/src/main/java/com/java110/job/task/fee/GenerateOweFeeTemplate.java

@@ -99,7 +99,6 @@ public class GenerateOweFeeTemplate extends TaskSystemQuartz {
 
 
         //删除无用数据
-
         feeDataFiltering(communityDto.getCommunityId());
 
         //查询费用项

+ 27 - 82
service-job/src/main/java/com/java110/job/task/wechat/PublicWeChatPushMessageTemplate.java

@@ -1,6 +1,7 @@
 package com.java110.job.task.wechat;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.java110.core.factory.WechatFactory;
 import com.java110.core.log.LoggerFactory;
 import com.java110.dto.community.CommunityDto;
@@ -18,6 +19,7 @@ import com.java110.intf.fee.IFeeInnerServiceSMO;
 import com.java110.intf.store.ISmallWeChatInnerServiceSMO;
 import com.java110.intf.store.ISmallWechatAttrInnerServiceSMO;
 import com.java110.intf.user.IOwnerAppUserInnerServiceSMO;
+import com.java110.job.msgNotify.MsgNotifyFactory;
 import com.java110.job.quartz.TaskSystemQuartz;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.cache.UrlCache;
@@ -87,48 +89,10 @@ public class PublicWeChatPushMessageTemplate extends TaskSystemQuartz {
 
     private void publishMsg(TaskDto taskDto, CommunityDto communityDto) throws Exception {
 
-//
-//        String templateId = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.KEY_PROPERTY_FEE_TEMPLATE_ID);
-//
-//        templateId = StringUtil.isEmpty(templateId) ? DEFAULT_TEMPLATE_ID : templateId;
-
-        //查询公众号配置
-        SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
-        smallWeChatDto.setWeChatType("1100");
-        smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
-        smallWeChatDto.setObjId(communityDto.getCommunityId());
-        List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
-
-        if (smallWeChatDto == null || smallWeChatDtos.size() <= 0) {
-            logger.error("未配置微信公众号信息,定时任务执行结束");
-            return;
-        }
-        SmallWeChatDto weChatDto = smallWeChatDtos.get(0);
-
-
-        SmallWechatAttrDto smallWechatAttrDto = new SmallWechatAttrDto();
-        smallWechatAttrDto.setCommunityId(communityDto.getCommunityId());
-        smallWechatAttrDto.setWechatId(weChatDto.getWeChatId());
-        smallWechatAttrDto.setSpecCd(SmallWechatAttrDto.SPEC_CD_OWE_FEE_TEMPLATE);
-        List<SmallWechatAttrDto> smallWechatAttrDtos = smallWechatAttrInnerServiceSMOImpl.querySmallWechatAttrs(smallWechatAttrDto);
-
-        if (smallWechatAttrDtos == null || smallWechatAttrDtos.size() <= 0) {
-            logger.error("未配置微信公众号消息模板");
-            return;
-        }
-
-        String templateId = smallWechatAttrDtos.get(0).getValue();
-
-        String accessToken = WechatFactory.getAccessToken(weChatDto.getAppId(), weChatDto.getAppSecret());
-
-        if (StringUtil.isEmpty(accessToken)) {
-            logger.error("推送微信模板,获取accessToken失败:{}", accessToken);
-            return;
-        }
 
         //根据小区id查询业主与公众号绑定信息
         OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
-        ownerAppUserDto.setCommunityId(weChatDto.getObjId());
+        ownerAppUserDto.setCommunityId(communityDto.getCommunityId());
         ownerAppUserDto.setAppType(OwnerAppUserDto.APP_TYPE_WECHAT);
         List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
 
@@ -148,7 +112,7 @@ public class PublicWeChatPushMessageTemplate extends TaskSystemQuartz {
         String[] memberIds = memberIdList.toArray(new String[memberIdList.size()]);
         //查询欠费信息
         BillOweFeeDto billOweFeeDto = new BillOweFeeDto();
-        billOweFeeDto.setCommunityId(weChatDto.getObjId());
+        billOweFeeDto.setCommunityId(communityDto.getCommunityId());
         billOweFeeDto.setOwnerIds(memberIds);
         billOweFeeDto.setState("1000");
         billOweFeeDto.setCurBill("T");
@@ -158,55 +122,36 @@ public class PublicWeChatPushMessageTemplate extends TaskSystemQuartz {
         if (StringUtil.isEmpty(sendTemplate)) {
             sendTemplate = sendMsgUrl;
         }
-        String url = sendTemplate + accessToken;
-
-        String oweRoomUrl = UrlCache.getOwnerUrl()+MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.OWE_FEE_PAGE);
-        String oweCarUrl = UrlCache.getOwnerUrl()+MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.OWE_CAR_FEE_PAGE);
-        Miniprogram miniprogram = null;
-        if (oweRoomUrl.contains("@@")) {
-            miniprogram = new Miniprogram();
-            miniprogram.setAppid(oweRoomUrl.split("@@")[0]);
-        }
-        //车辆费用
-        if (oweCarUrl.contains("@@")) {
-            miniprogram = new Miniprogram();
-            miniprogram.setAppid(oweCarUrl.split("@@")[0]);
-        }
+
+        String oweRoomUrl = UrlCache.getOwnerUrl() + MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.OWE_FEE_PAGE);
+        String oweCarUrl = UrlCache.getOwnerUrl() + MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.OWE_CAR_FEE_PAGE);
+//        Miniprogram miniprogram = null;
+//        if (oweRoomUrl.contains("@@")) {
+//            miniprogram = new Miniprogram();
+//            miniprogram.setAppid(oweRoomUrl.split("@@")[0]);
+//        }
+//        //车辆费用
+//        if (oweCarUrl.contains("@@")) {
+//            miniprogram = new Miniprogram();
+//            miniprogram.setAppid(oweCarUrl.split("@@")[0]);
+//        }
 
         String oweUrl = "";
+        JSONObject content = null;
         for (BillOweFeeDto fee : billOweFeeDtos) {
             oweUrl = FeeDto.PAYER_OBJ_TYPE_ROOM.equals(fee.getPayerObjType()) ? oweRoomUrl : oweCarUrl;
             for (OwnerAppUserDto appUserDto : ownerAppUserDtos) {
                 try {
-                    if (fee.getOwnerId().equals(appUserDto.getMemberId())) {
-                        Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(fee.getFeeEndTime());
-                        Calendar now = Calendar.getInstance();
-                        now.setTime(date);
-//                    int year = now.get(Calendar.YEAR);
-//                    int month = now.get(Calendar.MONTH);
-                        Data data = new Data();
-                        PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
-                        templateMessage.setTemplate_id(templateId);
-                        templateMessage.setTouser(appUserDto.getOpenId());
-                        /*data.setFirst(new Content("物业费缴费提醒"));*/
-                        data.setFirst(new Content(fee.getFeeTypeName() + "提醒"));
-                        data.setKeyword1(new Content(fee.getPayerObjName()));
-                        data.setKeyword2(new Content(fee.getBillAmountOwed()));
-                        data.setKeyword3(new Content(DateUtil.dateTimeToDate(fee.getFeeEndTime()) + "至" + DateUtil.dateTimeToDate(fee.getDeadlineTime())));
-                        data.setRemark(new Content("请您及时缴费,如有疑问请联系相关物业人员"));
-                        if (!StringUtil.isEmpty(oweUrl)) {
-                            if (miniprogram == null) {
-                                templateMessage.setUrl(oweUrl + fee.getPayObjId() + "&wAppId=" + weChatDto.getAppId());
-                            } else {
-                                miniprogram.setPagepath(oweUrl.split("@@")[1] + fee.getPayObjId() + "&wAppId=" + weChatDto.getAppId());
-                                templateMessage.setMiniprogram(miniprogram);
-                            }
-                        }
-                        templateMessage.setData(data);
-                        logger.info("发送模板消息内容:{}", JSON.toJSONString(templateMessage));
-                        ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
-                        logger.info("微信模板返回内容:{}", responseEntity);
+                    if (!fee.getOwnerId().equals(appUserDto.getMemberId())) {
+                        continue;
                     }
+                    content = new JSONObject();
+                    content.put("feeTypeName", fee.getFeeTypeName());
+                    content.put("payerObjName", fee.getPayerObjName());
+                    content.put("billAmountOwed", fee.getBillAmountOwed());
+                    content.put("date", DateUtil.dateTimeToDate(fee.getFeeEndTime()) + "~" + DateUtil.dateTimeToDate(fee.getDeadlineTime()));
+                    content.put("url",oweUrl);
+                    MsgNotifyFactory.sendOweFeeMsg(communityDto.getCommunityId(), appUserDto.getUserId(), content);
                 } catch (Exception e) {
                     logger.error("推送账单异常", e);
                 }