不可使用愿意 优惠券 列表

This commit is contained in:
wangw 2025-09-27 09:57:09 +08:00
parent a069d14657
commit 9dbd002211
9 changed files with 27 additions and 14 deletions

View File

@ -186,7 +186,7 @@ public class ACouponController {
* @param shopUserId 店铺用户Id * @param shopUserId 店铺用户Id
*/ */
@GetMapping("/findCoupon") @GetMapping("/findCoupon")
public CzgResult<List<UserCouponVo>> findCoupon(@RequestParam Long shopUserId, @RequestParam(required = false) Integer type) { public CzgResult<List<UserCouponVo>> findCoupon(@RequestParam Long shopUserId, @RequestParam(required = false) Integer type, @RequestParam(required = false) Integer isFood) {
return CzgResult.success(shopCouponService.findCoupon(StpKit.USER.getShopId(), shopUserId, type)); return CzgResult.success(shopCouponService.findCoupon(StpKit.USER.getShopId(), shopUserId, type, isFood));
} }
} }

View File

@ -83,8 +83,9 @@ public class UShopCouponController {
* @param shopUserId 店铺用户Id * @param shopUserId 店铺用户Id
*/ */
@GetMapping("/findCoupon") @GetMapping("/findCoupon")
public CzgResult<List<UserCouponVo>> findCoupon(@RequestHeader String shopId, @RequestParam Long shopUserId, @RequestParam(required = false) Integer type) { public CzgResult<List<UserCouponVo>> findCoupon(@RequestHeader String shopId, @RequestParam Long shopUserId,
@RequestParam(required = false) Integer type, @RequestParam(required = false) Integer isFood) {
AssertUtil.isBlank(shopId, "店铺Id不能为空"); AssertUtil.isBlank(shopId, "店铺Id不能为空");
return CzgResult.success(couponService.findCoupon(Long.parseLong(shopId), shopUserId, type)); return CzgResult.success(couponService.findCoupon(Long.parseLong(shopId), shopUserId, type, isFood));
} }
} }

View File

@ -33,6 +33,7 @@ public class UserCouponVo {
private String useRule; private String useRule;
private String ruleDetails; private String ruleDetails;
private String useRestrictions; private String useRestrictions;
private String noUseRestrictions;
private boolean isUse = false; private boolean isUse = false;
/** /**
* 优惠券门槛商品列表 * 优惠券门槛商品列表

View File

@ -26,7 +26,7 @@ public interface MkShopCouponRecordService extends IService<MkShopCouponRecord>
List<UserCouponVO> findByUser(String name, List<Long> shopUserIds, Integer status); List<UserCouponVO> findByUser(String name, List<Long> shopUserIds, Integer status);
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type); List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type, Integer isFood);
/** /**
* 优惠券列表/已领取详情 * 优惠券列表/已领取详情

View File

@ -35,7 +35,7 @@ public interface ShopCouponService extends IService<ShopCoupon> {
Page<UserCouponVO> find(Long userId, String name, Long shopId, Integer status); Page<UserCouponVO> find(Long userId, String name, Long shopId, Integer status);
List<UserCouponVo> findCoupon(Long shopId, Long shopUserId, Integer type); List<UserCouponVo> findCoupon(Long shopId, Long shopUserId, Integer type, Integer isFood);
Boolean use(List<Long> ids, Long shopUserId, Long orderId); Boolean use(List<Long> ids, Long shopUserId, Long orderId);

View File

@ -23,7 +23,7 @@ public interface MkShopCouponRecordMapper extends BaseMapper<MkShopCouponRecord>
List<UserCouponVO> findCouponVOByUser(String name, List<Long> shopUserIds, Integer status); List<UserCouponVO> findCouponVOByUser(String name, List<Long> shopUserIds, Integer status);
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type); List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type, Integer isFood);
List<ShopInfoCouponVO> getShopByCouponRecord(Long userId); List<ShopInfoCouponVO> getShopByCouponRecord(Long userId);
} }

View File

@ -72,8 +72,8 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
} }
@Override @Override
public List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type) { public List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type, Integer isFood) {
return getMapper().queryByVipIdAndShopId(shopId, shopUserId, type); return getMapper().queryByVipIdAndShopId(shopId, shopUserId, type, isFood);
} }

View File

@ -284,8 +284,8 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
} }
@Override @Override
public List<UserCouponVo> findCoupon(Long shopId, Long shopUserId, Integer type) { public List<UserCouponVo> findCoupon(Long shopId, Long shopUserId, Integer type, Integer isFood) {
List<UserCouponVo> tbUserCouponVos = recordService.queryByVipIdAndShopId(shopId, shopUserId, type); List<UserCouponVo> tbUserCouponVos = recordService.queryByVipIdAndShopId(shopId, shopUserId, type, isFood);
if (CollectionUtil.isNotEmpty(tbUserCouponVos)) { if (CollectionUtil.isNotEmpty(tbUserCouponVos)) {
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese(""); String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
@ -418,6 +418,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
useRestrictions = new StringBuilder(tbShopCoupon.getUseDays() + " "); useRestrictions = new StringBuilder(tbShopCoupon.getUseDays() + " ");
} }
if (!tbShopCoupon.getUseDays().contains(week)) { if (!tbShopCoupon.getUseDays().contains(week)) {
tbUserCouponVo.setNoUseRestrictions("不在可用时间范围内");
isUse = false; isUse = false;
} }
} }
@ -427,12 +428,15 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
LocalTime endTime = tbShopCoupon.getUseEndTime().toLocalTime(); LocalTime endTime = tbShopCoupon.getUseEndTime().toLocalTime();
if (currentTime.isBefore(startTime)) { if (currentTime.isBefore(startTime)) {
if (startTime.isBefore(endTime)) { if (startTime.isBefore(endTime)) {
tbUserCouponVo.setNoUseRestrictions("不在可用时间范围内");
isUse = false; isUse = false;
} else if (currentTime.isAfter(endTime)) { } else if (currentTime.isAfter(endTime)) {
tbUserCouponVo.setNoUseRestrictions("不在可用时间范围内");
isUse = false; isUse = false;
} }
} else if (startTime.isBefore(endTime)) { } else if (startTime.isBefore(endTime)) {
if (currentTime.isAfter(endTime)) { if (currentTime.isAfter(endTime)) {
tbUserCouponVo.setNoUseRestrictions("不在可用时间范围内");
isUse = false; isUse = false;
} }
} }

View File

@ -108,9 +108,16 @@
<if test="shopId != null and shopId != ''"> <if test="shopId != null and shopId != ''">
and inRecord.shop_id = #{shopId} and inRecord.shop_id = #{shopId}
</if> </if>
<if test="type != null "> <choose>
and inRecord.type = #{type} <when test="type != null ">
</if> and inRecord.type = #{type}
</when>
<otherwise>
<if test="isFood != null">
and inRecord.type != 2
</if>
</otherwise>
</choose>
and inRecord.status = 0 and inRecord.status = 0
and inRecord.use_start_time &lt; now() and inRecord.use_start_time &lt; now()
and inRecord.use_end_time &gt; now() and inRecord.use_end_time &gt; now()