@@ -15,6 +15,10 @@ class HuayiScoreSdk
|
||||
|
||||
//查询积分接口
|
||||
protected $get_balance_url = '/api/scoreshopv1/balance/index';
|
||||
//支出积分接口
|
||||
protected $pay_url = '/api/scoreshopv1/pay/index';
|
||||
//退回积分接口
|
||||
protected $refund_url = '/api/scoreshopv1/refund/index';
|
||||
|
||||
public function __construct($option)
|
||||
{
|
||||
@@ -23,6 +27,7 @@ class HuayiScoreSdk
|
||||
}
|
||||
|
||||
/**
|
||||
* PASS
|
||||
* 获取积分余额
|
||||
* @param $huayi_uid
|
||||
* @return bool
|
||||
@@ -39,7 +44,7 @@ class HuayiScoreSdk
|
||||
if (!$response) {//请求失败
|
||||
return false;
|
||||
} elseif ($response['body']['code'] == 1) {//请求成功
|
||||
return $response;
|
||||
return $response['body'];
|
||||
} else {//请求成功但是返回错误
|
||||
$this->error = $response['body']['msg'];
|
||||
return false;
|
||||
@@ -47,21 +52,61 @@ class HuayiScoreSdk
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO TEST
|
||||
* 支出积分
|
||||
* @return string
|
||||
* @param $huayi_uid
|
||||
* @param $amount
|
||||
* @param $note
|
||||
* @return bool
|
||||
*/
|
||||
public function pay($huayi_uid,$amount,$note)
|
||||
public function pay($huayi_uid, $amount, $note)
|
||||
{
|
||||
return $huayi_uid.$amount.$note;
|
||||
$url = $this->apiurl.$this->pay_url;
|
||||
|
||||
$data = [
|
||||
'uid'=>$huayi_uid,
|
||||
'amount'=>$amount,
|
||||
'note'=>$note,
|
||||
'timestamp'=>time()
|
||||
];
|
||||
$response = $this->postRequest($url, $data);
|
||||
if (!$response) {//请求失败
|
||||
return false;
|
||||
} elseif ($response['body']['code'] == 1) {//请求成功
|
||||
return $response['body'];
|
||||
} else {//请求成功但是返回错误
|
||||
$this->error = $response['body']['msg'];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO TEST
|
||||
* 退还积分
|
||||
* @return string
|
||||
* @param $huayi_uid
|
||||
* @param $amount
|
||||
* @param $note
|
||||
* @return bool
|
||||
*/
|
||||
public function refund($huayi_uid,$amount,$note)
|
||||
public function refund($huayi_uid, $amount, $note)
|
||||
{
|
||||
return $huayi_uid.$amount.$note;
|
||||
$url = $this->apiurl.$this->refund_url;
|
||||
|
||||
$data = [
|
||||
'uid'=>$huayi_uid,
|
||||
'amount'=>$amount,
|
||||
'note'=>$note,
|
||||
'timestamp'=>time()
|
||||
];
|
||||
$response = $this->postRequest($url, $data);
|
||||
if (!$response) {//请求失败
|
||||
return false;
|
||||
} elseif ($response['body']['code'] == 1) {//请求成功
|
||||
return $response['body'];
|
||||
} else {//请求成功但是返回错误
|
||||
$this->error = $response['body']['msg'];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user