Browse Source

优化代码

java110 5 years ago
parent
commit
7b2167a9fb
39 changed files with 3036 additions and 29 deletions
  1. 175 0
      docs/document/services/account/DeleteAccountInfo.md
  2. 175 0
      docs/document/services/account/SaveAccountInfo.md
  3. 188 0
      docs/document/services/account/UpdateAccountInfo.md
  4. 83 0
      java110-bean/src/main/java/com/java110/dto/account/AccountDto.java
  5. 53 0
      java110-bean/src/main/java/com/java110/po/account/AccountPo.java
  6. 1 0
      java110-core/src/main/java/com/java110/core/factory/GenerateCodeFactory.java
  7. 187 0
      java110-db/src/main/resources/mapper/acct/AccountServiceDaoImplMapper.xml
  8. 28 29
      java110-generator/src/main/resources/back/template_1.json
  9. 42 0
      java110-interface/src/main/java/com/java110/intf/acct/IAccountInnerServiceSMO.java
  10. 18 0
      java110-utils/src/main/java/com/java110/utils/constant/BusinessTypeConstant.java
  11. 31 0
      java110-utils/src/main/java/com/java110/utils/constant/ServiceCodeAccountConstant.java
  12. 1 0
      pom.xml
  13. 71 0
      service-acct/pom.xml
  14. 69 0
      service-acct/src/main/java/com/java110/acct/AcctServiceApplicationStart.java
  15. 81 0
      service-acct/src/main/java/com/java110/acct/dao/IAccountServiceDao.java
  16. 130 0
      service-acct/src/main/java/com/java110/acct/dao/impl/AccountServiceDaoImpl.java
  17. 16 0
      service-acct/src/main/java/com/java110/acct/kafka/AcctServiceBean.java
  18. 85 0
      service-acct/src/main/java/com/java110/acct/kafka/AcctServiceKafka.java
  19. 90 0
      service-acct/src/main/java/com/java110/acct/listener/account/AbstractAccountBusinessServiceDataFlowListener.java
  20. 176 0
      service-acct/src/main/java/com/java110/acct/listener/account/DeleteAccountInfoListener.java
  21. 176 0
      service-acct/src/main/java/com/java110/acct/listener/account/SaveAccountInfoListener.java
  22. 189 0
      service-acct/src/main/java/com/java110/acct/listener/account/UpdateAccountInfoListener.java
  23. 16 0
      service-acct/src/main/java/com/java110/acct/package-info.java
  24. 19 0
      service-acct/src/main/java/com/java110/acct/smo/IAcctServiceSMO.java
  25. 93 0
      service-acct/src/main/java/com/java110/acct/smo/impl/AccountInnerServiceSMOImpl.java
  26. 127 0
      service-acct/src/main/java/com/java110/acct/smo/impl/AcctServiceSMOImpl.java
  27. 97 0
      service-acct/src/main/resources/application-dev.yml
  28. 96 0
      service-acct/src/main/resources/application-prod.yml
  29. 96 0
      service-acct/src/main/resources/application-test.yml
  30. 3 0
      service-acct/src/main/resources/application.yml
  31. 15 0
      service-acct/src/main/resources/banner.txt
  32. 75 0
      service-acct/src/main/resources/dataSource.yml
  33. 3 0
      service-acct/src/main/resources/java110.properties
  34. 38 0
      service-api/src/main/java/com/java110/api/bmo/account/IAccountBMO.java
  35. 61 0
      service-api/src/main/java/com/java110/api/bmo/account/impl/AccountBMOImpl.java
  36. 49 0
      service-api/src/main/java/com/java110/api/listener/account/DeleteAccountListener.java
  37. 82 0
      service-api/src/main/java/com/java110/api/listener/account/ListAccountsListener.java
  38. 50 0
      service-api/src/main/java/com/java110/api/listener/account/SaveAccountListener.java
  39. 51 0
      service-api/src/main/java/com/java110/api/listener/account/UpdateAccountListener.java

+ 175 - 0
docs/document/services/account/DeleteAccountInfo.md

@@ -0,0 +1,175 @@
+package com.java110.acct.listener.account;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import com.java110.utils.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.acct.dao.IAccountServiceDao;
+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、businessAccount:{} 账户基本信息节点
+ * 2、businessAccountAttr:[{}] 账户属性信息节点
+ * 3、businessAccountPhoto:[{}] 账户照片信息节点
+ * 4、businessAccountCerdentials:[{}] 账户证件信息节点
+ * 协议地址 :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("deleteAccountInfoListener")
+@Transactional
+public class DeleteAccountInfoListener extends AbstractAccountBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(DeleteAccountInfoListener.class);
+    @Autowired
+    IAccountServiceDao accountServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 3;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_DELETE_ACCT;
+    }
+
+    /**
+     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+            //处理 businessAccount 节点
+            if(data.containsKey(AccountPo.class.getSimpleName())){
+                Object _obj = data.get(AccountPo.class.getSimpleName());
+                JSONArray businessAccounts = null;
+                if(_obj instanceof JSONObject){
+                    businessAccounts = new JSONArray();
+                    businessAccounts.add(_obj);
+                }else {
+                    businessAccounts = (JSONArray)_obj;
+                }
+                //JSONObject businessAccount = data.getJSONObject(AccountPo.class.getSimpleName());
+                for (int _accountIndex = 0; _accountIndex < businessAccounts.size();_accountIndex++) {
+                    JSONObject businessAccount = businessAccounts.getJSONObject(_accountIndex);
+                    doBusinessAccount(business, businessAccount);
+                    if(_obj instanceof JSONObject) {
+                        dataFlowContext.addParamOut("acctId", businessAccount.getString("acctId"));
+                    }
+                }
+
+        }
+
+
+    }
+
+    /**
+     * 删除 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> businessAccountInfos = accountServiceDaoImpl.getBusinessAccountInfo(info);
+        if( businessAccountInfos != null && businessAccountInfos.size() >0) {
+            for (int _accountIndex = 0; _accountIndex < businessAccountInfos.size();_accountIndex++) {
+                Map businessAccountInfo = businessAccountInfos.get(_accountIndex);
+                flushBusinessAccountInfo(businessAccountInfo,StatusConstant.STATUS_CD_INVALID);
+                accountServiceDaoImpl.updateAccountInfoInstance(businessAccountInfo);
+                dataFlowContext.addParamOut("acctId",businessAccountInfo.get("acct_id"));
+            }
+        }
+
+    }
+
+    /**
+     * 撤单
+     * 从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> accountInfo = accountServiceDaoImpl.getAccountInfo(info);
+        if(accountInfo != null && accountInfo.size() > 0){
+
+            //账户信息
+            List<Map> businessAccountInfos = accountServiceDaoImpl.getBusinessAccountInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessAccountInfos == null ||  businessAccountInfos.size() == 0){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(account),程序内部异常,请检查! "+delInfo);
+            }
+            for (int _accountIndex = 0; _accountIndex < businessAccountInfos.size();_accountIndex++) {
+                Map businessAccountInfo = businessAccountInfos.get(_accountIndex);
+                flushBusinessAccountInfo(businessAccountInfo,StatusConstant.STATUS_CD_VALID);
+                accountServiceDaoImpl.updateAccountInfoInstance(businessAccountInfo);
+            }
+        }
+    }
+
+
+
+    /**
+     * 处理 businessAccount 节点
+     * @param business 总的数据节点
+     * @param businessAccount 账户节点
+     */
+    private void doBusinessAccount(Business business,JSONObject businessAccount){
+
+        Assert.jsonObjectHaveKey(businessAccount,"acctId","businessAccount 节点下没有包含 acctId 节点");
+
+        if(businessAccount.getString("acctId").startsWith("-")){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"acctId 错误,不能自动生成(必须已经存在的acctId)"+businessAccount);
+        }
+        //自动插入DEL
+        autoSaveDelBusinessAccount(business,businessAccount);
+    }
+    @Override
+    public IAccountServiceDao getAccountServiceDaoImpl() {
+        return accountServiceDaoImpl;
+    }
+
+    public void setAccountServiceDaoImpl(IAccountServiceDao accountServiceDaoImpl) {
+        this.accountServiceDaoImpl = accountServiceDaoImpl;
+    }
+}

+ 175 - 0
docs/document/services/account/SaveAccountInfo.md

@@ -0,0 +1,175 @@
+package com.java110.acct.listener.account;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.util.Assert;
+import com.java110.acct.dao.IAccountServiceDao;
+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 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("saveAccountInfoListener")
+@Transactional
+public class SaveAccountInfoListener extends AbstractAccountBusinessServiceDataFlowListener{
+
+    private static Logger logger = LoggerFactory.getLogger(SaveAccountInfoListener.class);
+
+    @Autowired
+    private IAccountServiceDao accountServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_SAVE_ACCT;
+    }
+
+    /**
+     * 保存账户信息 business 表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessAccount 节点
+        if(data.containsKey(AccountPo.class.getSimpleName())){
+            Object bObj = data.get(AccountPo.class.getSimpleName());
+            JSONArray businessAccounts = null;
+            if(bObj instanceof JSONObject){
+                businessAccounts = new JSONArray();
+                businessAccounts.add(bObj);
+            }else {
+                businessAccounts = (JSONArray)bObj;
+            }
+            //JSONObject businessAccount = data.getJSONObject(AccountPo.class.getSimpleName());
+            for (int bAccountIndex = 0; bAccountIndex < businessAccounts.size();bAccountIndex++) {
+                JSONObject businessAccount = businessAccounts.getJSONObject(bAccountIndex);
+                doBusinessAccount(business, businessAccount);
+                if(bObj instanceof JSONObject) {
+                    dataFlowContext.addParamOut("acctId", businessAccount.getString("acctId"));
+                }
+            }
+        }
+    }
+
+    /**
+     * 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> businessAccountInfo = accountServiceDaoImpl.getBusinessAccountInfo(info);
+        if( businessAccountInfo != null && businessAccountInfo.size() >0) {
+            reFreshShareColumn(info, businessAccountInfo.get(0));
+            accountServiceDaoImpl.saveAccountInfoInstance(info);
+            if(businessAccountInfo.size() == 1) {
+                dataFlowContext.addParamOut("acctId", businessAccountInfo.get(0).get("acct_id"));
+            }
+        }
+    }
+
+
+    /**
+     * 刷 分片字段
+     *
+     * @param info         查询对象
+     * @param businessInfo 小区ID
+     */
+    private void reFreshShareColumn(Map info, Map businessInfo) {
+
+        if (info.containsKey("objId")) {
+            return;
+        }
+
+        if (!businessInfo.containsKey("obj_id")) {
+            return;
+        }
+
+        info.put("objId", businessInfo.get("obj_id"));
+    }
+    /**
+     * 撤单
+     * @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> accountInfo = accountServiceDaoImpl.getAccountInfo(info);
+        if(accountInfo != null && accountInfo.size() > 0){
+            reFreshShareColumn(paramIn, accountInfo.get(0));
+            accountServiceDaoImpl.updateAccountInfoInstance(paramIn);
+        }
+    }
+
+
+
+    /**
+     * 处理 businessAccount 节点
+     * @param business 总的数据节点
+     * @param businessAccount 账户节点
+     */
+    private void doBusinessAccount(Business business,JSONObject businessAccount){
+
+        Assert.jsonObjectHaveKey(businessAccount,"acctId","businessAccount 节点下没有包含 acctId 节点");
+
+        if(businessAccount.getString("acctId").startsWith("-")){
+            //刷新缓存
+            //flushAccountId(business.getDatas());
+
+            businessAccount.put("acctId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_acctId));
+
+        }
+
+        businessAccount.put("bId",business.getbId());
+        businessAccount.put("operate", StatusConstant.OPERATE_ADD);
+        //保存账户信息
+        accountServiceDaoImpl.saveBusinessAccountInfo(businessAccount);
+
+    }
+    @Override
+    public IAccountServiceDao getAccountServiceDaoImpl() {
+        return accountServiceDaoImpl;
+    }
+
+    public void setAccountServiceDaoImpl(IAccountServiceDao accountServiceDaoImpl) {
+        this.accountServiceDaoImpl = accountServiceDaoImpl;
+    }
+}

