فهرست منبع

定时发放优惠券模块

xdd 1 ماه پیش
والد
کامیت
3853ba2d5c

+ 104 - 0
fs-admin/src/main/java/com/fs/store/controller/FsCouponScheduleController.java

@@ -0,0 +1,104 @@
+package com.fs.store.controller;
+
+import java.util.List;
+
+import com.fs.store.domain.FsCouponSchedule;
+import com.fs.store.service.IFsCouponScheduleService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.core.page.TableDataInfo;
+
+/**
+ * 定时发放优惠券队列Controller
+ *
+ * @author fs
+ * @date 2025-03-08
+ */
+@RestController
+@RequestMapping("/system/schedule")
+public class FsCouponScheduleController extends BaseController
+{
+    @Autowired
+    private IFsCouponScheduleService fsCouponScheduleService;
+
+    /**
+     * 查询定时发放优惠券队列列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:schedule:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(FsCouponSchedule fsCouponSchedule)
+    {
+        startPage();
+        List<FsCouponSchedule> list = fsCouponScheduleService.selectFsCouponScheduleList(fsCouponSchedule);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出定时发放优惠券队列列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:schedule:export')")
+    @Log(title = "定时发放优惠券队列", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(FsCouponSchedule fsCouponSchedule)
+    {
+        List<FsCouponSchedule> list = fsCouponScheduleService.selectFsCouponScheduleList(fsCouponSchedule);
+        ExcelUtil<FsCouponSchedule> util = new ExcelUtil<FsCouponSchedule>(FsCouponSchedule.class);
+        return util.exportExcel(list, "schedule");
+    }
+
+    /**
+     * 获取定时发放优惠券队列详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:schedule:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(fsCouponScheduleService.selectFsCouponScheduleById(id));
+    }
+
+    /**
+     * 新增定时发放优惠券队列
+     */
+    @PreAuthorize("@ss.hasPermi('system:schedule:add')")
+    @Log(title = "定时发放优惠券队列", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody FsCouponSchedule fsCouponSchedule)
+    {
+        return toAjax(fsCouponScheduleService.insertFsCouponSchedule(fsCouponSchedule));
+    }
+
+    /**
+     * 修改定时发放优惠券队列
+     */
+    @PreAuthorize("@ss.hasPermi('system:schedule:edit')")
+    @Log(title = "定时发放优惠券队列", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody FsCouponSchedule fsCouponSchedule)
+    {
+        return toAjax(fsCouponScheduleService.updateFsCouponSchedule(fsCouponSchedule));
+    }
+
+    /**
+     * 删除定时发放优惠券队列
+     */
+    @PreAuthorize("@ss.hasPermi('system:schedule:remove')")
+    @Log(title = "定时发放优惠券队列", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(fsCouponScheduleService.deleteFsCouponScheduleByIds(ids));
+    }
+}

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

@@ -0,0 +1,111 @@
+package com.fs.store.domain;
+
+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_coupon_schedule
+ *
+ * @author fs
+ * @date 2025-03-08
+ */
+@Data
+public class FsCouponSchedule extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键ID */
+    private Long id;
+
+    /** 用户ID */
+    @Excel(name = "用户ID")
+    private Long userId;
+
+    /**
+     * 用户名称
+     */
+    @Excel(name = "用户名称")
+    private String userName;
+    /** 订单ID */
+    @Excel(name = "订单ID")
+    private String orderId;
+
+    /** 套餐ID */
+    @Excel(name = "套餐ID")
+    private Long setmealId;
+    /**
+     * 套餐名称
+     */
+    @Excel(name = "套餐名称")
+    private Long setmealTitle;
+
+    /** 总月数 */
+    @Excel(name = "总月数")
+    private Long month;
+
+    /** 当前次数 */
+    @Excel(name = "当前次数")
+    private Long count;
+
+    /** 0待处理, 1正在处理, 2成功, -1失败, 3用户拒签或者退货 */
+    @Excel(name = "0待处理, 1正在处理, 2成功, -1失败, 3用户拒签或者退货")
+    private Long status;
+
+    /** 下单时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "下单时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date orderTime;
+
+    /** 执行时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "执行时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date executeTime;
+
+    /** 优惠券ID */
+    @Excel(name = "优惠券ID")
+    private Long couponId;
+    /**
+     * 优惠券名称
+     */
+    @Excel(name = "优惠券名称")
+    private String couponName;
+
+    /** 优惠券批次ID */
+    @Excel(name = "优惠券批次ID")
+    private Long couponBatchId;
+
+    /** 预计发送时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "预计发送时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date sendTime;
+
+    /** 实际发送时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "实际发送时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date actualSendTime;
+
+    /** 错误信息 */
+    @Excel(name = "错误信息")
+    private String errorMessage;
+
+    /** 重试次数 */
+    @Excel(name = "重试次数")
+    private Long retryCount;
+
+    /** 最大重试次数 */
+    @Excel(name = "最大重试次数")
+    private Long maxRetries;
+
+    /** 下次重试时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "下次重试时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date nextRetryTime;
+
+    /** 订单来源 */
+    @Excel(name = "订单来源")
+    private String sourceType;
+
+}

