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

---
 service-job/src/main/java/com/java110/job/adapt/payment/notice/MachinePaymentNoticeAdapt.java |  355 +++++++++++++++++++++++++----------------------------------
 1 files changed, 150 insertions(+), 205 deletions(-)

diff --git a/service-job/src/main/java/com/java110/job/adapt/payment/notice/MachinePaymentNoticeAdapt.java b/service-job/src/main/java/com/java110/job/adapt/payment/notice/MachinePaymentNoticeAdapt.java
index 8e8f735..f9ebc85 100755
--- a/service-job/src/main/java/com/java110/job/adapt/payment/notice/MachinePaymentNoticeAdapt.java
+++ b/service-job/src/main/java/com/java110/job/adapt/payment/notice/MachinePaymentNoticeAdapt.java
@@ -14,7 +14,7 @@
 import com.aliyuncs.profile.DefaultProfile;
 import com.java110.core.factory.WechatFactory;
 import com.java110.core.smo.IComputeFeeSMO;
-import com.java110.dto.basePrivilege.BasePrivilegeDto;
+import com.java110.dto.privilege.BasePrivilegeDto;
 import com.java110.dto.community.CommunityDto;
 import com.java110.dto.fee.FeeDetailDto;
 import com.java110.dto.fee.FeeDto;
@@ -22,14 +22,15 @@
 import com.java110.dto.owner.OwnerCarDto;
 import com.java110.dto.owner.OwnerDto;
 import com.java110.dto.owner.OwnerRoomRelDto;
-import com.java110.dto.smallWeChat.SmallWeChatDto;
-import com.java110.dto.smallWechatAttr.SmallWechatAttrDto;
-import com.java110.dto.staffAppAuth.StaffAppAuthDto;
+import com.java110.dto.privilege.RoleCommunityDto;
+import com.java110.dto.wechat.SmallWeChatDto;
+import com.java110.dto.wechat.SmallWechatAttrDto;
+import com.java110.dto.user.StaffAppAuthDto;
 import com.java110.dto.user.UserDto;
-import com.java110.entity.order.Business;
-import com.java110.entity.wechat.Content;
-import com.java110.entity.wechat.Data;
-import com.java110.entity.wechat.PropertyFeeTemplateMessage;
+import com.java110.dto.system.Business;
+import com.java110.dto.wechat.Content;
+import com.java110.dto.wechat.Data;
+import com.java110.dto.wechat.PropertyFeeTemplateMessage;
 import com.java110.intf.community.ICommunityInnerServiceSMO;
 import com.java110.intf.fee.IFeeDetailInnerServiceSMO;
 import com.java110.intf.fee.IFeeInnerServiceSMO;
@@ -38,20 +39,24 @@
 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.fee.PayFeeDetailPo;
 import com.java110.utils.cache.MappingCache;
+import com.java110.utils.cache.UrlCache;
+import com.java110.utils.constant.MappingConstant;
 import com.java110.utils.constant.WechatConstant;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.utils.util.DateUtil;
-import com.java110.utils.util.StringUtil;
+import com.java110.utils.util.*;
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.java110.core.log.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -105,6 +110,9 @@
     @Autowired
     private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMO;
 
+    @Autowired
+    private IRoleCommunityV1InnerServiceSMO roleCommunityV1InnerServiceSMOImpl;
+
     //妯℃澘淇℃伅鎺ㄩ�佸湴鍧�
     private static String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
 
@@ -134,12 +142,26 @@
                 businessPayFeeDetails = (JSONArray) bObj;
             }
         } else {
-            return;
+            if (data instanceof JSONObject) {
+                businessPayFeeDetails = new JSONArray();
+                businessPayFeeDetails.add(data);
+            }
         }
         for (int bPayFeeDetailIndex = 0; bPayFeeDetailIndex < businessPayFeeDetails.size(); bPayFeeDetailIndex++) {
             JSONObject businessPayFeeDetail = businessPayFeeDetails.getJSONObject(bPayFeeDetailIndex);
             doSendPayFeeDetail(business, businessPayFeeDetail);
         }
