Commit f538efe9 by 王召彬

Merge branch 'master' of http://git.2b3.cn/hdllbackend/services

parents d452f6dc 32f3b022
......@@ -11,3 +11,4 @@ temp/
.phpintel/
.env
.DS_Store
/vendor
......@@ -9,13 +9,13 @@ namespace Hdll\Services\Buyer\Enum;
class BuyerError
{
const PARAMETER_ERR = ["msg" => "参数错误", "code" => 400, "errorCode" => 24001];
const REGISTERED = ["msg" => "用户已存在,无需创建", "code" => 400, "errorCode" => 24101];
const DB_ERROR = ["msg" => "数据库操作错误", "code" => 500, "errorCode" => 24102];
const SCORE_ERR = ["msg" => "你无权创建该用户", "code" => 403, "errorCode" => 24103];
const NOT_FOUND_COMMISSION = ["msg" => "获取佣金信息失败", "code" => 404, "errorCode" => 24104];
const INSUFFICIENT_COMMISSION = ["msg" => "可提现金额不足,无法提现", "code" => 400, "errorCode" => 24105];
const PARAMETER_ERR = ["msg" => "参数错误", "code" => 400, "errorCode" => 24001, 'rpcCode' => "PARAMETER_ERR"];
const REGISTERED = ["msg" => "用户已存在,无需创建", "code" => 400, "errorCode" => 24101, "rpcCode" => "REGISTERED"];
const DB_ERROR = ["msg" => "数据库操作错误", "code" => 500, "errorCode" => 24102, "rpcCode" => "DB_ERROR"];
const SCORE_ERR = ["msg" => "你无权创建该用户", "code" => 403, "errorCode" => 24103, "rpcCode" => "SCORE_ERR"];
const NOT_FOUND_COMMISSION = ["msg" => "获取佣金信息失败", "code" => 404, "errorCode" => 24104, "rpcCode" => "NOT_FOUND_COMMISSION"];
const INSUFFICIENT_COMMISSION = ["msg" => "可提现金额不足,无法提现", "code" => 400, "errorCode" => 24105, "rpcCode" => "INSUFFICIENT_COMMISSION"];
const NOT_FOUND_BUYER = ["msg" => "获取买家信息失败", "code" => 400, "errorCode" => 24106, "rpcCode" => "NOT_FOUND_BUYER"];
public static function atranslate($message,$param)
......
......@@ -17,7 +17,7 @@ use Swoft\Core\ResultInterface;
*/
interface BuyerInterface
{
public function getUser(string $token);
public function getUser(int $stroeId, int $BuyerId);
public function updateProfile(string $token, array $data);
......
......@@ -19,7 +19,7 @@ interface CommissionInterface
* @param $storeId
* @param $buyerId
* @param $money
* @return bool
* @return mixed|bool
*/
public function reduceBalanceCommission($storeId, $buyerId, $money);
......
......@@ -15,7 +15,7 @@ class CommonException extends Exception
public $errorCode = -1;
//异常调用路径
protected $path;
protected $path=[];
public function __construct($params = [])
{
......@@ -36,9 +36,16 @@ class CommonException extends Exception
}
if ( isset($params['path']) ) {
$this->path = json_encode($params['path']);
$this->path = $params['path'];
}
//将此次异常信息入栈
array_unshift($this->path,'Service:'.APP_NAME.' file:'.$this->file.$this->line)//将本次错误调用加入path
//json序列化path
&& $this->path = json_encode($this->path);
parent::__construct($this->message, $this->code);
}
......
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/3
* Time: 17:21
*/
namespace Hdll\Services\Common\Exception;
class ExceptionData
{
public static function getExceptionData($errData, array $param= [])
{
return [
"code" => $errData['code'],
"msg" => $errData['msg'],
"errorCode" => $errData["errCode"],
"data" => $errData['data'],
"path" => $errData['path']
];
}
/**
* 组装抛出的rpc信息
* @param \Throwable $e
* @return array
*/
public static function getRpcErrData(\Throwable $e)
{
//初始化异常数据
$data = [
"code" => $e->getCode(),
"msg" => $e->getMessage(),
"errCode" => is_callable([$e,'getErrCode'])?$e->getErrcode():'',
'path' =>[],
];
if ( is_callable([$e,"getPath"]) ) {
$data['path'] = json_decode($e->getPath(), true);
}
//获取调用堆栈信息
$info = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,1)[0];
//将此次异常信息入站
array_unshift($data['path'],'Service:'.APP_NAME.' file:'.$info['file'].$info['line']);
return ['msg' => json_encode($data), 'code' => $data['code']];
}
}
\ No newline at end of file
......@@ -11,9 +11,10 @@ class ExceptionParseData
{
public static function parseData(\Exception $e)
{
if ( is_callable($e,'getResponse') ) {
if ( is_callable([$e,'getResponse']) ) {
$response = $e->getResponse();
preg_match("/{.*}/",$response['msg'],$data);
$msg = isset($data['0'])?$data['0']:'';
......@@ -22,6 +23,7 @@ class ExceptionParseData
$data['msg'] = $e->getMessage();
$data['code'] = $e->getCode();
$data['file'] = $e->getFile().' '.$e->getLine();
$data['path'] = [$e->getFile().' '.$e->getLine()];
}
return $data;
......
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