Skip to content

上传预存code

商家券的Code码可由微信后台随机分配,同时支持商户自定义。如商家已有自己的优惠券系统,可直接使用自定义模式。即商家预先向微信支付上传券Code,当券在发放时,微信支付自动从已导入的Code中随机取值(不能指定),派发给用户。

请求参数类型描述
stock_idstring批次号
jsonobject声明请求的JSON数据结构
coupon_code_liststring[]
upload_request_nostring请求业务单据号
php
$instance->v3->marketing->busifavor->stocks->_stock_id_->couponcodes->postAsync([
  'stock_id' => '98065001',
  'json' => [
    'coupon_code_list' => ['string'],
    'upload_request_no' => '100002322019090134234sfdf',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/marketing/busifavor/stocks/{stock_id}/couponcodes')->postAsync([
  'stock_id' => '98065001',
  'json' => [
    'coupon_code_list' => ['string'],
    'upload_request_no' => '100002322019090134234sfdf',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/marketing/busifavor/stocks/{stock_id}/couponcodes']->postAsync([
  'stock_id' => '98065001',
  'json' => [
    'coupon_code_list' => ['string'],
    'upload_request_no' => '100002322019090134234sfdf',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->marketing->busifavor->stocks->_stock_id_->couponcodes->post([
  'stock_id' => '98065001',
  'json' => [
    'coupon_code_list' => ['string'],
    'upload_request_no' => '100002322019090134234sfdf',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/marketing/busifavor/stocks/{stock_id}/couponcodes')->post([
  'stock_id' => '98065001',
  'json' => [
    'coupon_code_list' => ['string'],
    'upload_request_no' => '100002322019090134234sfdf',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/marketing/busifavor/stocks/{stock_id}/couponcodes']->post([
  'stock_id' => '98065001',
  'json' => [
    'coupon_code_list' => ['string'],
    'upload_request_no' => '100002322019090134234sfdf',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
stock_idstring批次号
total_countinteger去重后上传code总数
success_countinteger上传成功code个数
success_codesstring[]
success_timestring上传成功时间
fail_countinteger上传失败code个数
fail_codesobject[]上传失败的code及原因
coupon_codestring上传失败的券code
codestring上传失败错误码
messagestring上传失败错误信息
exist_codesstring[]已存在的code列表
duplicate_codesstring[]本次请求中重复的code列表

参阅 官方文档

查询预存code列表

请求参数类型描述
stock_idstring批次号
queryobject声明请求的查询参数
statusstring券code状态
SENDED | USED | EXPIRED | DELETED | DEACTIVATED 枚举值之一
appidstring公众账号ID
offsetnumber分页页码
limitnumber分页大小
php
$instance->v3->marketing->busifavor->stocks->_stock_id_->couponcodes->getAsync([
  'stock_id' => '98065001',
  'query' => [
    'status' => 'SENDED',
    'appid' => 'wx233544546545989',
    'offset' => 0,
    'limit' => 20,
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/marketing/busifavor/stocks/{stock_id}/couponcodes')->getAsync([
  'stock_id' => '98065001',
  'query' => [
    'status' => 'SENDED',
    'appid' => 'wx233544546545989',
    'offset' => 0,
    'limit' => 20,
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/marketing/busifavor/stocks/{stock_id}/couponcodes']->getAsync([
  'stock_id' => '98065001',
  'query' => [
    'status' => 'SENDED',
    'appid' => 'wx233544546545989',
    'offset' => 0,
    'limit' => 20,
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->marketing->busifavor->stocks->_stock_id_->couponcodes->get([
  'stock_id' => '98065001',
  'query' => [
    'status' => 'SENDED',
    'appid' => 'wx233544546545989',
    'offset' => 0,
    'limit' => 20,
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/marketing/busifavor/stocks/{stock_id}/couponcodes')->get([
  'stock_id' => '98065001',
  'query' => [
    'status' => 'SENDED',
    'appid' => 'wx233544546545989',
    'offset' => 0,
    'limit' => 20,
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/marketing/busifavor/stocks/{stock_id}/couponcodes']->get([
  'stock_id' => '98065001',
  'query' => [
    'status' => 'SENDED',
    'appid' => 'wx233544546545989',
    'offset' => 0,
    'limit' => 20,
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
stock_idstring批次号
total_countinteger批次总数
limitinteger分页大小
offsetinteger分页页码
dataobject[]
codestring商户上传code
code_statusstring商户上传code分配状态
upload_timestring上传时间
dispatched_timestring被分配时间
openidstring领券用户的OpenID
unionidstring领券用户的UnionID
coupon_codestring用户券code

参阅 官方文档

Published on the GitHub by TheNorthMemory