소스 검색

优惠券相关代码

zyy 1 개월 전
부모
커밋
86c86362c7
16개의 변경된 파일380개의 추가작업 그리고 140개의 파일을 삭제
  1. 5 0
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreCouponIssueScrmController.java
  2. 5 3
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreCouponScrmController.java
  3. 4 0
      fs-service/src/main/java/com/fs/hisStore/domain/FsStoreCouponIssueScrm.java
  4. 13 0
      fs-service/src/main/java/com/fs/hisStore/domain/FsStoreCouponScrm.java
  5. 7 108
      fs-service/src/main/java/com/fs/hisStore/domain/FsStoreCouponUserScrm.java
  6. 36 27
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreCouponIssueScrmMapper.java
  7. 5 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreCouponIssueUserScrmMapper.java
  8. 10 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStoreCouponPublishParam.java
  9. 5 0
      fs-service/src/main/java/com/fs/hisStore/service/IFsStoreCouponIssueScrmService.java
  10. 94 0
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreCouponIssueScrmServiceImpl.java
  11. 7 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreCouponIssueVO.java
  12. 11 0
      fs-service/src/main/java/com/fs/hisStore/vo/ReceiveCouponDto.java
  13. 68 1
      fs-service/src/main/resources/mapper/hisStore/FsStoreCouponIssueScrmMapper.xml
  14. 7 1
      fs-service/src/main/resources/mapper/hisStore/FsStoreCouponIssueUserScrmMapper.xml
  15. 2 0
      fs-service/src/main/resources/mapper/hisStore/FsStoreCouponScrmMapper.xml
  16. 101 0
      fs-user-app/src/main/java/com/fs/app/controller/store/FsStoreCouponScrmController.java

+ 5 - 0
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreCouponIssueScrmController.java

@@ -95,4 +95,9 @@ public class FsStoreCouponIssueScrmController extends BaseController
     {
         return toAjax(fsStoreCouponIssueService.deleteFsStoreCouponIssueByIds(ids));
     }
+
+    /**
+     *  用户领取优惠券
+     */
+
 }

+ 5 - 3
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreCouponScrmController.java

@@ -134,9 +134,11 @@ public class FsStoreCouponScrmController extends BaseController
             issue.setCouponType(coupon.getType());
             issue.setStartTime(publishParam.getStartTime());
             issue.setLimitTime(publishParam.getLimitTime());
-            issue.setTotalCount(publishParam.getTotalCount());
-            issue.setRemainCount(0);
-            issue.setIsPermanent(0);
+            issue.setIsPermanent(publishParam.getIsPermanent());
+            if (publishParam.getIsPermanent()==0){
+                issue.setTotalCount(publishParam.getTotalCount());
+                issue.setRemainCount(publishParam.getTotalCount());
+            }
             issue.setStatus(1);
             issue.setCreateTime(new Date());
             fsStoreCouponIssueService.insertFsStoreCouponIssue(issue);

+ 4 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreCouponIssueScrm.java

@@ -5,6 +5,7 @@ import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
 
 /**
  * 优惠券领取对象 fs_store_coupon_issue
@@ -12,6 +13,7 @@ import com.fs.common.core.domain.BaseEntity;
  * @author fs
  * @date 2022-03-15
  */
+@Data
 public class FsStoreCouponIssueScrm extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -56,6 +58,8 @@ public class FsStoreCouponIssueScrm extends BaseEntity
     @Excel(name = "1 正常 0 未开启 -1 已无效")
     private Integer status;
 
+    private Long userId;
+
     /** $column.columnComment */
     @Excel(name = "1 正常 0 未开启 -1 已无效")
     private Integer isDel;

+ 13 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreCouponScrm.java

@@ -62,6 +62,10 @@ public class FsStoreCouponScrm extends BaseEntity
     @Excel(name = "是否删除")
     private Integer isDel;
 
+    /** 普通券种类:0无门槛 1指定商品 2满减 */
+    @Excel(name = "普通券种类", readConverterExp = "0=无门槛,1=指定商品,2=满减")
+    private Integer couponSubType;
+
     public String getPackageCateIds() {
         return packageCateIds;
     }
