|
@@ -163,6 +163,7 @@ public class PayOrderController {
|
|
|
// }
|
|
|
//payOrder.setDiscountAmt(Double.valueOf(payOrderResultInfo.getDzkDiscountAmt()));
|
|
|
}
|
|
|
+ resultMap.put("dzkDiscountPrice", payOrderResultInfo.getDzkDiscountPrice());
|
|
|
resultMap.put("cardEnabledFlag", payOrderResultInfo.getCardEnabledFlag());
|
|
|
resultMap.put("oilsCardFlag", payOrderResultInfo.getOilsCardFlag());
|
|
|
resultMap.put("discountAmt", payOrderResultInfo.getDiscountAmt()); //优惠金额
|
|
@@ -176,6 +177,9 @@ public class PayOrderController {
|
|
|
resultMap.put("sellDiscountAmt", payOrderResultInfo.getSellDiscountAmt());
|
|
|
}
|
|
|
payOrder.setDriverOilPrice(Double.valueOf(payOrderResultInfo.getDiscountPrice()));
|
|
|
+ if(payOrderResultInfo.getCardEnabledFlag().equals("1")){
|
|
|
+ payOrder.setDriverOilPrice(Double.valueOf(payOrderResultInfo.getDzkDiscountPrice()));
|
|
|
+ }
|
|
|
resultMap.put("receivableAmt", payOrderResultInfo.getReceivableAmt()); //应收价格
|
|
|
resultMap.put("oilLiters", payOrderResultInfo.getOilLiters());
|
|
|
resultMap.put("amt_dzk", payOrderResultInfo.getDzkAmt());
|
|
@@ -825,11 +829,14 @@ public class PayOrderController {
|
|
|
payOrderResultInfo.setBalance(map.get("balance"));
|
|
|
payOrderResultInfo.setOilsCardFlag(map.get("oilsCardFlag"));
|
|
|
payOrderResultInfo.setCardOilsType(map.get("cardOilsType"));
|
|
|
-// payOrderResultInfo.setStationId(Integer.valueOf(params.get("stationId").toString()));
|
|
|
-// payOrderResultInfo.setOilName(params.get("oilName").toString());
|
|
|
-// payOrderResultInfo.setUnionId(params.get("unionId").toString());
|
|
|
-// payOrderResultInfo.setAllDiscountType("2");
|
|
|
-// payOrderResultInfo.setUserCouponsList(this.getUserCouponAscList(payOrderResultInfo));
|
|
|
+
|
|
|
+ String dzkAmt = payOrderResultInfo.getDzkAmt();
|
|
|
+ if(oilLiters.toString().equals("0.00")){
|
|
|
+ payOrderResultInfo.setDzkDiscountPrice(oilPrice.toString());
|
|
|
+ }else {
|
|
|
+ BigDecimal dzkDiscountPrice = new BigDecimal(dzkAmt).divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ payOrderResultInfo.setDzkDiscountPrice(dzkDiscountPrice.toString());
|
|
|
+ }
|
|
|
}
|
|
|
return payOrderResultInfo;
|
|
|
}
|
|
@@ -1019,11 +1026,13 @@ public class PayOrderController {
|
|
|
payOrderResultInfo.setBalance(map.get("balance"));
|
|
|
payOrderResultInfo.setOilsCardFlag(map.get("oilsCardFlag"));
|
|
|
payOrderResultInfo.setCardOilsType(map.get("cardOilsType"));
|
|
|
-// payOrderResultInfo.setStationId(Integer.valueOf(params.get("stationId").toString()));
|
|
|
-// payOrderResultInfo.setOilName(params.get("oilName").toString());
|
|
|
-// payOrderResultInfo.setUnionId(params.get("unionId").toString());
|
|
|
-// payOrderResultInfo.setAllDiscountType("2");
|
|
|
-// payOrderResultInfo.setUserCouponsList(this.getUserCouponAscList(payOrderResultInfo));
|
|
|
+ String dzkAmt = payOrderResultInfo.getDzkAmt();
|
|
|
+ if(oilLiters.toString().equals("0.00")){
|
|
|
+ payOrderResultInfo.setDzkDiscountPrice(oilPrice.toString());
|
|
|
+ }else {
|
|
|
+ BigDecimal dzkDiscountPrice = new BigDecimal(dzkAmt).divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ payOrderResultInfo.setDzkDiscountPrice(dzkDiscountPrice.toString());
|
|
|
+ }
|
|
|
}
|
|
|
return payOrderResultInfo;
|
|
|
}
|
|
@@ -1158,11 +1167,13 @@ public class PayOrderController {
|
|
|
payOrderResultInfo.setBalance(map.get("balance"));
|
|
|
payOrderResultInfo.setOilsCardFlag(map.get("oilsCardFlag"));
|
|
|
payOrderResultInfo.setCardOilsType(map.get("cardOilsType"));
|
|
|
-// payOrderResultInfo.setStationId(Integer.valueOf(params.get("stationId").toString()));
|
|
|
-// payOrderResultInfo.setOilName(params.get("oilName").toString());
|
|
|
-// payOrderResultInfo.setUnionId(params.get("unionId").toString());
|
|
|
-// payOrderResultInfo.setAllDiscountType("2");
|
|
|
-// payOrderResultInfo.setUserCouponsList(this.getUserCouponAscList(payOrderResultInfo));
|
|
|
+ String dzkAmt = payOrderResultInfo.getDzkAmt();
|
|
|
+ if(oilLiters.toString().equals("0.00")){
|
|
|
+ payOrderResultInfo.setDzkDiscountPrice(oilPrice.toString());
|
|
|
+ }else {
|
|
|
+ BigDecimal dzkDiscountPrice = new BigDecimal(dzkAmt).divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ payOrderResultInfo.setDzkDiscountPrice(dzkDiscountPrice.toString());
|
|
|
+ }
|
|
|
}
|
|
|
return payOrderResultInfo;
|
|
|
}
|
|
@@ -1301,11 +1312,13 @@ public class PayOrderController {
|
|
|
payOrderResultInfo.setBalance(map.get("balance"));
|
|
|
payOrderResultInfo.setOilsCardFlag(map.get("oilsCardFlag"));
|
|
|
payOrderResultInfo.setCardOilsType(map.get("cardOilsType"));
|
|
|
-// payOrderResultInfo.setOilName(params.get("oilName").toString());
|
|
|
-// payOrderResultInfo.setUnionId(params.get("unionId").toString());
|
|
|
-// payOrderResultInfo.setAllDiscountType("2");
|
|
|
-// payOrderResultInfo.setStationId(Integer.valueOf(params.get("stationId").toString()));
|
|
|
-// payOrderResultInfo.setUserCouponsList(this.getUserCouponAscList(payOrderResultInfo));
|
|
|
+ String dzkAmt = payOrderResultInfo.getDzkAmt();
|
|
|
+ if(oilLiters.toString().equals("0.00")){
|
|
|
+ payOrderResultInfo.setDzkDiscountPrice(oilPrice.toString());
|
|
|
+ }else {
|
|
|
+ BigDecimal dzkDiscountPrice = new BigDecimal(dzkAmt).divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ payOrderResultInfo.setDzkDiscountPrice(dzkDiscountPrice.toString());
|
|
|
+ }
|
|
|
}
|
|
|
return payOrderResultInfo;
|
|
|
}
|
|
@@ -1419,11 +1432,13 @@ public class PayOrderController {
|
|
|
payOrderResultInfo.setBalance(map.get("balance"));
|
|
|
payOrderResultInfo.setOilsCardFlag(map.get("oilsCardFlag"));
|
|
|
payOrderResultInfo.setCardOilsType(map.get("cardOilsType"));
|
|
|
-// payOrderResultInfo.setOilName(params.get("oilName").toString());
|
|
|
-// payOrderResultInfo.setUnionId(params.get("unionId").toString());
|
|
|
-// payOrderResultInfo.setAllDiscountType("1");
|
|
|
-// payOrderResultInfo.setStationId(Integer.valueOf(params.get("stationId").toString()));
|
|
|
-// payOrderResultInfo.setUserCouponsList(this.getUserCouponAscList(payOrderResultInfo));
|
|
|
+ String dzkAmt = payOrderResultInfo.getDzkAmt();
|
|
|
+ if(oilLiters.toString().equals("0.00")){
|
|
|
+ payOrderResultInfo.setDzkDiscountPrice(oilPrice.toString());
|
|
|
+ }else {
|
|
|
+ BigDecimal dzkDiscountPrice = new BigDecimal(dzkAmt).divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ payOrderResultInfo.setDzkDiscountPrice(dzkDiscountPrice.toString());
|
|
|
+ }
|
|
|
}
|
|
|
return payOrderResultInfo;
|
|
|
}
|
|
@@ -1447,6 +1462,7 @@ public class PayOrderController {
|
|
|
userCoupon.setExpireFlag("0"); // SQL 条件判断 过期标志: 1 代表使用的优惠券已过期查询参数; 0 代表未过期有效的优惠券
|
|
|
userCoupon.setNoVerificationVerFlag("0"); //SQL 条件判断 查询没有异业券的参数标识: 0代表只有加油券 1代表只有异业券
|
|
|
userCoupon.setCurrentTime(new Date());
|
|
|
+ userCoupon.setOilName(p.getOilName());
|
|
|
userCouponsList = couponService.selectUserCoupons(userCoupon);
|
|
|
//循环计算优惠券金额 并排序
|
|
|
if(userCouponsList !=null && userCouponsList.size()>0){
|
|
@@ -1506,6 +1522,7 @@ public class PayOrderController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ uc.setCouponNo("");
|
|
|
uc.setCouponReckonAmt(couponReckonAmt);
|
|
|
}
|
|
|
}
|
|
@@ -1533,22 +1550,26 @@ public class PayOrderController {
|
|
|
String discountPrice = c.getDiscountPrice();
|
|
|
BigDecimal couponAmt = uc.getCouponAmt();
|
|
|
String receivableAmt = p.getReceivableAmt();
|
|
|
+ String dzkDiscountPrice = p.getDzkDiscountPrice();
|
|
|
|
|
|
BigDecimal dzkAmtNew = new BigDecimal(dzkAmt);
|
|
|
BigDecimal amtNew = new BigDecimal(amt);
|
|
|
BigDecimal discountPriceNew = new BigDecimal(discountPrice);
|
|
|
BigDecimal discountAmtNew = new BigDecimal(discountAmt);
|
|
|
BigDecimal dzkDiscountAmtNew = new BigDecimal(dzkDiscountAmt);
|
|
|
+ BigDecimal dzkDiscountPriceNew = new BigDecimal(dzkDiscountPrice);
|
|
|
|
|
|
- //根据优惠券类型计算金额
|
|
|
+ //根据优惠券类型计算金额
|
|
|
switch (uc.getCouponType()){
|
|
|
case "1": //现金券
|
|
|
if(p.getAllDiscountType().equals("1")){
|
|
|
//表示等级
|
|
|
if(uc.getIsGradeFlag().equals("1")){
|
|
|
amtNew = new BigDecimal(amt).subtract(couponAmt);
|
|
|
- amtNew = amtNew.signum() == -1 ? new BigDecimal("0.01") : amtNew;
|
|
|
- discountPriceNew = amtNew.divide(new BigDecimal(oilLiters), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ amtNew = amtNew.signum() == -1 ? new BigDecimal("0.01") : amtNew.setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ if(!oilLiters.equals("0.00")){
|
|
|
+ discountPriceNew = amtNew.divide(new BigDecimal(oilLiters), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
couponReckonAmt.setDiscountPrice(discountPriceNew.toString());
|
|
|
discountAmtNew = discountAmtNew.add(couponAmt);
|
|
|
couponReckonAmt.setDiscountAmt(discountAmtNew.toString());
|
|
@@ -1560,24 +1581,30 @@ public class PayOrderController {
|
|
|
if(uc.getIsMarketFlag().equals("1")){
|
|
|
//优惠券后的优惠金额
|
|
|
amtNew = new BigDecimal(amt).subtract(couponAmt);
|
|
|
- amtNew = amtNew.signum() == -1 ? new BigDecimal("0.01") : amtNew;
|
|
|
+ amtNew = amtNew.signum() == -1 ? new BigDecimal("0.01") : amtNew.setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
//优惠券后的优惠价格
|
|
|
- discountPriceNew = amtNew.divide(new BigDecimal(oilLiters), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ if(!oilLiters.equals("0.00")){
|
|
|
+ discountPriceNew = amtNew.divide(new BigDecimal(oilLiters), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
discountAmtNew = discountAmtNew.add(couponAmt);
|
|
|
couponReckonAmt.setDiscountAmt(discountAmtNew.toString());
|
|
|
couponReckonAmt.setDiscountPrice(discountPriceNew.toString());
|
|
|
couponReckonAmt.setAmt(amtNew.toString());
|
|
|
}
|
|
|
}
|
|
|
- if(uc.getIsCardFlag().equals("1")){
|
|
|
- //与电子卡共享
|
|
|
- dzkAmtNew = new BigDecimal(dzkAmt).subtract(couponAmt);
|
|
|
- dzkAmtNew = dzkAmtNew.signum() == -1 ? new BigDecimal("0.01") : dzkAmtNew;
|
|
|
- discountPriceNew = dzkAmtNew.divide(new BigDecimal(oilLiters), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- dzkDiscountAmtNew = dzkDiscountAmtNew.add(couponAmt);
|
|
|
- couponReckonAmt.setDzkDiscountAmt(dzkDiscountAmtNew.toString());
|
|
|
- couponReckonAmt.setDiscountPrice(discountPriceNew.toString());
|
|
|
- couponReckonAmt.setDzkAmt(dzkAmtNew.toString());
|
|
|
+ if(p.getCardEnabledFlag().equals("1")){
|
|
|
+ if(uc.getIsCardFlag().equals("1")){
|
|
|
+ //与电子卡共享
|
|
|
+ dzkAmtNew = new BigDecimal(dzkAmt).subtract(couponAmt);
|
|
|
+ dzkAmtNew = dzkAmtNew.signum() == -1 ? new BigDecimal("0.01") : dzkAmtNew.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ dzkDiscountAmtNew = dzkDiscountAmtNew.add(couponAmt);
|
|
|
+ couponReckonAmt.setDzkDiscountAmt(dzkDiscountAmtNew.toString());
|
|
|
+ couponReckonAmt.setDzkAmt(dzkAmtNew.toString());
|
|
|
+ if(!oilLiters.equals("0.00")){
|
|
|
+ dzkDiscountPriceNew = dzkAmtNew.divide(new BigDecimal(oilLiters), 2 ,BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ couponReckonAmt.setDzkDiscountPrice(dzkDiscountPriceNew.toString());
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
case "2": //折扣券
|
|
@@ -1586,8 +1613,10 @@ public class PayOrderController {
|
|
|
if(uc.getIsGradeFlag().equals("1")){
|
|
|
//表示与等级共享
|
|
|
amtNew = new BigDecimal(amt).multiply(couponAmt).divide(new BigDecimal("100"));
|
|
|
- amtNew = amtNew.signum() == -1 ? new BigDecimal("0.01") : amtNew;
|
|
|
- discountPriceNew = amtNew.divide(new BigDecimal(oilLiters), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ amtNew = amtNew.signum() == -1 ? new BigDecimal("0.01") : amtNew.setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ if(!oilLiters.equals("0.00")){
|
|
|
+ discountPriceNew = amtNew.divide(new BigDecimal(oilLiters), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
discountAmtNew = new BigDecimal(receivableAmt).subtract(amtNew);
|
|
|
couponReckonAmt.setDiscountAmt(discountAmtNew.toString());
|
|
|
couponReckonAmt.setDiscountPrice(discountPriceNew.toString());
|
|
@@ -1600,26 +1629,31 @@ public class PayOrderController {
|
|
|
if(uc.getIsMarketFlag().equals("1")){
|
|
|
//优惠券后的优惠金额
|
|
|
amtNew = new BigDecimal(amt).multiply(couponAmt).divide(new BigDecimal("100"));
|
|
|
- amtNew = amtNew.signum() == -1 ? new BigDecimal("0.01") : amtNew;
|
|
|
+ amtNew = amtNew.signum() == -1 ? new BigDecimal("0.01") : amtNew.setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
//优惠券后的优惠价格
|
|
|
- discountPriceNew = amtNew.divide(new BigDecimal(oilLiters), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ if(!oilLiters.equals("0.00")){
|
|
|
+ discountPriceNew = amtNew.divide(new BigDecimal(oilLiters), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
discountAmtNew = new BigDecimal(receivableAmt).subtract(amtNew);
|
|
|
couponReckonAmt.setDiscountAmt(discountAmtNew.toString());
|
|
|
couponReckonAmt.setDiscountPrice(discountPriceNew.toString());
|
|
|
couponReckonAmt.setAmt(amtNew.toString());
|
|
|
}
|
|
|
}
|
|
|
- if(uc.getIsCardFlag().equals("1")){
|
|
|
- //与电子卡共享
|
|
|
- dzkAmtNew = new BigDecimal(dzkAmt).multiply(couponAmt).divide(new BigDecimal("100"));
|
|
|
- dzkAmtNew = dzkAmtNew.signum() == -1 ? new BigDecimal("0.01") : dzkAmtNew;
|
|
|
- discountPriceNew = dzkAmtNew.divide(new BigDecimal(oilLiters), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- dzkDiscountAmtNew = new BigDecimal(receivableAmt).subtract(dzkAmtNew);
|
|
|
- couponReckonAmt.setDzkDiscountAmt(dzkDiscountAmtNew.toString());
|
|
|
- couponReckonAmt.setDiscountPrice(discountPriceNew.toString());
|
|
|
- couponReckonAmt.setDzkAmt(dzkAmtNew.toString());
|
|
|
+ if(p.getCardEnabledFlag().equals("1")){
|
|
|
+ if(uc.getIsCardFlag().equals("1")){
|
|
|
+ //与电子卡共享
|
|
|
+ dzkAmtNew = new BigDecimal(dzkAmt).multiply(couponAmt).divide(new BigDecimal("100"));
|
|
|
+ dzkAmtNew = dzkAmtNew.signum() == -1 ? new BigDecimal("0.01") : dzkAmtNew.setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ dzkDiscountAmtNew = new BigDecimal(receivableAmt).subtract(dzkAmtNew);
|
|
|
+ couponReckonAmt.setDzkDiscountAmt(dzkDiscountAmtNew.toString());
|
|
|
+ couponReckonAmt.setDzkAmt(dzkAmtNew.toString());
|
|
|
+ if(!oilLiters.equals("0.00")){
|
|
|
+ dzkDiscountPriceNew = dzkAmtNew.divide(new BigDecimal(oilLiters), 2 ,BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ couponReckonAmt.setDzkDiscountPrice(dzkDiscountPriceNew.toString());
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
break;
|
|
|
}
|
|
|
return couponReckonAmt;
|
|
@@ -1628,26 +1662,26 @@ public class PayOrderController {
|
|
|
|
|
|
|
|
|
//获取客户所拥有的优惠券
|
|
|
- public List<UserCoupon> getUserCoupon(String unionId, Integer stationId){
|
|
|
- List<UserCoupon> userCouponsList = new ArrayList<>();
|
|
|
- StationInfo stationInfo = new StationInfo();
|
|
|
- stationInfo.setStationId(stationId);
|
|
|
- StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
|
|
|
- if(stationInfos !=null && stationInfos.getCouponEnabledFlag() !=null && stationInfos.getCouponEnabledFlag().equals("1")){
|
|
|
- UserCoupon userCoupon = new UserCoupon();
|
|
|
- userCoupon.setStationId(stationId);
|
|
|
- if(stationInfos.getCouponFlag() !=null && stationInfos.getCouponFlag().equals("1")){
|
|
|
- userCoupon.setStationId(stationInfos.getGroupId());
|
|
|
- }
|
|
|
- userCoupon.setUnionId(unionId);
|
|
|
- userCoupon.setCouponIsUsed("0");
|
|
|
- userCoupon.setExpireFlag("0"); // SQL 条件判断 过期标志: 1 代表使用的优惠券已过期查询参数; 0 代表未过期有效的优惠券
|
|
|
- userCoupon.setNoVerificationVerFlag("0"); //SQL 条件判断 查询没有异业券的参数标识: 0代表只有加油券 1代表只有异业券
|
|
|
- userCoupon.setCurrentTime(new Date());
|
|
|
- userCouponsList = couponService.selectUserCoupons(userCoupon);
|
|
|
- }
|
|
|
- return userCouponsList;
|
|
|
- }
|
|
|
+// public List<UserCoupon> getUserCoupon(String unionId, Integer stationId){
|
|
|
+// List<UserCoupon> userCouponsList = new ArrayList<>();
|
|
|
+// StationInfo stationInfo = new StationInfo();
|
|
|
+// stationInfo.setStationId(stationId);
|
|
|
+// StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
|
|
|
+// if(stationInfos !=null && stationInfos.getCouponEnabledFlag() !=null && stationInfos.getCouponEnabledFlag().equals("1")){
|
|
|
+// UserCoupon userCoupon = new UserCoupon();
|
|
|
+// userCoupon.setStationId(stationId);
|
|
|
+// if(stationInfos.getCouponFlag() !=null && stationInfos.getCouponFlag().equals("1")){
|
|
|
+// userCoupon.setStationId(stationInfos.getGroupId());
|
|
|
+// }
|
|
|
+// userCoupon.setUnionId(unionId);
|
|
|
+// userCoupon.setCouponIsUsed("0");
|
|
|
+// userCoupon.setExpireFlag("0"); // SQL 条件判断 过期标志: 1 代表使用的优惠券已过期查询参数; 0 代表未过期有效的优惠券
|
|
|
+// userCoupon.setNoVerificationVerFlag("0"); //SQL 条件判断 查询没有异业券的参数标识: 0代表只有加油券 1代表只有异业券
|
|
|
+// userCoupon.setCurrentTime(new Date());
|
|
|
+// userCouponsList = couponService.selectUserCoupons(userCoupon);
|
|
|
+// }
|
|
|
+// return userCouponsList;
|
|
|
+// }
|
|
|
|
|
|
|
|
|
//获取支付后
|
|
@@ -1754,142 +1788,142 @@ public class PayOrderController {
|
|
|
return boo;
|
|
|
}
|
|
|
|
|
|
- /***
|
|
|
- * 计算使用优惠券金额
|
|
|
- * @param ordNo
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/calculateCouponDiscount", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public String calculateCouponDiscount(@RequestParam String ordNo, @RequestParam Integer id){
|
|
|
- Gson gson =new Gson();
|
|
|
- ResultData resultData =null;
|
|
|
- PayOrder payOrder = new PayOrder();
|
|
|
- payOrder.setOrderNo(ordNo);
|
|
|
- Map<String, Object> infoMap = payOrderService.getOrderInfoAndUserInfoByOrderNo(payOrder);
|
|
|
- StationInfo stationInfo = new StationInfo();
|
|
|
- stationInfo.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
|
|
|
- StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
|
|
|
- if(stationInfos !=null && stationInfos.getCouponEnabledFlag().equals("1")){
|
|
|
- Map<String ,Object> resultMap = new HashMap<>(); //返回结果集
|
|
|
- if(infoMap !=null){
|
|
|
- UserCoupon u = new UserCoupon();
|
|
|
- if(id !=null){
|
|
|
- u.setId(id);
|
|
|
- UserCoupon couponInfo = couponService.selectUserCouponInfo(u);
|
|
|
- if(couponInfo !=null){
|
|
|
- String oilName = infoMap.get("oilName").toString();
|
|
|
- String oilNames = couponInfo.getOilName();
|
|
|
- //判断该油品是否能用该张张优惠券
|
|
|
- boolean contains = oilNames.contains(oilName);
|
|
|
- if(contains){
|
|
|
- String status = couponInfo.getStatus();
|
|
|
- //该优惠券是否有效
|
|
|
- if(status !=null && status.equals("1")) {
|
|
|
- PayOrderResultInfo p = new PayOrderResultInfo();
|
|
|
- BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString()); //应收金额
|
|
|
- BigDecimal couponThresholdAmt = couponInfo.getCouponThresholdAmt(); //门槛金额
|
|
|
- p.setReceivableAmt(receivableAmt.toString());
|
|
|
- //判断该订单是否满足该优惠券门槛金额要求
|
|
|
- if(!(receivableAmt.compareTo(couponThresholdAmt) == -1)){
|
|
|
- String isMarketFlag = couponInfo.getIsMarketFlag();
|
|
|
- String isCardFlag = couponInfo.getIsCardFlag();
|
|
|
- String isGradeFlag = couponInfo.getIsGradeFlag();
|
|
|
- BigDecimal amt = new BigDecimal(infoMap.get("amt").toString()); //实收金额
|
|
|
- p.setAmt(amt.toString());
|
|
|
- BigDecimal dzkAmt = new BigDecimal(infoMap.get("dzkAmt").toString()); //电子卡金额
|
|
|
- p.setDzkAmt(dzkAmt.toString());
|
|
|
- BigDecimal oilPrice = new BigDecimal(infoMap.get("oilPirce").toString()); //油品价格
|
|
|
- BigDecimal orderLiters = new BigDecimal(infoMap.get("orderLiters").toString()); //电子卡金额
|
|
|
- p.setOilLiters(orderLiters.toString());
|
|
|
- BigDecimal couponAmt = couponInfo.getCouponAmt(); //优惠券金额:金额 比例值
|
|
|
- String couponType = couponInfo.getCouponType(); //优惠劵类型 1现金劵,2折扣券,3兑换券
|
|
|
- String cardEnabledFlag = stationInfos.getCardEnabledFlag(); //是否开启电子卡
|
|
|
- //计算优惠券优惠后金额
|
|
|
- CalCouponAmtInfo cal = new CalCouponAmtInfo();
|
|
|
- cal.setReceivableAmt(receivableAmt);
|
|
|
- cal.setAmt(amt);
|
|
|
- cal.setCardEnabledFlag(cardEnabledFlag);
|
|
|
- cal.setCouponAmt(couponAmt);
|
|
|
- cal.setCouponType(couponType);
|
|
|
- cal.setDzkAmt(dzkAmt);
|
|
|
- cal.setIsCardFlag(isCardFlag);
|
|
|
- cal.setIsGradeFlag(isGradeFlag);
|
|
|
- cal.setIsMarketFlag(isMarketFlag);
|
|
|
- //使用优惠券时返回结果
|
|
|
- PayOrderResultInfo resultCalCoupon = calCouponAmt(cal);
|
|
|
- //查询优惠券使用时间
|
|
|
- String availableControl = couponInfo.getAvailableControl(); //时间类型选择
|
|
|
- switch (availableControl){
|
|
|
- case "0":
|
|
|
- p.setAmt(resultCalCoupon.getAmt());
|
|
|
- p.setDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getAmt())).toString());
|
|
|
- p.setDzkAmt(resultCalCoupon.getDzkAmt());
|
|
|
- p.setDzkDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getDzkAmt())).toString());
|
|
|
- break;
|
|
|
- case "1":
|
|
|
- boolean activityDay = this.isActivityDay("1", couponInfo.getCycleDays());
|
|
|
- if(activityDay){
|
|
|
- p.setDzkAmt(resultCalCoupon.getDzkAmt());
|
|
|
- p.setDzkDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getDzkAmt())).toString());
|
|
|
- p.setAmt(resultCalCoupon.getAmt());
|
|
|
- p.setDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getAmt())).toString());
|
|
|
- }
|
|
|
- break;
|
|
|
- case "2":
|
|
|
- boolean activityDay2 = this.isActivityDay("2", couponInfo.getCycleDays());
|
|
|
- if(activityDay2){
|
|
|
- p.setDzkAmt(resultCalCoupon.getDzkAmt());
|
|
|
- p.setDzkDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getDzkAmt())).toString());
|
|
|
- p.setAmt(resultCalCoupon.getAmt());
|
|
|
- p.setDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getAmt())).toString());
|
|
|
- }
|
|
|
- break;
|
|
|
- case "3":
|
|
|
- boolean activityDay3 = this.isActivityDay("3", couponInfo.getCycleDays());
|
|
|
- if(activityDay3){
|
|
|
- p.setDzkAmt(resultCalCoupon.getDzkAmt());
|
|
|
- p.setDzkDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getDzkAmt())).toString());
|
|
|
- p.setAmt(resultCalCoupon.getAmt());
|
|
|
- p.setDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getAmt())).toString());
|
|
|
- }
|
|
|
- }
|
|
|
- BigDecimal discountPrice = oilPrice;
|
|
|
- if(!orderLiters.toString().equals("0.00")){
|
|
|
- //.setScale(2, BigDecimal.ROUND_HALF_UP)
|
|
|
- discountPrice = (new BigDecimal(p.getAmt()).divide(orderLiters, 2, BigDecimal.ROUND_HALF_UP));
|
|
|
- }
|
|
|
- resultMap.put("discountPrice", discountPrice.toString());
|
|
|
- resultMap.put("discountAmt", p.getDiscountAmt()); //优惠金额
|
|
|
- resultMap.put("amt", p.getAmt()); //实收价格
|
|
|
- resultMap.put("receivableAmt", p.getReceivableAmt()); //应收价格
|
|
|
- resultMap.put("oilLiters", p.getOilLiters());
|
|
|
- resultMap.put("amt_dzk", p.getDzkAmt());
|
|
|
- resultMap.put("discountAmt_dzk", p.getDzkDiscountAmt()); //电子卡优惠金额
|
|
|
- resultMap.put("ordNo", ordNo);
|
|
|
- resultData = ResultData.success(resultMap);
|
|
|
- }else{
|
|
|
- resultData = ResultData.error(CodeMsg.COUPON_NOT_COUPONTHRESHOLDAMT);
|
|
|
- }
|
|
|
- }else {
|
|
|
- resultData = ResultData.error(CodeMsg.COUPON_LOSE_EFFECTIVE);
|
|
|
- }
|
|
|
- }else {
|
|
|
- resultData = ResultData.error(CodeMsg.COUPON_NOT_CONTATINS_OILNAME);
|
|
|
- }
|
|
|
- }else {
|
|
|
- resultData = ResultData.error(CodeMsg.NO_COUPON);
|
|
|
- }
|
|
|
- }
|
|
|
- }else {
|
|
|
- resultData = ResultData.error(CodeMsg.NO_ORDER);
|
|
|
- }
|
|
|
- }else {
|
|
|
- resultData = ResultData.error(CodeMsg.NO_ENABLE_COUPON);
|
|
|
- }
|
|
|
- return gson.toJson(resultData);
|
|
|
- }
|
|
|
+// /***
|
|
|
+// * 计算使用优惠券金额
|
|
|
+// * @param ordNo
|
|
|
+// * @param id
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// @RequestMapping(value = "/calculateCouponDiscount", method = RequestMethod.GET)
|
|
|
+// @ResponseBody
|
|
|
+// public String calculateCouponDiscount(@RequestParam String ordNo, @RequestParam Integer id){
|
|
|
+// Gson gson =new Gson();
|
|
|
+// ResultData resultData =null;
|
|
|
+// PayOrder payOrder = new PayOrder();
|
|
|
+// payOrder.setOrderNo(ordNo);
|
|
|
+// Map<String, Object> infoMap = payOrderService.getOrderInfoAndUserInfoByOrderNo(payOrder);
|
|
|
+// StationInfo stationInfo = new StationInfo();
|
|
|
+// stationInfo.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
|
|
|
+// StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
|
|
|
+// if(stationInfos !=null && stationInfos.getCouponEnabledFlag().equals("1")){
|
|
|
+// Map<String ,Object> resultMap = new HashMap<>(); //返回结果集
|
|
|
+// if(infoMap !=null){
|
|
|
+// UserCoupon u = new UserCoupon();
|
|
|
+// if(id !=null){
|
|
|
+// u.setId(id);
|
|
|
+// UserCoupon couponInfo = couponService.selectUserCouponInfo(u);
|
|
|
+// if(couponInfo !=null){
|
|
|
+// String oilName = infoMap.get("oilName").toString();
|
|
|
+// String oilNames = couponInfo.getOilName();
|
|
|
+// //判断该油品是否能用该张张优惠券
|
|
|
+// boolean contains = oilNames.contains(oilName);
|
|
|
+// if(contains){
|
|
|
+// String status = couponInfo.getStatus();
|
|
|
+// //该优惠券是否有效
|
|
|
+// if(status !=null && status.equals("1")) {
|
|
|
+// PayOrderResultInfo p = new PayOrderResultInfo();
|
|
|
+// BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString()); //应收金额
|
|
|
+// BigDecimal couponThresholdAmt = couponInfo.getCouponThresholdAmt(); //门槛金额
|
|
|
+// p.setReceivableAmt(receivableAmt.toString());
|
|
|
+// //判断该订单是否满足该优惠券门槛金额要求
|
|
|
+// if(!(receivableAmt.compareTo(couponThresholdAmt) == -1)){
|
|
|
+// String isMarketFlag = couponInfo.getIsMarketFlag();
|
|
|
+// String isCardFlag = couponInfo.getIsCardFlag();
|
|
|
+// String isGradeFlag = couponInfo.getIsGradeFlag();
|
|
|
+// BigDecimal amt = new BigDecimal(infoMap.get("amt").toString()); //实收金额
|
|
|
+// p.setAmt(amt.toString());
|
|
|
+// BigDecimal dzkAmt = new BigDecimal(infoMap.get("dzkAmt").toString()); //电子卡金额
|
|
|
+// p.setDzkAmt(dzkAmt.toString());
|
|
|
+// BigDecimal oilPrice = new BigDecimal(infoMap.get("oilPirce").toString()); //油品价格
|
|
|
+// BigDecimal orderLiters = new BigDecimal(infoMap.get("orderLiters").toString()); //电子卡金额
|
|
|
+// p.setOilLiters(orderLiters.toString());
|
|
|
+// BigDecimal couponAmt = couponInfo.getCouponAmt(); //优惠券金额:金额 比例值
|
|
|
+// String couponType = couponInfo.getCouponType(); //优惠劵类型 1现金劵,2折扣券,3兑换券
|
|
|
+// String cardEnabledFlag = stationInfos.getCardEnabledFlag(); //是否开启电子卡
|
|
|
+// //计算优惠券优惠后金额
|
|
|
+// CalCouponAmtInfo cal = new CalCouponAmtInfo();
|
|
|
+// cal.setReceivableAmt(receivableAmt);
|
|
|
+// cal.setAmt(amt);
|
|
|
+// cal.setCardEnabledFlag(cardEnabledFlag);
|
|
|
+// cal.setCouponAmt(couponAmt);
|
|
|
+// cal.setCouponType(couponType);
|
|
|
+// cal.setDzkAmt(dzkAmt);
|
|
|
+// cal.setIsCardFlag(isCardFlag);
|
|
|
+// cal.setIsGradeFlag(isGradeFlag);
|
|
|
+// cal.setIsMarketFlag(isMarketFlag);
|
|
|
+// //使用优惠券时返回结果
|
|
|
+// PayOrderResultInfo resultCalCoupon = calCouponAmt(cal);
|
|
|
+// //查询优惠券使用时间
|
|
|
+// String availableControl = couponInfo.getAvailableControl(); //时间类型选择
|
|
|
+// switch (availableControl){
|
|
|
+// case "0":
|
|
|
+// p.setAmt(resultCalCoupon.getAmt());
|
|
|
+// p.setDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getAmt())).toString());
|
|
|
+// p.setDzkAmt(resultCalCoupon.getDzkAmt());
|
|
|
+// p.setDzkDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getDzkAmt())).toString());
|
|
|
+// break;
|
|
|
+// case "1":
|
|
|
+// boolean activityDay = this.isActivityDay("1", couponInfo.getCycleDays());
|
|
|
+// if(activityDay){
|
|
|
+// p.setDzkAmt(resultCalCoupon.getDzkAmt());
|
|
|
+// p.setDzkDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getDzkAmt())).toString());
|
|
|
+// p.setAmt(resultCalCoupon.getAmt());
|
|
|
+// p.setDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getAmt())).toString());
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// case "2":
|
|
|
+// boolean activityDay2 = this.isActivityDay("2", couponInfo.getCycleDays());
|
|
|
+// if(activityDay2){
|
|
|
+// p.setDzkAmt(resultCalCoupon.getDzkAmt());
|
|
|
+// p.setDzkDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getDzkAmt())).toString());
|
|
|
+// p.setAmt(resultCalCoupon.getAmt());
|
|
|
+// p.setDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getAmt())).toString());
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// case "3":
|
|
|
+// boolean activityDay3 = this.isActivityDay("3", couponInfo.getCycleDays());
|
|
|
+// if(activityDay3){
|
|
|
+// p.setDzkAmt(resultCalCoupon.getDzkAmt());
|
|
|
+// p.setDzkDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getDzkAmt())).toString());
|
|
|
+// p.setAmt(resultCalCoupon.getAmt());
|
|
|
+// p.setDiscountAmt(receivableAmt.subtract(new BigDecimal(resultCalCoupon.getAmt())).toString());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// BigDecimal discountPrice = oilPrice;
|
|
|
+// if(!orderLiters.toString().equals("0.00")){
|
|
|
+// //.setScale(2, BigDecimal.ROUND_HALF_UP)
|
|
|
+// discountPrice = (new BigDecimal(p.getAmt()).divide(orderLiters, 2, BigDecimal.ROUND_HALF_UP));
|
|
|
+// }
|
|
|
+// resultMap.put("discountPrice", discountPrice.toString());
|
|
|
+// resultMap.put("discountAmt", p.getDiscountAmt()); //优惠金额
|
|
|
+// resultMap.put("amt", p.getAmt()); //实收价格
|
|
|
+// resultMap.put("receivableAmt", p.getReceivableAmt()); //应收价格
|
|
|
+// resultMap.put("oilLiters", p.getOilLiters());
|
|
|
+// resultMap.put("amt_dzk", p.getDzkAmt());
|
|
|
+// resultMap.put("discountAmt_dzk", p.getDzkDiscountAmt()); //电子卡优惠金额
|
|
|
+// resultMap.put("ordNo", ordNo);
|
|
|
+// resultData = ResultData.success(resultMap);
|
|
|
+// }else{
|
|
|
+// resultData = ResultData.error(CodeMsg.COUPON_NOT_COUPONTHRESHOLDAMT);
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// resultData = ResultData.error(CodeMsg.COUPON_LOSE_EFFECTIVE);
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// resultData = ResultData.error(CodeMsg.COUPON_NOT_CONTATINS_OILNAME);
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// resultData = ResultData.error(CodeMsg.NO_COUPON);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// resultData = ResultData.error(CodeMsg.NO_ORDER);
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// resultData = ResultData.error(CodeMsg.NO_ENABLE_COUPON);
|
|
|
+// }
|
|
|
+// return gson.toJson(resultData);
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|