|
@@ -4,13 +4,16 @@ import com.bz.smart_city.commom.exception.ServiceException;
|
|
|
import com.bz.smart_city.commom.model.Pagination;
|
|
|
import com.bz.smart_city.commom.util.UserUtil;
|
|
|
import com.bz.smart_city.dao.pay.PayControlRuleMapper;
|
|
|
+import com.bz.smart_city.dao.pay.PayRechargeaccountMapper;
|
|
|
import com.bz.smart_city.dto.LoginUser;
|
|
|
+import com.bz.smart_city.dto.pay.PayRechargeaccountDto;
|
|
|
import com.bz.smart_city.entity.pay.PayControlRule;
|
|
|
import com.bz.smart_city.service.pay.PayControlRuleService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
@@ -23,6 +26,10 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
|
|
|
|
|
|
@Resource
|
|
|
PayControlRuleMapper payControlRuleMapper;
|
|
|
+ @Resource
|
|
|
+ PayRechargeaccountMapper payRechargeaccountMapper;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Integer add(PayControlRule payControlRule){
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
@@ -97,4 +104,277 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 欠费天数
|
|
|
+ * @param accountId 用户编号
|
|
|
+ * @param condition 条件
|
|
|
+ * @param value 判断值
|
|
|
+ * @return 符合条件返回true
|
|
|
+ */
|
|
|
+ public boolean ConditionDebtDay(String accountId,String condition,String value){
|
|
|
+ Integer day = payControlRuleMapper.findDebtDay(accountId);
|
|
|
+ int paramDay = Integer.valueOf(value).intValue();
|
|
|
+ if(day != null){
|
|
|
+ switch (condition){
|
|
|
+ case ">":{
|
|
|
+ if(day > paramDay)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<":{
|
|
|
+ if(day < paramDay)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<>":{
|
|
|
+ if(day != paramDay)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "=":{
|
|
|
+ if(day == paramDay)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case ">=":{
|
|
|
+ if(day >= paramDay)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<=":{
|
|
|
+ if(day <= paramDay)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 欠费金额
|
|
|
+ * @param accountId 用户编号
|
|
|
+ * @param condition 条件
|
|
|
+ * @param value 判断值
|
|
|
+ * @return 符合条件返回true
|
|
|
+ */
|
|
|
+ public boolean ConditionDebtMoney(String accountId,String condition,String value){
|
|
|
+ BigDecimal money = payControlRuleMapper.findDebtMoney(accountId);
|
|
|
+ if(money != null){
|
|
|
+ switch (condition){
|
|
|
+ case ">":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) > 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) < 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<>":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) != 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "=":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) == 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case ">=":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) >= 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<=":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) <= 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 预存余额
|
|
|
+ * @param accountId 用户编号
|
|
|
+ * @param condition 条件
|
|
|
+ * @param value 判断值
|
|
|
+ * @return 符合条件返回true
|
|
|
+ */
|
|
|
+ public boolean ConditionRecharge(String accountId,String condition,String value){
|
|
|
+ PayRechargeaccountDto payRechargeaccountDto = payRechargeaccountMapper.findById(null,new BigInteger(accountId));
|
|
|
+
|
|
|
+ if(payRechargeaccountDto != null){
|
|
|
+ BigDecimal money = payRechargeaccountDto.getRemaining();
|
|
|
+ switch (condition){
|
|
|
+ case ">":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) > 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) < 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<>":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) != 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "=":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) == 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case ">=":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) >= 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<=":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) <= 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用水余额
|
|
|
+ * @param accountId 用户编号
|
|
|
+ * @param condition 条件
|
|
|
+ * @param value 判断值
|
|
|
+ * @return 符合条件返回true
|
|
|
+ */
|
|
|
+ public boolean ConditionUsedMoney(String accountId,String condition,String value){
|
|
|
+ BigDecimal money = payControlRuleMapper.findUseMoeny(accountId);
|
|
|
+ if(money != null){
|
|
|
+ switch (condition){
|
|
|
+ case ">":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) > 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) < 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<>":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) != 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "=":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) == 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case ">=":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) >= 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<=":{
|
|
|
+ if(money.compareTo(new BigDecimal(value)) <= 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开户状态
|
|
|
+ * @param accountId 用户编号
|
|
|
+ * @param condition 条件
|
|
|
+ * @param value 判断值
|
|
|
+ * @return 符合条件返回true
|
|
|
+ */
|
|
|
+ public boolean ConditionOpenUsed(String accountId,String condition,String value){
|
|
|
+ Integer state = payControlRuleMapper.findDebtDay(accountId);
|
|
|
+ int paramValue = Integer.valueOf(value).intValue();
|
|
|
+ if(state != null){
|
|
|
+ switch (condition){
|
|
|
+ case "=":
|
|
|
+ {
|
|
|
+ if(paramValue == state)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<>":
|
|
|
+ {
|
|
|
+ if(paramValue != state)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 预存与欠费差额
|
|
|
+ * @param accountId 用户编号
|
|
|
+ * @param condition 条件
|
|
|
+ * @param value 判断值
|
|
|
+ * @return 符合条件返回true
|
|
|
+ */
|
|
|
+ public boolean ConditionRechargeAndDebt(String accountId,String condition,String value){
|
|
|
+ BigDecimal Recharge = payControlRuleMapper.findUseMoeny(accountId);
|
|
|
+ if(Recharge == null)
|
|
|
+ Recharge = new BigDecimal("0");
|
|
|
+
|
|
|
+ BigDecimal Debt = payControlRuleMapper.findDebtMoney(accountId);
|
|
|
+ if(Debt == null)
|
|
|
+ Debt = new BigDecimal("0");
|
|
|
+
|
|
|
+ BigDecimal DiffValue = null;
|
|
|
+ DiffValue = Recharge.subtract(Debt);
|
|
|
+ switch (condition) {
|
|
|
+ case ">": {
|
|
|
+ if (DiffValue.compareTo(new BigDecimal(value)) > 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<": {
|
|
|
+ if (DiffValue.compareTo(new BigDecimal(value)) < 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<>": {
|
|
|
+ if (DiffValue.compareTo(new BigDecimal(value)) != 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "=": {
|
|
|
+ if (DiffValue.compareTo(new BigDecimal(value)) == 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case ">=": {
|
|
|
+ if (DiffValue.compareTo(new BigDecimal(value)) >= 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "<=": {
|
|
|
+ if (DiffValue.compareTo(new BigDecimal(value)) <= 0)
|
|
|
+ return true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|