瀏覽代碼

99元刷头--优惠券问题

wangxiaoming 6 年之前
父節點
當前提交
e90e1dc50d

+ 1 - 0
tooth-common-tool/src/main/java/com/iamberry/wechat/tools/ResultInfo.java

@@ -313,6 +313,7 @@ public class ResultInfo {
 	public static String COUPON_INVALID="优惠券无效";
 	public static String COUPON_CONSUME_NO_ENOUGH="消费额度不足,优惠券无法使用";
 	public static String COUPON_NO_MEMBER="非会员需要购买电动牙刷刷头才能使用该优惠券";
+	public static String COUPON_YOUHUI="优惠套装无法使用优惠券";
 	public static String COUPON_NO_TOOTH="该现金券需要订单中有电动牙刷才能使用";
 	public static String COUPON_NO_TOOTH_AMOUNT="不满足优惠条件";
 

+ 36 - 9
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/order/OrderHandler.java

@@ -236,8 +236,8 @@ public class OrderHandler {
 		int toothbrushTotal = 0; // 支付金额
 		int sum = 0; // 产品数量
 		boolean disable = false;	//标识,是否可以使用(新人券)优惠券,当购买商品需要有牙刷时才能使用优惠券 - 20180316 以前
-		boolean brushFlag = false;	//标识,是否可以使用(新人券)优惠券,只能购买刷头的时候才能使用 - 20180316 以后
-		boolean combinationOffer = false;	//标识,是否有组合优惠套装,购买组合优惠套装不可使用优惠券 - 20181024
+		Integer brushFlag = 0;	//标识,是否可以使用(新人券)优惠券,只能购买刷头的时候才能使用 - 20180316 以后
+		Integer combinationOffer = 0;	//标识,是否有组合优惠套装,购买组合优惠套装不可使用优惠券 - 20181024
 		String element = systemService.selectOneShopRuleById(249).getRuleDesc();
 		String brushelEment = systemService.selectOneShopRuleById(253).getRuleDesc();
 		String combinationOfferColorIds = systemService.selectOneShopRuleById(259).getRuleDesc();
@@ -259,21 +259,21 @@ public class OrderHandler {
 
 			String[] els = element.split("-");
 			for(String el : els){
-				if(cartDto.getProductType() == Integer.valueOf(el)){		//订单中没有牙刷的时候,不能使用100元优惠券
+				if(cartDto.getProductType().equals(Integer.valueOf(el))){		//订单中没有牙刷的时候,不能使用100元优惠券
 					disable = true;
 					toothbrushTotal += cartDto.getCartNum() * cartDto.getProductPrice();
 				}
 			}
 			String[] brushelEls = brushelEment.split("-");
 			for(String brushelEl : brushelEls){
-				if(cartDto.getProductType() == Integer.valueOf(brushelEl)){		//判断订单中是否有刷头,有刷头 brushFlag 为true
-					brushFlag = true;
+				if(cartDto.getProductType().equals(Integer.valueOf(brushelEl))){		//判断订单中是否有刷头,有刷头 brushFlag 大于0
+					brushFlag += cartDto.getCartNum();
 				}
 			}
 			String[] coColorId = combinationOfferColorIds.split("-");
 			for(String colorId : coColorId){
 				if(cartDto.getCartColorId().equals(Integer.valueOf(colorId))){		//判断订单中是否有优惠组合套装
-					combinationOffer = true;
+					combinationOffer += cartDto.getCartNum();
 				}
 			}
 		}
@@ -298,7 +298,7 @@ public class OrderHandler {
 			if(total >= couponItemDto.getCouponConsumeEnough()){
 				/*新人卷没有其他限制*/
 				if(couponItemDto.getCouponIsNewPeople() == 1){  //当券为新人券
-					if(member.getUserIdentity() != 1 || !brushFlag){  //不为会员,或者没有牙刷刷头都无法使用
+					if(member.getUserIdentity() != 1 || brushFlag<1){  //不为会员,或者没有牙刷刷头都无法使用
 						flag = false;
 					}
 				}else if(couponItemDto.getCouponIsPurchase() == 1){  ///*控制是否需要购买的有牙刷*/
@@ -318,9 +318,12 @@ public class OrderHandler {
 			}
 		}
 		/*插入优惠券*/
-		if(channelType <= 0 && channelId <= 0 && !combinationOffer){
+		if(channelType <= 0 && channelId <= 0 && combinationOffer < 1){
+			dto.setCouponItems(list);
+		}else if(combinationOffer > 0 && brushFlag - combinationOffer > 0 ){
 			dto.setCouponItems(list);
 		}
+
 		dto.setCartId(cartIds);// 购物车ID
 		dto.setPayTotal(total); // 支付金额,单位为分
 		dto.setIsCustomize(isCustomize);//判断是否为定制牙刷
@@ -483,12 +486,17 @@ public class OrderHandler {
 		boolean isContainProduct = false;
 		boolean brush1Flag = false;	//60元优惠券
 		boolean brush2Flag = false;	//刷头兑换券
+		Integer brusHeadNumber = 0;	//刷头个数
+		Integer combinationOffer = 0;// 组合优惠个数
 //		String element = systemService.selectOneShopRuleById(249).getRuleDesc();
 		String brushelEment = systemService.selectOneShopRuleById(253).getRuleDesc();
+		/*优惠套装的颜色id*/
+		String combinationOfferColorIds = systemService.selectOneShopRuleById(259).getRuleDesc();
 
 		int brushelTotal = 0; // 牙刷总金额
 		int brushHeadTotal = 0; // 刷头总金额
 		int brushelCouponTotal = 0;  //优惠总价
+		int combinationOfferTotal = 0;  //组合优惠总价
 
 		boolean isChannelProduct = false;	//没有上朵分销商品
 
@@ -552,14 +560,29 @@ public class OrderHandler {
 
 				String[] brushelEls = brushelEment.split("-");
 				for(String brushelEl : brushelEls){
-					if(cartDto.getProductType().equals(Integer.valueOf(brushelEl))){		//判断订单中是否有刷头,有刷头 brushFlag 为true;
+					if(cartDto.getProductType().equals(Integer.valueOf(brushelEl)) && cartDto.getCartProductId() != 310){		//判断订单中是否有刷头,有刷头 brushFlag 为true;
 						brush1Flag = true;
 						brush2Flag = true;
+						//刷头个数
+						brusHeadNumber += cartDto.getCartNum();
 						brushHeadTotal += subTotal;
 						if(brushelCouponTotal == 0 || brushelCouponTotal < cartDto.getProductPrice()){
 							brushelCouponTotal = cartDto.getProductPrice();
 						}
 					}
+					if(cartDto.getCartProductId() == 310){
+						//刷头个数
+						brusHeadNumber += cartDto.getCartNum();
+						combinationOfferTotal += subTotal;
+					}
+				}
+
+				/*获取优惠套装个数*/
+				String[] coColorId = combinationOfferColorIds.split("-");
+				for(String colorId : coColorId){
+					if(cartDto.getCartColorId().equals(Integer.valueOf(colorId))){		//判断订单中是否有优惠组合套装
+						combinationOffer += cartDto.getCartNum();
+					}
 				}
 			}else if(cartDto.getProductStatus().intValue() != 1){
 				msg.setMessage(ResultInfo.cartNoStatusError);
@@ -622,6 +645,10 @@ public class OrderHandler {
 					msg.setMessage(ResultInfo.COUPON_NO_MEMBER); //非会员需要购买电动牙刷才能使用该优惠券
 					return msg;
 				}
+				if(combinationOffer > 0 && brusHeadNumber - combinationOffer < 1){
+					msg.setMessage(ResultInfo.COUPON_YOUHUI); //非会员需要购买电动牙刷才能使用该优惠券
+					return msg;
+				}
 			}else if(couponType.getCouponIsPurchase() == 1){/*判断优惠券是否购买牙刷必须优惠券,与新人卷 分开*/
 				if(!isContainProduct){
 					msg.setMessage(ResultInfo.COUPON_NO_TOOTH);  //100元现金券