Browse Source

套餐管理新增分期优惠券开关、月数、优惠券三个字段

xdd 1 month ago
parent
commit
d5049aa1af

+ 3 - 0
fs-admin/src/main/java/com/fs/store/controller/FsStoreCouponController.java

@@ -7,6 +7,7 @@ import com.fs.common.core.domain.R;
 import com.fs.store.domain.FsStoreCouponIssue;
 import com.fs.store.param.FsStoreCouponPublishParam;
 import com.fs.store.service.IFsStoreCouponIssueService;
+import com.fs.store.vo.FsStoreCouponIssueVO;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -40,6 +41,8 @@ public class FsStoreCouponController extends BaseController
     private IFsStoreCouponService fsStoreCouponService;
     @Autowired
     private IFsStoreCouponIssueService fsStoreCouponIssueService;
+
+
     /**
      * 查询优惠券列表
      */

+ 14 - 1
fs-admin/src/main/java/com/fs/store/controller/FsStoreCouponIssueController.java

@@ -2,6 +2,7 @@ package com.fs.store.controller;
 
 import java.util.List;
 
+import com.fs.store.domain.FsStoreCoupon;
 import com.fs.store.vo.FsStoreCouponIssueVO;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,7 +25,7 @@ import com.fs.common.core.page.TableDataInfo;
 
 /**
  * 优惠券领取Controller
- * 
+ *
  * @author fs
  * @date 2022-03-15
  */
@@ -35,6 +36,18 @@ public class FsStoreCouponIssueController extends BaseController
     @Autowired
     private IFsStoreCouponIssueService fsStoreCouponIssueService;
 
+
+    /**
+     * 获取所有可用套餐券
+     * @return 套餐券列表
+     */
+    @GetMapping("/listAllAvailable")
+    @PreAuthorize("@ss.hasPermi('store:storeCoupon:listAllAvailable')")
+    public AjaxResult listAllAvailable(){
+        List<FsStoreCouponIssueVO> fsStoreCouponIssueVOS = fsStoreCouponIssueService.listAllAvailable();
+        return AjaxResult.success(fsStoreCouponIssueVOS);
+    }
+
     /**
      * 查询优惠券领取列表
      */

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/domain/FsCouponSchedule.java

@@ -32,7 +32,7 @@ public class FsCouponSchedule extends BaseEntity
     private String userName;
     /** 订单ID */
     @Excel(name = "订单ID")
-    private String orderId;
+    private Long orderId;
 
     /** 套餐ID */
     @Excel(name = "套餐ID")

+ 52 - 143
fs-service-system/src/main/java/com/fs/store/domain/FsStoreProductPackage.java

@@ -2,17 +2,22 @@ package com.fs.store.domain;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.StringJoiner;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
 import com.fs.store.dto.StoreOrderProductDTO;
+import lombok.Data;
+import org.springframework.util.CollectionUtils;
 
 /**
  * 商品组合套餐对象 fs_store_product_package
- * 
+ *
  * @author fs
  * @date 2022-07-14
  */
+@Data
 public class FsStoreProductPackage extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -66,149 +71,53 @@ public class FsStoreProductPackage extends BaseEntity
 
     private Integer status;
 
