积分明细对接
接口提供方
该接口需要由开发者提供给燃豆
接口说明
鉴于燃豆服务端并未包含用户的全部积分明细数据,如果开发者需要在燃豆积分商城中展示用户全部的积分明细,可通过该接口对接后在燃豆后台开启积分明细列表页入口。
燃豆会在用户打开积分明细列表页面时,通过该接口实时请求开发者服务端用于获取积分明细数据直接展示给用户。
如果开发者不需要该功能,可不对接。
参数说明
该接口除了公共必传参数外,还包括以下参数:
参数 | 是否必须 | 类型[长度限制] | 说明 |
---|---|---|---|
uid | 是 | string[1,64] | 当前登录的用户id,该id由开发者在免登接口中传给燃豆的用户唯一标志 |
mall_no | 是 | string[6,6] | 商城的唯一编号,表示用户当前的所在商城编号,如JF_001 |
page | 是 | int | 当前列表的页码 |
pageSize | 是 | int | 每页展示条数 |
返回结果
开发者需以json数组格式返回响应内容,且不论查询结果如何,http响应码必须为200,返回码非200的情况下燃豆会认为本次请求失败,json数组中的响应参数如下:
参数 | 是否必须 | 类型[长度限制] | 说明 |
---|---|---|---|
id | 是 | string[1,64] | 该条明细的唯一id,燃豆会以此字段来做去重,避免展示两条一样的明细 |
amount | 是 | int | 积分的变动数量,大于0表示收入,小于0表示支出 |
desc | 是 | string[1,10] | 积分变动说明,比如:兑换、新人任务、积分过期等 |
ts | 是 | int | 积分变动时间戳,如1704448060 |
没有数据,可传空数组
返回案例
获取成功(http响应码为200)
[
{
"id": "100",
"amount": -1000,
"desc": "抽奖",
"ts": 1704448060
},
{
"id": "99",
"amount": -1500,
"desc": "兑换商品",
"ts": 1704448060
},
{
"id": "98",
"amount": 2000,
"desc": "抽奖获得",
"ts": 1704448060
}
]
// 如果没有更多了,请返回空数组
[]
获取失败(http响应码为非200)
{
"errMsg": "获取失败,请稍后再试"
}
代码示例
PHP
use Randou\Exception\RdException;
use Randou\RdClient;
use Randou\RdClientBuilder;
$appid = 'aaaaaaaaaaaaaaaaaaaaaaaa';
$appsecret = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb';
$params = $request->all();
try {
$client = RdClientBuilder::getClient($this->appid2, $this->appSecret2);
$event = $client->creditsList($params);
// print_r($event->all());
return [
['id' => '5', 'amount' => -999, 'desc' => '系统年底清零', 'ts' => 1704448060],
['id' => '4', 'amount' => 2100, 'desc' => '兑换返还', 'ts' => 1704447060],
['id' => '3', 'amount' => -2100, 'desc' => '商品兑换', 'ts' => 1704446060],
['id' => '2', 'amount' => 10, 'desc' => '每日签到', 'ts' => 1704445060],
['id' => '1', 'amount' => -20, 'desc' => '抽奖', 'ts' => 1704444060],
];
} catch (RdException $e) {
return response()->json([
'errMsg' => '获取失败,请稍后再试',
], 500);
}
JAVA
import com.randou_tech.ClientBuilder;
import com.randou_tech.RdClient;
import com.randou_tech.RdException;
import com.randou_tech.event.QueryCreditsListEvent;
import com.randou_tech.event.CreditsDetail
import com.randou_tech.Helper;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping("creditsQuery")
public ArrayList<CreditsDetail> creditsQuery(HttpServletRequest request) throws RdException {
String appid = "aaaaaaaaaaaaaaaaaaaaaaaa";
String appsecret = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
RdClient client = ClientBuilder.build(appid, appsecret);
QueryCreditsListEvent event = client.queryCreditsList(request);
// 如果项目中没有javax.servlet.http.HttpServletRequest,可从request中自行获取出全部参数,以下为从jakarta.servlet.http.HttpServletRequest对象中获取参数
// 获取所有参数名
// Enumeration<String> parameterNames = request.getParameterNames();
// Map<String, String> params = new HashMap<>();
// // 遍历参数名并获取对应的值
// while (parameterNames.hasMoreElements()) {
// String paramName = parameterNames.nextElement();
// String paramValue = request.getParameter(paramName); // 只取第一个值
// params.put(paramName, paramValue);
// }
// QueryCreditsListEvent event = client.queryCreditsListWithParams(params);
System.out.println(event.toString());
ArrayList<CreditsDetail> l = new ArrayList<CreditsDetail>();
l.add(new CreditsDetail("5", "系统年底清零", -888, 1704770389));
l.add(new CreditsDetail("4", "抽奖", -10, 1704770379));
l.add(new CreditsDetail("3", "兑换返还", 200, 1704770369));
l.add(new CreditsDetail("2", "兑换", -200, 1704770359));
l.add(new CreditsDetail("1", "每日签到", 20, 1704770349));
System.out.println(Helper.listToJson(l));
return l;
}