@@ -170,6 +174,14 @@ public class FsStoreCouponScrm extends BaseEntity
         return isDel;
     }
 
+    public Integer getCouponSubType() {
+        return couponSubType;
+    }
+
+    public void setCouponSubType(Integer couponSubType) {
+        this.couponSubType = couponSubType;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -186,6 +198,7 @@ public class FsStoreCouponScrm extends BaseEntity
             .append("createTime", getCreateTime())
             .append("updateTime", getUpdateTime())
             .append("isDel", getIsDel())
+            .append("couponSubType", getCouponSubType())
             .toString();
     }
 }

+ 7 - 108
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreCouponUserScrm.java

@@ -5,6 +5,7 @@ import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
 
 /**
  * 优惠券发放记录对象 fs_store_coupon_user
@@ -12,6 +13,7 @@ import com.fs.common.core.domain.BaseEntity;
  * @author fs
  * @date 2022-03-15
  */
+@Data
 public class FsStoreCouponUserScrm extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -65,114 +67,11 @@ public class FsStoreCouponUserScrm extends BaseEntity
     @Excel(name = "是否有效")
     private Integer isDel;
 
-    public void setId(Long id) 
-    {
-        this.id = id;
-    }
-
-    public Long getId() 
-    {
-        return id;
-    }
-    public void setCouponId(Long couponId) 
-    {
-        this.couponId = couponId;
-    }
-
-    public Long getCouponId() 
-    {
-        return couponId;
-    }
-    public void setUserId(Long userId) 
-    {
-        this.userId = userId;
-    }
-
-    public Long getUserId() 
-    {
-        return userId;
-    }
-    public void setCouponTitle(String couponTitle) 
-    {
-        this.couponTitle = couponTitle;
-    }
-
-    public String getCouponTitle() 
-    {
-        return couponTitle;
-    }
-    public void setCouponPrice(BigDecimal couponPrice) 
-    {
-        this.couponPrice = couponPrice;
-    }
-
-    public BigDecimal getCouponPrice() 
-    {
-        return couponPrice;
-    }
-    public void setUseMinPrice(BigDecimal useMinPrice) 
-    {
-        this.useMinPrice = useMinPrice;
-    }
-
-    public BigDecimal getUseMinPrice() 
-    {
-        return useMinPrice;
-    }
-
-    public Date getLimitTime() {
-        return limitTime;
-    }
-
-    public void setLimitTime(Date limitTime) {
-        this.limitTime = limitTime;
-    }
-
-    public void setUseTime(Date useTime)
-    {
-        this.useTime = useTime;
-    }
-
-    public Date getUseTime() 
-    {
-        return useTime;
-    }
-    public void setType(String type) 
-    {
-        this.type = type;
-    }
-
-    public String getType() 
-    {
-        return type;
-    }
-    public void setStatus(Integer status) 
-    {
-        this.status = status;
-    }
-
-    public Integer getStatus() 
-    {
-        return status;
-    }
-    public void setIsFail(Integer isFail) 
-    {
-        this.isFail = isFail;
-    }
-
-    public Integer getIsFail() 
-    {
-        return isFail;
-    }
-    public void setIsDel(Integer isDel) 
-    {
-        this.isDel = isDel;
-    }
-
-    public Integer getIsDel() 
-    {
-        return isDel;
-    }
+    /**
+     * 优惠券到期时间
+     * @param id
+     */
+    private Date expireTime;
 
 
 }

+ 36 - 27
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreCouponIssueScrmMapper.java

@@ -108,31 +108,40 @@ public interface FsStoreCouponIssueScrmMapper
             "where i.id=#{id}  order by c.coupon_price desc " +
             "</script>"})
     FsStoreCouponIssueVO selectFsStoreCouponIssueVOById(Long id);