-    List<StoreOrderProductDTO> productList;
-
-    public Integer getStatus() {
-        return status;
-    }
-
-    public void setStatus(Integer status) {
-        this.status = status;
-    }
-
-    public Integer getSort() {
-        return sort;
-    }
-
-    public void setSort(Integer sort) {
-        this.sort = sort;
-    }
-
-    public Integer getCateId() {
-        return cateId;
+    /**
+     * 分期赠送优惠券-是否开启 0未开启 1开启
+     */
+    private Integer icgEnable;
+
+    /**
+     * 分期赠送优惠券-月数
+     */
+    private Integer icgMonth;
+
+
+    /**
+     * 分期赠送优惠券-优惠券列表(数据库存储)
+     */
+    @JsonIgnore
+    private String icgCoupons;
+    /**
+     * 分期赠送优惠券-优惠券列表
+     */
+    private Integer[] icgCouponsId;
+
+    public String getIcgCoupons() {
+        if(icgCouponsId != null && icgCouponsId.length > 0){
+            StringJoiner stringJoiner = new StringJoiner(",");
+            for (Integer id : icgCouponsId) {
+                stringJoiner.add(id.toString());
+            }
+            icgCoupons = stringJoiner.toString();
+        }
+        return icgCoupons;
+    }
+
+    /**
+     * 获取优惠券列表ID
+     * @return 优惠券列表id
+     */
+    public Integer[] getIcgCouponsId() {
+        if (icgCouponsId == null && icgCoupons != null) {
+            String[] split = icgCoupons.split(",");
+            icgCouponsId = new Integer[split.length];
+            for (int i = 0; i < split.length; i++) {
+                icgCouponsId[i] = Integer.parseInt(split[i].trim());
+            }
+        }
+        return icgCouponsId;
     }
 
-    public void setCateId(Integer cateId) {
-        this.cateId = cateId;
-    }
-
-    public String getImages() {
-        return images;
-    }
-
-    public void setImages(String images) {
-        this.images = images;
-    }
-
-
-
-    public List<StoreOrderProductDTO> getProductList() {
-        return productList;
-    }
-
-    public void setProductList(List<StoreOrderProductDTO> productList) {
-        this.productList = productList;
-    }
-
-    public Integer getLimitCount() {
-        return limitCount;
-    }
-
-    public void setLimitCount(Integer limitCount) {
-        this.limitCount = limitCount;
-    }
-
-    public Integer getPayType() {
-        return payType;
-    }
-
-    public void setPayType(Integer payType) {
-        this.payType = payType;
-    }
-
-
-
-    public static long getSerialVersionUID() {
-        return serialVersionUID;
-    }
-
-    public Long getPackageId() {
-        return packageId;
-    }
-
-    public void setPackageId(Long packageId) {
-        this.packageId = packageId;
-    }
-
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
-    public String getDescs() {
-        return descs;
-    }
-
-    public void setDescs(String descs) {
-        this.descs = descs;
-    }
-
-    public String getContent() {
-        return content;
-    }
-
-    public void setContent(String content) {
-        this.content = content;
-    }
-
-    public String getImgUrl() {
-        return imgUrl;
-    }
-
-    public void setImgUrl(String imgUrl) {
-        this.imgUrl = imgUrl;
-    }
-
-    public BigDecimal getMoney() {
-        return money;
-    }
-
-    public void setMoney(BigDecimal money) {
-        this.money = money;
-    }
-
-    public BigDecimal getPayMoney() {
-        return payMoney;
-    }
-
-    public void setPayMoney(BigDecimal payMoney) {
-        this.payMoney = payMoney;
-    }
-
-    public Long getCompanyId() {
-        return companyId;
-    }
-
-    public void setCompanyId(Long companyId) {
-        this.companyId = companyId;
-    }
-
-    public Long getDeptId() {
-        return deptId;
-    }
-
-    public void setDeptId(Long deptId) {
-        this.deptId = deptId;
-    }
-
-    public String getProducts() {
-        return products;
-    }
+    List<StoreOrderProductDTO> productList;
 
-    public void setProducts(String products) {
-        this.products = products;
-    }
 }

+ 9 - 0
fs-service-system/src/main/java/com/fs/store/mapper/FsStoreCouponIssueMapper.java

@@ -1,6 +1,8 @@
 package com.fs.store.mapper;
 
 import java.util.List;
+
+import com.fs.store.domain.FsStoreCoupon;
 import com.fs.store.domain.FsStoreCouponIssue;
 import com.fs.store.param.FsCouponIssueParam;
 import com.fs.store.vo.FsStoreCouponIssueVO;
@@ -130,4 +132,11 @@ public interface FsStoreCouponIssueMapper
             " order by c.coupon_price "+
             "</script>"})
     List<FsStoreCouponIssueVO> selectFsStoreCouponIssueListVO(@Param("maps")FsStoreCouponIssue fsStoreCouponIssue);
