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

{% macro receiverOperationParams() %} 参数说明

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

参数 类型 必填 说明
request_no String 分账接收关系集修改请求号,用户自己生成自己维护。2个字符以内,可包含字母、数字、下划线。需保证在商户端不重复。
receivers Receiver[] 待添加的分账接收方列表

Receiver 类型包括以下几个属性:

参数 类型 必填 说明
type ReceiverType 分账接收方类型
account String 分账接收方账户 id
name String 分账接收方全称

{{profitSharing.receiverTypeAlipay()}} {% endmacro %}

支付宝商家分账

{{ profitSharing.versionWarning() }}

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

添加分账接收方

BaaS.alipay.profitSharing.addReceiver(options)

{{receiverOperationParams()}}

示例代码

  1. BaaS.alipay.profitSharing.addReceiver({
  2. receivers: [{
  3. type: '...',
  4. account: '...',
  5. name: '...',
  6. }],
  7. request_no: '...',
  8. }).then(res => {
  9. // success
  10. }).catch(e=>{
  11. // HError 对象
  12. })

返回示例

成功时 res 对象结构如下

  1. {
  2. "data": {
  3. "result_code": "SUCCESS",
  4. "return_code": "10000"
  5. },
  6. "status": 200
  7. }

删除分账接收方

BaaS.alipay.profitSharing.removeReceiver(options)

{{receiverOperationParams()}}

示例代码

  1. BaaS.alipay.profitSharing.removeReceiver({
  2. receivers: [{
  3. type: '...',
  4. account: '...',
  5. name: '...',
  6. }],
  7. request_no: '...',
  8. }).then(res => {
  9. // success
  10. }).catch(e=>{
  11. // HError 对象
  12. })

返回示例

成功时 res 对象结构如下

  1. {
  2. "data": {
  3. "result_code": "SUCCESS",
  4. "return_code": "10000"
  5. },
  6. "status": 200
  7. }

查询分账接收关系集

BaaS.alipay.profitSharing.receiverQuery(options)

参数说明

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

参数 类型 必填 说明
request_no String 分账接收关系集查询请求号,用户自己生成自己维护。2个字符以内,可包含字母、数字、下划线。需保证在商户端不重复。
page_num Number 第几页,从1开始。不填默认为1
page_size Number 页面大小。每页记录数,取值范围是(0,100]。不填默认为20

示例代码

  1. BaaS.alipay.profitSharing.receiverQuery({
  2. request_no: '...',
  3. }).then(res => {
  4. // success
  5. }).catch(e=>{
  6. // HError 对象
  7. })

返回示例

成功时 res 对象结构如下

  1. {
  2. "data": {
  3. "current_page_num": 1,
  4. "current_page_size": 20,
  5. "receiver_list": [
  6. {
  7. "account": "...",
  8. "type": "userId"
  9. },
  10. {
  11. "account": "...",
  12. "type": "userId"
  13. }
  14. ],
  15. "result_code": "SUCCESS",
  16. "return_code": "10000",
  17. "total_page_num": 1,
  18. "total_record_num": 2
  19. },
  20. "status": 200
  21. }

分账订单操作

分账单查询

BaaS.alipay.profitSharing.Order#getOrderList()

支持分页操作 offsetlimit

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

参数说明

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

Status 可选值说明:

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

示例代码

  1. var order = new BaaS.alipay.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": 20,
  5. "next": null,
  6. "offset": 0,
  7. "previous": null,
  8. "total_count": 1
  9. },
  10. "objects": [
  11. {
  12. "created_by_name": "...",
  13. "order_type": "profit_sharing",
  14. "payment_order_id": 1058,
  15. "receiver": [
  16. {
  17. "account": "...",
  18. "amount": 1,
  19. "description": "分账1分钱",
  20. "type": "userId"
  21. }
  22. ],
  23. "status": "finished",
  24. "trade_no": "1iITyzXl8q9HYJIp0NaiHPxOB4x9zjto"
  25. }
  26. ]
  27. },
  28. "status": 200
  29. }