+ 188 - 0
docs/document/services/account/UpdateAccountInfo.md

@@ -0,0 +1,188 @@
+package com.java110.acct.listener.account;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import com.java110.utils.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.acct.dao.IAccountServiceDao;
+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、businessAccount:{} 账户基本信息节点
+ * 2、businessAccountAttr:[{}] 账户属性信息节点
+ * 3、businessAccountPhoto:[{}] 账户照片信息节点
+ * 4、businessAccountCerdentials:[{}] 账户证件信息节点
+ * 协议地址 :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("updateAccountInfoListener")
+@Transactional
+public class UpdateAccountInfoListener extends AbstractAccountBusinessServiceDataFlowListener {
+
+    private static Logger logger = LoggerFactory.getLogger(UpdateAccountInfoListener.class);
+    @Autowired
+    private IAccountServiceDao accountServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 2;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_ACCT;
+    }
+
+    /**
+     * business过程
+     * @param dataFlowContext 上下文对象
+     * @param business 业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+
+            //处理 businessAccount 节点
+            if(data.containsKey(AccountPo.class.getSimpleName())){
+                Object _obj = data.get(AccountPo.class.getSimpleName());
+                JSONArray businessAccounts = null;
+                if(_obj instanceof JSONObject){
+                    businessAccounts = new JSONArray();
+                    businessAccounts.add(_obj);
+                }else {
+                    businessAccounts = (JSONArray)_obj;
+                }
+                //JSONObject businessAccount = data.getJSONObject(AccountPo.class.getSimpleName());
+                for (int _accountIndex = 0; _accountIndex < businessAccounts.size();_accountIndex++) {
+                    JSONObject businessAccount = businessAccounts.getJSONObject(_accountIndex);
+                    doBusinessAccount(business, businessAccount);
+                    if(_obj instanceof JSONObject) {
+                        dataFlowContext.addParamOut("acctId", businessAccount.getString("acctId"));
+                    }
+                }
+            }
+    }
+
+
+    /**
+     * 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> businessAccountInfos = accountServiceDaoImpl.getBusinessAccountInfo(info);
+        if( businessAccountInfos != null && businessAccountInfos.size() >0) {
+            for (int _accountIndex = 0; _accountIndex < businessAccountInfos.size();_accountIndex++) {
+                Map businessAccountInfo = businessAccountInfos.get(_accountIndex);
+                flushBusinessAccountInfo(businessAccountInfo,StatusConstant.STATUS_CD_VALID);
+                accountServiceDaoImpl.updateAccountInfoInstance(businessAccountInfo);
+                if(businessAccountInfo.size() == 1) {
+                    dataFlowContext.addParamOut("acctId", businessAccountInfo.get("acct_id"));
+                }
+            }
+        }
+
+    }
+
+    /**
+     * 撤单
+     * @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> accountInfo = accountServiceDaoImpl.getAccountInfo(info);
+        if(accountInfo != null && accountInfo.size() > 0){
+
+            //账户信息
+            List<Map> businessAccountInfos = accountServiceDaoImpl.getBusinessAccountInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessAccountInfos == null || businessAccountInfos.size() == 0){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(account),程序内部异常,请检查! "+delInfo);
+            }
+            for (int _accountIndex = 0; _accountIndex < businessAccountInfos.size();_accountIndex++) {
+                Map businessAccountInfo = businessAccountInfos.get(_accountIndex);
+                flushBusinessAccountInfo(businessAccountInfo,StatusConstant.STATUS_CD_VALID);
+                accountServiceDaoImpl.updateAccountInfoInstance(businessAccountInfo);
+            }
+        }
+
+    }
+
+
+
+    /**
+     * 处理 businessAccount 节点
+     * @param business 总的数据节点
+     * @param businessAccount 账户节点
+     */
+    private void doBusinessAccount(Business business,JSONObject businessAccount){
+
+        Assert.jsonObjectHaveKey(businessAccount,"acctId","businessAccount 节点下没有包含 acctId 节点");
+
+        if(businessAccount.getString("acctId").startsWith("-")){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"acctId 错误,不能自动生成(必须已经存在的acctId)"+businessAccount);
+        }
+        //自动保存DEL
+        autoSaveDelBusinessAccount(business,businessAccount);
+
+        businessAccount.put("bId",business.getbId());
+        businessAccount.put("operate", StatusConstant.OPERATE_ADD);
+        //保存账户信息
+        accountServiceDaoImpl.saveBusinessAccountInfo(businessAccount);
+
+    }
+
+
+
+    @Override
+    public IAccountServiceDao getAccountServiceDaoImpl() {
+        return accountServiceDaoImpl;
+    }
+
+    public void setAccountServiceDaoImpl(IAccountServiceDao accountServiceDaoImpl) {
+        this.accountServiceDaoImpl = accountServiceDaoImpl;
+    }
+
+
+
+}

+ 83 - 0
java110-bean/src/main/java/com/java110/dto/account/AccountDto.java

@@ -0,0 +1,83 @@
+package com.java110.dto.account;
+
+import com.java110.dto.PageDto;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @ClassName FloorDto
+ * @Description 账户数据层封装
+ * @Author wuxw
+ * @Date 2019/4/24 8:52
+ * @Version 1.0
+ * add by wuxw 2019/4/24
+ **/
+public class AccountDto extends PageDto implements Serializable {
+
+    private String amount;
+private String acctType;
+private String objId;
+private String acctId;
+private String acctName;
+private String objType;
+
+
+    private Date createTime;
+
+    private String statusCd = "0";
+
+
+    public String getAmount() {
+        return amount;
+    }
+public void setAmount(String amount) {
+        this.amount = amount;
+    }
+public String getAcctType() {
+        return acctType;
+    }
+public void setAcctType(String acctType) {
+        this.acctType = acctType;
+    }
+public String getObjId() {
+        return objId;
+    }
+public void setObjId(String objId) {
+        this.objId = objId;
+    }
+public String getAcctId() {
+        return acctId;
+    }
+public void setAcctId(String acctId) {
+        this.acctId = acctId;
+    }
+public String getAcctName() {
+        return acctName;
+    }
+public void setAcctName(String acctName) {
+        this.acctName = acctName;
+    }
+public String getObjType() {
+        return objType;
+    }
+public void setObjType(String objType) {
+        this.objType = objType;
+    }
+
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getStatusCd() {
+        return statusCd;
+    }
+
+    public void setStatusCd(String statusCd) {
+        this.statusCd = statusCd;
+    }
+}

+ 53 - 0
java110-bean/src/main/java/com/java110/po/account/AccountPo.java

@@ -0,0 +1,53 @@
+package com.java110.po.account;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class AccountPo implements Serializable {
+
+    private String amount;
+private String acctType;
+private String objId;
+private String acctId;
+private String acctName;
+private String objType;
+public String getAmount() {
+        return amount;
+    }
+public void setAmount(String amount) {
+        this.amount = amount;
+    }
+public String getAcctType() {
+        return acctType;
+    }
+public void setAcctType(String acctType) {
+        this.acctType = acctType;
+    }
+public String getObjId() {
+        return objId;
+    }
+public void setObjId(String objId) {
+        this.objId = objId;
+    }
+public String getAcctId() {
+        return acctId;
+    }
+public void setAcctId(String acctId) {
+        this.acctId = acctId;
+    }
+public String getAcctName() {
+        return acctName;
+    }
+public void setAcctName(String acctName) {
+        this.acctName = acctName;
+    }
+public String getObjType() {
+        return objType;
+    }
+public void setObjType(String objType) {
+        this.objType = objType;
+    }
+
+
+
+}

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

