|
| 1 | +package com.java110.api.listener.owner; |
| 2 | + |
| 3 | +import com.alibaba.fastjson.JSONObject; |
| 4 | +import com.java110.api.bmo.parkingSpace.IParkingSpaceBMO; |
| 5 | +import com.java110.api.listener.AbstractServiceApiPlusListener; |
| 6 | +import com.java110.core.annotation.Java110Listener; |
| 7 | +import com.java110.core.context.DataFlowContext; |
| 8 | +import com.java110.core.event.service.api.ServiceDataFlowEvent; |
| 9 | +import com.java110.core.factory.GenerateCodeFactory; |
| 10 | +import com.java110.intf.community.IParkingSpaceInnerServiceSMO; |
| 11 | +import com.java110.intf.fee.IFeeConfigInnerServiceSMO; |
| 12 | +import com.java110.utils.constant.ResponseConstant; |
| 13 | +import com.java110.utils.constant.ServiceCodeConstant; |
| 14 | +import com.java110.utils.exception.ListenerExecuteException; |
| 15 | +import com.java110.utils.util.Assert; |
| 16 | +import org.slf4j.Logger; |
| 17 | +import org.slf4j.LoggerFactory; |
| 18 | +import org.springframework.beans.factory.annotation.Autowired; |
| 19 | +import org.springframework.http.HttpMethod; |
| 20 | + |
| 21 | +/** |
| 22 | + * @ClassName SaveParkingSpaceListener |
| 23 | + * @Description 保存小区楼信息 |
| 24 | + * @Author wuxw |
| 25 | + * @Date 2019/4/26 14:51 |
| 26 | + * @Version 1.0 |
| 27 | + * add by wuxw 2019/4/26 |
| 28 | + **/ |
| 29 | + |
| 30 | +@Java110Listener("saveOwnerCarListener") |
| 31 | +public class SaveOwnerCarListener extends AbstractServiceApiPlusListener { |
| 32 | + |
| 33 | + |
| 34 | + private static Logger logger = LoggerFactory.getLogger(SaveOwnerCarListener.class); |
| 35 | + |
| 36 | + @Autowired |
| 37 | + private IParkingSpaceBMO parkingSpaceBMOImpl; |
| 38 | + |
| 39 | + @Autowired |
| 40 | + private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl; |
| 41 | + |
| 42 | + @Autowired |
| 43 | + private IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl; |
| 44 | + |
| 45 | + @Override |
| 46 | + public String getServiceCode() { |
| 47 | + return ServiceCodeConstant.SERVICE_CODE_SAVE_OWNER_CAR; |
| 48 | + } |
| 49 | + |
| 50 | + @Override |
| 51 | + public HttpMethod getHttpMethod() { |
| 52 | + return HttpMethod.POST; |
| 53 | + } |
| 54 | + |
| 55 | + |
| 56 | + @Override |
| 57 | + protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| 58 | + Assert.jsonObjectHaveKey(reqJson, "communityId", "未包含小区ID"); |
| 59 | + Assert.jsonObjectHaveKey(reqJson, "ownerId", "请求报文中未包含ownerId"); |
| 60 | + Assert.jsonObjectHaveKey(reqJson, "carNum", "请求报文中未包含carNum"); |
| 61 | + Assert.jsonObjectHaveKey(reqJson, "carBrand", "请求报文中未包含carBrand"); |
| 62 | + Assert.jsonObjectHaveKey(reqJson, "carType", "请求报文中未包含carType"); |
| 63 | + Assert.jsonObjectHaveKey(reqJson, "carColor", "未包含carColor"); |
| 64 | + Assert.jsonObjectHaveKey(reqJson, "psId", "未包含psId"); |
| 65 | + Assert.jsonObjectHaveKey(reqJson, "storeId", "未包含storeId"); |
| 66 | + Assert.jsonObjectHaveKey(reqJson, "receivedAmount", "未包含receivedAmount"); |
| 67 | + Assert.jsonObjectHaveKey(reqJson, "sellOrHire", "未包含sellOrHire"); |
| 68 | + |
| 69 | + Assert.hasLength(reqJson.getString("communityId"), "小区ID不能为空"); |
| 70 | + Assert.hasLength(reqJson.getString("ownerId"), "ownerId不能为空"); |
| 71 | + Assert.hasLength(reqJson.getString("psId"), "psId不能为空"); |
| 72 | + Assert.isMoney(reqJson.getString("receivedAmount"), "不是有效的实收金额"); |
| 73 | + |
| 74 | + if (!"H".equals(reqJson.getString("sellOrHire")) |
| 75 | + && !"S".equals(reqJson.getString("sellOrHire"))) { |
| 76 | + throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "请求报文中sellOrFire值错误 ,出售为S 出租为H"); |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| 82 | + |
| 83 | + String feeId = GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_feeId); |
| 84 | + reqJson.put("feeId", feeId); |
| 85 | + |
| 86 | + //添加小区楼 |
| 87 | + parkingSpaceBMOImpl.sellParkingSpace(reqJson, context); |
| 88 | + |
| 89 | + parkingSpaceBMOImpl.modifySellParkingSpaceState(reqJson, context); |
| 90 | + |
| 91 | + //计算 费用信息 |
| 92 | + parkingSpaceBMOImpl.computeFeeInfo(reqJson, context); |
| 93 | + //添加物业费用信息 |
| 94 | + parkingSpaceBMOImpl.addParkingSpaceFee(reqJson, context); |
| 95 | + |
| 96 | + parkingSpaceBMOImpl.addFeeDetail(reqJson, context); |
| 97 | + |
| 98 | + |
| 99 | + } |
| 100 | + |
| 101 | + |
| 102 | + @Override |
| 103 | + public int getOrder() { |
| 104 | + return 0; |
| 105 | + } |
| 106 | + |
| 107 | + public IFeeConfigInnerServiceSMO getFeeConfigInnerServiceSMOImpl() { |
| 108 | + return feeConfigInnerServiceSMOImpl; |
| 109 | + } |
| 110 | + |
| 111 | + public void setFeeConfigInnerServiceSMOImpl(IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl) { |
| 112 | + this.feeConfigInnerServiceSMOImpl = feeConfigInnerServiceSMOImpl; |
| 113 | + } |
| 114 | + |
| 115 | + public IParkingSpaceInnerServiceSMO getParkingSpaceInnerServiceSMOImpl() { |
| 116 | + return parkingSpaceInnerServiceSMOImpl; |
| 117 | + } |
| 118 | + |
| 119 | + public void setParkingSpaceInnerServiceSMOImpl(IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl) { |
| 120 | + this.parkingSpaceInnerServiceSMOImpl = parkingSpaceInnerServiceSMOImpl; |
| 121 | + } |
| 122 | +} |
0 commit comments