|
|
@@ -15,6 +15,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ruoyi.system.domain.PromotionCouponBatch;
|
|
|
import com.ruoyi.system.domain.PromotionCouponRule;
|
|
|
import com.ruoyi.system.domain.PromotionUserCoupon;
|
|
|
+import com.ruoyi.system.domain.vo.StoreCouponVO;
|
|
|
+import com.ruoyi.system.domain.vo.MyCouponVO;
|
|
|
import com.ruoyi.system.mapper.PromotionCouponBatchMapper;
|
|
|
import com.ruoyi.system.mapper.PromotionCouponRuleMapper;
|
|
|
import com.ruoyi.system.mapper.PromotionUserCouponMapper;
|
|
|
@@ -87,7 +89,7 @@ public class PromotionUserCouponServiceImpl extends ServiceImpl<PromotionUserCou
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> selectStoreCouponsForUser(Long userId, Long storeId) {
|
|
|
+ public List<StoreCouponVO> selectStoreCouponsForUser(Long userId, Long storeId) {
|
|
|
// 查询门店进行中的券批次
|
|
|
LambdaQueryWrapper<PromotionCouponBatch> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(PromotionCouponBatch::getStoreId, storeId)
|
|
|
@@ -96,24 +98,24 @@ public class PromotionUserCouponServiceImpl extends ServiceImpl<PromotionUserCou
|
|
|
.ge(PromotionCouponBatch::getEndTime, new Date());
|
|
|
List<PromotionCouponBatch> batches = batchMapper.selectList(wrapper);
|
|
|
|
|
|
- List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ List<StoreCouponVO> result = new ArrayList<>();
|
|
|
for (PromotionCouponBatch batch : batches) {
|
|
|
- Map<String, Object> item = new HashMap<>();
|
|
|
- item.put("id", batch.getId());
|
|
|
- item.put("name", batch.getName());
|
|
|
- item.put("couponType", batch.getCouponType());
|
|
|
- item.put("totalCount", batch.getTotalCount());
|
|
|
- item.put("remainCount", batch.getRemainCount());
|
|
|
+ StoreCouponVO vo = new StoreCouponVO();
|
|
|
+ vo.setId(batch.getId());
|
|
|
+ vo.setName(batch.getName());
|
|
|
+ vo.setCouponType(batch.getCouponType());
|
|
|
+ vo.setTotalCount(batch.getTotalCount());
|
|
|
+ vo.setRemainCount(batch.getRemainCount());
|
|
|
|
|
|
// 查询券规则
|
|
|
PromotionCouponRule rule = ruleMapper.selectOne(
|
|
|
new LambdaQueryWrapper<PromotionCouponRule>()
|
|
|
.eq(PromotionCouponRule::getBatchId, batch.getId()));
|
|
|
if (rule != null) {
|
|
|
- item.put("threshold", rule.getThreshold());
|
|
|
- item.put("amount", rule.getAmount());
|
|
|
- item.put("discountRate", rule.getDiscountRate());
|
|
|
- item.put("isMutex", rule.getIsMutex());
|
|
|
+ vo.setThreshold(rule.getThreshold());
|
|
|
+ vo.setAmount(rule.getAmount());
|
|
|
+ vo.setDiscountRate(rule.getDiscountRate());
|
|
|
+ vo.setIsMutex(rule.getIsMutex());
|
|
|
}
|
|
|
|
|
|
// 检查用户是否已领取
|
|
|
@@ -121,15 +123,15 @@ public class PromotionUserCouponServiceImpl extends ServiceImpl<PromotionUserCou
|
|
|
new LambdaQueryWrapper<PromotionUserCoupon>()
|
|
|
.eq(PromotionUserCoupon::getUserId, userId)
|
|
|
.eq(PromotionUserCoupon::getBatchId, batch.getId()));
|
|
|
- item.put("hasReceived", received > 0);
|
|
|
+ vo.setHasReceived(received > 0);
|
|
|
|
|
|
- result.add(item);
|
|
|
+ result.add(vo);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> selectMyCoupons(Long userId, Integer status, Long storeId) {
|
|
|
+ public List<MyCouponVO> selectMyCoupons(Long userId, Integer status, Long storeId) {
|
|
|
// 先把已过期的券标记为过期(expire_time < NOW() 且 status=0)
|
|
|
userCouponMapper.update(null,
|
|
|
new LambdaUpdateWrapper<PromotionUserCoupon>()
|
|
|
@@ -151,20 +153,20 @@ public class PromotionUserCouponServiceImpl extends ServiceImpl<PromotionUserCou
|
|
|
wrapper.orderByDesc(PromotionUserCoupon::getReceiveTime);
|
|
|
List<PromotionUserCoupon> coupons = userCouponMapper.selectList(wrapper);
|
|
|
|
|
|
- List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ List<MyCouponVO> result = new ArrayList<>();
|
|
|
for (PromotionUserCoupon coupon : coupons) {
|
|
|
- Map<String, Object> item = new HashMap<>();
|
|
|
- item.put("id", coupon.getId());
|
|
|
- item.put("batchId", coupon.getBatchId());
|
|
|
- item.put("storeId", coupon.getStoreId());
|
|
|
- item.put("status", coupon.getStatus());
|
|
|
- item.put("expireTime", coupon.getExpireTime());
|
|
|
+ MyCouponVO vo = new MyCouponVO();
|
|
|
+ vo.setId(coupon.getId());
|
|
|
+ vo.setBatchId(coupon.getBatchId());
|
|
|
+ vo.setStoreId(coupon.getStoreId());
|
|
|
+ vo.setStatus(coupon.getStatus());
|
|
|
+ vo.setExpireTime(coupon.getExpireTime());
|
|
|
|
|
|
// 查询批次信息
|
|
|
PromotionCouponBatch batch = batchMapper.selectById(coupon.getBatchId());
|
|
|
if (batch != null) {
|
|
|
- item.put("name", batch.getName());
|
|
|
- item.put("couponType", batch.getCouponType());
|
|
|
+ vo.setName(batch.getName());
|
|
|
+ vo.setCouponType(batch.getCouponType());
|
|
|
}
|
|
|
|
|
|
// 查询规则信息
|
|
|
@@ -172,13 +174,13 @@ public class PromotionUserCouponServiceImpl extends ServiceImpl<PromotionUserCou
|
|
|
new LambdaQueryWrapper<PromotionCouponRule>()
|
|
|
.eq(PromotionCouponRule::getBatchId, coupon.getBatchId()));
|
|
|
if (rule != null) {
|
|
|
- item.put("threshold", rule.getThreshold());
|
|
|
- item.put("amount", rule.getAmount());
|
|
|
- item.put("discountRate", rule.getDiscountRate());
|
|
|
- item.put("isMutex", rule.getIsMutex());
|
|
|
+ vo.setThreshold(rule.getThreshold());
|
|
|
+ vo.setAmount(rule.getAmount());
|
|
|
+ vo.setDiscountRate(rule.getDiscountRate());
|
|
|
+ vo.setIsMutex(rule.getIsMutex());
|
|
|
}
|
|
|
|
|
|
- result.add(item);
|
|
|
+ result.add(vo);
|
|
|
}
|
|
|
return result;
|
|
|
}
|