结算芝麻 GO 周期扣版
芝麻 GO 结算流程

第一步:协议退出通知
第二步:数据查询
请求示例
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", "app_id", "your private_key", "json", "GBK", "alipay_public_key", "RSA2");
ZhimaMerchantZmgoCumulateQueryRequest request = new ZhimaMerchantZmgoCumulateQueryRequest();
request.setBizContent("{" +
"\"agreement_id\":\"20195108518085620000\"," +
"\"user_id\":\"2088602002015001\"," +
"\"provider_pid\":\"2088621805983504\"," +
"\"need_detail\":false," +
"\"page_no\":1," +
"\"page_size\":20" +
" }");
ZhimaMerchantZmgoCumulateQueryResponse response = alipayClient.execute(request);
if (response.isSuccess()) {
System.out.println("调用成功");
} else {
System.out.println("调用失败");
}
响应示例
{
"zhima_merchant_zmgo_cumulate_query_response": {
"code": "10000",
"msg": "Success",
"agreement_id": "20195108518085620000",
"aggr_amount": 99.99,
"aggr_times": 4,
"aggr_discount_amount": 83.88,
"page_no": 1,
"page_size": 20,
"detail_list": [
{
"out_biz_no": "2020081211223006150094012926289",
"refer_out_biz_no": "2020081211223006150094012926289",
"biz_time": "2019-03-08 19:51:35",
"action_type": "POSITIVE",
"data_type": "TASK",
"sub_data_type": "AMOUNT",
"task_desc": "完成一次任务001",
"task_amount": 17.88,
"task_times": 1,
"discount_desc": "消费满减优惠001",
"discount_amount": 7.08
}
],
"fail_reason": "协议已经失效"
},
"sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}
第三步:发起结算
发起结算申请
请求示例
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do","app_id","your private_key","json","GBK","alipay_public_key","RSA2");
ZhimaCreditPeZmgoSettleApplyRequest request = new ZhimaCreditPeZmgoSettleApplyRequest();
request.setBizContent("{" +
"\"agreement_id\":\"ZMGO_AGR2020122710020604120000000001\"," +
"\"alipay_user_id\":\"2088101117955611\"," +
"\"partner_id\":\"2088102146225135\"," +
"\"out_request_no\":\"8077735255938032\"," +
"\"withhold_plan_no\":\"ZMGO_WHD2021010510020603410000006001\"," +
"\"pay_amount\":2.00," +
"\"total_real_pay_amount\":3.00," +
"\"total_discount_amount\":3.00," +
"\"total_task_count\":\"0\"," +
"\"action_type\":\"DEFAULT_SETTLE\"," +
"\"settle_extend_params\":{" +
"\"quit_type\":\"SETTLE_APPLY_QUIT\"" +
" }" +
" }");
ZhimaCreditPeZmgoSettleApplyResponse response = alipayClient.execute(request);
if(response.isSuccess()){
System.out.println("调用成功");
} else {
System.out.println("调用失败");
}
响应示例
{
"zhima_credit_pe_zmgo_settle_apply_response": {
"code": "10000",
"msg": "Success",
"out_request_no": "8077735255938032",
"agreement_id": "ZMGO_AGR2020122710020604120000000001",
"withhold_plan_no": "ZMGO_WHD2021010510020603410000006001",
"settle_status": "P",
"fail_reason": "累计支付宝支付金额不一致,支付宝:100.00元,商户:150.00元"
},
"sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}
结算接口可能返回几类异常信息
异常类型 | 解决方案 |
---|---|
两端金额比对不一致 | 原因 1:支付宝端累加金额发生延迟 方案:支付宝端一般会在用户发生交易后1分钟内完成消费累计,发生异常时也一般不超过 6 小时,商家可稍后重试,如果商家本身就是 T+1 的来做结算,则基本不会碰到该原因。原因 2:商家端累加发生延迟 方案:商户端累加完成后再发起重试。原因 3:商家端累计错误、会员费计算规则错误 方案:根据出参中返回的 fail_reason,商户排查自身数据原因,调整后再重试发起。 |
业务类异常 | 若商家协议已失效,商家账号被冻结,商家收款额度超限等业务异常,光靠系统重试是无法解决问题的,需要商户介入处理后再重试。 |
系统类异常 | 若支付宝端处理超时,内部未知异常等,可稍后重试。 |