@@ -202,6 +202,7 @@ public class GenerateCodeFactory {
     public static final String CODE_PREFIX_rsurId = "30";
     public static final String CODE_PREFIX_applyId = "29";
     public static final String CODE_PREFIX_prId = "30";
+    public static final String CODE_PREFIX_acctId = "31";
 
 
     /**

+ 187 - 0
java110-db/src/main/resources/mapper/acct/AccountServiceDaoImplMapper.xml

@@ -0,0 +1,187 @@
+<?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="accountServiceDaoImpl">
+
+    <!-- 保存账户信息 add by wuxw 2018-07-03 -->
+       <insert id="saveBusinessAccountInfo" parameterType="Map">
+           insert into business_account(
+amount,operate,acct_type,obj_id,acct_id,acct_name,b_id,obj_type
+) values (
+#{amount},#{operate},#{acctType},#{objId},#{acctId},#{acctName},#{bId},#{objType}
+)
+       </insert>
+
+
+       <!-- 查询账户信息(Business) add by wuxw 2018-07-03 -->
+       <select id="getBusinessAccountInfo" parameterType="Map" resultType="Map">
+           select  t.amount,t.operate,t.acct_type,t.acct_type acctType,t.obj_id,t.obj_id objId,t.acct_id,t.acct_id acctId,t.acct_name,t.acct_name acctName,t.b_id,t.b_id bId,t.obj_type,t.obj_type objType 
+from business_account t 
+where 1 =1 
+<if test="amount !=null and amount != ''">
+   and t.amount= #{amount}
+</if> 
+<if test="operate !=null and operate != ''">
+   and t.operate= #{operate}
+</if> 
+<if test="acctType !=null and acctType != ''">
+   and t.acct_type= #{acctType}
+</if> 
+<if test="objId !=null and objId != ''">
+   and t.obj_id= #{objId}
+</if> 
+<if test="acctId !=null and acctId != ''">
+   and t.acct_id= #{acctId}
+</if> 
+<if test="acctName !=null and acctName != ''">
+   and t.acct_name= #{acctName}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="objType !=null and objType != ''">
+   and t.obj_type= #{objType}
+</if> 
+
+       </select>
+
+
+
+
+
+    <!-- 保存账户信息至 instance表中 add by wuxw 2018-07-03 -->
+    <insert id="saveAccountInfoInstance" parameterType="Map">
+        insert into account(
+amount,acct_type,obj_id,acct_id,status_cd,acct_name,b_id,obj_type
+) select t.amount,t.acct_type,t.obj_id,t.acct_id,'0',t.acct_name,t.b_id,t.obj_type from business_account t where 1=1
+<if test="amount !=null and amount != ''">
+   and t.amount= #{amount}
+</if> 
+   and t.operate= 'ADD'
+<if test="acctType !=null and acctType != ''">
+   and t.acct_type= #{acctType}
+</if> 
+<if test="objId !=null and objId != ''">
+   and t.obj_id= #{objId}
+</if> 
+<if test="acctId !=null and acctId != ''">
+   and t.acct_id= #{acctId}
+</if> 
+<if test="acctName !=null and acctName != ''">
+   and t.acct_name= #{acctName}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="objType !=null and objType != ''">
+   and t.obj_type= #{objType}
+</if> 
+
+    </insert>
+
+
+
+    <!-- 查询账户信息 add by wuxw 2018-07-03 -->
+    <select id="getAccountInfo" parameterType="Map" resultType="Map">
+        select  t.amount,t.acct_type,t.acct_type acctType,t.obj_id,t.obj_id objId,t.acct_id,t.acct_id acctId,t.status_cd,t.status_cd statusCd,t.acct_name,t.acct_name acctName,t.b_id,t.b_id bId,t.obj_type,t.obj_type objType 
+from account t 
+where 1 =1 
+<if test="amount !=null and amount != ''">
+   and t.amount= #{amount}
+</if> 
+<if test="acctType !=null and acctType != ''">
+   and t.acct_type= #{acctType}
+</if> 
+<if test="objId !=null and objId != ''">
+   and t.obj_id= #{objId}
+</if> 
+<if test="acctId !=null and acctId != ''">
+   and t.acct_id= #{acctId}
+</if> 
+<if test="statusCd !=null and statusCd != ''">
+   and t.status_cd= #{statusCd}
+</if> 
+<if test="acctName !=null and acctName != ''">
+   and t.acct_name= #{acctName}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="objType !=null and objType != ''">
+   and t.obj_type= #{objType}
+</if> 
+order by t.create_time desc
+<if test="page != -1 and page != null ">
+   limit #{page}, #{row}
+</if> 
+
+    </select>
+
+
+
+
+    <!-- 修改账户信息 add by wuxw 2018-07-03 -->
+    <update id="updateAccountInfoInstance" parameterType="Map">
+        update  account t set t.status_cd = #{statusCd}
+<if test="newBId != null and newBId != ''">
+,t.b_id = #{newBId}
+</if> 
+<if test="amount !=null and amount != ''">
+, t.amount= #{amount}
+</if> 
+<if test="acctType !=null and acctType != ''">
+, t.acct_type= #{acctType}
+</if> 
+<if test="objId !=null and objId != ''">
+, t.obj_id= #{objId}
+</if> 
+<if test="acctName !=null and acctName != ''">
+, t.acct_name= #{acctName}
+</if> 
+<if test="objType !=null and objType != ''">
+, t.obj_type= #{objType}
+</if> 
+ where 1=1 <if test="acctId !=null and acctId != ''">
+and t.acct_id= #{acctId}
+</if> 
+<if test="bId !=null and bId != ''">
+and t.b_id= #{bId}
+</if> 
+
+    </update>
+
+    <!-- 查询账户数量 add by wuxw 2018-07-03 -->
+     <select id="queryAccountsCount" parameterType="Map" resultType="Map">
+        select  count(1) count 
+from account t 
+where 1 =1 
+<if test="amount !=null and amount != ''">
+   and t.amount= #{amount}
+</if> 
+<if test="acctType !=null and acctType != ''">
+   and t.acct_type= #{acctType}
+</if> 
+<if test="objId !=null and objId != ''">
+   and t.obj_id= #{objId}
+</if> 
+<if test="acctId !=null and acctId != ''">
+   and t.acct_id= #{acctId}
+</if> 
+<if test="statusCd !=null and statusCd != ''">
+   and t.status_cd= #{statusCd}
+</if> 
+<if test="acctName !=null and acctName != ''">
+   and t.acct_name= #{acctName}
+</if> 
+<if test="bId !=null and bId != ''">
+   and t.b_id= #{bId}
+</if> 
+<if test="objType !=null and objType != ''">
+   and t.obj_type= #{objType}
+</if> 
+
+
+     </select>
+
+</mapper>

+ 28 - 29
java110-generator/src/main/resources/back/template_1.json

@@ -1,47 +1,46 @@
 {
   "autoMove": true,
-  "id": "applyId",
-  "name": "allocationStorehouseApply",
-  "desc": "调拨申请",
-  "shareParam": "storeId",
-  "shareColumn": "store_id",
-  "shareName": "store",
-  "newBusinessTypeCd": "BUSINESS_TYPE_SAVE_ALLOCATION_STOREHOUSE_APPLY",
-  "updateBusinessTypeCd": "BUSINESS_TYPE_UPDATE_ALLOCATION_STOREHOUSE_APPLY",
-  "deleteBusinessTypeCd": "BUSINESS_TYPE_DELETE_ALLOCATION_STOREHOUSE_APPLY",
-  "newBusinessTypeCdValue": "681100030006",
-  "updateBusinessTypeCdValue": "681100040006",
-  "deleteBusinessTypeCdValue": "681100050006",
-  "businessTableName": "business_allocation_storehouse_apply",
-  "tableName": "allocation_storehouse_apply",
+  "id": "acctId",
+  "name": "account",
+  "desc": "账户",
+  "shareParam": "objId",
+  "shareColumn": "obj_id",
+  "shareName": "acct",
+  "newBusinessTypeCd": "BUSINESS_TYPE_SAVE_ACCT",
+  "updateBusinessTypeCd": "BUSINESS_TYPE_UPDATE_ACCT",
+  "deleteBusinessTypeCd": "BUSINESS_TYPE_DELETE_ACCT",
+  "newBusinessTypeCdValue": "121100030001",
+  "updateBusinessTypeCdValue": "121100040001",
+  "deleteBusinessTypeCdValue": "121100050001",
+  "businessTableName": "business_account",
+  "tableName": "account",
   "param": {
-    "applyId": "apply_id",
-    "startUserId": "start_user_id",
-    "startUserName": "start_user_name",
+    "acctId": "acct_id",
+    "acctName": "acct_name",
+    "acctType": "acct_type",
     "bId": "b_id",
-    "storeId": "store_id",
-    "remark": "remark",
-    "applyCount": "apply_count",
-    "state": "state",
+    "amount": "amount",
+    "objType": "obj_type",
+    "objId": "obj_id",
     "statusCd": "status_cd",
     "operate": "operate"
   },
   "required": [
     {
-      "code": "startUserId",
-      "msg": "申请人不能为空"
+      "code": "acctName",
+      "msg": "账户名称不能为空"
     },
     {
-      "code": "startUserName",
-      "msg": "申请人不能为空"
+      "code": "acctType",
+      "msg": "账户类型不能为空"
     },
     {
-      "code": "remark",
-      "msg": "申请说明不能为空"
+      "code": "amount",
+      "msg": "账户金额不能为空"
     },
     {
-      "code": "storeId",
-      "msg": "商户不能为空"
+      "code": "objId",
+      "msg": "账户对象不能为空"
     }
   ]
 }

+ 42 - 0
java110-interface/src/main/java/com/java110/intf/acct/IAccountInnerServiceSMO.java

@@ -0,0 +1,42 @@
+package com.java110.intf.acct;
+
+import com.java110.config.feign.FeignConfiguration;
+import com.java110.dto.account.AccountDto;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import java.util.List;
+
+/**
+ * @ClassName IAccountInnerServiceSMO
+ * @Description 账户接口类
+ * @Author wuxw
+ * @Date 2019/4/24 9:04
+ * @Version 1.0
+ * add by wuxw 2019/4/24
+ **/
+@FeignClient(name = "acct-service", configuration = {FeignConfiguration.class})
+@RequestMapping("/accountApi")
+public interface IAccountInnerServiceSMO {
+
+    /**
+     * <p>查询小区楼信息</p>
+     *
+     *
+     * @param accountDto 数据对象分享
+     * @return AccountDto 对象数据
+     */
+    @RequestMapping(value = "/queryAccounts", method = RequestMethod.POST)
+    List<AccountDto> queryAccounts(@RequestBody AccountDto accountDto);
+
+    /**
+     * 查询<p>小区楼</p>总记录数
+     *
+     * @param accountDto 数据对象分享
+     * @return 小区下的小区楼记录数
+     */
+    @RequestMapping(value = "/queryAccountsCount", method = RequestMethod.POST)
+    int queryAccountsCount(@RequestBody AccountDto accountDto);
+}

+ 18 - 0
java110-utils/src/main/java/com/java110/utils/constant/BusinessTypeConstant.java

@@ -1572,4 +1572,22 @@ public class BusinessTypeConstant {
     public static final String BUSINESS_TYPE_DELETE_ALLOCATION_STOREHOUSE_APPLY="681100050006";
 
 
+    /**
+     *  添加账户
+     *  3保存
+     */
+    public static final String BUSINESS_TYPE_SAVE_ACCT="121100030001";
+
+    /**
+     *  修改账户
+     *  3保存
+     */
+    public static final String BUSINESS_TYPE_UPDATE_ACCT="121100040001";
+
+    /**
+     * 删除账户
+     */
+    public static final String BUSINESS_TYPE_DELETE_ACCT="121100050001";
+
+
 }

+ 31 - 0
java110-utils/src/main/java/com/java110/utils/constant/ServiceCodeAccountConstant.java

@@ -0,0 +1,31 @@
+package com.java110.utils.constant;
+
+/**
+ * 账户常量类
+ * Created by wuxw on 2017/5/20.
+ */
+public class ServiceCodeAccountConstant {
+
+    /**
+     * 添加 账户
+     */
+    public static final String ADD_ACCOUNT = "account.saveAccount";
+
+
+    /**
+     * 修改 账户
+     */
+    public static final String UPDATE_ACCOUNT = "account.updateAccount";
+    /**
+     * 删除 账户
+     */
+    public static final String DELETE_ACCOUNT = "account.deleteAccount";
+
+
+    /**
+     * 查询 账户
+     */
+    public static final String LIST_ACCOUNTS = "account.listAccounts";
+
+
+}

+ 1 - 0
pom.xml

@@ -28,6 +28,7 @@
         <module>service-front</module>
         <module>service-goods</module>
         <module>java110-generator</module>
+        <module>service-acct</module>
 
     </modules>
 

+ 71 - 0
service-acct/pom.xml

@@ -0,0 +1,71 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>MicroCommunity</artifactId>
+    <groupId>com.java110</groupId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>service-acct</artifactId>
+  <packaging>jar</packaging>
+
+  <name>service-acct</name>
+  <url>http://maven.apache.org</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.source>1.7</maven.compiler.source>
+    <maven.compiler.target>1.7</maven.compiler.target>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>com.java110</groupId>
+      <artifactId>java110-service</artifactId>
+    </dependency>
+
+
+  </dependencies>
+
+
+  <build>
+    <finalName>service-acct</finalName>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <version>2.10</version>
+        <executions>
+          <execution>
+            <id>unpack</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>unpack</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>com.java110</groupId>
+                  <artifactId>java110-interface</artifactId>
+                  <version>${microcommunity.version}</version>
+                  <type>jar</type>
+                  <overWrite>true</overWrite>
+                  <outputDirectory>${project.build.directory}/classes</outputDirectory>
+                </artifactItem>
+              </artifactItems>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+        <configuration>
+          <mainClass>com.java110.user.AcctServiceApplicationStart</mainClass>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

+ 69 - 0
service-acct/src/main/java/com/java110/acct/AcctServiceApplicationStart.java

@@ -0,0 +1,69 @@
+package com.java110.acct;
+
+import com.java110.core.annotation.Java110ListenerDiscovery;
+import com.java110.core.client.RestTemplate;
+import com.java110.core.event.service.BusinessServiceDataFlowEventPublishing;
+import com.java110.service.init.ServiceStartInit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.http.converter.StringHttpMessageConverter;
+
+import java.nio.charset.Charset;
+
+
+/**
+ * spring boot 初始化启动类
+ *
+ * @version v0.1
+ * @auther com.java110.wuxw
+ * @mail 928255095@qq.com
+ * @date 2016年8月6日
+ * @tag
+ */
+@SpringBootApplication(
+        scanBasePackages = {"com.java110.service","com.java110.core", "com.java110.acct",  "com.java110.config.properties.code", "com.java110.db"},
+        excludeName = {"com.java110.intf.acct"}
+)
+@EnableDiscoveryClient
+@Java110ListenerDiscovery(listenerPublishClass = BusinessServiceDataFlowEventPublishing.class,
+        basePackages = {"com.java110.acct.listener"})
+@EnableFeignClients(basePackages = {"com.java110.intf.community","com.java110.intf.common","com.java110.intf.store",
+        "com.java110.intf.fee","com.java110.intf.order","com.java110.intf.user"})
+public class AcctServiceApplicationStart {
+
+    private static Logger logger = LoggerFactory.getLogger(AcctServiceApplicationStart.class);
+
+    private static final String LISTENER_PATH = "java110.UserService.listeners";
+
+    public static void main(String[] args) throws Exception {
+        try {
+            ApplicationContext context = SpringApplication.run(AcctServiceApplicationStart.class, args);
+            ServiceStartInit.initSystemConfig(context);
+            //加载业务侦听
+            // SystemStartLoadBusinessConfigure.initSystemConfig(LISTENER_PATH);
+        } catch (Throwable e) {
+            logger.error("系统启动失败", e);
+        }
+    }
+
+    /**
+     * 实例化RestTemplate,通过@LoadBalanced注解开启均衡负载能力.
+     *
+     * @return restTemplate
+     */
+    @Bean
+    @LoadBalanced
+    public RestTemplate restTemplate() {
+        StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8"));
+        RestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build(RestTemplate.class);
+        return restTemplate;
+    }
+}

+ 81 - 0
service-acct/src/main/java/com/java110/acct/dao/IAccountServiceDao.java

@@ -0,0 +1,81 @@
+package com.java110.acct.dao;
+
+
+import com.java110.utils.exception.DAOException;
+import com.java110.entity.merchant.BoMerchant;
+import com.java110.entity.merchant.BoMerchantAttr;
+import com.java110.entity.merchant.Merchant;
+import com.java110.entity.merchant.MerchantAttr;
+
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 账户组件内部之间使用,没有给外围系统提供服务能力
+ * 账户服务接口类,要求全部以字符串传输,方便微服务化
+ * 新建客户,修改客户,删除客户,查询客户等功能
+ *
+ * Created by wuxw on 2016/12/27.
+ */
+public interface IAccountServiceDao {
+
+    /**
+     * 保存 账户信息
+     * @param businessAccountInfo 账户信息 封装
+     * @throws DAOException 操作数据库异常
+     */
+    void saveBusinessAccountInfo(Map businessAccountInfo) throws DAOException;
+
+
+
+    /**
+     * 查询账户信息(business过程)
+     * 根据bId 查询账户信息
+     * @param info bId 信息
+     * @return 账户信息
+     * @throws DAOException DAO异常
+     */
+    List<Map> getBusinessAccountInfo(Map info) throws DAOException;
+
+
+
+
+    /**
+     * 保存 账户信息 Business数据到 Instance中
+     * @param info
+     * @throws DAOException DAO异常
+     */
+    void saveAccountInfoInstance(Map info) throws DAOException;
+
+
+
+
+    /**
+     * 查询账户信息(instance过程)
+     * 根据bId 查询账户信息
+     * @param info bId 信息
+     * @return 账户信息
+     * @throws DAOException DAO异常
+     */
+    List<Map> getAccountInfo(Map info) throws DAOException;
+
+
+
+    /**
+     * 修改账户信息
+     * @param info 修改信息
+     * @throws DAOException DAO异常
+     */
+    void updateAccountInfoInstance(Map info) throws DAOException;
+
+
+    /**
+     * 查询账户总数
+     *
+     * @param info 账户信息
+     * @return 账户数量
+     */
+    int queryAccountsCount(Map info);
+
+}

+ 130 - 0
service-acct/src/main/java/com/java110/acct/dao/impl/AccountServiceDaoImpl.java

@@ -0,0 +1,130 @@
+package com.java110.acct.dao.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.exception.DAOException;
+import com.java110.utils.util.DateUtil;
+import com.java110.core.base.dao.BaseServiceDao;
+import com.java110.acct.dao.IAccountServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 账户服务 与数据库交互
+ * Created by wuxw on 2017/4/5.
+ */
+@Service("accountServiceDaoImpl")
+//@Transactional
+public class AccountServiceDaoImpl extends BaseServiceDao implements IAccountServiceDao {
+
+    private static Logger logger = LoggerFactory.getLogger(AccountServiceDaoImpl.class);
+
+    /**
+     * 账户信息封装
+     * @param businessAccountInfo 账户信息 封装
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public void saveBusinessAccountInfo(Map businessAccountInfo) throws DAOException {
+        businessAccountInfo.put("month", DateUtil.getCurrentMonth());
+        // 查询business_user 数据是否已经存在
+        logger.debug("保存账户信息 入参 businessAccountInfo : {}",businessAccountInfo);
+        int saveFlag = sqlSessionTemplate.insert("accountServiceDaoImpl.saveBusinessAccountInfo",businessAccountInfo);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存账户数据失败:"+ JSONObject.toJSONString(businessAccountInfo));
+        }
+    }
+
+
+    /**
+     * 查询账户信息
+     * @param info bId 信息
+     * @return 账户信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public List<Map> getBusinessAccountInfo(Map info) throws DAOException {
+
+        logger.debug("查询账户信息 入参 info : {}",info);
+
+        List<Map> businessAccountInfos = sqlSessionTemplate.selectList("accountServiceDaoImpl.getBusinessAccountInfo",info);
+
+        return businessAccountInfos;
+    }
+
+
+
+    /**
+     * 保存账户信息 到 instance
+     * @param info   bId 信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public void saveAccountInfoInstance(Map info) throws DAOException {
+        logger.debug("保存账户信息Instance 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.insert("accountServiceDaoImpl.saveAccountInfoInstance",info);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存账户信息Instance数据失败:"+ JSONObject.toJSONString(info));
+        }
+    }
+
+
+    /**
+     * 查询账户信息(instance)
+     * @param info bId 信息
+     * @return List<Map>
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public List<Map> getAccountInfo(Map info) throws DAOException {
+        logger.debug("查询账户信息 入参 info : {}",info);
+
+        List<Map> businessAccountInfos = sqlSessionTemplate.selectList("accountServiceDaoImpl.getAccountInfo",info);
+
+        return businessAccountInfos;
+    }
+
+
+    /**
+     * 修改账户信息
+     * @param info 修改信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public void updateAccountInfoInstance(Map info) throws DAOException {
+        logger.debug("修改账户信息Instance 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.update("accountServiceDaoImpl.updateAccountInfoInstance",info);
+
+        if(saveFlag < 1){
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改账户信息Instance数据失败:"+ JSONObject.toJSONString(info));
+        }
+    }
+
+     /**
+     * 查询账户数量
+     * @param info 账户信息
+     * @return 账户数量
+     */
+    @Override
+    public int queryAccountsCount(Map info) {
+        logger.debug("查询账户数据 入参 info : {}",info);
+
+        List<Map> businessAccountInfos = sqlSessionTemplate.selectList("accountServiceDaoImpl.queryAccountsCount", info);
+        if (businessAccountInfos.size() < 1) {
+            return 0;
+        }
+
+        return Integer.parseInt(businessAccountInfos.get(0).get("count").toString());
+    }
+
+
+}

+ 16 - 0
service-acct/src/main/java/com/java110/acct/kafka/AcctServiceBean.java

@@ -0,0 +1,16 @@
+package com.java110.acct.kafka;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created by wuxw on 2018/4/15.
+ */
+@Configuration
+public class AcctServiceBean {
+    @Bean
+    public AcctServiceKafka listener() {
+        return new AcctServiceKafka();
+    }
+
+}

+ 85 - 0
service-acct/src/main/java/com/java110/acct/kafka/AcctServiceKafka.java

@@ -0,0 +1,85 @@
+package com.java110.acct.kafka;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.acct.smo.IAcctServiceSMO;
+import com.java110.core.base.controller.BaseController;
+import com.java110.core.context.BusinessServiceDataFlow;
+import com.java110.core.factory.DataTransactionFactory;
+import com.java110.utils.constant.KafkaConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.InitConfigDataException;
+import com.java110.utils.exception.InitDataFlowContextException;
+import com.java110.utils.kafka.KafkaFactory;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.kafka.annotation.KafkaListener;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * kafka侦听
+ * Created by wuxw on 2018/4/15.
+ */
+public class AcctServiceKafka extends BaseController {
+
+    private final static Logger logger = LoggerFactory.getLogger(AcctServiceKafka.class);
+
+    @Autowired
+    private IAcctServiceSMO acctServiceSMOImpl;
+
+    @KafkaListener(topics = {"userServiceTopic"})
+    public void listen(ConsumerRecord<?, ?> record) {
+        logger.info("kafka的key: " + record.key());
+        logger.info("kafka的value: " + record.value().toString());
+        String orderInfo = record.value().toString();
+        BusinessServiceDataFlow businessServiceDataFlow = null;
+        JSONObject responseJson = null;
+        try {
+            Map<String, String> headers = new HashMap<String, String>();
+            //预校验
+            preValiateOrderInfo(orderInfo);
+            businessServiceDataFlow = this.writeDataToDataFlowContext(orderInfo, headers);
+            responseJson = acctServiceSMOImpl.service(businessServiceDataFlow);
+        } catch (InitDataFlowContextException e) {
+            logger.error("请求报文错误,初始化 BusinessServiceDataFlow失败" + orderInfo, e);
+            responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo, ResponseConstant.RESULT_PARAM_ERROR, e.getMessage(), null);
+        } catch (InitConfigDataException e) {
+            logger.error("请求报文错误,加载配置信息失败" + orderInfo, e);
+            responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo, ResponseConstant.RESULT_PARAM_ERROR, e.getMessage(), null);
+        } catch (Exception e) {
+            logger.error("请求订单异常", e);
+            responseJson = DataTransactionFactory.createBusinessResponseJson(businessServiceDataFlow, ResponseConstant.RESULT_CODE_ERROR, e.getMessage() + e,
+                    null);
+        } finally {
+            logger.debug("当前请求报文:" + orderInfo + ", 当前返回报文:" + responseJson.toJSONString());
+            //只有business 和 instance 过程才做通知消息
+            if (!StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(responseJson.getString("businessType"))
+                    && !StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(responseJson.getString("businessType"))) {
+                return;
+            }
+            try {
+                KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_NOTIFY_CENTER_SERVICE_NAME, "", responseJson.toJSONString());
+            } catch (Exception e) {
+                logger.error("用户服务通知centerService失败" + responseJson, e);
+                //这里保存异常信息
+            }
+        }
+    }
+
+
+    /**
+     * 这里预校验,请求报文中不能有 dataFlowId
+     *
+     * @param orderInfo
+     */
+    private void preValiateOrderInfo(String orderInfo) {
+       /* if(JSONObject.parseObject(orderInfo).getJSONObject("orders").containsKey("dataFlowId")){
+            throw new BusinessException(ResponseConstant.RESULT_CODE_ERROR,"报文中不能存在dataFlowId节点");
+        }*/
+    }
+
+}