+ 64 - 0
fs-service-system/src/main/java/com/fs/store/mapper/FsCouponScheduleMapper.java

@@ -0,0 +1,64 @@
+package com.fs.store.mapper;
+
+import com.fs.store.domain.FsCouponSchedule;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * 定时发放优惠券队列Mapper接口
+ *
+ * @author fs
+ * @date 2025-03-08
+ */
+@Mapper
+public interface FsCouponScheduleMapper
+{
+    /**
+     * 查询定时发放优惠券队列
+     *
+     * @param id 定时发放优惠券队列ID
+     * @return 定时发放优惠券队列
+     */
+    public FsCouponSchedule selectFsCouponScheduleById(Long id);
+
+    /**
+     * 查询定时发放优惠券队列列表
+     *
+     * @param fsCouponSchedule 定时发放优惠券队列
+     * @return 定时发放优惠券队列集合
+     */
+    public List<FsCouponSchedule> selectFsCouponScheduleList(FsCouponSchedule fsCouponSchedule);
+
+    /**
+     * 新增定时发放优惠券队列
+     *
+     * @param fsCouponSchedule 定时发放优惠券队列
+     * @return 结果
+     */
+    public int insertFsCouponSchedule(FsCouponSchedule fsCouponSchedule);
+
+    /**
+     * 修改定时发放优惠券队列
+     *
+     * @param fsCouponSchedule 定时发放优惠券队列
+     * @return 结果
+     */
+    public int updateFsCouponSchedule(FsCouponSchedule fsCouponSchedule);
+
+    /**
+     * 删除定时发放优惠券队列
+     *
+     * @param id 定时发放优惠券队列ID
+     * @return 结果
+     */
+    public int deleteFsCouponScheduleById(Long id);
+
+    /**
+     * 批量删除定时发放优惠券队列
+     *
+     * @param ids 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteFsCouponScheduleByIds(Long[] ids);
+}

+ 63 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsCouponScheduleService.java

@@ -0,0 +1,63 @@
+package com.fs.store.service;
+
+
+import com.fs.store.domain.FsCouponSchedule;
+
+import java.util.List;
+
+/**
+ * 定时发放优惠券队列Service接口
+ *
+ * @author fs
+ * @date 2025-03-08
+ */
+public interface IFsCouponScheduleService
+{
+    /**
+     * 查询定时发放优惠券队列
+     *
+     * @param id 定时发放优惠券队列ID
+     * @return 定时发放优惠券队列
+     */
+    public FsCouponSchedule selectFsCouponScheduleById(Long id);
+
+    /**
+     * 查询定时发放优惠券队列列表
+     *
+     * @param fsCouponSchedule 定时发放优惠券队列
+     * @return 定时发放优惠券队列集合
+     */
+    public List<FsCouponSchedule> selectFsCouponScheduleList(FsCouponSchedule fsCouponSchedule);
+
+    /**
+     * 新增定时发放优惠券队列
+     *
+     * @param fsCouponSchedule 定时发放优惠券队列
+     * @return 结果
+     */
+    public int insertFsCouponSchedule(FsCouponSchedule fsCouponSchedule);
+
+    /**
+     * 修改定时发放优惠券队列
+     *
+     * @param fsCouponSchedule 定时发放优惠券队列
+     * @return 结果
+     */
+    public int updateFsCouponSchedule(FsCouponSchedule fsCouponSchedule);
+
+    /**
+     * 批量删除定时发放优惠券队列
+     *
+     * @param ids 需要删除的定时发放优惠券队列ID
+     * @return 结果
+     */
+    public int deleteFsCouponScheduleByIds(Long[] ids);
+
+    /**
+     * 删除定时发放优惠券队列信息
+     *
+     * @param id 定时发放优惠券队列ID
+     * @return 结果
+     */
+    public int deleteFsCouponScheduleById(Long id);
+}

+ 96 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/FsCouponScheduleServiceImpl.java

@@ -0,0 +1,96 @@
+package com.fs.store.service.impl;
+
+import java.util.List;
+import com.fs.common.utils.DateUtils;
+import com.fs.store.domain.FsCouponSchedule;
+import com.fs.store.mapper.FsCouponScheduleMapper;
+import com.fs.store.service.IFsCouponScheduleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 定时发放优惠券队列Service业务层处理
+ *
+ * @author fs
+ * @date 2025-03-08
+ */
+@Service
+public class FsCouponScheduleServiceImpl implements IFsCouponScheduleService
+{
+    @Autowired
+    private FsCouponScheduleMapper fsCouponScheduleMapper;
+
+    /**
+     * 查询定时发放优惠券队列
+     *
+     * @param id 定时发放优惠券队列ID
+     * @return 定时发放优惠券队列
+     */
+    @Override
+    public FsCouponSchedule selectFsCouponScheduleById(Long id)
+    {
+        return fsCouponScheduleMapper.selectFsCouponScheduleById(id);
+    }
+
+    /**
+     * 查询定时发放优惠券队列列表
+     *
+     * @param fsCouponSchedule 定时发放优惠券队列
+     * @return 定时发放优惠券队列
+     */
+    @Override
+    public List<FsCouponSchedule> selectFsCouponScheduleList(FsCouponSchedule fsCouponSchedule)
+    {
+        return fsCouponScheduleMapper.selectFsCouponScheduleList(fsCouponSchedule);
+    }
+
+    /**
+     * 新增定时发放优惠券队列
+     *
+     * @param fsCouponSchedule 定时发放优惠券队列
+     * @return 结果
+     */
+    @Override
+    public int insertFsCouponSchedule(FsCouponSchedule fsCouponSchedule)
+    {
+        fsCouponSchedule.setCreateTime(DateUtils.getNowDate());
+        return fsCouponScheduleMapper.insertFsCouponSchedule(fsCouponSchedule);
+    }
+
+    /**
+     * 修改定时发放优惠券队列
+     *
+     * @param fsCouponSchedule 定时发放优惠券队列
+     * @return 结果
+     */
+    @Override
+    public int updateFsCouponSchedule(FsCouponSchedule fsCouponSchedule)
+    {
+        fsCouponSchedule.setUpdateTime(DateUtils.getNowDate());
+        return fsCouponScheduleMapper.updateFsCouponSchedule(fsCouponSchedule);
+    }
+
+    /**
+     * 批量删除定时发放优惠券队列
+     *
+     * @param ids 需要删除的定时发放优惠券队列ID
+     * @return 结果
+     */
+    @Override
+    public int deleteFsCouponScheduleByIds(Long[] ids)
+    {
+        return fsCouponScheduleMapper.deleteFsCouponScheduleByIds(ids);
+    }
+
+    /**
+     * 删除定时发放优惠券队列信息
+     *
+     * @param id 定时发放优惠券队列ID
+     * @return 结果
+     */
+    @Override
+    public int deleteFsCouponScheduleById(Long id)
+    {
+        return fsCouponScheduleMapper.deleteFsCouponScheduleById(id);
+    }
+}

+ 157 - 0
fs-service-system/src/main/resources/mapper/store/FsCouponScheduleMapper.xml

@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.store.mapper.FsCouponScheduleMapper">
+
+    <resultMap type="FsCouponSchedule" id="FsCouponScheduleResult">
+        <result property="id"    column="id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="orderId"    column="order_id"    />
+        <result property="setmealId"    column="setmeal_id"    />
+        <result property="month"    column="month"    />
+        <result property="count"    column="count"    />
+        <result property="status"    column="status"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="orderTime"    column="order_time"    />
+        <result property="executeTime"    column="execute_time"    />
+        <result property="couponId"    column="coupon_id"    />
+        <result property="couponBatchId"    column="coupon_batch_id"    />
+        <result property="sendTime"    column="send_time"    />
+        <result property="actualSendTime"    column="actual_send_time"    />
+        <result property="errorMessage"    column="error_message"    />
+        <result property="retryCount"    column="retry_count"    />
+        <result property="maxRetries"    column="max_retries"    />
+        <result property="nextRetryTime"    column="next_retry_time"    />
+        <result property="sourceType"    column="source_type"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectFsCouponScheduleVo">
+        select id, user_id, order_id, setmeal_id, month, count, status, create_time, create_by, update_time, update_by, order_time, execute_time, coupon_id, coupon_batch_id, send_time, actual_send_time, error_message, retry_count, max_retries, next_retry_time, source_type, remark from fs_coupon_schedule
+    </sql>
+
+    <select id="selectFsCouponScheduleList" parameterType="FsCouponSchedule" resultMap="FsCouponScheduleResult">
+        <include refid="selectFsCouponScheduleVo"/>
+        <where>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
+            <if test="setmealId != null "> and setmeal_id = #{setmealId}</if>
+            <if test="month != null "> and month = #{month}</if>
+            <if test="count != null "> and count = #{count}</if>
+            <if test="status != null "> and status = #{status}</if>
+            <if test="orderTime != null "> and order_time = #{orderTime}</if>
+            <if test="executeTime != null "> and execute_time = #{executeTime}</if>
+            <if test="couponId != null "> and coupon_id = #{couponId}</if>
+            <if test="couponBatchId != null "> and coupon_batch_id = #{couponBatchId}</if>
+            <if test="sendTime != null "> and send_time = #{sendTime}</if>
+            <if test="actualSendTime != null "> and actual_send_time = #{actualSendTime}</if>
+            <if test="errorMessage != null  and errorMessage != ''"> and error_message = #{errorMessage}</if>
+            <if test="retryCount != null "> and retry_count = #{retryCount}</if>
+            <if test="maxRetries != null "> and max_retries = #{maxRetries}</if>
+            <if test="nextRetryTime != null "> and next_retry_time = #{nextRetryTime}</if>
+            <if test="sourceType != null  and sourceType != ''"> and source_type = #{sourceType}</if>
+        </where>
+    </select>
+
+    <select id="selectFsCouponScheduleById" parameterType="Long" resultMap="FsCouponScheduleResult">
+        <include refid="selectFsCouponScheduleVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertFsCouponSchedule" parameterType="FsCouponSchedule" useGeneratedKeys="true" keyProperty="id">
+        insert into fs_coupon_schedule
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null">user_id,</if>
+            <if test="orderId != null and orderId != ''">order_id,</if>
+            <if test="setmealId != null">setmeal_id,</if>
+            <if test="month != null">month,</if>
+            <if test="count != null">count,</if>
+            <if test="status != null">status,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="orderTime != null">order_time,</if>
+            <if test="executeTime != null">execute_time,</if>
+            <if test="couponId != null">coupon_id,</if>
+            <if test="couponBatchId != null">coupon_batch_id,</if>
+            <if test="sendTime != null">send_time,</if>
+            <if test="actualSendTime != null">actual_send_time,</if>
+            <if test="errorMessage != null">error_message,</if>
+            <if test="retryCount != null">retry_count,</if>
+            <if test="maxRetries != null">max_retries,</if>
+            <if test="nextRetryTime != null">next_retry_time,</if>
+            <if test="sourceType != null">source_type,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null">#{userId},</if>
+            <if test="orderId != null and orderId != ''">#{orderId},</if>
+            <if test="setmealId != null">#{setmealId},</if>
+            <if test="month != null">#{month},</if>
+            <if test="count != null">#{count},</if>
+            <if test="status != null">#{status},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="orderTime != null">#{orderTime},</if>
+            <if test="executeTime != null">#{executeTime},</if>
+            <if test="couponId != null">#{couponId},</if>
+            <if test="couponBatchId != null">#{couponBatchId},</if>
+            <if test="sendTime != null">#{sendTime},</if>
+            <if test="actualSendTime != null">#{actualSendTime},</if>
+            <if test="errorMessage != null">#{errorMessage},</if>
+            <if test="retryCount != null">#{retryCount},</if>
+            <if test="maxRetries != null">#{maxRetries},</if>
+            <if test="nextRetryTime != null">#{nextRetryTime},</if>
+            <if test="sourceType != null">#{sourceType},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateFsCouponSchedule" parameterType="FsCouponSchedule">
+        update fs_coupon_schedule
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="orderId != null and orderId != ''">order_id = #{orderId},</if>
+            <if test="setmealId != null">setmeal_id = #{setmealId},</if>
+            <if test="month != null">month = #{month},</if>
+            <if test="count != null">count = #{count},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="orderTime != null">order_time = #{orderTime},</if>
+            <if test="executeTime != null">execute_time = #{executeTime},</if>
+            <if test="couponId != null">coupon_id = #{couponId},</if>
+            <if test="couponBatchId != null">coupon_batch_id = #{couponBatchId},</if>
+            <if test="sendTime != null">send_time = #{sendTime},</if>
+            <if test="actualSendTime != null">actual_send_time = #{actualSendTime},</if>
+            <if test="errorMessage != null">error_message = #{errorMessage},</if>
+            <if test="retryCount != null">retry_count = #{retryCount},</if>
+            <if test="maxRetries != null">max_retries = #{maxRetries},</if>
+            <if test="nextRetryTime != null">next_retry_time = #{nextRetryTime},</if>
+            <if test="sourceType != null">source_type = #{sourceType},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteFsCouponScheduleById" parameterType="Long">
+        delete from fs_coupon_schedule where id = #{id}
+    </delete>
+
+    <delete id="deleteFsCouponScheduleByIds" parameterType="String">
+        delete from fs_coupon_schedule where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+</mapper>