{% import “./macro/profit-sharing.md” as profitSharing %}

微信直连商户分账

{{ profitSharing.versionWarning() }}

对某一订单进行分账,请查看订单操作文档

添加分账接收方

BaaS.wechat.profitSharing.addReceiver(options)

参数说明

options 是 Object 类型,它包括以下几个属性

参数 类型 必填 说明
mch_id String 商户号
appid String 微信分配的公众账号 ID
type ReceiverType 分账接收方类型
account String 分账接收方账户 id
relation_type ReceiverRelationType 与分账商户的关系类型
name String 分账接收方全称,type 不为 PERSONAL_OPENID 时必填
custom_relation String relation_type 为 CUSTOM 时必填

{{profitSharing.receiverType()}}

ReceiverRelationType 可选值说明:

说明
‘SERVICE_PROVIDER’ 服务商
‘STORE’ 门店
‘STAFF’ 员工
‘STORE_OWNER’ 店主
‘PARTNER’ 合作伙伴
‘HEADQUARTER’ 总部
‘BRAND’ 品牌方
‘DISTRIBUTOR’ 分销商
‘USER’ 用户
‘SUPPLIER’ 供应商
‘CUSTOM’ 自定义

示例代码

  1. BaaS.wechat.profitSharing.addReceiver({
  2. mch_id: '...',
  3. appid: '...',
  4. type: '...',
  5. account: '...',
  6. relation_type: '...',
  7. name: '...',
  8. custom_relation: '...',
  9. }).then(res => {
  10. // success
  11. }).catch(e=>{
  12. // HError 对象
  13. })

返回示例

成功时 res 对象结构如下

  1. {
  2. "data": {
  3. "return_code": "SUCCESS",
  4. "appid": "...",
  5. "receiver": "{\"type\":\"...\",\"account\":\"...\",\"relation_type\":\"...\"}",
  6. "mch_id": "..."
  7. },
  8. "status": 200
  9. }

删除分账接收方

BaaS.wechat.profitSharing.removeReceiver(options)

参数说明

options 是 Object 类型,它包括以下几个属性

参数 类型 必填 说明
mch_id String 商户号
appid String 微信分配的公众账号 ID
type ReceiverType 分账接收方类型
account String 分账接收方账户 id

{{profitSharing.receiverType()}}

示例代码

  1. BaaS.wechat.profitSharing.removeReceiver({
  2. mch_id: '...',
  3. appid: '...',
  4. type: '...',
  5. account: '...',
  6. }).then(res => {
  7. // success
  8. }).catch(e=>{
  9. // HError 对象
  10. })

返回示例

成功时 res 对象结构如下

  1. {
  2. "data": {
  3. "return_code": "SUCCESS",
  4. "appid": "...",
  5. "receiver": "{\"type\": \"...\", \"account\": \"...\"}",
  6. "mch_id": "..."
  7. },
  8. "status": 200
  9. }

分账订单操作

分账单查询

BaaS.wechat.profitSharing.Order#getOrderList()

支持分页操作 offsetlimit

params 是 Object 类型,为订单过滤条件,你可以参考后面的返回参数说明,进行筛选。

参数说明

参数 类型 说明
params.trade_no String 分账单号
params.status Status 分账单状态
params.order_type Type 分账单类型

Status 可选值说明:

说明
‘accepted’ 受理成功
‘processing’ 处理中
‘finished’ 处理完成
‘closed’ 处理失败,已关单

Type 可选值说明:

说明
‘profit_sharing’ 单次分账单
‘multi_profit_sharing’ 多次分账单
‘finish’ 完结分账单

示例代码

  1. var order = new BaaS.wechat.profitSharing.Order()
  2. order.offset(20).limit(20).getOrderList({trade_no: '...'}).then(res => {
  3. // success
  4. }).catch(e=>{
  5. // HError 对象
  6. })

返回示例

成功时 res 对象结构如下

  1. {
  2. "data": {
  3. "meta": {
  4. "limit": 99,
  5. "next": null,
  6. "offset": 0,
  7. "previous": null,
  8. "total_count": 15
  9. },
  10. "objects": [{
  11. "created_by_name": "...",
  12. "order_type": "finish",
  13. "payment_order_id": 1026,
  14. "receiver": null,
  15. "status": "accepted",
  16. "trade_no": "..."
  17. }],
  18. },
  19. "status": 200
  20. }

