From 22af580b148c675f25bda8a8ff599f679b497fbd Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 13 十二月 2022 22:08:14 +0800
Subject: [PATCH] 优化积分核销功能
---
service-acct/src/main/java/com/java110/acct/cmd/integral/ComputePayFeeIntegralCmd.java | 39 +++++++--------------------------------
1 files changed, 7 insertions(+), 32 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..e033938 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
@@ -7,6 +7,7 @@
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;
@@ -70,6 +71,9 @@
@Autowired
private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+ @Autowired
+ private IComputeFeeSMO computeFeeSMOImpl;
+
@Override
public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
@@ -98,7 +102,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 +116,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 +129,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