Your Name лет назад: 2
Родитель
Сommit
4eac15a831

+ 10 - 0
java110-bean/src/main/java/com/java110/dto/repair/RepairUserDto.java

@@ -108,6 +108,8 @@ public class RepairUserDto extends PageDto implements Serializable {
 
     private String payTypeName;
 
+    private String repairName;
+
     public String getContext() {
         return context;
     }
@@ -459,4 +461,12 @@ public class RepairUserDto extends PageDto implements Serializable {
     public void setPayTypeName(String payTypeName) {
         this.payTypeName = payTypeName;
     }
+
+    public String getRepairName() {
+        return repairName;
+    }
+
+    public void setRepairName(String repairName) {
+        this.repairName = repairName;
+    }
 }

+ 1 - 1
java110-db/src/main/resources/mapper/community/RepairUserServiceDaoImplMapper.xml

@@ -103,7 +103,7 @@
         t.pre_staff_id,t.pre_staff_id preStaffId,t.pre_staff_name,t.pre_staff_name preStaffName,
         t.start_time,t.start_time startTime,t.end_time,t.end_time endTime,d.name stateName,
         t.repair_event,t.repair_event repairEvent, t.pre_ru_id,t.pre_ru_id preRuId,t.create_time createTime,
-        rp.pay_type payType,d2.name payTypeName
+        rp.pay_type payType,d2.name payTypeName,rp.repair_name repairName
         from r_repair_user t
         left join r_repair_pool rp on t.repair_id = rp.repair_id and t.state in ('10009','12000')
         left join t_dict d on t.state = d.status_cd and d.table_name = 'r_repair_user' and d.table_columns = 'state'

+ 54 - 157
service-job/src/main/java/com/java110/job/adapt/Repair/MachineReturnRepairAdapt.java

@@ -25,11 +25,13 @@ import com.java110.intf.store.ISmallWeChatInnerServiceSMO;
 import com.java110.intf.store.ISmallWechatAttrInnerServiceSMO;
 import com.java110.intf.user.*;
 import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.msgNotify.MsgNotifyFactory;
 import com.java110.po.owner.RepairUserPo;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.cache.UrlCache;
 import com.java110.utils.constant.MappingConstant;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.DateUtil;
 import com.java110.utils.util.StringUtil;
 import org.slf4j.Logger;
 import com.java110.core.log.LoggerFactory;
@@ -90,7 +92,7 @@ public class MachineReturnRepairAdapt extends DatabusAdaptImpl {
     public void execute(Business business, List<Business> businesses) throws Exception {
         JSONObject data = business.getData();
         JSONArray businessRepairUsers = new JSONArray();
-        System.out.println("收到日志:>>>>>>>>>>>>>"+data.toJSONString());
+        System.out.println("收到日志:>>>>>>>>>>>>>" + data.toJSONString());
         if (data.containsKey(RepairUserPo.class.getSimpleName())) {
             Object bObj = data.get(RepairUserPo.class.getSimpleName());
 
@@ -149,7 +151,7 @@ public class MachineReturnRepairAdapt extends DatabusAdaptImpl {
         List<RepairSettingDto> repairSettingDtos = repairSettingInnerServiceSMO.queryRepairSettings(repairSettingDto);
         Assert.listOnlyOne(repairSettingDtos, "信息错误");
         JSONObject paramIn = new JSONObject();
-        if (state.equals("10003")) {   //退单状态
+        if (RepairUserDto.STATE_BACK.equals(state)) {   //退单状态
             //退单人
             String staffName = repairUserDtos.get(0).getStaffName();
             //退单备注
@@ -165,8 +167,9 @@ public class MachineReturnRepairAdapt extends DatabusAdaptImpl {
             paramIn.put("returnContext", returnContext);
             paramIn.put("preStaffId", preStaffId);
             paramIn.put("preStaffName", preStaffName);
+            paramIn.put("repairName", repairUserDtos.get(0).getRepairName());
             sendReturnMessage(paramIn, communityDtos.get(0));
-        } else if (state.equals("10002")) {     //结单
+        } else if (RepairUserDto.STATE_CLOSE.equals(state)) {     //结单
             //获取用户id
             String preStaffId = repairUserDtos.get(0).getPreStaffId();
             //获取维修师傅姓名
@@ -179,16 +182,6 @@ public class MachineReturnRepairAdapt extends DatabusAdaptImpl {
             String time = format.format(endTime);
             //获取价格
             String price = "";
-            //这里建议查询 报修所在费用的 固定费
-//            for (Business bus : businesses) {
-//                if (bus.getBusinessTypeCd().equals("600100030001")) {  //保存费用信息
-//                    JSONObject data = bus.getData();
-//                    JSONArray jsonArray = data.getJSONArray("PayFeePo");
-//                    JSONObject jsonObject = jsonArray.getJSONObject(0);
-//                    PayFeePo payFeePo = BeanConvertUtil.covertBean(jsonObject, PayFeePo.class);
-//                    price = payFeePo.getAmount();
-//                }
-//            }
             paramIn.put("repairName", repairName);
             paramIn.put("repairObjName", repairObjName);
             paramIn.put("context", context);
@@ -204,7 +197,7 @@ public class MachineReturnRepairAdapt extends DatabusAdaptImpl {
             //获取报修用户id
             String staffId = repairUserDtoList.get(0).getStaffId();
             paramIn.put("userId", staffId);
-            publishReturnMsg(paramIn, communityDtos.get(0));
+            sendFinishRepairOwnerMsg(paramIn, communityDtos.get(0));
             if (!StringUtil.isEmpty(price)) {
                 paramIn.put("price", price);
                 paramIn.put("feeState", "未缴费");
@@ -227,61 +220,20 @@ public class MachineReturnRepairAdapt extends DatabusAdaptImpl {
      * @param communityDto
      */
     private void sendReturnMessage(JSONObject paramIn, CommunityDto communityDto) {
-        //查询公众号配置
-        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_WORK_ORDER_REMIND_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;
-        }
-        String url = sendMsgUrl + accessToken;
-        //根据 userId 查询到openId
-        StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
-        staffAppAuthDto.setStaffId(paramIn.getString("preStaffId"));
-        staffAppAuthDto.setAppType("WECHAT");
-        List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto);
-        if (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(paramIn.getString("staffName") + "进行维修工单退单操作,请及时处理,信息如下:"));
-            data.setKeyword1(new Content(paramIn.getString("repairTypeName")));
-            if (communityDto.getName().equals(paramIn.getString("repairObjName"))) {
-                data.setKeyword2(new Content(paramIn.getString("repairObjName")));
-            } else {
-                data.setKeyword2(new Content(communityDto.getName() + paramIn.getString("repairObjName")));
-            }
-            data.setKeyword3(new Content(paramIn.getString("context")));
-            data.setRemark(new Content(paramIn.getString("returnContext")));
-            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("repairTypeName", paramIn.getString("repairTypeName"));
+        if (communityDto.getName().equals(paramIn.getString("repairObjName"))) {
+            content.put("repairObjName", paramIn.getString("repairObjName"));
+        } else {
+            content.put("repairObjName", communityDto.getName() + paramIn.getString("repairObjName"));
         }
+        content.put("repairName", paramIn.getString("repairName"));
+        String wechatUrl = MappingCache.getValue(MappingConstant.URL_DOMAIN, "STAFF_WECHAT_URL");
+        content.put("url", wechatUrl);
+
+        MsgNotifyFactory.sendReturnRepairMsg(communityDto.getCommunityId(), paramIn.getString("preStaffId"), content);
+
     }
 
     /**
@@ -290,7 +242,7 @@ public class MachineReturnRepairAdapt extends DatabusAdaptImpl {
      * @param paramIn
      * @param communityDto
      */
-    private void publishReturnMsg(JSONObject paramIn, CommunityDto communityDto) {
+    private void sendFinishRepairOwnerMsg(JSONObject paramIn, CommunityDto communityDto) {
         //查询公众号配置
         SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
         smallWeChatDto.setWeChatType("1100");
@@ -301,57 +253,22 @@ public class MachineReturnRepairAdapt 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_WORK_ORDER_END_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;
-        }
-        //获取用户id
-        String staffId = paramIn.getString("userId");
-        if (!StringUtil.isEmpty(staffId)) {
-            OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
-            ownerAppUserDto.setUserId(staffId);
-            ownerAppUserDto.setAppType("WECHAT");
-            //查询绑定业主
-            List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMO.queryOwnerAppUsers(ownerAppUserDto);
-            if (ownerAppUserDtos != null && 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);
-                data.setFirst(new Content("尊敬的" + paramIn.getString("repairName") + "先生/女士,您的报修问题,已经为您处理完毕。"));
-                if (communityDto.getName().equals(paramIn.getString("repairObjName"))) {
-                    data.setKeyword1(new Content(paramIn.getString("repairObjName")));
-                } else {
-                    data.setKeyword1(new Content(communityDto.getName() + paramIn.getString("repairObjName")));
-                }
-                data.setKeyword2(new Content(paramIn.getString("context")));
-                data.setKeyword3(new Content(paramIn.getString("staffName")));
-                data.setKeyword4(new Content(paramIn.getString("time")));
-                data.setRemark(new Content("请点击查看详情,对我们的工作进行评价,以便提供更优质的服务,感谢您的配合和使用,祝您生活愉快,阖家欢乐!"));
-                templateMessage.setData(data);
-                //获取业主公众号地址
-                String wechatUrl = UrlCache.getOwnerUrl();
-                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("repairObjName", paramIn.getString("repairObjName"));
+        content.put("staffName", paramIn.getString("staffName"));
+        content.put("time", paramIn.getString("time"));
+        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.sendFinishRepairOwnerMsg(communityDto.getCommunityId(), paramIn.getString("userId"), content);
+
+
     }
 
     /**
@@ -361,6 +278,7 @@ public class MachineReturnRepairAdapt extends DatabusAdaptImpl {
      * @param communityDto
      */
     private void sendMessage(JSONObject paramIn, CommunityDto communityDto) {
+
         //查询公众号配置
         SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
         smallWeChatDto.setWeChatType("1100");
@@ -371,22 +289,7 @@ public class MachineReturnRepairAdapt 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_REPAIR_CHARGE_SCENE_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;
-        }
+
         //获取房屋所属业主
         OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto();
         ownerRoomRelDto.setRoomId(paramIn.getString("roomId"));
@@ -399,28 +302,22 @@ public class MachineReturnRepairAdapt extends DatabusAdaptImpl {
         ownerAppUserDto.setMemberId(ownerId);
         ownerAppUserDto.setAppType("WECHAT");
         List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMO.queryOwnerAppUsers(ownerAppUserDto);
-        if (ownerAppUserDtos != null && 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);
-            data.setFirst(new Content(paramIn.getString("roomName") + "缴费信息如下:"));
-            data.setKeyword1(new Content(paramIn.getString("roomName")));
-            data.setKeyword2(new Content(paramIn.getString("repairName")));
-            data.setKeyword3(new Content("维修费"));
-            data.setKeyword4(new Content(paramIn.getString("feeState")));
-            data.setKeyword5(new Content(paramIn.getString("price") + "元"));
-            data.setRemark(new Content("请您及时缴费,感谢您的配合和使用,祝您生活愉快,阖家欢乐!"));
-            templateMessage.setData(data);
-            //获取业主公众号地址
-            String wechatUrl = UrlCache.getOwnerUrl();
-            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();
+        content.put("feeTypeName", "维修费");
+        content.put("payerObjName", paramIn.getString("roomName"));
+        content.put("billAmountOwed", paramIn.getString("price") + "元");
+        content.put("date", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B));
+        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.sendOweFeeMsg(communityDto.getCommunityId(), ownerAppUserDtos.get(0).getUserId(), content);
+
     }
 }

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

@@ -91,4 +91,34 @@ public interface IMsgNotify {
      * @return
      */
     ResultVo sendDistributeRepairOwnerMsg(String communityId, String userId, JSONObject content);
+
+    /**
+     * 报修完成给业主通知
+     *
+     * @param communityId 小区
+     * @param userId      用户
+     * @param content     {
+     *                    repairObjName,
+     *                    staffName,
+     *                    time,
+     *                    url
+     *                    }
+     * @return
+     */
+    ResultVo sendFinishRepairOwnerMsg(String communityId, String userId, JSONObject content);
+
+    /**
+     * 退单给业主发送消息
+     *
+     * @param communityId 小区
+     * @param userId      用户
+     * @param content     {
+     *                    repairTypeName,
+     *                    repairObjName,
+     *                    repairName,
+     *                    url
+     *                    }
+     * @return
+     */
+    ResultVo sendReturnRepairMsg(String communityId, String userId, JSONObject content);
 }

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

@@ -184,6 +184,61 @@ public class MsgNotifyFactory {
         return resultVo;
     }
 
+    /**
+     * 报修完成给业主通知
+     *
+     * @param communityId 小区
+     * @param userId      用户
+     * @param content     {
+     *                    repairObjName,
+     *                    staffName,
+     *                    time,
+     *                    url
+     *                    }
+     * @return
+     */
+    public static ResultVo sendFinishRepairOwnerMsg(String communityId, String userId, JSONObject content) {
+        ResultVo resultVo = null;
+        try {
+            IMsgNotify msgNotify = getMsgNotify();
+            resultVo = msgNotify.sendFinishRepairOwnerMsg(communityId, userId, content);
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error("通知 报修完成给业主通知 消息", e);
+            resultVo = new ResultVo(ResultVo.CODE_ERROR, e.getMessage());
+        }
+
+        return resultVo;
+    }
+
+
+    /**
+     * 退单给业主发送消息
+     *
+     * @param communityId 小区
+     * @param userId      用户
+     * @param content     {
+     *                    repairTypeName,
+     *                    repairObjName,
+     *                    repairName,
+     *                    url
+     *                    }
+     * @return
+     */
+    public static ResultVo sendReturnRepairMsg(String communityId, String userId, JSONObject content) {
+        ResultVo resultVo = null;
+        try {
+            IMsgNotify msgNotify = getMsgNotify();
+            resultVo = msgNotify.sendReturnRepairMsg(communityId, userId, content);
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error("通知 业主报修时 消息", e);
+            resultVo = new ResultVo(ResultVo.CODE_ERROR, e.getMessage());
+        }
+
+        return resultVo;
+    }
+
     /**
      * 获取通知适配器
      *

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

@@ -36,4 +36,9 @@ public class AliMsgNotifyImpl implements IMsgNotify {
     public ResultVo sendDistributeRepairOwnerMsg(String communityId, String userId, JSONObject content) {
         return null;
     }
+
+    @Override
+    public ResultVo sendFinishRepairOwnerMsg(String communityId, String userId, JSONObject content) {
+        return null;
+    }
 }

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

@@ -36,4 +36,9 @@ public class TencentMsgNotifyImpl implements IMsgNotify {
     public ResultVo sendDistributeRepairOwnerMsg(String communityId, String userId, JSONObject content) {
         return null;
     }
+
+    @Override
+    public ResultVo sendFinishRepairOwnerMsg(String communityId, String userId, JSONObject content) {
+        return null;
+    }
 }

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

@@ -63,6 +63,9 @@ public class WechatMsgNotifyImpl implements IMsgNotify {
         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[]{"房屋地址", "维修工程师", "维修完成时间"});
+
+
 
     }
 
@@ -388,4 +391,95 @@ public class WechatMsgNotifyImpl implements IMsgNotify {
         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("业主未绑定,没有获取到微信openId");
+        }
+        openId = ownerAppUserDtos.get(0).getOpenId();
+
+        Data data = new Data();
+        PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
+        templateMessage.setTemplate_id(templateId);
+        templateMessage.setTouser(openId);
+        data.setKeyword1(new Content(content.getString("repairObjName")));
+        data.setKeyword2(new Content(content.getString("staffName")));
+        data.setKeyword3(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"));
+    }
+
+    @Override
+    public ResultVo sendReturnRepairMsg(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_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;
+        Data data = new Data();
+        PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
+        templateMessage.setTemplate_id(templateId);
+        templateMessage.setTouser(openId);
+        data.setKeyword1(new Content(content.getString("repairTypeName")));
+        data.setKeyword2(new Content(content.getString("repairObjName")));
+        data.setKeyword3(new Content(content.getString("repairName")));
+        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"));
+    }
 }

+ 11 - 11
service-store/src/main/java/com/java110/store/cmd/smallWechat/SaveSmallWechatCmd.java

@@ -223,17 +223,17 @@ public class SaveSmallWechatCmd extends Cmd {
 //            throw new CmdException("保存数据失败");
 //        }
         //报修工单维修完成提醒给业主 通知--模板ID
-        smallWechatAttrPo = new SmallWechatAttrPo();
-        smallWechatAttrPo.setAttrId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
-        smallWechatAttrPo.setCommunityId(reqJson.getString("objId"));
-        smallWechatAttrPo.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_WORK_ORDER_END_TEMPLATE);
-        smallWechatAttrPo.setValue("这里请填写报修工单维修完成提醒给业主通知模板ID");
-        smallWechatAttrPo.setWechatId(wechatId);
-        flag = smallWechatAttrV1InnerServiceSMOImpl.saveSmallWechatAttr(smallWechatAttrPo);
-
-        if (flag < 1) {
-            throw new CmdException("保存数据失败");
-        }
+//        smallWechatAttrPo = new SmallWechatAttrPo();
+//        smallWechatAttrPo.setAttrId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+//        smallWechatAttrPo.setCommunityId(reqJson.getString("objId"));
+//        smallWechatAttrPo.setSpecCd(SmallWechatAttrDto.SPEC_CD_WECHAT_WORK_ORDER_END_TEMPLATE);
+//        smallWechatAttrPo.setValue("这里请填写报修工单维修完成提醒给业主通知模板ID");
+//        smallWechatAttrPo.setWechatId(wechatId);
+//        flag = smallWechatAttrV1InnerServiceSMOImpl.saveSmallWechatAttr(smallWechatAttrPo);
+//
+//        if (flag < 1) {
+//            throw new CmdException("保存数据失败");
+//        }
         //装修申请提醒给业主缴纳装修押金等信息 通知--模板ID
         smallWechatAttrPo = new SmallWechatAttrPo();
         smallWechatAttrPo.setAttrId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));