Skip to content

向用户预发放商品券

品牌方可以通过本接口向用户预发放指定商品券批次,并使用返回的token在领券组件中完成发券,当用户已领取过时使用相同参数获取的token拉起的领券组件会返回已领取状态,能否发放受限于商品券批次的发放限额:1. 商品券批次总预算; 2. 商品券批次每日预算(如果有); 3. 商品券批次每人限领(如果有)

请求参数类型描述
openidstring用户OpenID
jsonobject声明请求的JSON数据结构
brand_idstring品牌ID
product_coupon_idstring商品券ID
stock_idstring批次ID
coupon_codestring用户商品券Code
appidstring公众账号AppID
send_request_nostring发券请求单号
attachstring自定义附加信息
php
$instance->v3->marketing->partner->productCoupon->users->_openid_->preSendCoupon->postAsync([
  'openid' => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
  'json' => [
    'brand_id'          => '120344',
    'product_coupon_id' => '1000000013',
    'stock_id'          => '1000000013001',
    'coupon_code'       => '123446565767',
    'appid'             => 'wx233544546545989',
    'send_request_no'   => '34657_20250101_123456',
    'attach'            => 'example_attach',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/marketing/partner/product-coupon/users/{openid}/pre-send-coupon')->postAsync([
  'openid' => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
  'json' => [
    'brand_id'          => '120344',
    'product_coupon_id' => '1000000013',
    'stock_id'          => '1000000013001',
    'coupon_code'       => '123446565767',
    'appid'             => 'wx233544546545989',
    'send_request_no'   => '34657_20250101_123456',
    'attach'            => 'example_attach',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/marketing/partner/product-coupon/users/{openid}/pre-send-coupon']->postAsync([
  'openid' => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
  'json' => [
    'brand_id'          => '120344',
    'product_coupon_id' => '1000000013',
    'stock_id'          => '1000000013001',
    'coupon_code'       => '123446565767',
    'appid'             => 'wx233544546545989',
    'send_request_no'   => '34657_20250101_123456',
    'attach'            => 'example_attach',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->marketing->partner->productCoupon->users->_openid_->preSendCoupon->post([
  'openid' => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
  'json' => [
    'brand_id'          => '120344',
    'product_coupon_id' => '1000000013',
    'stock_id'          => '1000000013001',
    'coupon_code'       => '123446565767',
    'appid'             => 'wx233544546545989',
    'send_request_no'   => '34657_20250101_123456',
    'attach'            => 'example_attach',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/marketing/partner/product-coupon/users/{openid}/pre-send-coupon')->post([
  'openid' => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
  'json' => [
    'brand_id'          => '120344',
    'product_coupon_id' => '1000000013',
    'stock_id'          => '1000000013001',
    'coupon_code'       => '123446565767',
    'appid'             => 'wx233544546545989',
    'send_request_no'   => '34657_20250101_123456',
    'attach'            => 'example_attach',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/marketing/partner/product-coupon/users/{openid}/pre-send-coupon']->post([
  'openid' => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
  'json' => [
    'brand_id'          => '120344',
    'product_coupon_id' => '1000000013',
    'stock_id'          => '1000000013001',
    'coupon_code'       => '123446565767',
    'appid'             => 'wx233544546545989',
    'send_request_no'   => '34657_20250101_123456',
    'attach'            => 'example_attach',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
tokenstring预发券token

Published on the GitHub by TheNorthMemory