Procházet zdrojové kódy

代理商服务开发测试完成

wuxw před 7 roky
rodič
revize
3f68ecbfdb
36 změnil soubory, kde provedl 3367 přidání a 615 odebrání
  1. 29 0
      AgentService/doc/deleteAgentAttr.json
  2. 29 0
      AgentService/doc/deleteAgentCerdentials.json
  3. 29 0
      AgentService/doc/deleteAgentPhoto.json
  4. 29 0
      AgentService/doc/deleteAgentUser.json
  5. 35 0
      AgentService/doc/saveAgentCerdentials.json
  6. 41 0
      AgentService/doc/saveAgentInfo.json
  7. 32 0
      AgentService/doc/saveAgentPhoto.json
  8. 32 0
      AgentService/doc/saveAgentUser.json
  9. 34 0
      AgentService/doc/updateAgentCerdentials.json
  10. 40 0
      AgentService/doc/updateAgentInfo.json
  11. 32 0
      AgentService/doc/updateAgentPhoto.json
  12. 10 0
      AgentService/docker/Dockerfile
  13. 14 0
      AgentService/docker/bin/start_agent.sh
  14. 12 0
      AgentService/docker/docker-compose.yml
  15. 11 0
      AgentService/docker/onStart.sh
  16. 147 27
      AgentService/src/main/java/com/java110/agent/dao/IAgentServiceDao.java
  17. 288 63
      AgentService/src/main/java/com/java110/agent/dao/impl/AgentServiceDaoImpl.java
  18. 180 24
      AgentService/src/main/java/com/java110/agent/listener/AbstractAgentBusinessServiceDataFlowListener.java
  19. 153 0
      AgentService/src/main/java/com/java110/agent/listener/DeleteAgentAttrListener.java
  20. 156 0
      AgentService/src/main/java/com/java110/agent/listener/DeleteAgentCerdentialsListener.java
  21. 0 296
      AgentService/src/main/java/com/java110/agent/listener/DeleteAgentInfoListener.java
  22. 148 0
      AgentService/src/main/java/com/java110/agent/listener/DeleteAgentPhotoListener.java
  23. 152 0
      AgentService/src/main/java/com/java110/agent/listener/DeleteAgentUserListener.java
  24. 151 0
      AgentService/src/main/java/com/java110/agent/listener/SaveAgentCerdentialsListener.java
  25. 18 109
      AgentService/src/main/java/com/java110/agent/listener/SaveAgentInfoListener.java
  26. 139 0
      AgentService/src/main/java/com/java110/agent/listener/SaveAgentPhotoListener.java
  27. 244 0
      AgentService/src/main/java/com/java110/agent/listener/SaveAgentUserListener.java
  28. 155 0
      AgentService/src/main/java/com/java110/agent/listener/UpdateAgentCerdentialsListener.java
  29. 2 93
      AgentService/src/main/java/com/java110/agent/listener/UpdateAgentInfoListener.java
  30. 161 0
      AgentService/src/main/java/com/java110/agent/listener/UpdateAgentPhotoListener.java
  31. 1 1
      AgentService/src/main/resources/application.yml
  32. 13 0
      java110-common/src/main/java/com/java110/common/constant/ServiceCodeConstant.java
  33. 215 0
      java110-config/db/AgentService/create_table.sql
  34. 1 1
      java110-config/db/PropertyService/create_table.sql
  35. 617 0
      java110-config/src/main/resources/mapper/agent/AgentServiceDaoImplMapper.xml
  36. 17 1
      java110-core/src/main/java/com/java110/core/factory/GenerateCodeFactory.java

+ 29 - 0
AgentService/doc/deleteAgentAttr.json