完结分账

BaaS.wechat.profitSharing.Order#finish(options)

{{ profitSharing.warning() }}

参数说明

options 是 Object 类型,它包括以下几个属性

参数 类型 必填 说明
trade_no String 支付订单订单号(必须为微信支付订单)
appid String 微信分配的公众账号 ID
description String 分账完结描述

示例代码

  1. var order = new BaaS.wechat.profitSharing.Order()
  2. order.finish({
  3. trade_no: '...',
  4. appid: '...',
  5. description: '...',
  6. }).then(res => {
  7. // success
  8. }).catch(e=>{
  9. // HError 对象
  10. })

返回示例

成功时 res 对象结构如下

  1. {
  2. "data": {
  3. "wechat_order_no": "...",
  4. "mch_id": "...",
  5. "trade_no": "...",
  6. "return_code": "SUCCESS",
  7. "appid": "..."
  8. },
  9. "status": 200
  10. }

分账回退

BaaS.wechat.profitSharing.Order#refund(options)

info 此功能需要接收方在商户平台-交易中心-分账-分账接收设置下,开启同意分账回退后,才能使用。

{{ profitSharing.warning() }}

参数说明

options 是 Object 类型,它包括以下几个属性

参数 类型 必填 说明
trade_no String 分账单单号(非支付订单单号)
appid String 微信分配的公众账号 ID
refund_no String 分账回退单号,用户自己生成自己维护,商户系统内部唯一,同一回退单号多次请求等同一次,只能是数字、大小写字母_- *@
type ReceiverType 分账回退方类型
account String 分账回退方账户 id
amount Number 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
description String 分账回退描述

{{profitSharing.receiverType()}}

示例代码

  1. var order = new BaaS.wechat.profitSharing.Order()
  2. order.refund({
  3. trade_no: '...',
  4. appid: '...',
  5. refund_no: '...',
  6. type: '...',
  7. account: '...',
  8. amount: 100,
  9. description: '...',
  10. }).then(res => {
  11. // success
  12. }).catch(e=>{
  13. // HError 对象
  14. })

返回示例

成功时 res 对象结构如下

  1. {
  2. "data": {
  3. "fail_reason": null,
  4. "result": "SUCCESS",
  5. "refund_no": "...",
  6. "wechat_refund_no": "...",
  7. "appid": "...",
  8. "description": "...",
  9. "return_code": "SUCCESS",
  10. "amount": 1,
  11. "mch_id": "...",
  12. "finish_time": "...",
  13. "account_type": "...",
  14. "account": "..."
  15. },
  16. "status": 200
  17. }

分账回退结果查询

BaaS.wechat.profitSharing.Order#getRefundmentOrder(options)

参数说明

options 是 Object 类型,它包括以下几个属性

参数 类型 必填 说明
trade_no String 分账单单号(非支付订单单号)
appid String 微信分配的公众账号 ID
refund_no String 分账回退单号,用户自己生成自己维护,商户系统内部唯一,同一回退单号多次请求等同一次,只能是数字、大小写字母_- *@

示例代码

  1. var order = new BaaS.wechat.profitSharing.Order()
  2. order.getRefundmentOrder({
  3. trade_no: '...',
  4. appid: '...',
  5. refund_no: '...',
  6. }).then(res => {
  7. // success
  8. }).catch(e=>{
  9. // HError 对象
  10. })

返回示例

成功时 res 对象结构如下

  1. {
  2. "data": {
  3. "mch_id": "...",
  4. "fail_reason": null,
  5. "description": "...",
  6. "refund_no": "...",
  7. "result": "SUCCESS",
  8. "return_code": "SUCCESS",
  9. "appid": "...",
  10. "account_type": "...",
  11. "amount": 1,
  12. "finish_time": "...",
  13. "wechat_refund_no": "...",
  14. "account": "..."
  15. },
  16. "status": 200
  17. }