+
+
+    /**
+     * 返回所有可用套餐优惠券
+     * @return List<FsStoreCouponIssueVO>
+     */
+    List<FsStoreCouponIssueVO> listAllAvailable();
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/store/mapper/FsStoreCouponMapper.java

@@ -63,4 +63,6 @@ public interface FsStoreCouponMapper
 
     @Select("select * from fs_store_coupon where find_in_set(coupon_id,#{ids})")
     List<FsStoreCoupon> selectFsStoreCouponByIds(String ids);
+
+
 }

+ 13 - 8
fs-service-system/src/main/java/com/fs/store/service/IFsStoreCouponIssueService.java

@@ -10,15 +10,15 @@ import com.fs.store.vo.FsStoreCouponIssueVO;
 
 /**
  * 优惠券领取Service接口
- * 
+ *
  * @author fs
  * @date 2022-03-15
  */
-public interface IFsStoreCouponIssueService 
+public interface IFsStoreCouponIssueService
 {
     /**
      * 查询优惠券领取
-     * 
+     *
      * @param id 优惠券领取ID
      * @return 优惠券领取
      */
@@ -26,7 +26,7 @@ public interface IFsStoreCouponIssueService
 
     /**
      * 查询优惠券领取列表
-     * 
+     *
      * @param fsStoreCouponIssue 优惠券领取
      * @return 优惠券领取集合
      */
@@ -34,7 +34,7 @@ public interface IFsStoreCouponIssueService
 
     /**
      * 新增优惠券领取
-     * 
+     *
      * @param fsStoreCouponIssue 优惠券领取
      * @return 结果
      */
@@ -42,7 +42,7 @@ public interface IFsStoreCouponIssueService
 
     /**
      * 修改优惠券领取
-     * 
+     *
      * @param fsStoreCouponIssue 优惠券领取
      * @return 结果
      */
@@ -50,7 +50,7 @@ public interface IFsStoreCouponIssueService
 
     /**
      * 批量删除优惠券领取
-     * 
+     *
      * @param ids 需要删除的优惠券领取ID
      * @return 结果
      */
@@ -58,7 +58,7 @@ public interface IFsStoreCouponIssueService
 
     /**
      * 删除优惠券领取信息
-     * 
+     *
      * @param id 优惠券领取ID
      * @return 结果
      */
@@ -73,4 +73,9 @@ public interface IFsStoreCouponIssueService
     FsStoreCouponIssueVO selectFsStoreCouponIssueVOById(Long id);
 
     List<FsStoreCouponIssueVO> selectFsStoreCouponIssueListVO(FsStoreCouponIssue fsStoreCouponIssue);
+    /**
+     * 返回所有可用套餐优惠券
+     * @return List<FsStoreCouponIssueVO>
+     */
+    List<FsStoreCouponIssueVO> listAllAvailable();
 }

+ 1 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsStoreCouponService.java

@@ -61,4 +61,5 @@ public interface IFsStoreCouponService
     public int deleteFsStoreCouponById(Long couponId);
 
     List<FsStoreCoupon> selectFsStoreCouponByIds(String ids);
+
 }

+ 4 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreCouponIssueServiceImpl.java

@@ -181,5 +181,9 @@ public class FsStoreCouponIssueServiceImpl implements IFsStoreCouponIssueService
         return fsStoreCouponIssueMapper.selectFsStoreCouponIssueListVO(fsStoreCouponIssue);
     }
 
+    @Override
+    public List<FsStoreCouponIssueVO> listAllAvailable() {
+        return fsStoreCouponIssueMapper.listAllAvailable();
+    }
 
 }

+ 8 - 6
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -1384,13 +1384,15 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             storeOrder.setPayTime(new Date());
             fsStoreOrderMapper.updateFsStoreOrder(storeOrder);
 
-
             // 如果是套餐类型的
