|
@@ -697,141 +697,143 @@ public class PayController {
|
|
|
//获取该用户积分信息
|
|
|
CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(customerPoints);
|
|
|
if(customerPointsInfo !=null){
|
|
|
- String ruleType = rule.get(0).getRuleType(); //获取积分规则类型
|
|
|
+ //String ruleType = rule.get(0).getRuleType(); //获取积分规则类型
|
|
|
String[] datePicker={}; //积分比例时间
|
|
|
if(rule.get(0).getDatePicker() != null && rule.get(0).getDatePicker() !=""){
|
|
|
datePicker = rule.get(0).getDatePicker().split(",");
|
|
|
}
|
|
|
String currentTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间
|
|
|
List<IntegralRuleDetail> integralRuleDetailList = rule.get(0).getIntegralRuleDetailList(); //积分规则详细计算信息
|
|
|
- switch (ruleType){
|
|
|
- case "1": //以订单实付累计
|
|
|
- //已存在:现有余额积分 + 本次消费所获得的积分
|
|
|
- BigDecimal realAmt = new BigDecimal(infoMap.get("amt").toString()); //本次消费实收金额
|
|
|
- for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){
|
|
|
- if(realAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1){
|
|
|
- //此处使用等级与不使用等级时参数存储获取逻辑写重原因:省去一次根据等级ID查询规则的数据库访问
|
|
|
- if(discountPlanType == "1" && customerManage.getGrade().equals(integralRuleDetail.getGread())){
|
|
|
- //计算积分并取整
|
|
|
- BigDecimal integral = realAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
- //设置积分多倍时间时
|
|
|
- if(datePicker !=null){
|
|
|
- for(String str: datePicker){
|
|
|
- if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){
|
|
|
- integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
- break;
|
|
|
+ if(integralRuleDetailList !=null && integralRuleDetailList.size() > 0){
|
|
|
+ boolean b =false;
|
|
|
+ BigDecimal realAmt = new BigDecimal(infoMap.get("amt").toString()); //本次消费实收金额
|
|
|
+ BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString()); //本次消费实收金额
|
|
|
+ BigDecimal orderLiters = new BigDecimal(infoMap.get("orderLiters").toString()); //本次加油升数
|
|
|
+ for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){
|
|
|
+ //规则类型
|
|
|
+ String ruleType = integralRuleDetail.getRuleType();
|
|
|
+ switch (ruleType){
|
|
|
+ case "1": //以订单实付累计
|
|
|
+ //已存在:现有余额积分 + 本次消费所获得的积分
|
|
|
+ if(realAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1){
|
|
|
+ if(discountPlanType == "1" && integralRuleDetail.getGread() !=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){
|
|
|
+ //计算积分并取整
|
|
|
+ BigDecimal integral = realAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
+ //设置积分多倍时间时
|
|
|
+ if(datePicker !=null){
|
|
|
+ for(String str: datePicker){
|
|
|
+ if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){
|
|
|
+ integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
- break;
|
|
|
- }else {
|
|
|
- //计算积分并取整
|
|
|
- BigDecimal integral = realAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
- //设置积分多倍时间时
|
|
|
- if(datePicker !=null){
|
|
|
- for(String str: datePicker){
|
|
|
- if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){
|
|
|
- integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
- break;
|
|
|
+ customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
+ }else {
|
|
|
+ //计算积分并取整
|
|
|
+ BigDecimal integral = realAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
+ //设置积分多倍时间时
|
|
|
+ if(datePicker !=null){
|
|
|
+ for(String str: datePicker){
|
|
|
+ if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){
|
|
|
+ integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
}
|
|
|
- customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
- //break;
|
|
|
+ b=true;
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case "2": //以订单应付累计
|
|
|
- //已存在:现有余额积分 + 本次消费所获得的积分
|
|
|
- BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString()); //本次消费实收金额
|
|
|
- for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){
|
|
|
- if(receivableAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1){
|
|
|
- //此处使用等级与不使用等级时参数存储获取逻辑写重原因:省去一次数据库访问
|
|
|
- if(discountPlanType == "1" && customerManage.getGrade().equals(integralRuleDetail.getGread())){
|
|
|
- //计算积分并取整
|
|
|
- BigDecimal integral = receivableAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
- //设置积分多倍时间时
|
|
|
- if(datePicker !=null){
|
|
|
- for(String str: datePicker){
|
|
|
- if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){
|
|
|
- integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
- break;
|
|
|
+ break;
|
|
|
+ case "2": //以订单应付累计
|
|
|
+ //已存在:现有余额积分 + 本次消费所获得的积分
|
|
|
+ if(receivableAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1){
|
|
|
+ if(discountPlanType == "1" && integralRuleDetail.getGread() !=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){
|
|
|
+ //计算积分并取整
|
|
|
+ BigDecimal integral = receivableAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
+ //设置积分多倍时间时
|
|
|
+ if(datePicker !=null){
|
|
|
+ for(String str: datePicker){
|
|
|
+ if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){
|
|
|
+ integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
- break;
|
|
|
- }else {
|
|
|
- //计算积分并取整
|
|
|
- BigDecimal integral = receivableAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
- //设置积分多倍时间时
|
|
|
- if(datePicker !=null){
|
|
|
- for(String str: datePicker){
|
|
|
- if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){
|
|
|
- integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
- break;
|
|
|
+ customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
+ break;
|
|
|
+ }else {
|
|
|
+ //计算积分并取整
|
|
|
+ BigDecimal integral = receivableAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
+ //设置积分多倍时间时
|
|
|
+ if(datePicker !=null){
|
|
|
+ for(String str: datePicker){
|
|
|
+ if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){
|
|
|
+ integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
}
|
|
|
- customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
- //break;
|
|
|
+ b=true;
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case "3": //以加油升数
|
|
|
- BigDecimal orderLiters = new BigDecimal(infoMap.get("orderLiters").toString());
|
|
|
- for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){
|
|
|
- if(orderLiters.compareTo(integralRuleDetail.getRuleTerms()) ==1){
|
|
|
- //此处使用等级与不使用等级时参数存储获取逻辑写重原因:省去一次数据库访问
|
|
|
- if(discountPlanType == "1" && customerManage.getGrade().equals(integralRuleDetail.getGread())){
|
|
|
- //计算积分并取整
|
|
|
- BigDecimal integral = orderLiters.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
- //设置积分多倍时间时
|
|
|
- if(datePicker !=null){
|
|
|
- for(String str: datePicker){
|
|
|
- if (str.contains(currentTime) && rule.get(0).getIntegralProportion() !=null ){
|
|
|
- integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
- break;
|
|
|
+ break;
|
|
|
+ case "3": //以加油升数
|
|
|
+ if(orderLiters.compareTo(integralRuleDetail.getRuleTerms()) ==1){
|
|
|
+ //此处使用等级与不使用等级时参数存储获取逻辑写重原因:省去一次数据库访问
|
|
|
+ if(discountPlanType == "1" && integralRuleDetail.getGread() !=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){
|
|
|
+ //计算积分并取整
|
|
|
+ BigDecimal integral = orderLiters.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
+ //设置积分多倍时间时
|
|
|
+ if(datePicker !=null){
|
|
|
+ for(String str: datePicker){
|
|
|
+ if (str.contains(currentTime) && rule.get(0).getIntegralProportion() !=null ){
|
|
|
+ integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
- break;
|
|
|
- }else {
|
|
|
- //计算积分并取整
|
|
|
- BigDecimal integral = orderLiters.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
- //设置积分多倍时间时
|
|
|
- if(datePicker !=null){
|
|
|
- for(String str: datePicker){
|
|
|
- if (str.contains(currentTime) && rule.get(0).getIntegralProportion() !=null ){
|
|
|
- integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
- break;
|
|
|
+ customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
+ break;
|
|
|
+ }else {
|
|
|
+ //计算积分并取整
|
|
|
+ BigDecimal integral = orderLiters.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
+ //设置积分多倍时间时
|
|
|
+ if(datePicker !=null){
|
|
|
+ for(String str: datePicker){
|
|
|
+ if (str.contains(currentTime) && rule.get(0).getIntegralProportion() !=null ){
|
|
|
+ integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion()));
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
+ customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
}
|
|
|
- customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString()));
|
|
|
- customerPointsRecord.setIntegral(Integer.valueOf(integral.toString()));
|
|
|
- //break;
|
|
|
+ b=true;
|
|
|
}
|
|
|
- }
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
+ // b=true是跳出循环
|
|
|
+ if(b){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
//更新客户余额积分
|
|
|
customerPointsService.updateCustomerPointsInfo(customerPoints);
|
|
|
//插入客户积分记录表
|