From d6eacbd54ee7111972a04e13d50a7d1f77dfd105 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期日, 23 四月 2023 17:45:11 +0800
Subject: [PATCH] add product category functiong
---
service-acct/src/main/java/com/java110/acct/cmd/integral/ComputePayFeeIntegralCmd.java | 50 +++++++++-----------------------------------------
1 files changed, 9 insertions(+), 41 deletions(-)
diff --git a/service-acct/src/main/java/com/java110/acct/cmd/integral/ComputePayFeeIntegralCmd.java b/service-acct/src/main/java/com/java110/acct/cmd/integral/ComputePayFeeIntegralCmd.java
index b5f8cc2..a926098 100644
--- a/service-acct/src/main/java/com/java110/acct/cmd/integral/ComputePayFeeIntegralCmd.java
+++ b/service-acct/src/main/java/com/java110/acct/cmd/integral/ComputePayFeeIntegralCmd.java
@@ -1,20 +1,15 @@
package com.java110.acct.cmd.integral;
-import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.java110.acct.smo.impl.IntegralRuleConfigV1InnerServiceSMOImpl;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.smo.IComputeFeeSMO;
import com.java110.doc.annotation.*;
-import com.java110.dto.couponRuleCpps.CouponRuleCppsDto;
-import com.java110.dto.couponRuleFee.CouponRuleFeeDto;
import com.java110.dto.fee.FeeDto;
-import com.java110.dto.integralRuleConfig.IntegralRuleConfigDto;
-import com.java110.dto.integralRuleFee.IntegralRuleFeeDto;
-import com.java110.intf.acct.ICouponRuleCppsV1InnerServiceSMO;
-import com.java110.intf.acct.ICouponRuleFeeV1InnerServiceSMO;
+import com.java110.dto.integral.IntegralRuleConfigDto;
+import com.java110.dto.integral.IntegralRuleFeeDto;
import com.java110.intf.acct.IIntegralRuleConfigV1InnerServiceSMO;
import com.java110.intf.acct.IIntegralRuleFeeV1InnerServiceSMO;
import com.java110.intf.fee.IFeeInnerServiceSMO;
@@ -24,7 +19,6 @@
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
-import java.math.BigDecimal;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@@ -70,6 +64,9 @@
@Autowired
private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+ @Autowired
+ private IComputeFeeSMO computeFeeSMOImpl;
+
@Override
public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
@@ -98,7 +95,7 @@
List<IntegralRuleFeeDto> integralRuleFeeDtos = integralRuleFeeV1InnerServiceSMOImpl.queryIntegralRuleFees(integralRuleFeeDto);
if(integralRuleFeeDtos == null || integralRuleFeeDtos.size()<1){
- context.setResponseEntity(ResultVo.createResponseEntity(new JSONArray()));
+ context.setResponseEntity(ResultVo.createResponseEntity(0));
return ;
}
@@ -112,7 +109,7 @@
List<IntegralRuleConfigDto> integralRuleConfigDtos = integralRuleConfigV1InnerServiceSMOImpl.queryIntegralRuleConfigs(integralRuleConfigDto);
if(integralRuleConfigDtos == null || integralRuleConfigDtos.size() < 1){
- context.setResponseEntity(ResultVo.createResponseEntity(new JSONArray()));
+ context.setResponseEntity(ResultVo.createResponseEntity(0));
return ;
}
@@ -125,39 +122,10 @@
long quantity = 0;
for(IntegralRuleConfigDto integralRuleConfigDto:integralRuleConfigDtos){
- quantity += computeOneIntegralQuantity(integralRuleConfigDto,reqJson);
+ quantity += computeFeeSMOImpl.computeOneIntegralQuantity(integralRuleConfigDto,reqJson);
}
return quantity;
}
- /**
- * 璁$畻璁$畻绉垎
- * @param integralRuleConfigDto
- * @return
- */
- private long computeOneIntegralQuantity(IntegralRuleConfigDto integralRuleConfigDto,JSONObject reqJson) {
- String computingFormula = integralRuleConfigDto.getComputingFormula();
- BigDecimal amountDec = null;
- long amount = 0;
- if(IntegralRuleConfigDto.COMPUTING_FORMULA_AREA.equals(computingFormula)){ //闈㈢Н涔樹互鍗曚环
- BigDecimal areaDec = new BigDecimal(Double.parseDouble(reqJson.getString("area")));
- BigDecimal squarePriceDec = new BigDecimal(Double.parseDouble(integralRuleConfigDto.getSquarePrice()));
- amountDec = areaDec.multiply(squarePriceDec).setScale(2,BigDecimal.ROUND_HALF_UP);
- }else if(IntegralRuleConfigDto.COMPUTING_FORMULA_MONEY.equals(computingFormula)){ // 閲戦涔樹互鍗曚环
- BigDecimal aDec = new BigDecimal(Double.parseDouble(reqJson.getString("amount")));
- BigDecimal squarePriceDec = new BigDecimal(Double.parseDouble(integralRuleConfigDto.getSquarePrice()));
- amountDec = aDec.multiply(squarePriceDec).setScale(2,BigDecimal.ROUND_HALF_UP);
- }else if(IntegralRuleConfigDto.COMPUTING_FORMULA_FIXED.equals(computingFormula)){ // 鍥哄畾绉垎
- amountDec = new BigDecimal(Double.parseDouble(integralRuleConfigDto.getAdditionalAmount()));
- }else{
- amountDec = new BigDecimal(0);
- }
- if(IntegralRuleConfigDto.SCALE_UP.equals(integralRuleConfigDto.getScale())){
- amount = new Double(Math.ceil(amountDec.doubleValue())).longValue();
- }else{
- amount = new Double(Math.floor(amountDec.doubleValue())).longValue();
- }
- return amount;
- }
}
--
Gitblit v1.8.0