@@ -0,0 +1,29 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "serviceCode": "delete.agent.attr",
+    "serviceName": "删除代理商属性",
+    "remark": "备注",
+    "datas": {
+      "businessAgentAttr": [{
+        "attrId":"112018121800000002"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}

+ 29 - 0
AgentService/doc/deleteAgentCerdentials.json

@@ -0,0 +1,29 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "serviceCode": "delete.agent.cerdentials",
+    "serviceName": "删除商户证件信息",
+    "remark": "备注",
+    "datas": {
+      "businessAgentCerdentials":[{
+        "agentCerdentialsId":"9220181218000002"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}

+ 29 - 0
AgentService/doc/deleteAgentPhoto.json

@@ -0,0 +1,29 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "serviceCode": "delete.agent.photo",
+    "serviceName": "删除物业照片信息",
+    "remark": "备注",
+    "datas": {
+      "businessAgentPhoto":[{
+        "agentPhotoId":"12320181218000001"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}

+ 29 - 0
AgentService/doc/deleteAgentUser.json

@@ -0,0 +1,29 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "serviceCode": "delete.agent.user",
+    "serviceName": "删除住户信息",
+    "remark": "备注",
+    "datas": {
+      "businessAgentUser":[{
+        "agentUserId":"9320181219000001"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}

+ 35 - 0
AgentService/doc/saveAgentCerdentials.json

@@ -0,0 +1,35 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "serviceCode": "save.agent.cerdentials",
+    "serviceName": "保存商户信息",
+    "remark": "备注",
+    "datas": {
+      "businessAgentCerdentials":[{
+        "agentCerdentialsId":"-1",
+        "agentId":"9020181218000001",
+        "credentialsCd":"1",
+        "value":"632126XXXXXXXX2011",
+        "validityPeriod":"有效期,长期有效请写3000/01/01",
+        "positivePhoto":"正面照片地址,1234567.jpg",
+        "negativePhoto":"反面照片地址,没有不填写"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}

+ 41 - 0
AgentService/doc/saveAgentInfo.json

@@ -0,0 +1,41 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "serviceCode": "save.agent.info",
+    "serviceName": "保存物业信息",
+    "remark": "备注",
+    "datas": {
+      "businessAgent": {
+        "agentId": "-1",
+        "name": "方博家园",
+        "address": "青海省西宁市城中区129号",
+        "tel": "17797173942",
+        "nearbyLandmarks": "王府井旁30米",
+        "mapX": "101.801909",
+        "mapY": "36.597263"
+      },
+      "businessAgentAttr": [{
+        "agentId": "-1",
+        "attrId":"-1",
+        "specCd":"1001",
+        "value":"01"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}

+ 32 - 0
AgentService/doc/saveAgentPhoto.json

@@ -0,0 +1,32 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "serviceCode": "save.agent.photo",
+    "serviceName": "保存小区信息",
+    "remark": "备注",
+    "datas": {
+      "businessAgentPhoto":[{
+        "agentPhotoId":"-1",
+        "agentId":"123213",
+        "agentPhotoTypeCd":"T",
+        "photo":"12345678.jpg"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}

+ 32 - 0
AgentService/doc/saveAgentUser.json

@@ -0,0 +1,32 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "serviceCode": "save.agent.user",
+    "serviceName": "保存商户信息",
+    "remark": "备注",
+    "datas": {
+      "businessAgentUser":[{
+        "agentUserId":"-1",
+        "agentId":"9020181218000001",
+        "relCd":"600311000001",
+        "userId":"123"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}

+ 34 - 0
AgentService/doc/updateAgentCerdentials.json

@@ -0,0 +1,34 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "serviceCode": "update.agent.cerdentials",
+    "serviceName": "修改物业证件信息",
+    "remark": "备注",
+    "datas": {
+      "businessAgentCerdentials":[{
+        "agentCerdentialsId":"9220181218000002",
+        "agentId":"9020181218000001",
+        "value":"632126XXXXXXXX2012",
+        "validityPeriod":"3000-2-1",
+        "positivePhoto":"1234567.jpg",
+        "negativePhoto":"11.jpg"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}

+ 40 - 0
AgentService/doc/updateAgentInfo.json

@@ -0,0 +1,40 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "serviceCode": "update.agent.info",
+    "serviceName": "修改商户信息",
+    "remark": "备注",
+    "datas": {
+      "businessAgent": {
+        "agentId": "123123",
+        "name": "方博家园",
+        "address": "青海省西宁市城中区129号",
+        "tel": "17797173942",
+        "nearbyLandmarks": "王府井旁30米",
+        "mapX": "101.801909",
+        "mapY": "36.597263"
+      },
+      "businessAgentAttr": [{
+        "agentId": "12313",
+        "attrId":"123123",
+        "value":"01"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}

+ 32 - 0
AgentService/doc/updateAgentPhoto.json

@@ -0,0 +1,32 @@
+{
+  "orders": {
+    "appId": "外系统ID,分配得到",
+    "transactionId": "100000000020180409224736000001",
+    "userId": "用户ID",
+    "orderTypeCd": "订单类型,查询,受理",
+    "requestTime": "20180409224736",
+    "remark": "备注",
+    "sign": "这个服务是否要求MD5签名",
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  },
+  "business": {
+    "serviceCode": "update.agent.photo",
+    "serviceName": "修改物业照片信息",
+    "remark": "备注",
+    "datas": {
+      "businessAgentPhoto":[{
+        "agentPhotoId":"12320181218000001",
+        "agentId":"9020181218000001",
+        "agentPhotoTypeCd":"T",
+        "photo":"123456789.jpg"
+      }]
+    },
+    "attrs": [{
+      "specCd": "配置的字段ID",
+      "value": "具体值"
+    }]
+  }
+}

+ 10 - 0
AgentService/docker/Dockerfile

@@ -0,0 +1,10 @@
+FROM registry.cn-beijing.aliyuncs.com/sxd/ubuntu-java8:1.0
+MAINTAINER wuxw <928255095@qq.com>
+
+
+ADD bin/start_agent.sh /root/
+
+
+RUN chmod u+x /root/start_agent.sh
+
+CMD ["/root/start_agent.sh","dev"]

+ 14 - 0
AgentService/docker/bin/start_agent.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+#### debug model prod
+#nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar -Dspring.profiles.active=dev target/AgentService.jar > agent.log 2>&1 &
+
+#### normal prod model
+#nohup java -jar -Dspring.profiles.active=prod target/AgentService.jar > agent.log 2>&1 &
+
+#### normal test model
+#nohup java -jar -Dspring.profiles.active=test target/AgentService.jar > agent.log 2>&1 &
+
+#### normal dev model
+nohup java -jar -Dspring.profiles.active=$1 target/AgentService.jar > agent.log 2>&1 &
+
+tail -100f agent.log

+ 12 - 0
AgentService/docker/docker-compose.yml

@@ -0,0 +1,12 @@
+version: '2'
+services:
+   agentserivce:
+       container_name: agentserivce-1
+       build:
+          context: .
+          dockerfile: Dockerfile
+       restart: always
+       ports:
+       - "8009:8009"
+       volumes:
+       - ../target/AgentService.jar:/root/target/AgentService.jar

+ 11 - 0
AgentService/docker/onStart.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+cp -r ../bin .
+
+cp  -r ../target .
+
+docker build -t java110/agent .
+
+docker run -ti --name agent_test -p8006:8006 -idt java110/agent:latest
+
+docker logs -f agent_test

+ 147 - 27
AgentService/src/main/java/com/java110/agent/dao/IAgentServiceDao.java

@@ -44,6 +44,36 @@ public interface IAgentServiceDao {
      */
     public void saveBusinessAgentCerdentials(Map businessAgentCerdentials) throws DAOException;
 
+
+    /**
+     * 保存代理商用户信息
+     * @param info
+     * @throws DAOException
+     */
+    public void saveBusinessAgentUser(Map info) throws DAOException;
+
+    /**
+     * 保存代理商费用信息
+     * @param info
+     * @throws DAOException
+     */
+    public void saveBusinessAgentFee(Map info) throws DAOException;
+
+    /**
+     * 保存 住户信息
+     * @param businessAgentHouse 住户信息 封装
+     * @throws DAOException 操作数据库异常
+     */
+    public void saveBusinessAgentHouse(Map businessAgentHouse) throws DAOException;
+
+    /**
+     * 保存住户属性
+     * @param businessAgentHouseAttr 住户信息封装
+     * @throws DAOException 操作数据库异常
+     */
+    public void saveBusinessAgentHouseAttr(Map businessAgentHouseAttr) throws DAOException;
+
+
     /**
      * 查询代理商信息(business过程)
      * 根据bId 查询代理商信息
@@ -62,6 +92,25 @@ public interface IAgentServiceDao {
      */
     public List<Map> getBusinessAgentAttrs(Map info) throws DAOException;
 
+    /**
+     * 查询住户信息(business过程)
+     * 根据bId 查询代理商信息
+     * @param info bId 信息
+     * @return 代理商信息
+     * @throws DAOException
+     */
+    public Map getBusinessAgentHouse(Map info) throws DAOException;
+
+
+    /**
+     * 查询住户属性信息(business过程)
+     * @param info bId 信息
+     * @return 代理商属性
+     * @throws DAOException
+     */
+    public List<Map> getBusinessAgentHouseAttrs(Map info) throws DAOException;
+
+
 
     /**
      * 查询代理商照片
@@ -80,6 +129,21 @@ public interface IAgentServiceDao {
      */
     public List<Map> getBusinessAgentCerdentials(Map info) throws DAOException;
 
+    /**
+     * 查询代理商用户信息
+     * @param info bId 信息
+     * @return 代理商照片
+     * @throws DAOException
+     */
+    public List<Map> getBusinessAgentUser(Map info) throws DAOException;
+
+    /**
+     * 查询代理商费用信息
+     * @param info bId 信息
+     * @return 代理商照片
+     * @throws DAOException
+     */
+    public List<Map> getBusinessAgentFee(Map info) throws DAOException;
     /**
      * 保存 代理商信息 Business数据到 Instance中
      * @param info
@@ -95,6 +159,21 @@ public interface IAgentServiceDao {
      */
     public void saveAgentAttrsInstance(Map info) throws DAOException;
 
+    /**
+     * 保存 住户信息 Business数据到 Instance中
+     * @param info
+     * @throws DAOException
+     */
+    public void saveAgentHouseInstance(Map info) throws DAOException;
+
+
+    /**
+     * 保存 住户属性信息 Business数据到 Instance中
+     * @param info
+     * @throws DAOException
+     */
+    public void saveAgentHouseAttrsInstance(Map info) throws DAOException;
+
     /**
      * 保存 代理商照片信息 Business数据到 Instance中
      * @param info
@@ -111,6 +190,19 @@ public interface IAgentServiceDao {
     public void saveAgentCerdentialsInstance(Map info) throws DAOException;
 
 
+    /**
+     * 保存 代理商用户信息 Business数据到 Instance中
+     * @param info
+     * @throws DAOException
+     */
+    public void saveAgentUserInstance(Map info) throws DAOException;
+
+    /**
+     * 保存 代理商费用信息 Business数据到 Instance中
+     * @param info
+     * @throws DAOException
+     */
+    public void saveAgentFeeInstance(Map info) throws DAOException;
 
     /**
      * 查询代理商信息(instance过程)
@@ -130,6 +222,24 @@ public interface IAgentServiceDao {
      */
     public List<Map> getAgentAttrs(Map info) throws DAOException;
 
+    /**
+     * 查询住户信息(instance过程)
+     * 根据bId 查询代理商信息
+     * @param info bId 信息
+     * @return 代理商信息
+     * @throws DAOException
+     */
+    public Map getAgentHouse(Map info) throws DAOException;
+
+
+    /**
+     * 查询住户属性信息(instance过程)
+     * @param info bId 信息
+     * @return 代理商属性
+     * @throws DAOException
+     */
+    public List<Map> getAgentHouseAttrs(Map info) throws DAOException;
+
 
     /**
      * 查询代理商照片(instance 过程)
@@ -147,6 +257,22 @@ public interface IAgentServiceDao {
      */
     public List<Map> getAgentCerdentials(Map info) throws DAOException;
 
+    /**
+     * 查询代理商用户信息(instance 过程)
+     * @param info bId 信息
+     * @return 代理商照片
+     * @throws DAOException
+     */
+    public List<Map> getAgentUser(Map info) throws DAOException;
+
+    /**
+     * 查询代理商费用信息(instance 过程)
+     * @param info bId 信息
+     * @return 代理商照片
+     * @throws DAOException
+     */
+    public List<Map> getAgentFee(Map info) throws DAOException;
+
     /**
      * 修改代理商信息
      * @param info 修改信息
@@ -162,59 +288,53 @@ public interface IAgentServiceDao {
      */
     public void updateAgentAttrInstance(Map info) throws DAOException;
 
-
     /**
-     * 修改代理商照片信息
+     * 修改住户信息
      * @param info 修改信息
      * @throws DAOException
      */
-    public void updateAgentPhotoInstance(Map info) throws DAOException;
+    public void updateAgentHouseInstance(Map info) throws DAOException;
+
 
     /**
-     * 修改代理商证件信息
+     * 修改住户属性信息
      * @param info 修改信息
      * @throws DAOException
      */
-    public void updateAgentCerdentailsInstance(Map info) throws DAOException;
+    public void updateAgentHouseAttrInstance(Map info) throws DAOException;
 
 
     /**
-     * 代理商成员加入信息
-     * @param businessMemberAgent 代理商成员信息 封装
-     * @throws DAOException 操作数据库异常
-     */
-    public void saveBusinessMemberAgent(Map businessMemberAgent) throws DAOException;
-
-    /**
-     * 成员加入 保存信息至instance
-     * @param info
+     * 修改代理商照片信息
+     * @param info 修改信息
      * @throws DAOException
      */
-    public void saveMemberAgentInstance(Map info) throws DAOException;
+    public void updateAgentPhotoInstance(Map info) throws DAOException;
 
     /**
-     * 查询代理商成员加入信息(business过程)
-     * 根据bId 查询代理商信息
-     * @param info bId 信息
-     * @return 代理商信息
+     * 修改代理商证件信息
+     * @param info 修改信息
      * @throws DAOException
      */
-    public Map getBusinessMemberAgent(Map info) throws DAOException;
+    public void updateAgentCerdentailsInstance(Map info) throws DAOException;
+
 
     /**
-     * 查询代理商成员加入信息(instance过程)
-     * 根据bId 查询代理商信息
-     * @param info bId 信息
-     * @return 代理商信息
+     * 修改代理商用户信息
+     * @param info 修改信息
      * @throws DAOException
      */
-    public Map getMemberAgent(Map info) throws DAOException;
+    public void updateAgentUserInstance(Map info) throws DAOException;
+
+
 
     /**
-     * 修改代理商成员加入信息
+     * 修改代理商费用信息
      * @param info 修改信息
      * @throws DAOException
      */
-    public void updateMemberAgentInstance(Map info) throws DAOException;
+    public void updateAgentFeeInstance(Map info) throws DAOException;
+
+
 
 }

+ 288 - 63
AgentService/src/main/java/com/java110/agent/dao/impl/AgentServiceDaoImpl.java

@@ -1,11 +1,11 @@
 package com.java110.agent.dao.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.java110.agent.dao.IAgentServiceDao;
 import com.java110.common.constant.ResponseConstant;
 import com.java110.common.exception.DAOException;
 import com.java110.common.util.DateUtil;
 import com.java110.core.base.dao.BaseServiceDao;
-import com.java110.agent.dao.IAgentServiceDao;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -92,6 +92,71 @@ public class AgentServiceDaoImpl extends BaseServiceDao implements IAgentService
         }
     }
 
+    /**
+     * 保存代理商用户信息
+     * @param info
+     * @throws DAOException
+     */
+    public void saveBusinessAgentUser(Map info) throws DAOException{
+        info.put("month", DateUtil.getCurrentMonth());
+        logger.debug("保存代理商用户信息入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.insert("agentServiceDaoImpl.saveBusinessAgentUser",info);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存代理商用户信息数据失败:"+ JSONObject.toJSONString(info));
+        }
+    }
+
+    /**
+     * 保存代理商费用信息
+     * @param info
+     * @throws DAOException
+     */
+    public void saveBusinessAgentFee(Map info) throws DAOException{
+        info.put("month", DateUtil.getCurrentMonth());
+        logger.debug("保存代理商费用信息入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.insert("agentServiceDaoImpl.saveBusinessAgentFee",info);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存代理商费用信息数据失败:"+ JSONObject.toJSONString(info));
+        }
+    }
+
+    /**
+     * 保存 住户信息
+     * @param businessAgentHouse 住户信息 封装
+     * @throws DAOException 操作数据库异常
+     */
+    public void saveBusinessAgentHouse(Map businessAgentHouse) throws DAOException{
+        businessAgentHouse.put("month", DateUtil.getCurrentMonth());
+        // 查询business_user 数据是否已经存在
+        logger.debug("保存住户信息 入参 businessAgentHouse : {}",businessAgentHouse);
+        int saveFlag = sqlSessionTemplate.insert("agentServiceDaoImpl.saveBusinessAgentHouse",businessAgentHouse);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存住户数据失败:"+ JSONObject.toJSONString(businessAgentHouse));
+        }
+    }
+
+    /**
+     * 保存住户属性
+     * @param businessAgentHouseAttr 住户信息封装
+     * @throws DAOException 操作数据库异常
+     */
+    public void saveBusinessAgentHouseAttr(Map businessAgentHouseAttr) throws DAOException{
+        businessAgentHouseAttr.put("month", DateUtil.getCurrentMonth());
+        // 查询business_user 数据是否已经存在
+        logger.debug("保存住户属性信息 入参 businessAgentHouseAttr : {}",businessAgentHouseAttr);
+
+        int saveFlag = sqlSessionTemplate.insert("agentServiceDaoImpl.saveBusinessAgentHouseAttr",businessAgentHouseAttr);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存住户属性数据失败:"+ JSONObject.toJSONString(businessAgentHouseAttr));
+        }
+    }
+
     /**
      * 查询代理商信息
      * @param info bId 信息
@@ -129,6 +194,42 @@ public class AgentServiceDaoImpl extends BaseServiceDao implements IAgentService
         return businessAgentAttrs;
     }
 
+    /**
+     * 查询住户信息(business过程)
+     * 根据bId 查询代理商信息
+     * @param info bId 信息
+     * @return 代理商信息
+     * @throws DAOException
+     */
+    public Map getBusinessAgentHouse(Map info) throws DAOException{
+        logger.debug("查询住户信息 入参 info : {}",info);
+
+        List<Map> businessAgentHouses = sqlSessionTemplate.selectList("agentServiceDaoImpl.getBusinessAgentHouse",info);
+        if(businessAgentHouses == null){
+            return null;
+        }
+        if(businessAgentHouses.size() >1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:businessAgentHouse,"+ JSONObject.toJSONString(info));
+        }
+
+        return businessAgentHouses.get(0);
+    }
+
+
+    /**
+     * 查询住户属性信息(business过程)
+     * @param info bId 信息
+     * @return 代理商属性
+     * @throws DAOException
+     */
+    public List<Map> getBusinessAgentHouseAttrs(Map info) throws DAOException{
+        logger.debug("查询住户属性信息 入参 info : {}",info);
+
+        List<Map> businessAgentHouseAttrs = sqlSessionTemplate.selectList("agentServiceDaoImpl.getBusinessAgentHouseAttrs",info);
+
+        return businessAgentHouseAttrs;
+    }
+
     /**
      * 查询代理商照片
      * @param info bId 信息
@@ -159,6 +260,35 @@ public class AgentServiceDaoImpl extends BaseServiceDao implements IAgentService
         return businessAgentCerdentialses;
     }
 
+    /**
+     * 查询代理商用户信息
+     * @param info bId 信息
+     * @return 代理商照片
+     * @throws DAOException
+     */
+    public List<Map> getBusinessAgentUser(Map info) throws DAOException{
+        logger.debug("查询代理商用户信息 入参 info : {}",info);
+
+        List<Map> businessAgentUsers = sqlSessionTemplate.selectList("agentServiceDaoImpl.getBusinessAgentUser",info);
+
+        return businessAgentUsers;
+    }
+
+    /**
+     * 查询代理商费用信息
+     * @param info bId 信息
+     * @return 代理商照片
+     * @throws DAOException
+     */
+    public List<Map> getBusinessAgentFee(Map info) throws DAOException{
+        logger.debug("查询代理商用户信息 入参 info : {}",info);
+
+        List<Map> businessAgentUsers = sqlSessionTemplate.selectList("agentServiceDaoImpl.getBusinessAgentFee",info);
+
+        return businessAgentUsers;
+    }
+
+
     /**
      * 保存代理商信息 到 instance
      * @param info   bId 信息
@@ -186,6 +316,37 @@ public class AgentServiceDaoImpl extends BaseServiceDao implements IAgentService
         }
     }
 
+    /**
+     * 保存 住户信息 Business数据到 Instance中
+     * @param info
+     * @throws DAOException
+     */
+    public void saveAgentHouseInstance(Map info) throws DAOException{
+        logger.debug("保存住户信息Instance 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.insert("agentServiceDaoImpl.saveAgentHouseInstance",info);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存住户信息Instance数据失败:"+ JSONObject.toJSONString(info));
+        }
+    }
+
+
+    /**
+     * 保存 住户属性信息 Business数据到 Instance中
+     * @param info
+     * @throws DAOException
+     */
+    public void saveAgentHouseAttrsInstance(Map info) throws DAOException{
+        logger.debug("保存住户属性信息Instance 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.insert("agentServiceDaoImpl.saveAgentHouseAttrsInstance",info);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存住户属性信息Instance数据失败:"+ JSONObject.toJSONString(info));
+        }
+    }
+
     @Override
     public void saveAgentPhotoInstance(Map info) throws DAOException {
         logger.debug("保存代理商照片信息Instance 入参 info : {}",info);
@@ -208,6 +369,37 @@ public class AgentServiceDaoImpl extends BaseServiceDao implements IAgentService
         }
     }
 
+    /**
+     * 保存 代理商用户信息 Business数据到 Instance中
+     * @param info
+     * @throws DAOException
+     */
+    public void saveAgentUserInstance(Map info) throws DAOException{
+        logger.debug("保存代理商用户信息Instance 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.insert("agentServiceDaoImpl.saveAgentUserInstance",info);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存代理商用户信息Instance数据失败:"+ JSONObject.toJSONString(info));
+        }
+    }
+
+    /**
+     * 保存 代理商费用信息 Business数据到 Instance中
+     * @param info
+     * @throws DAOException
+     */
+    public void saveAgentFeeInstance(Map info) throws DAOException{
+        logger.debug("保存代理商费用信息Instance 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.insert("agentServiceDaoImpl.saveAgentFeeInstance",info);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存代理商费用信息Instance数据失败:"+ JSONObject.toJSONString(info));
+        }
+    }
+
+
     /**
      * 查询代理商信息(instance)
      * @param info bId 信息
@@ -244,6 +436,42 @@ public class AgentServiceDaoImpl extends BaseServiceDao implements IAgentService
         return agentAttrs;
     }
 
+    /**
+     * 查询住户信息(instance过程)
+     * 根据bId 查询代理商信息
+     * @param info bId 信息
+     * @return 代理商信息
+     * @throws DAOException
+     */
+    public Map getAgentHouse(Map info) throws DAOException{
+        logger.debug("查询住户信息 入参 info : {}",info);
+
+        List<Map> businessAgentInfos = sqlSessionTemplate.selectList("agentServiceDaoImpl.getAgentHouse",info);
+        if(businessAgentInfos == null || businessAgentInfos.size() == 0){
+            return null;
+        }
+        if(businessAgentInfos.size() >1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:getAgentHouse,"+ JSONObject.toJSONString(info));
+        }
+
+        return businessAgentInfos.get(0);
+    }
+
+
+    /**
+     * 查询住户属性信息(instance过程)
+     * @param info bId 信息
+     * @return 代理商属性
+     * @throws DAOException
+     */
+    public List<Map> getAgentHouseAttrs(Map info) throws DAOException{
+        logger.debug("查询住户属性信息 入参 info : {}",info);
+
+        List<Map> agentAttrs = sqlSessionTemplate.selectList("agentServiceDaoImpl.getAgentHouseAttrs",info);
+
+        return agentAttrs;
+    }
+
     /**
      * 代理商照片查询(instance)
      * @param info bId 信息
@@ -274,6 +502,26 @@ public class AgentServiceDaoImpl extends BaseServiceDao implements IAgentService
         return agentCerdentialses;
     }
 
+    /**
+     * 查询代理商用户信息(instance 过程)
+     * @param info bId 信息
+     * @return 代理商照片
+     * @throws DAOException
+     */
+    public List<Map> getAgentUser(Map info) throws DAOException{
+        logger.debug("查询代理商用户信息 入参 info : {}",info);
+
+        List<Map> agentUsers = sqlSessionTemplate.selectList("agentServiceDaoImpl.getAgentUser",info);
+
+        return agentUsers;
+    }
+
+    public List<Map> getAgentFee(Map info) throws DAOException{
+        logger.debug("查询代理商费用信息 入参 info : {}",info);
+        List<Map> agentFees = sqlSessionTemplate.selectList("agentServiceDaoImpl.getAgentFee",info);
+        return agentFees;
+    }
+
     /**
      * 修改代理商信息
      * @param info 修改信息
@@ -307,121 +555,98 @@ public class AgentServiceDaoImpl extends BaseServiceDao implements IAgentService
     }
 
     /**
-     * 修改 代理商照片信息
+     * 修改住户信息
      * @param info 修改信息
      * @throws DAOException
      */
-    @Override
-    public void updateAgentPhotoInstance(Map info) throws DAOException {
-        logger.debug("修改代理商照片信息Instance 入参 info : {}",info);
+    public void updateAgentHouseInstance(Map info) throws DAOException{
+        logger.debug("修改住户信息Instance 入参 info : {}",info);
 
-        int saveFlag = sqlSessionTemplate.update("agentServiceDaoImpl.updateAgentPhotoInstance",info);
+        int saveFlag = sqlSessionTemplate.update("agentServiceDaoImpl.updateAgentHouseInstance",info);
 
         if(saveFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改代理商照片信息Instance数据失败:"+ JSONObject.toJSONString(info));
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改住户信息Instance数据失败:"+ JSONObject.toJSONString(info));
         }
     }
 
+
     /**
-     * 修改代理商证件信息
+     * 修改住户属性信息
      * @param info 修改信息
      * @throws DAOException
      */
-    @Override
-    public void updateAgentCerdentailsInstance(Map info) throws DAOException {
-        logger.debug("修改代理商证件信息Instance 入参 info : {}",info);
+    public void updateAgentHouseAttrInstance(Map info) throws DAOException{
+        logger.debug("修改住户属性信息Instance 入参 info : {}",info);
 
-        int saveFlag = sqlSessionTemplate.update("agentServiceDaoImpl.updateAgentCerdentailsInstance",info);
+        int saveFlag = sqlSessionTemplate.update("agentServiceDaoImpl.updateAgentHouseAttrInstance",info);
 
         if(saveFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改代理商证件信息Instance数据失败:"+ JSONObject.toJSONString(info));
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改住户属性信息Instance数据失败:"+ JSONObject.toJSONString(info));
         }
     }
 
     /**
-     * 代理商成员加入信息
-     * @param businessMemberAgent 代理商成员信息 封装
-     * @throws DAOException 操作数据库异常
+     * 修改 代理商照片信息
+     * @param info 修改信息
+     * @throws DAOException
      */
-    public void saveBusinessMemberAgent(Map businessMemberAgent) throws DAOException{
-        logger.debug("代理商成员加入 入参 businessMemberAgent : {}",businessMemberAgent);
+    @Override
+    public void updateAgentPhotoInstance(Map info) throws DAOException {
+        logger.debug("修改代理商照片信息Instance 入参 info : {}",info);
 
-        int saveFlag = sqlSessionTemplate.insert("agentServiceDaoImpl.saveBusinessMemberAgent",businessMemberAgent);
+        int saveFlag = sqlSessionTemplate.update("agentServiceDaoImpl.updateAgentPhotoInstance",info);
 
         if(saveFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"代理商成员加入失败:"+ JSONObject.toJSONString(businessMemberAgent));
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改代理商照片信息Instance数据失败:"+ JSONObject.toJSONString(info));
         }
     }
 
     /**
-     * 成员加入 保存信息至instance
-     * @param info
+     * 修改代理商证件信息
+     * @param info 修改信息
      * @throws DAOException
      */
     @Override
-    public void saveMemberAgentInstance(Map info) throws DAOException {
-        logger.debug("代理商成员加入Instance 入参 info : {}",info);
+    public void updateAgentCerdentailsInstance(Map info) throws DAOException {
+        logger.debug("修改代理商证件信息Instance 入参 info : {}",info);
 
-        int saveFlag = sqlSessionTemplate.insert("agentServiceDaoImpl.saveMemberAgentInstance",info);
+        int saveFlag = sqlSessionTemplate.update("agentServiceDaoImpl.updateAgentCerdentailsInstance",info);
 
         if(saveFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存代理商照片信息Instance数据失败:"+ JSONObject.toJSONString(info));
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改代理商证件信息Instance数据失败:"+ JSONObject.toJSONString(info));
         }
     }
 
     /**
-     * 查询代理商成员加入信息(business过程)
-     * 根据bId 查询代理商信息
-     * @param info bId 信息
-     * @return 代理商信息
+     * 修改代理商用户信息
+     * @param info 修改信息
      * @throws DAOException
      */
-    public Map getBusinessMemberAgent(Map info) throws DAOException{
-        logger.debug("查询代理商成员加入信息 入参 info : {}",info);
+    public void updateAgentUserInstance(Map info) throws DAOException{
+        logger.debug("修改代理商用户信息Instance 入参 info : {}",info);
 
-        List<Map> businessMemberAgents = sqlSessionTemplate.selectList("agentServiceDaoImpl.getBusinessMemberAgent",info);
-        if(businessMemberAgents == null || businessMemberAgents.size() == 0){
-            return null;
-        }
-        if(businessMemberAgents.size() >1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:businessMemberAgent,"+ JSONObject.toJSONString(info));
-        }
+        int saveFlag = sqlSessionTemplate.update("agentServiceDaoImpl.updateAgentUserInstance",info);
 
-        return businessMemberAgents.get(0);
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改代理商用户信息Instance数据失败:"+ JSONObject.toJSONString(info));
+        }
     }
 
-    /**
-     * 查询代理商成员加入信息(instance过程)
-     * 根据bId 查询代理商信息
-     * @param info bId 信息
-     * @return 代理商信息
-     * @throws DAOException
-     */
-    public Map getMemberAgent(Map info) throws DAOException{
-        logger.debug("查询代理商成员加入信息 入参 info : {}",info);
 
-        List<Map> memberAgents = sqlSessionTemplate.selectList("agentServiceDaoImpl.getMemberAgent",info);
-        if(memberAgents == null || memberAgents.size() == 0){
-            return null;
-        }
-        if(memberAgents.size() >1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:getMemberAgent,"+ JSONObject.toJSONString(info));
-        }
 
-        return memberAgents.get(0);
-    }
     /**
-     * 修改代理商成员加入信息
+     * 修改代理商费用信息
      * @param info 修改信息
      * @throws DAOException
      */
-    public void updateMemberAgentInstance(Map info) throws DAOException{
-        logger.debug("修改代理商成员加入信息Instance 入参 info : {}",info);
+    public void updateAgentFeeInstance(Map info) throws DAOException{
+        logger.debug("修改代理商费用信息Instance 入参 info : {}",info);
 
-        int saveFlag = sqlSessionTemplate.update("agentServiceDaoImpl.updateMemberAgentInstance",info);
+        int saveFlag = sqlSessionTemplate.update("agentServiceDaoImpl.updateAgentFeeInstance",info);
 
         if(saveFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改代理商成员加入信息Instance数据失败:"+ JSONObject.toJSONString(info));
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改代理商费用信息Instance数据失败:"+ JSONObject.toJSONString(info));
         }
     }
+
 }

+ 180 - 24
AgentService/src/main/java/com/java110/agent/listener/AbstractAgentBusinessServiceDataFlowListener.java

@@ -34,8 +34,6 @@ public abstract class AbstractAgentBusinessServiceDataFlowListener extends Abstr
     protected void flushBusinessAgentInfo(Map businessAgentInfo,String statusCd){
         businessAgentInfo.put("newBId",businessAgentInfo.get("b_id"));
         businessAgentInfo.put("agentId",businessAgentInfo.get("agent_id"));
-        businessAgentInfo.put("userId",businessAgentInfo.get("user_id"));
-        businessAgentInfo.put("agentTypeCd",businessAgentInfo.get("agent_type_cd"));
         businessAgentInfo.put("nearbyLandmarks",businessAgentInfo.get("nearby_landmarks"));
         businessAgentInfo.put("mapX",businessAgentInfo.get("map_x"));
         businessAgentInfo.put("mapY",businessAgentInfo.get("map_y"));
@@ -56,6 +54,38 @@ public abstract class AbstractAgentBusinessServiceDataFlowListener extends Abstr
         businessAgentAttr.put("statusCd",statusCd);
     }
 
+    /**
+     * 刷新 businessAgentInfo 数据
+     * 主要将 数据库 中字段和 接口传递字段建立关系
+     * @param businessAgentHouse
+     */
+    protected void flushBusinessAgentHouse(Map businessAgentHouse,String statusCd){
+        businessAgentHouse.put("newBId",businessAgentHouse.get("b_id"));
+        businessAgentHouse.put("agentId",businessAgentHouse.get("agent_id"));
+        businessAgentHouse.put("houseId",businessAgentHouse.get("house_id"));
+        businessAgentHouse.put("houseNum",businessAgentHouse.get("house_num"));
+        businessAgentHouse.put("houseName",businessAgentHouse.get("house_name"));
+        businessAgentHouse.put("housePhone",businessAgentHouse.get("house_phone"));
+        businessAgentHouse.put("houseArea",businessAgentHouse.get("house_area"));
+        businessAgentHouse.put("feeTypeCd",businessAgentHouse.get("fee_type_cd"));
+        businessAgentHouse.put("feePrice",businessAgentHouse.get("fee_price"));
+        businessAgentHouse.put("statusCd", statusCd);
+    }
+
+    /**
+     刷新 businessAgentAttr 数据
+     * 主要将 数据库 中字段和 接口传递字段建立关系
+     * @param businessAgentHouesAttr
+     * @param statusCd
+     */
+    protected void flushBusinessAgentHouseAttr(Map businessAgentHouesAttr,String statusCd){
+        businessAgentHouesAttr.put("attrId",businessAgentHouesAttr.get("attr_id"));
+        businessAgentHouesAttr.put("specCd",businessAgentHouesAttr.get("spec_cd"));
+        businessAgentHouesAttr.put("houseId",businessAgentHouesAttr.get("house_id"));
+        businessAgentHouesAttr.put("newBId",businessAgentHouesAttr.get("b_id"));
+        businessAgentHouesAttr.put("statusCd",statusCd);
+    }
+
     /**
      * 刷新 businessAgentPhoto 数据
      * @param businessAgentPhoto
@@ -69,6 +99,40 @@ public abstract class AbstractAgentBusinessServiceDataFlowListener extends Abstr
         businessAgentPhoto.put("statusCd",statusCd);
     }
 
+    /**
+     * 刷新 businessAgentPhoto 数据
+     * @param businessAgentUser
+     * @param statusCd
+     */
+    protected void flushBusinessAgentUser(Map businessAgentUser,String statusCd){
+        businessAgentUser.put("agentId",businessAgentUser.get("agent_id"));
+        businessAgentUser.put("agentUserId",businessAgentUser.get("agent_user_id"));
+        businessAgentUser.put("userId",businessAgentUser.get("user_id"));
+        businessAgentUser.put("relCd",businessAgentUser.get("rel_cd"));
+        businessAgentUser.put("newBId",businessAgentUser.get("b_id"));
+        businessAgentUser.put("statusCd",statusCd);
+    }
+
+
+    /**
+     * 刷新 businessAgentPhoto 数据
+     * @param businessAgentFee
+     * @param statusCd
+     */
+    protected void flushBusinessAgentFee(Map businessAgentFee,String statusCd){
+        businessAgentFee.put("agentId",businessAgentFee.get("agent_id"));
+        businessAgentFee.put("feeId",businessAgentFee.get("fee_id"));
+        businessAgentFee.put("agentId",businessAgentFee.get("agent_id"));
+        businessAgentFee.put("feeTypeCd",businessAgentFee.get("fee_type_cd"));
+
+        businessAgentFee.put("feeMoney",businessAgentFee.get("fee_money"));
+        businessAgentFee.put("feeTime",businessAgentFee.get("fee_time"));
+        businessAgentFee.put("startTime",businessAgentFee.get("start_time"));
+        businessAgentFee.put("endTime",businessAgentFee.get("end_time"));
+        businessAgentFee.put("newBId",businessAgentFee.get("b_id"));
+        businessAgentFee.put("statusCd",statusCd);
+    }
+
     /**
      * 刷新 businessAgentCerdentials 数据
      * @param businessAgentCerdentials
@@ -85,6 +149,8 @@ public abstract class AbstractAgentBusinessServiceDataFlowListener extends Abstr
         businessAgentCerdentials.put("statusCd",statusCd);
     }
 
+
+
     /**
      * 刷新 businessMemberAgent 数据
      * 主要将 数据库 中字段和 接口传递字段建立关系
@@ -113,8 +179,6 @@ public abstract class AbstractAgentBusinessServiceDataFlowListener extends Abstr
         }
         currentAgentInfo.put("bId",business.getbId());
         currentAgentInfo.put("agentId",currentAgentInfo.get("agent_id"));
-        currentAgentInfo.put("userId",currentAgentInfo.get("user_id"));
-        currentAgentInfo.put("agentTypeCd",currentAgentInfo.get("agent_type_cd"));
         currentAgentInfo.put("nearbyLandmarks",currentAgentInfo.get("nearby_landmarks"));
         currentAgentInfo.put("mapX",currentAgentInfo.get("map_x"));
         currentAgentInfo.put("mapY",currentAgentInfo.get("map_y"));
@@ -143,6 +207,59 @@ public abstract class AbstractAgentBusinessServiceDataFlowListener extends Abstr
         currentAgentAttr.put("specCd",currentAgentAttr.get("spec_cd"));
         currentAgentAttr.put("operate",StatusConstant.OPERATE_DEL);
         getAgentServiceDaoImpl().saveBusinessAgentAttr(currentAgentAttr);
+        //这个不允许修改,这里直接写入查出来的
+        agentAttr.put("specCd",currentAgentAttr.get("spec_cd"));
+    }
+
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     * @param businessAgentHouse 代理商信息
+     */
+    protected void autoSaveDelBusinessAgentHouse(Business business, JSONObject businessAgentHouse){
+//自动插入DEL
+        Map info = new HashMap();
+        info.put("houseId",businessAgentHouse.getString("houseId"));
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        Map currentAgentHouse = getAgentServiceDaoImpl().getAgentHouse(info);
+        if(currentAgentHouse == null || currentAgentHouse.isEmpty()){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
+        }
+        currentAgentHouse.put("bId",business.getbId());
+        currentAgentHouse.put("agentId",currentAgentHouse.get("agent_id"));
+        currentAgentHouse.put("houseId",currentAgentHouse.get("house_id"));
+        currentAgentHouse.put("houseNum",currentAgentHouse.get("house_num"));
+        currentAgentHouse.put("houseName",currentAgentHouse.get("house_name"));
+        currentAgentHouse.put("housePhone",currentAgentHouse.get("house_phone"));
+        currentAgentHouse.put("houseArea",currentAgentHouse.get("house_area"));
+        currentAgentHouse.put("feeTypeCd",currentAgentHouse.get("fee_type_cd"));
+        currentAgentHouse.put("feePrice",currentAgentHouse.get("fee_price"));
+        currentAgentHouse.put("operate",StatusConstant.OPERATE_DEL);
+        getAgentServiceDaoImpl().saveBusinessAgentHouse(currentAgentHouse);
+    }
+
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     * @param business 当前业务
+     * @param agentHouseAttr 代理商属性
+     */
+    protected void autoSaveDelBusinessAgentHouseAttr(Business business, JSONObject agentHouseAttr){
+        Map info = new HashMap();
+        info.put("attrId",agentHouseAttr.getString("attrId"));
+        info.put("houseId",agentHouseAttr.getString("houseId"));
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        List<Map> currentAgentHouseAttrs = getAgentServiceDaoImpl().getAgentHouseAttrs(info);
+        if(currentAgentHouseAttrs == null || currentAgentHouseAttrs.size() != 1){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
+        }
+        Map currentAgentHouseAttr = currentAgentHouseAttrs.get(0);
+        currentAgentHouseAttr.put("bId",business.getbId());
+        currentAgentHouseAttr.put("attrId",currentAgentHouseAttr.get("attr_id"));
+        currentAgentHouseAttr.put("houseId",currentAgentHouseAttr.get("house_id"));
+        currentAgentHouseAttr.put("specCd",currentAgentHouseAttr.get("spec_cd"));
+        currentAgentHouseAttr.put("operate",StatusConstant.OPERATE_DEL);
+        getAgentServiceDaoImpl().saveBusinessAgentHouseAttr(currentAgentHouseAttr);
+        //这个不允许修改,这里直接写入查出来的
+        agentHouseAttr.put("specCd",currentAgentHouseAttr.get("spec_cd"));
     }
 
     /**
@@ -168,6 +285,61 @@ public abstract class AbstractAgentBusinessServiceDataFlowListener extends Abstr
         getAgentServiceDaoImpl().saveBusinessAgentPhoto(currentAgentPhoto);
     }
 
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     * @param business
+     * @param businessAgentUser 代理商用户
+     */
+    protected void autoSaveDelBusinessAgentUser(Business business,JSONObject businessAgentUser){
+        Map info = new HashMap();
+        info.put("agentUserId",businessAgentUser.getString("agentUserId"));
+        info.put("agentId",businessAgentUser.getString("agentId"));
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        List<Map> currentAgentUsers = getAgentServiceDaoImpl().getAgentUser(info);
+        if(currentAgentUsers == null || currentAgentUsers.size() != 1){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
+        }
+        Map currentAgentUser = currentAgentUsers.get(0);
+        currentAgentUser.put("bId",business.getbId());
+        currentAgentUser.put("agentUserId",currentAgentUser.get("agent_user_id"));
+        currentAgentUser.put("agentId",currentAgentUser.get("agent_id"));
+        currentAgentUser.put("userId",currentAgentUser.get("user_id"));
+        currentAgentUser.put("relCd",currentAgentUser.get("rel_cd"));
+        currentAgentUser.put("operate",StatusConstant.OPERATE_DEL);
+        getAgentServiceDaoImpl().saveBusinessAgentUser(currentAgentUser);
+    }
+
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     * @param business
+     * @param businessAgentFee 代理商费用
+     */
+    protected void autoSaveDelBusinessAgentFee(Business business,JSONObject businessAgentFee){
+        Map info = new HashMap();
+        info.put("feeId",businessAgentFee.getString("feeId"));
+        info.put("agentId",businessAgentFee.getString("agentId"));
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        List<Map> currentAgentFees = getAgentServiceDaoImpl().getAgentFee(info);
+        if(currentAgentFees == null || currentAgentFees.size() != 1){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
+        }
+        Map currentAgentFee = currentAgentFees.get(0);
+        currentAgentFee.put("bId",business.getbId());
+        currentAgentFee.put("feeId",currentAgentFee.get("fee_id"));
+        currentAgentFee.put("agentId",currentAgentFee.get("agent_id"));
+        currentAgentFee.put("feeTypeCd",currentAgentFee.get("fee_type_cd"));
+
+        currentAgentFee.put("feeMoney",currentAgentFee.get("fee_money"));
+        currentAgentFee.put("feeTime",currentAgentFee.get("fee_time"));
+        currentAgentFee.put("startTime",currentAgentFee.get("start_time"));
+        currentAgentFee.put("endTime",currentAgentFee.get("end_time"));
+        currentAgentFee.put("operate",StatusConstant.OPERATE_DEL);
+        getAgentServiceDaoImpl().saveBusinessAgentFee(currentAgentFee);
+
+        businessAgentFee.put("feeTypeCd",currentAgentFee.get("fee_type_cd"));
+    }
+
+
     /**
      * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
      * @param business
@@ -193,27 +365,11 @@ public abstract class AbstractAgentBusinessServiceDataFlowListener extends Abstr
         currentAgentCerdentials.put("negativePhoto",currentAgentCerdentials.get("negative_photo"));
         currentAgentCerdentials.put("operate",StatusConstant.OPERATE_DEL);
         getAgentServiceDaoImpl().saveBusinessAgentCerdentials(currentAgentCerdentials);
+
+        //证件类型不让修改
+        businessAgentCerdentials.put("credentialsCd",currentAgentCerdentials.get("credentials_cd"));
     }
 
 
-    /**
-     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
-     * @param businessMemberAgent 代理商信息
-     */
-    protected void autoSaveDelBusinessMemberAgent(Business business, JSONObject businessMemberAgent){
-//自动插入DEL
-        Map info = new HashMap();
-        info.put("memberAgentId",businessMemberAgent.getString("memberAgentId"));
-        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
-        Map currentMemberAgent = getAgentServiceDaoImpl().getMemberAgent(info);
-        if(currentMemberAgent == null || currentMemberAgent.isEmpty()){
-            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
-        }
-        currentMemberAgent.put("bId",business.getbId());
-        currentMemberAgent.put("agentId",currentMemberAgent.get("agent_id"));
-        currentMemberAgent.put("memberAgentId",currentMemberAgent.get("member_agent_id"));
-        currentMemberAgent.put("memberId",currentMemberAgent.get("member_id"));
-        currentMemberAgent.put("operate",StatusConstant.OPERATE_DEL);
-        getAgentServiceDaoImpl().saveBusinessAgentInfo(currentMemberAgent);
-    }
+
 }

+ 153 - 0
AgentService/src/main/java/com/java110/agent/listener/DeleteAgentAttrListener.java

@@ -0,0 +1,153 @@
+package com.java110.agent.listener;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.agent.dao.IAgentServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 删除代理商信息 侦听
+ *
+ * 处理节点
+ * 1、businessAgentHouse:{} 代理商住户信息节点
+ * 2、businessAgentAttr:[{}] 代理商属性信息节点
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("deleteAgentAttrListener")
+@Transactional
+public class DeleteAgentAttrListener extends AbstractAgentBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(DeleteAgentAttrListener.class);
+    @Autowired
+    IAgentServiceDao agentServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 3;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_DELETE_AGENT_ATTR;
+    }
+
+    /**
+     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        if(data.containsKey("businessAgentAttr")){
+            JSONArray businessAgentAttrs = data.getJSONArray("businessAgentAttr");
+            doSaveBusinessAgentAttrs(business,businessAgentAttrs);
+        }
+    }
+
+    /**
+     * 删除 instance数据
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+
+        //代理商信息
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_DEL);
+
+        //代理商属性
+        List<Map> businessAgentAttrs = agentServiceDaoImpl.getBusinessAgentAttrs(info);
+        if(businessAgentAttrs != null && businessAgentAttrs.size() > 0) {
+            for(Map businessAgentAttr : businessAgentAttrs) {
+                flushBusinessAgentAttr(businessAgentAttr,StatusConstant.STATUS_CD_INVALID);
+                agentServiceDaoImpl.updateAgentAttrInstance(businessAgentAttr);
+            }
+        }
+    }
+
+    /**
+     * 撤单
+     * 从business表中查询到DEL的数据 将instance中的数据更新回来
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+
+        Map delInfo = new HashMap();
+        delInfo.put("bId",business.getbId());
+        delInfo.put("operate",StatusConstant.OPERATE_DEL);
+
+        //代理商属性
+        List<Map> agentAttrs = agentServiceDaoImpl.getAgentAttrs(info);
+        if(agentAttrs != null && agentAttrs.size()>0){
+
+            List<Map> businessAgentAttrs = agentServiceDaoImpl.getBusinessAgentAttrs(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessAgentAttrs == null || businessAgentAttrs.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent_attr),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessAgentAttr : businessAgentAttrs) {
+                flushBusinessAgentAttr(businessAgentAttr,StatusConstant.STATUS_CD_VALID);
+                agentServiceDaoImpl.updateAgentAttrInstance(businessAgentAttr);
+            }
+        }
+    }
+
+
+
+    /**
+     * 保存代理商属性信息
+     * @param business 当前业务
+     * @param businessAgentAttrs 代理商属性
+     */
+    private void doSaveBusinessAgentAttrs(Business business,JSONArray businessAgentAttrs){
+        JSONObject data = business.getDatas();
+
+        for(int agentAttrIndex = 0 ; agentAttrIndex < businessAgentAttrs.size();agentAttrIndex ++){
+            JSONObject agentAttr = businessAgentAttrs.getJSONObject(agentAttrIndex);
+            Assert.jsonObjectHaveKey(agentAttr,"attrId","businessAgentAttr 节点下没有包含 attrId 节点");
+            if(agentAttr.getString("attrId").startsWith("-")){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+agentAttr);
+            }
+
+            autoSaveDelBusinessAgentAttr(business,agentAttr);
+        }
+    }
+
+    public IAgentServiceDao getAgentServiceDaoImpl() {
+        return agentServiceDaoImpl;
+    }
+
+    public void setAgentServiceDaoImpl(IAgentServiceDao agentServiceDaoImpl) {
+        this.agentServiceDaoImpl = agentServiceDaoImpl;
+    }
+}

+ 156 - 0
AgentService/src/main/java/com/java110/agent/listener/DeleteAgentCerdentialsListener.java

@@ -0,0 +1,156 @@
+package com.java110.agent.listener;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.agent.dao.IAgentServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 删除代理商信息 侦听
+ *
+ * 处理节点
+ * 1、businessAgent:{} 代理商基本信息节点
+ * 2、businessAgentAttr:[{}] 代理商属性信息节点
+ * 3、businessAgentPhoto:[{}] 代理商照片信息节点
+ * 4、businessAgentCerdentials:[{}] 代理商证件信息节点
+ * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E5%88%A0%E9%99%A4%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("deleteAgentCerdentialsListener")
+@Transactional
+public class DeleteAgentCerdentialsListener extends AbstractAgentBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(DeleteAgentCerdentialsListener.class);
+    @Autowired
+    IAgentServiceDao agentServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 3;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_DELETE_AGENT_CERDENTIALS;
+    }
+
+    /**
+     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        if(data.containsKey("businessAgentCerdentials")){
+            JSONArray businessAgentCerdentialses = data.getJSONArray("businessAgentCerdentials");
+            doBusinessAgentCerdentials(business,businessAgentCerdentialses);
+        }
+    }
+
+    /**
+     * 删除 instance数据
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+
+        //代理商信息
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_DEL);
+
+        //代理商证件
+        List<Map> businessAgentCerdentialses = agentServiceDaoImpl.getBusinessAgentCerdentials(info);
+        if(businessAgentCerdentialses != null && businessAgentCerdentialses.size()>0){
+            for(Map businessAgentCerdentials : businessAgentCerdentialses) {
+                flushBusinessAgentCredentials(businessAgentCerdentials,StatusConstant.STATUS_CD_INVALID);
+                agentServiceDaoImpl.updateAgentCerdentailsInstance(businessAgentCerdentials);
+            }
+        }
+    }
+
+    /**
+     * 撤单
+     * 从business表中查询到DEL的数据 将instance中的数据更新回来
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+
+        Map delInfo = new HashMap();
+        delInfo.put("bId",business.getbId());
+        delInfo.put("operate",StatusConstant.OPERATE_DEL);
+
+        //代理商属性
+        List<Map> agentCerdentialses = agentServiceDaoImpl.getAgentCerdentials(info);
+        if(agentCerdentialses != null && agentCerdentialses.size()>0){
+            List<Map> businessAgentCerdentialses = agentServiceDaoImpl.getBusinessAgentCerdentials(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessAgentCerdentialses == null || businessAgentCerdentialses.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent_cerdentials),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessAgentCerdentials : businessAgentCerdentialses) {
+                flushBusinessAgentCredentials(businessAgentCerdentials,StatusConstant.STATUS_CD_VALID);
+                agentServiceDaoImpl.updateAgentCerdentailsInstance(businessAgentCerdentials);
+            }
+        }
+    }
+
+
+
+    /**
+     * 保存 代理商证件 信息
+     * @param business 当前业务
+     * @param businessAgentCerdentialses 代理商证件
+     */
+    private void doBusinessAgentCerdentials(Business business, JSONArray businessAgentCerdentialses) {
+
+
+        for(int businessAgentCerdentialsIndex = 0 ; businessAgentCerdentialsIndex < businessAgentCerdentialses.size() ; businessAgentCerdentialsIndex ++) {
+            JSONObject businessAgentCerdentials = businessAgentCerdentialses.getJSONObject(businessAgentCerdentialsIndex);
+            Assert.jsonObjectHaveKey(businessAgentCerdentials, "agentCerdentialsId", "businessAgentPhoto 节点下没有包含 agentCerdentialsId 节点");
+
+            if (businessAgentCerdentials.getString("agentCerdentialsId").startsWith("-")) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"agentPhotoId 错误,不能自动生成(必须已经存在的agentPhotoId)"+businessAgentCerdentials);
+            }
+
+            autoSaveDelBusinessAgentCerdentials(business,businessAgentCerdentials);
+        }
+    }
+
+    public IAgentServiceDao getAgentServiceDaoImpl() {
+        return agentServiceDaoImpl;
+    }
+
+    public void setAgentServiceDaoImpl(IAgentServiceDao agentServiceDaoImpl) {
+        this.agentServiceDaoImpl = agentServiceDaoImpl;
+    }
+}

+ 0 - 296
AgentService/src/main/java/com/java110/agent/listener/DeleteAgentInfoListener.java

@@ -1,296 +0,0 @@
-package com.java110.agent.listener;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.java110.common.constant.ResponseConstant;
-import com.java110.common.constant.ServiceCodeConstant;
-import com.java110.common.constant.StatusConstant;
-import com.java110.common.exception.ListenerExecuteException;
-import com.java110.common.util.Assert;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.entity.center.Business;
-import com.java110.agent.dao.IAgentServiceDao;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 删除代理商信息 侦听
- *
- * 处理节点
- * 1、businessAgent:{} 代理商基本信息节点
- * 2、businessAgentAttr:[{}] 代理商属性信息节点
- * 3、businessAgentPhoto:[{}] 代理商照片信息节点
- * 4、businessAgentCerdentials:[{}] 代理商证件信息节点
- * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E5%88%A0%E9%99%A4%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE
- * Created by wuxw on 2018/5/18.
- */
-@Java110Listener("deleteAgentInfoListener")
-@Transactional
-public class DeleteAgentInfoListener extends AbstractAgentBusinessServiceDataFlowListener {
-
-    private final static Logger logger = LoggerFactory.getLogger(DeleteAgentInfoListener.class);
-    @Autowired
-    IAgentServiceDao agentServiceDaoImpl;
-
-    @Override
-    public int getOrder() {
-        return 3;
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeConstant.SERVICE_CODE_DELETE_STORE_INFO;
-    }
-
-    /**
-     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
-     * @param dataFlowContext 数据对象
-     * @param business 当前业务对象
-     */
-    @Override
-    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
-        JSONObject data = business.getDatas();
-
-        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
-
-        //处理 businessAgent 节点 按理这里不应该处理,程序上支持,以防真有这种业务
-        if(data.containsKey("businessAgent")){
-            JSONObject businessAgent = data.getJSONObject("businessAgent");
-            doBusinessAgent(business,businessAgent);
-            dataFlowContext.addParamOut("agentId",businessAgent.getString("agentId"));
-        }
-
-        if(data.containsKey("businessAgentAttr")){
-            JSONArray businessAgentAttrs = data.getJSONArray("businessAgentAttr");
-            doSaveBusinessAgentAttrs(business,businessAgentAttrs);
-        }
-
-        if(data.containsKey("businessAgentPhoto")){
-            JSONArray businessAgentPhotos = data.getJSONArray("businessAgentPhoto");
-            doBusinessAgentPhoto(business,businessAgentPhotos);
-        }
-
-        if(data.containsKey("businessAgentCerdentials")){
-            JSONArray businessAgentCerdentialses = data.getJSONArray("businessAgentCerdentials");
-            doBusinessAgentCerdentials(business,businessAgentCerdentialses);
-        }
-    }
-
-    /**
-     * 删除 instance数据
-     * @param dataFlowContext 数据对象
-     * @param business 当前业务对象
-     */
-    @Override
-    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
-        String bId = business.getbId();
-        //Assert.hasLength(bId,"请求报文中没有包含 bId");
-
-        //代理商信息
-        Map info = new HashMap();
-        info.put("bId",business.getbId());
-        info.put("operate",StatusConstant.OPERATE_DEL);
-
-        //代理商信息
-        Map businessAgentInfo = agentServiceDaoImpl.getBusinessAgentInfo(info);
-        if( businessAgentInfo != null && !businessAgentInfo.isEmpty()) {
-            flushBusinessAgentInfo(businessAgentInfo,StatusConstant.STATUS_CD_INVALID);
-            agentServiceDaoImpl.updateAgentInfoInstance(businessAgentInfo);
-            dataFlowContext.addParamOut("agentId",businessAgentInfo.get("agent_id"));
-        }
-        //代理商属性
-        List<Map> businessAgentAttrs = agentServiceDaoImpl.getBusinessAgentAttrs(info);
-        if(businessAgentAttrs != null && businessAgentAttrs.size() > 0) {
-            for(Map businessAgentAttr : businessAgentAttrs) {
-                flushBusinessAgentAttr(businessAgentAttr,StatusConstant.STATUS_CD_INVALID);
-                agentServiceDaoImpl.updateAgentAttrInstance(businessAgentAttr);
-            }
-        }
-        //代理商照片
-        List<Map> businessAgentPhotos = agentServiceDaoImpl.getBusinessAgentPhoto(info);
-        if(businessAgentPhotos != null && businessAgentPhotos.size() >0){
-            for(Map businessAgentPhoto : businessAgentPhotos) {
-                flushBusinessAgentPhoto(businessAgentPhoto,StatusConstant.STATUS_CD_INVALID);
-                agentServiceDaoImpl.updateAgentPhotoInstance(businessAgentPhoto);
-            }
-        }
-        //代理商证件
-        List<Map> businessAgentCerdentialses = agentServiceDaoImpl.getBusinessAgentCerdentials(info);
-        if(businessAgentCerdentialses != null && businessAgentCerdentialses.size()>0){
-            for(Map businessAgentCerdentials : businessAgentCerdentialses) {
-                flushBusinessAgentCredentials(businessAgentCerdentials,StatusConstant.STATUS_CD_INVALID);
-                agentServiceDaoImpl.updateAgentCerdentailsInstance(businessAgentCerdentials);
-            }
-        }
-    }
-
-    /**
-     * 撤单
-     * 从business表中查询到DEL的数据 将instance中的数据更新回来
-     * @param dataFlowContext 数据对象
-     * @param business 当前业务对象
-     */
-    @Override
-    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
-        String bId = business.getbId();
-        //Assert.hasLength(bId,"请求报文中没有包含 bId");
-        Map info = new HashMap();
-        info.put("bId",bId);
-        info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
-
-        Map delInfo = new HashMap();
-        delInfo.put("bId",business.getbId());
-        delInfo.put("operate",StatusConstant.OPERATE_DEL);
-        //代理商信息
-        Map agentInfo = agentServiceDaoImpl.getAgentInfo(info);
-        if(agentInfo != null && !agentInfo.isEmpty()){
-
-            //代理商信息
-            Map businessAgentInfo = agentServiceDaoImpl.getBusinessAgentInfo(delInfo);
-            //除非程序出错了,这里不会为空
-            if(businessAgentInfo == null || businessAgentInfo.isEmpty()){
-                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent),程序内部异常,请检查! "+delInfo);
-            }
-
-            flushBusinessAgentInfo(businessAgentInfo,StatusConstant.STATUS_CD_VALID);
-            agentServiceDaoImpl.updateAgentInfoInstance(businessAgentInfo);
-            dataFlowContext.addParamOut("agentId",agentInfo.get("agent_id"));
-        }
-
-        //代理商属性
-        List<Map> agentAttrs = agentServiceDaoImpl.getAgentAttrs(info);
-        if(agentAttrs != null && agentAttrs.size()>0){
-
-            List<Map> businessAgentAttrs = agentServiceDaoImpl.getBusinessAgentAttrs(delInfo);
-            //除非程序出错了,这里不会为空
-            if(businessAgentAttrs == null || businessAgentAttrs.size() ==0 ){
-                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent_attr),程序内部异常,请检查! "+delInfo);
-            }
-            for(Map businessAgentAttr : businessAgentAttrs) {
-                flushBusinessAgentAttr(businessAgentAttr,StatusConstant.STATUS_CD_VALID);
-                agentServiceDaoImpl.updateAgentAttrInstance(businessAgentAttr);
-            }
-        }
-
-        //代理商照片
-        List<Map> agentPhotos = agentServiceDaoImpl.getAgentPhoto(info);
-        if(agentPhotos != null && agentPhotos.size()>0){
-            List<Map> businessAgentPhotos = agentServiceDaoImpl.getBusinessAgentPhoto(delInfo);
-            //除非程序出错了,这里不会为空
-            if(businessAgentPhotos == null || businessAgentPhotos.size() ==0 ){
-                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent_photo),程序内部异常,请检查! "+delInfo);
-            }
-            for(Map businessAgentPhoto : businessAgentPhotos) {
-                flushBusinessAgentPhoto(businessAgentPhoto,StatusConstant.STATUS_CD_VALID);
-                agentServiceDaoImpl.updateAgentPhotoInstance(businessAgentPhoto);
-            }
-        }
-
-        //代理商属性
-        List<Map> agentCerdentialses = agentServiceDaoImpl.getAgentCerdentials(info);
-        if(agentCerdentialses != null && agentCerdentialses.size()>0){
-            List<Map> businessAgentCerdentialses = agentServiceDaoImpl.getBusinessAgentCerdentials(delInfo);
-            //除非程序出错了,这里不会为空
-            if(businessAgentCerdentialses == null || businessAgentCerdentialses.size() ==0 ){
-                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent_cerdentials),程序内部异常,请检查! "+delInfo);
-            }
-            for(Map businessAgentCerdentials : businessAgentCerdentialses) {
-                flushBusinessAgentCredentials(businessAgentCerdentials,StatusConstant.STATUS_CD_VALID);
-                agentServiceDaoImpl.updateAgentCerdentailsInstance(businessAgentCerdentials);
-            }
-        }
-    }
-
-    /**
-     * 保存代理商照片
-     * @param business 业务对象
-     * @param businessAgentPhotos 代理商照片
-     */
-    private void doBusinessAgentPhoto(Business business, JSONArray businessAgentPhotos) {
-
-        for(int businessAgentPhotoIndex = 0 ;businessAgentPhotoIndex < businessAgentPhotos.size();businessAgentPhotoIndex++) {
-            JSONObject businessAgentPhoto = businessAgentPhotos.getJSONObject(businessAgentPhotoIndex);
-            Assert.jsonObjectHaveKey(businessAgentPhoto, "agentId", "businessAgentPhoto 节点下没有包含 agentId 节点");
-
-            if (businessAgentPhoto.getString("agentPhotoId").startsWith("-")) {
-                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"agentPhotoId 错误,不能自动生成(必须已经存在的agentPhotoId)"+businessAgentPhoto);
-            }
-
-            autoSaveDelBusinessAgentPhoto(business,businessAgentPhoto);
-        }
-    }
-
-    /**
-     * 处理 businessAgent 节点
-     * @param business 总的数据节点
-     * @param businessAgent 代理商节点
-     */
-    private void doBusinessAgent(Business business,JSONObject businessAgent){
-
-        Assert.jsonObjectHaveKey(businessAgent,"agentId","businessAgent 节点下没有包含 agentId 节点");
-
-        if(businessAgent.getString("agentId").startsWith("-")){
-            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"agentId 错误,不能自动生成(必须已经存在的agentId)"+businessAgent);
-        }
-        //自动插入DEL
-        autoSaveDelBusinessAgent(business,businessAgent);
-    }
-
-
-
-    /**
-     * 保存代理商属性信息
-     * @param business 当前业务
-     * @param businessAgentAttrs 代理商属性
-     */
-    private void doSaveBusinessAgentAttrs(Business business,JSONArray businessAgentAttrs){
-        JSONObject data = business.getDatas();
-
-        for(int agentAttrIndex = 0 ; agentAttrIndex < businessAgentAttrs.size();agentAttrIndex ++){
-            JSONObject agentAttr = businessAgentAttrs.getJSONObject(agentAttrIndex);
-            Assert.jsonObjectHaveKey(agentAttr,"attrId","businessAgentAttr 节点下没有包含 attrId 节点");
-            if(agentAttr.getString("attrId").startsWith("-")){
-                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+agentAttr);
-            }
-
-            autoSaveDelBusinessAgentAttr(business,agentAttr);
-        }
-    }
-
-
-    /**
-     * 保存 代理商证件 信息
-     * @param business 当前业务
-     * @param businessAgentCerdentialses 代理商证件
-     */
-    private void doBusinessAgentCerdentials(Business business, JSONArray businessAgentCerdentialses) {
-
-        Map info = null;
-        Map currentAgentCerdentials = null;
-        for(int businessAgentCerdentialsIndex = 0 ; businessAgentCerdentialsIndex < businessAgentCerdentialses.size() ; businessAgentCerdentialsIndex ++) {
-            JSONObject businessAgentCerdentials = businessAgentCerdentialses.getJSONObject(businessAgentCerdentialsIndex);
-            Assert.jsonObjectHaveKey(businessAgentCerdentials, "agentId", "businessAgentPhoto 节点下没有包含 agentId 节点");
-
-            if (businessAgentCerdentials.getString("agentCerdentialsId").startsWith("-")) {
-                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"agentPhotoId 错误,不能自动生成(必须已经存在的agentPhotoId)"+businessAgentCerdentials);
-            }
-
-            autoSaveDelBusinessAgentCerdentials(business,businessAgentCerdentials);
-        }
-    }
-
-    public IAgentServiceDao getAgentServiceDaoImpl() {
-        return agentServiceDaoImpl;
-    }
-
-    public void setAgentServiceDaoImpl(IAgentServiceDao agentServiceDaoImpl) {
-        this.agentServiceDaoImpl = agentServiceDaoImpl;
-    }
-}

