| Api/src/main/java/com/java110/api/listener/fee/SaveFeeConfigListener.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Api/src/main/java/com/java110/api/listener/fee/UpdateFeeConfigListener.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| WebService/src/main/java/com/java110/web/components/fee/ConfigPropertyFeeComponent.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| WebService/src/main/java/com/java110/web/smo/IFeeServiceSMO.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| WebService/src/main/java/com/java110/web/smo/impl/FeeServiceSMOImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| java110-common/src/main/java/com/java110/common/constant/ServiceCodeConstant.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Api/src/main/java/com/java110/api/listener/fee/SaveFeeConfigListener.java
New file @@ -0,0 +1,155 @@ package com.java110.api.listener.fee; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.api.listener.AbstractServiceApiDataFlowListener; import com.java110.api.listener.room.SaveRoomListener; import com.java110.common.constant.BusinessTypeConstant; import com.java110.common.constant.CommonConstant; import com.java110.common.constant.ServiceCodeConstant; import com.java110.common.util.Assert; import com.java110.common.util.BeanConvertUtil; import com.java110.core.annotation.Java110Listener; import com.java110.core.context.DataFlowContext; import com.java110.core.smo.fee.IFeeConfigInnerServiceSMO; import com.java110.core.smo.floor.IFloorInnerServiceSMO; import com.java110.core.smo.room.IRoomInnerServiceSMO; import com.java110.core.smo.unit.IUnitInnerServiceSMO; import com.java110.dto.FeeConfigDto; import com.java110.dto.RoomDto; import com.java110.dto.UnitDto; import com.java110.entity.center.AppService; import com.java110.event.service.api.ServiceDataFlowEvent; import com.java110.vo.api.ApiRoomDataVo; import com.java110.vo.api.ApiRoomVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import java.util.List; /** * @ClassName SaveFeeConfigListener * @Description TODO * @Author wuxw * @Date 2019/6/1 20:51 * @Version 1.0 * add by wuxw 2019/6/1 **/ @Java110Listener("saveFeeConfigListener") public class SaveFeeConfigListener extends AbstractServiceApiDataFlowListener { private static Logger logger = LoggerFactory.getLogger(SaveFeeConfigListener.class); @Autowired private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl; @Override public String getServiceCode() { return ServiceCodeConstant.SERVICE_CODE_SAVE_FEE_CONFIG; } @Override public HttpMethod getHttpMethod() { return HttpMethod.POST; } @Override public void soService(ServiceDataFlowEvent event) { logger.debug("ServiceDataFlowEvent : {}", event); DataFlowContext dataFlowContext = event.getDataFlowContext(); AppService service = event.getAppService(); String paramIn = dataFlowContext.getReqData(); //校验数据 validate(paramIn); JSONObject paramObj = JSONObject.parseObject(paramIn); HttpHeaders header = new HttpHeaders(); dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D"); JSONArray businesses = new JSONArray(); //添加单元信息 businesses.add(addFeeConfig(paramObj, dataFlowContext)); JSONObject paramInObj = super.restToCenterProtocol(businesses, dataFlowContext.getRequestCurrentHeaders()); //将 rest header 信息传递到下层服务中去 super.freshHttpHeader(header, dataFlowContext.getRequestCurrentHeaders()); ResponseEntity<String> responseEntity = this.callService(dataFlowContext, service.getServiceCode(), paramInObj); dataFlowContext.setResponseEntity(responseEntity); } /** * 添加小区楼信息 * * @param paramInJson 接口调用放传入入参 * @param dataFlowContext 数据上下文 * @return 订单服务能够接受的报文 */ private JSONObject addFeeConfig(JSONObject paramInJson, DataFlowContext dataFlowContext) { JSONObject business = JSONObject.parseObject("{\"datas\":{}}"); business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_CONFIG); business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ); business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S); JSONObject businessFeeConfig = new JSONObject(); businessFeeConfig.putAll(paramInJson); businessFeeConfig.put("configId", "-1"); business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessFeeConfig", businessFeeConfig); return business; } /** * 数据校验 * * @param paramIn "communityId": "7020181217000001", * "memberId": "3456789", * "memberTypeCd": "390001200001" */ private void validate(String paramIn) { Assert.jsonObjectHaveKey(paramIn, "communityId", "请求报文中未包含communityId节点"); Assert.jsonObjectHaveKey(paramIn, "squarePrice", "请求报文中未包含squarePrice节点"); Assert.jsonObjectHaveKey(paramIn, "additionalAmount", "请求报文中未包含additionalAmount节点"); Assert.jsonObjectHaveKey(paramIn, "feeTypeCd", "请求报文中未包含feeTypeCd节点"); JSONObject reqJson = JSONObject.parseObject(paramIn); Assert.isMoney(reqJson.getString("squarePrice"), "squarePrice不是有效金额格式"); Assert.isMoney(reqJson.getString("additionalAmount"), "additionalAmount不是有效金额格式"); FeeConfigDto feeConfigDto = new FeeConfigDto(); feeConfigDto.setCommunityId(reqJson.getString("communityId")); feeConfigDto.setFeeTypeCd(reqJson.getString("feeTypeCd")); //校验小区楼ID和小区是否有对应关系 List<FeeConfigDto> configDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto); if (configDtos != null || configDtos.size() > 0) { throw new IllegalArgumentException("已经存在费用配置信息"); } } @Override public int getOrder() { return DEFAULT_ORDER; } public IFeeConfigInnerServiceSMO getFeeConfigInnerServiceSMOImpl() { return feeConfigInnerServiceSMOImpl; } public void setFeeConfigInnerServiceSMOImpl(IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl) { this.feeConfigInnerServiceSMOImpl = feeConfigInnerServiceSMOImpl; } } Api/src/main/java/com/java110/api/listener/fee/UpdateFeeConfigListener.java
New file @@ -0,0 +1,147 @@ package com.java110.api.listener.fee; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.api.listener.AbstractServiceApiDataFlowListener; import com.java110.common.constant.BusinessTypeConstant; import com.java110.common.constant.CommonConstant; import com.java110.common.constant.ServiceCodeConstant; import com.java110.common.util.Assert; import com.java110.core.annotation.Java110Listener; import com.java110.core.context.DataFlowContext; import com.java110.core.smo.fee.IFeeConfigInnerServiceSMO; import com.java110.dto.FeeConfigDto; import com.java110.entity.center.AppService; import com.java110.event.service.api.ServiceDataFlowEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import java.util.List; /** * @ClassName SaveFeeConfigListener * @Description TODO * @Author wuxw * @Date 2019/6/1 20:51 * @Version 1.0 * add by wuxw 2019/6/1 **/ @Java110Listener("updateFeeConfigListener") public class UpdateFeeConfigListener extends AbstractServiceApiDataFlowListener { private static Logger logger = LoggerFactory.getLogger(UpdateFeeConfigListener.class); @Autowired private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl; @Override public String getServiceCode() { return ServiceCodeConstant.SERVICE_CODE_UPDATE_FEE_CONFIG; } @Override public HttpMethod getHttpMethod() { return HttpMethod.POST; } @Override public void soService(ServiceDataFlowEvent event) { logger.debug("ServiceDataFlowEvent : {}", event); DataFlowContext dataFlowContext = event.getDataFlowContext(); AppService service = event.getAppService(); String paramIn = dataFlowContext.getReqData(); //校验数据 validate(paramIn); JSONObject paramObj = JSONObject.parseObject(paramIn); HttpHeaders header = new HttpHeaders(); dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D"); JSONArray businesses = new JSONArray(); //添加单元信息 businesses.add(modifyFeeConfig(paramObj, dataFlowContext)); JSONObject paramInObj = super.restToCenterProtocol(businesses, dataFlowContext.getRequestCurrentHeaders()); //将 rest header 信息传递到下层服务中去 super.freshHttpHeader(header, dataFlowContext.getRequestCurrentHeaders()); ResponseEntity<String> responseEntity = this.callService(dataFlowContext, service.getServiceCode(), paramInObj); dataFlowContext.setResponseEntity(responseEntity); } /** * 添加小区楼信息 * * @param paramInJson 接口调用放传入入参 * @param dataFlowContext 数据上下文 * @return 订单服务能够接受的报文 */ private JSONObject modifyFeeConfig(JSONObject paramInJson, DataFlowContext dataFlowContext) { JSONObject business = JSONObject.parseObject("{\"datas\":{}}"); business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_FEE_CONFIG); business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ); business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S); JSONObject businessFeeConfig = new JSONObject(); businessFeeConfig.putAll(paramInJson); business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessFeeConfig", businessFeeConfig); return business; } /** * 数据校验 * * @param paramIn "communityId": "7020181217000001", * "memberId": "3456789", * "memberTypeCd": "390001200001" */ private void validate(String paramIn) { Assert.jsonObjectHaveKey(paramIn, "communityId", "请求报文中未包含communityId节点"); Assert.jsonObjectHaveKey(paramIn, "configId", "请求报文中未包含communityId节点"); Assert.jsonObjectHaveKey(paramIn, "squarePrice", "请求报文中未包含squarePrice节点"); Assert.jsonObjectHaveKey(paramIn, "additionalAmount", "请求报文中未包含additionalAmount节点"); Assert.jsonObjectHaveKey(paramIn, "feeTypeCd", "请求报文中未包含feeTypeCd节点"); JSONObject reqJson = JSONObject.parseObject(paramIn); Assert.isMoney(reqJson.getString("squarePrice"), "squarePrice不是有效金额格式"); Assert.isMoney(reqJson.getString("additionalAmount"), "additionalAmount不是有效金额格式"); Assert.hasLength(reqJson.getString("communityId"), "小区ID错误"); Assert.hasLength(reqJson.getString("configId"), "configId错误"); FeeConfigDto feeConfigDto = new FeeConfigDto(); feeConfigDto.setCommunityId(reqJson.getString("communityId")); feeConfigDto.setFeeTypeCd(reqJson.getString("feeTypeCd")); //校验小区楼ID和小区是否有对应关系 List<FeeConfigDto> configDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto); if (configDtos == null || configDtos.size() != 1) { throw new IllegalArgumentException("不存在改费用配置(" + JSONObject.toJSONString(feeConfigDto) + ")信息"); } } @Override public int getOrder() { return DEFAULT_ORDER; } public IFeeConfigInnerServiceSMO getFeeConfigInnerServiceSMOImpl() { return feeConfigInnerServiceSMOImpl; } public void setFeeConfigInnerServiceSMOImpl(IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl) { this.feeConfigInnerServiceSMOImpl = feeConfigInnerServiceSMOImpl; } } WebService/src/main/java/com/java110/web/components/fee/ConfigPropertyFeeComponent.java
New file @@ -0,0 +1,35 @@ package com.java110.web.components.fee; import com.java110.core.context.IPageData; import com.java110.web.smo.IFeeServiceSMO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; /** * @ClassName ViewPropertyFeeConfigComponent * @Description 展示物业费信息 * @Author wuxw * @Date 2019/6/1 14:33 * @Version 1.0 * add by wuxw 2019/6/1 **/ @Component("configPropertyFee") public class ConfigPropertyFeeComponent { @Autowired private IFeeServiceSMO feeServiceSMOImpl; public ResponseEntity<String> change(IPageData pd) { return feeServiceSMOImpl.loadPropertyConfigFee(pd); } public IFeeServiceSMO getFeeServiceSMOImpl() { return feeServiceSMOImpl; } public void setFeeServiceSMOImpl(IFeeServiceSMO feeServiceSMOImpl) { this.feeServiceSMOImpl = feeServiceSMOImpl; } } WebService/src/main/java/com/java110/web/smo/IFeeServiceSMO.java
@@ -16,6 +16,13 @@ */ ResponseEntity<String> loadPropertyConfigFee(IPageData pd); /** * 保存或修改物业费配置 * @param pd 页面数据封装对象 * @return 返回 ResponseEntity对象包含 http状态 信息 body信息 */ ResponseEntity<String> saveOrUpdatePropertyFeeConfig(IPageData pd); } WebService/src/main/java/com/java110/web/smo/impl/FeeServiceSMOImpl.java
@@ -8,6 +8,8 @@ import com.java110.common.constant.ServiceConstant; import com.java110.common.exception.SMOException; import com.java110.common.util.Assert; import com.java110.common.util.CommonUtil; import com.java110.common.util.StringUtil; import com.java110.core.context.IPageData; import com.java110.web.core.BaseComponentSMO; import com.java110.web.smo.IFeeServiceSMO; @@ -56,7 +58,7 @@ paramIn.put("feeTypeCd", FeeTypeConstant.FEE_TYPE_PROPERTY); responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), ServiceConstant.SERVICE_API_URL + "/api/fee.queryFeeConfig", HttpMethod.POST); HttpMethod.GET); JSONArray feeConfigs = JSONArray.parseArray(responseEntity.getBody().toString()); if(feeConfigs != null && feeConfigs.size() > 1){ @@ -75,6 +77,45 @@ return responseEntity; } /** * * @param pd 页面数据封装对象 * @return */ @Override public ResponseEntity<String> saveOrUpdatePropertyFeeConfig(IPageData pd) { validateLoadPropertyConfigFee(pd); //校验员工是否有权限操作 super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.PRIVILEGE_PROPERTY_CONFIG_FEE); JSONObject paramIn = JSONObject.parseObject(pd.getReqData()); String communityId = paramIn.getString("communityId"); ResponseEntity responseEntity = super.getStoreInfo(pd, restTemplate); if (responseEntity.getStatusCode() != HttpStatus.OK) { return responseEntity; } Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeId", "根据用户ID查询商户ID失败,未包含storeId节点"); Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeTypeCd", "根据用户ID查询商户类型失败,未包含storeTypeCd节点"); String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId"); String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd"); //数据校验是否 商户是否入驻该小区 super.checkStoreEnterCommunity(pd, storeId, storeTypeCd, communityId, restTemplate); paramIn.put("feeTypeCd", FeeTypeConstant.FEE_TYPE_PROPERTY); if(!paramIn.containsKey("configId") || StringUtil.isEmpty(paramIn.getString("configId"))) { responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), ServiceConstant.SERVICE_API_URL + "/api/fee.saveFeeConfig", HttpMethod.POST); }else{ responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), ServiceConstant.SERVICE_API_URL + "/api/fee.updateFeeConfig", HttpMethod.POST); } return responseEntity; } /** * 小区房屋查询数据校验 @@ -89,6 +130,24 @@ } /** * 校验数据合法性 * @param pd */ private void validateSaveOrUpdatePropertyFeeConfig(IPageData pd){ Assert.jsonObjectHaveKey(pd.getReqData(), "communityId", "请求报文中未包含communityId节点"); Assert.jsonObjectHaveKey(pd.getReqData(), "squarePrice", "请求报文中未包含communityId节点"); Assert.jsonObjectHaveKey(pd.getReqData(), "additionalAmount", "请求报文中未包含communityId节点"); JSONObject paramIn = JSONObject.parseObject(pd.getReqData()); Assert.hasLength(paramIn.getString("communityId"), "小区ID不能为空"); Assert.isMoney(paramIn.getString("squarePrice"), "不是有效金额格式"); Assert.isMoney(paramIn.getString("additionalAmount"), "不是有效金额格式"); } /** * 校验前台传入房屋信息 * * @param pd 页面数据封装 java110-common/src/main/java/com/java110/common/constant/ServiceCodeConstant.java
@@ -424,4 +424,10 @@ //查询费用配置 public static final String SERVICE_CODE_QUERY_FEE_CONFIG = "fee.queryFeeConfig"; //保存费用配置 public static final String SERVICE_CODE_SAVE_FEE_CONFIG = "fee.saveFeeConfig"; //修改费用配置 public static final String SERVICE_CODE_UPDATE_FEE_CONFIG = "fee.updateFeeConfig"; }