+ 90 - 0
service-acct/src/main/java/com/java110/acct/listener/account/AbstractAccountBusinessServiceDataFlowListener.java

@@ -0,0 +1,90 @@
+package com.java110.acct.listener.account;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.acct.dao.IAccountServiceDao;
+import com.java110.core.event.service.AbstractBusinessServiceDataFlowListener;
+import com.java110.entity.center.Business;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 账户 服务侦听 父类
+ * Created by wuxw on 2018/7/4.
+ */
+public abstract class AbstractAccountBusinessServiceDataFlowListener extends AbstractBusinessServiceDataFlowListener {
+    private static Logger logger = LoggerFactory.getLogger(AbstractAccountBusinessServiceDataFlowListener.class);
+
+
+    /**
+     * 获取 DAO工具类
+     *
+     * @return
+     */
+    public abstract IAccountServiceDao getAccountServiceDaoImpl();
+
+    /**
+     * 刷新 businessAccountInfo 数据
+     * 主要将 数据库 中字段和 接口传递字段建立关系
+     *
+     * @param businessAccountInfo
+     */
+    protected void flushBusinessAccountInfo(Map businessAccountInfo, String statusCd) {
+        businessAccountInfo.put("newBId", businessAccountInfo.get("b_id"));
+        businessAccountInfo.put("amount", businessAccountInfo.get("amount"));
+        businessAccountInfo.put("operate", businessAccountInfo.get("operate"));
+        businessAccountInfo.put("acctType", businessAccountInfo.get("acct_type"));
+        businessAccountInfo.put("objId", businessAccountInfo.get("obj_id"));
+        businessAccountInfo.put("acctId", businessAccountInfo.get("acct_id"));
+        businessAccountInfo.put("acctName", businessAccountInfo.get("acct_name"));
+        businessAccountInfo.put("objType", businessAccountInfo.get("obj_type"));
+        businessAccountInfo.remove("bId");
+        businessAccountInfo.put("statusCd", statusCd);
+    }
+
+
+    /**
+     * 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
+     *
+     * @param businessAccount 账户信息
+     */
+    protected void autoSaveDelBusinessAccount(Business business, JSONObject businessAccount) {
+//自动插入DEL
+        Map info = new HashMap();
+        info.put("acctId", businessAccount.getString("acctId"));
+        info.put("statusCd", StatusConstant.STATUS_CD_VALID);
+        List<Map> currentAccountInfos = getAccountServiceDaoImpl().getAccountInfo(info);
+        if (currentAccountInfos == null || currentAccountInfos.size() != 1) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "未找到需要修改数据信息,入参错误或数据有问题,请检查" + info);
+        }
+
+        Map currentAccountInfo = currentAccountInfos.get(0);
+
+        currentAccountInfo.put("bId", business.getbId());
+
+        currentAccountInfo.put("amount", currentAccountInfo.get("amount"));
+        currentAccountInfo.put("operate", currentAccountInfo.get("operate"));
+        currentAccountInfo.put("acctType", currentAccountInfo.get("acct_type"));
+        currentAccountInfo.put("objId", currentAccountInfo.get("obj_id"));
+        currentAccountInfo.put("acctId", currentAccountInfo.get("acct_id"));
+        currentAccountInfo.put("acctName", currentAccountInfo.get("acct_name"));
+        currentAccountInfo.put("objType", currentAccountInfo.get("obj_type"));
+
+
+        currentAccountInfo.put("operate", StatusConstant.OPERATE_DEL);
+        getAccountServiceDaoImpl().saveBusinessAccountInfo(currentAccountInfo);
+        for (Object key : currentAccountInfo.keySet()) {
+            if (businessAccount.get(key) == null) {
+                businessAccount.put(key.toString(), currentAccountInfo.get(key));
+            }
+        }
+    }
+
+
+}

