天天看點

使用者口碑優惠資産查詢接口詳解

說明: 

在使用者查詢口碑優惠資産資訊,檢視可享受的優惠。 

調用流程: 

使用者口碑優惠資産查詢接口詳解

需要注意的點: 

1.該接口有三個枚舉,分别是: 

A 使用者所有資産(USER_ALL_ASSET), 

B 使用者指定商戶可用資産(USER_MERCHANT_ASSET), 

C 使用者指定門店可用資産(USER_SHOP_ASSET) 

2.因為接口是使用者查詢口碑優惠資産資訊,是以肯定是需要【

使用者資訊授權

】的,在喚起使用者授權頁面的過程中,需在拼接跳轉的url中指定固定的scope參數值,此參數可保證較長時間的有效性(為期一年),即使用者僅需授權一次後即可維持一年的授權有效期,參數值為scope=auth_user_assets。 針對其他場景,比如會員卡,閃電開票,生活繳費等不同産品,scope是不同的,如果scope傳遞錯誤,相當于使用者并沒有授權給ISV這個産品的權限,是以在調用接口時會報錯“無效的通路令牌”。 

無效的通路令牌”排查方案

】 

3.如果您是代商戶開發內建,在查詢使用者指定商戶可用資産(USER_MERCHANT_ASSET)、使用者指定門店可用資産(USER_SHOP_ASSET)時還需要用到【

第三方應用授權

】;指定USER_SHOP_ASSET必須傳遞shop_id參數 

4.如果接口中既需要第三方應用授權,又需要使用者資訊授權,相當于使用者是授權給商戶,而不是ISV。是以在拼接使用者資訊授權的url時,url連結中的APPID和redirect_uri參數需要傳遞商戶的 

代碼示例: 

1.查詢使用者所有資産 

AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",AlipayConfig.app_id,AlipayConfig.merchant_private_key,"json","GBK",AlipayConfig.alipay_public_key,"RSA2");
  
  
KoubeiMarketingCampaignUserAssetQueryRequest request = new KoubeiMarketingCampaignUserAssetQueryRequest();
  
request.setBizContent("{" +
""scope":"USER_ALL_ASSET"," +
""page_num":1," +
""page_size":50" +
"}");
KoubeiMarketingCampaignUserAssetQueryResponse response;
try {
    response = alipayClient.execute(request,"uassetsBcf4f2ca7d4ae4d50960995fea73b8X40");
      
    if(response.isSuccess()){
        System.out.println("調用成功"+response.getBody());
        } else {
        System.out.println("調用失敗"+response.getBody());
        }
      
} catch (AlipayApiException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}finally {
                         
}      

2.查詢使用者指定商戶可用資産 

AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",AlipayConfig.app_id,AlipayConfig.merchant_private_key,"json","GBK",AlipayConfig.alipay_public_key,"RSA2");
  
  
KoubeiMarketingCampaignUserAssetQueryRequest request = new KoubeiMarketingCampaignUserAssetQueryRequest();
  
request.putOtherTextParam("app_auth_token","201803BBbb7ea300ac0342b78d34bd9ea3a96X35");
request.setBizContent("{" +
""scope":"USER_MERCHANT_ASSET"," +
""page_num":1," +
""page_size":50" +
"}");
KoubeiMarketingCampaignUserAssetQueryResponse response;
try {
    response = alipayClient.execute(request,"uassetsB05f0c40dee374f7db6d0c72d93c8eX40");
      
    if(response.isSuccess()){
        System.out.println("調用成功"+response.getBody());
        } else {
        System.out.println("調用失敗"+response.getBody());
        }
      
} catch (AlipayApiException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}finally {
      
}      

3.查詢使用者指定門店可用資産 

AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",AlipayConfig.app_id,AlipayConfig.merchant_private_key,"json","GBK",AlipayConfig.alipay_public_key,"RSA2");
          
          
        KoubeiMarketingCampaignUserAssetQueryRequest request = new KoubeiMarketingCampaignUserAssetQueryRequest();
      
        request.putOtherTextParam("app_auth_token","201803BBbb7ea300ac0342b78d34bd9ea3a96X35");
        request.setBizContent("{" +
        ""scope":"USER_MERCHANT_ASSET"," +
        ""page_num":1," +
        ""shop_id":"20170xxxxxxxxxxxxxx"," +
        ""page_size":50" +
        "}");
        KoubeiMarketingCampaignUserAssetQueryResponse response;
        try {
            response = alipayClient.execute(request,"uassetsB05f0c40dee374f7db6d0c72d93c8eX40");
              
            if(response.isSuccess()){
                System.out.println("調用成功"+response.getBody());
                } else {
                System.out.println("調用失敗"+response.getBody());
                }
              
        } catch (AlipayApiException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally {
              
        }      

如果大家還有什麼疑問歡迎文章下面跟帖追問吐槽