|
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -76,8 +77,11 @@ public class PromotionFactoryBase extends ServiceImpl<PromotionMapper, Promotion
|
|
|
return save.getId();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public JMap<String, Object> goodsListPrice(JMap<String, Object> param) {
|
|
|
+ //返回是否可以使用优惠券参数
|
|
|
+ param.put("ableCoupon", true);
|
|
|
List<JMap<String, Object>> goodsList = param.getListMap("goodsList");
|
|
|
String deviceId = param.getString("deviceId");
|
|
|
Integer mercId = param.getInt("mercId");
|
|
@@ -108,6 +112,26 @@ public class PromotionFactoryBase extends ServiceImpl<PromotionMapper, Promotion
|
|
|
if (!Emptys.check(promotionList)) {
|
|
|
return param;
|
|
|
}
|
|
|
+ //判断时间段是否符合
|
|
|
+ //提取时间部分
|
|
|
+ LocalTime orderTime = orderCreateTime.toLocalTime();
|
|
|
+ for (int i = 0; i < promotionList.size(); i++) {
|
|
|
+ Promotion promotion = promotionList.get(i);
|
|
|
+ if (!promotion.getIsAllDay()) {
|
|
|
+ String dayTime = promotion.getDayTime();
|
|
|
+ JSONArray jsonArray = JSONUtil.parseArray(dayTime);
|
|
|
+ for (int j = 0; j < jsonArray.size(); j++) {
|
|
|
+ JSONObject jsonObject = jsonArray.getJSONObject(j);
|
|
|
+ LocalTime startTime = LocalTime.parse(jsonObject.get("startTime").toString() + ":00", DateTimeFormatter.ofPattern("HH:mm:ss"));
|
|
|
+ LocalTime endTime = LocalTime.parse(jsonObject.get("endTime").toString() + ":00", DateTimeFormatter.ofPattern("HH:mm:ss"));
|
|
|
+ // 判断 orderCreateTime 是否在指定时间段内
|
|
|
+ if (orderTime.isBefore(startTime) || orderTime.isAfter(endTime)) {
|
|
|
+ promotionList.remove(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//判断设备是否符合
|
|
|
for (int i = 0; i < promotionList.size(); i++) {
|
|
|
Promotion promotion = promotionList.get(i);
|
|
@@ -118,7 +142,7 @@ public class PromotionFactoryBase extends ServiceImpl<PromotionMapper, Promotion
|
|
|
deviceCondition = deviceService.checkDeviceId(promotion.getId(), deviceId, "promotion");
|
|
|
if (!deviceCondition) {
|
|
|
//设备不符合,直接从LIST删除
|
|
|
- promotionList.remove(i);
|
|
|
+ //promotionList.remove(i);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -126,6 +150,13 @@ public class PromotionFactoryBase extends ServiceImpl<PromotionMapper, Promotion
|
|
|
if (!Emptys.check(promotionList)) {
|
|
|
return param;
|
|
|
}
|
|
|
+ //判断是否可以使用优惠券
|
|
|
+ promotionList.forEach(promotion -> {
|
|
|
+ if (!promotion.getCanCoupon()) {
|
|
|
+ param.put("ableCoupon", false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
//查询活动商品表
|
|
|
List<Integer> promotionIdList = promotionList.stream().map(Promotion::getId).collect(Collectors.toList());
|
|
|
List<Map<String, Object>> actGoodsList = goodsService.list(new JHashMap<String, Object>()
|
|
@@ -166,6 +197,7 @@ public class PromotionFactoryBase extends ServiceImpl<PromotionMapper, Promotion
|
|
|
promotionList1.add(promotion);
|
|
|
goods.set("promotionList", promotionList1);
|
|
|
goods.set("amount", Integer.valueOf(promotionGoods.get("priceOnsale").toString()) * goods.getInt("num"));
|
|
|
+ param.put("ableCoupon", false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -219,6 +251,9 @@ public class PromotionFactoryBase extends ServiceImpl<PromotionMapper, Promotion
|
|
|
List<Object> promotionList1 = goods.getList("promotionList");
|
|
|
promotionList1.add(promotion);
|
|
|
goods.set("promotionList", promotionList1);
|
|
|
+ if (!promotion.getCanCoupon()) {
|
|
|
+ param.put("ableCoupon", false);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|