|
@@ -164,8 +164,10 @@ public class OrderHandler {
|
|
|
// 判断当前提交的购物车ID,有多少产品在售
|
|
|
int total = 0; // 支付金额
|
|
|
int sum = 0; // 产品数量
|
|
|
- boolean disable = false; //标识,是否可以使用(新人券)优惠券,当购买商品需要有牙刷时才能使用优惠券
|
|
|
+ boolean disable = false; //标识,是否可以使用(新人券)优惠券,当购买商品需要有牙刷时才能使用优惠券 - 20180316 以前
|
|
|
+ boolean brushFlag = false; //标识,是否可以使用(新人券)优惠券,只能购买刷头的时候才能使用 - 20180316 以后
|
|
|
String element = systemService.selectOneShopRuleById(249).getRuleDesc();
|
|
|
+ String brushelEment = systemService.selectOneShopRuleById(253).getRuleDesc();
|
|
|
|
|
|
List<CartDto> tempCarts = new ArrayList<CartDto>();
|
|
|
for (CartDto cartDto : cartDtos) {
|
|
@@ -183,6 +185,13 @@ public class OrderHandler {
|
|
|
disable = true;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ String[] brushelEls = brushelEment.split("-");
|
|
|
+ for(String brushelEl : brushelEls){
|
|
|
+ if(cartDto.getProductType() == Integer.valueOf(brushelEl)){ //判断订单中是否有刷头,有刷头 brushFlag 为true;
|
|
|
+ brushFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if (sum <= 0) {
|
|
|
msg.setMessage(ResultInfo.cartEmptyError);
|
|
@@ -205,8 +214,8 @@ public class OrderHandler {
|
|
|
if(total >= couponItemDto.getCouponConsumeEnough()){
|
|
|
|
|
|
/*新人卷没有其他限制*/
|
|
|
- if(couponItemDto.getCouponIsNewPeople() == 1 && member.getUserIdentity() != 1){ //当券为新人券,用户为非会员时,需要有牙刷,结算才可以使用该券
|
|
|
- if(!disable){ //订单中没有牙刷
|
|
|
+ if(couponItemDto.getCouponIsNewPeople() == 1){ //当券为新人券
|
|
|
+ if(member.getUserIdentity() != 1 || !brushFlag){ //不为会员,或者没有牙刷刷头都无法使用
|
|
|
flag = false;
|
|
|
}
|
|
|
}else if(couponItemDto.getCouponIsPurchase() == 1){ ///*控制是否需要购买的有牙刷*/
|
|
@@ -332,6 +341,11 @@ public class OrderHandler {
|
|
|
|
|
|
/*是否含有电动牙刷*/
|
|
|
boolean isContainProduct = false;
|
|
|
+ boolean brushFlag = false; //标识,是否可以使用(新人券)优惠券,只能购买刷头的时候才能使用 - 20180316 以后
|
|
|
+// String element = systemService.selectOneShopRuleById(249).getRuleDesc();
|
|
|
+ String brushelEment = systemService.selectOneShopRuleById(253).getRuleDesc();
|
|
|
+
|
|
|
+ int brushelTotal = 0; // 牙刷总金额
|
|
|
|
|
|
int total = 0; // 需要支付的总额, 单位为分
|
|
|
/** 提前准备订单项数据 */
|
|
@@ -358,13 +372,24 @@ public class OrderHandler {
|
|
|
item.setItemProductPrice(cartDto.getProductDiscount());
|
|
|
item.setItemColorId(cartDto.getCartColorId());
|
|
|
list.add(item);
|
|
|
+
|
|
|
+
|
|
|
+ if(cartDto.getProductType() == 100){ //当订单中有电动牙刷时,isContainProduct为true
|
|
|
+ isContainProduct = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] brushelEls = brushelEment.split("-");
|
|
|
+ for(String brushelEl : brushelEls){
|
|
|
+ if(cartDto.getProductType() == Integer.valueOf(brushelEl)){ //判断订单中是否有刷头,有刷头 brushFlag 为true;
|
|
|
+ brushFlag = true;
|
|
|
+ brushelTotal += subTotal;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}else if(cartDto.getProductStatus().intValue() != 1){
|
|
|
msg.setMessage(ResultInfo.cartNoStatusError);
|
|
|
return msg;
|
|
|
}
|
|
|
- if(cartDto.getProductType() == 100){ //当订单中有电动牙刷时,isContainProduct为true
|
|
|
- isContainProduct = true;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
// 准备订单对象
|
|
@@ -404,22 +429,32 @@ public class OrderHandler {
|
|
|
msg.setMessage(ResultInfo.COUPON_CONSUME_NO_ENOUGH); //消费额度不足
|
|
|
return msg;
|
|
|
}
|
|
|
- if(member.getUserIdentity() != 1){ //判断该用户是否为会员
|
|
|
- if(couponItem.getCouponIsNewPeople() == 1 && !isContainProduct){
|
|
|
+
|
|
|
+ /*新人卷没有其他限制*/
|
|
|
+ if(couponItemDto.getCouponIsNewPeople() == 1){ //当券为新人券
|
|
|
+ if(member.getUserIdentity() != 1 || !brushFlag){ //不为会员,或者没有牙刷刷头都无法使用
|
|
|
msg.setMessage(ResultInfo.COUPON_NO_MEMBER); //非会员需要购买电动牙刷才能使用该优惠券
|
|
|
return msg;
|
|
|
}
|
|
|
- }
|
|
|
- /*判断优惠券是否购买牙刷必须优惠券,与新人卷 分开*/
|
|
|
- if(couponType.getCouponIsPurchase() == 1){
|
|
|
+ }else if(couponType.getCouponIsPurchase() == 1){/*判断优惠券是否购买牙刷必须优惠券,与新人卷 分开*/
|
|
|
if(!isContainProduct){
|
|
|
- msg.setMessage(ResultInfo.COUPON_NO_TOOTH); //非会员需要购买电动牙刷才能使用该优惠券
|
|
|
+ msg.setMessage(ResultInfo.COUPON_NO_TOOTH); //100元现金券
|
|
|
return msg;
|
|
|
}
|
|
|
}
|
|
|
+ int br = 0;
|
|
|
//优惠券的类型,是直接减免额度 还是折扣价
|
|
|
if(couponType.getCouponType()==1){
|
|
|
- total=total-couponType.getCouponReduce();
|
|
|
+ if(couponItemDto.getCouponIsNewPeople() == 1){ //当券为新人券
|
|
|
+ br = brushelTotal - couponType.getCouponReduce();
|
|
|
+ if(br <= 0){
|
|
|
+ total=total-brushelTotal;
|
|
|
+ }else{
|
|
|
+ total=total-couponType.getCouponReduce();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ total=total-couponType.getCouponReduce();
|
|
|
+ }
|
|
|
}else if(couponType.getCouponType()==2){
|
|
|
Integer all = new Integer(total);
|
|
|
total=total*couponType.getCouponReduce()/100;
|