-    @Select({"<script> " +
-            "select i.*,c.coupon_price,c.use_min_price,c.coupon_time  from fs_store_coupon_issue_scrm i left join fs_store_coupon_scrm c on c.coupon_id=i.coupon_id  " +
-            "where i.limit_time &gt; now() " +
-            "<if test = 'maps.isDel != null     '> " +
-            "and i.is_del =#{maps.isDel} " +
-            "</if>" +
-            "<if test = 'maps.status != null     '> " +
-            "and i.status =#{maps.status} " +
-            "</if>" +
-            "<if test = 'maps.couponType != null     '> " +
-            "and i.coupon_type =#{maps.couponType} " +
-            "</if>" +
-            "<if test = 'maps.couponPrice != null     '> " +
-            "and c.coupon_price =#{maps.couponPrice} " +
-            "</if>" +
-            "<if test = 'maps.couponName != null and  maps.couponName !=\"\"     '> " +
-            "and i.coupon_name like CONCAT('%',#{maps.couponName},'%') " +
-            "</if>" +
-            "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
-            "and date_format(i.create_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d') " +
-            "</if>" +
-            "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
-            "and date_format(i.create_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
-            "</if>" +
-            " order by c.coupon_price "+
-            "</script>"})
-    List<FsStoreCouponIssueVO> selectFsStoreCouponIssueListVO(@Param("maps") FsStoreCouponIssueScrm fsStoreCouponIssue);
+//    @Select({"<script> " +
+//            "select i.*,c.coupon_price,c.use_min_price,c.coupon_time,c.product_ids  from fs_store_coupon_issue_scrm i left join fs_store_coupon_scrm c on c.coupon_id=i.coupon_id  " +
+//            "where i.limit_time &gt; now() " +
+//            "<if test = 'maps.isDel != null     '> " +
+//            "and i.is_del =#{maps.isDel} " +
+//            "</if>" +
+//            "<if test = 'maps.status != null     '> " +
+//            "and i.status =#{maps.status} " +
+//            "</if>" +
+//            "<if test = 'maps.couponType != null     '> " +
+//            "and i.coupon_type =#{maps.couponType} " +
+//            "</if>" +
+//            "<if test = 'maps.couponPrice != null     '> " +
+//            "and c.coupon_price =#{maps.couponPrice} " +
+//            "</if>" +
+//            "<if test = 'maps.couponName != null and  maps.couponName !=\"\"     '> " +
+//            "and i.coupon_name like CONCAT('%',#{maps.couponName},'%') " +
+//            "</if>" +
+//            "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
+//            "and date_format(i.create_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d') " +
+//            "</if>" +
+//            "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
+//            "and date_format(i.create_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
+//            "</if>" +
+//            " order by c.coupon_price "+
+//            "</script>"})
+//    List<FsStoreCouponIssueVO> selectFsStoreCouponIssueListVO(@Param("maps") FsStoreCouponIssueScrm fsStoreCouponIssue);
+
+    List<FsStoreCouponIssueVO> selectFsStoreCouponIssueListVO(
+            @Param("maps") FsStoreCouponIssueScrm fsStoreCouponIssue
+    );
+
+    /**
+     * 扣减优惠券库存,防止超发
+     */
+    int deductRemainCount(@Param("issueId") Long issueId);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreCouponIssueUserScrmMapper.java

@@ -62,4 +62,9 @@ public interface FsStoreCouponIssueUserScrmMapper
     public int deleteFsStoreCouponIssueUserByIds(Long[] ids);
     @Select("select ifnull(count(1),0) from fs_store_coupon_issue_user_scrm where user_id=#{userId} and issue_id=#{id} ")
     int checkReceive(@Param("userId") String userId,@Param("id") Long id);
+
+    /**
+     *  校验用户是否领取过当前优惠券
+     */
+    int countUserReceived(@Param("userId") Long userId, @Param("issueId") Long issueId);
 }

+ 10 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreCouponPublishParam.java

@@ -22,5 +22,15 @@ public class FsStoreCouponPublishParam implements Serializable
 
     private String ids;
 
+    /**
+     * 是否无限张数(0.否 1.是)
+     */
+    private Integer isPermanent;
+
+    /**
+     * 优惠券类型(1.用户领取的券,2.平台发放的券)
+     */
+    private Integer couponType;
+
 
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreCouponIssueScrmService.java

