diff --git a/app/Domains/Artisan/.gitkeep b/app/Domains/Artisan/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/app/Domains/Artisan/Database/migrations/2019_01_17_114148_create_artisans_table.php b/app/Domains/Artisan/Database/migrations/2019_01_17_114148_create_artisans_table.php
new file mode 100644
index 00000000..37e41ab0
--- /dev/null
+++ b/app/Domains/Artisan/Database/migrations/2019_01_17_114148_create_artisans_table.php
@@ -0,0 +1,33 @@
+increments('id');
+ $table->string('command', 32)->default('')->comment('命令类型');
+ $table->text('parameters')->nullable()->comment('参数');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('artisans');
+ }
+}
diff --git a/app/Domains/Artisan/Http/Controllers/ArtisanController.php b/app/Domains/Artisan/Http/Controllers/ArtisanController.php
new file mode 100644
index 00000000..3ceb74e0
--- /dev/null
+++ b/app/Domains/Artisan/Http/Controllers/ArtisanController.php
@@ -0,0 +1,56 @@
+request = $request;
+ $this->artisanService = $artisanService;
+ }
+
+ /**
+ * 列表.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function index()
+ {
+ $conditions = $this->request->all();
+
+ $res = $this->artisanService->index($conditions);
+
+ return res($res, '命令记录', 201);
+ }
+
+
+ /**
+ * 执行.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function call()
+ {
+ set_time_limit(0);
+ ini_set('memory_limit', '4096m');
+ ini_set('default_socket_timeout', -1);
+
+ $command = $this->request->get('command');
+ $parameters = $this->request->get('parameters', []);
+
+ $this->artisanService->call($command, $parameters);
+
+ return res(true, '执行成功');
+ }
+}
diff --git a/app/Domains/Artisan/Providers/ArtisanServiceProvider.php b/app/Domains/Artisan/Providers/ArtisanServiceProvider.php
new file mode 100644
index 00000000..3c36ba01
--- /dev/null
+++ b/app/Domains/Artisan/Providers/ArtisanServiceProvider.php
@@ -0,0 +1,33 @@
+loadMigrationsFrom([realpath(__DIR__ . '/../Database/migrations')]);
+ // $this->app->make(EloquentFactory::class)->load(realpath(__DIR__ . '/../Database/factories'));
+ // $this->mergeConfigFrom(realpath(__DIR__ . '/../config.php'), 'domain.artisan');
+ }
+
+ /**
+ * 注册一个服务提供者
+ *
+ * @return void
+ */
+ public function register()
+ {
+ $this->app->register(RouteServiceProvider::class);
+ }
+}
diff --git a/app/Domains/Artisan/Providers/RouteServiceProvider.php b/app/Domains/Artisan/Providers/RouteServiceProvider.php
new file mode 100644
index 00000000..b14f12bf
--- /dev/null
+++ b/app/Domains/Artisan/Providers/RouteServiceProvider.php
@@ -0,0 +1,20 @@
+app;
+ $namespace = 'App\Domains\Artisan\Http\Controllers';
+ $pathApi = __DIR__.'/../Routes/api.php';
+ $pathWeb = __DIR__.'/../Routes/web.php';
+
+ $this->loadRoutesFiles($app->router, $namespace, $pathApi, $pathWeb);
+ }
+}
diff --git a/app/Domains/Artisan/Repositories/ArtisanRepository.php b/app/Domains/Artisan/Repositories/ArtisanRepository.php
new file mode 100644
index 00000000..679194ce
--- /dev/null
+++ b/app/Domains/Artisan/Repositories/ArtisanRepository.php
@@ -0,0 +1,76 @@
+ '=',
+ 'created_at' => 'like',
+ ];
+
+ public function model()
+ {
+ return Model::class;
+ }
+
+ /**
+ * 数据格式化
+ *
+ * @param mixed $result
+ *
+ * @return mixed
+ */
+ public function transform($model)
+ {
+ return $model->toArray();
+ }
+
+ /**
+ * 查询条件
+ *
+ * @return void
+ */
+ public function withConditions(array $conditions = [])
+ {
+ if (isset($conditions['id'])) {
+ $conditions['id'] = array_wrap($conditions['id']);
+ $this->model = $this->model->whereIn('id', $conditions['id']);
+ }
+
+ if (isset($conditions['command'])) {
+ $conditions['command'] = array_wrap($conditions['command']);
+ $this->model = $this->model->whereIn('command', $conditions['command']);
+ }
+
+ if (isset($conditions['starttime'])) {
+ $query->where('created_at', '>=', Carbon::parse($conditions['starttime']));
+ }
+
+ if (isset($conditions['endtime'])) {
+ $query->where('created_at', '<=', Carbon::parse($conditions['endtime']));
+ }
+
+ return $this;
+ }
+}
diff --git a/app/Domains/Artisan/Routes/api.php b/app/Domains/Artisan/Routes/api.php
new file mode 100644
index 00000000..f65bce37
--- /dev/null
+++ b/app/Domains/Artisan/Routes/api.php
@@ -0,0 +1,9 @@
+group(['prefix' => 'artisan', 'as' => 'artisan', 'middleware' => ['adminAuth']], function($router) {
+
+ // The controllers live in Domains/Artisan/Http/Controllers
+ $router->get('/', ['as' => 'index', 'uses' => 'ArtisanController@index']);
+ $router->post('call', ['as' => 'call', 'uses' => 'ArtisanController@call']);
+});
diff --git a/app/Domains/Artisan/Routes/web.php b/app/Domains/Artisan/Routes/web.php
new file mode 100644
index 00000000..ecc0bce9
--- /dev/null
+++ b/app/Domains/Artisan/Routes/web.php
@@ -0,0 +1,14 @@
+group(['prefix' => 'artisans', 'as' => 'artisans'], function($router) {
+
+ // The controllers live in Domains/Artisan/Http/Controllers
+ // $router->get('/', ['as' => 'index', 'uses' => 'ArtisanController@index']);
+
+ /**
+ * 需要认证的接口
+ */
+ // $router->group(['middleware' => ['userAuth']], function($router) {
+ // // $router->post('delete', ['as' => 'delete', 'uses' => 'ArtisanController@delete']);
+ // });
+});
diff --git a/app/Domains/Artisan/Services/ArtisanService.php b/app/Domains/Artisan/Services/ArtisanService.php
new file mode 100644
index 00000000..0a4cd6b0
--- /dev/null
+++ b/app/Domains/Artisan/Services/ArtisanService.php
@@ -0,0 +1,64 @@
+artisanRepository = $artisanRepository;
+ }
+
+ /**
+ * 命令执行记录
+ *
+ * @return void
+ */
+ public function index(array $conditions = [])
+ {
+ $limit = $conditions['limit'] ?? 20;
+
+ $artisans = $this->artisanRepository->withConditions($conditions)->applyConditions()->paginate($limit);
+
+ return $artisans;
+ }
+
+ /**
+ * 执行.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function call($command, array $parameters = [])
+ {
+ $commands = array_keys(Artisan::all());
+
+ if (!in_array($command, $commands)) {
+ throw new NotAllowedException('非法的命令');
+ }
+
+ try {
+ Artisan::call($command, $parameters);
+ $this->artisanRepository->create([
+ 'command' => $command,
+ 'parameters' => $parameters,
+ ]);
+ } catch (\Exception $e) {
+ throw new HttpException($e->getMessage());
+ }
+
+
+ return res(true, '执行成功');
+ }
+}
diff --git a/app/Domains/Artisan/Tests/Services/ArtisanServiceTest.php b/app/Domains/Artisan/Tests/Services/ArtisanServiceTest.php
new file mode 100644
index 00000000..85895388
--- /dev/null
+++ b/app/Domains/Artisan/Tests/Services/ArtisanServiceTest.php
@@ -0,0 +1,13 @@
+assertTrue(true);
+ }
+}
diff --git a/app/Domains/Artisan/composer.json b/app/Domains/Artisan/composer.json
new file mode 100644
index 00000000..b1520104
--- /dev/null
+++ b/app/Domains/Artisan/composer.json
@@ -0,0 +1,11 @@
+{
+ "name": "app/artisan",
+ "description": "",
+ "type": "app-domain",
+ "require": {
+
+ },
+ "autoload": {
+
+ }
+}
\ No newline at end of file
diff --git a/app/Domains/Company/Http/Controllers/OrderController.php b/app/Domains/Company/Http/Controllers/OrderController.php
index 35992e08..483508a0 100644
--- a/app/Domains/Company/Http/Controllers/OrderController.php
+++ b/app/Domains/Company/Http/Controllers/OrderController.php
@@ -135,7 +135,7 @@ class OrderController extends Controller
public function cancel()
{
$ids = $this->request->ids();
-
+
foreach ($ids as $id) {
$res = $this->orderService->cancel($id);
}
@@ -149,7 +149,7 @@ class OrderController extends Controller
public function received()
{
$ids = $this->request->ids();
-
+
foreach ($ids as $id) {
$res = $this->orderService->received($id);
}
diff --git a/app/Domains/Real/Commands/Sync/AddedOrderSync.php b/app/Domains/Real/Commands/Sync/AddedOrderSync.php
index 00ece303..16740ede 100644
--- a/app/Domains/Real/Commands/Sync/AddedOrderSync.php
+++ b/app/Domains/Real/Commands/Sync/AddedOrderSync.php
@@ -50,7 +50,7 @@ class AddedOrderSync extends Command
$this->line('插入订单数据,条数:'.count($orders));
foreach (array_chunk($orders, $this->chunks) as $data) {
- echo '.';
+ $this->getOutput()->write('.');
AddedOrder::upsert($orders, 'id');
}
app(AddedOrderRepository::class)->forgetCached();
@@ -66,7 +66,7 @@ class AddedOrderSync extends Command
];
foreach ($dataOrderCards as $type => $orderCards) {
foreach (array_chunk($orderCards, $this->chunks) as $data) {
- echo '.';
+ $this->getOutput()->write('.');
DB::table($tables[$type])->upsert($data, ['sim', 'order_id']);
}
}
diff --git a/app/Domains/Real/Commands/Sync/OrderBaseSync.php b/app/Domains/Real/Commands/Sync/OrderBaseSync.php
index 857c8a99..89e10fac 100644
--- a/app/Domains/Real/Commands/Sync/OrderBaseSync.php
+++ b/app/Domains/Real/Commands/Sync/OrderBaseSync.php
@@ -38,7 +38,7 @@ class OrderBaseSync extends Command
try {
$this->line('插入订单数据,条数:'.count($orders));
foreach (array_chunk($orders, $this->chunks) as $data) {
- echo '.';
+ $this->getOutput()->write('.');
foreach ($data as &$item) {
unset($item['package_id']);
}
@@ -49,8 +49,8 @@ class OrderBaseSync extends Command
$this->line('插入订单关联数据,条数:'.count($cards));
foreach (array_chunk($cards, $this->chunks) as $data) {
- echo '.';
- OrderCard::upsert($data, ['sim', 'order_id']);
+ $this->getOutput()->write('.');
+ OrderCard::upsert($data, ['sim', 'deleted_at']);
}
app(OrderCardRepository::class)->forgetCached();
$this->line('插入订单关联数据成功');
diff --git a/app/Domains/Virtual/Http/Controllers/ArtisanController.php b/app/Domains/Virtual/Http/Controllers/ArtisanController.php
deleted file mode 100644
index d4df8257..00000000
--- a/app/Domains/Virtual/Http/Controllers/ArtisanController.php
+++ /dev/null
@@ -1,47 +0,0 @@
-request = $request;
- }
-
- /**
- * 列表.
- *
- * @return \Illuminate\Http\Response
- */
- public function call()
- {
- $command = $this->request->get('command');
-
- $commands = array_keys(Artisan::all());
-
- if (!in_array($command, $commands)) {
- throw new NotAllowedException('非法的命令');
- }
-
- $parameters = $this->request->get('parameters', []);
-
- try{
- Artisan::call($command, $parameters);
- }catch(\Exception $e){
- throw new HttpException($e->getMessage());
- }
-
- return res(true, '执行成功');
- }
-}
diff --git a/app/Domains/Virtual/Routes/api.php b/app/Domains/Virtual/Routes/api.php
index 83fef39d..6ba2d13f 100644
--- a/app/Domains/Virtual/Routes/api.php
+++ b/app/Domains/Virtual/Routes/api.php
@@ -5,7 +5,6 @@ $router->group(['prefix' => 'virtual', 'as' => 'virtual', 'middleware' => ['admi
// The controllers live in Domains/Virtual/Http/Controllers
$router->get('/', ['as' => 'index', 'uses' => 'VirtualController@index']);
- $router->post('/artisan/call', ['as' => 'artisan.call', 'uses' => 'ArtisanController@call']);
// 名称查找
$router->get('/fetch/companies', ['as' => 'fetch.companies', 'uses' => 'FetchController@companies']);
diff --git a/app/Models/Artisan/Artisan.php b/app/Models/Artisan/Artisan.php
new file mode 100644
index 00000000..311b896c
--- /dev/null
+++ b/app/Models/Artisan/Artisan.php
@@ -0,0 +1,40 @@
+ 'array',
+ ];
+
+ protected $appends = ['command_name'];
+
+ public static $names = [
+ 'real:sync-added-order' => '同步RD企业订单数据',
+ 'real:sync-bloc' => '同步RD集团数据',
+ 'real:sync-company' => '同步RD企业数据',
+ 'real:sync-mongo' => '同步卡基础信息数据',
+ 'real:sync-order' => '同步RD基础订单数据',
+ 'real:sync-package' => '同步RD套餐数据',
+ 'virtual:sync-card' => '同步VD卡信息数据',
+ 'virtual:sync-company' => '同步VD企业数据',
+ 'virtual:sync-log' => '同步VD订单数据',
+ 'virtual:sync-package' => '同步VD套餐数据',
+ 'virtual:sync-product' => '同步VD定价',
+ ];
+
+ /**
+ * 获取命令名称
+ *
+ * @return string
+ */
+ public function getCommandNameAttribute()
+ {
+ return self::$names[$this->attributes['command']] ?? '';
+ }
+}
diff --git a/etc/supervisor.conf b/etc/supervisor.conf
index b96c2112..22b18bd1 100644
--- a/etc/supervisor.conf
+++ b/etc/supervisor.conf
@@ -1,6 +1,6 @@
[program:vd-worker]
process_name=%(program_name)s_%(process_num)02d
-command=php /www/vd/artisan queue:work --queue=default,sync --sleep=3 --tries=1 --memory=4096
+command=php /www/vd/artisan queue:work --queue=default,sync --memory=4096
autostart=true
autorestart=true
user=www
diff --git a/frontend/src/router/routes.js b/frontend/src/router/routes.js
index 9f2cfaf9..ced99780 100644
--- a/frontend/src/router/routes.js
+++ b/frontend/src/router/routes.js
@@ -26,7 +26,7 @@ const routes = [
{ path: '/exports', name: 'StatsExports', component: load('exports/index'), meta: { title: '导出记录' } },
{ path: '/stats/company-count', name: 'StatsCompanyCount', component: load('stats/company-count/index'), meta: { title: '企业统计' } },
{ path: '/stats/order/:type', name: 'StatsOrder', component: load('stats/order/index'), meta: { title: '订单统计' } },
- { path: '/stats/company-report/:type', name: 'StatsCompanyReport', component: load('stats/company-report/index'), meta: { title: '月报表' } }
+ { path: '/artisan/real-sync', name: 'RealSync', component: load('artisan/real-sync/index'), meta: { title: 'RD数据同步' } }
]
},
{ path: '*', redirect: { path: '/home' } }
diff --git a/frontend/src/views/artisan/real-sync/edit.vue b/frontend/src/views/artisan/real-sync/edit.vue
new file mode 100644
index 00000000..81c21644
--- /dev/null
+++ b/frontend/src/views/artisan/real-sync/edit.vue
@@ -0,0 +1,64 @@
+
+ {{circle.content}}{{circle.percent}}%
+
+
+
+
+
+
+
+
{{message}}
\n\t选择图标
\n\n{{CONFIG.title}}
\n \n