+ 148 - 0
AgentService/src/main/java/com/java110/agent/listener/DeleteAgentPhotoListener.java

@@ -0,0 +1,148 @@
+package com.java110.agent.listener;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.agent.dao.IAgentServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 删除代理商信息 侦听
+ *
+ * 处理节点
+ * 3、businessAgentPhoto:[{}] 代理商照片信息节点
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("deleteAgentPhotoListener")
+@Transactional
+public class DeleteAgentPhotoListener extends AbstractAgentBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(DeleteAgentPhotoListener.class);
+    @Autowired
+    IAgentServiceDao agentServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 3;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_DELETE_AGENT_PHOTO;
+    }
+
+    /**
+     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+        if(data.containsKey("businessAgentPhoto")){
+            JSONArray businessAgentPhotos = data.getJSONArray("businessAgentPhoto");
+            doBusinessAgentPhoto(business,businessAgentPhotos);
+        }
+    }
+
+    /**
+     * 删除 instance数据
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+
+        //代理商信息
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_DEL);
+        //代理商照片
+        List<Map> businessAgentPhotos = agentServiceDaoImpl.getBusinessAgentPhoto(info);
+        if(businessAgentPhotos != null && businessAgentPhotos.size() >0){
+            for(Map businessAgentPhoto : businessAgentPhotos) {
+                flushBusinessAgentPhoto(businessAgentPhoto,StatusConstant.STATUS_CD_INVALID);
+                agentServiceDaoImpl.updateAgentPhotoInstance(businessAgentPhoto);
+            }
+        }
+    }
+
+    /**
+     * 撤单
+     * 从business表中查询到DEL的数据 将instance中的数据更新回来
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+
+        Map delInfo = new HashMap();
+        delInfo.put("bId",business.getbId());
+        delInfo.put("operate",StatusConstant.OPERATE_DEL);
+
+        //代理商照片
+        List<Map> agentPhotos = agentServiceDaoImpl.getAgentPhoto(info);
+        if(agentPhotos != null && agentPhotos.size()>0){
+            List<Map> businessAgentPhotos = agentServiceDaoImpl.getBusinessAgentPhoto(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessAgentPhotos == null || businessAgentPhotos.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent_photo),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessAgentPhoto : businessAgentPhotos) {
+                flushBusinessAgentPhoto(businessAgentPhoto,StatusConstant.STATUS_CD_VALID);
+                agentServiceDaoImpl.updateAgentPhotoInstance(businessAgentPhoto);
+            }
+        }
+
+    }
+
+    /**
+     * 保存代理商照片
+     * @param business 业务对象
+     * @param businessAgentPhotos 代理商照片
+     */
+    private void doBusinessAgentPhoto(Business business, JSONArray businessAgentPhotos) {
+
+        for(int businessAgentPhotoIndex = 0 ;businessAgentPhotoIndex < businessAgentPhotos.size();businessAgentPhotoIndex++) {
+            JSONObject businessAgentPhoto = businessAgentPhotos.getJSONObject(businessAgentPhotoIndex);
+            Assert.jsonObjectHaveKey(businessAgentPhoto, "agentPhotoId", "businessAgentPhoto 节点下没有包含 agentPhotoId 节点");
+
+            if (businessAgentPhoto.getString("agentPhotoId").startsWith("-")) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"agentPhotoId 错误,不能自动生成(必须已经存在的agentPhotoId)"+businessAgentPhoto);
+            }
+
+            autoSaveDelBusinessAgentPhoto(business,businessAgentPhoto);
+        }
+    }
+
+    public IAgentServiceDao getAgentServiceDaoImpl() {
+        return agentServiceDaoImpl;
+    }
+
+    public void setAgentServiceDaoImpl(IAgentServiceDao agentServiceDaoImpl) {
+        this.agentServiceDaoImpl = agentServiceDaoImpl;
+    }
+}

