Просмотр исходного кода

chore: auto bump version and changelog [skip ci]

iwt 2 месяцев назад
Родитель
Сommit
596cc7214a

+ 5 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/CouponController.java

@@ -75,4 +75,9 @@ public class CouponController {
     public Result<List<Coupon>> joinRules() {
         return Result.success(couponService.listJoinRules());
     }
+
+    @PostMapping("/my")
+    public Result<List<Map<String, Object>>> my(@RequestAttribute("userId") Long userId) {
+        return Result.success(couponService.listMyCoupons(userId));
+    }
 }

+ 42 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/CouponService.java

@@ -13,7 +13,9 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -255,4 +257,44 @@ public class CouponService {
         return couponMapper.selectList(
                 new LambdaQueryWrapper<Coupon>().eq(Coupon::getGrantType, "JOIN"));
     }
+
+    /** 我的优惠券:返回 user_coupon + coupon 联合数据,含 status/receivedAt/usedAt */
+    public List<Map<String, Object>> listMyCoupons(Long userId) {
+        List<UserCoupon> userCoupons = userCouponMapper.selectList(
+                new LambdaQueryWrapper<UserCoupon>()
+                        .eq(UserCoupon::getUserId, userId)
+                        .orderByDesc(UserCoupon::getReceivedAt));
+        if (userCoupons.isEmpty()) {
+            return new ArrayList<>();
+        }
+        Date now = new Date();
+        List<Map<String, Object>> result = new ArrayList<>();
+        for (UserCoupon uc : userCoupons) {
+            Coupon coupon = couponMapper.selectById(uc.getCouponId());
+            if (coupon == null) continue;
+            // 过期判断
+            String status = uc.getStatus();
+            if ("AVAILABLE".equals(status) && coupon.getValidUntil() != null && now.after(coupon.getValidUntil())) {
+                status = "EXPIRED";
+            }
+            Map<String, Object> item = new HashMap<>();
+            item.put("userCouponId", uc.getId());
+            item.put("id", uc.getId());
+            item.put("couponId", coupon.getId());
+            item.put("name", coupon.getName());
+            item.put("type", coupon.getType());
+            item.put("value", coupon.getValue());
+            item.put("discountRate", coupon.getDiscountRate());
+            item.put("minSpend", coupon.getMinSpend());
+            item.put("applicableTo", coupon.getApplicableTo());
+            item.put("validFrom", coupon.getValidFrom());
+            item.put("validUntil", coupon.getValidUntil());
+            item.put("status", status);
+            item.put("receivedAt", uc.getReceivedAt());
+            item.put("usedAt", uc.getUsedAt());
+            item.put("orderId", uc.getOrderId());
+            result.add(item);
+        }
+        return result;
+    }
 }

+ 2 - 2
cfc-frontend/pages/profile-extra/coupons.vue

@@ -86,7 +86,7 @@
 </template>
 
 <script>
-import { getCouponList, claimCoupon, getExchangeableCoupons, exchangeCoupon } from '../../utils/api.js'
+import { getMyCoupons, claimCoupon, getExchangeableCoupons, exchangeCoupon } from '../../utils/api.js'
 import { parseDate } from '../../utils/format.js'
 
 export default {
@@ -147,7 +147,7 @@ export default {
     async loadCoupons() {
       this.loading = true
       try {
-        var res = await getCouponList()
+        var res = await getMyCoupons()
         this.coupons = res.data || []
       } catch (e) {
         console.error('加载优惠券失败', e)

+ 4 - 0
cfc-frontend/utils/api.js

@@ -2175,6 +2175,10 @@ export const getCouponList = () => {
   return request('/api/coupon/list', 'POST')
 }
 
+export const getMyCoupons = () => {
+  return request('/api/coupon/my', 'POST')
+}
+
 export const claimCoupon = (couponId) => {
   return request('/api/coupon/claim', 'POST', { couponId })
 }

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-5bf218fe3c722cae8331d25470e692908efc4ce1
+1d51481c73453ebfe8eec940b0ffe8d6a4d0adfe

+ 1 - 1
cfc-web/package.json

@@ -1,6 +1,6 @@
 {
   "name": "cfc-web",
-  "version": "1.0.916",
+  "version": "1.0.917",
   "private": true,
   "scripts": {
     "dev": "vue-cli-service serve",

+ 9 - 0
cfc-web/public/CHANGELOG-v1.0.md

@@ -4,6 +4,15 @@
 
 ---
 
+## v1.0.917 (2026-08-09)
+
+### 文档
+- 新增规划与设计文档 - 内部沟通/合伙人PPT/家庭挑战参与
+
+### Bug 修复
+- CouponService 改用显式 Logger 替代 @Slf4j,修复编译错误
+
+
 ## v1.0.916 (2026-08-09)
 
 ### Bug 修复

+ 10 - 1
cfc-web/public/CHANGELOG.md

@@ -1,6 +1,6 @@
 # 更新日志
 
-> 当前版本: v1.0.916
+> 当前版本: v1.0.917
 
 ## 历史版本
 
@@ -8,6 +8,15 @@
 
 ---
 
+## v1.0.917 (2026-08-09)
+
+### 文档
+- 新增规划与设计文档 - 内部沟通/合伙人PPT/家庭挑战参与
+
+### Bug 修复
+- CouponService 改用显式 Logger 替代 @Slf4j,修复编译错误
+
+
 ## v1.0.916 (2026-08-09)
 
 ### Bug 修复