+ 176 - 0
service-acct/src/main/java/com/java110/acct/listener/account/DeleteAccountInfoListener.java

@@ -0,0 +1,176 @@
+package com.java110.acct.listener.account;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.po.account.AccountPo;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import com.java110.utils.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.acct.dao.IAccountServiceDao;
+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、businessAccount:{} 账户基本信息节点
+ * 2、businessAccountAttr:[{}] 账户属性信息节点
+ * 3、businessAccountPhoto:[{}] 账户照片信息节点
+ * 4、businessAccountCerdentials:[{}] 账户证件信息节点
+ * 协议地址 :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("deleteAccountInfoListener")
+@Transactional
+public class DeleteAccountInfoListener extends AbstractAccountBusinessServiceDataFlowListener {
+
+    private final static Logger logger = LoggerFactory.getLogger(DeleteAccountInfoListener.class);
+    @Autowired
+    IAccountServiceDao accountServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 3;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_DELETE_ACCT;
+    }
+
+    /**
+     * 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+            //处理 businessAccount 节点
+            if(data.containsKey(AccountPo.class.getSimpleName())){
+                Object _obj = data.get(AccountPo.class.getSimpleName());
+                JSONArray businessAccounts = null;
+                if(_obj instanceof JSONObject){
+                    businessAccounts = new JSONArray();
+                    businessAccounts.add(_obj);
+                }else {
+                    businessAccounts = (JSONArray)_obj;
+                }
+                //JSONObject businessAccount = data.getJSONObject(AccountPo.class.getSimpleName());
+                for (int _accountIndex = 0; _accountIndex < businessAccounts.size();_accountIndex++) {
+                    JSONObject businessAccount = businessAccounts.getJSONObject(_accountIndex);
+                    doBusinessAccount(business, businessAccount);
+                    if(_obj instanceof JSONObject) {
+                        dataFlowContext.addParamOut("acctId", businessAccount.getString("acctId"));
+                    }
+                }
+
+        }
+
+
+    }
+
+    /**
+     * 删除 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> businessAccountInfos = accountServiceDaoImpl.getBusinessAccountInfo(info);
+        if( businessAccountInfos != null && businessAccountInfos.size() >0) {
+            for (int _accountIndex = 0; _accountIndex < businessAccountInfos.size();_accountIndex++) {
+                Map businessAccountInfo = businessAccountInfos.get(_accountIndex);
+                flushBusinessAccountInfo(businessAccountInfo,StatusConstant.STATUS_CD_INVALID);
+                accountServiceDaoImpl.updateAccountInfoInstance(businessAccountInfo);
+                dataFlowContext.addParamOut("acctId",businessAccountInfo.get("acct_id"));
+            }
+        }
+
+    }
+
+    /**
+     * 撤单
+     * 从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> accountInfo = accountServiceDaoImpl.getAccountInfo(info);
+        if(accountInfo != null && accountInfo.size() > 0){
+
+            //账户信息
+            List<Map> businessAccountInfos = accountServiceDaoImpl.getBusinessAccountInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessAccountInfos == null ||  businessAccountInfos.size() == 0){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(account),程序内部异常,请检查! "+delInfo);
+            }
+            for (int _accountIndex = 0; _accountIndex < businessAccountInfos.size();_accountIndex++) {
+                Map businessAccountInfo = businessAccountInfos.get(_accountIndex);
+                flushBusinessAccountInfo(businessAccountInfo,StatusConstant.STATUS_CD_VALID);
+                accountServiceDaoImpl.updateAccountInfoInstance(businessAccountInfo);
+            }
+        }
+    }
+
+
+
+    /**
+     * 处理 businessAccount 节点
+     * @param business 总的数据节点
+     * @param businessAccount 账户节点
+     */
+    private void doBusinessAccount(Business business,JSONObject businessAccount){
+
+        Assert.jsonObjectHaveKey(businessAccount,"acctId","businessAccount 节点下没有包含 acctId 节点");
+
+        if(businessAccount.getString("acctId").startsWith("-")){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"acctId 错误,不能自动生成(必须已经存在的acctId)"+businessAccount);
+        }
+        //自动插入DEL
+        autoSaveDelBusinessAccount(business,businessAccount);
+    }
+    @Override
+    public IAccountServiceDao getAccountServiceDaoImpl() {
+        return accountServiceDaoImpl;
+    }
+
+    public void setAccountServiceDaoImpl(IAccountServiceDao accountServiceDaoImpl) {
+        this.accountServiceDaoImpl = accountServiceDaoImpl;
+    }
+}

+ 176 - 0
service-acct/src/main/java/com/java110/acct/listener/account/SaveAccountInfoListener.java

@@ -0,0 +1,176 @@
+package com.java110.acct.listener.account;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.po.account.AccountPo;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.util.Assert;
+import com.java110.acct.dao.IAccountServiceDao;
+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 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("saveAccountInfoListener")
+@Transactional
+public class SaveAccountInfoListener extends AbstractAccountBusinessServiceDataFlowListener{
+
+    private static Logger logger = LoggerFactory.getLogger(SaveAccountInfoListener.class);
+
+    @Autowired
+    private IAccountServiceDao accountServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_SAVE_ACCT;
+    }
+
+    /**
+     * 保存账户信息 business 表中
+     * @param dataFlowContext 数据对象
+     * @param business 当前业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+        JSONObject data = business.getDatas();
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+        //处理 businessAccount 节点
+        if(data.containsKey(AccountPo.class.getSimpleName())){
+            Object bObj = data.get(AccountPo.class.getSimpleName());
+            JSONArray businessAccounts = null;
+            if(bObj instanceof JSONObject){
+                businessAccounts = new JSONArray();
+                businessAccounts.add(bObj);
+            }else {
+                businessAccounts = (JSONArray)bObj;
+            }
+            //JSONObject businessAccount = data.getJSONObject(AccountPo.class.getSimpleName());
+            for (int bAccountIndex = 0; bAccountIndex < businessAccounts.size();bAccountIndex++) {
+                JSONObject businessAccount = businessAccounts.getJSONObject(bAccountIndex);
+                doBusinessAccount(business, businessAccount);
+                if(bObj instanceof JSONObject) {
+                    dataFlowContext.addParamOut("acctId", businessAccount.getString("acctId"));
+                }
+            }
+        }
+    }
+
+    /**
+     * 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> businessAccountInfo = accountServiceDaoImpl.getBusinessAccountInfo(info);
+        if( businessAccountInfo != null && businessAccountInfo.size() >0) {
+            reFreshShareColumn(info, businessAccountInfo.get(0));
+            accountServiceDaoImpl.saveAccountInfoInstance(info);
+            if(businessAccountInfo.size() == 1) {
+                dataFlowContext.addParamOut("acctId", businessAccountInfo.get(0).get("acct_id"));
+            }
+        }
+    }
+
+
+    /**
+     * 刷 分片字段
+     *
+     * @param info         查询对象
+     * @param businessInfo 小区ID
+     */
+    private void reFreshShareColumn(Map info, Map businessInfo) {
+
+        if (info.containsKey("objId")) {
+            return;
+        }
+
+        if (!businessInfo.containsKey("obj_id")) {
+            return;
+        }
+
+        info.put("objId", businessInfo.get("obj_id"));
+    }
+    /**
+     * 撤单
+     * @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> accountInfo = accountServiceDaoImpl.getAccountInfo(info);
+        if(accountInfo != null && accountInfo.size() > 0){
+            reFreshShareColumn(paramIn, accountInfo.get(0));
+            accountServiceDaoImpl.updateAccountInfoInstance(paramIn);
+        }
+    }
+
+
+
+    /**
+     * 处理 businessAccount 节点
+     * @param business 总的数据节点
+     * @param businessAccount 账户节点
+     */
+    private void doBusinessAccount(Business business,JSONObject businessAccount){
+
+        Assert.jsonObjectHaveKey(businessAccount,"acctId","businessAccount 节点下没有包含 acctId 节点");
+
+        if(businessAccount.getString("acctId").startsWith("-")){
+            //刷新缓存
+            //flushAccountId(business.getDatas());
+
+            businessAccount.put("acctId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_acctId));
+
+        }
+
+        businessAccount.put("bId",business.getbId());
+        businessAccount.put("operate", StatusConstant.OPERATE_ADD);
+        //保存账户信息
+        accountServiceDaoImpl.saveBusinessAccountInfo(businessAccount);
+
+    }
+    @Override
+    public IAccountServiceDao getAccountServiceDaoImpl() {
+        return accountServiceDaoImpl;
+    }
+
+    public void setAccountServiceDaoImpl(IAccountServiceDao accountServiceDaoImpl) {
+        this.accountServiceDaoImpl = accountServiceDaoImpl;
+    }
+}