-//            if(ObjectUtil.equal(storeOrder.getIsPackage(),1)) {
-//                FsCouponSchedule fsCouponSchedule = new FsCouponSchedule();
-//
-//                fsCouponScheduleService.insertFsCouponSchedule()
-//            }
+            if(ObjectUtil.equal(storeOrder.getIsPackage(),1)) {
+                // 如果该套餐有定时发放优惠券
+
+                FsCouponSchedule fsCouponSchedule = new FsCouponSchedule();
+                fsCouponSchedule.setOrderId(order.getId());
+
+                fsCouponScheduleService.insertFsCouponSchedule(fsCouponSchedule);
+            }
             //非处方直接提交OMS
             try {
                 if(order.getIsPrescribe().equals(0)){

+ 36 - 0
fs-service-system/src/main/java/com/fs/store/vo/FsStoreProductPacketVO.java

@@ -1,5 +1,6 @@
 package com.fs.store.vo;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fs.common.annotation.Excel;
 import com.fs.store.dto.StoreOrderProductDTO;
 import lombok.Data;
@@ -7,6 +8,7 @@ import lombok.Data;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.StringJoiner;
 
 /**
  * 订单对象 fs_store_order
@@ -71,6 +73,40 @@ public class FsStoreProductPacketVO implements Serializable
     @Excel(name = "状态", dictType = "common_status")
     private Integer status;
 
+    /**
+     * 分期赠送优惠券-是否开启 0未开启 1开启
+     */
+    private Integer icgEnable;
+    /**
+     * 分期赠送优惠券-月数
+     */
+    private Integer icgMonth;
+
+    /**
+     * 分期赠送优惠券-优惠券列表(数据库存储)
+     */
+    @JsonIgnore
+    private String icgCoupons;
+    /**
+     * 分期赠送优惠券-优惠券列表
+     */
+    private Integer[] icgCouponsId;
+
+    /**
+     * 获取优惠券列表ID
+     * @return 优惠券列表id
+     */
+    public Integer[] getIcgCouponsId() {
+        if (icgCouponsId == null && icgCoupons != null) {
+            String[] split = icgCoupons.split(",");
+            icgCouponsId = new Integer[split.length];
+            for (int i = 0; i < split.length; i++) {
+                icgCouponsId[i] = Integer.parseInt(split[i].trim());
+            }
+        }
+        return icgCouponsId;
+    }
+
     List<StoreOrderProductDTO> productList;
 
 }

+ 53 - 7
fs-service-system/src/main/resources/mapper/store/FsStoreCouponIssueMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.store.mapper.FsStoreCouponIssueMapper">
-    
+
     <resultMap type="FsStoreCouponIssue" id="FsStoreCouponIssueResult">
         <result property="id"    column="id"    />
         <result property="couponName"    column="coupon_name"    />
@@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectFsStoreCouponIssueList" parameterType="FsStoreCouponIssue" resultMap="FsStoreCouponIssueResult">
         <include refid="selectFsStoreCouponIssueVo"/>
-        <where>  
+        <where>
             <if test="couponName != null  and couponName != ''"> and coupon_name like concat('%', #{couponName}, '%')</if>
             <if test="couponId != null "> and coupon_id = #{couponId}</if>
             <if test="couponType != null "> and coupon_type = #{couponType}</if>
@@ -40,12 +40,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
         order by id desc
     </select>
-    
+
     <select id="selectFsStoreCouponIssueById" parameterType="Long" resultMap="FsStoreCouponIssueResult">
         <include refid="selectFsStoreCouponIssueVo"/>
         where id = #{id}
     </select>
-        
+    <select id="listAllAvailable" resultMap="FsStoreCouponIssueResult">
+        SELECT
+            id,
+            coupon_name,
+            coupon_id,
+            coupon_type,
+            start_time,
+            limit_time,
+            total_count,
+            remain_count,
+            is_permanent,
+            STATUS,
+            is_del,
+            create_time,
+            update_time
+        FROM
+            fs_store_coupon_issue
+        WHERE
+            coupon_type = 1
+          AND  remain_count> 0
+          AND ifnull(is_del,0)= 0
+          AND `status`=1
+
+        UNION
+
+        SELECT
+            id,
+            coupon_name,
+            coupon_id,
+            coupon_type,
+            start_time,
+            limit_time,
+            total_count,
+            remain_count,
+            is_permanent,
+            STATUS,
+            is_del,
+            create_time,
+            update_time
+        FROM
+            fs_store_coupon_issue
+        WHERE
+            coupon_type = 1
+          AND is_permanent= 1
+          AND ifnull(is_del,0)= 0
+          AND `status`=1
+    </select>
     <insert id="insertFsStoreCouponIssue" parameterType="FsStoreCouponIssue" useGeneratedKeys="true" keyProperty="id">
         insert into fs_store_coupon_issue
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -102,10 +148,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteFsStoreCouponIssueByIds" parameterType="String">
-        delete from fs_store_coupon_issue where id in 
+        delete from fs_store_coupon_issue where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-    
-</mapper>
+
+</mapper>

+ 1 - 0
fs-service-system/src/main/resources/mapper/store/FsStoreCouponMapper.xml

@@ -52,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where coupon_id = #{couponId}
     </select>
 
+
     <insert id="insertFsStoreCoupon" parameterType="FsStoreCoupon" useGeneratedKeys="true" keyProperty="couponId">
         insert into fs_store_coupon
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 16 - 1
fs-service-system/src/main/resources/mapper/store/FsStoreProductPackageMapper.xml

@@ -20,10 +20,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="cateId"    column="cate_id"    />
         <result property="sort"    column="sort"    />
         <result property="status"    column="status"    />
+        <result property="icgEnable"    column="icg_enable"    />
+        <result property="icgMonth"    column="icg_month"    />
+        <result property="icgCoupons"    column="icg_coupons"    />
     </resultMap>
 
     <sql id="selectFsStoreProductPackageVo">
-        select package_id, title, descs, content, img_url,images, products, money, pay_money, company_id, dept_id,pay_type,limit_count,cate_id,sort,status from fs_store_product_package
+        select package_id, title, descs, content, img_url,images, products, money, pay_money, company_id, dept_id,pay_type,limit_count,cate_id,sort,status,icg_enable,icg_month,icg_coupons from fs_store_product_package
     </sql>
 
     <select id="selectFsStoreProductPackageList" parameterType="FsStoreProductPackage" resultMap="FsStoreProductPackageResult">
@@ -40,6 +43,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="deptId != null "> and dept_id = #{deptId}</if>
             <if test="cateId != null "> and cate_id = #{cateId}</if>
             <if test="status != null "> and status = #{status}</if>
+            <if test="icgEnable != null "> and icg_enable = #{icgEnable}</if>
+            <if test="icgMonth != null "> and icg_month = #{icgMonth}</if>
+            <if test="icgCoupons != null "> and icg_coupons = #{icgCoupons}</if>
         </where>
     </select>
 
@@ -69,6 +75,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="cateId != null">cate_id,</if>
             <if test="sort != null">sort,</if>
             <if test="status != null">status,</if>
+            <if test="icgEnable != null">icg_enable,</if>
+            <if test="icgMonth != null">icg_month,</if>
+            <if test="icgCoupons != null">icg_coupons,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="packageId != null">#{packageId},</if>
@@ -87,6 +96,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="cateId != null">#{cateId},</if>
             <if test="sort != null">#{sort},</if>
             <if test="status != null">#{status},</if>
+            <if test="icgEnable != null">#{icgEnable},</if>
+            <if test="icgMonth != null">#{icgMonth},</if>
+            <if test="icgCoupons != null">#{icgCoupons},</if>
          </trim>
     </insert>
 
@@ -108,6 +120,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="cateId != null">cate_id = #{cateId},</if>
             <if test="sort != null">sort = #{sort},</if>
             <if test="status != null">status = #{status},</if>
+            <if test="icgEnable != null">icg_enable = #{icgEnable},</if>
+            <if test="icgMonth != null">icg_month = #{icgMonth},</if>
+            <if test="icgCoupons != null">icg_coupons = #{icgCoupons},</if>
         </trim>
         where package_id = #{packageId}
     </update>