+ 152 - 0
AgentService/src/main/java/com/java110/agent/listener/DeleteAgentUserListener.java

@@ -0,0 +1,152 @@
+package com.java110.agent.listener;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.agent.dao.IAgentServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 删除代理商信息 侦听
+ *
+ * 处理节点
+ * 3、businessAgentUser:[{}] 代理商照片信息节点
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("deleteAgentUserListener")
+@Transactional
+public class DeleteAgentUserListener extends AbstractAgentBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(DeleteAgentUserListener.class);
+    @Autowired
+    IAgentServiceDao agentServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 3;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_DELETE_AGENT_USER;
+    }
+
+    /**
+     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        if(data.containsKey("businessAgentUser")){
+            JSONArray businessAgentUsers = data.getJSONArray("businessAgentUser");
+            doBusinessAgentUser(business,businessAgentUsers);
+        }
+
+    }
+
+    /**
+     * 删除 instance数据
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+
+        //代理商信息
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_DEL);
+
+
+        //代理商照片
+        List<Map> businessAgentUsers = agentServiceDaoImpl.getBusinessAgentUser(info);
+        if(businessAgentUsers != null && businessAgentUsers.size() >0){
+            for(Map businessAgentUser : businessAgentUsers) {
+                flushBusinessAgentUser(businessAgentUser,StatusConstant.STATUS_CD_INVALID);
+                agentServiceDaoImpl.updateAgentUserInstance(businessAgentUser);
+            }
+        }
+    }
+
+    /**
+     * 撤单
+     * 从business表中查询到DEL的数据 将instance中的数据更新回来
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+
+        Map delInfo = new HashMap();
+        delInfo.put("bId",business.getbId());
+        delInfo.put("operate",StatusConstant.OPERATE_DEL);
+
+
+        //代理商照片
+        List<Map> agentUsers = agentServiceDaoImpl.getAgentUser(info);
+        if(agentUsers != null && agentUsers.size()>0){
+            List<Map> businessAgentUsers = agentServiceDaoImpl.getBusinessAgentUser(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessAgentUsers == null || businessAgentUsers.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent_photo),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessAgentUser : businessAgentUsers) {
+                flushBusinessAgentUser(businessAgentUser,StatusConstant.STATUS_CD_VALID);
+                agentServiceDaoImpl.updateAgentUserInstance(businessAgentUser);
+            }
+        }
+    }
+
+    /**
+     * 保存代理商照片
+     * @param business 业务对象
+     * @param businessAgentUsers 代理商照片
+     */
+    private void doBusinessAgentUser(Business business, JSONArray businessAgentUsers) {
+
+        for(int businessAgentUserIndex = 0 ;businessAgentUserIndex < businessAgentUsers.size();businessAgentUserIndex++) {
+            JSONObject businessAgentUser = businessAgentUsers.getJSONObject(businessAgentUserIndex);
+            Assert.jsonObjectHaveKey(businessAgentUser, "agentUserId", "businessAgentUser 节点下没有包含 agentUserId 节点");
+
+            if (businessAgentUser.getString("agentUserId").startsWith("-")) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"agentUserId 错误,不能自动生成(必须已经存在的agentUserId)"+businessAgentUser);
+            }
+
+            autoSaveDelBusinessAgentUser(business,businessAgentUser);
+        }
+    }
+
+    public IAgentServiceDao getAgentServiceDaoImpl() {
+        return agentServiceDaoImpl;
+    }
+
+    public void setAgentServiceDaoImpl(IAgentServiceDao agentServiceDaoImpl) {
+        this.agentServiceDaoImpl = agentServiceDaoImpl;
+    }
+}

+ 151 - 0
AgentService/src/main/java/com/java110/agent/listener/SaveAgentCerdentialsListener.java

