Переглянути джерело

优化车位申请的逻辑

wuxw 1 рік тому
батько
коміт
2b201e316c

+ 1 - 0
java110-bean/src/main/java/com/java110/dto/parking/ParkingSpaceApplyDto.java

@@ -16,6 +16,7 @@ import java.util.Date;
 public class ParkingSpaceApplyDto extends PageDto implements Serializable {
 
     public static final String STATE_FAIL = "4004"; // 审核失败
+    public static final String STATE_SUCCESS = "3003"; // 审核成功
 
     private String carBrand;
     private String applyPersonName;

+ 7 - 37
service-community/src/main/java/com/java110/community/cmd/parkingSpaceApply/AuditParkingSpaceApplyCmd.java

@@ -43,6 +43,7 @@ import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.ListUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -87,6 +88,8 @@ public class AuditParkingSpaceApplyCmd extends Cmd {
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "applyId", "applyId不能为空");
+        Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
+
     }
 
     @Override
@@ -104,9 +107,8 @@ public class AuditParkingSpaceApplyCmd extends Cmd {
             }
             return;
         }
-        PayFeePo payFeePo = new PayFeePo();
-        payFeePo.setFeeId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
-        parkingSpaceApplyPo.setFeeId(payFeePo.getFeeId());
+        parkingSpaceApplyPo.setFeeId("-1");
+        parkingSpaceApplyPo.setState(ParkingSpaceApplyDto.STATE_SUCCESS);
         int flag = parkingSpaceApplyV1InnerServiceSMOImpl.updateParkingSpaceApply(parkingSpaceApplyPo);
         if (flag < 1) {
             throw new CmdException("更新数据失败");
@@ -114,7 +116,7 @@ public class AuditParkingSpaceApplyCmd extends Cmd {
         ParkingSpaceApplyDto parkingSpaceApplyDto = new ParkingSpaceApplyDto();
         parkingSpaceApplyDto.setApplyId(parkingSpaceApplyPo.getApplyId());
         List<ParkingSpaceApplyDto> parkingSpaceApplyDtos = parkingSpaceApplyV1InnerServiceSMOImpl.queryParkingSpaceApplys(parkingSpaceApplyDto);
-        if (parkingSpaceApplyDtos == null || parkingSpaceApplyDtos.size() < 1) {
+        if (ListUtil.isNull(parkingSpaceApplyDtos)) {
             throw new CmdException("未查询到申请单,请联系管理员");
         }
         ParkingSpaceApplyDto parkingSpaceApply = parkingSpaceApplyDtos.get(0);
@@ -126,7 +128,7 @@ public class AuditParkingSpaceApplyCmd extends Cmd {
         List<OwnerCarDto> ownerCarDtos = ownerCarV1InnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
         String catId = "";
         OwnerCarPo ownerCarPo = new OwnerCarPo();
-        if (ownerCarDtos == null || ownerCarDtos.size() < 1) {
+        if (ListUtil.isNull(ownerCarDtos)) {
             ownerCarPo.setCarId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
             ownerCarPo.setOwnerId(parkingSpaceApply.getApplyPersonId());
             ownerCarPo.setbId("-1");
@@ -160,38 +162,6 @@ public class AuditParkingSpaceApplyCmd extends Cmd {
         if (flag < 1) {
             throw new CmdException("更新车位状态失败");
         }
-        FeeConfigDto feeConfigDto = new FeeConfigDto();
-        feeConfigDto.setConfigId(parkingSpaceApply.getConfigId());
-        List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
-        if (feeConfigDtos == null || feeConfigDtos.size() < 1) {
-            throw new CmdException("未查询到相关费用项设置,请联系管理员");
-        }
-        CommunityMemberDto communityMemberDto = new CommunityMemberDto();
-        communityMemberDto.setCommunityId(parkingSpaceApply.getCommunityId());
-        communityMemberDto.setMemberTypeCd("390001200002");
-        List<CommunityMemberDto> communityMemberDtos = communityMemberV1InnerServiceSMOImpl.queryCommunityMembers(communityMemberDto);
-        if (communityMemberDtos == null || communityMemberDtos.size() < 1) {
-            throw new CmdException("未查询到小区和商户的关系,请联系管理员");
-        }
-        FeeConfigDto feeConfig = feeConfigDtos.get(0);
-        payFeePo.setCommunityId(feeConfig.getCommunityId());
-        payFeePo.setConfigId(feeConfig.getConfigId());
-        payFeePo.setFeeTypeCd(feeConfig.getFeeTypeCd());
-        payFeePo.setPayerObjId(catId);
-        payFeePo.setIncomeObjId(communityMemberDtos.get(0).getMemberId());//根据小区ID查询storeId
-        payFeePo.setStartTime(parkingSpaceApply.getStartTime());
-        payFeePo.setEndTime(parkingSpaceApply.getStartTime());
-        payFeePo.setAmount("0");
-        payFeePo.setFeeFlag(feeConfig.getFeeFlag());
-        payFeePo.setState(FeeDto.STATE_DOING);
-        payFeePo.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_PARKING_SPACE);
-        payFeePo.setBatchId("-1");
-        payFeePo.setbId("-1");
-        payFeePo.setUserId(userId);
-        flag = payFeeNewV1InnerServiceSMOImpl.savePayFee(payFeePo);
-        if (flag < 1) {
-            throw new CmdException("更新数据失败");
-        }
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }
 }

+ 8 - 12
service-community/src/main/java/com/java110/community/cmd/parkingSpaceApply/SaveParkingSpaceApplyCmd.java

@@ -34,6 +34,8 @@ import com.java110.po.parking.ParkingSpaceApplyPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.ListUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.slf4j.Logger;
@@ -73,8 +75,6 @@ public class SaveParkingSpaceApplyCmd extends Cmd {
         Assert.hasKeyAndValue(reqJson, "carBrand", "请求报文中未包含carBrand");
         Assert.hasKeyAndValue(reqJson, "carType", "请求报文中未包含carType");
         Assert.hasKeyAndValue(reqJson, "carColor", "请求报文中未包含carColor");
-        Assert.hasKeyAndValue(reqJson, "startTime", "请求报文中未包含startTime");
-        Assert.hasKeyAndValue(reqJson, "endTime", "请求报文中未包含endTime");
         Assert.hasKeyAndValue(reqJson, "state", "请求报文中未包含state");
         Assert.hasKeyAndValue(reqJson, "applyPersonName", "请求报文中未包含applyPersonName");
         Assert.hasKeyAndValue(reqJson, "applyPersonLink", "请求报文中未包含applyPersonLink");
@@ -101,13 +101,14 @@ public class SaveParkingSpaceApplyCmd extends Cmd {
         OwnerDto ownerDto = new OwnerDto();
         ownerDto.setOwnerId(parkingSpaceApplyPo.getApplyPersonId());
         List<OwnerDto> ownerDtos = buildingOwnerV1InnerServiceSMOImpl.queryBuildingOwners(ownerDto);
-        if (ownerDtos == null || ownerDtos.size() < 1) {
+        if (ListUtil.isNull(ownerDtos)) {
             throw new CmdException("不是本小区业主不能申请车位!");
         }
         //判断车辆是否已经有申请单
         ParkingSpaceApplyDto parkingSpaceApplyDto = new ParkingSpaceApplyDto();
         parkingSpaceApplyDto.setCarNum(parkingSpaceApplyPo.getCarNum());
         parkingSpaceApplyDto.setState("1001");//审核中
+        parkingSpaceApplyDto.setCommunityId(reqJson.getString("communityId"));
         int count = parkingSpaceApplyV1InnerServiceSMOImpl.queryParkingSpaceApplysCount(parkingSpaceApplyDto);
         if (count > 1) {
             throw new CmdException("当前车辆申请处理审核中,不能重复申请。");
@@ -117,17 +118,12 @@ public class SaveParkingSpaceApplyCmd extends Cmd {
         ownerCarDto.setCarNum(parkingSpaceApplyPo.getCarNum());
         ownerCarDto.setCommunityId(parkingSpaceApplyPo.getCommunityId());
         List<OwnerCarDto> ownerCarDtos = ownerCarV1InnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
-        if (ownerCarDtos != null && ownerCarDtos.size() > 0) {
-            PayFeeDto payFeeDto = new PayFeeDto();
-            payFeeDto.setPayerObjId(ownerCarDtos.get(0).getCarId());
-            payFeeDto.setState("2008001");
-            List<PayFeeDto> payFeeDtos = payFeeV1InnerServiceSMOImpl.queryPayFees(payFeeDto);
-            if (payFeeDtos != null && payFeeDtos.size() > 0) {
-                throw new CmdException("该车辆已经有相关费用,请到停车费中续费。或者联系管理员");
-            }
+        if (!ListUtil.isNull(ownerCarDtos)) {
+            throw new CmdException("该车辆已存在,购买月卡续费。或者联系管理员");
         }
-
         parkingSpaceApplyPo.setApplyId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+        parkingSpaceApplyPo.setStartTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+        parkingSpaceApplyPo.setEndTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
         int flag = parkingSpaceApplyV1InnerServiceSMOImpl.saveParkingSpaceApply(parkingSpaceApplyPo);
         if (flag < 1) {
             throw new CmdException("保存数据失败");