Skip to content

根据手机号导入用户会员卡

对于经营会员生意的商家来说,存量会员的注册渠道广泛,包括但不限于线下渠道、微信渠道、App及其他线上渠道。因而,在微信生态下经营会员时常遇到两类问题:(1)存量会员的身份难统一识别;(2)在应用「开卡有礼」活动能力时,容易对存量(但未同步身份至微信侧的)老会员重复补贴。因而,若商家侧存在较多线下渠道注册的存量会员,则商家可通过加密后的用户手机号,将存量会员通过接口导入至微信侧后台。注意:1、“导入”仅为后台操作,微信会员卡系统会在后台将用户的会员卡静默激活,但不会在用户卡包中自动出现该会员卡,建议商家侧后续在其他路径引导用户主动添加会员卡到卡包;2、用户手机号,需调用方按接口文档要求加密后再传入。

请求参数类型描述
jsonobject声明请求的JSON数据结构
brand_idstring品牌ID
card_idstring会员卡模板ID
phone_numberstring加密的手机号
user_card_codestring会员卡code
user_informationobject用户开卡时填写的个人信息
common_field_listobject[]平台提供的通用开卡信息字段
namestring平台提供的通用开卡信息字段
USER_FORM_FLAG_SEX | USER_FORM_FLAG_NAME | USER_FORM_FLAG_BIRTHDAY | USER_FORM_FLAG_ADDRESS | USER_FORM_FLAG_EMAIL | USER_FORM_FLAG_CITY 枚举值之一
valuestring加密的用户开卡时填写的个人信息
custom_field_listobject[]商户自定义的开卡信息字段
namestring字段名称
user_chosen_valuesstring[]加密的用户选择的字段值列表
date_informationobject会员卡有效期
typestring有效期类型
FIX_TIME_RANGE | FIX_TERM | PERMANENT 枚举值之一
available_begin_timestring有效期开始时间
available_end_timestring有效期结束时间
available_day_after_receiveinteger生效后N天内有效
pickup_timestring领取时间
headersobject声明请求的头参数
Wechatpay-Serialstring微信支付公钥ID/平台证书序列号
php
$instance->v3->brand->partner->cardMember->userCards->importByPhone->postAsync([
  'json' => [
    'brand_id'         => '1004',
    'card_id'          => 'pbLatjvWOibDc5-TBnbUk1pD12o0',
    'phone_number'     => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
    'user_card_code'   => '478515832665',
    'user_information' => [
      'common_field_list' => [[
        'name'  => 'USER_FORM_FLAG_SEX',
        'value' => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
      ],],
      'custom_field_list' => [[
        'name'               => '喜欢的运动',
        'user_chosen_values' => ['vvysDQeEaH3I+wRh14St0abIkvQyFgh/'],
      ],],
    ],
    'date_information' => [
      'type'                        => 'FIX_TIME_RANGE',
      'available_begin_time'        => '2020-05-20T13:29:35.120+08:00',
      'available_end_time'          => '2030-05-20T13:29:35.120+08:00',
      'available_day_after_receive' => 200,
    ],
    'pickup_time'      => '2020-05-20T13:29:35.120+08:00',
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/brand/partner/card-member/user-cards/import-by-phone')->postAsync([
  'json' => [
    'brand_id'         => '1004',
    'card_id'          => 'pbLatjvWOibDc5-TBnbUk1pD12o0',
    'phone_number'     => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
    'user_card_code'   => '478515832665',
    'user_information' => [
      'common_field_list' => [[
        'name'  => 'USER_FORM_FLAG_SEX',
        'value' => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
      ],],
      'custom_field_list' => [[
        'name'               => '喜欢的运动',
        'user_chosen_values' => ['vvysDQeEaH3I+wRh14St0abIkvQyFgh/'],
      ],],
    ],
    'date_information' => [
      'type'                        => 'FIX_TIME_RANGE',
      'available_begin_time'        => '2020-05-20T13:29:35.120+08:00',
      'available_end_time'          => '2030-05-20T13:29:35.120+08:00',
      'available_day_after_receive' => 200,
    ],
    'pickup_time'      => '2020-05-20T13:29:35.120+08:00',
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/brand/partner/card-member/user-cards/import-by-phone']->postAsync([
  'json' => [
    'brand_id'         => '1004',
    'card_id'          => 'pbLatjvWOibDc5-TBnbUk1pD12o0',
    'phone_number'     => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
    'user_card_code'   => '478515832665',
    'user_information' => [
      'common_field_list' => [[
        'name'  => 'USER_FORM_FLAG_SEX',
        'value' => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
      ],],
      'custom_field_list' => [[
        'name'               => '喜欢的运动',
        'user_chosen_values' => ['vvysDQeEaH3I+wRh14St0abIkvQyFgh/'],
      ],],
    ],
    'date_information' => [
      'type'                        => 'FIX_TIME_RANGE',
      'available_begin_time'        => '2020-05-20T13:29:35.120+08:00',
      'available_end_time'          => '2030-05-20T13:29:35.120+08:00',
      'available_day_after_receive' => 200,
    ],
    'pickup_time'      => '2020-05-20T13:29:35.120+08:00',
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->brand->partner->cardMember->userCards->importByPhone->post([
  'json' => [
    'brand_id'         => '1004',
    'card_id'          => 'pbLatjvWOibDc5-TBnbUk1pD12o0',
    'phone_number'     => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
    'user_card_code'   => '478515832665',
    'user_information' => [
      'common_field_list' => [[
        'name'  => 'USER_FORM_FLAG_SEX',
        'value' => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
      ],],
      'custom_field_list' => [[
        'name'               => '喜欢的运动',
        'user_chosen_values' => ['vvysDQeEaH3I+wRh14St0abIkvQyFgh/'],
      ],],
    ],
    'date_information' => [
      'type'                        => 'FIX_TIME_RANGE',
      'available_begin_time'        => '2020-05-20T13:29:35.120+08:00',
      'available_end_time'          => '2030-05-20T13:29:35.120+08:00',
      'available_day_after_receive' => 200,
    ],
    'pickup_time'      => '2020-05-20T13:29:35.120+08:00',
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/brand/partner/card-member/user-cards/import-by-phone')->post([
  'json' => [
    'brand_id'         => '1004',
    'card_id'          => 'pbLatjvWOibDc5-TBnbUk1pD12o0',
    'phone_number'     => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
    'user_card_code'   => '478515832665',
    'user_information' => [
      'common_field_list' => [[
        'name'  => 'USER_FORM_FLAG_SEX',
        'value' => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
      ],],
      'custom_field_list' => [[
        'name'               => '喜欢的运动',
        'user_chosen_values' => ['vvysDQeEaH3I+wRh14St0abIkvQyFgh/'],
      ],],
    ],
    'date_information' => [
      'type'                        => 'FIX_TIME_RANGE',
      'available_begin_time'        => '2020-05-20T13:29:35.120+08:00',
      'available_end_time'          => '2030-05-20T13:29:35.120+08:00',
      'available_day_after_receive' => 200,
    ],
    'pickup_time'      => '2020-05-20T13:29:35.120+08:00',
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/brand/partner/card-member/user-cards/import-by-phone']->post([
  'json' => [
    'brand_id'         => '1004',
    'card_id'          => 'pbLatjvWOibDc5-TBnbUk1pD12o0',
    'phone_number'     => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
    'user_card_code'   => '478515832665',
    'user_information' => [
      'common_field_list' => [[
        'name'  => 'USER_FORM_FLAG_SEX',
        'value' => 'vvysDQeEaH3I+wRh14St0abIkvQyFgh/fbWY==',
      ],],
      'custom_field_list' => [[
        'name'               => '喜欢的运动',
        'user_chosen_values' => ['vvysDQeEaH3I+wRh14St0abIkvQyFgh/'],
      ],],
    ],
    'date_information' => [
      'type'                        => 'FIX_TIME_RANGE',
      'available_begin_time'        => '2020-05-20T13:29:35.120+08:00',
      'available_end_time'          => '2030-05-20T13:29:35.120+08:00',
      'available_day_after_receive' => 200,
    ],
    'pickup_time'      => '2020-05-20T13:29:35.120+08:00',
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
user_card_codestring会员卡code
card_idstring会员卡模板ID
openidstring用户标识
card_colorstring卡背景颜色
card_picture_urlstring卡背景图URL
brand_idstring品牌ID
card_typestring会员卡类型
PURCHASE | NORMAL | BALANCE 枚举值之一
phone_numberstring加密的手机号
levelstring等级
valid_date_informationobject会员卡有效期
typestring有效期类型
FIX_TIME_RANGE | FIX_TERM | PERMANENT 枚举值之一
available_begin_timestring有效期开始时间
available_end_timestring有效期结束时间
available_day_after_receiveinteger生效后N天内有效
pickup_timestring领取时间
user_informationobject用户开卡时填写的个人信息
common_field_listobject[]平台提供的通用开卡信息字段
namestring平台提供的通用开卡信息字段
USER_FORM_FLAG_SEX | USER_FORM_FLAG_NAME | USER_FORM_FLAG_BIRTHDAY | USER_FORM_FLAG_ADDRESS | USER_FORM_FLAG_EMAIL | USER_FORM_FLAG_CITY 枚举值之一
valuestring加密的用户开卡时填写的个人信息
custom_field_listobject[]商户自定义的开卡信息字段
namestring字段名称
user_chosen_valuesstring[]加密的用户选择的字段值列表
attachstring商家数据包
user_card_statestring用户会员卡状态
UNACTIVATED | EFFECTIVE | EXPIRED | INVALID 枚举值之一
invalid_reasonstring作废原因
invalid_timestring作废时间

参阅 官方文档

Published on the GitHub by TheNorthMemory