+    }
+
+    private String subDay(String date) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date dt = sdf.parse(date);
+        Calendar rightNow = Calendar.getInstance();
+        rightNow.setTime(dt);
+        rightNow.add(Calendar.DAY_OF_MONTH, -1);
+        Date dt1 = rightNow.getTime();
+        String reStr = sdf.format(dt1);
+        return reStr;
     }
 
     private void doSendPayFeeDetail(Business business, JSONObject businessPayFeeDetail) {
@@ -162,25 +184,56 @@
         String startTime = DateUtil.dateTimeToDate(payFeeDetailPo.getStartTime());
         //鑾峰彇鐢ㄦ埛缂磋垂鍒版湡鏃堕棿
         String endTime = DateUtil.dateTimeToDate(payFeeDetailPo.getEndTime());
+        try {
+            endTime = subDay(endTime);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
         //鑾峰彇鐢ㄦ埛缂磋垂閲戦
         String receivedAmount = payFeeDetailPo.getReceivedAmount();
         //鑾峰彇璐圭敤绫诲瀷
         String feeTypeCd = feeDtos.get(0).getFeeTypeCd();
+        //鑾峰彇浠樿垂瀵硅薄绫诲瀷
+        String payerObjType = feeDtos.get(0).getPayerObjType();
+        //鑾峰彇鐘舵��
+        String state = payFeeDetailPo.getState();
+        //杞︾墝鍙�
+        String carNum = "";
+        //鍋滆溅鍦�
+        String num = "";
+        //杞︿綅
+        String spaceNum = "";
+        if (!StringUtil.isEmpty(payerObjType) && payerObjType.equals("6666")) {
+            String[] split = payerObjName.split("-");
+            //鑾峰彇杞︾墝
+            carNum = split[0];
+            //鑾峰彇鍋滆溅鍦�
+            num = split[1];
+            //鑾峰彇杞︿綅
+            spaceNum = split[2];
+        }
         //鑾峰彇绀惧尯鍚嶇О
         String name = communityDtos.get(0).getName();
         JSONObject paramIn = new JSONObject();
-        paramIn.put("payFeeRoom", name + payerObjName);
+        paramIn.put("payFeeRoom", name + "-" + payerObjName);
         paramIn.put("feeTypeCdName", feeTypeCdName);
-        paramIn.put("payFeeTime", startTime + "鑷�" + endTime);
+        paramIn.put("feeName",feeDtos.get(0).getFeeName());
+        paramIn.put("payFeeTime", startTime + "~" + endTime);
         paramIn.put("receivedAmount", receivedAmount);
         paramIn.put("startTime", startTime);
         paramIn.put("endTime", endTime);
+        paramIn.put("payerObjType", payerObjType);
+        paramIn.put("carNum", carNum);
+        paramIn.put("num", num);
+        paramIn.put("spaceNum", spaceNum);
+        paramIn.put("state", state);
         //缁欎笟涓绘帹閫佹秷鎭�
         sendMessage(paramIn, communityDtos.get(0), payFeeDetailPo);
-        if (feeTypeCd.equals("888800010012")) {
+        if (!StringUtil.isEmpty(state) && !state.equals("1300") && feeTypeCd.equals("888800010012")) {
             //缁欏鐞嗘姤淇畬缁撳崟鐨勭淮淇笀鍌呮帹閫佹秷鎭�
             sendMsg(paramIn, communityDtos.get(0), payFeeDetailPo);
-        } else {
+        }
+        if (!StringUtil.isEmpty(state) && !state.equals("1300")) {
             //缁欏憳宸ユ帹閫佹秷鎭�
             publishMsg(paramIn, communityDtos.get(0), payFeeDetailPo);
         }
@@ -194,32 +247,7 @@
      * @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());
@@ -227,35 +255,37 @@
         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 url = sendMsgUrl + accessToken;
+        String wechatUrl = MappingCache.getValue(MappingConstant.URL_DOMAIN, "STAFF_WECHAT_URL");
+
+        //鑾峰彇浠樿垂瀵硅薄绫诲瀷
+        String payerObjType = paramIn.getString("payerObjType");
+        if (userDtos == null || userDtos.size() < 1) {
+            return;
+        }
         for (UserDto userDto : userDtos) {
             //鏍规嵁 userId 鏌ヨ鍒皁penId
+
+            //todo 鍒ゆ柇缁欏憳宸ユ槸鍚︽巿鏉冧簡璇ュ皬鍖�
+            RoleCommunityDto roleCommunityDto = new RoleCommunityDto();
+            roleCommunityDto.setStaffId(userDto.getUserId());
+            roleCommunityDto.setCommunityId(payFeeDetailPo.getCommunityId());
+           List<RoleCommunityDto> roleCommunityDtos =  roleCommunityV1InnerServiceSMOImpl.queryRoleCommunitys(roleCommunityDto);
+           if(ListUtil.isNull(roleCommunityDtos)){
+               continue;
+           }
+
             try {
-                StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto();
-                staffAppAuthDto.setStaffId(userDto.getUserId());
-                staffAppAuthDto.setAppType("WECHAT");
-                List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto);
-                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("OWNER_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("feeName", paramIn.getString("feeName"));
+                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);
             }
@@ -270,32 +300,6 @@
      * @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());
@@ -303,35 +307,17 @@
         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 鏌ヨ鍒皁penId
         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("OWNER_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("feeName",paramIn.getString("feeName"));
+            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);
         }
