微信小程序优惠劵功能(包含用户需求,axure原型设计,数据库设计,后台功能,微信小程序功能)

Posted 秋9

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了微信小程序优惠劵功能(包含用户需求,axure原型设计,数据库设计,后台功能,微信小程序功能)相关的知识,希望对你有一定的参考价值。

1.用户需求

优惠券功能有:
1.后台可以设置优惠券和查看已发出优惠券的状态
2.平台自动给新用户发放优惠劵,或者手动给某些用户发放优惠券
3.用户在小程序中手动领取优惠券
4.用户中心新增“优惠券”模块,查看所有优惠券
5.下单时使用优惠券

2.axure原型设计

原型设计生成的html页面,下载地址:https://download.csdn.net/download/jlq_diligence/19652279
下载后,使用ie浏览器打开,打开后的html文件目录结构如下:

3.数据库设计

优惠劵2张表的表结构如下:

CREATE TABLE `coupon_rules` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '优惠券主键',
  `gmt_create` datetime NOT NULL COMMENT '优惠券创建时间',
  `gmt_modified` datetime DEFAULT NULL COMMENT '优惠券修改时间',
  `creator` int(11) DEFAULT NULL COMMENT '创建人',
  `partner_id` int(11) DEFAULT NULL COMMENT '关联运营商id',
  `coupon_name` varchar(255) CHARACTER SET utf8 NOT NULL COMMENT '优惠券名称',
  `coupon_amount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '优惠券金额',
  `grant_rules` int(2) NOT NULL COMMENT '发放规则',
  `use_start_time` datetime DEFAULT NULL COMMENT '使用起始时间',
  `use_end_time` datetime DEFAULT NULL COMMENT '使用结束时间',
  `quantity_ceiling` int(11) DEFAULT NULL COMMENT '数量上限,一般指按订单金额发放,例如某用户在订单满100元发放5元优惠卷,该用户累计发放次数不能超过10次,累计同一优惠券领取超过该值时则不发放,0为不设限',
  `use_conditions` int(2) DEFAULT NULL COMMENT '使用条件:无门槛|满减使用',
  `use_conditions_content` decimal(10,2) DEFAULT '0.00' COMMENT '使用条件补充内容',
  `grant_conditions` int(11) unsigned DEFAULT NULL COMMENT '发放条件,存类目id',
  `order_minimum` decimal(12,4) DEFAULT '0.0000' COMMENT '按照订单金额发放时的最低金额设定',
  `grant_start_time` datetime DEFAULT NULL COMMENT '优惠券发放起始时间',
  `grant_end_time` datetime DEFAULT NULL COMMENT '优惠券发放结束时间',
  `status` int(2) DEFAULT '1' COMMENT '状态,正常1|删除0 ',
  `grant_max_num` int(11) DEFAULT '0' COMMENT '优惠券发放上限',
  `grant_num` int(11) DEFAULT '0' COMMENT '已发放数量',
  `duration` int(11) DEFAULT '30' COMMENT '领取后优惠券的有效天数',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4;


CREATE TABLE `coupon_info` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '优惠券主键',
  `rules_id` int(11) NOT NULL COMMENT '关联优惠券规则主键id',
  `grant_time` datetime DEFAULT NULL COMMENT '优惠券发放时间',
  `status` int(2) NOT NULL DEFAULT '0' COMMENT '优惠券状态,0未使用|1已使用|2已失效',
  `member_id` int(11) DEFAULT NULL COMMENT '关联消费者id',
  `order_id` int(11) DEFAULT NULL COMMENT '订单id',
  `use_time` datetime DEFAULT NULL COMMENT '使用时间',
  `coupon_name` varchar(255) CHARACTER SET utf8 NOT NULL COMMENT '优惠券名称',
  `coupon_amount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '优惠券金额',
  `use_start_time` datetime DEFAULT NULL COMMENT '使用起始时间',
  `use_end_time` datetime DEFAULT NULL COMMENT '使用结束时间',
  `grant_conditions` int(11) DEFAULT NULL COMMENT '发放条件,存类目id',
  `use_conditions_content` decimal(10,2) DEFAULT NULL COMMENT '使用条件补充内容',
  `from_id` int(11) DEFAULT NULL COMMENT '发放来源(存储完工的订单id或注册的商家id等等)',
  `from_remark` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '发放备注',
  `gmt_create` datetime NOT NULL COMMENT '优惠券创建时间',
  `gmt_modified` datetime DEFAULT NULL COMMENT '优惠券修改时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=utf8mb4;

4.后台优惠劵功能实现

CouponRulesMapper.xml