+ 189 - 0
service-acct/src/main/java/com/java110/acct/listener/account/UpdateAccountInfoListener.java

@@ -0,0 +1,189 @@
+package com.java110.acct.listener.account;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.po.account.AccountPo;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import com.java110.utils.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.Business;
+import com.java110.acct.dao.IAccountServiceDao;
+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、businessAccount:{} 账户基本信息节点
+ * 2、businessAccountAttr:[{}] 账户属性信息节点
+ * 3、businessAccountPhoto:[{}] 账户照片信息节点
+ * 4、businessAccountCerdentials:[{}] 账户证件信息节点
+ * 协议地址 :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("updateAccountInfoListener")
+@Transactional
+public class UpdateAccountInfoListener extends AbstractAccountBusinessServiceDataFlowListener {
+
+    private static Logger logger = LoggerFactory.getLogger(UpdateAccountInfoListener.class);
+    @Autowired
+    private IAccountServiceDao accountServiceDaoImpl;
+
+    @Override
+    public int getOrder() {
+        return 2;
+    }
+
+    @Override
+    public String getBusinessTypeCd() {
+        return BusinessTypeConstant.BUSINESS_TYPE_UPDATE_ACCT;
+    }
+
+    /**
+     * business过程
+     * @param dataFlowContext 上下文对象
+     * @param business 业务对象
+     */
+    @Override
+    protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
+
+        JSONObject data = business.getDatas();
+
+        Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
+
+
+            //处理 businessAccount 节点
+            if(data.containsKey(AccountPo.class.getSimpleName())){
+                Object _obj = data.get(AccountPo.class.getSimpleName());
+                JSONArray businessAccounts = null;
+                if(_obj instanceof JSONObject){
+                    businessAccounts = new JSONArray();
+                    businessAccounts.add(_obj);
+                }else {
+                    businessAccounts = (JSONArray)_obj;
+                }
+                //JSONObject businessAccount = data.getJSONObject(AccountPo.class.getSimpleName());
+                for (int _accountIndex = 0; _accountIndex < businessAccounts.size();_accountIndex++) {
+                    JSONObject businessAccount = businessAccounts.getJSONObject(_accountIndex);
+                    doBusinessAccount(business, businessAccount);
+                    if(_obj instanceof JSONObject) {
+                        dataFlowContext.addParamOut("acctId", businessAccount.getString("acctId"));
+                    }
+                }
+            }
+    }
+
+
+    /**
+     * 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> businessAccountInfos = accountServiceDaoImpl.getBusinessAccountInfo(info);
+        if( businessAccountInfos != null && businessAccountInfos.size() >0) {
+            for (int _accountIndex = 0; _accountIndex < businessAccountInfos.size();_accountIndex++) {
+                Map businessAccountInfo = businessAccountInfos.get(_accountIndex);
+                flushBusinessAccountInfo(businessAccountInfo,StatusConstant.STATUS_CD_VALID);
+                accountServiceDaoImpl.updateAccountInfoInstance(businessAccountInfo);
+                if(businessAccountInfo.size() == 1) {
+                    dataFlowContext.addParamOut("acctId", businessAccountInfo.get("acct_id"));
+                }
+            }
+        }
+
+    }
+
+    /**
+     * 撤单
+     * @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> accountInfo = accountServiceDaoImpl.getAccountInfo(info);
+        if(accountInfo != null && accountInfo.size() > 0){
+
+            //账户信息
+            List<Map> businessAccountInfos = accountServiceDaoImpl.getBusinessAccountInfo(delInfo);
+            //除非程序出错了,这里不会为空
+            if(businessAccountInfos == null || businessAccountInfos.size() == 0){
+                throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(account),程序内部异常,请检查! "+delInfo);
+            }
+            for (int _accountIndex = 0; _accountIndex < businessAccountInfos.size();_accountIndex++) {
+                Map businessAccountInfo = businessAccountInfos.get(_accountIndex);
+                flushBusinessAccountInfo(businessAccountInfo,StatusConstant.STATUS_CD_VALID);
+                accountServiceDaoImpl.updateAccountInfoInstance(businessAccountInfo);
+            }
+        }
+
+    }
+
+
+
+    /**
+     * 处理 businessAccount 节点
+     * @param business 总的数据节点
+     * @param businessAccount 账户节点
+     */
+    private void doBusinessAccount(Business business,JSONObject businessAccount){
+
+        Assert.jsonObjectHaveKey(businessAccount,"acctId","businessAccount 节点下没有包含 acctId 节点");
+
+        if(businessAccount.getString("acctId").startsWith("-")){
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"acctId 错误,不能自动生成(必须已经存在的acctId)"+businessAccount);
+        }
+        //自动保存DEL
+        autoSaveDelBusinessAccount(business,businessAccount);
+
+        businessAccount.put("bId",business.getbId());
+        businessAccount.put("operate", StatusConstant.OPERATE_ADD);
+        //保存账户信息
+        accountServiceDaoImpl.saveBusinessAccountInfo(businessAccount);
+
+    }
+
+
+
+    @Override
+    public IAccountServiceDao getAccountServiceDaoImpl() {
+        return accountServiceDaoImpl;
+    }
+
+    public void setAccountServiceDaoImpl(IAccountServiceDao accountServiceDaoImpl) {
+        this.accountServiceDaoImpl = accountServiceDaoImpl;
+    }
+
+
+
+}

+ 16 - 0
service-acct/src/main/java/com/java110/acct/package-info.java

@@ -0,0 +1,16 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.acct;

+ 19 - 0
service-acct/src/main/java/com/java110/acct/smo/IAcctServiceSMO.java

@@ -0,0 +1,19 @@
+package com.java110.acct.smo;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.context.BusinessServiceDataFlow;
+import com.java110.utils.exception.SMOException;
+
+/**
+ *
+ * 用户信息管理,服务
+ * Created by wuxw on 2017/4/5.
+ */
+public interface IAcctServiceSMO {
+
+
+
+    public JSONObject service(BusinessServiceDataFlow businessServiceDataFlow) throws SMOException;
+
+
+}

+ 93 - 0
service-acct/src/main/java/com/java110/acct/smo/impl/AccountInnerServiceSMOImpl.java

@@ -0,0 +1,93 @@
+package com.java110.acct.smo.impl;
+
+
+import com.java110.acct.dao.IAccountServiceDao;
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.dto.PageDto;
+import com.java110.dto.account.AccountDto;
+import com.java110.dto.user.UserDto;
+import com.java110.intf.acct.IAccountInnerServiceSMO;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @ClassName FloorInnerServiceSMOImpl
+ * @Description 账户内部服务实现类
+ * @Author wuxw
+ * @Date 2019/4/24 9:20
+ * @Version 1.0
+ * add by wuxw 2019/4/24
+ **/
+@RestController
+public class AccountInnerServiceSMOImpl extends BaseServiceSMO implements IAccountInnerServiceSMO {
+
+    @Autowired
+    private IAccountServiceDao accountServiceDaoImpl;
+
+
+    @Override
+    public List<AccountDto> queryAccounts(@RequestBody AccountDto accountDto) {
+
+        //校验是否传了 分页信息
+
+        int page = accountDto.getPage();
+
+        if (page != PageDto.DEFAULT_PAGE) {
+            accountDto.setPage((page - 1) * accountDto.getRow());
+        }
+
+        List<AccountDto> accounts = BeanConvertUtil.covertBeanList(accountServiceDaoImpl.getAccountInfo(BeanConvertUtil.beanCovertMap(accountDto)), AccountDto.class);
+
+
+        return accounts;
+    }
+
+    /**
+     * 从用户列表中查询用户,将用户中的信息 刷新到 floor对象中
+     *
+     * @param account 小区账户信息
+     * @param users   用户列表
+     */
+    private void refreshAccount(AccountDto account, List<UserDto> users) {
+        for (UserDto user : users) {
+            if (account.getAcctId().equals(user.getUserId())) {
+                BeanConvertUtil.covertBean(user, account);
+            }
+        }
+    }
+
+    /**
+     * 获取批量userId
+     *
+     * @param accounts 小区楼信息
+     * @return 批量userIds 信息
+     */
+    private String[] getUserIds(List<AccountDto> accounts) {
+        List<String> userIds = new ArrayList<String>();
+        for (AccountDto account : accounts) {
+            userIds.add(account.getAcctId());
+        }
+
+        return userIds.toArray(new String[userIds.size()]);
+    }
+
+    @Override
+    public int queryAccountsCount(@RequestBody AccountDto accountDto) {
+        return accountServiceDaoImpl.queryAccountsCount(BeanConvertUtil.beanCovertMap(accountDto));
+    }
+
+    public IAccountServiceDao getAccountServiceDaoImpl() {
+        return accountServiceDaoImpl;
+    }
+
+    public void setAccountServiceDaoImpl(IAccountServiceDao accountServiceDaoImpl) {
+        this.accountServiceDaoImpl = accountServiceDaoImpl;
+    }
+
+
+}

+ 127 - 0
service-acct/src/main/java/com/java110/acct/smo/impl/AcctServiceSMOImpl.java

