|
@@ -271,13 +271,13 @@ public class PayOrderController {
|
|
CustomerElectronicCard electronicCardInfo = electronicMembershipCardService.getElectronicCardInfoByUnionId(customerElectronicCard);
|
|
CustomerElectronicCard electronicCardInfo = electronicMembershipCardService.getElectronicCardInfoByUnionId(customerElectronicCard);
|
|
BigDecimal balance = null;
|
|
BigDecimal balance = null;
|
|
String cardOilsType1 ="";
|
|
String cardOilsType1 ="";
|
|
|
|
+ Map<String, String> result = new HashMap<>();
|
|
if(electronicCardInfo !=null){
|
|
if(electronicCardInfo !=null){
|
|
balance = electronicCardInfo.getAmt();
|
|
balance = electronicCardInfo.getAmt();
|
|
cardOilsType1 = electronicCardInfo.getCardOilsType();
|
|
cardOilsType1 = electronicCardInfo.getCardOilsType();
|
|
|
|
+ result.put("balance",balance.toString());
|
|
|
|
+ result.put("cardOilsType",cardOilsType1);
|
|
}
|
|
}
|
|
- Map<String, String> result = new HashMap<>();
|
|
|
|
- result.put("balance",balance.toString());
|
|
|
|
- result.put("cardOilsType",cardOilsType1);
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -521,6 +521,7 @@ public class PayOrderController {
|
|
if(payOrderRequest.getReceivableAmt() !=null){ //应收金额
|
|
if(payOrderRequest.getReceivableAmt() !=null){ //应收金额
|
|
Double receivableAmt = payOrderRequest.getReceivableAmt(); //应收金额 用户输入的金额
|
|
Double receivableAmt = payOrderRequest.getReceivableAmt(); //应收金额 用户输入的金额
|
|
Integer stationId = payOrderRequest.getStationId(); //油站ID
|
|
Integer stationId = payOrderRequest.getStationId(); //油站ID
|
|
|
|
+
|
|
//String oilGun = payOrderRequest.getOilGun(); //油枪号
|
|
//String oilGun = payOrderRequest.getOilGun(); //油枪号
|
|
String oilName = payOrderRequest.getOilName(); //油品名称
|
|
String oilName = payOrderRequest.getOilName(); //油品名称
|
|
String openId = payOrderRequest.getOpenId(); //用户的openId
|
|
String openId = payOrderRequest.getOpenId(); //用户的openId
|
|
@@ -540,6 +541,21 @@ public class PayOrderController {
|
|
//resultMap.put("stationName", stationNanme);
|
|
//resultMap.put("stationName", stationNanme);
|
|
resultMap.put("oilPrice", oilPrice); //油品价格
|
|
resultMap.put("oilPrice", oilPrice); //油品价格
|
|
resultMap.put("receivableAmt", receivableAmt); //应收价格
|
|
resultMap.put("receivableAmt", receivableAmt); //应收价格
|
|
|
|
+// String isGradeSetting =""; //电子卡是否开启等级
|
|
|
|
+// String isMarket =""; //
|
|
|
|
+// StationPayManage stationPayManage = new StationPayManage();
|
|
|
|
+// stationPayManage.setStationId(stationId);
|
|
|
|
+// StationPayManage stationPayManageInfo = stationService.selectStationPayManage(stationPayManage); //换取油站配置信息
|
|
|
|
+// //是否开起电子卡功能
|
|
|
|
+// if(stationPayManageInfo !=null && stationPayManageInfo.getCardEnabledFlag().equals("1")){
|
|
|
|
+// CustomerCardSetting customerCardSetting = new CustomerCardSetting();
|
|
|
|
+// customerCardSetting.setStationId(stationId);
|
|
|
|
+// List<CustomerCardSetting> cardRechargeSettingList = electronicMembershipCardService.getCardRechargeSettingList(customerCardSetting);
|
|
|
|
+// if(cardRechargeSettingList !=null && cardRechargeSettingList.size() >0){
|
|
|
|
+// isGradeSetting = cardRechargeSettingList.get(0).getIsGradeSetting();
|
|
|
|
+// isMarket = cardRechargeSettingList.get(0).getIsMarket();
|
|
|
|
+// }
|
|
|
|
+// }
|
|
//该油站的优惠方式
|
|
//该油站的优惠方式
|
|
String stationDiscountWay = stationService.getStationDiscountWay(stationId.toString());
|
|
String stationDiscountWay = stationService.getStationDiscountWay(stationId.toString());
|
|
Map<String ,Object> params = new HashMap<String, Object>();
|
|
Map<String ,Object> params = new HashMap<String, Object>();
|
|
@@ -566,7 +582,6 @@ public class PayOrderController {
|
|
}
|
|
}
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
- //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
resultMap.put("amt", amt.doubleValue());
|
|
resultMap.put("amt", amt.doubleValue());
|
|
resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
@@ -585,11 +600,8 @@ public class PayOrderController {
|
|
}else {
|
|
}else {
|
|
discountAmt =new BigDecimal("0.00");
|
|
discountAmt =new BigDecimal("0.00");
|
|
}
|
|
}
|
|
-// discountAmt = oilLiters.multiply(new BigDecimal(customerGradeList.get(0).get("gasoilDiscountLitre").toString()));
|
|
|
|
-// discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
- //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
resultMap.put("amt", amt.doubleValue());
|
|
resultMap.put("amt", amt.doubleValue());
|
|
resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
@@ -673,9 +685,9 @@ public class PayOrderController {
|
|
params.put("discountPlanType", "2");
|
|
params.put("discountPlanType", "2");
|
|
//营销方案
|
|
//营销方案
|
|
List<Map> customerMarkertPlanList_2 = customerGradeServices.getCustomerMarkertPlanList(params);
|
|
List<Map> customerMarkertPlanList_2 = customerGradeServices.getCustomerMarkertPlanList(params);
|
|
- //是否共享会员优惠叠加: 1 代表是; 2 代表否;
|
|
|
|
- String vipDiscountyPlus = customerMarkertPlanList_2.get(0).get("vipDiscountyPlus").toString();
|
|
|
|
if(customerMarkertPlanList_2 !=null && customerMarkertPlanList_2.size() >0){
|
|
if(customerMarkertPlanList_2 !=null && customerMarkertPlanList_2.size() >0){
|
|
|
|
+ //是否共享会员优惠叠加: 1 代表是; 2 代表否;
|
|
|
|
+ String vipDiscountyPlus = customerMarkertPlanList_2.get(0).get("vipDiscountyPlus").toString();
|
|
//如果当前应收金额大于条件金额
|
|
//如果当前应收金额大于条件金额
|
|
BigDecimal discountAmt_b = new BigDecimal(customerMarkertPlanList_2.get(0).get("discountAmt").toString()); //条件金额
|
|
BigDecimal discountAmt_b = new BigDecimal(customerMarkertPlanList_2.get(0).get("discountAmt").toString()); //条件金额
|
|
if(receivableAmt_b.compareTo(discountAmt_b) ==1 || receivableAmt_b.compareTo(discountAmt_b) ==0){
|
|
if(receivableAmt_b.compareTo(discountAmt_b) ==1 || receivableAmt_b.compareTo(discountAmt_b) ==0){
|
|
@@ -684,7 +696,6 @@ public class PayOrderController {
|
|
amt = receivableAmt_b.subtract(gasoilDiscountAmt_b); //实收金额
|
|
amt = receivableAmt_b.subtract(gasoilDiscountAmt_b); //实收金额
|
|
oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice), 2, BigDecimal.ROUND_HALF_UP); //加油升数
|
|
oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice), 2, BigDecimal.ROUND_HALF_UP); //加油升数
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
- //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP); //优惠价格
|
|
|
|
switch (vipDiscountyPlus){
|
|
switch (vipDiscountyPlus){
|
|
case "1":
|
|
case "1":
|
|
Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
@@ -741,71 +752,98 @@ public class PayOrderController {
|
|
//营销方案
|
|
//营销方案
|
|
List<Map> customerMarkertPlanList_3 = customerGradeServices.getCustomerMarkertPlanList(params);
|
|
List<Map> customerMarkertPlanList_3 = customerGradeServices.getCustomerMarkertPlanList(params);
|
|
if(customerMarkertPlanList_3 !=null && customerMarkertPlanList_3.size() >0){
|
|
if(customerMarkertPlanList_3 !=null && customerMarkertPlanList_3.size() >0){
|
|
- boolean flag= true;
|
|
|
|
- //独立直降时会存在多条
|
|
|
|
- for(Map m : customerMarkertPlanList_3){
|
|
|
|
- BigDecimal discountAmt_b = new BigDecimal(m.get("discountAmt").toString()); //条件金额
|
|
|
|
- BigDecimal gasoilDiscountAmt_b = new BigDecimal(m.get("gasoilDiscountAmt").toString());
|
|
|
|
- oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice), 2, BigDecimal.ROUND_HALF_UP); //加油升数
|
|
|
|
- if(m.get("discountTerm").toString().equals("1")){ //按升数优惠
|
|
|
|
- if(oilLiters.compareTo(discountAmt_b) ==1 || oilLiters.compareTo(discountAmt_b) ==0){
|
|
|
|
- //计算
|
|
|
|
- discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
|
|
|
|
- discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
+ //是否共享会员优惠叠加: 1 代表是; 2 代表否;
|
|
|
|
+ String vipDiscountyPlus_4 = customerMarkertPlanList_3.get(0).get("vipDiscountyPlus").toString();
|
|
|
|
+ BigDecimal discountAmt_b = new BigDecimal(customerMarkertPlanList_3.get(0).get("discountAmt").toString()); //条件金额
|
|
|
|
+ BigDecimal gasoilDiscountAmt_b = new BigDecimal(customerMarkertPlanList_3.get(0).get("gasoilDiscountAmt").toString());
|
|
|
|
+ oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice), 2, BigDecimal.ROUND_HALF_UP); //加油升数
|
|
|
|
+ if(customerMarkertPlanList_3.get(0).get("discountTerm").toString().equals("1")){ //按升数优惠
|
|
|
|
+ if(oilLiters.compareTo(discountAmt_b) ==1 || oilLiters.compareTo(discountAmt_b) ==0){
|
|
|
|
+ //计算
|
|
|
|
+ discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
|
|
|
|
+ discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ amt = receivableAmt_b.subtract(discountAmt);
|
|
|
|
+ discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP); //优惠价格
|
|
|
|
+
|
|
|
|
+ if(vipDiscountyPlus_4.equals("1")){
|
|
|
|
+ Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
|
|
+ discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
- //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP); //优惠价格
|
|
|
|
- //是否共享会员优惠叠加
|
|
|
|
- String vipDiscountyPlus_3 = m.get("vipDiscountyPlus").toString();
|
|
|
|
- if(vipDiscountyPlus_3.equals("1")){
|
|
|
|
|
|
+ //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ }
|
|
|
|
+ resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
|
|
+ resultMap.put("amt", amt.doubleValue());
|
|
|
|
+ resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
+ resultMap.put("discountPrice", discountPrice.doubleValue());
|
|
|
|
+ break;
|
|
|
|
+ }else {
|
|
|
|
+ //不满足优惠条件
|
|
|
|
+ switch (vipDiscountyPlus_4) {
|
|
|
|
+ case "1":
|
|
Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
|
|
discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
- //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
- }
|
|
|
|
- resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
|
|
- resultMap.put("amt", amt.doubleValue());
|
|
|
|
- resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
- resultMap.put("discountPrice", discountPrice.doubleValue());
|
|
|
|
- flag =false;
|
|
|
|
- break;
|
|
|
|
|
|
+ resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
|
|
+ resultMap.put("amt", amt.doubleValue());
|
|
|
|
+ resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
+ resultMap.put("discountPrice", discountPrice.doubleValue());
|
|
|
|
+ break;
|
|
|
|
+ case "2":
|
|
|
|
+ resultMap.put("discountAmt", 0);
|
|
|
|
+ resultMap.put("amt", receivableAmt.doubleValue());
|
|
|
|
+ oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice),2, BigDecimal.ROUND_HALF_UP); //加油升数
|
|
|
|
+ resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
+ resultMap.put("discountPrice", oilPrice);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
- }else if(m.get("discountTerm").toString().equals("2")){ //按金额优惠
|
|
|
|
- if(receivableAmt_b.compareTo(discountAmt_b) ==1 || receivableAmt_b.compareTo(discountAmt_b) ==0){
|
|
|
|
- discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
|
|
|
|
- discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
+ }
|
|
|
|
+ }else if(customerMarkertPlanList_3.get(0).get("discountTerm").toString().equals("2")){ //按金额优惠
|
|
|
|
+ if(receivableAmt_b.compareTo(discountAmt_b) ==1 || receivableAmt_b.compareTo(discountAmt_b) ==0){
|
|
|
|
+ discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
|
|
|
|
+ discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ amt = receivableAmt_b.subtract(discountAmt);
|
|
|
|
+ discountPrice = oilLiters !=new BigDecimal("0.00") ? amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP) : new BigDecimal(oilPrice);
|
|
|
|
+ //是否共享会员优惠叠加
|
|
|
|
+ if(vipDiscountyPlus_4.equals("1")){
|
|
|
|
+ Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
|
|
+ discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
- discountPrice = oilLiters !=new BigDecimal("0.00") ? amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP) : new BigDecimal(oilPrice);
|
|
|
|
- //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP); //优惠价格
|
|
|
|
- //是否共享会员优惠叠加
|
|
|
|
- String vipDiscountyPlus_3 = m.get("vipDiscountyPlus").toString();
|
|
|
|
- if(vipDiscountyPlus_3.equals("1")){
|
|
|
|
|
|
+ discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ }
|
|
|
|
+ resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
|
|
+ resultMap.put("amt", amt.doubleValue());
|
|
|
|
+ resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
+ resultMap.put("discountPrice", discountPrice.doubleValue());
|
|
|
|
+ break;
|
|
|
|
+ }else {
|
|
|
|
+ //不满足优惠条件
|
|
|
|
+ switch (vipDiscountyPlus_4) {
|
|
|
|
+ case "1":
|
|
Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
|
|
discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
amt = receivableAmt_b.subtract(discountAmt);
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
- //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
- }
|
|
|
|
- resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
|
|
- resultMap.put("amt", amt.doubleValue());
|
|
|
|
- resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
- resultMap.put("discountPrice", discountPrice.doubleValue());
|
|
|
|
- flag =false;
|
|
|
|
- break;
|
|
|
|
|
|
+ resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
|
|
+ resultMap.put("amt", amt.doubleValue());
|
|
|
|
+ resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
+ resultMap.put("discountPrice", discountPrice.doubleValue());
|
|
|
|
+ break;
|
|
|
|
+ case "2":
|
|
|
|
+ resultMap.put("discountAmt", 0);
|
|
|
|
+ resultMap.put("amt", receivableAmt.doubleValue());
|
|
|
|
+ oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice),2, BigDecimal.ROUND_HALF_UP); //加油升数
|
|
|
|
+ resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
+ resultMap.put("discountPrice", oilPrice);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //如果用户加油金额都不符合优惠门槛则计算等级的优惠
|
|
|
|
- if(flag){
|
|
|
|
- Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
|
|
- resultMap.put("discountAmt", map.get("discountAmt").toString());
|
|
|
|
- resultMap.put("amt", map.get("amt").toString());
|
|
|
|
- resultMap.put("oilLiters", map.get("oilLiters").toString());
|
|
|
|
- resultMap.put("discountPrice", map.get("discountPrice").toString());
|
|
|
|
- }
|
|
|
|
}else {
|
|
}else {
|
|
- //用户没有设置优惠规则时
|
|
|
|
|
|
+ //没有设置优惠条件时
|
|
Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
resultMap.put("discountAmt", map.get("discountAmt").toString());
|
|
resultMap.put("discountAmt", map.get("discountAmt").toString());
|
|
resultMap.put("amt", map.get("amt").toString());
|
|
resultMap.put("amt", map.get("amt").toString());
|
|
@@ -818,6 +856,9 @@ public class PayOrderController {
|
|
return resultMap;
|
|
return resultMap;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //计算
|
|
|
|
+
|
|
|
|
+
|
|
//计算等级直降
|
|
//计算等级直降
|
|
public Map<String, Object> calcuteDengJiZhiJiang(Map params){
|
|
public Map<String, Object> calcuteDengJiZhiJiang(Map params){
|
|
Double receivableAmt = Double.valueOf(params.get("receivableAmt").toString());
|
|
Double receivableAmt = Double.valueOf(params.get("receivableAmt").toString());
|
|
@@ -877,6 +918,82 @@ public class PayOrderController {
|
|
return resultMap;
|
|
return resultMap;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //计算满减
|
|
|
|
+ public Map<String, Object> calcuteManjian(Map params){
|
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
+ Double receivableAmt = Double.valueOf(params.get("receivableAmt").toString());
|
|
|
|
+ BigDecimal oilLiters = null;
|
|
|
|
+ BigDecimal discountAmt =null;
|
|
|
|
+ BigDecimal discountPrice = null;
|
|
|
|
+ BigDecimal amt = null;
|
|
|
|
+ BigDecimal receivableAmt_b = new BigDecimal(receivableAmt); //传入的应收金额
|
|
|
|
+ String oilPrice = params.get("oilPrice").toString();
|
|
|
|
+ params.put("discountPlanType", "1");
|
|
|
|
+ //营销方案
|
|
|
|
+ List<Map> customerMarkertPlanList_1 = customerGradeServices.getCustomerMarkertPlanList(params);
|
|
|
|
+ //有优惠规则
|
|
|
|
+ if(customerMarkertPlanList_1 !=null && customerMarkertPlanList_1.size() >0){
|
|
|
|
+ //是否共享会员优惠叠加: 1 代表是; 2 代表否;
|
|
|
|
+ String vipDiscountyPlus = customerMarkertPlanList_1.get(0).get("vipDiscountyPlus").toString();
|
|
|
|
+ //如果当前应收金额大于条件金额
|
|
|
|
+ BigDecimal discountAmt_b = new BigDecimal(customerMarkertPlanList_1.get(0).get("discountAmt").toString()); //条件金额
|
|
|
|
+ if(receivableAmt_b.compareTo(discountAmt_b) ==1 || receivableAmt_b.compareTo(discountAmt_b) ==0){
|
|
|
|
+ BigDecimal gasoilDiscountAmt_b = new BigDecimal(customerMarkertPlanList_1.get(0).get("gasoilDiscountAmt").toString()); //每满多少优惠多少的金额
|
|
|
|
+ discountAmt = receivableAmt_b.divide(discountAmt_b, 2, BigDecimal.ROUND_HALF_UP).multiply(gasoilDiscountAmt_b); //优惠金额
|
|
|
|
+ discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ amt = receivableAmt_b.subtract(discountAmt); //实收金额
|
|
|
|
+ oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice),2, BigDecimal.ROUND_HALF_UP); //加油升数
|
|
|
|
+ discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ switch (vipDiscountyPlus){
|
|
|
|
+ case "1":
|
|
|
|
+ Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
|
|
+ discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
|
|
|
|
+ amt = receivableAmt_b.subtract(discountAmt);
|
|
|
|
+ discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
|
|
+ resultMap.put("amt", amt.doubleValue());
|
|
|
|
+ resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
+ resultMap.put("discountPrice", discountPrice.doubleValue());
|
|
|
|
+ break;
|
|
|
|
+ case "2":
|
|
|
|
+ resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
|
|
+ resultMap.put("amt", amt.doubleValue());
|
|
|
|
+ resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
+ resultMap.put("discountPrice", discountPrice.doubleValue());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ switch (vipDiscountyPlus){
|
|
|
|
+ case "1":
|
|
|
|
+ Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
|
|
+ discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
|
|
|
|
+ amt = receivableAmt_b.subtract(discountAmt);
|
|
|
|
+ discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ resultMap.put("discountAmt", discountAmt.doubleValue());
|
|
|
|
+ resultMap.put("amt", amt.doubleValue());
|
|
|
|
+ resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
+ resultMap.put("discountPrice", discountPrice.doubleValue());
|
|
|
|
+ break;
|
|
|
|
+ case "2":
|
|
|
|
+ resultMap.put("discountAmt", 0);
|
|
|
|
+ resultMap.put("amt", receivableAmt.doubleValue());
|
|
|
|
+ oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice),2, BigDecimal.ROUND_HALF_UP); //加油升数
|
|
|
|
+ resultMap.put("oilLiters", oilLiters.doubleValue());
|
|
|
|
+ resultMap.put("discountPrice", oilPrice);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ //用户没有设置优惠规则时
|
|
|
|
+ Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
|
|
|
|
+ resultMap.put("discountAmt", map.get("discountAmt").toString());
|
|
|
|
+ resultMap.put("amt", map.get("amt").toString());
|
|
|
|
+ resultMap.put("oilLiters", map.get("oilLiters").toString());
|
|
|
|
+ resultMap.put("discountPrice", map.get("discountPrice").toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return resultMap;
|
|
|
|
+ };
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据订单号获取订单信息
|
|
* 根据订单号获取订单信息
|