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