@@ -0,0 +1,151 @@
+package com.java110.agent.listener;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.common.util.DateUtil;
+import com.java110.common.util.StringUtil;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.entity.center.Business;
+import com.java110.agent.dao.IAgentServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 保存 用户信息 侦听
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("saveAgentCerdentialsListener")
+@Transactional
+public class SaveAgentCerdentialsListener extends AbstractAgentBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(SaveAgentCerdentialsListener.class);
+
+    @Autowired
+    IAgentServiceDao agentServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_SAVE_AGENT_CERDENTIALS;
+    }
+
+    /**
+     * 保存代理商信息 business 表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        if(!data.containsKey("businessAgentCerdentials")){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"没有businessAgentCerdentials节点");
+        }
+        JSONArray businessAgentCerdentialses = data.getJSONArray("businessAgentCerdentials");
+        doBusinessAgentCerdentials(business,businessAgentCerdentialses);
+    }
+
+    /**
+     * business 数据转移到 instance
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_ADD);
+
+        //代理商证件
+        List<Map> businessAgentCerdentialses = agentServiceDaoImpl.getBusinessAgentCerdentials(info);
+        if(businessAgentCerdentialses != null && businessAgentCerdentialses.size()>0){
+            agentServiceDaoImpl.saveAgentCerdentialsInstance(info);
+        }
+    }
+
+    /**
+     * 撤单
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        Map paramIn = new HashMap();
+        paramIn.put("bId",bId);
+        paramIn.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+        //代理商属性
+        List<Map> agentCerdentialses = agentServiceDaoImpl.getAgentCerdentials(info);
+        if(agentCerdentialses != null && agentCerdentialses.size()>0){
+            agentServiceDaoImpl.updateAgentCerdentailsInstance(paramIn);
+        }
+    }
+
+
+    /**
+     * 保存 代理商证件 信息
+     * @param business 当前业务
+     * @param businessAgentCerdentialses 代理商证件
+     */
+    private void doBusinessAgentCerdentials(Business business, JSONArray businessAgentCerdentialses) {
+        for(int businessAgentCerdentialsIndex = 0 ; businessAgentCerdentialsIndex < businessAgentCerdentialses.size() ; businessAgentCerdentialsIndex ++) {
+            JSONObject businessAgentCerdentials = businessAgentCerdentialses.getJSONObject(businessAgentCerdentialsIndex);
+            Assert.jsonObjectHaveKey(businessAgentCerdentials, "agentId", "businessAgentPhoto 节点下没有包含 agentId 节点");
+
+            if (businessAgentCerdentials.getString("agentCerdentialsId").startsWith("-")) {
+                String agentAgentId = GenerateCodeFactory.getAgentCerdentialsId();
+                businessAgentCerdentials.put("agentCerdentialsId", agentAgentId);
+            }
+            Date validityPeriod = null;
+            try {
+                if(StringUtil.isNullOrNone(businessAgentCerdentials.getString("validityPeriod"))){
+                    validityPeriod = DateUtil.getLastDate();
+                }else {
+                    validityPeriod = DateUtil.getDateFromString(businessAgentCerdentials.getString("validityPeriod"), DateUtil.DATE_FORMATE_STRING_B);
+                }
+            } catch (ParseException e) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"传入参数 validityPeriod 格式不正确,请填写 "+DateUtil.DATE_FORMATE_STRING_B +" 格式,"+businessAgentCerdentials);
+            }
+            businessAgentCerdentials.put("validityPeriod",validityPeriod);
+            businessAgentCerdentials.put("bId", business.getbId());
+            businessAgentCerdentials.put("operate", StatusConstant.OPERATE_ADD);
+            //保存代理商信息
+            agentServiceDaoImpl.saveBusinessAgentCerdentials(businessAgentCerdentials);
+        }
+    }
+
+
+    public IAgentServiceDao getAgentServiceDaoImpl() {
+        return agentServiceDaoImpl;
+    }
+
+    public void setAgentServiceDaoImpl(IAgentServiceDao agentServiceDaoImpl) {
+        this.agentServiceDaoImpl = agentServiceDaoImpl;
+    }
+}

+ 18 - 109
AgentService/src/main/java/com/java110/agent/listener/SaveAgentInfoListener.java

@@ -2,13 +2,9 @@ package com.java110.agent.listener;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.java110.common.constant.ResponseConstant;
 import com.java110.common.constant.ServiceCodeConstant;
 import com.java110.common.constant.StatusConstant;
-import com.java110.common.exception.ListenerExecuteException;
 import com.java110.common.util.Assert;
-import com.java110.common.util.DateUtil;
-import com.java110.common.util.StringUtil;
 import com.java110.core.annotation.Java110Listener;
 import com.java110.core.context.DataFlowContext;
 import com.java110.core.factory.GenerateCodeFactory;
@@ -19,14 +15,12 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.text.ParseException;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 /**
- * 保存 用户信息 侦听
+ * 保存 代理商信息 侦听
  * Created by wuxw on 2018/5/18.
  */
 @Java110Listener("saveAgentInfoListener")
@@ -45,7 +39,7 @@ public class SaveAgentInfoListener extends AbstractAgentBusinessServiceDataFlowL
 
     @Override
     public String getServiceCode() {
-        return ServiceCodeConstant.SERVICE_CODE_SAVE_STORE_INFO;
+        return ServiceCodeConstant.SERVICE_CODE_SAVE_AGENT_INFO;
     }
 
     /**
@@ -69,16 +63,6 @@ public class SaveAgentInfoListener extends AbstractAgentBusinessServiceDataFlowL
             JSONArray businessAgentAttrs = data.getJSONArray("businessAgentAttr");
             doSaveBusinessAgentAttrs(business,businessAgentAttrs);
         }
-
-        if(data.containsKey("businessAgentPhoto")){
-            JSONArray businessAgentPhotos = data.getJSONArray("businessAgentPhoto");
-            doBusinessAgentPhoto(business,businessAgentPhotos);
-        }
-
-        if(data.containsKey("businessAgentCerdentials")){
-            JSONArray businessAgentCerdentialses = data.getJSONArray("businessAgentCerdentials");
-            doBusinessAgentCerdentials(business,businessAgentCerdentialses);
-        }
     }
 
     /**
@@ -105,16 +89,6 @@ public class SaveAgentInfoListener extends AbstractAgentBusinessServiceDataFlowL
         if(businessAgentAttrs != null && businessAgentAttrs.size() > 0) {
             agentServiceDaoImpl.saveAgentAttrsInstance(info);
         }
-        //代理商照片
-        List<Map> businessAgentPhotos = agentServiceDaoImpl.getBusinessAgentPhoto(info);
-        if(businessAgentPhotos != null && businessAgentPhotos.size() >0){
-            agentServiceDaoImpl.saveAgentPhotoInstance(info);
-        }
-        //代理商证件
-        List<Map> businessAgentCerdentialses = agentServiceDaoImpl.getBusinessAgentCerdentials(info);
-        if(businessAgentCerdentialses != null && businessAgentCerdentialses.size()>0){
-            agentServiceDaoImpl.saveAgentCerdentialsInstance(info);
-        }
     }
 
     /**
@@ -145,41 +119,9 @@ public class SaveAgentInfoListener extends AbstractAgentBusinessServiceDataFlowL
         if(agentAttrs != null && agentAttrs.size()>0){
             agentServiceDaoImpl.updateAgentAttrInstance(paramIn);
         }
-
-        //代理商照片
-        List<Map> agentPhotos = agentServiceDaoImpl.getAgentPhoto(info);
-        if(agentPhotos != null && agentPhotos.size()>0){
-            agentServiceDaoImpl.updateAgentPhotoInstance(paramIn);
-        }
-
-        //代理商属性
-        List<Map> agentCerdentialses = agentServiceDaoImpl.getAgentCerdentials(info);
-        if(agentCerdentialses != null && agentCerdentialses.size()>0){
-            agentServiceDaoImpl.updateAgentCerdentailsInstance(paramIn);
-        }
     }
 
-    /**
-     * 保存代理商照片
-     * @param business 业务对象
-     * @param businessAgentPhotos 代理商照片
-     */
-    private void doBusinessAgentPhoto(Business business, JSONArray businessAgentPhotos) {
-
-        for(int businessAgentPhotoIndex = 0 ;businessAgentPhotoIndex < businessAgentPhotos.size();businessAgentPhotoIndex++) {
-            JSONObject businessAgentPhoto = businessAgentPhotos.getJSONObject(businessAgentPhotoIndex);
-            Assert.jsonObjectHaveKey(businessAgentPhoto, "agentId", "businessAgentPhoto 节点下没有包含 agentId 节点");
 
-            if (businessAgentPhoto.getString("agentPhotoId").startsWith("-")) {
-                String agentPhotoId = GenerateCodeFactory.getAgentPhotoId();
-                businessAgentPhoto.put("agentPhotoId", agentPhotoId);
-            }
-            businessAgentPhoto.put("bId", business.getbId());
-            businessAgentPhoto.put("operate", StatusConstant.OPERATE_ADD);
-            //保存代理商信息
-            agentServiceDaoImpl.saveBusinessAgentPhoto(businessAgentPhoto);
-        }
-    }
 
     /**
      * 处理 businessAgent 节点
@@ -230,39 +172,6 @@ public class SaveAgentInfoListener extends AbstractAgentBusinessServiceDataFlowL
     }
 
 
-    /**
-     * 保存 代理商证件 信息
-     * @param business 当前业务
-     * @param businessAgentCerdentialses 代理商证件
-     */
-    private void doBusinessAgentCerdentials(Business business, JSONArray businessAgentCerdentialses) {
-        for(int businessAgentCerdentialsIndex = 0 ; businessAgentCerdentialsIndex < businessAgentCerdentialses.size() ; businessAgentCerdentialsIndex ++) {
-            JSONObject businessAgentCerdentials = businessAgentCerdentialses.getJSONObject(businessAgentCerdentialsIndex);
-            Assert.jsonObjectHaveKey(businessAgentCerdentials, "agentId", "businessAgentPhoto 节点下没有包含 agentId 节点");
-
-            if (businessAgentCerdentials.getString("agentCerdentialsId").startsWith("-")) {
-                String agentPhotoId = GenerateCodeFactory.getAgentCerdentialsId();
-                businessAgentCerdentials.put("agentCerdentialsId", agentPhotoId);
-            }
-            Date validityPeriod = null;
-            try {
-                if(StringUtil.isNullOrNone(businessAgentCerdentials.getString("validityPeriod"))){
-                    validityPeriod = DateUtil.getLastDate();
-                }else {
-                    validityPeriod = DateUtil.getDateFromString(businessAgentCerdentials.getString("validityPeriod"), DateUtil.DATE_FORMATE_STRING_B);
-                }
-            } catch (ParseException e) {
-                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"传入参数 validityPeriod 格式不正确,请填写 "+DateUtil.DATE_FORMATE_STRING_B +" 格式,"+businessAgentCerdentials);
-            }
-            businessAgentCerdentials.put("validityPeriod",validityPeriod);
-            businessAgentCerdentials.put("bId", business.getbId());
-            businessAgentCerdentials.put("operate", StatusConstant.OPERATE_ADD);
-            //保存代理商信息
-            agentServiceDaoImpl.saveBusinessAgentCerdentials(businessAgentCerdentials);
-        }
-    }
-
-
 
     /**
      * 刷新 代理商ID
@@ -281,22 +190,22 @@ public class SaveAgentInfoListener extends AbstractAgentBusinessServiceDataFlowL
                 businessAgentAttr.put("agentId", agentId);
             }
         }
-        //刷 是代理商照片 的 agentId
-        if(data.containsKey("businessAgentPhoto")) {
-            JSONArray businessAgentPhotos = data.getJSONArray("businessAgentPhoto");
-            for(int businessAgentPhotoIndex = 0;businessAgentPhotoIndex < businessAgentPhotos.size();businessAgentPhotoIndex++) {
-                JSONObject businessAgentPhoto = businessAgentPhotos.getJSONObject(businessAgentPhotoIndex);
-                businessAgentPhoto.put("agentId", agentId);
-            }
-        }
-        //刷 代理商证件 的agentId
-        if(data.containsKey("businessAgentCerdentials")) {
-            JSONArray businessAgentCerdentialses = data.getJSONArray("businessAgentCerdentials");
-            for(int businessAgentCerdentialsIndex = 0;businessAgentCerdentialsIndex < businessAgentCerdentialses.size();businessAgentCerdentialsIndex++) {
-                JSONObject businessAgentCerdentials = businessAgentCerdentialses.getJSONObject(businessAgentCerdentialsIndex);
-                businessAgentCerdentials.put("agentId", agentId);
-            }
-        }
+//        //刷 是代理商照片 的 agentId
+//        if(data.containsKey("businessAgentPhoto")) {
+//            JSONArray businessAgentPhotos = data.getJSONArray("businessAgentPhoto");
+//            for(int businessAgentPhotoIndex = 0;businessAgentPhotoIndex < businessAgentPhotos.size();businessAgentPhotoIndex++) {
+//                JSONObject businessAgentPhoto = businessAgentPhotos.getJSONObject(businessAgentPhotoIndex);
+//                businessAgentPhoto.put("agentId", agentId);
+//            }
+//        }
+//        //刷 代理商证件 的agentId
+//        if(data.containsKey("businessAgentCerdentials")) {
+//            JSONArray businessAgentCerdentialses = data.getJSONArray("businessAgentCerdentials");
+//            for(int businessAgentCerdentialsIndex = 0;businessAgentCerdentialsIndex < businessAgentCerdentialses.size();businessAgentCerdentialsIndex++) {
+//                JSONObject businessAgentCerdentials = businessAgentCerdentialses.getJSONObject(businessAgentCerdentialsIndex);
+//                businessAgentCerdentials.put("agentId", agentId);
+//            }
+//        }
     }
 
 

+ 139 - 0
AgentService/src/main/java/com/java110/agent/listener/SaveAgentPhotoListener.java

@@ -0,0 +1,139 @@
+package com.java110.agent.listener;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.entity.center.Business;
+import com.java110.agent.dao.IAgentServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 保存 用户信息 侦听
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("saveAgentPhotoListener")
+@Transactional
+public class SaveAgentPhotoListener extends AbstractAgentBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(SaveAgentPhotoListener.class);
+
+    @Autowired
+    IAgentServiceDao agentServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_SAVE_AGENT_PHOTO;
+    }
+
+    /**
+     * 保存代理商信息 business 表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        if(!data.containsKey("businessAgentPhoto")){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"没有businessAgentPhoto节点");
+        }
+
+        JSONArray businessAgentPhotos = data.getJSONArray("businessAgentPhoto");
+        doBusinessAgentPhoto(business,businessAgentPhotos);
+    }
+
+    /**
+     * business 数据转移到 instance
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_ADD);
+
+        //代理商照片
+        List<Map> businessAgentPhotos = agentServiceDaoImpl.getBusinessAgentPhoto(info);
+        if(businessAgentPhotos != null && businessAgentPhotos.size() >0){
+            agentServiceDaoImpl.saveAgentPhotoInstance(info);
+        }
+    }
+
+    /**
+     * 撤单
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        Map paramIn = new HashMap();
+        paramIn.put("bId",bId);
+        paramIn.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+
+        //代理商照片
+        List<Map> agentPhotos = agentServiceDaoImpl.getAgentPhoto(info);
+        if(agentPhotos != null && agentPhotos.size()>0){
+            agentServiceDaoImpl.updateAgentPhotoInstance(paramIn);
+        }
+    }
+
+    /**
+     * 保存代理商照片
+     * @param business 业务对象
+     * @param businessAgentPhotos 代理商照片
+     */
+    private void doBusinessAgentPhoto(Business business, JSONArray businessAgentPhotos) {
+
+        for(int businessAgentPhotoIndex = 0 ;businessAgentPhotoIndex < businessAgentPhotos.size();businessAgentPhotoIndex++) {
+            JSONObject businessAgentPhoto = businessAgentPhotos.getJSONObject(businessAgentPhotoIndex);
+            Assert.jsonObjectHaveKey(businessAgentPhoto, "agentId", "businessAgentPhoto 节点下没有包含 agentId 节点");
+
+            if (businessAgentPhoto.getString("agentPhotoId").startsWith("-")) {
+                String agentPhotoId = GenerateCodeFactory.getAgentPhotoId();
+                businessAgentPhoto.put("agentPhotoId", agentPhotoId);
+            }
+            businessAgentPhoto.put("bId", business.getbId());
+            businessAgentPhoto.put("operate", StatusConstant.OPERATE_ADD);
+            //保存代理商信息
+            agentServiceDaoImpl.saveBusinessAgentPhoto(businessAgentPhoto);
+        }
+    }
+
+
+
+    public IAgentServiceDao getAgentServiceDaoImpl() {
+        return agentServiceDaoImpl;
+    }
+
+    public void setAgentServiceDaoImpl(IAgentServiceDao agentServiceDaoImpl) {
+        this.agentServiceDaoImpl = agentServiceDaoImpl;
+    }
+}

+ 244 - 0
AgentService/src/main/java/com/java110/agent/listener/SaveAgentUserListener.java