@@ -0,0 +1,127 @@
+package com.java110.acct.smo.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.acct.smo.IAcctServiceSMO;
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.core.context.BusinessServiceDataFlow;
+import com.java110.core.event.service.BusinessServiceDataFlowEventPublishing;
+import com.java110.core.factory.DataFlowFactory;
+import com.java110.entity.center.DataFlowLinksCost;
+import com.java110.entity.center.DataFlowLog;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.KafkaConstant;
+import com.java110.utils.constant.MappingConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.exception.SMOException;
+import com.java110.utils.kafka.KafkaFactory;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.DateUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 用户服务信息管理业务信息实现
+ * Created by wuxw on 2017/4/5.
+ */
+@Service("acctServiceSMOImpl")
+@Transactional
+public class AcctServiceSMOImpl extends BaseServiceSMO implements IAcctServiceSMO {
+
+    private static Logger logger = LoggerFactory.getLogger(AcctServiceSMOImpl.class);
+
+
+    //新增用户
+    private static final String USER_ACTION_ADD = "ADD";
+
+    //新增用户
+    private static final String USER_ACTION_KIP = "KIP";
+
+    //新增用户
+    private static final String USER_ACTION_DEL = "DEL";
+
+
+    @Override
+    public JSONObject service(BusinessServiceDataFlow businessServiceDataFlow) throws SMOException {
+        try {
+            Assert.hasLength(businessServiceDataFlow.getbId(), "bId 不能为空");
+
+            BusinessServiceDataFlowEventPublishing.multicastEvent(businessServiceDataFlow);
+            Assert.notEmpty(businessServiceDataFlow.getResJson(), "用户服务[" + businessServiceDataFlow.getCurrentBusiness().getServiceCode() + "]没有返回内容");
+        } catch (Exception e) {
+            logger.error("用户信息处理异常", e);
+            throw new SMOException(ResponseConstant.RESULT_PARAM_ERROR, "用户信息处理异常" + e.getMessage());
+        } finally {
+            if (businessServiceDataFlow == null) {
+                return null;
+            }
+
+            //这里记录日志
+            Date endDate = DateUtil.getCurrentDate();
+
+            businessServiceDataFlow.setEndDate(endDate);
+            //添加耗时
+            DataFlowFactory.addCostTime(businessServiceDataFlow, "service", "业务处理总耗时",
+                    businessServiceDataFlow.getStartDate(), businessServiceDataFlow.getEndDate());
+            //保存耗时
+            saveCostTimeLogMessage(businessServiceDataFlow);
+            //保存日志
+            saveLogMessage(businessServiceDataFlow);
+        }
+        return businessServiceDataFlow.getResJson();
+    }
+
+
+    /**
+     * 保存日志信息
+     *
+     * @param businessServiceDataFlow 业务日志对象
+     */
+    private void saveLogMessage(BusinessServiceDataFlow businessServiceDataFlow) {
+
+        try {
+            if (MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_LOG_ON_OFF))) {
+                for (DataFlowLog dataFlowLog : businessServiceDataFlow.getLogDatas()) {
+                    KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_LOG_NAME, "", JSONObject.toJSONString(dataFlowLog));
+                }
+            }
+        } catch (Exception e) {
+            logger.error("报错日志出错了,", e);
+        }
+    }
+
+    /**
+     * 保存耗时信息
+     *
+     * @param businessServiceDataFlow
+     */
+    private void saveCostTimeLogMessage(BusinessServiceDataFlow businessServiceDataFlow) {
+        try {
+            if (MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_COST_TIME_ON_OFF))) {
+                List<DataFlowLinksCost> dataFlowLinksCosts = businessServiceDataFlow.getLinksCostDates();
+                JSONObject costDate = new JSONObject();
+                JSONArray costDates = new JSONArray();
+                JSONObject newObj = null;
+                for (DataFlowLinksCost dataFlowLinksCost : dataFlowLinksCosts) {
+                    newObj = JSONObject.parseObject(JSONObject.toJSONString(dataFlowLinksCost));
+                    newObj.put("dataFlowId", businessServiceDataFlow.getDataFlowId());
+                    newObj.put("transactionId", businessServiceDataFlow.getTransactionId());
+                    costDates.add(newObj);
+                }
+                costDate.put("costDates", costDates);
+
+                KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_COST_TIME_LOG_NAME, "", costDate.toJSONString());
+            }
+        } catch (Exception e) {
+            logger.error("报错日志出错了,", e);
+        }
+    }
+
+
+}

+ 97 - 0
service-acct/src/main/resources/application-dev.yml

@@ -0,0 +1,97 @@
+jedis:
+  pool:
+    config:
+      maxTotal: 100
+      maxIdle: 20
+      maxWaitMillis: 20000
+    host: dev.redis.java110.com
+    port: 6379
+    timeout: 3000
+    password: hc
+
+eureka:
+  instance:
+    leaseRenewalIntervalInSeconds: 10
+    leaseExpirationDurationInSeconds: 30
+    preferIpAddress: true
+    instanceId: ${spring.cloud.client.ip-address}:${server.port}
+  client:
+    serviceUrl:
+      defaultZone: http://dev.java110.com:8761/eureka/
+      #defaultZone: http://localhost:8761/eureka/
+server:
+  port: 8003
+  tomcat:
+    uri-encoding: UTF-8
+
+spring:
+  http:
+    encoding:
+      charset: UTF-8
+      enabled: true
+      force: true
+  application:
+    name: acct-service
+  redis:
+    database: 0
+    host: dev.redis.java110.com
+    port: 6379
+    password: hc
+    pool:
+      max-active: 300
+      max-wait: 10000
+      max-idle: 100
+      min-idle: 0
+      timeout: 0
+  datasource:
+    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
+    minIdle: 5
+    validationQuery: SELECT 1 FROM DUAL
+    initialSize: 5
+    maxWait: 60000
+    filters: stat,wall,log4j
+    poolPreparedStatements: true
+    type: com.alibaba.druid.pool.DruidDataSource
+    url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
+    maxPoolPreparedStatementPerConnectionSize: 20
+    password: TT@12345678
+    testOnBorrow: false
+    testWhileIdle: true
+    minEvictableIdleTimeMillis: 300000
+    timeBetweenEvictionRunsMillis: 60000
+    testOnReturn: false
+    driverClassName: com.mysql.cj.jdbc.Driver
+    maxActive: 20
+    username: TT
+
+#============== kafka ===================
+kafka:
+  consumer:
+    zookeeper:
+      connect: dev.zk.java110.com:2181
+    servers: dev.kafka.java110.com:9092
+    enable:
+      auto:
+        commit: true
+    session:
+      timeout: 6000
+    auto:
+      commit:
+        interval: 100
+      offset:
+        reset: latest
+    topic: test
+    group:
+      id: notifyBusinessStatus
+    concurrency: 10
+
+  producer:
+    zookeeper:
+      connect: dev.zk.java110.com:2181
+    servers: dev.kafka.java110.com:9092
+    retries: 0
+    batch:
+      size: 4096
+    linger: 1
+    buffer:
+      memory: 40960

+ 96 - 0
service-acct/src/main/resources/application-prod.yml

@@ -0,0 +1,96 @@
+jedis:
+  pool:
+    config:
+      maxTotal: 100
+      maxIdle: 20
+      maxWaitMillis: 20000
+    host: prod.redis.java110.com
+    port: 6379
+    timeout: 3000
+    password:
+
+eureka:
+  instance:
+    leaseRenewalIntervalInSeconds: 10
+    leaseExpirationDurationInSeconds: 30
+    preferIpAddress: true
+    instanceId: ${spring.cloud.client.ip-address}:${server.port}
+  client:
+    serviceUrl:
+      defaultZone: http://prod.java110.com:8761/eureka/
+      #defaultZone: http://localhost:8761/eureka/
+server:
+  port: 8003
+  tomcat:
+    uri-encoding: UTF-8
+
+spring:
+  http:
+    encoding:
+      charset: UTF-8
+      enabled: true
+      force: true
+  application:
+    name: acct-service
+  redis:
+    database: 0
+    host: prod.redis.java110.com
+    port: 6379
+    pool:
+      max-active: 300
+      max-wait: 10000
+      max-idle: 100
+      min-idle: 0
+      timeout: 0
+  datasource:
+    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
+    minIdle: 5
+    validationQuery: SELECT 1 FROM DUAL
+    initialSize: 5
+    maxWait: 60000
+    filters: stat,wall,log4j
+    poolPreparedStatements: true
+    type: com.alibaba.druid.pool.DruidDataSource
+    url: jdbc:mysql://prod.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
+    maxPoolPreparedStatementPerConnectionSize: 20
+    password: TT@12345678
+    testOnBorrow: false
+    testWhileIdle: true
+    minEvictableIdleTimeMillis: 300000
+    timeBetweenEvictionRunsMillis: 60000
+    testOnReturn: false
+    driverClassName: com.mysql.cj.jdbc.Driver
+    maxActive: 20
+    username: TT
+
+#============== kafka ===================
+kafka:
+  consumer:
+    zookeeper:
+      connect: prod.zk.java110.com:2181
+    servers: prod.kafka.java110.com:9092
+    enable:
+      auto:
+        commit: true
+    session:
+      timeout: 6000
+    auto:
+      commit:
+        interval: 100
+      offset:
+        reset: latest
+    topic: test
+    group:
+      id: notifyBusinessStatus
+    concurrency: 10
+
+  producer:
+    zookeeper:
+      connect: prod.zk.java110.com:2181
+    servers: prod.kafka.java110.com:9092
+    retries: 0
+    batch:
+      size: 4096
+    linger: 1
+    buffer:
+      memory: 40960

+ 96 - 0
service-acct/src/main/resources/application-test.yml

@@ -0,0 +1,96 @@
+jedis:
+  pool:
+    config:
+      maxTotal: 100
+      maxIdle: 20
+      maxWaitMillis: 20000
+    host: test.redis.java110.com
+    port: 6379
+    timeout: 3000
+    password:
+
+eureka:
+  instance:
+    leaseRenewalIntervalInSeconds: 10
+    leaseExpirationDurationInSeconds: 30
+    preferIpAddress: true
+    instanceId: ${spring.cloud.client.ip-address}:${server.port}
+  client:
+    serviceUrl:
+      defaultZone: http://test.java110.com:8761/eureka/
+      #defaultZone: http://localhost:8761/eureka/
+server:
+  port: 8003
+  tomcat:
+    uri-encoding: UTF-8
+
+spring:
+  http:
+    encoding:
+      charset: UTF-8
+      enabled: true
+      force: true
+  application:
+    name: acct-service
+  redis:
+    database: 0
+    host: test.redis.java110.com
+    port: 6379
+    pool:
+      max-active: 300
+      max-wait: 10000
+      max-idle: 100
+      min-idle: 0
+      timeout: 0
+  datasource:
+    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
+    minIdle: 5
+    validationQuery: SELECT 1 FROM DUAL
+    initialSize: 5
+    maxWait: 60000
+    filters: stat,wall,log4j
+    poolPreparedStatements: true
+    type: com.alibaba.druid.pool.DruidDataSource
+    url: jdbc:mysql://test.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
+    maxPoolPreparedStatementPerConnectionSize: 20
+    password: TT@12345678
+    testOnBorrow: false
+    testWhileIdle: true
+    minEvictableIdleTimeMillis: 300000
+    timeBetweenEvictionRunsMillis: 60000
+    testOnReturn: false
+    driverClassName: com.mysql.cj.jdbc.Driver
+    maxActive: 20
+    username: TT
+
+#============== kafka ===================
+kafka:
+  consumer:
+    zookeeper:
+      connect: test.zk.java110.com:2181
+    servers: test.kafka.java110.com:9092
+    enable:
+      auto:
+        commit: true
+    session:
+      timeout: 6000
+    auto:
+      commit:
+        interval: 100
+      offset:
+        reset: latest
+    topic: test
+    group:
+      id: notifyBusinessStatus
+    concurrency: 10
+
+  producer:
+    zookeeper:
+      connect: test.zk.java110.com:2181
+    servers: test.kafka.java110.com:9092
+    retries: 0
+    batch:
+      size: 4096
+    linger: 1
+    buffer:
+      memory: 40960

+ 3 - 0
service-acct/src/main/resources/application.yml

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

+ 15 - 0
service-acct/src/main/resources/banner.txt

