| 
					
				 | 
			
			
				@@ -56,7 +56,7 @@ public class PayOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public String  AddPayOrderInfoNew(@RequestBody PayOrderRequest payOrderRequest){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         logger.info("生成订单前端传来参数油站ID:"+payOrderRequest.getStationId()+"; 用户openId:"+ payOrderRequest.getOpenId() +"; 加油员ID:" +payOrderRequest.getPersonnelId()+ ";"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Gson gson =new Gson(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Gson gson =new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ResultData resultData =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         AppUserInfo appUserInfo =new AppUserInfo();     //查询客户信息传递参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         PayOrder payOrder = new PayOrder();             //生成订单参数 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -132,7 +132,11 @@ public class PayOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     payOrder.setOilName(oilName);                                                   //油品名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     //该油站是否开启优惠券功能 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    resultMap.put("couponEnabledFlag", stationInfos.getCouponEnabledFlag()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(stationInfos.getCouponEnabledFlag() == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        resultMap.put("couponEnabledFlag", "0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        resultMap.put("couponEnabledFlag", stationInfos.getCouponEnabledFlag()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     //获取用户的优惠券 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if(stationInfos.getCouponEnabledFlag() !=null && stationInfos.getCouponEnabledFlag().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         Integer stationId = payOrderRequest.getStationId(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1484,71 +1488,115 @@ public class PayOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         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){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Coupon coupon = new Coupon(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                coupon.setId(couponId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Coupon couponInfo = couponService.selectCouponInfo(coupon); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(couponInfo !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    String status = couponInfo.getStatus(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //该优惠券是否有效 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if(status !=null && status.equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        String isMarketFlag = coupon.getIsMarketFlag(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        String isCardFlag = coupon.getIsCardFlag(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        String isGradeFlag = coupon.getIsGradeFlag(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        PayOrder p = new PayOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                    BigDecimal receivableAmt = new BigDecimal(payOrder.getReceivableAmt().toString());  //应收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                    BigDecimal amt = new BigDecimal(payOrder.getAmt().toString());                      //实收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                    BigDecimal dzkAmt = new BigDecimal(payOrder.getDzkAmt().toString());                //应收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString());  //应收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        p.setReceivableAmt(receivableAmt.doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        BigDecimal amt = new BigDecimal(infoMap.get("amt").toString());                      //实收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        p.setAmt(amt.doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        BigDecimal dzkAmt = new BigDecimal(infoMap.get("dzkAmt").toString());                //电子卡金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        p.setDzkAmt(dzkAmt.doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        BigDecimal oilPrice = new BigDecimal(infoMap.get("oilPirce").toString());            //油品价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        BigDecimal couponAmt = coupon.getCouponAmt();                                       //优惠券金额:金额 比例值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        String couponType = coupon.getCouponType();                                         //优惠劵类型 1现金劵,2折扣券,3兑换券 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        //计算优惠券优惠后金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        PayOrder resultCalCoupon = calCouponAmt(couponType, receivableAmt, couponAmt, dzkAmt, amt, isCardFlag, isMarketFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        //查询优惠券使用时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        String availableControl = coupon.getAvailableControl(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        switch (availableControl){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            case "0": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                p.setDzkAmt(resultCalCoupon.getDzkAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                p.setAmt(resultCalCoupon.getAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            case "1": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                boolean activityDay = this.isActivityDay("1", coupon.getCycleDays()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if(activityDay){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    p.setDzkAmt(resultCalCoupon.getDzkAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    p.setAmt(resultCalCoupon.getAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            case "2": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                boolean activityDay2 = this.isActivityDay("2", coupon.getCycleDays()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if(activityDay2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    p.setDzkAmt(resultCalCoupon.getDzkAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    p.setAmt(resultCalCoupon.getAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            case "3": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                boolean activityDay3 = this.isActivityDay("3", coupon.getCycleDays()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if(activityDay3){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    p.setDzkAmt(resultCalCoupon.getDzkAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    p.setAmt(resultCalCoupon.getAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(couponId !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    coupon.setId(couponId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Coupon couponInfo = couponService.selectCouponInfo(coupon); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        resultData = ResultData.success(p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        resultData = ResultData.error(CodeMsg.COUPON_LOSE_EFFECTIVE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        resultData = ResultData.error(CodeMsg.NO_COUPON); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    resultData = ResultData.error(CodeMsg.NO_COUPON); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 resultData = ResultData.error(CodeMsg.NO_ORDER); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1559,48 +1607,66 @@ public class PayOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return gson.toJson(resultData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     //计算优惠券金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public PayOrder calCouponAmt(String couponType, BigDecimal receivableAmt, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                 BigDecimal couponAmt, BigDecimal dzkAmt, BigDecimal amt, String isCardFlag, String isMarketFlag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        PayOrder p = new PayOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        switch (couponType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public PayOrderResultInfo calCouponAmt(CalCouponAmtInfo calCouponAmtInfo){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        PayOrderResultInfo p = new PayOrderResultInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal receivableAmt = calCouponAmtInfo.getReceivableAmt();         // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal amt = calCouponAmtInfo.getAmt(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal couponAmt = calCouponAmtInfo.getCouponAmt();                 //优惠券优惠值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal dzkAmt = calCouponAmtInfo.getDzkAmt();                       //优惠券电子卡金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String cardEnabledFlag = calCouponAmtInfo.getCardEnabledFlag();         //是否开启电子卡 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        switch (calCouponAmtInfo.getCouponType()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             case "1": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //现金券 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //与营销方案,电子卡互斥 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 BigDecimal subtract = receivableAmt.subtract(couponAmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 subtract = subtract.signum() == -1 ? new BigDecimal("0.01") : subtract; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                p.setAmt(subtract.doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                p.setDzkAmt(subtract.doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //是否与电子卡叠加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (isCardFlag.equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    BigDecimal dzkAmtSub = dzkAmt.subtract(couponAmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    dzkAmtSub = dzkAmtSub.signum() == -1 ? new BigDecimal("0.01") : dzkAmtSub; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    p.setDzkAmt(dzkAmtSub.doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                p.setAmt(subtract.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //是否开启电子卡 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(cardEnabledFlag.equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    p.setDzkAmt(subtract.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //是否与电子卡叠加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (calCouponAmtInfo.getIsCardFlag().equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        BigDecimal dzkAmtSub = dzkAmt.subtract(couponAmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        dzkAmtSub = dzkAmtSub.signum() == -1 ? new BigDecimal("0.01") : dzkAmtSub; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        p.setDzkAmt(dzkAmtSub.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //是否与营销方案叠加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (isMarketFlag.equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    BigDecimal marketSub = amt.subtract(couponAmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (calCouponAmtInfo.getIsMarketFlag().equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    BigDecimal marketSub = amt.subtract(calCouponAmtInfo.getCouponAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     marketSub = marketSub.signum() == -1 ? new BigDecimal("0.01") : marketSub; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    p.setAmt(marketSub.doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    p.setAmt(marketSub.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //是否与等级叠加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(calCouponAmtInfo.getIsGradeFlag().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             case "2": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //折扣券 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                BigDecimal multiply = receivableAmt.multiply(couponAmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                BigDecimal multiply = calCouponAmtInfo.getReceivableAmt().multiply(calCouponAmtInfo.getCouponAmt()).divide(new BigDecimal("100")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 multiply = receivableAmt.subtract(multiply).setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                p.setAmt(multiply.doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                p.setDzkAmt(multiply.doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //是否与电子卡叠加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (isCardFlag.equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    BigDecimal multiplyCard = dzkAmt.multiply(couponAmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    multiplyCard = dzkAmt.subtract(multiplyCard).setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    p.setDzkAmt(multiplyCard.doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                p.setAmt(multiply.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(cardEnabledFlag.equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    p.setDzkAmt(multiply.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //是否与电子卡叠加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (calCouponAmtInfo.getIsCardFlag().equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        BigDecimal multiplyCard = dzkAmt.multiply(couponAmt).divide(new BigDecimal("100")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        multiplyCard = dzkAmt.subtract(multiplyCard).setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        p.setDzkAmt(multiplyCard.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //是否与营销方案叠加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (isMarketFlag.equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    BigDecimal multiplyMarket = amt.multiply(couponAmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (calCouponAmtInfo.getIsMarketFlag().equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    BigDecimal multiplyMarket = amt.multiply(couponAmt).divide(new BigDecimal("100")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     multiplyMarket = amt.subtract(multiplyMarket).setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    p.setAmt(multiplyMarket.doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    p.setAmt(multiplyMarket.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1608,6 +1674,21 @@ public class PayOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /*** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 计算使用优惠券金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param ordNo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param couponId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @RequestMapping(value = "/updateOrderCoupon", method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public String updateOrderCoupon(@RequestParam String ordNo, @RequestParam Integer couponId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Gson gson =new Gson(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ResultData resultData =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return  gson.toJson(resultData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 根据订单号获取订单信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * produces="application/json;charset=UTF-8",consumes = "application/json", 
			 |