From db5ea69bd9bfca00e72c3d8d3a80bb5db991c75d Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期二, 06 一月 2026 14:48:21 +0800
Subject: [PATCH] bug修改 全部代码提交

---
 cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java |   44 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java b/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java
index edef607..01cebc9 100644
--- a/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java
+++ b/cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java
@@ -754,8 +754,19 @@
                         coupon.setIntegral(BigDecimal.valueOf(dataVo.getRequiredPoints()));
                         break;
                     case 2:
-                        coupon.setIntegral(BigDecimal.valueOf(dataVo.getRequiredPoints()));
-                        coupon.setCash(dataVo.getRequiredCash());
+                        if (dataVo.getRequiredCash() != null){
+                            coupon.setCash(dataVo.getRequiredCash());
+                        }else{
+                            coupon.setCash(BigDecimal.ZERO);
+
+                        }
+                        if (dataVo.getRequiredPoints() != null){
+                            coupon.setIntegral(BigDecimal.valueOf(dataVo.getRequiredPoints()));
+
+                        }else{
+                            coupon.setIntegral(BigDecimal.ZERO);
+
+                        }
                         break;
                     case 3:
                         coupon.setCash(dataVo.getRequiredCash());
@@ -814,6 +825,7 @@
             Integer pickUpQuantity = dataVo.getPickUpQuantity();
             // 赠送用户数量
             int count = quantityIssued / pickUpQuantity;
+
             // 自动发券
             if (dataVo.getDistributionMethod() == 3) {
                 // 判断用户人群 再判断限领数量
@@ -823,6 +835,9 @@
                         // 全部用户ids
                         List<Integer> collect = tAppUsers.stream()
                                 .map(TAppUser::getId).collect(Collectors.toList());
+                        if (collect.size()<count){
+                            count = collect.size();
+                        }
                         for (int i = 0; i < count; i++) {
                             for (int j = 0; j < pickUpQuantity; j++) {
                                 UserCoupon u1 = new UserCoupon();
@@ -841,6 +856,9 @@
                         List<Integer> collect1 = tAppUsers.stream().filter(t -> t.getVipEndTime().after(new Date()))
                                 .map(TAppUser::getId)
                                 .collect(Collectors.toList());
+                        if (collect1.size()<count){
+                            count = collect1.size();
+                        }
                         for (int i = 0; i < count; i++) {
                             for (int j = 0; j < pickUpQuantity; j++) {
                                 UserCoupon u1 = new UserCoupon();
@@ -857,6 +875,9 @@
                     case 3:
                         // 给已有学员用户发券 获取已有学员的用户ids
                         List<Integer> collect2 = studentClient.getHasStudentUser();
+                        if (collect2.size()<count){
+                            count = collect2.size();
+                        }
                         for (int i = 0; i < count; i++) {
                             for (int j = 0; j < pickUpQuantity; j++) {
                                 UserCoupon u1 = new UserCoupon();
@@ -955,6 +976,25 @@
             VipDetail vipDetailServiceById = vipDetailService.getById(userCoupon.getVipDetailId());
             vipDetailServiceById.setUseTime(new Date());
             vipDetailServiceById.setStatus(2);
+            vipDetailServiceById.setOperatorId(0);
+            vipDetailService.updateById(vipDetailServiceById);
+        }
+
+    }
+    @GetMapping("/base/coupon/updateTypeOther/{id}/{operatorId}/{storeId}/{siteId}")
+    void updateTypeOther(@PathVariable("id")Long id,@PathVariable("operatorId")Integer operatorId,
+                         @PathVariable("storeId")Integer storeId,@PathVariable("siteId")Integer siteId){
+        couponService.updateType(id);
+        UserCoupon userCoupon = userCouponService.getById(id);
+        if (userCoupon.getIsVipGrant()!=null&& userCoupon.getIsVipGrant()==1){
+            VipDetail vipDetailServiceById = vipDetailService.getById(userCoupon.getVipDetailId());
+            vipDetailServiceById.setUseTime(new Date());
+            vipDetailServiceById.setStatus(2);
+            vipDetailServiceById.setOperatorId(operatorId);
+            vipDetailServiceById.setUseStoreId(storeId);
+            if (siteId!=0){
+                vipDetailServiceById.setUseSiteId(siteId);
+            }
             vipDetailService.updateById(vipDetailServiceById);
         }
 

--
Gitblit v1.7.1