@@ -76,4 +76,9 @@ public interface IFsStoreCouponIssueScrmService
     List<FsStoreCouponIssueVO> selectFsStoreCouponIssueListVO(FsStoreCouponIssueScrm fsStoreCouponIssue);
 
     R sendFsUserCoupon(FsUserCouponScrmSendParam param);
+
+    /**
+     * 用户领取优惠券
+     */
+    R receiveCoupon(Long issueId, Long userId);
 }

+ 94 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreCouponIssueScrmServiceImpl.java

@@ -7,6 +7,7 @@ import java.util.List;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.CustomException;
+import com.fs.common.exception.ServiceException;
 import com.fs.common.utils.DateUtils;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.mapper.*;
@@ -235,4 +236,97 @@ public class FsStoreCouponIssueScrmServiceImpl implements IFsStoreCouponIssueScr
     }
 
 
+
+    /**
+     * 用户领取优惠券
+     *
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R receiveCoupon(Long issueId, Long userId) {
+        if (issueId == null) {
+            throw new CustomException("优惠券发布ID不能为空");
+        }
+        if (userId == null) {
+            throw new CustomException("用户ID不能为空");
+        }
+
+        // 1. 查询发布详情和优惠券模板
+        FsStoreCouponIssueScrm issue = fsStoreCouponIssueMapper.selectFsStoreCouponIssueById(issueId);
+        if (issue == null) {
+            throw new CustomException("优惠券不存在");
+        }
+        if(issue.getStatus().equals(0)){
+            return R.error("此优惠券已停止领取");
+        }
+
+        Date now = new Date();
+
+        // 2. 校验领取时间
+        if (issue.getStartTime() != null && now.before(issue.getStartTime())) {
+            throw new CustomException("优惠券领取未开始");
+        }
+
+        if (issue.getLimitTime() != null && now.after(issue.getLimitTime())) {
+            throw new CustomException("优惠券领取已结束");
+        }
+
+        // 3. 校验是否已领取
+        int receivedCount = fsStoreCouponIssueUserMapper.countUserReceived(userId, issueId);
+        if (receivedCount > 0) {
+            throw new CustomException("您已经领取过该优惠券");
+        }
+
+         //4. 非无限张数,需要扣减库存
+        if (issue.getIsPermanent() == null || issue.getIsPermanent() != 1) {
+            int deductRows = fsStoreCouponIssueMapper.deductRemainCount(issueId);
+
+            if (deductRows <= 0) {
+                throw new CustomException("优惠券已领完");
+            }
+        }
+
+         //5. 插入领取记录
+        try {
+            FsStoreCouponIssueUserScrm couponIssueUser = new FsStoreCouponIssueUserScrm();
+            couponIssueUser.setUserId(userId);
+            couponIssueUser.setIssueId(issueId);
+            couponIssueUser.setCreateTime(new Date());
+            couponIssueUser.setIsDel(0);
+            fsStoreCouponIssueUserMapper.insertFsStoreCouponIssueUser(couponIssueUser);
+        } catch (Exception e) {
+            throw new CustomException("插入领取记录失败");
+        }
+
+        // 6. 计算用户优惠券有效期
+//        Date userCouponLimitTime = buildUserCouponLimitTime(issue.getCouponTime());
+
+        // 7. 插入用户实际可用优惠券
+//        couponReceiveMapper.insertUserCoupon(
+//                issue,
+//                userId,
+//                userCouponLimitTime,
+//                "receive"
+//        );
+
+        FsStoreCouponScrm coupon=couponMapper.selectFsStoreCouponById(issue.getCouponId());
+        FsStoreCouponUserScrm couponUser=new FsStoreCouponUserScrm();
+        couponUser.setCouponId(issue.getCouponId());
+        couponUser.setUserId(userId);
+        couponUser.setCouponTitle(issue.getCouponName());
+        couponUser.setCouponPrice(coupon.getCouponPrice());
+        couponUser.setUseMinPrice(coupon.getUseMinPrice());
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        calendar.add(Calendar.DATE,coupon.getCouponTime().intValue());
+        couponUser.setLimitTime(calendar.getTime());
+        couponUser.setCreateTime(new Date());
+        couponUser.setType("Claim");
+        couponUser.setStatus(0);
+        fsStoreCouponUserMapper.insertFsStoreCouponUser(couponUser);
+
+
+//
+        return R.ok("领取成功");
+    }
 }

+ 7 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreCouponIssueVO.java

@@ -43,6 +43,13 @@ public class FsStoreCouponIssueVO implements Serializable
 
     private Integer isDel;
 
+    /**
+     * 适用商品
+     */
+    private String productIds;
+
+    private Integer receiveStatus;
+
     private Integer receiveCount;
 
     private BigDecimal couponPrice;