@@ -0,0 +1,15 @@
+${AnsiColor.BRIGHT_RED}
+     __                    ____ ___________
+    |__|____ ___  _______ /_   /_   \   _  \
+    |  \__  \\  \/ /\__  \ |   ||   /  /_\  \
+    |  |/ __ \\   /  / __ \|   ||   \  \_/   \
+/\__|  (____  /\_/  (____  /___||___|\_____  /
+\______|    \/           \/                \/
+ ____ ___                    _________                  .__
+|    |   \______ ___________/   _____/ ______________  _|__| ____  ____
+|    |   /  ___// __ \_  __ \_____  \_/ __ \_  __ \  \/ /  |/ ___\/ __ \
+|    |  /\___ \\  ___/|  | \/        \  ___/|  | \/\   /|  \  \__\  ___/
+|______//____  >\___  >__| /_______  /\___  >__|    \_/ |__|\___  >___  >
+             \/     \/             \/     \/                    \/    \/
+
+ java110 UserService starting, more information scan https://github.com/java110/MicroCommunity

+ 75 - 0
service-acct/src/main/resources/dataSource.yml

@@ -0,0 +1,75 @@
+dataSources:
+  ds0: !!com.alibaba.druid.pool.DruidDataSource
+    driverClassName: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://dev.db.java110.com:3306/hc_community?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC
+    username: hc_community
+    password: hc_community@12345678
+    minIdle: 5
+    validationQuery: SELECT 1 FROM DUAL
+    initialSize: 5
+    maxWait: 60000
+    filters: stat,wall,log4j
+    poolPreparedStatements: true
+#  ds0_slave0: !!com.alibaba.druid.pool.DruidDataSource
+#    driverClassName: com.mysql.jdbc.Driver
+#    url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
+#    username: TT
+#    password: TT@12345678
+#    connectionTimeoutMilliseconds: 30000
+#    idleTimeoutMilliseconds: 60000
+#    maxPoolSize: 50
+#    minPoolSize: 1
+#    maintenanceIntervalMilliseconds: 30000
+  ds1: !!com.alibaba.druid.pool.DruidDataSource
+    driverClassName: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC
+    username: TT
+    password: TT@12345678
+    minIdle: 5
+    validationQuery: SELECT 1 FROM DUAL
+    initialSize: 5
+    maxWait: 60000
+    filters: stat,wall,log4j
+    poolPreparedStatements: true
+#  ds1_slave0: !!com.alibaba.druid.pool.DruidDataSource
+#    driverClassName: com.mysql.jdbc.Driver
+#    url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
+#    username: TT
+#    password: TT@12345678
+#    connectionTimeoutMilliseconds: 30000
+#    idleTimeoutMilliseconds: 60000
+#    maxPoolSize: 50
+#    minPoolSize: 1
+#    maintenanceIntervalMilliseconds: 30000
+
+shardingRule:
+  tables:
+    business_xxx:
+      actualDataNodes: ds${0..1}.business_community
+      databaseStrategy:
+        inline:
+          shardingColumn: community_id
+          algorithmExpression: ds${Long.parseLong(community_id) % 2}
+
+  bindingTables:
+    - business_xxx
+
+  defaultDataSourceName: ds1
+  defaultDatabaseStrategy:
+    none:
+  defaultTableStrategy:
+    none:
+
+#  masterSlaveRules:
+#    ms_ds0:
+#     masterDataSourceName: ds0
+#     slaveDataSourceNames:
+#       - ds0_slave0
+#     loadBalanceAlgorithmType: ROUND_ROBIN
+#   ms_ds1:
+#     masterDataSourceName: ds1
+#     slaveDataSourceNames:
+#       - ds1_slave0
+#     loadBalanceAlgorithmType: ROUND_ROBIN
+props:
+  sql.show: true

+ 3 - 0
service-acct/src/main/resources/java110.properties

@@ -0,0 +1,3 @@
+java110.mappingPath=classpath:mapper/acct/**/*.xml,classpath:mapper/service/*.xml
+
+

+ 38 - 0
service-api/src/main/java/com/java110/api/bmo/account/IAccountBMO.java

@@ -0,0 +1,38 @@
+package com.java110.api.bmo.account;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.bmo.IApiBaseBMO;
+import com.java110.core.context.DataFlowContext;
+
+public interface IAccountBMO extends IApiBaseBMO {
+
+
+    /**
+     * 添加账户
+     * @param paramInJson
+     * @param dataFlowContext
+     * @return
+     */
+     void addAccount(JSONObject paramInJson, DataFlowContext dataFlowContext);
+
+    /**
+     * 添加账户信息
+     *
+     * @param paramInJson     接口调用放传入入参
+     * @param dataFlowContext 数据上下文
+     * @return 订单服务能够接受的报文
+     */
+     void updateAccount(JSONObject paramInJson, DataFlowContext dataFlowContext);
+
+    /**
+     * 删除账户
+     *
+     * @param paramInJson     接口调用放传入入参
+     * @param dataFlowContext 数据上下文
+     * @return 订单服务能够接受的报文
+     */
+     void deleteAccount(JSONObject paramInJson, DataFlowContext dataFlowContext);
+
+
+
+}

+ 61 - 0
service-api/src/main/java/com/java110/api/bmo/account/impl/AccountBMOImpl.java

@@ -0,0 +1,61 @@
+package com.java110.api.bmo.account.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.bmo.ApiBaseBMO;
+import com.java110.api.bmo.account.IAccountBMO;
+import com.java110.core.context.DataFlowContext;
+import com.java110.intf.acct.IAccountInnerServiceSMO;
+import com.java110.po.account.AccountPo;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service("accountBMOImpl")
+public class AccountBMOImpl extends ApiBaseBMO implements IAccountBMO {
+
+    @Autowired
+    private IAccountInnerServiceSMO accountInnerServiceSMOImpl;
+
+    /**
+     * 添加小区信息
+     *
+     * @param paramInJson     接口调用放传入入参
+     * @param dataFlowContext 数据上下文
+     * @return 订单服务能够接受的报文
+     */
+    public void addAccount(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+
+        paramInJson.put("acctId", "-1");
+        AccountPo accountPo = BeanConvertUtil.covertBean(paramInJson, AccountPo.class);
+        super.insert(dataFlowContext, accountPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_ACCT);
+    }
+
+
+    /**
+     * 添加活动信息
+     *
+     * @param paramInJson     接口调用放传入入参
+     * @param dataFlowContext 数据上下文
+     * @return 订单服务能够接受的报文
+     */
+    public void updateAccount(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+        AccountPo accountPo = BeanConvertUtil.covertBean(paramInJson, AccountPo.class);
+        super.update(dataFlowContext, accountPo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_ACCT);
+    }
+
+
+    /**
+     * 添加小区信息
+     *
+     * @param paramInJson     接口调用放传入入参
+     * @param dataFlowContext 数据上下文
+     * @return 订单服务能够接受的报文
+     */
+    public void deleteAccount(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+
+        AccountPo accountPo = BeanConvertUtil.covertBean(paramInJson, AccountPo.class);
+        super.update(dataFlowContext, accountPo, BusinessTypeConstant.BUSINESS_TYPE_DELETE_ACCT);
+    }
+
+}

+ 49 - 0
service-api/src/main/java/com/java110/api/listener/account/DeleteAccountListener.java

@@ -0,0 +1,49 @@
+package com.java110.api.listener.account;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.bmo.account.IAccountBMO;
+import com.java110.api.listener.AbstractServiceApiPlusListener;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.event.service.api.ServiceDataFlowEvent;
+import com.java110.utils.constant.ServiceCodeAccountConstant;
+import com.java110.utils.util.Assert;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+
+
+/**
+ * 保存小区侦听
+ * add by wuxw 2019-06-30
+ */
+@Java110Listener("deleteAccountListener")
+public class DeleteAccountListener extends AbstractServiceApiPlusListener {
+
+    @Autowired
+    private IAccountBMO accountBMOImpl;
+
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
+
+        Assert.hasKeyAndValue(reqJson, "acctId", "acctId不能为空");
+
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+
+        accountBMOImpl.deleteAccount(reqJson, context);
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeAccountConstant.DELETE_ACCOUNT;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+
+}

+ 82 - 0
service-api/src/main/java/com/java110/api/listener/account/ListAccountsListener.java

@@ -0,0 +1,82 @@
+package com.java110.api.listener.account;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.listener.AbstractServiceApiListener;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.event.service.api.ServiceDataFlowEvent;
+import com.java110.dto.account.AccountDto;
+import com.java110.intf.acct.IAccountInnerServiceSMO;
+import com.java110.utils.constant.ServiceCodeAccountConstant;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 查询小区侦听类
+ */
+@Java110Listener("listAccountsListener")
+public class ListAccountsListener extends AbstractServiceApiListener {
+
+    @Autowired
+    private IAccountInnerServiceSMO accountInnerServiceSMOImpl;
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeAccountConstant.LIST_ACCOUNTS;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.GET;
+    }
+
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+
+
+    public IAccountInnerServiceSMO getAccountInnerServiceSMOImpl() {
+        return accountInnerServiceSMOImpl;
+    }
+
+    public void setAccountInnerServiceSMOImpl(IAccountInnerServiceSMO accountInnerServiceSMOImpl) {
+        this.accountInnerServiceSMOImpl = accountInnerServiceSMOImpl;
+    }
+
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+        super.validatePageInfo(reqJson);
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+
+        AccountDto accountDto = BeanConvertUtil.covertBean(reqJson, AccountDto.class);
+
+        int count = accountInnerServiceSMOImpl.queryAccountsCount(accountDto);
+
+        List<AccountDto> accountDtos = null;
+
+        if (count > 0) {
+            accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto);
+        } else {
+            accountDtos = new ArrayList<>();
+        }
+
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, accountDtos);
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+
+        context.setResponseEntity(responseEntity);
+
+    }
+}

+ 50 - 0
service-api/src/main/java/com/java110/api/listener/account/SaveAccountListener.java

@@ -0,0 +1,50 @@
+package com.java110.api.listener.account;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.bmo.account.IAccountBMO;
+import com.java110.api.listener.AbstractServiceApiPlusListener;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.event.service.api.ServiceDataFlowEvent;
+import com.java110.utils.constant.ServiceCodeAccountConstant;
+import com.java110.utils.util.Assert;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+
+/**
+ * 保存商户侦听
+ * add by wuxw 2019-06-30
+ */
+@Java110Listener("saveAccountListener")
+public class SaveAccountListener extends AbstractServiceApiPlusListener {
+
+    @Autowired
+    private IAccountBMO accountBMOImpl;
+
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
+
+        Assert.hasKeyAndValue(reqJson, "acctName", "请求报文中未包含acctName");
+        Assert.hasKeyAndValue(reqJson, "acctType", "请求报文中未包含acctType");
+        Assert.hasKeyAndValue(reqJson, "amount", "请求报文中未包含amount");
+        Assert.hasKeyAndValue(reqJson, "objId", "请求报文中未包含objId");
+
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+        accountBMOImpl.addAccount(reqJson, context);
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeAccountConstant.ADD_ACCOUNT;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+
+}

+ 51 - 0
service-api/src/main/java/com/java110/api/listener/account/UpdateAccountListener.java

@@ -0,0 +1,51 @@
+package com.java110.api.listener.account;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.bmo.account.IAccountBMO;
+import com.java110.api.listener.AbstractServiceApiPlusListener;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.event.service.api.ServiceDataFlowEvent;
+import com.java110.utils.constant.ServiceCodeAccountConstant;
+import com.java110.utils.util.Assert;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+
+/**
+ * 保存账户侦听
+ * add by wuxw 2019-06-30
+ */
+@Java110Listener("updateAccountListener")
+public class UpdateAccountListener extends AbstractServiceApiPlusListener {
+
+    @Autowired
+    private IAccountBMO accountBMOImpl;
+
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+
+        Assert.hasKeyAndValue(reqJson, "acctId", "acctId不能为空");
+        Assert.hasKeyAndValue(reqJson, "acctName", "请求报文中未包含acctName");
+        Assert.hasKeyAndValue(reqJson, "acctType", "请求报文中未包含acctType");
+        Assert.hasKeyAndValue(reqJson, "amount", "请求报文中未包含amount");
+        Assert.hasKeyAndValue(reqJson, "objId", "请求报文中未包含objId");
+
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+
+        accountBMOImpl.updateAccount(reqJson, context);
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeAccountConstant.UPDATE_ACCOUNT;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+}