|
@@ -16,6 +16,7 @@ import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.store.*;
|
|
import shop.alien.entity.store.*;
|
|
|
import shop.alien.entity.store.dto.LifeDiscountCouponStoreFriendDto;
|
|
import shop.alien.entity.store.dto.LifeDiscountCouponStoreFriendDto;
|
|
|
import shop.alien.entity.store.vo.LifeCouponStatusVo;
|
|
import shop.alien.entity.store.vo.LifeCouponStatusVo;
|
|
|
|
|
+import shop.alien.entity.storePlatform.vo.LifeCouponPlatformDto;
|
|
|
import shop.alien.mapper.*;
|
|
import shop.alien.mapper.*;
|
|
|
import shop.alien.storeplatform.service.LifeCouponPlatformService;
|
|
import shop.alien.storeplatform.service.LifeCouponPlatformService;
|
|
|
import shop.alien.util.common.UniqueRandomNumGenerator;
|
|
import shop.alien.util.common.UniqueRandomNumGenerator;
|
|
@@ -23,6 +24,7 @@ import shop.alien.util.common.constant.OrderStatusEnum;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.*;
|
|
import java.time.*;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.TextStyle;
|
|
import java.time.format.TextStyle;
|
|
@@ -30,11 +32,12 @@ import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 优惠券
|
|
|
|
|
|
|
+ * 优惠券服务实现类(平台端)
|
|
|
|
|
+ * 负责处理优惠券的创建、更新、删除、查询、核销等核心业务逻辑
|
|
|
|
|
+ * 支持优惠券库存管理、状态管理、节假日管理、订单核销验证等功能
|
|
|
*
|
|
*
|
|
|
- * @author ssk
|
|
|
|
|
- * @version 1.0
|
|
|
|
|
- * @date 2024/12/23 15:08
|
|
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@@ -58,6 +61,16 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
|
|
|
|
|
|
|
|
private final LifeDiscountCouponMapper lifeDiscountCouponMapper;
|
|
private final LifeDiscountCouponMapper lifeDiscountCouponMapper;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增或更新优惠券
|
|
|
|
|
+ * 根据优惠券是否存在ID判断是新增还是更新操作
|
|
|
|
|
+ * 自动生成优惠券编码,设置优惠标签和状态
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param lifeCoupon 优惠券对象
|
|
|
|
|
+ * @return LifeCoupon 保存后的优惠券信息
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
public LifeCoupon addOrUpdateCoupon(LifeCoupon lifeCoupon) {
|
|
public LifeCoupon addOrUpdateCoupon(LifeCoupon lifeCoupon) {
|
|
|
|
|
|
|
@@ -83,17 +96,6 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
|
|
|
lifeCoupon.setDiscountTagName(String.join(",", businessTypeNames));
|
|
lifeCoupon.setDiscountTagName(String.join(",", businessTypeNames));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// int status = 0;
|
|
|
|
|
-// Date now = new Date();
|
|
|
|
|
-// Date startDate = lifeCoupon.getStartDate();
|
|
|
|
|
-// Date endDate = lifeCoupon.getEndDate();
|
|
|
|
|
-// if (now.compareTo(startDate) >= 0 && now.compareTo(endDate) <= 0) {
|
|
|
|
|
-// status = 1;
|
|
|
|
|
-// } else if (now.compareTo(startDate) < 0) {
|
|
|
|
|
-// status = 0;
|
|
|
|
|
-// } else if (now.compareTo(endDate) >= 0) {
|
|
|
|
|
-// status = 3;
|
|
|
|
|
-// }
|
|
|
|
|
lifeCoupon.setStatus(1);
|
|
lifeCoupon.setStatus(1);
|
|
|
if (StringUtils.isEmpty(lifeCoupon.getId())) {
|
|
if (StringUtils.isEmpty(lifeCoupon.getId())) {
|
|
|
lifeCoupon.setType(1);
|
|
lifeCoupon.setType(1);
|
|
@@ -107,10 +109,13 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 修改库存数量
|
|
* 修改库存数量
|
|
|
|
|
+ * 更新指定优惠券的库存数量,当库存为0时增加库存会自动修改状态为进行中
|
|
|
*
|
|
*
|
|
|
- * @param id 主键
|
|
|
|
|
|
|
+ * @param id 优惠券ID
|
|
|
* @param singleQty 库存数量
|
|
* @param singleQty 库存数量
|
|
|
- * @return boolean
|
|
|
|
|
|
|
+ * @return boolean 更新是否成功
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public boolean updateCouponSingleQty(Integer id, Integer singleQty) {
|
|
public boolean updateCouponSingleQty(Integer id, Integer singleQty) {
|
|
@@ -136,14 +141,73 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除优惠券
|
|
|
|
|
+ * 通过设置删除标记实现软删除
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 优惠券ID
|
|
|
|
|
+ * @return boolean 删除是否成功
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean deleteCoupon(Integer id) {
|
|
|
|
|
+ LambdaUpdateWrapper<LifeCoupon> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ lambdaUpdateWrapper.eq(LifeCoupon :: getId, id);
|
|
|
|
|
+ lambdaUpdateWrapper.set(LifeCoupon :: getDeleteFlag, 1);
|
|
|
|
|
+ lifeCouponMapper.update(null, lambdaUpdateWrapper);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分页查询优惠券列表
|
|
|
|
|
+ * 支持按门店、状态、名称、数据类型、审核状态等条件筛选
|
|
|
|
|
+ * 包含销量统计、状态转换等业务逻辑
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param page 页码
|
|
|
|
|
+ * @param size 每页数量
|
|
|
|
|
+ * @param storeId 门店ID
|
|
|
|
|
+ * @param status 状态
|
|
|
|
|
+ * @param name 优惠券名称
|
|
|
|
|
+ * @param dataType 数据类型(0:正式数据, 1:草稿数据)
|
|
|
|
|
+ * @param reviewType 审核状态
|
|
|
|
|
+ * @return IPage<LifeCouponPlatformDto> 分页优惠券列表
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
- public IPage<LifeCoupon> getCouponList(int page, int size, String storeId, String status, String name, Integer dataType) {
|
|
|
|
|
|
|
+ public IPage<LifeCouponPlatformDto> getCouponList(int page, int size, String storeId, String status, String name, Integer dataType, String reviewType) {
|
|
|
|
|
+
|
|
|
LambdaUpdateWrapper<LifeCoupon> wrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<LifeCoupon> wrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ if (!StringUtils.isEmpty(reviewType)) {
|
|
|
|
|
+ switch (reviewType) {
|
|
|
|
|
+ case "0":
|
|
|
|
|
+ wrapper.eq(LifeCoupon::getStatus, "1");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "1":
|
|
|
|
|
+ wrapper.in(LifeCoupon::getStatus, Arrays.asList("2", "4", "5", "6", "7", "8"));
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "2":
|
|
|
|
|
+ wrapper.eq(LifeCoupon::getStatus, "3");
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ wrapper.eq(status != null && !status.isEmpty(), LifeCoupon::getStatus, status);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (dataType == 1) {
|
|
|
|
|
+ wrapper.eq(status != null && !status.isEmpty(), LifeCoupon::getStatus, 1);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wrapper.eq(status != null && !status.isEmpty(), LifeCoupon::getStatus, status);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
wrapper.eq(storeId != null && !storeId.isEmpty(), LifeCoupon::getStoreId, storeId);
|
|
wrapper.eq(storeId != null && !storeId.isEmpty(), LifeCoupon::getStoreId, storeId);
|
|
|
- wrapper.eq(status != null && !status.isEmpty(), LifeCoupon::getStatus, status);
|
|
|
|
|
wrapper.like(name != null && !name.isEmpty(), LifeCoupon::getName, name);
|
|
wrapper.like(name != null && !name.isEmpty(), LifeCoupon::getName, name);
|
|
|
wrapper.eq(LifeCoupon::getType, 1);
|
|
wrapper.eq(LifeCoupon::getType, 1);
|
|
|
- wrapper.eq(LifeCoupon::getDataType, dataType);
|
|
|
|
|
|
|
+ if ( dataType != 2 ){
|
|
|
|
|
+ wrapper.eq(LifeCoupon::getDataType, dataType);
|
|
|
|
|
+ }
|
|
|
// 修改排序 按照status(0草稿/1待审核/2未开始/3审核拒绝/4已售罄/5进行中/6已下架/7已结束/8=2+手动下架) 审核拒绝>待审核>进行中>已售罄,已下架,已结束(同等优先级的情况下,按照审核时间的倒序显示)
|
|
// 修改排序 按照status(0草稿/1待审核/2未开始/3审核拒绝/4已售罄/5进行中/6已下架/7已结束/8=2+手动下架) 审核拒绝>待审核>进行中>已售罄,已下架,已结束(同等优先级的情况下,按照审核时间的倒序显示)
|
|
|
wrapper.last("ORDER BY CASE " +
|
|
wrapper.last("ORDER BY CASE " +
|
|
|
"WHEN status = 3 THEN 0 " + // 审核拒绝
|
|
"WHEN status = 3 THEN 0 " + // 审核拒绝
|
|
@@ -152,10 +216,92 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
|
|
|
"WHEN status IN (4, 6, 7) THEN 3 " + // 已售罄、已下架、已结束
|
|
"WHEN status IN (4, 6, 7) THEN 3 " + // 已售罄、已下架、已结束
|
|
|
"ELSE 4 END ASC, " +
|
|
"ELSE 4 END ASC, " +
|
|
|
"created_time DESC");
|
|
"created_time DESC");
|
|
|
- IPage<LifeCoupon> lifeCouponIPage = new Page<>(page, size);
|
|
|
|
|
- return lifeCouponMapper.selectPage(lifeCouponIPage, wrapper);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ IPage<LifeCoupon> lifeCouponIPag = lifeCouponMapper.selectPage(new Page<>(page, size), wrapper);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建 LifeCouponPlatformDto 的分页对象
|
|
|
|
|
+ IPage<LifeCouponPlatformDto> dto = new Page<>(page, size);
|
|
|
|
|
+
|
|
|
|
|
+ // 将 lifeCouponIPag 中的数据复制到 dto 中
|
|
|
|
|
+ // 复制分页信息
|
|
|
|
|
+ dto.setPages(lifeCouponIPag.getPages());
|
|
|
|
|
+ dto.setCurrent(lifeCouponIPag.getCurrent());
|
|
|
|
|
+ dto.setSize(lifeCouponIPag.getSize());
|
|
|
|
|
+ dto.setTotal(lifeCouponIPag.getTotal());
|
|
|
|
|
+
|
|
|
|
|
+ // 复制记录列表,将 LifeCoupon 转换为 LifeCouponPlatformDto
|
|
|
|
|
+ List<LifeCouponPlatformDto> dtoRecords = lifeCouponIPag.getRecords().stream().map(coupon -> {
|
|
|
|
|
+ LifeCouponPlatformDto dtoRecord = new LifeCouponPlatformDto();
|
|
|
|
|
+ // 使用 BeanUtils 复制相同属性
|
|
|
|
|
+ org.springframework.beans.BeanUtils.copyProperties(coupon, dtoRecord);
|
|
|
|
|
+
|
|
|
|
|
+ if (dtoRecord.getDataType() == 1) {
|
|
|
|
|
+ dtoRecord.setSaleNum("");
|
|
|
|
|
+ dtoRecord.setSingleQty(null);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ dtoRecord.setSaleNum(lifeUserOrderMapper.countCouponByCouponId(coupon.getId()).toString());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (coupon.getStatus() == 1) {
|
|
|
|
|
+ dtoRecord.setReviewType("待审核");
|
|
|
|
|
+ } else if (coupon.getStatus() == 2 || coupon.getStatus() == 4 || coupon.getStatus() == 5 || coupon.getStatus() == 6 || coupon.getStatus() == 7 ) {
|
|
|
|
|
+ dtoRecord.setReviewType("审核通过");
|
|
|
|
|
+ } else if (coupon.getStatus() == 3) {
|
|
|
|
|
+ dtoRecord.setReviewType("审核拒绝");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (Objects.nonNull(coupon.getStatus())) {
|
|
|
|
|
+ switch (coupon.getStatus()) {
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ dtoRecord.setStatusName("草稿");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ dtoRecord.setStatusName("待审核");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ dtoRecord.setStatusName("未开始");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ dtoRecord.setStatusName("审核拒绝");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 4:
|
|
|
|
|
+ dtoRecord.setStatusName("已售罄");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 5:
|
|
|
|
|
+ dtoRecord.setStatusName("进行中");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 6:
|
|
|
|
|
+ dtoRecord.setStatusName("已下架");
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 7:
|
|
|
|
|
+ dtoRecord.setStatusName("已结束");
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ dtoRecord.setStatusName("未知状态");
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return dtoRecord;
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ dto.setRecords(dtoRecords);
|
|
|
|
|
+
|
|
|
|
|
+ return dto;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新优惠券状态
|
|
|
|
|
+ * 修改优惠券的状态,支持上架、下架等操作
|
|
|
|
|
+ * 自动判断优惠券是否已结束
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 优惠券ID
|
|
|
|
|
+ * @param status 状态值
|
|
|
|
|
+ * @return int 更新的记录数
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
public int updateCoupon(String id, Integer status) {
|
|
public int updateCoupon(String id, Integer status) {
|
|
|
LifeCoupon coupon = lifeCouponMapper.selectById(id);
|
|
LifeCoupon coupon = lifeCouponMapper.selectById(id);
|
|
@@ -172,114 +318,22 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
|
|
|
return lifeCouponMapper.updateById(lifeCoupon);
|
|
return lifeCouponMapper.updateById(lifeCoupon);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 验券
|
|
|
|
|
- *
|
|
|
|
|
- * @param storeId
|
|
|
|
|
- * @param quanCode
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public Map<String, String> couponVerify(String storeId, String quanCode) {
|
|
|
|
|
- LambdaUpdateWrapper<LifeUserOrder> wrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
- wrapper.eq(LifeUserOrder::getQuanCode, quanCode);
|
|
|
|
|
- LifeUserOrder order = lifeUserOrderMapper.selectOne(wrapper);
|
|
|
|
|
- Map<String, String> resultMap = new HashMap<>();
|
|
|
|
|
- String errMessage = "";
|
|
|
|
|
- if (order == null) {
|
|
|
|
|
- errMessage = "没有这张券";
|
|
|
|
|
- } else {
|
|
|
|
|
- if (order.getStatus() == 5) {
|
|
|
|
|
- errMessage = "该券已核销";
|
|
|
|
|
- }
|
|
|
|
|
- if (order.getStatus() == 6) {
|
|
|
|
|
- errMessage = "该券已过期";
|
|
|
|
|
- }
|
|
|
|
|
- if (order.getStatus() == 7) {
|
|
|
|
|
- errMessage = "该券待退款";
|
|
|
|
|
- }
|
|
|
|
|
- if (order.getStatus() == 4) {
|
|
|
|
|
- errMessage = "该券已退款";
|
|
|
|
|
- }
|
|
|
|
|
- if (!order.getStoreId().equals(storeId)) {
|
|
|
|
|
- errMessage = "核销商家与券不一致";
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (!StringUtils.isEmpty(errMessage)) {
|
|
|
|
|
- resultMap.put("code", "false");
|
|
|
|
|
- resultMap.put("message", errMessage);
|
|
|
|
|
- return resultMap;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- order.setStatus(5);
|
|
|
|
|
- order.setUsedTime(new Date());
|
|
|
|
|
- lifeUserOrderMapper.updateById(order);
|
|
|
|
|
-
|
|
|
|
|
- LambdaUpdateWrapper<LifeCoupon> couponWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
- couponWrapper.eq(LifeCoupon::getId, order.getQuanId());
|
|
|
|
|
- LifeCoupon coupon = lifeCouponMapper.selectOne(couponWrapper);
|
|
|
|
|
- // TODO 抽成比例应该从商户里取
|
|
|
|
|
- BigDecimal amounts = new BigDecimal(order.getFinalPrice()).multiply(new BigDecimal(100));
|
|
|
|
|
- BigDecimal commission = amounts.multiply(new BigDecimal(0.04)).setScale(0, RoundingMode.HALF_UP);
|
|
|
|
|
- BigDecimal money = amounts.subtract(commission);
|
|
|
|
|
-
|
|
|
|
|
- // 插入收入明细表数据
|
|
|
|
|
- StoreIncomeDetailsRecord record = new StoreIncomeDetailsRecord();
|
|
|
|
|
- record.setStoreId(Integer.parseInt(storeId));
|
|
|
|
|
- record.setUserOrderId(Integer.parseInt(order.getId()));
|
|
|
|
|
- record.setIncomeType(coupon.getType());
|
|
|
|
|
- record.setBusinessId(Integer.parseInt(order.getQuanId()));
|
|
|
|
|
- record.setCommission(commission.intValue());
|
|
|
|
|
- record.setMoney(money.intValue());
|
|
|
|
|
- storeIncomeDetailsRecordMapper.insert(record);
|
|
|
|
|
- // 店铺账户余额增加
|
|
|
|
|
- UpdateWrapper<StoreUser> updateWrapper = new UpdateWrapper();
|
|
|
|
|
- updateWrapper.eq("store_id", storeId);
|
|
|
|
|
- updateWrapper.eq("delete_flag", 0);
|
|
|
|
|
- updateWrapper.setSql("money = money + " + money);
|
|
|
|
|
- storeUserMapper.update(null, updateWrapper);
|
|
|
|
|
- //发放好友优惠券
|
|
|
|
|
- LifeDiscountCouponStoreFriendDto lifeDiscountCouponStoreFriendDto = new LifeDiscountCouponStoreFriendDto();
|
|
|
|
|
- lifeDiscountCouponStoreFriendDto.setOrderId(Integer.parseInt(order.getId()));
|
|
|
|
|
-// lifeDiscountCouponStoreFriendService.issueFriendCoupon(lifeDiscountCouponStoreFriendDto);
|
|
|
|
|
- resultMap.put("code", "true");
|
|
|
|
|
- resultMap.put("message", "核销成功");
|
|
|
|
|
- return resultMap;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * <p>
|
|
|
|
|
- * 获取代金券状态
|
|
|
|
|
- * </p>
|
|
|
|
|
|
|
+ * 分页查询节假日列表
|
|
|
|
|
+ * 支持按年份、开关状态、节假日名称筛选
|
|
|
|
|
+ * 未指定年份时按年份分组查询,指定年份时查询该年份的详细节假日列表
|
|
|
*
|
|
*
|
|
|
- * @author zhangchen
|
|
|
|
|
- * @since 2025-07-14
|
|
|
|
|
|
|
+ * @param page 页码
|
|
|
|
|
+ * @param size 每页数量
|
|
|
|
|
+ * @param year 年份
|
|
|
|
|
+ * @param openFlag 是否启用(0:未启用,1:已启用)
|
|
|
|
|
+ * @param holidayName 节假日名称
|
|
|
|
|
+ * @return IPage<EssentialHolidayComparison> 分页节假日列表
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public LifeCouponStatusVo getCouponStatus(String couponId) {
|
|
|
|
|
- if (couponId == null || couponId.isEmpty()) {
|
|
|
|
|
- log.error("获取代金券状态失败:couponId为空");
|
|
|
|
|
- throw new IllegalArgumentException("couponId不能为空");
|
|
|
|
|
- }
|
|
|
|
|
- try {
|
|
|
|
|
- LifeCoupon coupon = lifeCouponMapper.selectById(couponId);
|
|
|
|
|
- LifeCouponStatusVo lifeCouponStatusVo = new LifeCouponStatusVo();
|
|
|
|
|
- if (coupon != null) {
|
|
|
|
|
- lifeCouponStatusVo.setCouponId(couponId);
|
|
|
|
|
- lifeCouponStatusVo.setSingleQty(coupon.getSingleQty());
|
|
|
|
|
- lifeCouponStatusVo.setBuyLimit(coupon.getBuyLimit());
|
|
|
|
|
- } else {
|
|
|
|
|
- // 可选:设置默认值或标记状态为无效
|
|
|
|
|
- lifeCouponStatusVo.setSingleQty(0); // 或其他默认逻辑
|
|
|
|
|
- }
|
|
|
|
|
- return lifeCouponStatusVo;
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("获取代金券状态失败: {}", e);
|
|
|
|
|
- throw new RuntimeException("获取代金券状态失败", e); // 或者根据项目规范处理
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
public IPage<EssentialHolidayComparison> getHolidayList(int page, int size, String year, String openFlag, String holidayName) {
|
|
public IPage<EssentialHolidayComparison> getHolidayList(int page, int size, String year, String openFlag, String holidayName) {
|
|
|
if (StringUtils.isEmpty(year)) {
|
|
if (StringUtils.isEmpty(year)) {
|
|
|
LambdaQueryWrapper<EssentialHolidayComparison> essentialHolidayComparisonLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<EssentialHolidayComparison> essentialHolidayComparisonLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
@@ -298,6 +352,15 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存节假日信息
|
|
|
|
|
+ * 新增或更新节假日配置,自动设置节假日日期
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param essentialHolidayComparison 节假日对象
|
|
|
|
|
+ * @return boolean 保存是否成功
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
public boolean saveHoliday(EssentialHolidayComparison essentialHolidayComparison) {
|
|
public boolean saveHoliday(EssentialHolidayComparison essentialHolidayComparison) {
|
|
|
if (ObjectUtils.isNotEmpty(essentialHolidayComparison.getId())) {
|
|
if (ObjectUtils.isNotEmpty(essentialHolidayComparison.getId())) {
|
|
@@ -315,18 +378,45 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除节假日
|
|
|
|
|
+ * 根据ID删除指定的节假日配置(软删除)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 节假日ID
|
|
|
|
|
+ * @return boolean 删除是否成功
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
public boolean delHoliday(String id) {
|
|
public boolean delHoliday(String id) {
|
|
|
essentialHolidayComparisonMapper.update(null, new LambdaUpdateWrapper<EssentialHolidayComparison>().eq(EssentialHolidayComparison::getId, id).set(EssentialHolidayComparison::getDelFlag, 1));
|
|
essentialHolidayComparisonMapper.update(null, new LambdaUpdateWrapper<EssentialHolidayComparison>().eq(EssentialHolidayComparison::getId, id).set(EssentialHolidayComparison::getDelFlag, 1));
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按年份删除节假日
|
|
|
|
|
+ * 删除指定年份的所有节假日配置(软删除)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param year 年份
|
|
|
|
|
+ * @return boolean 删除是否成功
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
public boolean delHolidayByYear(String year) {
|
|
public boolean delHolidayByYear(String year) {
|
|
|
essentialHolidayComparisonMapper.update(null, new LambdaUpdateWrapper<EssentialHolidayComparison>().eq(EssentialHolidayComparison::getParticularYear, year).set(EssentialHolidayComparison::getDelFlag, 1));
|
|
essentialHolidayComparisonMapper.update(null, new LambdaUpdateWrapper<EssentialHolidayComparison>().eq(EssentialHolidayComparison::getParticularYear, year).set(EssentialHolidayComparison::getDelFlag, 1));
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 启用或禁用节假日
|
|
|
|
|
+ * 切换指定节假日的开关状态(0-未启用,1-已启用)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 节假日ID
|
|
|
|
|
+ * @return boolean 操作是否成功
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
public boolean openCloseHoliday(String id) {
|
|
public boolean openCloseHoliday(String id) {
|
|
|
EssentialHolidayComparison essentialHolidayComparison = essentialHolidayComparisonMapper.selectById(id);
|
|
EssentialHolidayComparison essentialHolidayComparison = essentialHolidayComparisonMapper.selectById(id);
|
|
@@ -339,26 +429,14 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 核销订单前效验
|
|
|
|
|
|
|
+ * 判断当前日期是否在任意一个日期范围内
|
|
|
|
|
+ * 用于验证优惠券或团购券的自定义不可用日期
|
|
|
*
|
|
*
|
|
|
- * @param orderCode
|
|
|
|
|
- * @return
|
|
|
|
|
|
|
+ * @param dateRanges 日期范围数组,格式为["yyyy-MM-dd,yyyy-MM-dd", ...]
|
|
|
|
|
+ * @return boolean 当前日期是否在任意范围内
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
*/
|
|
*/
|
|
|
- @Override
|
|
|
|
|
- public R<String> orderVerify(String orderCode) {
|
|
|
|
|
- OrderCouponMiddle orderCouponMiddle = orderCouponMiddleMapper.selectOne(new LambdaQueryWrapper<OrderCouponMiddle>().eq(OrderCouponMiddle::getCouponCode, orderCode));
|
|
|
|
|
- if (!StringUtils.isEmpty(orderCouponMiddle) && orderCouponMiddle.getStatus() == 1) {
|
|
|
|
|
- LifeUserOrder lifeUserOrder = lifeUserOrderMapper.selectOne(new LambdaQueryWrapper<LifeUserOrder>().eq(LifeUserOrder::getId, orderCouponMiddle.getOrderId()));
|
|
|
|
|
- //类型为:1 代金券订单
|
|
|
|
|
- if (lifeUserOrder.getCouponType() == 1) {
|
|
|
|
|
- return couponVerification(orderCouponMiddle);
|
|
|
|
|
- } else if (lifeUserOrder.getCouponType() == 2) {//类型为:2 团购订单
|
|
|
|
|
- return groupVerification(orderCouponMiddle);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return R.fail("该劵不是待使用状态");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public static boolean isCurrentDateInAnyRange(String[] dateRanges) {
|
|
public static boolean isCurrentDateInAnyRange(String[] dateRanges) {
|
|
|
// 获取当前日期
|
|
// 获取当前日期
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
LocalDate currentDate = LocalDate.now();
|
|
@@ -392,6 +470,15 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 团购券核销验证
|
|
|
|
|
+ * 验证团购券的有效期、不可用日期(星期、节日、自定义日期)等
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param orderCouponMiddle 订单优惠券中间表对象
|
|
|
|
|
+ * @return R<String> 验证结果
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
|
|
+ */
|
|
|
public R<String> groupVerification(OrderCouponMiddle orderCouponMiddle) {
|
|
public R<String> groupVerification(OrderCouponMiddle orderCouponMiddle) {
|
|
|
LifeGroupBuyMain lifeGroupBuyMain = lifeGroupBuyMainMapper.selectOne(new LambdaQueryWrapper<LifeGroupBuyMain>().eq(LifeGroupBuyMain::getId, orderCouponMiddle.getCouponId()));
|
|
LifeGroupBuyMain lifeGroupBuyMain = lifeGroupBuyMainMapper.selectOne(new LambdaQueryWrapper<LifeGroupBuyMain>().eq(LifeGroupBuyMain::getId, orderCouponMiddle.getCouponId()));
|
|
|
//团购有效期类型为:0 指定天数
|
|
//团购有效期类型为:0 指定天数
|
|
@@ -454,6 +541,15 @@ public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper,
|
|
|
return R.success("效验通过");
|
|
return R.success("效验通过");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 代金券核销验证
|
|
|
|
|
+ * 验证代金券的有效期、不可用日期(星期、节日、自定义日期)、使用时间段、单次核销数量等
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param orderCouponMiddle 订单优惠券中间表对象
|
|
|
|
|
+ * @return R<String> 验证结果
|
|
|
|
|
+ * @author alien-cloud
|
|
|
|
|
+ * @date 2025-11-18
|
|
|
|
|
+ */
|
|
|
public R<String> couponVerification(OrderCouponMiddle orderCouponMiddle) {
|
|
public R<String> couponVerification(OrderCouponMiddle orderCouponMiddle) {
|
|
|
LifeCoupon lifeCoupon = lifeCouponMapper.selectOne(new LambdaQueryWrapper<LifeCoupon>().eq(LifeCoupon::getId, orderCouponMiddle.getCouponId()));
|
|
LifeCoupon lifeCoupon = lifeCouponMapper.selectOne(new LambdaQueryWrapper<LifeCoupon>().eq(LifeCoupon::getId, orderCouponMiddle.getCouponId()));
|
|
|
//代金券有效期类型为:1 指定天数
|
|
//代金券有效期类型为:1 指定天数
|