+ 11 - 0
fs-service/src/main/java/com/fs/hisStore/vo/ReceiveCouponDto.java

@@ -0,0 +1,11 @@
+package com.fs.hisStore.vo;
+
+import lombok.Data;
+
+@Data
+public class ReceiveCouponDto {
+
+    private Long userId;
+
+    private Long issueId;
+}

+ 68 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreCouponIssueScrmMapper.xml

@@ -45,7 +45,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectFsStoreCouponIssueVo"/>
         where id = #{id}
     </select>
-        
+    <select id="selectFsStoreCouponIssueListVO"
+            resultType="com.fs.hisStore.vo.FsStoreCouponIssueVO">
+
+        select
+        i.*,
+        c.coupon_price,
+        c.use_min_price,
+        c.coupon_time,
+        c.product_ids,
+        case
+        when iu.id is not null then 1
+        else 0
+        end as receiveStatus
+        from fs_store_coupon_issue_scrm i
+        left join fs_store_coupon_scrm c
+        on c.coupon_id = i.coupon_id
+        left join fs_store_coupon_issue_user_scrm iu
+        on iu.issue_id = i.id
+        and iu.user_id = #{maps.userId}
+        and iu.is_del = 0
+
+        <where>
+            i.limit_time &gt; now()
+
+            <if test="maps.isDel != null">
+                and i.is_del = #{maps.isDel}
+            </if>
+
+            <if test="maps.status != null">
+                and i.status = #{maps.status}
+            </if>
+
+            <if test="maps.couponType != null">
+                and i.coupon_type = #{maps.couponType}
+            </if>
+
+            <if test="maps.couponPrice != null">
+                and c.coupon_price = #{maps.couponPrice}
+            </if>
+
+            <if test="maps.couponName != null and maps.couponName != ''">
+                and i.coupon_name like concat('%', #{maps.couponName}, '%')
+            </if>
+
+            <if test="maps.beginTime != null and maps.beginTime != ''">
+                and date_format(i.create_time, '%y%m%d') &gt;= date_format(#{maps.beginTime}, '%y%m%d')
+            </if>
+
+            <if test="maps.endTime != null and maps.endTime != ''">
+                and date_format(i.create_time, '%y%m%d') &lt;= date_format(#{maps.endTime}, '%y%m%d')
+            </if>
+        </where>
+
+        order by c.coupon_price
+
+    </select>
+
     <insert id="insertFsStoreCouponIssue" parameterType="FsStoreCouponIssueScrm" useGeneratedKeys="true" keyProperty="id">
         insert into fs_store_coupon_issue_scrm
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -107,5 +163,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <!-- 原子扣减库存,防止超发 -->
+    <update id="deductRemainCount">
+        update fs_store_coupon_issue_scrm
+        set remain_count = remain_count - 1,
+            update_time = now()
+        where id = #{issueId}
+          and status = 1
+          and is_del = 0
+          and remain_count > 0
+    </update>
     
 </mapper>

+ 7 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreCouponIssueUserScrmMapper.xml

@@ -30,7 +30,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectFsStoreCouponIssueUserVo"/>
         where id = #{id}
     </select>
-        
+    <select id="countUserReceived" resultType="java.lang.Integer">
+        select count(1) from fs_store_coupon_issue_user_scrm
+          where issue_id = #{issueId}
+          and issue_id = #{issueId}
+          and is_del = 0
+    </select>
+
     <insert id="insertFsStoreCouponIssueUser" parameterType="FsStoreCouponIssueUserScrm" useGeneratedKeys="true" keyProperty="id">
         insert into fs_store_coupon_issue_user_scrm
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 2 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreCouponScrmMapper.xml

@@ -73,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="isDel != null">is_del,</if>
+            <if test="couponSubType != null">coupon_sub_type,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="title != null and title != ''">#{title},</if>
@@ -88,6 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">#{createTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="isDel != null">#{isDel},</if>
+            <if test="couponSubType != null">#{couponSubType},</if>
          </trim>
     </insert>
 

+ 101 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/FsStoreCouponScrmController.java

@@ -0,0 +1,101 @@
+package com.fs.app.controller.store;
+
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.domain.R;
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.hisStore.domain.FsStoreCouponIssueScrm;
+import com.fs.hisStore.domain.FsStoreCouponScrm;
+import com.fs.hisStore.param.FsStoreCouponPublishParam;
+import com.fs.hisStore.service.IFsStoreCouponIssueScrmService;
+import com.fs.hisStore.service.IFsStoreCouponScrmService;
+import com.fs.hisStore.vo.FsStoreCouponIssueVO;
+import com.fs.hisStore.vo.ReceiveCouponDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.token.TokenService;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 优惠券Controller
+ *
+ * @author fs
+ * @date 2022-03-15
+ */
+@RestController
+@RequestMapping("/store/storeCoupon")
+public class FsStoreCouponScrmController extends BaseController
+{
+    @Autowired
+    private IFsStoreCouponScrmService fsStoreCouponService;
+    @Autowired
+    private IFsStoreCouponIssueScrmService fsStoreCouponIssueService;
+
+//    /**
+//     * 查询优惠券列表
+//     */
+//    @PreAuthorize("@ss.hasPermi('store:storeCoupon:list')")
+//    @GetMapping("/list")
+//    public TableDataInfo list(FsStoreCouponScrm fsStoreCoupon)
+//    {
+//        startPage();
+//        fsStoreCoupon.setIsDel(0);
+//        List<FsStoreCouponScrm> list = fsStoreCouponService.selectFsStoreCouponList(fsStoreCoupon);
+//        return getDataTable(list);
+//    }
+
+    /**
+     * 查询优惠券领取列表
+     */
+//    @PreAuthorize("@ss.hasPermi('store:storeCouponIssue:list')")
+    @PostMapping("/list")
+    public TableDataInfo list(@RequestBody FsStoreCouponIssueScrm fsStoreCouponIssue)
+    {
+        startPage();
+        List<FsStoreCouponIssueVO> list = fsStoreCouponIssueService.selectFsStoreCouponIssueListVO(fsStoreCouponIssue);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 获取优惠券领取详细信息
+     */
+//    @PreAuthorize("@ss.hasPermi('store:storeCouponIssue:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(fsStoreCouponIssueService.selectFsStoreCouponIssueById(id));
+    }
+
+
+    /**
+     * 新增优惠券领取
+     */
+//    @PreAuthorize("@ss.hasPermi('store:storeCouponIssue:add')")
+//    @Log(title = "优惠券领取", businessType = BusinessType.INSERT)
+//    @PostMapping
+//    public AjaxResult add(@RequestBody FsStoreCouponIssueScrm fsStoreCouponIssue)
+//    {
+//        return toAjax(fsStoreCouponIssueService.insertFsStoreCouponIssue(fsStoreCouponIssue));
+//    }
+
+//    @PreAuthorize("@ss.hasPermi('store:storeCouponIssue:add')")
+    @Log(title = "优惠券领取", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult receiveCoupon(@RequestBody ReceiveCouponDto receiveCouponDto)
+    {
+        R r = fsStoreCouponIssueService.receiveCoupon(receiveCouponDto.getIssueId(), receiveCouponDto.getUserId());
+        return AjaxResult.success(r);
+    }
+
+
+
+
+
+}