# Create a coupon

# Dxplaination of Interface Call Request

When creating the coupon, status = 1, note that all the time fields below are timestamps in seconds!

http请求方式:POST
https://api.weixin.qq.com/product/coupon/create?access_token=xxxxxxxxx

# Example of request parameters

{
    "type": 1,
    "name" : "双十一特惠满100-50",  //长度 <= 10
    "discount_info" : 
    {
        "discount_condition" : 
        {
            "product_cnt" : 10,//商品折扣券填
            "product_ids" : //商品券填
            [
                1673110742,
                1673110743
            ],
            "product_price" : 100//满减券填
        },
        "discount_fee" : 50,//满减金额
        "discount_num" : 5000//折扣券填,换算规则,比如5000=5折,7800=7.8折,范围是1000-10000,必须是100的整数
    },
    "ext_info" : 
    {
        "jump_product_id" : 1673110742,//商品券可以填,领取后跳转
        "notes" : "备注",
        "valid_time" : 1673110742,  // valid_type=1时与valid_info.start_time一致, valid_type=2时商家自己填一个绝对开始时间
        "invalid_time" : 1673110742 // valid_type=1时与valid_info.end_time一致, valid_type=2时商家自己填一个绝对结束时间
    },
    "promote_info" : 
    {
        "customize_channel" : "//自定义推广渠道,具体内容",
        "promote_type" : 1     //推广类型,1:店铺内推广,2:自定义推广渠道
    },
    "receive_info" : // 允许用户领取优惠券的设置
    {
        "end_time" : 1673110742,
        "limit_num_one_person" : 1,
        "start_time" : 1673110742,
        "total_num" : 100
    },
    "valid_info" : 
    {
        "end_time" : 1673110742,        //绝对生效开始时间, valid_type=1时必填
        "start_time" : 1673110742,      //绝对生效结束时间, valid_type=1时必填
        "valid_day_num" : 1,            //相对生效时间时长, 以用户领到券的时候开始算, valid_type=2时必填
         "valid_type" : 1
    }
}

# Examples of back-up

{
    "errcode": 0,
    "errmsg": "ok",
    "data": {
        "coupon_id": 111
    }
}

# Dxplaination of request parameters

参数 type Is it compulsory? Introductions
type number yes Types of coupons
name string yes Coupon Name
discount_info.discount_condition.product_cnt number no The amount of discounted merchandise vouchers
discount_info.discount_condition.product_ids number no Product id, product discount coupon need to fill in
discount_info.discount_condition.product_price number no Product prices, full coupons need to be filled in
discount_info.discount_fee number no The amount reduced is in units. Direct reductions and full reductions are required
discount_info.discount_num number no Number of items discounted, full discount vouchers need to be filled in, conversion rules, 5000 = 5 discount, 7000 = 7 discount, range is 1000 - 10000, must be an integer of 100
ext_info.invalid_time number yes Coupon expiration timestamp
ext_info.jump_product_id number no The product id of the jump after receiving the discount coupon
ext_info.notes string no Note information
ext_info.valid_time number yes Coupon Expiration Date
promote_info.customize_channel string yes User-Defined Promotion Channel
promote_info.promote_type number yes Types of promotion
receive_info.end_time number yes Coupon Acceptance End Time Stamp
receive_info.limit_num_one_person number yes Limit on number of tickets per person
receive_info.start_time number yes Coupon Acceptance Begins Date
receive_info.total_num number yes Total number of coupons received
valid_info.end_time number no The coupon has an expiration date, if start is required
valid_info.start_time number no Choose between valid_day_num and valid_day_num
valid_info.valid_day_num number yes Choose between the number of days the coupon is valid and start_time
valid_info.valid_type number yes Type of coupon validity

# Dxplaination of callback parameters

参数 type Introductions
errcode number Error code
errmsg string Error message
data.coupon_id number Coupon ID

# Enumeration - coupon_type

枚举值 describe
1 Discount coupon, discount_condition.product_ids, discount_condition.product_cnt, discount_info.discount_num Required
2 Discount coupon, discount_condition.product_ids, discount_condition.product_price, discount_info.discount_fee required
3 Product Uniform Discount Coupon, discount_condition.product_ids, discount_info.discount_num Required
4 Direct discount coupon, if less than the minimum price of the available item will be reminded (no item more than 50w reminder), discount_condition.product_ids, discount_fee required
101 Store Condition Discount Coupon, discount_condition.product_cnt, discount_info.discount_num required
102 Shop full discount coupon, discount_condition.product_price, discount_info.discount_fee required
103 Store Unified Discount Coupon, discount_info.discount_num required
104 Store direct discount coupon, if less than the minimum price of available items will be reminded (no item more than 50w reminder), discount_fee required

# Enumeration - valid_type

枚举值 describe
1 The specified time frame takes effect
2 Number of days in effect

# Return code

返回码 Error Type
-1 System exceptions
-2 Token too long
9401020 The parameter is incorrect.