Skip to content

向用户预发放商品券

商户通过本接口向用户预发放指定商品券批次,并使用返回的token在「小程序发券组件」中完成发券。支持发放两种商品券:单券模式:用户只能使用一次,使用后券失效。多次优惠模式:用户可以按顺序多次使用,每次核销成功后会发放下一次优惠机会,直到用完为止。

请求参数类型描述
jsonobject声明请求的JSON数据结构
stock_idstring批次ID
coupon_codestring用户商品券Code
appidstring公众账号AppID
openidstring用户OpenID
send_request_nostring发券请求单号
php
$instance->v3->marketing->busifavor->productCoupons->preSend->postAsync([
  'json' => [
    'stock_id'        => '1000000013001',
    'coupon_code'     => '123446565767',
    'appid'           => 'wx233544546545989',
    'openid'          => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
    'send_request_no' => '34657_20250101_123456',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/marketing/busifavor/product-coupons/pre-send')->postAsync([
  'json' => [
    'stock_id'        => '1000000013001',
    'coupon_code'     => '123446565767',
    'appid'           => 'wx233544546545989',
    'openid'          => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
    'send_request_no' => '34657_20250101_123456',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/marketing/busifavor/product-coupons/pre-send']->postAsync([
  'json' => [
    'stock_id'        => '1000000013001',
    'coupon_code'     => '123446565767',
    'appid'           => 'wx233544546545989',
    'openid'          => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
    'send_request_no' => '34657_20250101_123456',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->marketing->busifavor->productCoupons->preSend->post([
  'json' => [
    'stock_id'        => '1000000013001',
    'coupon_code'     => '123446565767',
    'appid'           => 'wx233544546545989',
    'openid'          => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
    'send_request_no' => '34657_20250101_123456',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/marketing/busifavor/product-coupons/pre-send')->post([
  'json' => [
    'stock_id'        => '1000000013001',
    'coupon_code'     => '123446565767',
    'appid'           => 'wx233544546545989',
    'openid'          => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
    'send_request_no' => '34657_20250101_123456',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/marketing/busifavor/product-coupons/pre-send']->post([
  'json' => [
    'stock_id'        => '1000000013001',
    'coupon_code'     => '123446565767',
    'appid'           => 'wx233544546545989',
    'openid'          => 'oh-394z-6CGkNoJrsDLTTUKiAnp4',
    'send_request_no' => '34657_20250101_123456',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
tokenstring预发券token

参阅 官方文档

Published on the GitHub by TheNorthMemory