Commit 5cc32256 authored by wangjj's avatar wangjj

Merge remote-tracking branch 'origin/master'

parents 00a1232e dc221dc7
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 2017/6/28
* Time: 10:23
*/
use internalApi\ucenter\Express;
require __DIR__.'/_init.php';
//Express::setDebug();
$info = Express::query('70191547363252','huitongkuaidi');
// $info = Member::getInfoByMobile('15395081586');
//$info = Member::getSyncByMobile('13000000002');
//$info = Member::getSyncByUid(514);
print_r($info);
...@@ -18,4 +18,32 @@ namespace internalApi\base; ...@@ -18,4 +18,32 @@ namespace internalApi\base;
*/ */
class ApiException extends \Exception class ApiException extends \Exception
{ {
protected $remote;
public function __construct($message = "", $code = 0, array $remote=null, \Throwable $previous = NULL) {
parent::__construct($message, $code, $previous);
$this->remote = $remote;
}
public function getRemoteClass()
{
return $this->remote['class'];
}
public function getRemoteLine()
{
return $this->remote['line'];
}
public function getRemoteFile()
{
return $this->remote['file'];
}
public function getRemoteTraceString()
{
return $this->remote['traceString'];
}
} }
\ No newline at end of file
...@@ -125,7 +125,7 @@ class Client ...@@ -125,7 +125,7 @@ class Client
if ($httpCode == 500 && substr($response, 0, 10) === 'exception:') { if ($httpCode == 500 && substr($response, 0, 10) === 'exception:') {
$e = substr($response, 10); $e = substr($response, 10);
$e = json_decode($e, true); $e = json_decode($e, true);
throw new ApiException("{$e['class']}: {$e['message']}", $e['code']); throw new ApiException($e['message'], $e['code'], $e);
} }
if ($httpCode == 0) { if ($httpCode == 0) {
......
...@@ -118,7 +118,7 @@ class Server ...@@ -118,7 +118,7 @@ class Server
'class' => get_class($e), 'class' => get_class($e),
'code' => $e->getCode(), 'code' => $e->getCode(),
'message' => $e->getMessage(), 'message' => $e->getMessage(),
'line' => $e->getFile(), 'line' => $e->getLine(),
'file' => $e->getFile(), 'file' => $e->getFile(),
'traceString' => $e->getTraceAsString() 'traceString' => $e->getTraceAsString()
]; ];
......
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 2017/6/30
* Time: 15:08
*/
namespace internalApi\ucenter;
use internalApi\base\Client;
/**
* 用户中心消息服务
*
* @package internalApi\ucenter
*/
class Express extends Client
{
/**
* 获取物流信息
*
* @param string $nu 快递单号
* @param string $com 快递公司代码
* @return array
*/
public static function query($nu, $com)
{
return self::call('express.query', compact('nu', 'com'));
}
/**
* 获取支持的快递公司代码列表
*
* @param boolean $all false:只获取常用的,true:获取所有快递公司
* @return array
*/
public static function company($all=false)
{
return self::call('express.company', compact('all'));
}
}
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 2018/4/13
* Time: 14:58
*/
namespace internalApi\ucenter;
use internalApi\base\Client;
/**
* 用户钱包
* @package internalApi\ucenter
*/
class Wallet extends Client
{
const TURNOVER_TYPE_INCOME = 'income'; //收入
const TURNOVER_TYPE_EXPEND = 'disbursement'; //支出
const TURNOVER_TYPE_FREEZE = 'freeze'; //冻结
const TURNOVER_TYPE_UNFREEZE = 'unfreeze'; //解冻
/**
* 获取用户钱包信息
*
* @param int $uid
* @return array|false 查询失败则返回false
*/
public static function queryWallet($uid)
{
return self::call('wallet.queryWallet', compact('uid'));
}
/**
* 创建钱包流水
*
* 输入对应操作类型 $type 参数即可操作用户钱包,将直接影响到余额
*
* @param int $uid
* @param string $type 流水类型,使用 Wallet::TURNOVER_TYPE_ 前缀常量
* @param float $amount 金额,单位:元。可精确到小数点后两位数,即分
* @param string $busNumber 业务关联编号,自定义
* @param int $busId 业务关联ID
* @param string $busRemark 业务流水备注
* @param int $busTypeId 业务类型ID,保留默认
* @return int|false 交易成功返回流水ID,失败返回 false
*/
public static function turnover($uid, $type, $amount, $busNumber=null, $busId=null, $busRemark=null, $busTypeId=15522201)
{
return self::call('wallet.turnover', compact('uid', 'type', 'amount', 'amount', 'busNumber', 'busId','busRemark', 'busTypeId'));
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment