java110 před 6 roky
rodič
revize
07fd8064ac

+ 9 - 4
java110-db/src/main/resources/mapper/user/OwnerCarServiceDaoImplMapper.xml

@@ -110,15 +110,17 @@
 
     <!-- 查询车辆管理信息 add by wuxw 2018-07-03 -->
     <select id="getOwnerCarInfo" parameterType="Map" resultType="Map">
-        select t.car_color,t.car_color carColor,t.car_brand,t.car_brand carBrand,t.car_type,t.car_type carType,t1.name carTypeName,
+        select t.car_color,t.car_color carColor,t.car_brand,t.car_brand carBrand,t.car_type,t.car_type carType,t1.name
+        carTypeName,
         t.car_num,t.car_num carNum,t.ps_id,t.ps_id psId,t.remark,t.status_cd,t.status_cd statusCd,t.owner_id,
         t.owner_id ownerId,t.b_id,t.b_id bId,t.user_id,t.user_id userId,t.car_id,t.car_id carId ,t.create_time
         createTime,t.community_id communityId,bow.name ownerName,bow.id_card idCard,bow.link,t2.name stateName,
         t.start_time,t.start_time startTime,t.end_time,t.end_time endTime,t.state
         from owner_car t
-        left join  t_dict t1  on t.car_type=t1.status_cd and t1.table_name='owner_car' and t1.table_columns = 'car_type'
-        left join  t_dict t2  on t.state=t2.status_cd and t2.table_name='owner_car' and t2.table_columns = 'state'
-        left join building_owner bow on t.owner_id = bow.member_id and bow.status_cd = '0' and bow.community_id = t.community_id
+        left join t_dict t1 on t.car_type=t1.status_cd and t1.table_name='owner_car' and t1.table_columns = 'car_type'
+        left join t_dict t2 on t.state=t2.status_cd and t2.table_name='owner_car' and t2.table_columns = 'state'
+        left join building_owner bow on t.owner_id = bow.member_id and bow.status_cd = '0' and bow.community_id =
+        t.community_id
         where
         t.status_cd = '0'
         <if test="carColor !=null and carColor != ''">
@@ -210,6 +212,9 @@
         <if test="endTime !=null ">
             , t.end_time= #{endTime}
         </if>
+        <if test="state !=null ">
+            , t.state= #{state}
+        </if>
         where 1=1
         <if test="bId !=null and bId != ''">
             and t.b_id= #{bId}

+ 4 - 1
java110-utils/src/main/java/com/java110/utils/constant/ServiceCodeConstant.java

@@ -471,9 +471,12 @@ public class ServiceCodeConstant {
     //添加业主车辆
     public static final String SERVICE_CODE_SAVE_OWNER_CAR = "owner.saveOwnerCar";
 
-    //添加业主车辆
+    //编辑业主车辆
     public static final String SERVICE_CODE_EDIT_OWNER_CAR = "owner.editOwnerCar";
 
+    //释放车位
+    public static final String SERVICE_CODE_DELETE_CAR_PARKING_SPACE = "owner.deleteCarParkingSpace";
+
     //查询业主成员
     public static final String SERVICE_CODE_QUERY_OWNER_MEMBER = "owner.queryOwnerMembers";
 

+ 128 - 0
service-api/src/main/java/com/java110/api/listener/owner/DeleteCarParkingSpaceListener.java

@@ -0,0 +1,128 @@
+package com.java110.api.listener.owner;
+
+import com.alibaba.fastjson.JSONObject;
+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.dto.fee.FeeDto;
+import com.java110.dto.owner.OwnerCarDto;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarInnerServiceSMO;
+import com.java110.po.car.OwnerCarPo;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.ServiceCodeConstant;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+
+import java.util.List;
+
+/**
+ * @ClassName DeleteCarParkingSpaceListener
+ * @Description 释放车位
+ * @Author wuxw
+ * @Date 2019/4/26 14:51
+ * @Version 1.0
+ * @site http://www.homecommunity.cn
+ * add by wuxw 2019/4/26
+ **/
+
+@Java110Listener("deleteCarParkingSpaceListener")
+public class DeleteCarParkingSpaceListener extends AbstractServiceApiPlusListener {
+
+
+    private static Logger logger = LoggerFactory.getLogger(DeleteCarParkingSpaceListener.class);
+
+    @Autowired
+    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+
+    @Autowired
+    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_DELETE_CAR_PARKING_SPACE;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+
+
+    /**
+     * @param event   事件对象
+     * @param reqJson 请求报文数据
+     */
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+        Assert.jsonObjectHaveKey(reqJson, "communityId", "未包含小区ID");
+        Assert.jsonObjectHaveKey(reqJson, "carId", "请求报文中未包含carId");
+        Assert.hasLength(reqJson.getString("communityId"), "小区ID不能为空");
+
+        OwnerCarDto ownerCarDto = new OwnerCarDto();
+        ownerCarDto.setCarId(reqJson.getString("carId"));
+        ownerCarDto.setCommunityId(reqJson.getString("communityId"));
+        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+
+        Assert.listOnlyOne(ownerCarDtos, "未找到车辆信息");
+
+        String psId = ownerCarDtos.get(0).getPsId();
+
+        if (StringUtil.isEmpty(psId) || "-1".equals(psId)) {
+            throw new IllegalArgumentException("车位已经释放无需释放");
+        }
+
+        if (ownerCarDtos.get(0).getEndTime().getTime() > DateUtil.getCurrentDate().getTime()) {
+            throw new IllegalArgumentException("车位租用还未结束不能释放");
+        }
+
+        reqJson.put("ownerCarDto", ownerCarDtos.get(0));
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+
+        OwnerCarDto ownerCarDto = (OwnerCarDto) reqJson.get("ownerCarDto");
+        FeeDto feeDto = new FeeDto();
+        feeDto.setPayerObjId(reqJson.getString("carId"));
+        feeDto.setCommunityId(reqJson.getString("communityId"));
+        feeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_CAR);
+        List<FeeDto> feeDtoList = feeInnerServiceSMOImpl.queryFees(feeDto);
+        boolean oweFee = false;
+        for (FeeDto tmpFeeDto : feeDtoList) {
+            if (tmpFeeDto.getEndTime().getTime() < ownerCarDto.getEndTime().getTime()) {
+                oweFee = true;
+                break;
+            }
+        }
+
+        if (OwnerCarDto.STATE_OWE.equals(ownerCarDto.getState())) {
+            oweFee = false;
+        }
+
+
+        OwnerCarPo ownerCarPo = new OwnerCarPo();
+        ownerCarPo.setPsId("-1");
+        ownerCarPo.setCarId(reqJson.getString("carId"));
+        ownerCarPo.setCommunityId(reqJson.getString("communityId"));
+        if (oweFee) {
+            ownerCarPo.setState(OwnerCarDto.STATE_OWE);
+        }
+        super.update(context, ownerCarPo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_OWNER_CAR);
+
+    }
+
+
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+
+}