|
@@ -3,15 +3,25 @@ package com.java110.fee.smo.impl;
|
|
|
|
|
|
|
|
import com.java110.core.base.smo.BaseServiceSMO;
|
|
import com.java110.core.base.smo.BaseServiceSMO;
|
|
|
import com.java110.dto.PageDto;
|
|
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.feeDiscount.FeeDiscountDto;
|
|
|
|
|
+import com.java110.dto.payFeeConfigDiscount.PayFeeConfigDiscountDto;
|
|
|
import com.java110.fee.dao.IFeeDiscountServiceDao;
|
|
import com.java110.fee.dao.IFeeDiscountServiceDao;
|
|
|
|
|
+import com.java110.fee.discount.IComputeDiscount;
|
|
|
import com.java110.intf.fee.IFeeDiscountInnerServiceSMO;
|
|
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.po.feeDiscount.FeeDiscountPo;
|
|
|
|
|
+import com.java110.utils.factory.ApplicationContextFactory;
|
|
|
|
|
+import com.java110.utils.util.Assert;
|
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -28,6 +38,12 @@ public class FeeDiscountInnerServiceSMOImpl extends BaseServiceSMO implements IF
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFeeDiscountServiceDao feeDiscountServiceDaoImpl;
|
|
private IFeeDiscountServiceDao feeDiscountServiceDaoImpl;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IPayFeeConfigDiscountInnerServiceSMO payFeeConfigDiscountInnerServiceSMOImpl;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int saveFeeDiscount(@RequestBody FeeDiscountPo feeDiscountPo) {
|
|
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
|
|
@Override
|
|
|
public int queryFeeDiscountsCount(@RequestBody FeeDiscountDto feeDiscountDto) {
|
|
public int queryFeeDiscountsCount(@RequestBody FeeDiscountDto feeDiscountDto) {
|
|
|
return feeDiscountServiceDaoImpl.queryFeeDiscountsCount(BeanConvertUtil.beanCovertMap(feeDiscountDto));
|
|
return feeDiscountServiceDaoImpl.queryFeeDiscountsCount(BeanConvertUtil.beanCovertMap(feeDiscountDto));
|