@@ -0,0 +1,244 @@
+package com.java110.agent.listener;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.common.util.DateUtil;
+import com.java110.common.util.StringUtil;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.entity.center.Business;
+import com.java110.agent.dao.IAgentServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 保存 用户信息 侦听
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("saveAgentUserListener")
+@Transactional
+public class SaveAgentUserListener extends AbstractAgentBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(SaveAgentUserListener.class);
+
+    @Autowired
+    IAgentServiceDao agentServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_SAVE_AGENT_USER;
+    }
+
+    /**
+     * 保存代理商信息 business 表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessAgent 节点
+        if(!data.containsKey("businessAgentUser")){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"没有businessAgentUser节点");
+        }
+
+
+        JSONArray businessAgentUsers = data.getJSONArray("businessAgentUser");
+        doBusinessAgentUser(business,businessAgentUsers);
+    }
+
+    /**
+     * business 数据转移到 instance
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_ADD);
+
+        //代理商用户
+        List<Map> businessAgentUsers = agentServiceDaoImpl.getBusinessAgentUser(info);
+        if(businessAgentUsers != null && businessAgentUsers.size() >0){
+            agentServiceDaoImpl.saveAgentUserInstance(info);
+        }
+    }
+
+    /**
+     * 撤单
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        Map paramIn = new HashMap();
+        paramIn.put("bId",bId);
+        paramIn.put("statusCd",StatusConstant.STATUS_CD_INVALID);
+        //代理商照片
+        List<Map> agentUsers = agentServiceDaoImpl.getAgentUser(info);
+        if(agentUsers != null && agentUsers.size()>0){
+            agentServiceDaoImpl.updateAgentUserInstance(paramIn);
+        }
+    }
+
+
+    /**
+     * 处理 businessAgent 节点
+     * @param business 总的数据节点
+     * @param businessAgentUsers 代理商用户节点
+     */
+    private void doBusinessAgentUser(Business business,JSONArray businessAgentUsers){
+
+
+        for(int businessAgentUserIndex = 0 ;businessAgentUserIndex < businessAgentUsers.size();businessAgentUserIndex++) {
+            JSONObject businessAgentUser = businessAgentUsers.getJSONObject(businessAgentUserIndex);
+            Assert.jsonObjectHaveKey(businessAgentUser,"agentId","businessAgentUser 节点下没有包含 agentId 节点");
+            Assert.jsonObjectHaveKey(businessAgentUser,"userId","businessAgentUser 节点下没有包含 userId 节点");
+
+            if(businessAgentUser.getString("agentUserId").startsWith("-")){
+                String agentUserId = GenerateCodeFactory.getAgentUserId();
+                businessAgentUser.put("agentUserId", agentUserId);
+            }
+            businessAgentUser.put("bId",business.getbId());
+            businessAgentUser.put("operate", StatusConstant.OPERATE_ADD);
+            //保存代理商信息
+            agentServiceDaoImpl.saveBusinessAgentUser(businessAgentUser);
+        }
+
+    }
+
+
+
+    /**
+     * 保存代理商属性信息
+     * @param business 当前业务
+     * @param businessAgentAttrs 代理商属性
+     */
+    private void doSaveBusinessAgentAttrs(Business business,JSONArray businessAgentAttrs){
+        JSONObject data = business.getDatas();
+        JSONObject businessAgent = data.getJSONObject("businessAgent");
+        for(int agentAttrIndex = 0 ; agentAttrIndex < businessAgentAttrs.size();agentAttrIndex ++){
+            JSONObject agentAttr = businessAgentAttrs.getJSONObject(agentAttrIndex);
+            Assert.jsonObjectHaveKey(agentAttr,"attrId","businessAgentAttr 节点下没有包含 attrId 节点");
+
+            if(agentAttr.getString("attrId").startsWith("-")){
+                String attrId = GenerateCodeFactory.getAttrId();
+                agentAttr.put("attrId",attrId);
+            }
+
+            agentAttr.put("bId",business.getbId());
+            agentAttr.put("agentId",businessAgent.getString("agentId"));
+            agentAttr.put("operate", StatusConstant.OPERATE_ADD);
+
+            agentServiceDaoImpl.saveBusinessAgentAttr(agentAttr);
+        }
+    }
+
+
+    /**
+     * 保存 代理商证件 信息
+     * @param business 当前业务
+     * @param businessAgentCerdentialses 代理商证件
+     */
+    private void doBusinessAgentCerdentials(Business business, JSONArray businessAgentCerdentialses) {
+        for(int businessAgentCerdentialsIndex = 0 ; businessAgentCerdentialsIndex < businessAgentCerdentialses.size() ; businessAgentCerdentialsIndex ++) {
+            JSONObject businessAgentCerdentials = businessAgentCerdentialses.getJSONObject(businessAgentCerdentialsIndex);
+            Assert.jsonObjectHaveKey(businessAgentCerdentials, "agentId", "businessAgentPhoto 节点下没有包含 agentId 节点");
+
+            if (businessAgentCerdentials.getString("agentCerdentialsId").startsWith("-")) {
+                String agentPhotoId = GenerateCodeFactory.getAgentCerdentialsId();
+                businessAgentCerdentials.put("agentCerdentialsId", agentPhotoId);
+            }
+            Date validityPeriod = null;
+            try {
+                if(StringUtil.isNullOrNone(businessAgentCerdentials.getString("validityPeriod"))){
+                    validityPeriod = DateUtil.getLastDate();
+                }else {
+                    validityPeriod = DateUtil.getDateFromString(businessAgentCerdentials.getString("validityPeriod"), DateUtil.DATE_FORMATE_STRING_B);
+                }
+            } catch (ParseException e) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"传入参数 validityPeriod 格式不正确,请填写 "+DateUtil.DATE_FORMATE_STRING_B +" 格式,"+businessAgentCerdentials);
+            }
+            businessAgentCerdentials.put("validityPeriod",validityPeriod);
+            businessAgentCerdentials.put("bId", business.getbId());
+            businessAgentCerdentials.put("operate", StatusConstant.OPERATE_ADD);
+            //保存代理商信息
+            agentServiceDaoImpl.saveBusinessAgentCerdentials(businessAgentCerdentials);
+        }
+    }
+
+
+
+    /**
+     * 刷新 代理商ID
+     * @param data
+     */
+    private void flushAgentId(JSONObject data) {
+
+        String agentId = GenerateCodeFactory.getAgentId();
+        JSONObject businessAgent = data.getJSONObject("businessAgent");
+        businessAgent.put("agentId",agentId);
+        //刷代理商属性
+        if(data.containsKey("businessAgentAttr")) {
+            JSONArray businessAgentAttrs = data.getJSONArray("businessAgentAttr");
+            for(int businessAgentAttrIndex = 0;businessAgentAttrIndex < businessAgentAttrs.size();businessAgentAttrIndex++) {
+                JSONObject businessAgentAttr = businessAgentAttrs.getJSONObject(businessAgentAttrIndex);
+                businessAgentAttr.put("agentId", agentId);
+            }
+        }
+        //刷 是代理商照片 的 agentId
+        if(data.containsKey("businessAgentPhoto")) {
+            JSONArray businessAgentPhotos = data.getJSONArray("businessAgentPhoto");
+            for(int businessAgentPhotoIndex = 0;businessAgentPhotoIndex < businessAgentPhotos.size();businessAgentPhotoIndex++) {
+                JSONObject businessAgentPhoto = businessAgentPhotos.getJSONObject(businessAgentPhotoIndex);
+                businessAgentPhoto.put("agentId", agentId);
+            }
+        }
+        //刷 代理商证件 的agentId
+        if(data.containsKey("businessAgentCerdentials")) {
+            JSONArray businessAgentCerdentialses = data.getJSONArray("businessAgentCerdentials");
+            for(int businessAgentCerdentialsIndex = 0;businessAgentCerdentialsIndex < businessAgentCerdentialses.size();businessAgentCerdentialsIndex++) {
+                JSONObject businessAgentCerdentials = businessAgentCerdentialses.getJSONObject(businessAgentCerdentialsIndex);
+                businessAgentCerdentials.put("agentId", agentId);
+            }
+        }
+    }
+
+
+    public IAgentServiceDao getAgentServiceDaoImpl() {
+        return agentServiceDaoImpl;
+    }
+
+    public void setAgentServiceDaoImpl(IAgentServiceDao agentServiceDaoImpl) {
+        this.agentServiceDaoImpl = agentServiceDaoImpl;
+    }
+}

+ 155 - 0
AgentService/src/main/java/com/java110/agent/listener/UpdateAgentCerdentialsListener.java

@@ -0,0 +1,155 @@
+package com.java110.agent.listener;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.agent.dao.IAgentServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 修改代理商信息 侦听
+ *
+ * 处理节点
+ * 4、businessAgentCerdentials:[{}] 代理商证件信息节点
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("updateAgentCerdentialsListener")
+@Transactional
+public class UpdateAgentCerdentialsListener extends AbstractAgentBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(UpdateAgentCerdentialsListener.class);
+    @Autowired
+    IAgentServiceDao agentServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 2;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_UPDATE_AGENT_CERDENTIALS;
+    }
+
+    /**
+     * business过程
+     * @param dataFlowContext
+     * @param business
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        if(data.containsKey("businessAgentCerdentials")){
+            JSONArray businessAgentCerdentialses = data.getJSONArray("businessAgentCerdentials");
+            doBusinessAgentCerdentials(business,businessAgentCerdentialses);
+        }
+    }
+
+
+    /**
+     * business to instance 过程
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+
+        JSONObject data = business.getDatas();
+
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_ADD);
+        //代理商证件
+        List<Map> businessAgentCerdentialses = agentServiceDaoImpl.getBusinessAgentCerdentials(info);
+        if(businessAgentCerdentialses != null && businessAgentCerdentialses.size()>0){
+            for(Map businessAgentCerdentials : businessAgentCerdentialses) {
+                flushBusinessAgentCredentials(businessAgentCerdentials,StatusConstant.STATUS_CD_VALID);
+                agentServiceDaoImpl.updateAgentCerdentailsInstance(businessAgentCerdentials);
+            }
+        }
+    }
+
+    /**
+     * 撤单
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        Map delInfo = new HashMap();
+        delInfo.put("bId",business.getbId());
+        delInfo.put("operate",StatusConstant.OPERATE_DEL);
+        //代理商属性
+        List<Map> agentCerdentialses = agentServiceDaoImpl.getAgentCerdentials(info);
+        if(agentCerdentialses != null && agentCerdentialses.size()>0){
+            List<Map> businessAgentCerdentialses = agentServiceDaoImpl.getBusinessAgentCerdentials(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessAgentCerdentialses == null || businessAgentCerdentialses.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent_cerdentials),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessAgentCerdentials : businessAgentCerdentialses) {
+                flushBusinessAgentCredentials(businessAgentCerdentials,StatusConstant.STATUS_CD_VALID);
+                agentServiceDaoImpl.updateAgentCerdentailsInstance(businessAgentCerdentials);
+            }
+        }
+    }
+
+    /**
+     * 保存 代理商证件 信息
+     * @param business 当前业务
+     * @param businessAgentCerdentialses 代理商证件
+     */
+    private void doBusinessAgentCerdentials(Business business, JSONArray businessAgentCerdentialses) {
+
+        for(int businessAgentCerdentialsIndex = 0 ; businessAgentCerdentialsIndex < businessAgentCerdentialses.size() ; businessAgentCerdentialsIndex ++) {
+            JSONObject businessAgentCerdentials = businessAgentCerdentialses.getJSONObject(businessAgentCerdentialsIndex);
+            Assert.jsonObjectHaveKey(businessAgentCerdentials, "agentId", "businessAgentPhoto 节点下没有包含 agentId 节点");
+
+            if (businessAgentCerdentials.getString("agentCerdentialsId").startsWith("-")) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"agentPhotoId 错误,不能自动生成(必须已经存在的agentCerdentialsId)"+businessAgentCerdentials);
+            }
+
+            autoSaveDelBusinessAgentCerdentials(business,businessAgentCerdentials);
+
+            businessAgentCerdentials.put("bId", business.getbId());
+            businessAgentCerdentials.put("operate", StatusConstant.OPERATE_ADD);
+            //保存代理商信息
+            agentServiceDaoImpl.saveBusinessAgentCerdentials(businessAgentCerdentials);
+        }
+    }
+
+    public IAgentServiceDao getAgentServiceDaoImpl() {
+        return agentServiceDaoImpl;
+    }
+
+    public void setAgentServiceDaoImpl(IAgentServiceDao agentServiceDaoImpl) {
+        this.agentServiceDaoImpl = agentServiceDaoImpl;
+    }
+
+
+
+}

+ 2 - 93
AgentService/src/main/java/com/java110/agent/listener/UpdateAgentInfoListener.java

@@ -24,11 +24,8 @@ import java.util.Map;
  * 修改代理商信息 侦听
  *
  * 处理节点
- * 1、businessAgent:{} 代理商基本信息节点
+ * 1、businessAgentInfo:{} 代理商基本信息节点
  * 2、businessAgentAttr:[{}] 代理商属性信息节点
- * 3、businessAgentPhoto:[{}] 代理商照片信息节点
- * 4、businessAgentCerdentials:[{}] 代理商证件信息节点
- * 协议地址 :https://github.com/java110/MicroCommunity/wiki/%E4%BF%AE%E6%94%B9%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF-%E5%8D%8F%E8%AE%AE
  * Created by wuxw on 2018/5/18.
  */
 @Java110Listener("updateAgentInfoListener")
@@ -46,7 +43,7 @@ public class UpdateAgentInfoListener extends AbstractAgentBusinessServiceDataFlo
 
     @Override
     public String getServiceCode() {
-        return ServiceCodeConstant.SERVICE_CODE_UPDATE_STORE_INFO;
+        return ServiceCodeConstant.SERVICE_CODE_UPDATE_AGENT_INFO;
     }
 
     /**
@@ -72,16 +69,6 @@ public class UpdateAgentInfoListener extends AbstractAgentBusinessServiceDataFlo
             JSONArray businessAgentAttrs = data.getJSONArray("businessAgentAttr");
             doSaveBusinessAgentAttrs(business,businessAgentAttrs);
         }
-
-        if(data.containsKey("businessAgentPhoto")){
-            JSONArray businessAgentPhotos = data.getJSONArray("businessAgentPhoto");
-            doBusinessAgentPhoto(business,businessAgentPhotos);
-        }
-
-        if(data.containsKey("businessAgentCerdentials")){
-            JSONArray businessAgentCerdentialses = data.getJSONArray("businessAgentCerdentials");
-            doBusinessAgentCerdentials(business,businessAgentCerdentialses);
-        }
     }
 
 
@@ -178,60 +165,6 @@ public class UpdateAgentInfoListener extends AbstractAgentBusinessServiceDataFlo
                 agentServiceDaoImpl.updateAgentAttrInstance(businessAgentAttr);
             }
         }
-
-        //代理商照片
-        List<Map> agentPhotos = agentServiceDaoImpl.getAgentPhoto(info);
-        if(agentPhotos != null && agentPhotos.size()>0){
-            List<Map> businessAgentPhotos = agentServiceDaoImpl.getBusinessAgentPhoto(delInfo);
-            //除非程序出错了,这里不会为空
-            if(businessAgentPhotos == null || businessAgentPhotos.size() ==0 ){
-                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent_photo),程序内部异常,请检查! "+delInfo);
-            }
-            for(Map businessAgentPhoto : businessAgentPhotos) {
-                flushBusinessAgentPhoto(businessAgentPhoto,StatusConstant.STATUS_CD_VALID);
-                agentServiceDaoImpl.updateAgentPhotoInstance(businessAgentPhoto);
-            }
-        }
-
-        //代理商属性
-        List<Map> agentCerdentialses = agentServiceDaoImpl.getAgentCerdentials(info);
-        if(agentCerdentialses != null && agentCerdentialses.size()>0){
-            List<Map> businessAgentCerdentialses = agentServiceDaoImpl.getBusinessAgentCerdentials(delInfo);
-            //除非程序出错了,这里不会为空
-            if(businessAgentCerdentialses == null || businessAgentCerdentialses.size() ==0 ){
-                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent_cerdentials),程序内部异常,请检查! "+delInfo);
-            }
-            for(Map businessAgentCerdentials : businessAgentCerdentialses) {
-                flushBusinessAgentCredentials(businessAgentCerdentials,StatusConstant.STATUS_CD_VALID);
-                agentServiceDaoImpl.updateAgentCerdentailsInstance(businessAgentCerdentials);
-            }
-        }
-    }
-
-    /**
-     * 保存代理商照片
-     * @param business 业务对象
-     * @param businessAgentPhotos 代理商照片
-     */
-    private void doBusinessAgentPhoto(Business business, JSONArray businessAgentPhotos) {
-
-
-        for(int businessAgentPhotoIndex = 0 ;businessAgentPhotoIndex < businessAgentPhotos.size();businessAgentPhotoIndex++) {
-            JSONObject businessAgentPhoto = businessAgentPhotos.getJSONObject(businessAgentPhotoIndex);
-            Assert.jsonObjectHaveKey(businessAgentPhoto, "agentId", "businessAgentPhoto 节点下没有包含 agentId 节点");
-
-            if (businessAgentPhoto.getString("agentPhotoId").startsWith("-")) {
-                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"agentPhotoId 错误,不能自动生成(必须已经存在的agentPhotoId)"+businessAgentPhoto);
-            }
-
-            //自动保存DEL信息
-            autoSaveDelBusinessAgentPhoto(business,businessAgentPhoto);
-
-            businessAgentPhoto.put("bId", business.getbId());
-            businessAgentPhoto.put("operate", StatusConstant.OPERATE_ADD);
-            //保存代理商信息
-            agentServiceDaoImpl.saveBusinessAgentPhoto(businessAgentPhoto);
-        }
     }
 
     /**
@@ -285,30 +218,6 @@ public class UpdateAgentInfoListener extends AbstractAgentBusinessServiceDataFlo
     }
 
 
-    /**
-     * 保存 代理商证件 信息
-     * @param business 当前业务
-     * @param businessAgentCerdentialses 代理商证件
-     */
-    private void doBusinessAgentCerdentials(Business business, JSONArray businessAgentCerdentialses) {
-
-        for(int businessAgentCerdentialsIndex = 0 ; businessAgentCerdentialsIndex < businessAgentCerdentialses.size() ; businessAgentCerdentialsIndex ++) {
-            JSONObject businessAgentCerdentials = businessAgentCerdentialses.getJSONObject(businessAgentCerdentialsIndex);
-            Assert.jsonObjectHaveKey(businessAgentCerdentials, "agentId", "businessAgentPhoto 节点下没有包含 agentId 节点");
-
-            if (businessAgentCerdentials.getString("agentCerdentialsId").startsWith("-")) {
-                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"agentPhotoId 错误,不能自动生成(必须已经存在的agentPhotoId)"+businessAgentCerdentials);
-            }
-
-            autoSaveDelBusinessAgentCerdentials(business,businessAgentCerdentials);
-
-            businessAgentCerdentials.put("bId", business.getbId());
-            businessAgentCerdentials.put("operate", StatusConstant.OPERATE_ADD);
-            //保存代理商信息
-            agentServiceDaoImpl.saveBusinessAgentCerdentials(businessAgentCerdentials);
-        }
-    }
-
     public IAgentServiceDao getAgentServiceDaoImpl() {
         return agentServiceDaoImpl;
     }

+ 161 - 0
AgentService/src/main/java/com/java110/agent/listener/UpdateAgentPhotoListener.java

@@ -0,0 +1,161 @@
+package com.java110.agent.listener;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.constant.StatusConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.agent.dao.IAgentServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 修改代理商信息 侦听
+ *
+ * 处理节点
+ * 1、businessAgentPhoto:{} 代理商照片节点
+ * Created by wuxw on 2018/5/18.
+ */
+@Java110Listener("updateAgentPhotoListener")
+@Transactional
+public class UpdateAgentPhotoListener extends AbstractAgentBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(UpdateAgentPhotoListener.class);
+    @Autowired
+    IAgentServiceDao agentServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 2;
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_UPDATE_AGENT_PHOTO;
+    }
+
+    /**
+     * business过程
+     * @param dataFlowContext
+     * @param business
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        if(data.containsKey("businessAgentPhoto")){
+            JSONArray businessAgentPhotos = data.getJSONArray("businessAgentPhoto");
+            doBusinessAgentPhoto(business,businessAgentPhotos);
+        }
+    }
+
+
+    /**
+     * business to instance 过程
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
+
+        JSONObject data = business.getDatas();
+
+        Map info = new HashMap();
+        info.put("bId",business.getbId());
+        info.put("operate",StatusConstant.OPERATE_ADD);
+
+        //代理商照片
+        List<Map> businessAgentPhotos = agentServiceDaoImpl.getBusinessAgentPhoto(info);
+        if(businessAgentPhotos != null && businessAgentPhotos.size() >0){
+            for(Map businessAgentPhoto : businessAgentPhotos) {
+                flushBusinessAgentPhoto(businessAgentPhoto,StatusConstant.STATUS_CD_VALID);
+                agentServiceDaoImpl.updateAgentPhotoInstance(businessAgentPhoto);
+            }
+        }
+
+    }
+
+    /**
+     * 撤单
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doRecover(DataFlowContext dataFlowContext, Business business) {
+
+        String bId = business.getbId();
+        //Assert.hasLength(bId,"请求报文中没有包含 bId");
+        Map info = new HashMap();
+        info.put("bId",bId);
+        info.put("statusCd",StatusConstant.STATUS_CD_VALID);
+        Map delInfo = new HashMap();
+        delInfo.put("bId",business.getbId());
+        delInfo.put("operate",StatusConstant.OPERATE_DEL);
+
+        //代理商照片
+        List<Map> agentPhotos = agentServiceDaoImpl.getAgentPhoto(info);
+        if(agentPhotos != null && agentPhotos.size()>0){
+            List<Map> businessAgentPhotos = agentServiceDaoImpl.getBusinessAgentPhoto(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessAgentPhotos == null || businessAgentPhotos.size() ==0 ){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(agent_photo),程序内部异常,请检查! "+delInfo);
+            }
+            for(Map businessAgentPhoto : businessAgentPhotos) {
+                flushBusinessAgentPhoto(businessAgentPhoto,StatusConstant.STATUS_CD_VALID);
+                agentServiceDaoImpl.updateAgentPhotoInstance(businessAgentPhoto);
+            }
+        }
+    }
+
+    /**
+     * 保存代理商照片
+     * @param business 业务对象
+     * @param businessAgentPhotos 代理商照片
+     */
+    private void doBusinessAgentPhoto(Business business, JSONArray businessAgentPhotos) {
+
+
+        for(int businessAgentPhotoIndex = 0 ;businessAgentPhotoIndex < businessAgentPhotos.size();businessAgentPhotoIndex++) {
+            JSONObject businessAgentPhoto = businessAgentPhotos.getJSONObject(businessAgentPhotoIndex);
+            Assert.jsonObjectHaveKey(businessAgentPhoto, "agentId", "businessAgentPhoto 节点下没有包含 agentId 节点");
+
+            if (businessAgentPhoto.getString("agentPhotoId").startsWith("-")) {
+                throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"agentPhotoId 错误,不能自动生成(必须已经存在的agentPhotoId)"+businessAgentPhoto);
+            }
+
+            //自动保存DEL信息
+            autoSaveDelBusinessAgentPhoto(business,businessAgentPhoto);
+
+            businessAgentPhoto.put("bId", business.getbId());
+            businessAgentPhoto.put("operate", StatusConstant.OPERATE_ADD);
+            //保存代理商信息
+            agentServiceDaoImpl.saveBusinessAgentPhoto(businessAgentPhoto);
+        }
+    }
+
+
+    public IAgentServiceDao getAgentServiceDaoImpl() {
+        return agentServiceDaoImpl;
+    }
+
+    public void setAgentServiceDaoImpl(IAgentServiceDao agentServiceDaoImpl) {
+        this.agentServiceDaoImpl = agentServiceDaoImpl;
+    }
+
+
+
+}

