Commit d0e61f2b authored by root's avatar root

hyperf2.2.0

parent 67b1274b
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
This diff is collapsed.
{ {
"name": "meibuyu/micro", "name": "meibuyu/micro",
"description": "美不语微服务公共接口库", "description": "美不语微服务公共接口库",
"type": "library", "type": "library",
"license": "MIT", "license": "MIT",
"authors": [ "authors": [
{ {
"name": "梁俊杰", "name": "梁俊杰",
"email": "blithe8787@163.com" "email": "blithe8787@163.com"
} }
], ],
"require": { "require": {
"ext-json": "*", "ext-json": "*",
"ext-redis": "*", "ext-redis": "*",
"ext-gd": "*", "ext-gd": "*",
"ext-curl": "*", "ext-curl": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"hyperf/cache": "~2.1.0", "hyperf/cache": "~2.2.0",
"hyperf/framework": "~2.1.0", "hyperf/framework": "~2.2.0",
"hyperf/db-connection": "~2.1.0", "hyperf/db-connection": "~2.2.0",
"hyperf/validation": "~2.1.0", "hyperf/validation": "~2.2.0",
"hyperf/command": "~2.1.0", "hyperf/command": "~2.2.0",
"hyperf/redis": "~2.1.0", "hyperf/redis": "~2.2.0",
"hyperf/guzzle": "~2.1.0", "hyperf/guzzle": "~2.2.0",
"hyperf/config": "~2.1.0", "hyperf/config": "~2.2.0",
"hyperf/logger": "~2.1.0", "hyperf/logger": "~2.2.0",
"hyperf/service-governance": "~2.1.0", "hyperf/service-governance": "~2.2.0",
"fzaninotto/faker": "^1.9", "fzaninotto/faker": "^1.9",
"phpoffice/phpspreadsheet": "^1.18", "phpoffice/phpspreadsheet": "^1.18",
"dimsav/unix-zipper": "1.*", "dimsav/unix-zipper": "1.*",
"hyperf/amqp": "~2.1.0", "hyperf/amqp": "~2.2.0",
"hyperf/paginator": "~2.1.0" "hyperf/paginator": "~2.2.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Meibuyu\\Micro\\": "src/" "Meibuyu\\Micro\\": "src/"
}, },
"files": [ "files": [
"src/functions.php", "src/functions.php",
"src/const.php" "src/const.php"
] ]
}, },
"extra": { "extra": {
"hyperf": { "hyperf": {
"config": "Meibuyu\\Micro\\ConfigProvider" "config": "Meibuyu\\Micro\\ConfigProvider"
} }
} }
} }
File mode changed from 100644 to 100755
<?php <?php
/** /**
* 异步协程处理 * 异步协程处理
*/ */
namespace Meibuyu\Micro\Annotation; namespace Meibuyu\Micro\Annotation;
use Hyperf\Di\Annotation\AbstractAnnotation; use Hyperf\Di\Annotation\AbstractAnnotation;
/** /**
* @Annotation * @Annotation
* @Target("METHOD") * @Target("METHOD")
*/ */
class AsyncCoroutine extends AbstractAnnotation class AsyncCoroutine extends AbstractAnnotation
{ {
public function collectMethod(string $className, ?string $target): void public function collectMethod(string $className, ?string $target): void
{ {
parent::collectMethod($className, $target); // TODO: Change the autogenerated stub parent::collectMethod($className, $target); // TODO: Change the autogenerated stub
} }
} }
\ No newline at end of file
File mode changed from 100644 to 100755
<?php <?php
/** /**
* 日志追踪 写队列 批量更新到数据库 * 日志追踪 写队列 批量更新到数据库
*/ */
namespace Meibuyu\Micro\Annotation; namespace Meibuyu\Micro\Annotation;
use Hyperf\Di\Annotation\AbstractAnnotation; use Hyperf\Di\Annotation\AbstractAnnotation;
/** /**
* @Annotation * @Annotation
* @Target("METHOD") * @Target("METHOD")
*/ */
class LogTrace extends AbstractAnnotation class LogTrace extends AbstractAnnotation
{ {
public function collectMethod(string $className, ?string $target): void public function collectMethod(string $className, ?string $target): void
{ {
parent::collectMethod($className, $target); // TODO: Change the autogenerated stub parent::collectMethod($className, $target); // TODO: Change the autogenerated stub
} }
} }
\ No newline at end of file
File mode changed from 100644 to 100755
<?php <?php
namespace Meibuyu\Micro\Aspect; namespace Meibuyu\Micro\Aspect;
use Meibuyu\Micro\Handler\LogTrace\LogTraceHandler; use Meibuyu\Micro\Handler\LogTrace\LogTraceHandler;
use Hyperf\Di\Annotation\Aspect; use Hyperf\Di\Annotation\Aspect;
use Hyperf\Di\Aop\AbstractAspect; use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint; use Hyperf\Di\Aop\ProceedingJoinPoint;
use Meibuyu\Micro\Annotation\AsyncCoroutine; use Meibuyu\Micro\Annotation\AsyncCoroutine;
use Hyperf\Utils\Coroutine; use Hyperf\Utils\Coroutine;
/** /**
* @Aspect( * @Aspect(
* annotations={ * annotations={
* AsyncCoroutine::class * AsyncCoroutine::class
* } * }
* ) * )
*/ */
class AsyncCoroutineAspect extends AbstractAspect class AsyncCoroutineAspect extends AbstractAspect
{ {
/** /**
* 优先级 * 优先级
* @var int * @var int
*/ */
public $priority = 998; public $priority = 998;
public function process(ProceedingJoinPoint $proceedingJoinPoint) public function process(ProceedingJoinPoint $proceedingJoinPoint)
{ {
// 切面切入后,执行对应的方法会由此来负责 // 切面切入后,执行对应的方法会由此来负责
// $proceedingJoinPoint 为连接点,通过该类的 process() 方法调用原方法并获得结果 // $proceedingJoinPoint 为连接点,通过该类的 process() 方法调用原方法并获得结果
// 在调用前进行某些处理 // 在调用前进行某些处理
return Coroutine::create(function ()use($proceedingJoinPoint){ return Coroutine::create(function ()use($proceedingJoinPoint){
LogTraceHandler::recordProcess( LogTraceHandler::recordProcess(
'投递到子协程任务,id:'.Coroutine::id() '投递到子协程任务,id:'.Coroutine::id()
.' ,类:'.$proceedingJoinPoint->className .' ,类:'.$proceedingJoinPoint->className
.' ,方法:'.$proceedingJoinPoint->methodName .' ,方法:'.$proceedingJoinPoint->methodName
.' ,参数:'.json_encode($proceedingJoinPoint->getArguments()) .' ,参数:'.json_encode($proceedingJoinPoint->getArguments())
, ,
true true
); );
$result = $proceedingJoinPoint->process(); $result = $proceedingJoinPoint->process();
LogTraceHandler::recordProcess( LogTraceHandler::recordProcess(
'子协程任务id:'.Coroutine::id().'已完成,执行结果:'. '子协程任务id:'.Coroutine::id().'已完成,执行结果:'.
json_encode($result),true json_encode($result),true
); );
}); });
} }
} }
\ No newline at end of file
<?php <?php
namespace Meibuyu\Micro\Aspect; namespace Meibuyu\Micro\Aspect;
use Hyperf\Di\Annotation\Aspect; use Hyperf\Di\Annotation\Aspect;
use Hyperf\Di\Aop\AbstractAspect; use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint; use Hyperf\Di\Aop\ProceedingJoinPoint;
use Hyperf\HttpServer\Contract\RequestInterface; use Hyperf\HttpServer\Contract\RequestInterface;
use Meibuyu\Micro\Annotation\LogTrace; use Meibuyu\Micro\Annotation\LogTrace;
use Meibuyu\Micro\Handler\LogTrace\LogTraceHandler; use Meibuyu\Micro\Handler\LogTrace\LogTraceHandler;
/** /**
* @Aspect( * @Aspect(
* annotations={ * annotations={
* LogTrace::class * LogTrace::class
* } * }
* ) * )
*/ */
class LogTraceAspect extends AbstractAspect class LogTraceAspect extends AbstractAspect
{ {
/** /**
* 优先级 * 优先级
* @var int * @var int
*/ */
public $priority = 999; public $priority = 999;
public function process(ProceedingJoinPoint $proceedingJoinPoint) public function process(ProceedingJoinPoint $proceedingJoinPoint)
{ {
$originParams = [ $originParams = [
'called_params'=>$proceedingJoinPoint->getArguments(), 'called_params'=>$proceedingJoinPoint->getArguments(),
'http_params'=>make(RequestInterface::class)->all() 'http_params'=>make(RequestInterface::class)->all()
]; ];
LogTraceHandler::createLogTrace( LogTraceHandler::createLogTrace(
$proceedingJoinPoint->className.'@'.$proceedingJoinPoint->methodName, $proceedingJoinPoint->className.'@'.$proceedingJoinPoint->methodName,
$originParams $originParams
); );
$result = $proceedingJoinPoint->process(); $result = $proceedingJoinPoint->process();
LogTraceHandler::recordProcess('返回结果:'.json_encode($result)); LogTraceHandler::recordProcess('返回结果:'.json_encode($result));
return $result; return $result;
} }
} }
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
<?php <?php
/** /**
* 执行日志记录 * 执行日志记录
*/ */
namespace Meibuyu\Micro\Handler\LogTrace; namespace Meibuyu\Micro\Handler\LogTrace;
use Meibuyu\Micro\Model\LogTrace; use Meibuyu\Micro\Model\LogTrace;
use Hyperf\Utils\Coroutine; use Hyperf\Utils\Coroutine;
use Swoole\Server; use Swoole\Server;
use Throwable; use Throwable;
/** /**
* Class LogTraceHandler * Class LogTraceHandler
* @package App\Service * @package App\Service
*/ */
class LogTraceHandler class LogTraceHandler
{ {
/** /**
* 1.对执行操作进行的方法入口注解 LogTrace * 1.对执行操作进行的方法入口注解 LogTrace
2.对程序主动进行输出 2.对程序主动进行输出
try { try {
//流程1 //流程1
LogTraceHandler::recordProcess('执行到流程1'); LogTraceHandler::recordProcess('执行到流程1');
//流程2 //流程2
LogTraceHandler::recordProcess('执行到流程2'); LogTraceHandler::recordProcess('执行到流程2');
//记录输出数组 //记录输出数组
LogTraceHandler::recordProcess(['test'=>1]); LogTraceHandler::recordProcess(['test'=>1]);
//流程3 抛出一个异常 //流程3 抛出一个异常
throw new Exception('test111'); throw new Exception('test111');
//流程执行完成标记结束 //流程执行完成标记结束
LogTraceHandler::markComplete(); LogTraceHandler::markComplete();
}catch (\Throwable $exception){ }catch (\Throwable $exception){
//记录异常日志 //记录异常日志
LogTraceHandler::recordProcess($exception); LogTraceHandler::recordProcess($exception);
} }
* @param $params * @param $params
* @param $source * @param $source
* @return mixed * @return mixed
* @throws \Exception * @throws \Exception
*/ */
public static function createLogTrace($source, $params) public static function createLogTrace($source, $params)
{ {
if(!Coroutine::inCoroutine()) return; if(!Coroutine::inCoroutine()) return;
LogTrace::insertOrIgnore([ LogTrace::insertOrIgnore([
'request_id' => self::getRequestId(), 'request_id' => self::getRequestId(),
'origin_params' => json_encode($params), 'origin_params' => json_encode($params),
'source' => $source, 'source' => $source,
'created_at' => now(), 'created_at' => now(),
'process_info' => '' 'process_info' => ''
]); ]);
} }
/** /**
* @param bool $isInAsyncCoroutine * @param bool $isInAsyncCoroutine
* @return string * @return string
* @throws \Exception * @throws \Exception
*/ */
private static function getRequestId($isInAsyncCoroutine=false) private static function getRequestId($isInAsyncCoroutine=false)
{ {
$workId = posix_getpid(); $workId = posix_getpid();
$cid = $isInAsyncCoroutine?Coroutine::parentId(Coroutine::id()):Coroutine::id(); $cid = $isInAsyncCoroutine?Coroutine::parentId(Coroutine::id()):Coroutine::id();
if(!$cid) throw new \Exception('无法使用协程标记录日志'); if(!$cid) throw new \Exception('无法使用协程标记录日志');
return container(Server::class)->stats()['start_time'] .$workId. $cid; return container(Server::class)->stats()['start_time'] .$workId. $cid;
} }
/** /**
* 程序执行完成标记结束 * 程序执行完成标记结束
* @throws \Exception * @throws \Exception
*/ */
public static function markComplete() public static function markComplete()
{ {
if(!Coroutine::inCoroutine()) return; if(!Coroutine::inCoroutine()) return;
container(LogTraceQueue::class)->addToQueue([ container(LogTraceQueue::class)->addToQueue([
'request_id'=>self::getRequestId(), 'request_id'=>self::getRequestId(),
'is_completed'=>YES 'is_completed'=>YES
]); ]);
//LogTrace::where('request_id', self::getRequestId())->update(['is_completed' => YES]); //LogTrace::where('request_id', self::getRequestId())->update(['is_completed' => YES]);
} }
/* /*
* 事务回滚导致部分流程日志无法记录 暂写到文件里 * 事务回滚导致部分流程日志无法记录 暂写到文件里
* 待写到Es后可以避免 * 待写到Es后可以避免
* 记录当前日志(包括异常捕获) * 记录当前日志(包括异常捕获)
*/ */
public static function recordProcess($track,$isInAsyncCoroutine=false) public static function recordProcess($track,$isInAsyncCoroutine=false)
{ {
if (empty($track)) return; if (empty($track)) return;
if(!Coroutine::inCoroutine()) return; if(!Coroutine::inCoroutine()) return;
$logInfo = ''; $logInfo = '';
if ($track instanceof Throwable) { if ($track instanceof Throwable) {
$logInfo = $track->getMessage() . "\n" . $logInfo = $track->getMessage() . "\n" .
$track->getFile() . " line:" . $track->getFile() . " line:" .
$track->getLine() . "\n" . $track->getLine() . "\n" .
$track->getTraceAsString(); $track->getTraceAsString();
} }
if (is_array($track)) { if (is_array($track)) {
$logInfo = var_export($track, true); $logInfo = var_export($track, true);
} }
if (is_string($track)||is_numeric($track)) { if (is_string($track)||is_numeric($track)) {
$logInfo = $track; $logInfo = $track;
} }
$logInfo .= "\n\n"; $logInfo .= "\n\n";
container(LogTraceQueue::class)->addToQueue([ container(LogTraceQueue::class)->addToQueue([
'request_id'=>self::getRequestId($isInAsyncCoroutine), 'request_id'=>self::getRequestId($isInAsyncCoroutine),
'process_info'=>$logInfo 'process_info'=>$logInfo
]); ]);
// $log = LogTrace::where('request_id', self::getRequestId())->first(); // $log = LogTrace::where('request_id', self::getRequestId())->first();
// if(empty($log)) return ; // if(empty($log)) return ;
// //
// $log->update([ // $log->update([
// 'process_info' => Db::raw("CONCAT(process_info,\"{$logInfo}\")") // 'process_info' => Db::raw("CONCAT(process_info,\"{$logInfo}\")")
// ]); // ]);
// //写入文件 // //写入文件
// put_log( // put_log(
// self::getRequestId()."\n". // self::getRequestId()."\n".
// $logInfo, // $logInfo,
// str_replace('\\','_',$log->source).'/'.today() // str_replace('\\','_',$log->source).'/'.today()
// ); // );
} }
// /** // /**
// * 记录流程日志 // * 记录流程日志
// * @param $funName // * @param $funName
// * @param $arguments // * @param $arguments
// * @throws \Exception // * @throws \Exception
// */ // */
// public static function __callStatic($funName, $arguments) // public static function __callStatic($funName, $arguments)
// { // {
// if(self::$instance){ // if(self::$instance){
// throw new \Exception('请用LogTraceService::createLogTrace 先实例化对象'); // throw new \Exception('请用LogTraceService::createLogTrace 先实例化对象');
// } // }
// self::$instance->$funName($arguments); // self::$instance->$funName($arguments);
// } // }
} }
\ No newline at end of file
<?php <?php
namespace Meibuyu\Micro\Handler\LogTrace; namespace Meibuyu\Micro\Handler\LogTrace;
use Meibuyu\Micro\Handler\RedisQueueBatchHandler; use Meibuyu\Micro\Handler\RedisQueueBatchHandler;
use Meibuyu\Micro\Model\LogTrace; use Meibuyu\Micro\Model\LogTrace;
class LogTraceQueue extends RedisQueueBatchHandler class LogTraceQueue extends RedisQueueBatchHandler
{ {
protected function specifyQueueName() protected function specifyQueueName()
{ {
$this->queue_name = env('APP_NAME').':LogTraceQueue'; $this->queue_name = env('APP_NAME').':LogTraceQueue';
} }
/** /**
* 具体批处理逻辑 * 具体批处理逻辑
* @param $dataArr * @param $dataArr
*/ */
function batchDeal($dataArr) function batchDeal($dataArr)
{ {
$updateArr = []; $updateArr = [];
$updateMarkComplete = []; $updateMarkComplete = [];
foreach ($dataArr as $arr){ foreach ($dataArr as $arr){
if(isset($arr['is_completed'])&&$arr['is_completed']==YES){ if(isset($arr['is_completed'])&&$arr['is_completed']==YES){
$updateMarkComplete[]= $arr['request_id'] ;continue; $updateMarkComplete[]= $arr['request_id'] ;continue;
} }
$updateArr[$arr['request_id']]['request_id'] = $arr['request_id']; $updateArr[$arr['request_id']]['request_id'] = $arr['request_id'];
$process_info = isset($updateArr[$arr['request_id']]['process_info'])? $process_info = isset($updateArr[$arr['request_id']]['process_info'])?
$updateArr[$arr['request_id']]['process_info']:''; $updateArr[$arr['request_id']]['process_info']:'';
$updateArr[$arr['request_id']]['process_info'] = $process_info.$arr['process_info']; $updateArr[$arr['request_id']]['process_info'] = $process_info.$arr['process_info'];
} }
//执行前先查一下 原先有的记录 避免被覆盖 //执行前先查一下 原先有的记录 避免被覆盖
$originLogs = LogTrace::whereIn('request_id',array_column($dataArr,'request_id')) $originLogs = LogTrace::whereIn('request_id',array_column($dataArr,'request_id'))
->pluck('process_info','request_id')->toArray(); ->pluck('process_info','request_id')->toArray();
//追加到原记录之后 //追加到原记录之后
$updateArr = array_map(function ($item)use($originLogs){ $updateArr = array_map(function ($item)use($originLogs){
if(!isset($originLogs[$item['request_id']])) return $item; if(!isset($originLogs[$item['request_id']])) return $item;
if(empty($originLogs[$item['request_id']])) return $item; if(empty($originLogs[$item['request_id']])) return $item;
$item['process_info'] = $originLogs[$item['request_id']].$item['process_info']; $item['process_info'] = $originLogs[$item['request_id']].$item['process_info'];
return $item; return $item;
},$updateArr); },$updateArr);
//批量更新 //批量更新
if(!empty($updateMarkComplete)){ if(!empty($updateMarkComplete)){
LogTrace::whereIn('request_id',$updateMarkComplete)->update(['is_completed'=>YES]); LogTrace::whereIn('request_id',$updateMarkComplete)->update(['is_completed'=>YES]);
} }
LogTrace::getModel()->batchUpdateByField(array_values($updateArr),'request_id'); LogTrace::getModel()->batchUpdateByField(array_values($updateArr),'request_id');
} }
} }
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
<?php <?php
namespace Meibuyu\Micro\Handler; namespace Meibuyu\Micro\Handler;
abstract class RedisQueueBatchHandler abstract class RedisQueueBatchHandler
{ {
/** /**
* 重试次数 * 重试次数
*/ */
protected $retrys=0; protected $retrys=0;
protected $queue_name; protected $queue_name;
const MAX_RETRY_TIMES = 3; const MAX_RETRY_TIMES = 3;
const BATCH_DEAL_NUM = 100; const BATCH_DEAL_NUM = 100;
const ERROR_RETRY_CODE = 9000; const ERROR_RETRY_CODE = 9000;
/** /**
* RedisQueueBatchHandler constructor. * RedisQueueBatchHandler constructor.
*/ */
public function __construct() public function __construct()
{ {
$this->specifyQueueName(); $this->specifyQueueName();
} }
/** /**
* 添加至队列 * 添加至队列
*/ */
public function addToQueue($data) public function addToQueue($data)
{ {
redis()->rPush($this->queue_name,json_encode($data)); redis()->rPush($this->queue_name,json_encode($data));
} }
/** /**
* 通过管道将执行失败的数据重回队列 * 通过管道将执行失败的数据重回队列
* @param $arr * @param $arr
* @param \Hyperf\Redis\Redis $redis * @param \Hyperf\Redis\Redis $redis
*/ */
protected function backToQueue($arr,\Hyperf\Redis\Redis $redis) protected function backToQueue($arr,\Hyperf\Redis\Redis $redis)
{ {
//开启管道 //开启管道
$pip = $redis->multi(); $pip = $redis->multi();
foreach ($arr as $i){ foreach ($arr as $i){
$pip->lPush($this->queue_name,$i); $pip->lPush($this->queue_name,$i);
} }
//批量提交 //批量提交
$pip->exec(); $pip->exec();
} }
//批处理具体逻辑 //批处理具体逻辑
abstract protected function batchDeal($data); abstract protected function batchDeal($data);
abstract protected function specifyQueueName(); abstract protected function specifyQueueName();
public function consume() public function consume()
{ {
$redis = redis(); $redis = redis();
while (true){ while (true){
//有数据则放回 否则延迟20s后返回空数组,同时可保持连接活跃 //有数据则放回 否则延迟20s后返回空数组,同时可保持连接活跃
//执行过程 如果redis服务异常,调用io操作时异常退出,框架重新拉起该进程 //执行过程 如果redis服务异常,调用io操作时异常退出,框架重新拉起该进程
$exist = $redis->blPop($this->queue_name,30); $exist = $redis->blPop($this->queue_name,30);
if(empty($exist)) continue ; if(empty($exist)) continue ;
$redis->lPush($this->queue_name,$exist[1]); $redis->lPush($this->queue_name,$exist[1]);
//每次从列表取100 //每次从列表取100
$arr = $redis->lRange($this->queue_name,0,self::BATCH_DEAL_NUM-1); $arr = $redis->lRange($this->queue_name,0,self::BATCH_DEAL_NUM-1);
//取完 从队列删掉 //取完 从队列删掉
$redis->lTrim($this->queue_name,count($arr),-1); $redis->lTrim($this->queue_name,count($arr),-1);
//数据格式化 //数据格式化
$formatArr = array_map(function ($item){ $formatArr = array_map(function ($item){
return json_decode($item,true); return json_decode($item,true);
},$arr); },$arr);
try { try {
//具体批处理逻辑 //具体批处理逻辑
$this->batchDeal($formatArr); $this->batchDeal($formatArr);
}catch (\Throwable $exception){ }catch (\Throwable $exception){
//错误码为100 通过管道从新推到队列 //错误码为100 通过管道从新推到队列
if($exception->getCode()==self::ERROR_RETRY_CODE){ if($exception->getCode()==self::ERROR_RETRY_CODE){
if($this->retrys<self::MAX_RETRY_TIMES){ //重试次数不超过3次 if($this->retrys<self::MAX_RETRY_TIMES){ //重试次数不超过3次
$this->backToQueue($arr,$redis); $this->backToQueue($arr,$redis);
$this->retrys++; $this->retrys++;
}else{ }else{
$this->retrys = 0; //重置当前次数 $this->retrys = 0; //重置当前次数
$this->errorWriteToFile($formatArr,$exception); $this->errorWriteToFile($formatArr,$exception);
} }
}else{ }else{
$this->errorWriteToFile($formatArr,$exception); $this->errorWriteToFile($formatArr,$exception);
} }
} }
} }
} }
/** /**
* @param $data * @param $data
* @param \Throwable $exception * @param \Throwable $exception
*/ */
private function errorWriteToFile($data, \Throwable $exception) private function errorWriteToFile($data, \Throwable $exception)
{ {
put_log( put_log(
json_encode($data)."\n". json_encode($data)."\n".
$exception->getMessage()."\n". $exception->getMessage()."\n".
$exception->getFile().' line:'. $exception->getFile().' line:'.
$exception->getLine()."\n". $exception->getLine()."\n".
$exception->getTraceAsString() $exception->getTraceAsString()
,'RedisQueue/'.$this->queue_name.'/'.today() ,'RedisQueue/'.$this->queue_name.'/'.today()
); );
} }
} }
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
This diff is collapsed.
<?php <?php
namespace Meibuyu\Micro\Middleware; namespace Meibuyu\Micro\Middleware;
use FastRoute\Dispatcher; use FastRoute\Dispatcher;
use Hyperf\HttpServer\Router\DispatcherFactory; use Hyperf\HttpServer\Router\DispatcherFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Utils\ApplicationContext;
use Meibuyu\Micro\Model\Auth; use Meibuyu\Micro\Model\Auth;
use Meibuyu\Micro\Service\Interfaces\User\AuthenticationServiceInterface; use Meibuyu\Micro\Service\Interfaces\User\AuthenticationServiceInterface;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Server\RequestHandlerInterface;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
class AuthorizeMiddleware implements MiddlewareInterface class AuthorizeMiddleware implements MiddlewareInterface
{ {
/** /**
* @Inject() * @Inject()
* @var AuthenticationServiceInterface * @var AuthenticationServiceInterface
*/ */
private $authorizationService; private $authorizationService;
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{ {
$path = $request->getUri()->getPath(); $path = $request->getUri()->getPath();
$token = token(); $token = token();
$applicationName = env('APP_NAME'); $applicationName = env('APP_NAME');
$method = $request->getMethod(); $method = $request->getMethod();
if (empty($path)) return $handler->handle($request); if (empty($path)) return $handler->handle($request);
//获取对应的 path 对应的权限,如果 path 是不需要登录鉴权,直接返回 //获取对应的 path 对应的权限,如果 path 是不需要登录鉴权,直接返回
$passed = $this->authRouter($applicationName, $path, $method, $token); $passed = $this->authRouter($applicationName, $path, $method, $token);
if ($passed) { if ($passed) {
return $handler->handle($request); return $handler->handle($request);
} }
return response()->withStatus(403)->json( return response()->withStatus(403)->json(
[ [
'code' => 403, 'code' => 403,
'msg' => "您没有访问接口的权限,请检查后再操作" 'msg' => "您没有访问接口的权限,请检查后再操作"
]); //鉴权失败,错误码 403 forbidden ]); //鉴权失败,错误码 403 forbidden
//path 是需要登录鉴权的,判断当前用户是佛有对应 path 的权限 //path 是需要登录鉴权的,判断当前用户是佛有对应 path 的权限
} }
/** /**
* 获取对应路由的权限,调用 RPC 服务 * 获取对应路由的权限,调用 RPC 服务
* @param $applicationName * @param $applicationName
* @param $route * @param $route
* @param $token * @param $token
* @return bool * @return bool
*/ */
protected function authRouter($applicationName, $path, $method, $token): bool protected function authRouter($applicationName, $path, $method, $token): bool
{ {
$userId = $this->getUserIdByToken($token); $userId = $this->getUserIdByToken($token);
$route = $this->getRouterByPath($path, $method); $route = $this->getRouterByPath($path, $method);
if (empty($route)) return true; //说明没有匹配到路由,直接 pass,后续执行一定会返回 404, 这里也可以直接 返回 404 if (empty($route)) return true; //说明没有匹配到路由,直接 pass,后续执行一定会返回 404, 这里也可以直接 返回 404
return $this->authorizationService->authByRouter($applicationName, $route, $method, $userId); return $this->authorizationService->authByRouter($applicationName, $route, $method, $userId);
} }
/** /**
* 根据 path 和 method 获取对应的 router * 根据 path 和 method 获取对应的 router
* @param string $path * @param string $path
* @param string $method * @param string $method
* @return array|string * @return array|string
*/ */
private function getRouterByPath(string $path, string $method) : string private function getRouterByPath(string $path, string $method) : string
{ {
$factory = ApplicationContext::getContainer()->get(DispatcherFactory::class); $factory = ApplicationContext::getContainer()->get(DispatcherFactory::class);
$dispatcher = $factory->getDispatcher('http'); $dispatcher = $factory->getDispatcher('http');
$routerMatched = $dispatcher->dispatch($method, $path); $routerMatched = $dispatcher->dispatch($method, $path);
$founded = $routerMatched[0]; $founded = $routerMatched[0];
if ( $founded != Dispatcher::FOUND) return ''; //说明没有匹配上路由,可以直接 return 404 not found if ( $founded != Dispatcher::FOUND) return ''; //说明没有匹配上路由,可以直接 return 404 not found
$handler = $routerMatched[1]; $handler = $routerMatched[1];
return $handler->route; return $handler->route;
} }
/** /**
* 根据 token 获取对应的 user_id * 根据 token 获取对应的 user_id
* @param $token * @param $token
* @return int|mixed * @return int|mixed
*/ */
protected function getUserIdByToken($token) protected function getUserIdByToken($token)
{ {
if (empty($token)) return 0; if (empty($token)) return 0;
$user = redis()->get($token); $user = redis()->get($token);
if ( ! $user) return 0; if ( ! $user) return 0;
$userArr = \json_decode($user, true); $userArr = \json_decode($user, true);
return !empty($userArr['id']) ? $userArr['id'] : 0; return !empty($userArr['id']) ? $userArr['id'] : 0;
} }
} }
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
<?php <?php
declare(strict_types=1); declare(strict_types=1);
namespace Meibuyu\Micro\Model; namespace Meibuyu\Micro\Model;
use Hyperf\DbConnection\Model\Model ; use Hyperf\DbConnection\Model\Model ;
abstract class BaseModel extends Model abstract class BaseModel extends Model
{ {
/** /**
* Function addDataToMysql * Function addDataToMysql
* 批量插入数据到数据库,无则插入,重复则更新 * 批量插入数据到数据库,无则插入,重复则更新
*/ */
public function batchUpdateOrCreateByUniqueKey($data) public function batchUpdateOrCreateByUniqueKey($data)
{ {
$buildInsertBatchSqlStr = $this->buildInsertBatchSqlStr($data); $buildInsertBatchSqlStr = $this->buildInsertBatchSqlStr($data);
$sql = $buildInsertBatchSqlStr['sql']; $sql = $buildInsertBatchSqlStr['sql'];
return $this->getConnection()->update($sql); return $this->getConnection()->update($sql);
} }
/** /**
* Function buildInsertBatchSqlStr * Function buildInsertBatchSqlStr
* 组装mysql * 组装mysql
*/ */
private function buildInsertBatchSqlStr($data) private function buildInsertBatchSqlStr($data)
{ {
//从data中 获取更新的字段 //从data中 获取更新的字段
if (empty($data)) { if (empty($data)) {
return false; return false;
} }
$new_data=[]; $new_data=[];
$maxdim=$this->getmaxdim($data); $maxdim=$this->getmaxdim($data);
if($maxdim==1){ if($maxdim==1){
// 兼容一维数组 // 兼容一维数组
$new_data[]=$data; $new_data[]=$data;
}elseif($maxdim>2){ }elseif($maxdim>2){
// 大于2维返回false // 大于2维返回false
return false; return false;
}else{ }else{
$new_data=$data; $new_data=$data;
} }
$keys_arr = []; $keys_arr = [];
$datas_arr = []; $datas_arr = [];
$where_arr = []; $where_arr = [];
foreach ($new_data as $k => $v) { foreach ($new_data as $k => $v) {
if (!$keys_arr) { if (!$keys_arr) {
$keys_arr = array_keys($v); $keys_arr = array_keys($v);
} }
foreach ($v as $k2=>&$v2){ foreach ($v as $k2=>&$v2){
if(is_string($v2)){ if(is_string($v2)){
$v2="'".addslashes($v2)."'"; $v2="'".addslashes($v2)."'";
} }
} }
//数据重组 //数据重组
$onedata = "( " . implode(',', $v) . " )"; $onedata = "( " . implode(',', $v) . " )";
$datas_arr[] = $onedata; $datas_arr[] = $onedata;
unset($onedata); unset($onedata);
} }
// 组装格式 pt_uid=VALUES(pt_uid), // 组装格式 pt_uid=VALUES(pt_uid),
foreach ($keys_arr as $k2 => $v2) { foreach ($keys_arr as $k2 => $v2) {
$where_arr[] = "$v2 = VALUES($v2)"; $where_arr[] = "$v2 = VALUES($v2)";
} }
$keys_str = implode(',', $keys_arr); $keys_str = implode(',', $keys_arr);
$datas_str = implode(',', $datas_arr); $datas_str = implode(',', $datas_arr);
$where_str = implode(',', $where_arr); $where_str = implode(',', $where_arr);
$sql = ""; $sql = "";
if ($keys_str && $datas_str && $where_str) { if ($keys_str && $datas_str && $where_str) {
$table = $this->getTable(); $table = $this->getTable();
$sql = " INSERT INTO $table ( $keys_str ) VALUES $datas_str ON DUPLICATE KEY UPDATE $where_str"; $sql = " INSERT INTO $table ( $keys_str ) VALUES $datas_str ON DUPLICATE KEY UPDATE $where_str";
} }
unset($keys_str, $where_str); unset($keys_str, $where_str);
return ['sql' => $sql, 'count' => count($datas_arr)]; return ['sql' => $sql, 'count' => count($datas_arr)];
} }
/** /**
* Function getmaxdim * Function getmaxdim
* 数组维数 * 数组维数
*/ */
private function getmaxdim($vDim){ private function getmaxdim($vDim){
if(!is_array($vDim)) return 0; if(!is_array($vDim)) return 0;
else { else {
$max1 = 0; $max1 = 0;
foreach($vDim as $item1) { foreach($vDim as $item1) {
$t1 = $this->getmaxdim($item1); $t1 = $this->getmaxdim($item1);
if( $t1 > $max1) $max1 = $t1; if( $t1 > $max1) $max1 = $t1;
} }
return $max1 + 1; return $max1 + 1;
} }
} }
/** /**
* 批量更新数组 有则 * 批量更新数组 有则
* @param $data array 待更新的数据,二维数组格式 * @param $data array 待更新的数据,二维数组格式
* @param string $field string 值不同的条件,默认为id * @param string $field string 值不同的条件,默认为id
* @return bool|string * @return bool|string
*/ */
public function batchUpdateByField($data, $field = null) public function batchUpdateByField($data, $field = null)
{ {
if(is_null($field)) $field = $this->getKeyName(); if(is_null($field)) $field = $this->getKeyName();
if (!is_array($data) || !$field ) { if (!is_array($data) || !$field ) {
return false; return false;
} }
$updates = $this->parseUpdate($data, $field); $updates = $this->parseUpdate($data, $field);
// 获取所有键名为$field列的值,值两边加上单引号,保存在$fields数组中 // 获取所有键名为$field列的值,值两边加上单引号,保存在$fields数组中
// array_column()函数需要PHP5.5.0+,如果小于这个版本,可以自己实现, // array_column()函数需要PHP5.5.0+,如果小于这个版本,可以自己实现,
// 参考地址:http://php.net/manual/zh/function.array-column.php#118831 // 参考地址:http://php.net/manual/zh/function.array-column.php#118831
$fields = array_column($data, $field); $fields = array_column($data, $field);
$fields = implode(',', array_map(function($value) { $fields = implode(',', array_map(function($value) {
return "'".$value."'"; return "'".$value."'";
}, $fields)); }, $fields));
$sql = sprintf( $sql = sprintf(
"UPDATE `%s` SET %s WHERE `%s` IN (%s) ", "UPDATE `%s` SET %s WHERE `%s` IN (%s) ",
$this->getTable(), $updates, $field, $fields $this->getTable(), $updates, $field, $fields
); );
return $this->getConnection()->update($sql); return $this->getConnection()->update($sql);
} }
/** /**
* 将二维数组转换成CASE WHEN THEN的批量更新条件 * 将二维数组转换成CASE WHEN THEN的批量更新条件
* @param $data array 二维数组 * @param $data array 二维数组
* @param $field string 列名 * @param $field string 列名
* @return string sql语句 * @return string sql语句
*/ */
private function parseUpdate($data, $field) private function parseUpdate($data, $field)
{ {
$sql = ''; $sql = '';
$keys = array_keys(current($data)); $keys = array_keys(current($data));
foreach ($keys as $column) { foreach ($keys as $column) {
if($column==$keys) continue; if($column==$keys) continue;
$sql .= sprintf("`%s` = CASE `%s` \n", $column, $field); $sql .= sprintf("`%s` = CASE `%s` \n", $column, $field);
foreach ($data as $line) { foreach ($data as $line) {
$sql .= sprintf( $sql .= sprintf(
"WHEN '%s' THEN '%s' \n", "WHEN '%s' THEN '%s' \n",
$line[$field], $line[$field],
!is_numeric($line[$column])?addslashes($line[$column]):$line[$column] !is_numeric($line[$column])?addslashes($line[$column]):$line[$column]
); );
} }
$sql .= "END,"; $sql .= "END,";
} }
return rtrim($sql, ','); return rtrim($sql, ',');
} }
} }
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: Auto generated. * User: Auto generated.
* Date: 2022-01-20 * Date: 2022-01-20
* Time: 10:08:03 * Time: 10:08:03
* Description: * Description:
*/ */
declare (strict_types=1); declare (strict_types=1);
namespace Meibuyu\Micro\Model; namespace Meibuyu\Micro\Model;
/** /**
* 模型类 LogTrace * 模型类 LogTrace
* @package App\Model * @package App\Model
* @property integer $id * @property integer $id
* @property string $source 路径 * @property string $source 路径
* @property string $origin_params * @property string $origin_params
* @property integer $is_completed * @property integer $is_completed
* @property string $created_at * @property string $created_at
* @property string $process_info * @property string $process_info
*/ */
class LogTrace extends BaseModel class LogTrace extends BaseModel
{ {
protected $table = 'trace_logs'; protected $table = 'trace_logs';
/** /**
* 是否使用时间戳管理 * 是否使用时间戳管理
* @var bool * @var bool
*/ */
public $timestamps = false; public $timestamps = false;
/** /**
* 可写入数据的字段. * 可写入数据的字段.
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'source', 'source',
'origin_params', 'origin_params',
'is_completed', 'is_completed',
'process_info', 'process_info',
]; ];
} }
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: 王源 * User: 王源
* Date: 2020/1/9 * Date: 2020/1/9
* Time: 15:08 * Time: 15:08
*/ */
namespace Meibuyu\Micro\Service; namespace Meibuyu\Micro\Service;
use Exception; use Exception;
use Hyperf\DbConnection\Model\Model; use Hyperf\DbConnection\Model\Model;
use Meibuyu\Micro\Helper; use Meibuyu\Micro\Helper;
/** /**
* @deprecated 此类废弃,在之后的版本会被删除 * @deprecated 此类废弃,在之后的版本会被删除
*/ */
class BaseService class BaseService
{ {
/** /**
* @var Model * @var Model
*/ */
protected $model; protected $model;
/** /**
* 查找一个数据 * 查找一个数据
* @param $id * @param $id
* @return Model | array * @return Model | array
*/ */
protected function find($id) protected function find($id)
{ {
$model = $this->model->find($id); $model = $this->model->find($id);
return $model; return $model;
} }
public function all(array $columns = ['*'], array $relations = []): array public function all(array $columns = ['*'], array $relations = []): array
{ {
return $this->model->with($relations)->get($columns)->toArray(); return $this->model->with($relations)->get($columns)->toArray();
} }
/** /**
* 获取一条数据 * 获取一条数据
* @param int $id * @param int $id
* @param array $columns * @param array $columns
* @param array $relations * @param array $relations
* @return mixed * @return mixed
*/ */
public function get(int $id, array $columns = ['*'], array $relations = []) public function get(int $id, array $columns = ['*'], array $relations = [])
{ {
return $this->model->with($relations)->find($id, $columns); return $this->model->with($relations)->find($id, $columns);
} }
/** /**
* 插入一条数据 * 插入一条数据
* @param array $params * @param array $params
* @return array * @return array
*/ */
public function insert($params) public function insert($params)
{ {
try { try {
$res = $this->model->insert($params); $res = $this->model->insert($params);
return Helper::success($res); return Helper::success($res);
} catch (Exception $e) { } catch (Exception $e) {
return Helper::fail('', $e->getMessage()); return Helper::fail('', $e->getMessage());
} }
} }
/** /**
* 新增一条数据 * 新增一条数据
* @param array $params * @param array $params
* @return array * @return array
*/ */
public function create($params) public function create($params)
{ {
try { try {
$model = $this->model->newInstance($params); $model = $this->model->newInstance($params);
$model->save(); $model->save();
return Helper::success($model); return Helper::success($model);
} catch (Exception $e) { } catch (Exception $e) {
return Helper::fail('', $e->getMessage()); return Helper::fail('', $e->getMessage());
} }
} }
/** /**
* 更新数据 * 更新数据
* @param $id * @param $id
* @param array $params * @param array $params
* @return array * @return array
*/ */
public function update($id, $params) public function update($id, $params)
{ {
try { try {
$model = $this->find($id); $model = $this->find($id);
$model->fill($params); $model->fill($params);
$model->save(); $model->save();
return Helper::success($model); return Helper::success($model);
} catch (Exception $e) { } catch (Exception $e) {
return Helper::fail('', $e->getMessage()); return Helper::fail('', $e->getMessage());
} }
} }
/** /**
* 删除数据 * 删除数据
* @param $id * @param $id
* @return array * @return array
*/ */
public function delete($id) public function delete($id)
{ {
try { try {
$model = $this->find($id); $model = $this->find($id);
$res = $model->delete(); $res = $model->delete();
if ($res) { if ($res) {
return Helper::success($res, '删除成功'); return Helper::success($res, '删除成功');
} else { } else {
return Helper::fail($res, '删除失败'); return Helper::fail($res, '删除失败');
} }
} catch (Exception $e) { } catch (Exception $e) {
return Helper::fail('', $e->getMessage()); return Helper::fail('', $e->getMessage());
} }
} }
} }
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: zero * User: zero
* Date: 2020/3/27 * Date: 2020/3/27
* Time: 15:03 * Time: 15:03
*/ */
namespace Meibuyu\Micro\Service\Interfaces; namespace Meibuyu\Micro\Service\Interfaces;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\App\AppServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\App\AppServiceInterface
*/ */
interface AppServiceInterface interface AppServiceInterface
{ {
/** /**
* 获取当前用户可访问的应用数组 * 获取当前用户可访问的应用数组
* @param $user * @param $user
* @param bool $isSuperAdmin 是否是超级管理员 * @param bool $isSuperAdmin 是否是超级管理员
* @return mixed * @return mixed
*/ */
public function getAccessApps($user, $isSuperAdmin = false); public function getAccessApps($user, $isSuperAdmin = false);
/** /**
* 获取单个数据 * 获取单个数据
* @param int $id * @param int $id
* @param array $relations 关联关系只有['group'] * @param array $relations 关联关系只有['group']
* @param array $columns * @param array $columns
* @return mixed * @return mixed
*/ */
public function get(int $id, array $relations = [], array $columns = ['id', 'title']); public function get(int $id, array $relations = [], array $columns = ['id', 'title']);
/** /**
* 通过id列表获取应用数组 * 通过id列表获取应用数组
* @param array $idList 默认去重 * @param array $idList 默认去重
* @param array $relations 关联关系只有['group'] * @param array $relations 关联关系只有['group']
* @param array $columns 默认展示id和title,可传['title', 'name', 'entry', 'prefix', 'group_id', 'is_inside', 'is_active', 'icon', 'desc', 'weight'] * @param array $columns 默认展示id和title,可传['title', 'name', 'entry', 'prefix', 'group_id', 'is_inside', 'is_active', 'icon', 'desc', 'weight']
* @return array 默认keyBy('id') * @return array 默认keyBy('id')
*/ */
public function getByIdList(array $idList, array $relations = [], array $columns = ['id', 'title']): array; public function getByIdList(array $idList, array $relations = [], array $columns = ['id', 'title']): array;
/** /**
* 通过name列表获取应用数组 * 通过name列表获取应用数组
* @param array $nameList 默认去重 * @param array $nameList 默认去重
* @param array $relations 关联关系只有['group'] * @param array $relations 关联关系只有['group']
* @param array $columns 默认展示id和title,可传['title', 'name', 'entry', 'prefix', 'group_id', 'is_inside', 'is_active', 'icon', 'desc', 'weight'] * @param array $columns 默认展示id和title,可传['title', 'name', 'entry', 'prefix', 'group_id', 'is_inside', 'is_active', 'icon', 'desc', 'weight']
* @return array 默认keyBy('id') * @return array 默认keyBy('id')
*/ */
public function getByNameList(array $nameList, array $relations = [], array $columns = ['id', 'title', 'name']): array; public function getByNameList(array $nameList, array $relations = [], array $columns = ['id', 'title', 'name']): array;
} }
This diff is collapsed.
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: 王源 * User: 王源
* Date: 2020/3/16 * Date: 2020/3/16
* Time: 15:07 * Time: 15:07
*/ */
namespace Meibuyu\Micro\Service\Interfaces; namespace Meibuyu\Micro\Service\Interfaces;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Datacenter\DatacenterServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Datacenter\DatacenterServiceInterface
*/ */
interface DatacenterServiceInterface interface DatacenterServiceInterface
{ {
/** /**
* description:获取国家汇率 默认取最新一个汇率值 * description:获取国家汇率 默认取最新一个汇率值
* author: fuyunnan * author: fuyunnan
* @param int $currencyId 货币id * @param int $currencyId 货币id
* @param array $field 字段 * @param array $field 字段
* @param array $where 筛选数组 * @param array $where 筛选数组
* @return array * @return array
* @throws * @throws
* Date: 2020/8/11 * Date: 2020/8/11
*/ */
public function getCurrencyRate($currencyId, $field = ['id', 'currency_id', 'rate_val'], $where = []): array; public function getCurrencyRate($currencyId, $field = ['id', 'currency_id', 'rate_val'], $where = []): array;
/** /**
* description:获取国家汇率 默认取最新一个汇率值 * description:获取国家汇率 默认取最新一个汇率值
* author: fuyunnan * author: fuyunnan
* @param array $currencyIds 货币ids * @param array $currencyIds 货币ids
* @param array $field 字段 * @param array $field 字段
* @param array $where 筛选数组 * @param array $where 筛选数组
* @return array * @return array
* @throws * @throws
* Date: 2020/8/11 * Date: 2020/8/11
*/ */
public function getCurrencyListRate($currencyIds, $field = ['id', 'currency_id', 'rate_val'], $where = []): array; public function getCurrencyListRate($currencyIds, $field = ['id', 'currency_id', 'rate_val'], $where = []): array;
} }
\ No newline at end of file
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: 姜克保 * User: 姜克保
* Date: 2020/5/20 * Date: 2020/5/20
* Time: 15:48 * Time: 15:48
*/ */
namespace Meibuyu\Micro\Service\Interfaces\DingTalk; namespace Meibuyu\Micro\Service\Interfaces\DingTalk;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Message\DingTalk\DingDepartmentServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Message\DingTalk\DingDepartmentServiceInterface
*/ */
interface DingDepartmentServiceInterface interface DingDepartmentServiceInterface
{ {
/** /**
* 获取部门列表 * 获取部门列表
* @param null $id 部门id * @param null $id 部门id
* @param bool $isFetchChild 是否获取子部门 * @param bool $isFetchChild 是否获取子部门
* @param null $lang * @param null $lang
* @return array * @return array
*/ */
public function getDepartmentList($id = null, $isFetchChild = false, $lang = null): array; public function getDepartmentList($id = null, $isFetchChild = false, $lang = null): array;
} }
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: 姜克保 * User: 姜克保
* Date: 2020/5/20 * Date: 2020/5/20
* Time: 15:48 * Time: 15:48
*/ */
namespace Meibuyu\Micro\Service\Interfaces\DingTalk; namespace Meibuyu\Micro\Service\Interfaces\DingTalk;
use phpDocumentor\Reflection\Types\Mixed_; use phpDocumentor\Reflection\Types\Mixed_;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Message\DingTalk\DingMessageServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Message\DingTalk\DingMessageServiceInterface
*/ */
interface DingMessageServiceInterface interface DingMessageServiceInterface
{ {
/** /**
* 发送普通消息 * 发送普通消息
* *
* @param string $sender 消息发送者 userId * @param string $sender 消息发送者 userId
* @param string $cid 群会话或者个人会话的id,通过JSAPI接口唤起联系人界面选择会话获取会话cid;小程序参考获取会话信息,H5微应用参考获取会话信息 * @param string $cid 群会话或者个人会话的id,通过JSAPI接口唤起联系人界面选择会话获取会话cid;小程序参考获取会话信息,H5微应用参考获取会话信息
* @param array $message 消息内容,消息类型和样例可参考“消息类型与数据格式”文档。最长不超过2048个字节 * @param array $message 消息内容,消息类型和样例可参考“消息类型与数据格式”文档。最长不超过2048个字节
* *
* @return mixed * @return mixed
*/ */
public function sendGeneralMessage($sender, $cid, $message); public function sendGeneralMessage($sender, $cid, $message);
/** /**
* 发送工作通知消息 * 发送工作通知消息
* @param array $params * @param array $params
* 发送给多个用户userid_list userid用逗号分隔 * 发送给多个用户userid_list userid用逗号分隔
* ['userid_list' => "016740060622772430,251201234433774424",'msg' => '钉钉消息测试','msgtype' => 'text']; * ['userid_list' => "016740060622772430,251201234433774424",'msg' => '钉钉消息测试','msgtype' => 'text'];
* 发送给所有人 * 发送给所有人
* ['dept_id_list' => "1,2",'msg' => '钉钉消息测试','msgtype' => 'text']; * ['dept_id_list' => "1,2",'msg' => '钉钉消息测试','msgtype' => 'text'];
* 发送给多个部门 部门用逗号分隔 * 发送给多个部门 部门用逗号分隔
* ['to_all_user' => "true",'msg' => '钉钉消息测试','msgtype' => 'text']; * ['to_all_user' => "true",'msg' => '钉钉消息测试','msgtype' => 'text'];
* @return mixed * @return mixed
*/ */
public function sendCorporationMessage($params); public function sendCorporationMessage($params);
/** /**
* @param int $taskId * @param int $taskId
* *
* @return mixed * @return mixed
*/ */
public function corporationMessage($taskId); public function corporationMessage($taskId);
/** /**
* 发送text钉钉消息 * 发送text钉钉消息
* @param integer $templateId 模板id * @param integer $templateId 模板id
* @param array $replace 替换内容(注意顺序) * @param array $replace 替换内容(注意顺序)
* @param array $userIds 用户id(这个是微服务用户的id) * @param array $userIds 用户id(这个是微服务用户的id)
* @return mixed * @return mixed
*/ */
public function sendTextMessage($templateId, $replace, $userIds); public function sendTextMessage($templateId, $replace, $userIds);
} }
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: 姜克保 * User: 姜克保
* Date: 2020/5/20 * Date: 2020/5/20
* Time: 15:48 * Time: 15:48
*/ */
namespace Meibuyu\Micro\Service\Interfaces\DingTalk; namespace Meibuyu\Micro\Service\Interfaces\DingTalk;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Message\DingTalk\DingUserServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Message\DingTalk\DingUserServiceInterface
*/ */
interface DingUserServiceInterface interface DingUserServiceInterface
{ {
/** 通过用户id获取单个用户信息 /** 通过用户id获取单个用户信息
* @param string $ding_user_id 钉钉用户id * @param string $ding_user_id 钉钉用户id
* @return array 钉钉用户信息 * @return array 钉钉用户信息
*/ */
public function getByDingUserId($ding_user_id): array; public function getByDingUserId($ding_user_id): array;
/** /**
* 获取部门用户列表 * 获取部门用户列表
* @return array * @return array
*/ */
public function getDingUserLists(): array; public function getDingUserLists(): array;
/** /**
* 通过临时授权码获取用户信息 * 通过临时授权码获取用户信息
* @param string $code 临时授权码 * @param string $code 临时授权码
* @return array * @return array
*/ */
public function getDingUserByTempCode($code): array; public function getDingUserByTempCode($code): array;
} }
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: 姜克保 * User: 姜克保
* Date: 2020/5/20 * Date: 2020/5/20
* Time: 15:48 * Time: 15:48
*/ */
namespace Meibuyu\Micro\Service\Interfaces; namespace Meibuyu\Micro\Service\Interfaces;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Store\DispatchPlanServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Store\DispatchPlanServiceInterface
*/ */
interface DispatchPlanServiceInterface interface DispatchPlanServiceInterface
{ {
/** /**
* 返回发货计划存在的仓库子产品id * 返回发货计划存在的仓库子产品id
* @param array $idList 仓库子产品id * @param array $idList 仓库子产品id
* @return array * @return array
*/ */
public function getExistProductChildIds(array $idList): array; public function getExistProductChildIds(array $idList): array;
/** /**
* 返回发货计划存在的平台子产品id * 返回发货计划存在的平台子产品id
* @param array $idList * @param array $idList
* @return array * @return array
*/ */
public function getExistPlatformProductChildIds(array $idList): array; public function getExistPlatformProductChildIds(array $idList): array;
} }
<?php <?php
namespace Meibuyu\Micro\Service\Interfaces\File; namespace Meibuyu\Micro\Service\Interfaces\File;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\File\FileServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\File\FileServiceInterface
*/ */
interface FileServiceInterface interface FileServiceInterface
{ {
/** /**
* @param string $type 类型编码 0001 * @param string $type 类型编码 0001
* @param integer $number 生成条形码数量 100 * @param integer $number 生成条形码数量 100
* @return mixed * @return mixed
*/ */
public function generateBarCode($type, $number); public function generateBarCode($type, $number);
} }
\ No newline at end of file
<?php <?php
namespace Meibuyu\Micro\Service\Interfaces\Flow; namespace Meibuyu\Micro\Service\Interfaces\Flow;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Flow\GetConnectModuleServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Flow\GetConnectModuleServiceInterface
*/ */
interface GetConnectModuleServiceInterface interface GetConnectModuleServiceInterface
{ {
/** /**
*通过通道名称获取process_id *通过通道名称获取process_id
* @param string $channel 通道名 * @param string $channel 通道名
* @return mixed * @return mixed
*/ */
public function getConnectModule($channel); public function getConnectModule($channel);
} }
\ No newline at end of file
<?php <?php
namespace Meibuyu\Micro\Service\Interfaces\Flow; namespace Meibuyu\Micro\Service\Interfaces\Flow;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Flow\ProcessFormServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Flow\ProcessFormServiceInterface
*/ */
interface ProcessFormServiceInterface interface ProcessFormServiceInterface
{ {
/** /**
* 创建流程申请 * 创建流程申请
* @param integer $processId 流程id * @param integer $processId 流程id
* @param string $url 表单图片地址 * @param string $url 表单图片地址
* @param array $data 表单详细内容 * @param array $data 表单详细内容
* @param string $user 当前用户信息 * @param string $user 当前用户信息
* @return mixed * @return mixed
*/ */
public function createProcessForm($processId, $url, array $data, $user); public function createProcessForm($processId, $url, array $data, $user);
/** /**
* @param array $ApplyId 申请的id * @param array $ApplyId 申请的id
* @param string $operate 操作:'agree'同意 'turnDown'驳回 'plug'撤回 * @param string $operate 操作:'agree'同意 'turnDown'驳回 'plug'撤回
* @return mixed * @return mixed
*/ */
public function operateFlow($ApplyId, $operate); public function operateFlow($ApplyId, $operate);
} }
\ No newline at end of file
<?php <?php
namespace Meibuyu\Micro\Service\Interfaces\Logistics; namespace Meibuyu\Micro\Service\Interfaces\Logistics;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Logistics\LogisticsServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Logistics\LogisticsServiceInterface
*/ */
interface LogisticsServiceInterface interface LogisticsServiceInterface
{ {
/** /**
* 将物流单号推送到物流中心,物流中心会时刻监视运单变化实时推送给订阅模块 * 将物流单号推送到物流中心,物流中心会时刻监视运单变化实时推送给订阅模块
* @param string $module 模块名称 * @param string $module 模块名称
* @param array $logisticsInfo 物流公司信息 $logisticsInfo = [['logistics_code' => '', 'logistics_no' => '']]; * @param array $logisticsInfo 物流公司信息 $logisticsInfo = [['logistics_code' => '', 'logistics_no' => '']];
* @return mixed * @return mixed
*/ */
public function push($module,$logisticsInfo); public function push($module,$logisticsInfo);
/** /**
* 根据物流单号查询物流信息 * 根据物流单号查询物流信息
* @param array $logisticsNo 物流订单号 * @param array $logisticsNo 物流订单号
* @return mixed * @return mixed
*/ */
public function logisticsInfo($logisticsNo); public function logisticsInfo($logisticsNo);
} }
\ No newline at end of file
File mode changed from 100644 to 100755
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: zhaopeng * User: zhaopeng
* Date: 2020/9/5 * Date: 2020/9/5
* Time: 10:09 * Time: 10:09
*/ */
namespace Meibuyu\Micro\Service\Interfaces\Operation; namespace Meibuyu\Micro\Service\Interfaces\Operation;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Operation\OperationServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Operation\OperationServiceInterface
*/ */
interface OperationServiceInterface interface OperationServiceInterface
{ {
/** /**
* 获取销售报表其他数据 * 获取销售报表其他数据
* @param array $conditions 必传条件 site_id team_id start_time end_time * @param array $conditions 必传条件 site_id team_id start_time end_time
* @return mixed * @return mixed
*/ */
public function getBusinessSaleOtherDatum(array $conditions); public function getBusinessSaleOtherDatum(array $conditions);
/** /**
* 获取销售报表其他数据 * 获取销售报表其他数据
* @param array $conditions 必传条件 site_id team_id start_time end_time * @param array $conditions 必传条件 site_id team_id start_time end_time
* @return mixed * @return mixed
*/ */
public function getBusinessSaleOtherDatumRmb(array $conditions); public function getBusinessSaleOtherDatumRmb(array $conditions);
} }
\ No newline at end of file
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: 姜克保 * User: 姜克保
* Date: 2020/5/20 * Date: 2020/5/20
* Time: 15:48 * Time: 15:48
*/ */
namespace Meibuyu\Micro\Service\Interfaces\Order; namespace Meibuyu\Micro\Service\Interfaces\Order;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Order\ShopifyOrderServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Order\ShopifyOrderServiceInterface
*/ */
interface ShopifyOrderServiceInterface interface ShopifyOrderServiceInterface
{ {
/** /**
* shopify 推送订单信息 * shopify 推送订单信息
* @param string $topic 动作 * @param string $topic 动作
* @param array $array 订单信息 * @param array $array 订单信息
* @param array $shopifySite 站点信息 * @param array $shopifySite 站点信息
* @return mixed * @return mixed
*/ */
public function pushOrder($topic, array $array = [], array $shopifySite = []); public function pushOrder($topic, array $array = [], array $shopifySite = []);
} }
<?php <?php
namespace Meibuyu\Micro\Service\Interfaces\Order; namespace Meibuyu\Micro\Service\Interfaces\Order;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Order\StockUpServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Order\StockUpServiceInterface
*/ */
interface StockUpServiceInterface interface StockUpServiceInterface
{ {
/** /**
*自动备货入库后改变备货单状态为已入库 *自动备货入库后改变备货单状态为已入库
* @param $stockNo * @param $stockNo
* @return mixed * @return mixed
*/ */
public function stockIntoUpdateStatus($stockNo):bool; public function stockIntoUpdateStatus($stockNo):bool;
/** /**
* 跟进物流单号 * 跟进物流单号
* @param $logisticsNo * @param $logisticsNo
* @return array * @return array
*/ */
public function getStockUpInfoByLogisticsNo($logisticsNo):array; public function getStockUpInfoByLogisticsNo($logisticsNo):array;
/** /**
* *
* @param $sourceNo * @param $sourceNo
* @return array * @return array
*/ */
public function getStockUpInfoByOrderNo($sourceNo):array; public function getStockUpInfoByOrderNo($sourceNo):array;
} }
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: zhaopeng * User: zhaopeng
* Date: 2020/9/1 * Date: 2020/9/1
* Time: 10:09 * Time: 10:09
*/ */
namespace Meibuyu\Micro\Service\Interfaces\Order; namespace Meibuyu\Micro\Service\Interfaces\Order;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Order\SubOrderServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Order\SubOrderServiceInterface
*/ */
interface SubOrderServiceInterface interface SubOrderServiceInterface
{ {
/** /**
* @param int $id * @param int $id
* @param array $column 需要查询的字段 * @param array $column 需要查询的字段
* @param array $relation 需要的子订单关联关系可传入['order','order_product'] * @param array $relation 需要的子订单关联关系可传入['order','order_product']
* @return array | null * @return array | null
*/ */
public function getById(int $id, array $column = ['*'], array $relation = []): array; public function getById(int $id, array $column = ['*'], array $relation = []): array;
/** /**
* *
* @param array $idList 子订单的ID 数组[1,2,3] * @param array $idList 子订单的ID 数组[1,2,3]
* @param array $column 需要查询字段 * @param array $column 需要查询字段
* @param array $relation 需要的关联关系可传入['order','order_product'] * @param array $relation 需要的关联关系可传入['order','order_product']
* @return array | null * @return array | null
*/ */
public function getByIdList(array $idList, array $column = ['*'], array $relation = []): array; public function getByIdList(array $idList, array $column = ['*'], array $relation = []): array;
/** /**
* @param array $idList 需要改变发货状态的子订单ID数组 * @param array $idList 需要改变发货状态的子订单ID数组
* @param int $status 需要改变的发货状态ID 1 待发货 2 已发货 3 已签收 4 已取消 * @param int $status 需要改变的发货状态ID 1 待发货 2 已发货 3 已签收 4 已取消
* @return bool * @return bool
*/ */
public function updateSubOrderShipStatus(array $idList, int $status): bool; public function updateSubOrderShipStatus(array $idList, int $status): bool;
/** /**
* 需要改变的子订单id * 需要改变的子订单id
* @param int $id * @param int $id
* @return bool * @return bool
*/ */
public function StockIntoUpdateSubOrderStatus(int $id): bool; public function StockIntoUpdateSubOrderStatus(int $id): bool;
/** /**
* description:通过来源单号获取生产工厂 * description:通过来源单号获取生产工厂
* author: fuyunnan * author: fuyunnan
* @param * @param
* @return array * @return array
* @throws * @throws
* Date: 2020/10/29 * Date: 2020/10/29
*/ */
public function getBySourcesFactory($sources): array; public function getBySourcesFactory($sources): array;
/** /**
* *
* @param array $source 来源单号数组 * @param array $source 来源单号数组
* @return array * @return array
*/ */
public function getBySourceSite($source): array; public function getBySourceSite($source): array;
/** /**
* 订单采购完成 修改子订单信息 ---1688采购系统使用 * 订单采购完成 修改子订单信息 ---1688采购系统使用
* @param $data //修改参数数组(二维数组) * @param $data //修改参数数组(二维数组)
* 参数字段:$data = [ * 参数字段:$data = [
* [ * [
* 'sub_order_no'=>oa子订单编号 * 'sub_order_no'=>oa子订单编号
* 'supplier_name'=>供应商, * 'supplier_name'=>供应商,
* 'purchase_price'=>采购总价, * 'purchase_price'=>采购总价,
* 'platform_order'=>'采购平台订单号', * 'platform_order'=>'采购平台订单号',
* 'domestic_logistics_no'=>物流单号, * 'domestic_logistics_no'=>物流单号,
* 'domestic_logistics_price'=>物流价格 * 'domestic_logistics_price'=>物流价格
* ], * ],
* [ * [
* 'sub_order_no'=>oa子订单编号 * 'sub_order_no'=>oa子订单编号
* 'supplier_name'=>供应商, * 'supplier_name'=>供应商,
* 'purchase_price'=>采购总价, * 'purchase_price'=>采购总价,
* 'platform_order'=>'采购平台订单号', * 'platform_order'=>'采购平台订单号',
* 'domestic_logistics_no'=>物流单号, * 'domestic_logistics_no'=>物流单号,
* 'domestic_logistics_price'=>物流价格 * 'domestic_logistics_price'=>物流价格
* ] * ]
* ] * ]
* @return bool * @return bool
*/ */
public function purchaseCompleted($data,$type): bool; public function purchaseCompleted($data,$type): bool;
/** /**
* 1688采购异常订单 修改OA子订单状态 * 1688采购异常订单 修改OA子订单状态
* @param $orderId //oa子订单id * @param $orderId //oa子订单id
* @param $errorCode //异常信息 1 取消 2其他 * @param $errorCode //异常信息 1 取消 2其他
* @return array * @return array
*/ */
public function purchaseError($orderId,$errorCode):array ; public function purchaseError($orderId,$errorCode):array ;
/** /**
* 1688采购取消 * 1688采购取消
* @param $orderNo * @param $orderNo
* @param $editData * @param $editData
* @return bool * @return bool
*/ */
public function purchaseCancel($orderNo,$editData = []):bool; public function purchaseCancel($orderNo,$editData = []):bool;
/** /**
* 1688采购 修改oa子订单 * 1688采购 修改oa子订单
* @param $editData * @param $editData
* $editData = [ * $editData = [
* 'logistic_no'=>'需要修改的物流单号' * 'logistic_no'=>'需要修改的物流单号'
* 'logistic_no_new'=>'修改后的物流单号', * 'logistic_no_new'=>'修改后的物流单号',
* 'logistic_price'=>'物流费用', * 'logistic_price'=>'物流费用',
* ] * ]
* @return array * @return array
*/ */
public function purchaseEdit($editData):bool ; public function purchaseEdit($editData):bool ;
/** /**
* 删除物流信息 * 删除物流信息
* @param $data =>[ * @param $data =>[
* 'sub_order_no'=>'子订单号', * 'sub_order_no'=>'子订单号',
* 'logistic_no'=>'物流单号' * 'logistic_no'=>'物流单号'
* ] * ]
* @return bool * @return bool
*/ */
public function purchaseDelete($data):bool; public function purchaseDelete($data):bool;
} }
\ No newline at end of file
This diff is collapsed.
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: 王源 * User: 王源
* Date: 2020/1/9 * Date: 2020/1/9
* Time: 15:07 * Time: 15:07
*/ */
namespace Meibuyu\Micro\Service\Interfaces\Product; namespace Meibuyu\Micro\Service\Interfaces\Product;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Product\PlatformProductServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Product\PlatformProductServiceInterface
*/ */
interface PlatformProductServiceInterface interface PlatformProductServiceInterface
{ {
/** /**
* 获取单个数据 * 获取单个数据
* @param int $id 平台产品id * @param int $id 平台产品id
* @param array $relations 平台产品的关联关系, * @param array $relations 平台产品的关联关系,
* 支持:["status","product","amazon_warehouse","platform_product_children","brand","category","ingredient","product_name","images","price_info","property"] * 支持:["status","product","amazon_warehouse","platform_product_children","brand","category","ingredient","product_name","images","price_info","property"]
* @param array $columns 平台产品表的字段,默认全部字段 * @param array $columns 平台产品表的字段,默认全部字段
* ['id', 'sku', 'product_id', 'name', 'team_id', 'site_id', 'price', 'currency_id', 'platform_product_status_id', 'creator_id', 'asin', 'amazon_warehouse_id', 'info_completed'] * ['id', 'sku', 'product_id', 'name', 'team_id', 'site_id', 'price', 'currency_id', 'platform_product_status_id', 'creator_id', 'asin', 'amazon_warehouse_id', 'info_completed']
* @return array|null * @return array|null
*/ */
public function get($id, array $relations = [], $columns = ['*']); public function get($id, array $relations = [], $columns = ['*']);
/** /**
* 通过id列表获取平台产品数组 * 通过id列表获取平台产品数组
* @param array $idList 平台产品id的列表, 默认去重 * @param array $idList 平台产品id的列表, 默认去重
* @param array $relations 平台产品的关联关系, * @param array $relations 平台产品的关联关系,
* 支持:["status","product","amazon_warehouse","platform_product_children","brand","category","ingredient","product_name","images","price_info","property"] * 支持:["status","product","amazon_warehouse","platform_product_children","brand","category","ingredient","product_name","images","price_info","property"]
* @param array $columns 平台产品表的字段,默认全部字段 * @param array $columns 平台产品表的字段,默认全部字段
* ['id', 'sku', 'product_id', 'name', 'team_id', 'site_id', 'price', 'currency_id', 'platform_product_status_id', 'creator_id', 'asin', 'amazon_warehouse_id', 'info_completed'] * ['id', 'sku', 'product_id', 'name', 'team_id', 'site_id', 'price', 'currency_id', 'platform_product_status_id', 'creator_id', 'asin', 'amazon_warehouse_id', 'info_completed']
* @return array 默认keyBy('id') * @return array 默认keyBy('id')
*/ */
public function getByIdList(array $idList, array $relations = [], $columns = ['*']): array; public function getByIdList(array $idList, array $relations = [], $columns = ['*']): array;
/** /**
* 获取申报要素数据 * 获取申报要素数据
* @param array $idList * @param array $idList
* @param bool $groupByFlag * @param bool $groupByFlag
* @return array * @return array
*/ */
public function getWithPoint(array $idList, $groupByFlag = false); public function getWithPoint(array $idList, $groupByFlag = false);
/** /**
* 获取全部亚马逊仓库 * 获取全部亚马逊仓库
* @return array * @return array
*/ */
public function amazonWarehouses(); public function amazonWarehouses();
} }
This diff is collapsed.
This diff is collapsed.
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: Zero * User: Zero
* Date: 2020/10/12 * Date: 2020/10/12
* Time: 9:39 * Time: 9:39
*/ */
namespace Meibuyu\Micro\Service\Interfaces\Product; namespace Meibuyu\Micro\Service\Interfaces\Product;
/** /**
* @deprecated 此接口废弃,在之后的版本会被删除 * @deprecated 此接口废弃,在之后的版本会被删除
* 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Product\ShopifyProductServiceInterface * 请引入meibuyu/rpc组件,使用Meibuyu\Rpc\Service\Interfaces\Product\ShopifyProductServiceInterface
*/ */
interface ShopifyProductServiceInterface interface ShopifyProductServiceInterface
{ {
/** /**
* 通过shopify子产品的shopify_id获取shopify子产品 * 通过shopify子产品的shopify_id获取shopify子产品
* @param array $vids 默认去重 * @param array $vids 默认去重
* @return array 默认keyBy * @return array 默认keyBy
*/ */
public function getChildrenByVids(array $vids): array; public function getChildrenByVids(array $vids): array;
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File mode changed from 100644 to 100755
This diff is collapsed.
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
This diff is collapsed.
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
This diff is collapsed.
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
This diff is collapsed.
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
This diff is collapsed.
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