|
@@ -61,6 +61,7 @@ import javax.servlet.ServletException;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
@@ -235,7 +236,7 @@ public class OrderHandler {
|
|
|
}else{
|
|
|
if(activityDate.isStatus()){
|
|
|
/*满减*/
|
|
|
- Integer promotionAmout = fullReduc(activityDate,allAmount);; //促销之后的金额 -- 总金额减去满减,满减的优先级高一些
|
|
|
+ Integer promotionAmout = fullReduc(activityDate,cartDtos);; //促销之后的金额 -- 总金额减去满减,满减的优先级高一些
|
|
|
|
|
|
//满赠
|
|
|
giftCart(cartDtos);
|
|
@@ -515,9 +516,6 @@ public class OrderHandler {
|
|
|
activityDate.setStatus(false);
|
|
|
}else {
|
|
|
if (activityDate.isStatus()) {
|
|
|
- /*满减*/
|
|
|
- Integer promotionAmout = fullReduc(activityDate,allAmount);; //促销之后的金额 -- 总金额减去满减,满减的优先级高一些
|
|
|
-
|
|
|
//满赠
|
|
|
giftCart(cartDtos);
|
|
|
}
|
|
@@ -769,12 +767,9 @@ public class OrderHandler {
|
|
|
|
|
|
//双十二期间,全场满328元减50元,全场满499元减100元,全场满满699元减150元
|
|
|
if (activityDate.isStatus()) {
|
|
|
- for (SalesActivities salesActivities : activityDate.getSalesActivitiesList()){
|
|
|
- if(mustPay >= salesActivities.getSalesActivitiesFull()){
|
|
|
- mustPay = mustPay - salesActivities.getSalesActivitiesReduction();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ /*满减*/
|
|
|
+ Integer promotionAmout = fullReduc(activityDate,cartDtos);
|
|
|
+ mustPay -= promotionAmout;
|
|
|
}
|
|
|
|
|
|
Integer salesPostage = 0;
|
|
@@ -1145,6 +1140,38 @@ public class OrderHandler {
|
|
|
SettlementGift settlementGift = new SettlementGift();
|
|
|
settlementGift.setSettGiftStatus(1);
|
|
|
List<SettlementGift> settlementGiftList = settlementGiftService.getSettlementGiftList(settlementGift);
|
|
|
+
|
|
|
+ //2019年圣诞活动 -开始
|
|
|
+ for (SettlementGift sg:settlementGiftList) {
|
|
|
+ if(sg.getSettGiftId() == 50){
|
|
|
+ Integer nownum = 0;
|
|
|
+ for (CartDto cartDto:cartDtoList) {
|
|
|
+ if(cartDto.getCartColorId() == 60 || cartDto.getCartColorId() == 61 ||
|
|
|
+ cartDto.getCartColorId() == 62 || cartDto.getCartColorId() == 63){ //60,61,62,63
|
|
|
+ nownum += cartDto.getCartNum();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(nownum == 1){
|
|
|
+ CartDto cartDto = new CartDto();
|
|
|
+ cartDto.setCartColorId(361);
|
|
|
+ cartDto.setCartNum(1);
|
|
|
+ cartDto.setProductDiscount(0);
|
|
|
+ cartDto.setProductPrice(0);
|
|
|
+ cartDto.setTotal(0);
|
|
|
+ giftList.add(cartDto);
|
|
|
+ }else if(nownum >= 1){
|
|
|
+ CartDto cartDto = new CartDto();
|
|
|
+ cartDto.setCartColorId(316);
|
|
|
+ cartDto.setCartNum(1);
|
|
|
+ cartDto.setProductDiscount(0);
|
|
|
+ cartDto.setProductPrice(0);
|
|
|
+ cartDto.setTotal(0);
|
|
|
+ giftList.add(cartDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //2019年圣诞活动 - 结束
|
|
|
+
|
|
|
for (CartDto cd:cartDtoList) {
|
|
|
for (SettlementGift sg:settlementGiftList) {
|
|
|
if(Objects.equals(cd.getCartColorId(), sg.getSettGiftFillColorId())){//添加赠送产品
|
|
@@ -1230,18 +1257,42 @@ public class OrderHandler {
|
|
|
* 满减
|
|
|
* @return
|
|
|
*/
|
|
|
- public Integer fullReduc(ActivityDate activityDate, Integer allAmount){
|
|
|
+ public Integer fullReduc(ActivityDate activityDate,List<CartDto> cartDtos){
|
|
|
Integer promotionAmout = 0;
|
|
|
SalesActivities sa = new SalesActivities();
|
|
|
sa.setSalesActivitiesStatus(1);
|
|
|
sa.setSalesActivitiesType(activityDate.getType());
|
|
|
- sa.setSalesActivitiesScenes(1);
|
|
|
List<SalesActivities> salesActivitiesList = salesActivitiesService.getSalesActivitiesList(sa);
|
|
|
activityDate.setSalesActivitiesList(salesActivitiesList);
|
|
|
for (SalesActivities salesActivities : salesActivitiesList){
|
|
|
- if(promotionAmout >= salesActivities.getSalesActivitiesFull()){
|
|
|
- promotionAmout = allAmount - salesActivities.getSalesActivitiesReduction();
|
|
|
- break;
|
|
|
+ if(salesActivities.getSalesActivitiesScenes() == 2){
|
|
|
+
|
|
|
+ if(salesActivities.getSalesActivitiesId() == 10){ //活动10专用 //圣诞活动,R系列一件减去90,两件打6.5折,因数据库设计过于复杂,只好在这写了
|
|
|
+ Integer num = 0;
|
|
|
+ Integer sunAmount = 0;
|
|
|
+ for (CartDto cartDto:cartDtos) {
|
|
|
+ if(cartDto.getCartColorId() == 60 || cartDto.getCartColorId() == 61 ||
|
|
|
+ cartDto.getCartColorId() == 62 || cartDto.getCartColorId() == 63){ //60,61,62,63
|
|
|
+ num += cartDto.getCartNum();
|
|
|
+ sunAmount += cartDto.getCartNum() * cartDto.getProductPrice();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(num == 1){
|
|
|
+ promotionAmout = 9000;
|
|
|
+ }else if(num >= 2){
|
|
|
+ Double amount = Double.valueOf(sunAmount);
|
|
|
+ BigDecimal bd1 = new BigDecimal(Double.toString(amount));
|
|
|
+ BigDecimal bd2 = new BigDecimal(Double.toString(0.35));
|
|
|
+ amount = bd1.multiply(bd2).doubleValue();
|
|
|
+ promotionAmout = amount.intValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ if(promotionAmout >= salesActivities.getSalesActivitiesFull()){
|
|
|
+ promotionAmout = salesActivities.getSalesActivitiesReduction();
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return promotionAmout;
|