Explorar el Código

优惠券恢复

wangxiaoming hace 7 años
padre
commit
994485a54e

+ 1 - 1
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/coupon/CouponTypeHandler.java

@@ -585,7 +585,7 @@ public class CouponTypeHandler {
 			}
 
 			CouponItem couponItem = new CouponItem();
-			couponItem.setCouponId(couponTypeList.get(0).getCouponId());
+			couponItem.setCouponId(20000);
 			Calendar calendar = Calendar.getInstance();
 			calendar.add(Calendar.YEAR,1);
 			couponItem.setCouponUseEndDate(calendar.getTime());//领取后一年有效

+ 20 - 14
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/order/OrderHandler.java

@@ -179,9 +179,10 @@ public class OrderHandler {
 				msg.setMessage(ResultInfo.cartNoStatusError);
 				return msg;
 			}
+
 			String[] els = element.split("-");
 			for(String el : els){
-				if(cartDto.getProductType() == Integer.valueOf(el)){		//订单中没有牙刷的时候,不能使用新人
+				if(cartDto.getProductType() == Integer.valueOf(el)){		//订单中没有牙刷的时候,不能使用100元优惠
 					disable = true;
 				}
 			}
@@ -192,6 +193,7 @@ public class OrderHandler {
 					brushFlag = true;
 				}
 			}
+
 		}
 		if (sum <= 0) {
 			msg.setMessage(ResultInfo.cartEmptyError);
@@ -341,11 +343,12 @@ public class OrderHandler {
 
 		/*是否含有电动牙刷*/
 		boolean isContainProduct = false;
-		boolean brushFlag = false;	//标识,是否可以使用(新人券)优惠券,只能购买刷头的时候才能使用 - 20180316 以后
+		boolean brush1Flag = false;	//60元优惠券
+		boolean brush2Flag = false;	//刷头兑换券
 //		String element = systemService.selectOneShopRuleById(249).getRuleDesc();
 		String brushelEment = systemService.selectOneShopRuleById(253).getRuleDesc();
 
-//		int brushelTotal = 0; // 牙刷总金额
+		int brushelTotal = 0; // 牙刷总金额
 		int brushelCouponTotal = 0;  //优惠总价
 
 		int total = 0; // 需要支付的总额, 单位为分
@@ -382,8 +385,9 @@ public class OrderHandler {
 				String[] brushelEls = brushelEment.split("-");
 				for(String brushelEl : brushelEls){
 					if(cartDto.getProductType() == Integer.valueOf(brushelEl)){		//判断订单中是否有刷头,有刷头 brushFlag 为true;
-						brushFlag = true;
-//						brushelTotal += subTotal;
+						brush1Flag = true;
+						brush2Flag = true;
+						brushelTotal += subTotal;
 						if(brushelCouponTotal == 0 || brushelCouponTotal < cartDto.getProductPrice()){
 							brushelCouponTotal = cartDto.getProductPrice();
 						}
@@ -436,7 +440,7 @@ public class OrderHandler {
 
 				/*新人卷没有其他限制*/
 			if(couponItemDto.getCouponIsNewPeople() == 1){  //当券为新人券
-				if(member.getUserIdentity() != 1 || !brushFlag){  //不为会员,或者没有牙刷刷头都无法使用
+				if(member.getUserIdentity() != 1 || !brush1Flag || !brush2Flag){  //不为会员,或者没有牙刷刷头都无法使用
 					msg.setMessage(ResultInfo.COUPON_NO_MEMBER); //非会员需要购买电动牙刷才能使用该优惠券
 					return msg;
 				}
@@ -446,17 +450,19 @@ public class OrderHandler {
 					return msg;
 				}
 			}
-//			int br = 0;
+
 			//优惠券的类型,是直接减免额度 还是折扣价
 			if(couponType.getCouponType()==1){
-				if(couponItemDto.getCouponIsNewPeople() == 1){  //当券为新人券
+				if(couponItemDto.getCouponIsNewPeople() == 1 && couponItemDto.getCouponId() == 20000){  //当券 新人卷    刷头抵扣卷
 					total = total - brushelCouponTotal;
-//					br = brushelTotal - couponType.getCouponReduce();
-//					if(br <= 0){
-//						total=total-brushelTotal;
-//					}else{
-//						total=total-couponType.getCouponReduce();
-//					}
+				}else if(couponItemDto.getCouponIsNewPeople() == 1 && couponItemDto.getCouponId() ==40000){			////当券 新人卷    60元优惠券
+					int br = 0;
+					br = brushelTotal - couponType.getCouponReduce();	//刷头总价减去优惠券金额  小于零(只需要减去刷头总价) 大于零(需要减去优惠券总价)
+					if(br <= 0){
+						total=total-brushelTotal;
+					}else{
+						total=total-couponType.getCouponReduce();
+					}
 				}else{
 					total=total-couponType.getCouponReduce();
 				}