<?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.**.dao.coupon.CouponRulesMapper">
    <resultMap id="BaseResultMap" type="com.**.model.coupon.CouponRules">
        <!--@mbg.generated-->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
        <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/>
        <result column="creator" jdbcType="INTEGER" property="creator"/>
        <result column="partner_id" jdbcType="INTEGER" property="partnerId"/>
        <result column="coupon_name" jdbcType="VARCHAR" property="couponName"/>
        <result column="coupon_amount" jdbcType="DECIMAL" property="couponAmount"/>
        <result column="grant_rules" jdbcType="INTEGER" property="grantRules"/>
        <result column="use_start_time" jdbcType="TIMESTAMP" property="useStartTime"/>
        <result column="use_end_time" jdbcType="TIMESTAMP" property="useEndTime"/>
        <result column="quantity_ceiling" jdbcType="INTEGER" property="quantityCeiling"/>
        <result column="use_conditions" jdbcType="INTEGER" property="useConditions"/>
        <result column="use_conditions_content" jdbcType="DECIMAL" property="useConditionsContent"/>
        <result column="grant_conditions" jdbcType="INTEGER" property="grantConditions"/>
        <result column="order_minimum" jdbcType="DECIMAL" property="orderMinimum"/>
        <result column="grant_start_time" jdbcType="TIMESTAMP" property="grantStartTime"/>
        <result column="grant_end_time" jdbcType="TIMESTAMP" property="grantEndTime"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <result column="grant_max_num" jdbcType="INTEGER" property="grantMaxNum"/>
        <result column="grant_num" jdbcType="INTEGER" property="grantNum"/>
        <result column="duration" jdbcType="INTEGER" property="duration"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, gmt_create, gmt_modified, creator, partner_id, coupon_name, coupon_amount, grant_rules,
        use_start_time, use_end_time, quantity_ceiling, use_conditions, use_conditions_content,
        grant_conditions, order_minimum, grant_start_time, grant_end_time, `status`, grant_max_num,
        grant_num,duration
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from coupon_rules
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        <!--@mbg.generated-->
        delete from coupon_rules
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.**.model.coupon.CouponRules"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into coupon_rules (gmt_create, gmt_modified, creator,
        partner_id, coupon_name, coupon_amount,
        grant_rules, use_start_time, use_end_time,
        quantity_ceiling, use_conditions, use_conditions_content,
        grant_conditions, order_minimum, grant_start_time,
        grant_end_time, `status`, grant_max_num,
        grant_num)
        values (#{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP}, #{creator,jdbcType=INTEGER},
        #{partnerId,jdbcType=INTEGER}, #{couponName,jdbcType=VARCHAR}, #{couponAmount,jdbcType=DECIMAL},
        #{grantRules,jdbcType=INTEGER}, #{useStartTime,jdbcType=TIMESTAMP}, #{useEndTime,jdbcType=TIMESTAMP},
        #{quantityCeiling,jdbcType=INTEGER}, #{useConditions,jdbcType=INTEGER},
        #{useConditionsContent,jdbcType=DECIMAL},
        #{grantConditions,jdbcType=INTEGER}, #{orderMinimum,jdbcType=DECIMAL}, #{grantStartTime,jdbcType=TIMESTAMP},
        #{grantEndTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, #{grantMaxNum,jdbcType=INTEGER},
        #{grantNum,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.**.model.coupon.CouponRules"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into coupon_rules
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="gmtCreate != null">
                gmt_create,
            </if>
            <if test="gmtModified != null">
                gmt_modified,
            </if>
            <if test="creator != null">
                creator,
            </if>
            <if test="partnerId != null">
                partner_id,
            </if>
            <if test="couponName != null">
                coupon_name,
            </if>
            <if test="couponAmount != null">
                coupon_amount,
            </if>
            <if test="grantRules != null">
                grant_rules,
            </if>
            <if test="useStartTime != null">
                use_start_time,
            </if>
            <if test="useEndTime != null">
                use_end_time,
            </if>
            <if test="quantityCeiling != null">
                quantity_ceiling,
            </if>
            <if test="useConditions != null">
                use_conditions,
            </if>
            <if test="useConditionsContent != null">
                use_conditions_content,
            </if>
            <if test="grantConditions != null">
                grant_conditions,
            </if>
            <if test="orderMinimum != null">
                order_minimum,
            </if>
            <if test="grantStartTime != null">
                grant_start_time,
            </if>
            <if test="grantEndTime != null">
                grant_end_time,
            </if>
            <if test="status != null">
                `status`,
            </if>
            <if test="grantMaxNum != null">
                grant_max_num,
            </if>
            <if test="grantNum != null">
                grant_num,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="gmtCreate != null">
                #{gmtCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="gmtModified != null">
                #{gmtModified,jdbcType=TIMESTAMP},
            </if>
            <if test="creator != null">
                #{creator,jdbcType=INTEGER},
            </if>
            <if test="partnerId != null">
                #{partnerId,jdbcType=INTEGER},
            </if>
            <if test="couponName != null">
                #{couponName,jdbcType=VARCHAR},
            </if>
            <if test="couponAmount != null">
                #{couponAmount,jdbcType=DECIMAL},
            </if>
            <if test="grantRules != null">
                #{grantRules,jdbcType=INTEGER},
            </if>
            <if test="useStartTime != null">
                #{useStartTime,jdbcType=TIMESTAMP},
            </if>
            <if test="useEndTime != null">
                #{useEndTime,jdbcType=TIMESTAMP},
            </if>
            <if test="quantityCeiling != null">
                #{quantityCeiling,jdbcType=INTEGER},
            </if>
            <if test="useConditions != null">
                #{useConditions,jdbcType=INTEGER},
            </if>
            <if test="useConditionsContent != null">
                #{useConditionsContent,jdbcType=DECIMAL},
            </if>
            <if test="grantConditions != null">
                #{grantConditions,jdbcType=INTEGER},
            </if>
            <if test="orderMinimum != null">
                #{orderMinimum,jdbcType=DECIMAL},
            </if>
            <if test="grantStartTime != null">
                #{grantStartTime,jdbcType=TIMESTAMP},
            </if>
            <if test="grantEndTime != null">
                #{grantEndTime,jdbcType=TIMESTAMP},
            </if>
            <开源推荐微信小程序&公众号商城管理系统

PRD:「FITLIFE」小程序产品需求文档(用户端)

微信小程序中的收藏功能(包含用户需求,数据库设计,后台功能,微信小程序功能,效果截图等)

微信小程序中的收藏功能(包含用户需求,数据库设计,后台功能,微信小程序功能,效果截图等)

qq小程序道具优惠劵怎么卡进去

微信小程序怎么做淘宝客优惠券商城手把手教你完成从申请到上线