@@ -351,32 +337,18 @@
         smallWeChatDto.setObjType(SmallWeChatDto.OBJ_TYPE_COMMUNITY);
         smallWeChatDto.setObjId(communityDto.getCommunityId());
         List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
-        if (smallWeChatDto == null || smallWeChatDtos.size() <= 0) {
+        if (smallWeChatDto == null || smallWeChatDtos.isEmpty()) {
             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());
         List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
         Assert.listOnlyOne(feeDtos, "璐圭敤涓嶅瓨鍦�");
-        //鏀粯鎴块棿id
+        //鏀粯鎴块棿id(鏀粯杞﹁締id)
         String payerObjId = feeDtos.get(0).getPayerObjId();
         //鏀粯绫诲瀷(鎴垮眿銆佽溅杈�)
         String payerObjType = feeDtos.get(0).getPayerObjType();
@@ -386,12 +358,18 @@
             OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto();
             ownerRoomRelDto.setRoomId(payerObjId);
             List<OwnerRoomRelDto> ownerRoomRelDtos = ownerRoomRelInnerServiceSMO.queryOwnerRoomRels(ownerRoomRelDto);
+            if (ownerRoomRelDtos == null || ownerRoomRelDtos.size() != 1) {
+                return;
+            }
             //鍙栧緱涓氫富id
             ownerId = ownerRoomRelDtos.get(0).getOwnerId();
         } else if (payerObjType.equals("6666")) {
             OwnerCarDto ownerCarDto = new OwnerCarDto();
-            ownerCarDto.setPsId(payerObjId);
+            ownerCarDto.setCarId(payerObjId);
             List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMO.queryOwnerCars(ownerCarDto);
+            if (ownerCarDtos == null || ownerCarDtos.size() != 1) {
+                return;
+            }
             //鍙栧緱涓氫富id
             ownerId = ownerCarDtos.get(0).getOwnerId();
         }
@@ -401,78 +379,45 @@
         ownerDto.setOwnerTypeCd("1001");
         //鏌ヨ涓氫富
         List<OwnerDto> ownerDtos = ownerInnerServiceSMO.queryOwners(ownerDto);
+        Assert.listOnlyOne(ownerDtos, "鏌ヨ涓氫富淇℃伅閿欒锛�");
         //鑾峰緱鎴愬憳id
         String memberId = ownerDtos.get(0).getMemberId();
         OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
         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);
-            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("OWNER_WECHAT_URL");
-            templateMessage.setUrl(wechatUrl);
-            logger.info("鍙戦�佹ā鏉挎秷鎭唴瀹�:{}", JSON.toJSONString(templateMessage));
-            ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
-            logger.info("寰俊妯℃澘杩斿洖鍐呭:{}", responseEntity);
-        } 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();
-            }
+        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"));
+        content.put("feeName",feeDtos.get(0).getFeeName());
+
+        //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 {
+            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);
+
     }
 }

--
Gitblit v1.8.0