java110 5 lat temu
rodzic
commit
98b40992b1

+ 89 - 0
java110-bean/src/main/java/com/java110/dto/feeDiscount/ComputeDiscountDto.java

@@ -0,0 +1,89 @@
+/*
+ * 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.dto.feeDiscount;
+
+import com.java110.dto.PageDto;
+import com.java110.dto.feeDiscountRuleSpec.FeeDiscountRuleSpecDto;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @desc add by 吴学文 9:53
+ */
+public class ComputeDiscountDto extends PageDto implements Serializable {
+
+    private String discountId;
+
+    private String discountType;
+
+    private String ruleName;
+
+    private String ruleId;
+
+    private List<FeeDiscountRuleSpecDto> feeDiscountRuleSpecs;
+
+    private double discountPrice;
+
+
+    public String getDiscountId() {
+        return discountId;
+    }
+
+    public void setDiscountId(String discountId) {
+        this.discountId = discountId;
+    }
+
+    public String getRuleName() {
+        return ruleName;
+    }
+
+    public void setRuleName(String ruleName) {
+        this.ruleName = ruleName;
+    }
+
+    public String getRuleId() {
+        return ruleId;
+    }
+
+    public void setRuleId(String ruleId) {
+        this.ruleId = ruleId;
+    }
+
+    public List<FeeDiscountRuleSpecDto> getFeeDiscountRuleSpecs() {
+        return feeDiscountRuleSpecs;
+    }
+
+    public void setFeeDiscountRuleSpecs(List<FeeDiscountRuleSpecDto> feeDiscountRuleSpecs) {
+        this.feeDiscountRuleSpecs = feeDiscountRuleSpecs;
+    }
+
+    public double getDiscountPrice() {
+        return discountPrice;
+    }
+
+    public void setDiscountPrice(double discountPrice) {
+        this.discountPrice = discountPrice;
+    }
+
+    public String getDiscountType() {
+        return discountType;
+    }
+
+    public void setDiscountType(String discountType) {
+        this.discountType = discountType;
+    }
+}

+ 9 - 0
java110-bean/src/main/java/com/java110/dto/feeDiscount/FeeDiscountDto.java

