Commit 6f917e07 authored by hangjun83's avatar hangjun83

后端:百化销售订单退货功能逻辑

parent e3e43c88
#标准树(有三种不同的树:未注册的树x主要用于本地或私有环境,个人树prs主要用于非商业发行的项目,供应商树vndvnd主要用于可公开获得和分发的项目。您使用的标准树将取决于您正在开发的项目。) #标准树(有三种不同的树:未注册的树x主要用于本地或私有环境,个人树prs主要用于非商业发行的项目,供应商树vndvnd主要用于可公开获得和分发的项目。您使用的标准树将取决于您正在开发的项目。)
API_STANDARDS_TREE=x API_STANDARDS_TREE=x
#亚型(子类型通常是应用程序或项目的缩写全为小写。) #亚型(子类型通常是应用程序或项目的缩写全为小写。)
API_SUBTYPE=rhawn API_SUBTYPE=rhawn
#前缀 #前缀
API_PREFIX=/ API_PREFIX=/
#域(也就是项目网址) #域(也就是项目网址)
API_DOMAIN=localhost API_DOMAIN=localhost
#默认API版本 #默认API版本
API_VERSION=v1 API_VERSION=v1
#API名称 #API名称
API_NAME="rhawn tools" API_NAME="rhawn tools"
#条件请求状态(默认情况下,条件请求处于启用状态,因为它将在可能的情况下利用客户端缓存功能来缓存API请求。 #条件请求状态(默认情况下,条件请求处于启用状态,因为它将在可能的情况下利用客户端缓存功能来缓存API请求。
API_CONDITIONAL_REQUEST=false API_CONDITIONAL_REQUEST=false
...@@ -19,6 +25,7 @@ API_STRICT=true ...@@ -19,6 +25,7 @@ API_STRICT=true
#默认响应格式 #默认响应格式
API_DEFAULT_FORMAT=json API_DEFAULT_FORMAT=json
#调试模式 #调试模式
API_DEBUG=true API_DEBUG=true
...@@ -31,10 +38,21 @@ APP_URL=http://localhost ...@@ -31,10 +38,21 @@ APP_URL=http://localhost
APP_TIMEZONE=UTC APP_TIMEZONE=UTC
APP_LOCALE=en APP_LOCALE=en
# lumen日志配置
LOG_CHANNEL=stack LOG_CHANNEL=stack
LOG_SLACK_WEBHOOK_URL= LOG_SLACK_WEBHOOK_URL=
LOG_QUERY=false LOG_QUERY=true
LOG_REQUEST=false LOG_REQUEST=true
# 如果使用的是 mongo channel 需要配置
LOG_MONGODB_SEPARATE=daily
LOG_MONGODB_LEVEL=debug
LOG_MONGODB_HOST=127.0.0.1
LOG_MONGODB_PORT=27017
LOG_MONGODB_DATABASE=logs
LOG_MONGODB_USERNAME=
LOG_MONGODB_PASSWORD=
LOG_MONGODB_AUTHENTICATION_DATABASE=admin
# 数据库配置 # 数据库配置
DB_CONNECTION=mysql DB_CONNECTION=mysql
...@@ -44,6 +62,7 @@ DB_DATABASE=rhawn_tools ...@@ -44,6 +62,7 @@ DB_DATABASE=rhawn_tools
DB_USERNAME=root DB_USERNAME=root
DB_PASSWORD=123456 DB_PASSWORD=123456
# mongo数据库配置
#MONGODB_HOST=127.0.0.1 #MONGODB_HOST=127.0.0.1
#MONGODB_PORT=27017 #MONGODB_PORT=27017
#MONGODB_USERNAME=homestead #MONGODB_USERNAME=homestead
...@@ -51,7 +70,9 @@ DB_PASSWORD=123456 ...@@ -51,7 +70,9 @@ DB_PASSWORD=123456
#MONGODB_DATABASE=homestead #MONGODB_DATABASE=homestead
#MONGODB_AUTHENTICATION_DATABASE=admin #MONGODB_AUTHENTICATION_DATABASE=admin
# 缓存配置
CACHE_DRIVER=file CACHE_DRIVER=file
QUEUE_CONNECTION=sync QUEUE_CONNECTION=sync
# jwt配置
JWT_SECRET= JWT_SECRET=
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Http\Controllers\V1;
use App\Services\BhOrdersService;
use Illuminate\Http\Request;
use Jiannei\Enum\Laravel\Repositories\Enums\LogEnum;
use Jiannei\Response\Laravel\Support\Facades\Response;
use App\Http\Controllers\V1\Controller;
use App\Support\Traits\Helpers;
class BhOrdersController extends Controller
{
use Helpers;
protected $bhOrdersService = null;
public function __construct(BhOrdersService $bhOrdersService)
{
$this->bhOrdersService = $bhOrdersService;
}
/**
* 白化采购订单搜索
* @param Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
*/
public function searchPorders(Request $request)
{
$message = [
'bhOrderNo.required' => "订单号必填",
];
$this->validateRequest($request, $message);
try{
$orderList = $this->bhOrdersService->searchPordersToPage($request);
return Response::success($orderList, '操作成功');
}catch(\Exception $exception){
return Response::fail($exception->getMessage(),500);
}
}
public function editBhPorders(Request $request)
{
$message = [
'poNo.required' => "订单号必填",
];
$this->validateRequest($request, $message);
try{
$order = $this->bhOrdersService->editBhPordersInfo($request);
return Response::success($order, '更新成功');
}catch(\Exception $exception){
return Response::fail($exception->getMessage(),500);
}
}
/**
* 添加一个订单退货人任务
* @param Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
*/
public function addSorderRefundTask(Request $request)
{
$message = [
'name.required' => "任务名称必填",
'orderNo.required' => "订单号必填",
'itemId.required' => "订单购买项必填",
'refundNums.required' => "退货数量必填",
'handleFee.required' => "手续费费用必填",
'transferPre.required' => "是否转预存必选",
];
$this->validateRequest($request, $message);
try{
$order = $this->bhOrdersService->addSordersRefundTask($request);
return Response::success($order, '添加成功');
}catch(\Exception $exception){
return Response::fail($exception->getMessage(),500);
}
}
/**
* 获取订单退货任务列表
* @param Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
*/
public function getBhSorderRefundTaskToPage(Request $request)
{
try{
$order = $this->bhOrdersService->getSordersRefundTask($request);
return Response::success($order, '添加成功');
}catch(\Exception $exception){
return Response::fail($exception->getMessage(),500);
}
}
/**
* 执行百化退货任务
* @param Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
*/
public function execBhSorderRefundTask(Request $request)
{
$message = [
'taskId.required' => "任务id必填",
];
$this->validateRequest($request, $message);
try{
$this->bhOrdersService->execSordersRefundTask($request);
return Response::success([],'操作成功');
}catch(\Exception $exception){
return Response::fail($exception->getMessage(),500);
}
}
/**
* 查询订单详情
* @param Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
*/
public function getBhSordersDetail(Request $request)
{
$message = [
'orderNo.required' => "订单号必填",
];
$this->validateRequest($request, $message);
try{
$order = $this->bhOrdersService->getBhSorderDetail($request);
return Response::success($this->formatKeysfromArray($order), '更新成功');
}catch(\Exception $exception){
return Response::fail($exception->getMessage(),500);
}
}
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Jobs;
use App\Repositories\Contracts\BhSorderRefundRepository;
use App\Services\BhOrdersService;
use Illuminate\Support\Facades\DB;
class BhSorderRefundJob extends Job
{
protected $refundInfo;
public function __construct($refundInfo)
{
$this->refundInfo = $refundInfo;
}
/**
* Execute the job.
*/
public function handle()
{
try{
app(BhSorderRefundRepository::class)->update(['status' => 'running'],$this->refundInfo['id']);
$refundInfo = json_decode($this->refundInfo['exec_content']);
$service = app(BhOrdersService::class);
$service->sOrderRefund($refundInfo);
//对任务进行更新
$update = [];
$update['status'] = 'finish';
$update['exec_nums'] = $this->refundInfo['exec_nums'] + 1;
$update['error_message'] = '';
}catch(\Exception $e){
//对任务进行更新
$update = [];
$update['status'] = 'error';
$update['error_message'] = $e->getMessage();
$update['exec_nums'] = intval($this->refundInfo['exec_nums'] + 1);
}
try{
$db = DB::connection('mysql');
$db->beginTransaction();
$update['updated_at'] = date('Y-m-d H:i:s',time());
app(BhSorderRefundRepository::class)->update($update,$this->refundInfo['id']);
$logInsert = [];
$logInsert['task_id'] = $this->refundInfo['id'];
if(isset($update['error_message']) && !empty($update['error_message'])){
$logInsert['content'] = $update['error_message'];
}else{
$logInsert['content'] = '执行完成';
}
$logInsert['created_at'] = date('Y-m-d H:i:s',time());
$logInsert['updated_at'] = date('Y-m-d H:i:s',time());
$db->table('task_log')->insertGetId($logInsert);
$db->commit();
}catch(\Exception $e){
$db->rollback();
throw $e;
}
}
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Contracts;
use Prettus\Repository\Contracts\RepositoryInterface;
/**
* Interface UserRepository.
*/
interface BhPordersRepository extends RepositoryInterface
{
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Contracts;
use Prettus\Repository\Contracts\RepositoryInterface;
/**
* Interface UserRepository.
*/
interface BhSoitemsRepository extends RepositoryInterface
{
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Contracts;
use Prettus\Repository\Contracts\RepositoryInterface;
/**
* Interface UserRepository.
*/
interface BhSorderRefundRepository extends RepositoryInterface
{
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Contracts;
use Prettus\Repository\Contracts\RepositoryInterface;
/**
* Interface UserRepository.
*/
interface BhSordersRepository extends RepositoryInterface
{
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Criteria;
use Illuminate\Database\Eloquent\Builder;
use App\Repositories\Criteria\Criteria;
class BhPordersCriteria extends Criteria
{
protected function condition(Builder $query): void
{
if ($orderNo = $this->request->get('bhOrderNo')) {
$query->where('po_no', '=', $orderNo);
}
}
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Criteria;
use Illuminate\Database\Eloquent\Builder;
use App\Repositories\Criteria\Criteria;
class BhSorderRefundCriteria extends Criteria
{
protected function condition(Builder $query): void
{
if($this->request->has('type')){
$query->where('type', '=', $this->request->get('type'));
}
}
}
<?php
namespace App\Repositories\Eloquent;
use App\Repositories\Contracts\BhPordersRepository;
use App\Repositories\Criteria\RequestCriteria;
use App\Repositories\Models\BhPorders;
use App\Repositories\Eloquent\BaseRepository;
use Illuminate\Support\Facades\DB;
use Prettus\Validator\Contracts\ValidatorInterface;
/**
* Class UserRepositoryEloquent.
*/
class BhPordersRepositoryEloquent extends BaseRepository implements BhPordersRepository
{
protected $fieldSearchable = [
];
/**
* 定义validator的检索规则
* @var \string[][]
*/
public $rules = [
ValidatorInterface::RULE_CREATE => [
'menu_name' => 'required',
'title' => 'required',
'menu_path' => 'required',
'parent_id' => 'required',
'menu_type' => 'required',
'status' => 'required',
'sort' => 'required',
'is_show' => 'required',
'sys_default' => 'required'
],
ValidatorInterface::RULE_UPDATE => [
'menu_name' => 'required',
'title' => 'required',
'menu_path' => 'required',
'parent_id' => 'required',
'menu_type' => 'required',
'status' => 'required',
'sort' => 'required',
'is_show' => 'required',
'sys_default' => 'required'
]
];
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return BhPorders::class;
}
/**
* Boot up the repository, pushing criteria.
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/
public function boot()
{
$this->pushCriteria(app(RequestCriteria::class));
}
/**
* 获取采购订单详情
* @param $po_id
* @return array
*/
public function getPorderItemsFromPoId($po_id,$pi_id = null)
{
$pOrder = $this->findWhere(['po_id' => $po_id])->toArray();
$db = DB::connection('bh_mysql');
$rowQueryobj = $db->table('poitems')
->join('products','poitems.p_id','products.p_id')
->join('chemicals','products.c_id','chemicals.c_id')
->join('brands','products.b_id','brands.b_id');
$rowQueryobj->where('poitems.po_id',$po_id);
if(!is_null($pi_id)){
$rowQueryobj->where('poitems.pi_id',$pi_id);
}
$pOrder['poitems'] = $rowQueryobj->get()->toArray();
return $pOrder;
}
}
<?php
namespace App\Repositories\Eloquent;
use App\Repositories\Contracts\BhSoitemsRepository;
use App\Repositories\Contracts\BhSordersRepository;
use App\Repositories\Criteria\RequestCriteria;
use App\Repositories\Models\BhSoitems;
use App\Repositories\Eloquent\BaseRepository;
use Prettus\Validator\Contracts\ValidatorInterface;
/**
* Class UserRepositoryEloquent.
*/
class BhSoitemsRepositoryEloquent extends BaseRepository implements BhSoitemsRepository
{
protected $fieldSearchable = [
];
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return BhSoitems::class;
}
/**
* Boot up the repository, pushing criteria.
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/
public function boot()
{
$this->pushCriteria(app(RequestCriteria::class));
}
/**
* 获取订单详情
* @param $orderId
* @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
*/
public function getSorderItemsDetailFromOrderId($orderId)
{
$order = app(BhSordersRepository::class)->find($orderId);
if(!$order){
throw new \LogicException('该订单不存在!',500);
}
//查询订单的详情
$soItems = BhSoitems::query()
->join('products','soitems.p_id','products.p_id')
->join('chemicals','products.c_id','chemicals.c_id')
->join('brands','products.b_id','brands.b_id')
->where('soitems.so_id',$order->so_id)->get();
return $soItems;
}
/**
* 根据si_id获取订单明细项
* @param $si_id
* @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
*/
public function getSorderItemFromItemId($si_id)
{
$item = $this->find($si_id);
if(!$item){
throw new \LogicException('该订单项不存在!',500);
}
//查询订单的详情
$soItems = BhSoitems::query()
->join('products','soitems.p_id','products.p_id')
->where('soitems.si_id',$si_id)->get();
return $soItems;
}
}
<?php
namespace App\Repositories\Eloquent;
use App\Repositories\Contracts\BhSorderRefundRepository;
use App\Repositories\Criteria\RequestCriteria;
use App\Repositories\Models\BhSorderRefund;
use App\Repositories\Eloquent\BaseRepository;
use Prettus\Validator\Contracts\ValidatorInterface;
/**
* Class UserRepositoryEloquent.
*/
class BhSorderRefundRepositoryEloquent extends BaseRepository implements BhSorderRefundRepository
{
protected $fieldSearchable = [
];
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return BhSorderRefund::class;
}
/**
* Boot up the repository, pushing criteria.
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/
public function boot()
{
$this->pushCriteria(app(RequestCriteria::class));
}
/**
* 添加退款任务
* @param $request
*/
public function addRefundTask($params)
{
if(empty($params)){
throw new \LogicException('参数为空!',500);
}
$task = [];
$task['name'] = $params['name'];
unset($params['name']);
$task['exec_content'] = json_encode($params);
$task['create_by'] = auth()->user()->id;
$task['status'] = 'notexec';
$task['type'] = 'sorder_refund';
return $this->create($task);
}
}
<?php
namespace App\Repositories\Eloquent;
use App\Repositories\Contracts\BhSordersRepository;
use App\Repositories\Criteria\RequestCriteria;
use App\Repositories\Models\BhSorders;
use App\Repositories\Eloquent\BaseRepository;
use Illuminate\Support\Facades\DB;
use Prettus\Validator\Contracts\ValidatorInterface;
/**
* Class UserRepositoryEloquent.
*/
class BhSordersRepositoryEloquent extends BaseRepository implements BhSordersRepository
{
protected $fieldSearchable = [
];
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return BhSorders::class;
}
/**
* Boot up the repository, pushing criteria.
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/
public function boot()
{
$this->pushCriteria(app(RequestCriteria::class));
}
/**
* 返回指定订单编号的订单信息
* @param $order_no
* @return mixed
*/
public function getSorderFromOrderNo($orderNo)
{
$where = [
'so_no' => $orderNo
];
return $this->findWhere($where)->first();
}
/**
* 获取订单详情
* @param $orderNo
* @return mixed
*/
public function getSorderItemsFromOrderNo($orderNo){
$soItems = $this
->join('soitems','soitems.so_id','sorders.so_id')
->where('sorders.so_no',$orderNo)->get();
return $soItems;
}
/**
* 获取订单相关信息(包括,产品,客户,品牌等)
* @param $so_id
* @return mixed
*/
public function getSorderDetailFromOrderId($so_id)
{
$sOrderInfo = $this
->join('customers','sorders.cus_id','customers.cus_id')
->where('sorders.so_id',$so_id)
->get();
if(!$sOrderInfo){
return ;
}
$sOrderInfo = current($sOrderInfo->toArray());
$items = DB::connection('bh_mysql')->table('soitems')
->join('products','soitems.p_id','products.p_id')
->join('chemicals','products.c_id','chemicals.c_id')
->join('brands','products.b_id','brands.b_id')
->where('soitems.so_id',$so_id)
->get();
if(!$items){
$sOrderInfo['items'] = [];
}
$sOrderInfo['items'] = $items->toArray();
return $sOrderInfo;
}
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Models;
class BhPorders extends Model
{
protected $table = 'porders';
protected $connection = 'bh_mysql';
protected $primaryKey = 'po_id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'po_sup_order','po_if_direct'
];
protected $guarded = ['updated_at'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
];
/**
* update时不做自动更新时间操作
* @return null
*/
public function getUpdatedAtColumn()
{
return null;
}
}
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Models;
class BhSoitems extends Model
{
// 销售订单
protected $table = 'soitems';
protected $connection = 'bh_mysql';
protected $primaryKey = 'si_id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
];
protected $guarded = ['created_at', 'updated_at'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
];
/**
* update时不做自动更新时间操作
* @return null
*/
public function getUpdatedAtColumn()
{
return null;
}
public function getCreatedAtColumn()
{
return null;
}
}
\ No newline at end of file
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Models;
class BhSorderRefund extends Model
{
protected $table = 'tools_task';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name','exec_content','status','error_message','type','exec_nums','create_by'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
];
}
\ No newline at end of file
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Models;
class BhSorders extends Model
{
// 销售订单
protected $table = 'sorders';
protected $connection = 'bh_mysql';
protected $primaryKey = 'so_id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
];
protected $guarded = ['created_at', 'updated_at'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
];
/**
* update时不做自动更新时间操作
* @return null
*/
public function getUpdatedAtColumn()
{
return null;
}
public function getCreatedAtColumn()
{
return null;
}
}
\ No newline at end of file
This diff is collapsed.
...@@ -9,4 +9,4 @@ $api = app('Dingo\Api\Routing\Router'); ...@@ -9,4 +9,4 @@ $api = app('Dingo\Api\Routing\Router');
require __DIR__.'/../routes/api/auth.php'; require __DIR__.'/../routes/api/auth.php';
require __DIR__.'/../routes/api/permissions.php'; require __DIR__.'/../routes/api/permissions.php';
//require __DIR__.'/../routes/api/tools.php'; require __DIR__.'/../routes/api/tools.php';
...@@ -61,6 +61,21 @@ return [ ...@@ -61,6 +61,21 @@ return [
'engine' => env('DB_ENGINE', null), 'engine' => env('DB_ENGINE', null),
'timezone' => env('DB_TIMEZONE', '+00:00'), 'timezone' => env('DB_TIMEZONE', '+00:00'),
], ],
'bh_mysql' => [
'driver' => 'mysql',
'host' => env('BH_DB_HOST', '127.0.0.1'),
'port' => env('BH_DB_PORT', 3306),
'database' => env('BH_DB_DATABASE', 'forge'),
'username' => env('BH_DB_USERNAME', 'forge'),
'password' => env('BH_DB_PASSWORD', ''),
'unix_socket' => env('BH_DB_SOCKET', ''),
'charset' => env('BH_DB_CHARSET', 'utf8mb4'),
'collation' => env('BH_DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => env('BH_DB_PREFIX', ''),
'strict' => env('BH_DB_STRICT_MODE', true),
'engine' => env('BH_DB_ENGINE', null),
'timezone' => env('BH_DB_TIMEZONE', '+00:00'),
],
'pgsql' => [ 'pgsql' => [
'driver' => 'pgsql', 'driver' => 'pgsql',
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CreateToolsTaskTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$tableNames = 'tools_task';
Schema::create($tableNames, function (Blueprint $table) {
$table->id();
$table->string('name')->comment('任务名称');
$table->longText('exec_content')->comment('任务内容');
$table->enum('status',['notexec','running','error','finish'])->comment('任务状态');
$table->string('type')->comment('任务类型');
$table->longText('error_message')->nullable()->comment('错误信息');
$table->unsignedTinyInteger('create_by')->comment('创建人');
$table->unsignedTinyInteger('exec_nums')->default(0)->comment('执行次数');
$table->timestamps();
});
Schema::table($tableNames,function(Blueprint $table){
DB::statement('ALTER TABLE '.$table->getTable(). ' ROW_FORMAT=DYNAMIC;');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tools_task');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTaskLogTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('task_log', function (Blueprint $table) {
$table->id();
$table->string('task_id')->comment('任务id');
$table->longText('content')->comment('执行内容');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('task_log');
}
}
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