+ 1 - 1
AgentService/src/main/resources/application.yml

@@ -1,3 +1,3 @@
 spring:
   profiles:
-    active: test
+    active: dev

+ 13 - 0
java110-common/src/main/java/com/java110/common/constant/ServiceCodeConstant.java

@@ -268,4 +268,17 @@ public class ServiceCodeConstant {
     public static final String SERVICE_CODE_DELETE_PROPERTY_USER = "delete.property.user";
     public static final String SERVICE_CODE_DELETE_PROPERTY_HOUSE = "delete.property.house";
 
+
+    public static final String SERVICE_CODE_SAVE_AGENT_INFO = "save.agent.info";
+    public static final String SERVICE_CODE_SAVE_AGENT_PHOTO = "save.agent.photo";
+    public static final String SERVICE_CODE_SAVE_AGENT_CERDENTIALS = "save.agent.cerdentials";
+    public static final String SERVICE_CODE_SAVE_AGENT_USER = "save.agent.user";
+    public static final String SERVICE_CODE_UPDATE_AGENT_INFO = "update.agent.info";
+    public static final String SERVICE_CODE_UPDATE_AGENT_PHOTO = "update.agent.photo";
+    public static final String SERVICE_CODE_UPDATE_AGENT_CERDENTIALS = "update.agent.cerdentials";
+    public static final String SERVICE_CODE_DELETE_AGENT_ATTR = "delete.agent.attr";
+    public static final String SERVICE_CODE_DELETE_AGENT_PHOTO = "delete.agent.photo";
+    public static final String SERVICE_CODE_DELETE_AGENT_CERDENTIALS = "delete.agent.cerdentials";
+    public static final String SERVICE_CODE_DELETE_AGENT_USER = "delete.agent.user";
+
 }

+ 215 - 0
java110-config/db/AgentService/create_table.sql

@@ -0,0 +1,215 @@
+-- agent 表 过程表
+
+CREATE TABLE business_agent(
+    agent_id VARCHAR(30) NOT NULL COMMENT '代理商ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    `name` VARCHAR(100) NOT NULL COMMENT '代理商名称',
+    address VARCHAR(200) NOT NULL COMMENT '代理商地址',
+    tel VARCHAR(11) NOT NULL COMMENT '电话',
+    nearby_landmarks VARCHAR(200) COMMENT '地标,如王府井北60米',
+    map_x VARCHAR(20) NOT NULL COMMENT '地区 x坐标',
+    map_y VARCHAR(20) NOT NULL COMMENT '地区 y坐标',
+    `month` INT NOT NULL COMMENT '月份',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    operate VARCHAR(3) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL'
+)
+PARTITION BY RANGE (`month`) (
+    PARTITION business_agent_1 VALUES LESS THAN (2),
+    PARTITION business_agent_2 VALUES LESS THAN (3),
+    PARTITION business_agent_3 VALUES LESS THAN (4),
+    PARTITION business_agent_4 VALUES LESS THAN (5),
+    PARTITION business_agent_5 VALUES LESS THAN (6),
+    PARTITION business_agent_6 VALUES LESS THAN (7),
+    PARTITION business_agent_7 VALUES LESS THAN (8),
+    PARTITION business_agent_8 VALUES LESS THAN (9),
+    PARTITION business_agent_9 VALUES LESS THAN (10),
+    PARTITION business_agent_10 VALUES LESS THAN (11),
+    PARTITION business_agent_11 VALUES LESS THAN (12),
+    PARTITION business_agent_12 VALUES LESS THAN (13)
+);
+CREATE INDEX idx_business_agent_id ON business_agent(agent_id);
+CREATE INDEX idx_business_agent_b_id ON business_agent(b_id);
+
+create table business_agent_attr(
+    b_id VARCHAR(30) NOT NULL COMMENT '订单ID',
+    attr_id VARCHAR(30) NOT NULL COMMENT '属性id',
+    agent_id VARCHAR(30) NOT NULL COMMENT '用户ID',
+    spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表',
+    value VARCHAR(50) NOT NULL COMMENT '属性值',
+    `month` INT NOT NULL comment '月份',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    operate VARCHAR(3) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL'
+)
+partition BY RANGE (`month`) (
+    partition business_agent_attr_1 VALUES LESS THAN (2),
+    partition business_agent_attr_2 VALUES LESS THAN (3),
+    partition business_agent_attr_3 VALUES LESS THAN (4),
+    partition business_agent_attr_4 VALUES LESS THAN (5),
+    partition business_agent_attr_5 VALUES LESS THAN (6),
+    partition business_agent_attr_6 VALUES LESS THAN (7),
+    partition business_agent_attr_7 VALUES LESS THAN (8),
+    partition business_agent_attr_8 VALUES LESS THAN (9),
+    partition business_agent_attr_9 VALUES LESS THAN (10),
+    partition business_agent_attr_10 VALUES LESS THAN (11),
+    partition business_agent_attr_11 VALUES LESS THAN (12),
+    partition business_agent_attr_12 VALUES LESS THAN (13)
+);
+CREATE INDEX idx_business_attr_agent_id ON business_agent_attr(agent_id);
+CREATE INDEX idx_business_agent_attr_b_id ON business_agent_attr(b_id);
+
+-- 代理商照片
+CREATE TABLE business_agent_photo(
+    agent_photo_id VARCHAR(30) NOT NULL COMMENT '代理商照片ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    agent_id VARCHAR(30) NOT NULL COMMENT '代理商ID',
+    agent_photo_type_cd VARCHAR(12) NOT NULL COMMENT '代理商照片类型,T 门头照 I 内景照',
+    photo VARCHAR(100) NOT NULL COMMENT '照片',
+    `month` INT NOT NULL COMMENT '月份',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    operate VARCHAR(3) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL'
+)
+PARTITION BY RANGE (`month`) (
+    PARTITION business_agent_photo_1 VALUES LESS THAN (2),
+    PARTITION business_agent_photo_2 VALUES LESS THAN (3),
+    PARTITION business_agent_photo_3 VALUES LESS THAN (4),
+    PARTITION business_agent_photo_4 VALUES LESS THAN (5),
+    PARTITION business_agent_photo_5 VALUES LESS THAN (6),
+    PARTITION business_agent_photo_6 VALUES LESS THAN (7),
+    PARTITION business_agent_photo_7 VALUES LESS THAN (8),
+    PARTITION business_agent_photo_8 VALUES LESS THAN (9),
+    PARTITION business_agent_photo_9 VALUES LESS THAN (10),
+    PARTITION business_agent_photo_10 VALUES LESS THAN (11),
+    PARTITION business_agent_photo_11 VALUES LESS THAN (12),
+    PARTITION business_agent_photo_12 VALUES LESS THAN (13)
+);
+CREATE INDEX idx_business_photo_agent_id ON business_agent_photo(agent_id);
+CREATE INDEX idx_business_agent_photo_b_id ON business_agent_photo(b_id);
+-- 代理商证件
+create table business_agent_cerdentials(
+    agent_cerdentials_id varchar(30) not null comment '代理商证件ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    agent_id VARCHAR(30) NOT NULL COMMENT '代理商ID',
+    credentials_cd varchar(12) not null comment '证件类型,对应于 credentials表',
+    value varchar(50) not null  comment '证件号码',
+    validity_period DATE NOT NULL  COMMENT '有效期,如果是长期有效 写成 3000/1/1',
+    positive_photo varchar(100) comment '正面照片',
+    negative_photo varchar(100) comment '反面照片',
+    `month` INT NOT NULL comment '月份',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    operate VARCHAR(3) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL'
+)
+partition BY RANGE (`month`) (
+    partition business_agent_cerdentials_1 VALUES LESS THAN (2),
+    partition business_agent_cerdentials_2 VALUES LESS THAN (3),
+    partition business_agent_cerdentials_3 VALUES LESS THAN (4),
+    partition business_agent_cerdentials_4 VALUES LESS THAN (5),
+    partition business_agent_cerdentials_5 VALUES LESS THAN (6),
+    partition business_agent_cerdentials_6 VALUES LESS THAN (7),
+    partition business_agent_cerdentials_7 VALUES LESS THAN (8),
+    partition business_agent_cerdentials_8 VALUES LESS THAN (9),
+    partition business_agent_cerdentials_9 VALUES LESS THAN (10),
+    partition business_agent_cerdentials_10 VALUES LESS THAN (11),
+    partition business_agent_cerdentials_11 VALUES LESS THAN (12),
+    partition business_agent_cerdentials_12 VALUES LESS THAN (13)
+);
+CREATE INDEX idx_business_cerdentials_agent_id ON business_agent_cerdentials(agent_id);
+CREATE INDEX idx_business_agent_cerdentials_b_id ON business_agent_cerdentials(b_id);
+
+-- 代理商用户关系
+CREATE TABLE business_agent_user(
+    agent_user_id VARCHAR(30) NOT NULL COMMENT '代理商用户ID',
+    agent_id VARCHAR(30) NOT NULL COMMENT '代理商ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
+    rel_cd varchar(30) not null comment '用户和代理商关系 详情查看 agent_user_rel表',
+    `month` INT NOT NULL COMMENT '月份',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    operate VARCHAR(3) NOT NULL COMMENT '数据状态,添加ADD,修改MOD 删除DEL'
+);
+
+-- agent 表 过程表
+
+CREATE TABLE a_agent(
+    agent_id VARCHAR(30) NOT NULL COMMENT '代理商ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    `name` VARCHAR(100) NOT NULL COMMENT '代理商名称',
+    address VARCHAR(200) NOT NULL COMMENT '代理商地址',
+    tel VARCHAR(11) NOT NULL COMMENT '电话',
+    nearby_landmarks VARCHAR(200) COMMENT '地标,如王府井北60米',
+    map_x VARCHAR(20) NOT NULL COMMENT '地区 x坐标',
+    map_y VARCHAR(20) NOT NULL COMMENT '地区 y坐标',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效',
+    UNIQUE KEY (agent_id)
+);
+CREATE INDEX idx_agent_b_id ON a_agent(b_id);
+CREATE UNIQUE INDEX idx_agent_agent_id ON a_agent(agent_id);
+
+CREATE TABLE a_agent_attr(
+    b_id VARCHAR(30) NOT NULL COMMENT '订单ID',
+    attr_id VARCHAR(30) NOT NULL COMMENT '属性id',
+    agent_id VARCHAR(30) NOT NULL COMMENT '用户ID',
+    spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表',
+    VALUE VARCHAR(50) NOT NULL COMMENT '属性值',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效',
+    UNIQUE KEY (attr_id)
+);
+CREATE INDEX idx_agent_attr_b_id ON a_agent_attr(b_id);
+CREATE INDEX idx_agent_attr_agent_id ON a_agent_attr(agent_id);
+
+-- 代理商照片
+CREATE TABLE a_agent_photo(
+    agent_photo_id VARCHAR(30) NOT NULL COMMENT '代理商照片ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    agent_id VARCHAR(30) NOT NULL COMMENT '代理商ID',
+    agent_photo_type_cd VARCHAR(12) NOT NULL COMMENT '代理商照片类型,T 门头照 I 内景照',
+    photo VARCHAR(100) NOT NULL COMMENT '照片',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效',
+    UNIQUE KEY (agent_photo_id)
+);
+CREATE INDEX idx_agent_photo_b_id ON a_agent_photo(b_id);
+CREATE INDEX idx_agent_photo_agent_id ON a_agent_photo(agent_id);
+CREATE INDEX idx_agent_photo_agent_photo_id ON a_agent_photo(agent_photo_id);
+
+-- 代理商证件
+create table a_agent_cerdentials(
+    agent_cerdentials_id varchar(30) not null comment '代理商证件ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    agent_id VARCHAR(30) NOT NULL COMMENT '代理商ID',
+    credentials_cd varchar(12) not null comment '证件类型,对应于 credentials表',
+    value varchar(50) not null  comment '证件号码',
+    validity_period DATE NOT NULL  COMMENT '有效期,如果是长期有效 写成 3000/1/1',
+    positive_photo varchar(100) comment '正面照片',
+    negative_photo varchar(100) comment '反面照片',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效',
+    unique KEY (agent_cerdentials_id)
+);
+
+
+
+CREATE INDEX idx_agent_cerdentials_b_id ON a_agent_cerdentials(b_id);
+CREATE INDEX idx_agent_cerdentials_agent_id ON a_agent_cerdentials(agent_id);
+CREATE INDEX idx__agent_cerdentials_id ON a_agent_cerdentials(agent_cerdentials_id);
+
+CREATE TABLE a_agent_user(
+    agent_user_id VARCHAR(30) NOT NULL COMMENT '代理商用户ID',
+    agent_id VARCHAR(30) NOT NULL COMMENT '代理商ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
+    rel_cd varchar(30) not null comment '用户和代理商关系 详情查看 agent_user_rel表',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+        status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效',
+        unique KEY (agent_user_id)
+);
+
+CREATE TABLE agent_user_rel(
+    id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
+    rel_cd VARCHAR(12) NOT NULL COMMENT '代理商用户关系编码',
+    `name` VARCHAR(50) NOT NULL COMMENT '代理商用户关系编码名称',
+    description VARCHAR(200) COMMENT '描述',
+    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    UNIQUE KEY (rel_cd)
+);

+ 1 - 1
java110-config/db/PropertyService/create_table.sql

@@ -307,7 +307,7 @@ CREATE TABLE property_user_rel(
     `name` VARCHAR(50) NOT NULL COMMENT '物业用户关系编码名称',
     description VARCHAR(200) COMMENT '描述',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
-    UNIQUE KEY (fee_type_cd)
+    UNIQUE KEY (rel_cd)
 );
 
 

+ 617 - 0
java110-config/src/main/resources/mapper/agent/AgentServiceDaoImplMapper.xml