@@ -24,6 +24,7 @@ public class FeeDiscountDto extends PageDto implements Serializable {
     private String communityId;
     private String ruleId;
     private String ruleName;
+    private String beanImpl;
 
     private List<FeeDiscountSpecDto> feeDiscountSpecs;
 
@@ -113,4 +114,12 @@ public class FeeDiscountDto extends PageDto implements Serializable {
     public void setRuleName(String ruleName) {
         this.ruleName = ruleName;
     }
+
+    public String getBeanImpl() {
+        return beanImpl;
+    }
+
+    public void setBeanImpl(String beanImpl) {
+        this.beanImpl = beanImpl;
+    }
 }

+ 33 - 19
java110-bean/src/main/java/com/java110/dto/payFeeDetailDiscount/PayFeeDetailDiscountDto.java

@@ -1,6 +1,7 @@
 package com.java110.dto.payFeeDetailDiscount;
 
 import com.java110.dto.PageDto;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -15,12 +16,12 @@ import java.util.Date;
 public class PayFeeDetailDiscountDto extends PageDto implements Serializable {
 
     private String detailDiscountId;
-private String discountPrice;
-private String detailId;
-private String remark;
-private String communityId;
-private String discountId;
-private String feeId;
+    private String discountPrice;
+    private String detailId;
+    private String remark;
+    private String communityId;
+    private String discountId;
+    private String feeId;
 
 
     private Date createTime;
@@ -31,43 +32,56 @@ private String feeId;
     public String getDetailDiscountId() {
         return detailDiscountId;
     }
-public void setDetailDiscountId(String detailDiscountId) {
+
+    public void setDetailDiscountId(String detailDiscountId) {
         this.detailDiscountId = detailDiscountId;
     }
-public String getDiscountPrice() {
+
+    public String getDiscountPrice() {
         return discountPrice;
     }
-public void setDiscountPrice(String discountPrice) {
+
+    public void setDiscountPrice(String discountPrice) {
         this.discountPrice = discountPrice;
     }
-public String getDetailId() {
+
+    public String getDetailId() {
         return detailId;
     }
-public void setDetailId(String detailId) {
+
+    public void setDetailId(String detailId) {
         this.detailId = detailId;
     }
-public String getRemark() {
+
+    public String getRemark() {
         return remark;
     }
-public void setRemark(String remark) {
+
+    public void setRemark(String remark) {
         this.remark = remark;
     }
-public String getCommunityId() {
+
+    public String getCommunityId() {
         return communityId;
     }
-public void setCommunityId(String communityId) {
+
+    public void setCommunityId(String communityId) {
         this.communityId = communityId;
     }
-public String getDiscountId() {
+
+    public String getDiscountId() {
         return discountId;
     }
-public void setDiscountId(String discountId) {
+
+    public void setDiscountId(String discountId) {
         this.discountId = discountId;
     }
-public String getFeeId() {
+
+    public String getFeeId() {
         return feeId;
     }
-public void setFeeId(String feeId) {
+
+    public void setFeeId(String feeId) {
         this.feeId = feeId;
     }
 

+ 2 - 3
java110-core/src/main/java/com/java110/core/factory/GenerateCodeFactory.java

@@ -176,8 +176,6 @@ public class GenerateCodeFactory {
     public static final String CODE_PREFIX_errId = "10";
 
 
-
-
     /**
      * 只有在不调用服务生成ID时有用
      */
@@ -247,6 +245,7 @@ public class GenerateCodeFactory {
         }
     }
 
+
     public static String nextId() {
         return nextId("%04d");
     }
@@ -306,7 +305,7 @@ public class GenerateCodeFactory {
      * @throws GenerateCodeException
      */
     public static String getSpecCd() throws GenerateCodeException {
-        return DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_L) + nextId("%04d");
+        return nextId("%06d");
     }
 
     public static String getOId() throws GenerateCodeException {

+ 1 - 1
java110-db/src/main/resources/mapper/fee/FeeDiscountServiceDaoImplMapper.xml

@@ -20,7 +20,7 @@
         select t.discount_name,t.discount_name discountName,t.discount_desc,t.discount_desc
         discountDesc,t.discount_type,t.discount_type discountType,t.status_cd,t.status_cd
         statusCd,t.discount_id,t.discount_id discountId,t.community_id,t.community_id communityId,t.rule_id,t.rule_id
-        ruleId,t.create_time createTime,fdr.rule_name ruleName
+        ruleId,t.create_time createTime,fdr.rule_name ruleName,fdr.bean_impl beanImpl
         from fee_discount t
         left join fee_discount_rule fdr on t.rule_id = fdr.rule_id and fdr.status_cd = '0'
         where 1 =1

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

@@ -243,8 +243,13 @@
     <select id="queryOwnerCarsCount" parameterType="Map" resultType="Map">
         select count(1) count
         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
-        where 1 =1
+        where 1=1
+        <if test="statusCd !=null and statusCd != ''">
+            and  t.status_cd = #{statusCd}
+        </if>
         <if test="carColor !=null and carColor != ''">
             and t.car_color= #{carColor}
         </if>
@@ -257,6 +262,12 @@
         <if test="carNum !=null and carNum != ''">
             and t.car_num= #{carNum}
         </if>
+        <if test="carNums !=null">
+            and t.car_num in
+            <foreach collection="carNums" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="psId !=null and psId != ''">
             and t.ps_id= #{psId}
         </if>
@@ -275,18 +286,24 @@
         <if test="bId !=null and bId != ''">
             and t.b_id= #{bId}
         </if>
-        <if test="userId !=null and userId != ''">
-            and t.user_id= #{userId}
-        </if>
         <if test="carId !=null and carId != ''">
             and t.car_id= #{carId}
         </if>
+        <if test="carIds !=null">
+            and t.car_id in
+            <foreach collection="carIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="communityId !=null and communityId != ''">
             and t.community_id= #{communityId}
         </if>
         <if test="state !=null and state != ''">
             and t.state= #{state}
         </if>
+        <if test="valid == '1'">
+            and t.end_time &gt; now()
+        </if>
 
 
     </select>

+ 11 - 0
java110-interface/src/main/java/com/java110/intf/fee/IFeeDiscountInnerServiceSMO.java

@@ -1,6 +1,8 @@
 package com.java110.intf.fee;
 
 import com.java110.config.feign.FeignConfiguration;
+import com.java110.dto.fee.FeeDetailDto;
+import com.java110.dto.feeDiscount.ComputeDiscountDto;
 import com.java110.dto.feeDiscount.FeeDiscountDto;
 import com.java110.po.feeDiscount.FeeDiscountPo;
 import org.springframework.cloud.openfeign.FeignClient;
@@ -49,4 +51,13 @@ public interface IFeeDiscountInnerServiceSMO {
      */
     @RequestMapping(value = "/queryFeeDiscountsCount", method = RequestMethod.POST)
     int queryFeeDiscountsCount(@RequestBody FeeDiscountDto feeDiscountDto);
+
+    /**
+     * 计算折扣
+     *
+     * @param feeDetailDto
+     * @return
+     */
+    @RequestMapping(value = "/computeDiscount", method = RequestMethod.POST)
+    public List<ComputeDiscountDto> computeDiscount(@RequestBody FeeDetailDto feeDetailDto);
 }

+ 13 - 31
service-fee/src/main/java/com/java110/fee/bmo/feeDiscountRuleSpec/impl/ComputeFeeDiscountBMOImpl.java

@@ -1,11 +1,9 @@
 package com.java110.fee.bmo.feeDiscountRuleSpec.impl;
 
-import com.java110.dto.fee.FeeDto;
-import com.java110.dto.payFeeConfigDiscount.PayFeeConfigDiscountDto;
+import com.java110.dto.fee.FeeDetailDto;
+import com.java110.dto.feeDiscount.ComputeDiscountDto;
 import com.java110.fee.bmo.feeDiscountRuleSpec.IComputeFeeDiscountBMO;
-import com.java110.intf.fee.IFeeInnerServiceSMO;
-import com.java110.intf.fee.IPayFeeConfigDiscountInnerServiceSMO;
-import com.java110.utils.util.Assert;
+import com.java110.fee.smo.impl.FeeDiscountInnerServiceSMOImpl;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
@@ -18,10 +16,7 @@ public class ComputeFeeDiscountBMOImpl implements IComputeFeeDiscountBMO {
 
 
     @Autowired
-    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
-
-    @Autowired
-    private IPayFeeConfigDiscountInnerServiceSMO payFeeConfigDiscountInnerServiceSMOImpl;
+    private FeeDiscountInnerServiceSMOImpl feeDiscountInnerServiceSMOImpl;
 
 
     /**
@@ -37,28 +32,15 @@ public class ComputeFeeDiscountBMOImpl implements IComputeFeeDiscountBMO {
     @Override
     public ResponseEntity<String> compute(String feeId, String communityId, double cycles, int page, int row) {
 
-        FeeDto feeDto = new FeeDto();
-        feeDto.setFeeId(feeId);
-        feeDto.setCommunityId(communityId);
-        feeDto.setState(FeeDto.STATE_DOING);
-        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
-        Assert.listOnlyOne(feeDtos, "费用不存在");
-
-        PayFeeConfigDiscountDto payFeeConfigDiscountDto = new PayFeeConfigDiscountDto();
-        payFeeConfigDiscountDto.setConfigId(feeDtos.get(0).getConfigId());
-        payFeeConfigDiscountDto.setCommunityId(communityId);
-        List<PayFeeConfigDiscountDto> payFeeConfigDiscountDtos =
-                payFeeConfigDiscountInnerServiceSMOImpl.queryPayFeeConfigDiscounts(payFeeConfigDiscountDto);
-
-        if (payFeeConfigDiscountDtos == null || payFeeConfigDiscountDtos.size() < 1) {
-            return ResultVo.success();
-        }
-
-
-        for(PayFeeConfigDiscountDto tmpPayFeeConfigDiscountDto : payFeeConfigDiscountDtos){
+        FeeDetailDto feeDetailDto = new FeeDetailDto();
+        feeDetailDto.setCommunityId(communityId);
+        feeDetailDto.setFeeId(feeId);
+        feeDetailDto.setCycles(cycles + "");
+        feeDetailDto.setRow(row);
+        feeDetailDto.setPage(page);
+        List<ComputeDiscountDto> computeDiscountDtos = feeDiscountInnerServiceSMOImpl.computeDiscount(feeDetailDto);
+        return ResultVo.createResponseEntity(computeDiscountDtos);
+    }
 
-        }
 
-        return null;
-    }
 }

+ 34 - 0
service-fee/src/main/java/com/java110/fee/discount/IComputeDiscount.java

@@ -0,0 +1,34 @@
+
+/*
+ * 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.fee.discount;
+
+
+import com.java110.dto.feeDiscount.ComputeDiscountDto;
+import com.java110.dto.feeDiscount.FeeDiscountDto;
+
+/**
+ * 折扣计算
+ */
+public interface IComputeDiscount {
+
+    /**
+     * 计算折扣
+     * @param feeDiscountDto
+     * @return
+     */
+    ComputeDiscountDto compute(FeeDiscountDto feeDiscountDto);
+}

+ 66 - 0
service-fee/src/main/java/com/java110/fee/smo/impl/FeeDiscountInnerServiceSMOImpl.java

@@ -3,15 +3,25 @@ package com.java110.fee.smo.impl;
 
 import com.java110.core.base.smo.BaseServiceSMO;
 import com.java110.dto.PageDto;
+import com.java110.dto.fee.FeeDetailDto;
+import com.java110.dto.fee.FeeDto;
+import com.java110.dto.feeDiscount.ComputeDiscountDto;
 import com.java110.dto.feeDiscount.FeeDiscountDto;
+import com.java110.dto.payFeeConfigDiscount.PayFeeConfigDiscountDto;
 import com.java110.fee.dao.IFeeDiscountServiceDao;
+import com.java110.fee.discount.IComputeDiscount;
 import com.java110.intf.fee.IFeeDiscountInnerServiceSMO;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.fee.IPayFeeConfigDiscountInnerServiceSMO;
 import com.java110.po.feeDiscount.FeeDiscountPo;
+import com.java110.utils.factory.ApplicationContextFactory;
+import com.java110.utils.util.Assert;
 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;
 
 /**
@@ -28,6 +38,12 @@ public class FeeDiscountInnerServiceSMOImpl extends BaseServiceSMO implements IF
     @Autowired
     private IFeeDiscountServiceDao feeDiscountServiceDaoImpl;
 
+    @Autowired
+    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+
+    @Autowired
+    private IPayFeeConfigDiscountInnerServiceSMO payFeeConfigDiscountInnerServiceSMOImpl;
+
 
     @Override
     public int saveFeeDiscount(@RequestBody FeeDiscountPo feeDiscountPo) {
@@ -68,6 +84,56 @@ public class FeeDiscountInnerServiceSMOImpl extends BaseServiceSMO implements IF
     }
 
 
+    /**
+     * 计算折扣
+     *
+     * @param feeDetailDto
+     * @return
+     */
+
+    public List<ComputeDiscountDto> computeDiscount(@RequestBody FeeDetailDto feeDetailDto) {
+        List<ComputeDiscountDto> computeDiscountDtos = new ArrayList<>();
+        FeeDto feeDto = new FeeDto();
+        feeDto.setFeeId(feeDetailDto.getFeeId());
+        feeDto.setCommunityId(feeDetailDto.getCommunityId());
+        feeDto.setState(FeeDto.STATE_DOING);
+        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+        Assert.listOnlyOne(feeDtos, "费用不存在");
+
+        PayFeeConfigDiscountDto payFeeConfigDiscountDto = new PayFeeConfigDiscountDto();
+        payFeeConfigDiscountDto.setConfigId(feeDtos.get(0).getConfigId());
+        payFeeConfigDiscountDto.setRow(feeDetailDto.getRow());
+        payFeeConfigDiscountDto.setPage(feeDetailDto.getRow());
+        payFeeConfigDiscountDto.setCommunityId(feeDetailDto.getCommunityId());
+        List<PayFeeConfigDiscountDto> payFeeConfigDiscountDtos =
+                payFeeConfigDiscountInnerServiceSMOImpl.queryPayFeeConfigDiscounts(payFeeConfigDiscountDto);
+
+        if (payFeeConfigDiscountDtos == null || payFeeConfigDiscountDtos.size() < 1) {
+            return computeDiscountDtos;
+        }
+
+        for (PayFeeConfigDiscountDto tmpPayFeeConfigDiscountDto : payFeeConfigDiscountDtos) {
+            doCompute(tmpPayFeeConfigDiscountDto, Double.parseDouble(feeDetailDto.getCycles()), computeDiscountDtos);
+        }
+        return computeDiscountDtos;
+
+    }
+
+    private void doCompute(PayFeeConfigDiscountDto tmpPayFeeConfigDiscountDto, double cycles, List<ComputeDiscountDto> computeDiscountDtos) {
+
+        FeeDiscountDto feeDiscountDto = new FeeDiscountDto();
+        feeDiscountDto.setCommunityId(tmpPayFeeConfigDiscountDto.getCommunityId());
+        feeDiscountDto.setDiscountId(tmpPayFeeConfigDiscountDto.getDiscountId());
+        List<FeeDiscountDto> feeDiscountDtos = queryFeeDiscounts(feeDiscountDto);
+        if (feeDiscountDtos == null || feeDiscountDtos.size() < 1) {
+            return;
+        }
+        IComputeDiscount computeDiscount = (IComputeDiscount) ApplicationContextFactory.getBean(feeDiscountDtos.get(0).getBeanImpl());
+        ComputeDiscountDto computeDiscountDto = computeDiscount.compute(feeDiscountDtos.get(0));
+        computeDiscountDtos.add(computeDiscountDto);
+    }
+
+
     @Override
     public int queryFeeDiscountsCount(@RequestBody FeeDiscountDto feeDiscountDto) {
         return feeDiscountServiceDaoImpl.queryFeeDiscountsCount(BeanConvertUtil.beanCovertMap(feeDiscountDto));