فهرست منبع

回滚吴某某代码

lutong 2 ماه پیش
والد
کامیت
a0d100d83b

+ 6 - 6
alien-entity/src/main/java/shop/alien/entity/storePlatform/StoreOperationalActivity.java

@@ -55,7 +55,7 @@ public class StoreOperationalActivity {
     @TableField("activity_rule")
     private String activityRule;
 
-    @ApiModelProperty(value = "奖励类型:COUPON-优惠券, RED_PACKET-红包")
+    @ApiModelProperty(value = "奖励类型:COUPON-优惠券, RED_PACKET-红包, VOUCHER-代金券")
     @TableField("reward_type")
     private String rewardType;
 
@@ -63,15 +63,15 @@ public class StoreOperationalActivity {
     @TableField("coupon_id")
     private Integer couponId;
 
-//    @ApiModelProperty(value = "代金券ID,关联代金券表 life_coupon(评论有礼时可二选一或同时配置)")
-//    @TableField("voucher_id")
-//    private Integer voucherId;
+    @ApiModelProperty(value = "代金券ID,关联代金券表 life_coupon(评论有礼时可二选一或同时配置)")
+    @TableField("voucher_id")
+    private Integer voucherId;
 
     @ApiModelProperty(value = "优惠券发放数量")
     @TableField("coupon_quantity")
     private Integer couponQuantity;
 
-    @ApiModelProperty(value = "状态:1-待审核, 2-未开始, 3-审核拒绝, 4-已售罄, 5-进行中, 6-已下架, 7-已结束, 8-审核成功")
+    @ApiModelProperty(value = "状态:0-草稿, 1-待审核, 2-未开始, 3-审核拒绝, 4-已售罄, 5-进行中, 6-已下架, 7-已结束, 8-审核成功(2+手动下架)")
     @TableField("status")
     private Integer status;
 
@@ -82,7 +82,7 @@ public class StoreOperationalActivity {
 
     @ApiModelProperty(value = "创建时间")
     @TableField(value = "created_time", fill = FieldFill.INSERT)
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.S", timezone = "GMT+8")
     private Date createdTime;
 
     @ApiModelProperty(value = "创建人ID")

+ 14 - 2
alien-entity/src/main/resources/mapper/storePlatform/StoreOperationalActivityMapper.xml

@@ -14,7 +14,7 @@
         <result column="activity_rule" property="activityRule" />
         <result column="reward_type" property="rewardType" />
         <result column="coupon_id" property="couponId" />
-<!--        <result column="voucher_id" property="voucherId" />-->
+        <result column="voucher_id" property="voucherId" />
         <result column="coupon_quantity" property="couponQuantity" />
         <result column="status" property="status" />
         <result column="delete_flag" property="deleteFlag" />
@@ -22,11 +22,23 @@
         <result column="created_user_id" property="createdUserId" />
         <result column="updated_time" property="updatedTime" />
         <result column="updated_user_id" property="updatedUserId" />
+        <result column="approval_comments" property="approvalComments" />
+        <result column="activity_type" property="activityType" />
+        <result column="signup_start_time" property="signupStartTime" />
+        <result column="signup_end_time" property="signupEndTime" />
+        <result column="activity_limit_people" property="activityLimitPeople" />
+        <result column="activity_details" property="activityDetails" />
+        <result column="result_type" property="resultType" />
+        <result column="result_text" property="resultText" />
+        <result column="result_media_url" property="resultMediaUrl" />
+        <result column="audit_time" property="auditTime" />
+        <result column="upload_img_type" property="uploadImgType" />
+        <result column="audit_status" property="auditStatus" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, store_id, activity_name, promotional_image, start_time, end_time, participation_limit, activity_rule, reward_type, coupon_id, coupon_quantity, status, delete_flag, created_time, created_user_id, updated_time, updated_user_id
+        id, store_id, activity_name, promotional_image, start_time, end_time, participation_limit, activity_rule, reward_type, coupon_id, voucher_id, coupon_quantity, status, delete_flag, created_time, created_user_id, updated_time, updated_user_id, approval_comments, activity_type, signup_start_time, signup_end_time, activity_limit_people, activity_details, result_type, result_text, result_media_url, audit_time, upload_img_type, audit_status
     </sql>
 
 </mapper>

+ 1 - 1
alien-store/src/main/java/shop/alien/store/service/LifeDiscountCouponStoreFriendService.java

@@ -74,5 +74,5 @@ public interface LifeDiscountCouponStoreFriendService extends IService<LifeDisco
      * @param voucherId 代金券ID(life_coupon),为null则不发代金券
      * @return 发放数量(优惠券+代金券),0表示未发放
      */
-//    int issueCouponForGoodRating(Integer userId, Integer storeId);
+    int issueCouponForGoodRating(Integer userId, Integer storeId);
 }

+ 3 - 3
alien-store/src/main/java/shop/alien/store/service/impl/CommonRatingServiceImpl.java

@@ -237,9 +237,9 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
                             .orderByDesc(StoreOperationalActivity::getId)
                             .last("LIMIT 1");
                     StoreOperationalActivity activity = storeOperationalActivityMapper.selectOne(activityWrapper);
-//                    if (activity == null || (activity.getCouponId() == null && activity.getVoucherId() == null)) {
-//                        return;
-//                    }
+                    if (activity == null || (activity.getCouponId() == null && activity.getVoucherId() == null)) {
+                        return;
+                    }
                     Integer limit = activity.getParticipationLimit();
                     if (limit != null && limit > 0) {
                         int passedCount = commonRatingMapper.countPassedGoodRatingsByUserAndStore(commonRating.getUserId(), businessId);

+ 131 - 98
alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponStoreFriendServiceImpl.java

@@ -15,7 +15,9 @@ import org.springframework.stereotype.Service;
 import shop.alien.entity.store.*;
 import shop.alien.entity.store.dto.LifeDiscountCouponStoreFriendDto;
 import shop.alien.entity.store.vo.*;
+import shop.alien.entity.storePlatform.StoreOperationalActivity;
 import shop.alien.mapper.*;
+import shop.alien.mapper.storePlantform.StoreOperationalActivityMapper;
 import shop.alien.store.config.WebSocketProcess;
 import shop.alien.store.service.LifeDiscountCouponStoreFriendService;
 import shop.alien.util.common.constant.DiscountCouponEnum;
@@ -71,6 +73,8 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
 
     private final WebSocketProcess webSocketProcess;
 
+    private final StoreOperationalActivityMapper storeOperationalActivityMapper;
+
     @Override
     public List<LifeDiscountCouponStoreFriendVo> getFriendCouponList(UserLoginInfo userLoginInfo, String friendUserId) {
         List<LifeDiscountCouponStoreFriendVo> result = new ArrayList<>();
@@ -145,7 +149,7 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
                 return true;
             }
             for (LifeDiscountCouponStoreFriendDto couponDto : coupons) {
-                if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(couponDto.getVoucherId())) {
+                if (StringUtils.isNotEmpty(couponDto.getVoucherId())) {
                     // 代金券:入参为 voucherId,对应 life_coupon 表
                     if (!handleVoucherFriendCoupon(userLoginInfo, lifeDiscountCouponStoreFriendDto, couponDto)) {
                         return false;
@@ -425,7 +429,7 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
                 lifeNotice.setReceiverId("user_" + lifeUser.getUserPhone());
                 //存入信息
                 String text = storeInfo.getStoreName() + "赠送了您他的好友店铺优惠券,快去我的券包查看吧~";
-                com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject();
+                JSONObject jsonObject = new JSONObject();
                 jsonObject.put("message", text);
                 lifeNotice.setContext(jsonObject.toJSONString());
                 //存入类型
@@ -649,102 +653,131 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
     }
 
     /**
+     * 好评送券:用户好评且AI审核通过后,按运营活动配置的优惠券/代金券ID发放到用户券包,发放成功后扣减库存;按券类型发送对应通知。
+     *
+     * @param userId  评价用户ID(life用户)
+     * @param storeId 店铺ID(businessId)
+     * @return 发放数量(优惠券+代金券),0表示未发放
+     */
+    @Override
+    public int issueCouponForGoodRating(Integer userId, Integer storeId) {
+        if (userId == null || storeId == null) {
+            return 0;
+        }
+        // 查询运营活动配置(评论有礼)
+        Date now = new Date();
+        LambdaQueryWrapper<StoreOperationalActivity> activityWrapper = new LambdaQueryWrapper<>();
+        activityWrapper.eq(StoreOperationalActivity::getStoreId, storeId)
+                .eq(StoreOperationalActivity::getActivityType, "COMMENT")
+                .in(StoreOperationalActivity::getStatus, 5, 8)
+                .le(StoreOperationalActivity::getStartTime, now)
+                .ge(StoreOperationalActivity::getEndTime, now)
+                .orderByDesc(StoreOperationalActivity::getId)
+                .last("LIMIT 1");
+        StoreOperationalActivity activity = storeOperationalActivityMapper.selectOne(activityWrapper);
+        if (activity == null || (activity.getCouponId() == null && activity.getVoucherId() == null)) {
+            return 0;
+        }
+        // 调用4参数方法进行发放
+        return issueCouponForGoodRating(userId, storeId, activity.getCouponId(), activity.getVoucherId());
+    }
+
+    /**
      * 好评送券:按优惠券/代金券ID发放到用户券包,发放成功后扣减库存;根据是优惠券还是代金券发送对应通知。
      */
-//    @Override
-//    public int issueCouponForGoodRating(Integer userId, Integer storeId, Integer couponId, Integer voucherId) {
-//        if (userId == null || storeId == null) {
-//            return 0;
-//        }
-//        if ((couponId == null || couponId <= 0) && (voucherId == null || voucherId <= 0)) {
-//            return 0;
-//        }
-//        int commenterUserId = userId.intValue();
-//        StoreInfo storeInfo = storeInfoMapper.selectById(storeId);
-//        LifeUser lifeUser = lifeUserMapper.selectById(commenterUserId);
-//        int grantedCoupon = 0;
-//        int grantedVoucher = 0;
-//
-//        // 按优惠券ID发放:发放1张,扣减库存,发优惠券通知
-//        if (couponId != null && couponId > 0) {
-//            LifeDiscountCoupon coupon = lifeDiscountCouponMapper.selectById(couponId);
-//            if (coupon != null && String.valueOf(storeId).equals(coupon.getStoreId())
-//                    && coupon.getSingleQty() != null && coupon.getSingleQty() > 0) {
-//                try {
-//                    LifeDiscountCouponUser lifeDiscountCouponUser = new LifeDiscountCouponUser();
-//                    lifeDiscountCouponUser.setCouponId(coupon.getId());
-//                    lifeDiscountCouponUser.setUserId(commenterUserId);
-//                    lifeDiscountCouponUser.setReceiveTime(new Date());
-//                    lifeDiscountCouponUser.setExpirationTime(coupon.getValidDate());
-//                    lifeDiscountCouponUser.setStatus(Integer.parseInt(DiscountCouponEnum.WAITING_USED.getValue()));
-//                    lifeDiscountCouponUser.setDeleteFlag(0);
-//                    lifeDiscountCouponUserMapper.insert(lifeDiscountCouponUser);
-//                    coupon.setSingleQty(coupon.getSingleQty() - 1);
-//                    lifeDiscountCouponMapper.updateById(coupon);
-//                    grantedCoupon = 1;
-//                } catch (Exception e) {
-//
-//                }
-//            }
-//        }
-//
-//        // 按代金券ID发放:发放1张,扣减库存,发代金券通知
-//        if (voucherId != null && voucherId > 0) {
-//            LifeCoupon lifeCoupon = lifeCouponMapper.selectById(voucherId);
-//            if (lifeCoupon != null && String.valueOf(storeId).equals(lifeCoupon.getStoreId())
-//                    && lifeCoupon.getSingleQty() != null && lifeCoupon.getSingleQty() > 0) {
-//                try {
-//                    LifeDiscountCouponUser lifeDiscountCouponUser = new LifeDiscountCouponUser();
-//                    lifeDiscountCouponUser.setVoucherId(lifeCoupon.getId());
-//                    lifeDiscountCouponUser.setUserId(commenterUserId);
-//                    lifeDiscountCouponUser.setReceiveTime(new Date());
-//                    if (lifeCoupon.getEndDate() != null) {
-//                        lifeDiscountCouponUser.setExpirationTime(lifeCoupon.getEndDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
-//                    }
-//                    lifeDiscountCouponUser.setStatus(Integer.parseInt(DiscountCouponEnum.WAITING_USED.getValue()));
-//                    lifeDiscountCouponUser.setDeleteFlag(0);
-//                    lifeDiscountCouponUserMapper.insert(lifeDiscountCouponUser);
-//                    lifeCoupon.setSingleQty(lifeCoupon.getSingleQty() - 1);
-//                    lifeCouponMapper.updateById(lifeCoupon);
-//                    grantedVoucher = 1;
-//                } catch (Exception e) {
-//
-//                }
-//            }
-//        }
-//
-//        // 根据发放的是优惠券还是代金券发送对应通知
-//        if (lifeUser != null && storeInfo != null) {
-//            if (grantedCoupon > 0) {
-//                LifeNotice couponNotice = new LifeNotice();
-//                couponNotice.setSenderId("system");
-//                couponNotice.setReceiverId("user_" + lifeUser.getUserPhone());
-//                String couponText = "您对店铺「" + storeInfo.getStoreName() + "」的好评已通过审核,已为您发放优惠券,快去我的券包查看吧~";
-//                JSONObject couponJson = new JSONObject();
-//                couponJson.put("message", couponText);
-//                couponNotice.setContext(couponJson.toJSONString());
-//                couponNotice.setNoticeType(1);
-//                couponNotice.setTitle("好评送券");
-//                couponNotice.setIsRead(0);
-//                couponNotice.setDeleteFlag(0);
-//                lifeNoticeMapper.insert(couponNotice);
-//            }
-//            if (grantedVoucher > 0) {
-//                LifeNotice voucherNotice = new LifeNotice();
-//                voucherNotice.setSenderId("system");
-//                voucherNotice.setReceiverId("user_" + lifeUser.getUserPhone());
-//                String voucherText = "您对店铺「" + storeInfo.getStoreName() + "」的好评已通过审核,已为您发放代金券,快去我的券包查看吧~";
-//                JSONObject voucherJson = new JSONObject();
-//                voucherJson.put("message", voucherText);
-//                voucherNotice.setContext(voucherJson.toJSONString());
-//                voucherNotice.setNoticeType(1);
-//                voucherNotice.setTitle("好评送代金券");
-//                voucherNotice.setIsRead(0);
-//                voucherNotice.setDeleteFlag(0);
-//                lifeNoticeMapper.insert(voucherNotice);
-//            }
-//        }
-//
-//        return grantedCoupon + grantedVoucher;
-//    }
+    public int issueCouponForGoodRating(Integer userId, Integer storeId, Integer couponId, Integer voucherId) {
+        if (userId == null || storeId == null) {
+            return 0;
+        }
+        if ((couponId == null || couponId <= 0) && (voucherId == null || voucherId <= 0)) {
+            return 0;
+        }
+        int commenterUserId = userId.intValue();
+        StoreInfo storeInfo = storeInfoMapper.selectById(storeId);
+        LifeUser lifeUser = lifeUserMapper.selectById(commenterUserId);
+        int grantedCoupon = 0;
+        int grantedVoucher = 0;
+
+        // 按优惠券ID发放:发放1张,扣减库存,发优惠券通知
+        if (couponId != null && couponId > 0) {
+            LifeDiscountCoupon coupon = lifeDiscountCouponMapper.selectById(couponId);
+            if (coupon != null && String.valueOf(storeId).equals(coupon.getStoreId())
+                    && coupon.getSingleQty() != null && coupon.getSingleQty() > 0) {
+                try {
+                    LifeDiscountCouponUser lifeDiscountCouponUser = new LifeDiscountCouponUser();
+                    lifeDiscountCouponUser.setCouponId(coupon.getId());
+                    lifeDiscountCouponUser.setUserId(commenterUserId);
+                    lifeDiscountCouponUser.setReceiveTime(new Date());
+                    lifeDiscountCouponUser.setExpirationTime(coupon.getValidDate());
+                    lifeDiscountCouponUser.setStatus(Integer.parseInt(DiscountCouponEnum.WAITING_USED.getValue()));
+                    lifeDiscountCouponUser.setDeleteFlag(0);
+                    lifeDiscountCouponUserMapper.insert(lifeDiscountCouponUser);
+                    coupon.setSingleQty(coupon.getSingleQty() - 1);
+                    lifeDiscountCouponMapper.updateById(coupon);
+                    grantedCoupon = 1;
+                } catch (Exception e) {
+
+                }
+            }
+        }
+
+        // 按代金券ID发放:发放1张,扣减库存,发代金券通知
+        if (voucherId != null && voucherId > 0) {
+            LifeCoupon lifeCoupon = lifeCouponMapper.selectById(voucherId);
+            if (lifeCoupon != null && String.valueOf(storeId).equals(lifeCoupon.getStoreId())
+                    && lifeCoupon.getSingleQty() != null && lifeCoupon.getSingleQty() > 0) {
+                try {
+                    LifeDiscountCouponUser lifeDiscountCouponUser = new LifeDiscountCouponUser();
+                    lifeDiscountCouponUser.setVoucherId(lifeCoupon.getId());
+                    lifeDiscountCouponUser.setUserId(commenterUserId);
+                    lifeDiscountCouponUser.setReceiveTime(new Date());
+                    if (lifeCoupon.getEndDate() != null) {
+                        lifeDiscountCouponUser.setExpirationTime(lifeCoupon.getEndDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
+                    }
+                    lifeDiscountCouponUser.setStatus(Integer.parseInt(DiscountCouponEnum.WAITING_USED.getValue()));
+                    lifeDiscountCouponUser.setDeleteFlag(0);
+                    lifeDiscountCouponUserMapper.insert(lifeDiscountCouponUser);
+                    lifeCoupon.setSingleQty(lifeCoupon.getSingleQty() - 1);
+                    lifeCouponMapper.updateById(lifeCoupon);
+                    grantedVoucher = 1;
+                } catch (Exception e) {
+
+                }
+            }
+        }
+
+        // 根据发放的是优惠券还是代金券发送对应通知
+        if (lifeUser != null && storeInfo != null) {
+            if (grantedCoupon > 0) {
+                LifeNotice couponNotice = new LifeNotice();
+                couponNotice.setSenderId("system");
+                couponNotice.setReceiverId("user_" + lifeUser.getUserPhone());
+                String couponText = "您对店铺「" + storeInfo.getStoreName() + "」的好评已通过审核,已为您发放优惠券,快去我的券包查看吧~";
+                JSONObject couponJson = new JSONObject();
+                couponJson.put("message", couponText);
+                couponNotice.setContext(couponJson.toJSONString());
+                couponNotice.setNoticeType(1);
+                couponNotice.setTitle("好评送券");
+                couponNotice.setIsRead(0);
+                couponNotice.setDeleteFlag(0);
+                lifeNoticeMapper.insert(couponNotice);
+            }
+            if (grantedVoucher > 0) {
+                LifeNotice voucherNotice = new LifeNotice();
+                voucherNotice.setSenderId("system");
+                voucherNotice.setReceiverId("user_" + lifeUser.getUserPhone());
+                String voucherText = "您对店铺「" + storeInfo.getStoreName() + "」的好评已通过审核,已为您发放代金券,快去我的券包查看吧~";
+                JSONObject voucherJson = new JSONObject();
+                voucherJson.put("message", voucherText);
+                voucherNotice.setContext(voucherJson.toJSONString());
+                voucherNotice.setNoticeType(1);
+                voucherNotice.setTitle("好评送代金券");
+                voucherNotice.setIsRead(0);
+                voucherNotice.setDeleteFlag(0);
+                lifeNoticeMapper.insert(voucherNotice);
+            }
+        }
+
+        return grantedCoupon + grantedVoucher;
+    }
 }