@@ -0,0 +1,617 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="agentServiceDaoImpl">
+    
+    <!-- 保存商户信息 add by wuxw 2018-07-03 -->
+    <insert id="saveBusinessAgentInfo" parameterType="Map">
+        insert into business_agent(agent_id,b_id,name,address,tel,nearby_landmarks,map_x,map_y,month,operate)
+        values(#{agentId},#{bId},#{name},#{address},#{tel},#{nearbyLandmarks},#{mapX},#{mapY},#{month},#{operate})
+    </insert>
+    <!-- 保存商户属性信息  add by wuxw 2018-07-03 -->
+    <insert id="saveBusinessAgentAttr" parameterType="Map">
+        insert into business_agent_attr(b_id,attr_id,agent_id,spec_cd,value,month,operate)
+        values(#{bId},#{attrId},#{agentId},#{specCd},#{value},#{month},#{operate})
+    </insert>
+    <!-- 保存商户照片信息 add by wuxw 2018-07-03 -->
+    <insert id="saveBusinessAgentPhoto" parameterType="Map">
+        insert into business_agent_photo(agent_photo_id,b_id,agent_id,agent_photo_type_cd,photo,month,operate)
+        values(#{agentPhotoId},#{bId},#{agentId},#{agentPhotoTypeCd},#{photo},#{month},#{operate})
+    </insert>
+    <!-- 保存商户证件信息 add by wuxw 2018-07-03 -->
+    <insert id="saveBusinessAgentCerdentials" parameterType="Map">
+        insert into business_agent_cerdentials(agent_cerdentials_id,b_id,agent_id,credentials_cd,value,validity_period,positive_photo,negative_photo,month,operate)
+        values(#{agentCerdentialsId},#{bId},#{agentId},#{credentialsCd},#{value},#{validityPeriod},#{positivePhoto},#{negativePhoto},#{month},#{operate})
+    </insert>
+
+    <!-- 保存代理商用户信息 add by wuxw 2018-07-03 -->
+    <insert id="saveBusinessAgentUser" parameterType="Map">
+        insert into business_agent_user(agent_user_id,b_id,agent_id,user_id,rel_cd,month,operate)
+        values(#{agentUserId},#{bId},#{agentId},#{userId},#{relCd},#{month},#{operate})
+    </insert>
+    <!-- 保存代理商费用信息 add by wuxw 2018-12-20 -->
+    <insert id="saveBusinessAgentFee" parameterType="Map">
+        insert into business_agent_fee(fee_id,b_id,agent_id,fee_type_cd,fee_money,fee_time,start_time,end_time,month,operate)
+        values(#{feeId},#{bId},#{agentId},#{feeTypeCd},#{feeMoney},#{feeTime},#{startTime},#{endTime},#{month},#{operate})
+    </insert>
+
+    <!-- 保存住户信息 add by wuxw 2018-07-03 -->
+    <insert id="saveBusinessAgentHouse" parameterType="Map">
+        insert into business_agent_house(house_id,agent_id,b_id,house_num,house_name,house_phone,house_area,fee_type_cd,fee_price,month,operate)
+        values(#{houseId},#{agentId},#{bId},#{houseNum},#{houseName},#{housePhone},#{houseArea},#{feeTypeCd},#{feePrice},#{month},#{operate})
+    </insert>
+    <!-- 保存商户属性信息  add by wuxw 2018-07-03 -->
+    <insert id="saveBusinessAgentHouseAttr" parameterType="Map">
+        insert into business_agent_house_attr(b_id,attr_id,house_id,spec_cd,value,month,operate)
+        values(#{bId},#{attrId},#{houseId},#{specCd},#{value},#{month},#{operate})
+    </insert>
+
+    <!-- 查询商户信息(Business) add by wuxw 2018-07-03 -->
+    <select id="getBusinessAgentInfo" parameterType="Map" resultType="Map">
+        select s.agent_id,s.b_id,s.name,s.address,s.tel,s.nearby_landmarks,s.map_x,s.map_y,s.operate
+        from business_agent s where 1 = 1
+        <if test="operate != null and operate != ''">
+            and s.operate = #{operate}
+        </if>
+        <if test="bId != null and bId !=''">
+            and s.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId != ''">
+            and s.agent_id = #{agentId}
+        </if>
+    </select>
+
+
+    <!-- 查询商户属性信息(Business) add by wuxw 2018-07-03 -->
+    <select id="getBusinessAgentAttrs" parameterType="Map" resultType="Map">
+        select sa.b_id,sa.attr_id,sa.agent_id,sa.spec_cd,sa.value,sa.operate
+        from business_agent_attr sa where 1=1
+        <if test="operate != null and operate != ''">
+            and sa.operate = #{operate}
+        </if>
+        <if test="bId != null and bId !=''">
+            and sa.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId != ''">
+            and sa.agent_id = #{agentId}
+        </if>
+        <if test="attrId != null and attrId != ''">
+            and sa.attr_id = #{attrId}
+        </if>
+    </select>
+
+    <!-- 查询住户信息(Business) add by wuxw 2018-07-03 -->
+    <select id="getBusinessAgentHouse" parameterType="Map" resultType="Map">
+        select s.house_id,s.agent_id,s.b_id,s.house_num,s.house_name,s.house_phone,s.house_area,s.fee_type_cd,s.fee_price,s.operate
+        from business_agent_house s where 1 = 1
+        <if test="operate != null and operate != ''">
+            and s.operate = #{operate}
+        </if>
+        <if test="bId != null and bId !=''">
+            and s.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId != ''">
+            and s.agent_id = #{agentId}
+        </if>
+        <if test="houseId != null and houseId != ''">
+            and s.house_id = #{houseId}
+        </if>
+    </select>
+
+
+    <!-- 查询住户属性信息(Business) add by wuxw 2018-07-03 -->
+    <select id="getBusinessAgentHouseAttrs" parameterType="Map" resultType="Map">
+        select sa.b_id,sa.attr_id,sa.house_id,sa.spec_cd,sa.value,sa.operate
+        from business_agent_house_attr sa where 1=1
+        <if test="operate != null and operate != ''">
+            and sa.operate = #{operate}
+        </if>
+        <if test="bId != null and bId !=''">
+            and sa.b_id = #{bId}
+        </if>
+        <if test="houseId != null and houseId != ''">
+            and sa.house_id = #{houseId}
+        </if>
+        <if test="attrId != null and attrId != ''">
+            and sa.attr_id = #{attrId}
+        </if>
+    </select>
+
+    <!-- 查询商户照片信息 add by wuxw 2018-07-03 -->
+    <select id="getBusinessAgentPhoto" parameterType="Map" resultType="Map">
+        select sp.agent_photo_id,sp.b_id,sp.agent_id,sp.agent_photo_type_cd,sp.photo,sp.operate
+        from business_agent_photo sp where 1=1
+        <if test="bId != null and bId !=''">
+            and sp.b_id = #{bId}
+        </if>
+        <if test="operate != null and operate != ''">
+            and sp.operate = #{operate}
+        </if>
+        <if test="agentId != null and agentId != ''">
+            and sp.agent_id = #{agentId}
+        </if>
+    </select>
+
+    <!-- 查询商户 证件信息 add by wuxw 2018-07-03 -->
+    <select id="getBusinessAgentCerdentials" parameterType="Map" resultType="Map">
+        select sc.agent_cerdentials_id,sc.b_id,sc.agent_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,sc.operate
+        from business_agent_cerdentials sc where 1 = 1
+        <if test="bId != null and bId !=''">
+            and sc.b_id = #{bId}
+        </if>
+        <if test="operate != null and operate != ''">
+            and sc.operate = #{operate}
+        </if>
+        <if test="agentId != null and agentId != ''">
+            and sc.agent_id = #{agentId}
+        </if>
+    </select>
+
+    <!-- 查询代理商 用户信息 add by wuxw 2018-07-03 -->
+    <select id="getBusinessAgentUser" parameterType="Map" resultType="Map">
+        select sc.agent_user_id,sc.b_id,sc.agent_id,sc.user_id,sc.rel_cd,sc.operate
+        from business_agent_user sc where 1 = 1
+        <if test="bId != null and bId !=''">
+            and sc.b_id = #{bId}
+        </if>
+        <if test="operate != null and operate != ''">
+            and sc.operate = #{operate}
+        </if>
+        <if test="agentId != null and agentId != ''">
+            and sc.agent_id = #{agentId}
+        </if>
+    </select>
+
+    <!-- 查询代理商费用 add by wuxw 2018-12-20 -->
+    <select id="getBusinessAgentFee" parameterType="Map" resultType="Map">
+        select sc.fee_id,sc.b_id,sc.agent_id,sc.fee_type_cd,sc.fee_money,sc.fee_time,sc.create_time,sc.start_time,sc.end_time,sc.operate
+        from business_agent_fee sc where 1 = 1
+        <if test="bId != null and bId !=''">
+            and sc.b_id = #{bId}
+        </if>
+        <if test="operate != null and operate != ''">
+            and sc.operate = #{operate}
+        </if>
+        <if test="agentId != null and agentId != ''">
+            and sc.agent_id = #{agentId}
+        </if>
+    </select>
+
+    <!-- 保存商户信息至 instance表中 add by wuxw 2018-07-03 -->
+    <insert id="saveAgentInfoInstance" parameterType="Map">
+        insert into a_agent(agent_id,b_id,name,address,tel,nearby_landmarks,map_x,map_y,status_cd)
+        select s.agent_id,s.b_id,s.name,s.address,s.tel,s.nearby_landmarks,s.map_x,s.map_y,'0'
+        from business_agent s where 
+        s.operate = 'ADD' and s.b_id=#{bId}
+    </insert>
+
+    <!-- 保存商户属性信息到 instance add by wuxw 2018-07-03 -->
+    <insert id="saveAgentAttrsInstance" parameterType="Map">
+        insert into a_agent_attr(b_id,attr_id,agent_id,spec_cd,value,status_cd)
+        select sa.b_id,sa.attr_id,sa.agent_id,sa.spec_cd,sa.value,'0'
+        from business_agent_attr sa
+        where sa.operate = 'ADD' and sa.b_id=#{bId}
+    </insert>
+
+    <!-- 保存住户信息至 instance表中 add by wuxw 2018-07-03 -->
+    <insert id="saveAgentHouseInstance" parameterType="Map">
+        insert into a_agent_house(house_id,agent_id,b_id,house_num,house_name,house_phone,house_area,fee_type_cd,fee_price,status_cd)
+        select s.house_id,s.agent_id,s.b_id,s.house_num,s.house_name,s.house_phone,s.house_area,s.fee_type_cd,s.fee_price,'0'
+        from business_agent_house s where
+        s.operate = 'ADD' and s.b_id=#{bId}
+    </insert>
+
+    <!-- 保存住户属性信息到 instance add by wuxw 2018-07-03 -->
+    <insert id="saveAgentHouseAttrsInstance" parameterType="Map">
+        insert into a_agent_house_attr(b_id,attr_id,house_id,spec_cd,value,status_cd)
+        select sa.b_id,sa.attr_id,sa.house_id,sa.spec_cd,sa.value,'0'
+        from business_agent_house_attr sa
+        where sa.operate = 'ADD' and sa.b_id=#{bId}
+    </insert>
+    
+    <!-- 保存 商户照片信息 instance add by wuxw 2018-07-03 -->
+    <insert id="saveAgentPhotoInstance" parameterType="Map">
+        insert into a_agent_photo(agent_photo_id,b_id,agent_id,agent_photo_type_cd,photo,status_cd)
+        select sp.agent_photo_id,sp.b_id,sp.agent_id,sp.agent_photo_type_cd,sp.photo,'0'
+        from business_agent_photo sp
+        where  sp.operate = 'ADD' and sp.b_id=#{bId}
+    </insert>
+    <!-- 保存 商户证件信息 instance add by wuxw 2018-07-03 -->
+    <insert id="saveAgentCerdentialsInstance" parameterType="Map">
+        insert into a_agent_cerdentials(agent_cerdentials_id,b_id,agent_id,credentials_cd,value,validity_period,positive_photo,negative_photo,status_cd)
+        select sc.agent_cerdentials_id,sc.b_id,sc.agent_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,'0'
+        from business_agent_cerdentials sc
+        where sc.operate = 'ADD' and sc.b_id=#{bId}
+    </insert>
+
+    <!-- 保存 商户用户信息 instance add by wuxw 2018-07-03 -->
+    <insert id="saveAgentUserInstance" parameterType="Map">
+        insert into a_agent_user(agent_user_id,b_id,agent_id,user_id,rel_cd,status_cd)
+        select sc.agent_user_id,sc.b_id,sc.agent_id,sc.user_id,sc.rel_cd,'0'
+        from business_agent_user sc
+        where sc.operate = 'ADD' and sc.b_id=#{bId}
+    </insert>
+
+
+    <!-- 保存 商户用户信息 instance add by wuxw 2018-07-03 -->
+    <insert id="saveAgentFeeInstance" parameterType="Map">
+        insert into a_agent_fee(fee_id,b_id,agent_id,fee_type_cd,fee_money,fee_time,start_time,end_time,status_cd)
+        select sc.fee_id,sc.b_id,sc.agent_id,sc.fee_type_cd,sc.fee_money,sc.fee_time,sc.start_time,sc.end_time,'0'
+        from business_agent_fee sc
+        where sc.operate = 'ADD' and sc.b_id=#{bId}
+    </insert>
+
+    <!-- 查询商户信息 add by wuxw 2018-07-03 -->
+    <select id="getAgentInfo" parameterType="Map" resultType="Map">
+        select s.agent_id,s.b_id,s.name,s.address,s.tel,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd
+        from a_agent s
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and s.status_cd = #{statusCd}
+        </if>
+
+        <if test="bId != null and bId !=''">
+            and s.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and s.agent_id = #{agentId}
+        </if>
+    </select>
+
+    <!-- 查询商户属性信息 add by wuxw 2018-07-03 -->
+    <select id="getAgentAttrs" parameterType="Map" resultType="Map">
+        select sa.b_id,sa.attr_id,sa.agent_id,sa.spec_cd,sa.value,sa.status_cd
+        from a_agent_attr sa
+        where
+        1=1
+        <if test="statusCd != null and statusCd != ''">
+            and sa.status_cd = #{statusCd}
+        </if>
+        <if test="bId != null and bId !=''">
+            and sa.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and sa.agent_id = #{agentId}
+        </if>
+        <if test="attrId != null and attrId != ''">
+            and sa.attr_id = #{attrId}
+        </if>
+    </select>
+
+
+
+    <!-- 查询住户信息 add by wuxw 2018-07-03 -->
+    <select id="getAgentHouse" parameterType="Map" resultType="Map">
+        select s.house_id,s.agent_id,s.b_id,s.house_num,s.house_name,s.house_area,s.house_phone,s.fee_type_cd,s.fee_price,s.status_cd
+        from a_agent_house s
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and s.status_cd = #{statusCd}
+        </if>
+
+        <if test="bId != null and bId !=''">
+            and s.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and s.agent_id = #{agentId}
+        </if>
+        <if test="houseId != null and houseId !=''">
+            and s.house_id = #{houseId}
+        </if>
+    </select>
+
+    <!-- 查询住户属性信息 add by wuxw 2018-07-03 -->
+    <select id="getAgentHouseAttrs" parameterType="Map" resultType="Map">
+        select sa.b_id,sa.attr_id,sa.house_id,sa.spec_cd,sa.value,sa.status_cd
+        from a_agent_house_attr sa
+        where
+        1=1
+        <if test="statusCd != null and statusCd != ''">
+            and sa.status_cd = #{statusCd}
+        </if>
+        <if test="bId != null and bId !=''">
+            and sa.b_id = #{bId}
+        </if>
+        <if test="houseId != null and houseId !=''">
+            and sa.house_id = #{houseId}
+        </if>
+        <if test="attrId != null and attrId != ''">
+            and sa.attr_id = #{attrId}
+        </if>
+    </select>
+
+    <!-- 查询商户照片信息 add by wuxw 2018-07-03 -->
+    <select id="getAgentPhoto" parameterType="Map" resultType="Map">
+        select sp.agent_photo_id,sp.b_id,sp.agent_id,sp.agent_photo_type_cd,sp.photo,sp.status_cd
+        from a_agent_photo sp
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and sp.status_cd = #{statusCd}
+        </if>
+        <if test="bId != null and bId !=''">
+            and sp.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and sp.agent_id = #{agentId}
+        </if>
+    </select>
+
+    <!-- 查询商户证件信息 add by wuxw 2018-07-03 -->
+    <select id="getAgentCerdentials" parameterType="Map" resultType="Map">
+        select sc.agent_cerdentials_id,sc.b_id,sc.agent_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,sc.status_cd
+        from a_agent_cerdentials sc
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and sc.status_cd = #{statusCd}
+        </if>
+        <if test="bId != null and bId !=''">
+            and sc.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and sc.agent_id = #{agentId}
+        </if>
+    </select>
+
+    <!-- 查询商户证件信息 add by wuxw 2018-07-03 -->
+    <select id="getAgentUser" parameterType="Map" resultType="Map">
+        select sc.agent_user_id,sc.b_id,sc.agent_id,sc.user_id,sc.rel_cd,sc.status_cd
+        from a_agent_user sc
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and sc.status_cd = #{statusCd}
+        </if>
+        <if test="bId != null and bId !=''">
+            and sc.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and sc.agent_id = #{agentId}
+        </if>
+    </select>
+
+
+    <!-- 查询代理商费用信息 add by wuxw 2018-07-03 -->
+    <select id="getAgentFee" parameterType="Map" resultType="Map">
+        select sc.fee_id,sc.b_id,sc.agent_id,sc.fee_type_cd,sc.fee_money,sc.fee_time,sc.start_time,sc.end_time,sc.status_cd
+        from a_agent_fee sc
+        where 1=1
+        <if test="statusCd != null and statusCd != ''">
+            and sc.status_cd = #{statusCd}
+        </if>
+        <if test="bId != null and bId !=''">
+            and sc.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and sc.agent_id = #{agentId}
+        </if>
+    </select>
+
+
+    <!-- 修改商户信息 add by wuxw 2018-07-03 -->
+    <update id="updateAgentInfoInstance" parameterType="Map">
+        update a_agent s set s.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,s.b_id = #{newBId}
+        </if>
+        <if test="name != null and name != ''">
+            ,s.name = #{name}
+        </if>
+        <if test="address != null and address != ''">
+            ,s.address = #{address}
+        </if>
+        <if test="tel != null and tel != ''">
+            ,s.tel = #{tel}
+        </if>
+        <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
+            ,s.nearby_landmarks = #{nearbyLandmarks}
+        </if>
+        <if test="mapX != null and mapX != ''">
+            ,s.map_x = #{mapX}
+        </if>
+        <if test="mapY != null and mapY != ''">
+            ,s.map_y = #{mapY}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and s.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and s.agent_id = #{agentId}
+        </if>
+    </update>
+
+    <!-- 修改商户属性信息 add by wuxw 2018-07-03 -->
+    <update id="updateAgentAttrInstance" parameterType="Map">
+        update a_agent_attr sa set sa.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,sa.b_id = #{newBId}
+        </if>
+        <if test="value != null and value != ''">
+            ,sa.value = #{value}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and sa.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and sa.agent_id = #{agentId}
+        </if>
+        <if test="specCd != null and specCd !=''">
+            and sa.spec_cd = #{specCd}
+        </if>
+        <if test="attrId != null and attrId !=''">
+            and sa.attr_id = #{attrId}
+        </if>
+    </update>
+
+    <!-- 修改住户信息 add by wuxw 2018-07-03 -->
+    <update id="updateAgentHouseInstance" parameterType="Map">
+        update a_agent_house s set s.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,s.b_id = #{newBId}
+        </if>
+        <if test="houseName != null and houseName != ''">
+            ,s.house_name = #{houseName}
+        </if>
+        <if test="houseNum != null and houseNum != ''">
+            ,s.house_num = #{houseNum}
+        </if>
+        <if test="housePhone != null and housePhone != ''">
+            ,s.house_phone = #{housePhone}
+        </if>
+        <if test="houseArea != null and houseArea != ''">
+            ,s.house_area = #{houseArea}
+        </if>
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            ,s.fee_type_cd = #{feeTypeCd}
+        </if>
+        <if test="feePrice != null and feePrice != ''">
+            ,s.fee_price = #{feePrice}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and s.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and s.agent_id = #{agentId}
+        </if>
+        <if test="houseId != null and houseId !=''">
+            and s.house_id = #{houseId}
+        </if>
+    </update>
+
+    <!-- 修改住户属性信息 add by wuxw 2018-07-03 -->
+    <update id="updateAgentHouseAttrInstance" parameterType="Map">
+        update a_agent_house_attr sa set sa.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,sa.b_id = #{newBId}
+        </if>
+        <if test="value != null and value != ''">
+            ,sa.value = #{value}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and sa.b_id = #{bId}
+        </if>
+        <if test="houseId != null and houseId !=''">
+            and sa.house_id = #{houseId}
+        </if>
+        <if test="specCd != null and specCd !=''">
+            and sa.spec_cd = #{specCd}
+        </if>
+        <if test="attrId != null and attrId !=''">
+            and sa.attr_id = #{attrId}
+        </if>
+    </update>
+
+    <!-- 修改商户照片信息 add by wuxw 2018-07-03 -->
+    <update id="updateAgentPhotoInstance" parameterType="Map">
+        update a_agent_photo sp set sp.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,sp.b_id = #{newBId}
+        </if>
+        <if test="agentPhotoTypeCd != null and agentPhotoTypeCd != ''">
+            ,sp.agent_photo_type_cd = #{agentPhotoTypeCd}
+        </if>
+        <if test="photo != null and photo != ''">
+            ,sp.photo = #{photo}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and sp.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and sp.agent_id = #{agentId}
+        </if>
+        <if test="agentPhotoId != null and agentPhotoId !=''">
+            and sp.agent_photo_id = #{agentPhotoId}
+        </if>
+    </update>
+
+    <!-- 修改商户证件信息 add by wuxw 2018-07-03 -->
+    <update id="updateAgentCerdentailsInstance" parameterType="Map">
+        update a_agent_cerdentials sc set sc.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,sc.b_id = #{newBId}
+        </if>
+        <if test="credentialsCd != null and credentialsCd != ''">
+            ,sc.credentials_cd = #{credentialsCd}
+        </if>
+        <if test="value != null and value != ''">
+            ,sc.value = #{value}
+        </if>
+        <if test="validityPeriod != null">
+            ,sc.validity_period = #{validityPeriod}
+        </if>
+        <if test="positivePhoto != null and positivePhoto != ''">
+            ,sc.positive_photo = #{positivePhoto}
+        </if>
+        <if test="negativePhoto != null and negativePhoto != ''">
+            ,sc.negative_photo = #{negativePhoto}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and sc.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and sc.agent_id = #{agentId}
+        </if>
+        <if test="agentCerdentialsId != null and agentCerdentialsId !=''">
+            and sc.agent_cerdentials_id = #{agentCerdentialsId}
+        </if>
+    </update>
+
+
+    <!-- 修改商户用户信息 add by wuxw 2018-07-03 -->
+    <update id="updateAgentUserInstance" parameterType="Map">
+        update a_agent_user sc set sc.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,sc.b_id = #{newBId}
+        </if>
+        <if test="relCd != null and relCd != ''">
+            ,sc.rel_cd = #{relCd}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and sc.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and sc.agent_id = #{agentId}
+        </if>
+        <if test="agentUserId != null and agentUserId !=''">
+            and sc.agent_user_id = #{agentUserId}
+        </if>
+    </update>
+
+
+    <!-- 修改商户用户信息 add by wuxw 2018-07-03 -->
+    <update id="updateAgentFeeInstance" parameterType="Map">
+        update a_agent_fee sc set sc.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,sc.b_id = #{newBId}
+        </if>
+        <if test="feeMoney != null and feeMoney != ''">
+            ,sc.fee_money = #{feeMoney}
+        </if>
+        <if test="feeTime != null and feeTime != ''">
+            ,sc.fee_time = #{feeTime}
+        </if>
+        <if test="startTime != null">
+            ,sc.start_time = #{startTime}
+        </if>
+        <if test="endTime != null">
+            ,sc.end_time = #{endTime}
+        </if>
+        where 1=1
+        <if test="bId != null and bId !=''">
+            and sc.b_id = #{bId}
+        </if>
+        <if test="agentId != null and agentId !=''">
+            and sc.agent_id = #{agentId}
+        </if>
+        <if test="feeId != null and feeId !=''">
+            and sc.fee_id = #{feeId}
+        </if>
+    </update>
+
+</mapper>

+ 17 - 1
java110-core/src/main/java/com/java110/core/factory/GenerateCodeFactory.java

@@ -73,8 +73,9 @@ public class GenerateCodeFactory {
         prefixMap.put("communityPhotoId","71");
         prefixMap.put("communityMemberId","72");
         prefixMap.put("agentId","80");
-        prefixMap.put("agentIdPhotoId","81");
+        prefixMap.put("agentPhotoId","81");
         prefixMap.put("agentCerdentialsId","82");
+        prefixMap.put("agentUserId","83");
         prefixMap.put("propertyId","90");
         prefixMap.put("propertyPhotoId","91");
         prefixMap.put("propertyCerdentialsId","92");
@@ -333,6 +334,21 @@ public class GenerateCodeFactory {
     }
 
 
+
+    /**
+     *
+     * @return
+     * @throws GenerateCodeException
+     */
+    public static String getAgentUserId()  throws GenerateCodeException{
+        if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
+            return prefixMap.get("agentUserId") +DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H)+ nextId("%06d");
+        }
+        //调用服务
+        return getCode(prefixMap.get("agentUserId"));
+    }
+
+
     /**
      * 获取小区ID
      * @return