Merge branch 'develop_bm' into feature/mzl_dev
# Conflicts: # app/controller/IndexController.php # config/route.php
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\BrandService;
|
||||
|
||||
class BrandController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new BrandService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
if (!empty($data['logo']))
|
||||
$data['logo_full'] = (new OssService)->generatePrivateUrl($data['logo']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
if (empty($data['logo']))
|
||||
$data['logo_full'] = (new OssService)->generatePrivateUrl($data['logo']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\BrandSeriesService;
|
||||
|
||||
class BrandSeriesController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new BrandSeriesService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\SysCurrency;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\SysAccountService;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard\Currency;
|
||||
|
||||
class SysAccountController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SysAccountService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name');
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name');
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\SysCurrencyService;
|
||||
|
||||
class SysCurrencyController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SysCurrencyService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
if (isset($data['last_updated']))
|
||||
$data['last_updated'] = date('Y-m-d H:i:s', $data['last_updated']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
if (isset($data['last_updated']))
|
||||
$data['last_updated'] = date('Y-m-d H:i:s', $data['last_updated']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\SysDictItem;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\SysDictService;
|
||||
use support\Request;
|
||||
|
||||
class SysDictController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SysDictService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['sysDictItem']))
|
||||
$data['sysDictItem'] = SysDictItem::where('dict_id',$data['id'])->get();
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
$data['sysDictItem'] = SysDictItem::where('dict_id',$data['id'])->get();
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\SysDictItemService;
|
||||
|
||||
class SysDictItemController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SysDictItemService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\Country;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\SysPortService;
|
||||
|
||||
class SysPortController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SysPortService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
if (isset($data['country_id']))
|
||||
if (isset($data['country_id']))
|
||||
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr');
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr');
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\VehColorService;
|
||||
|
||||
class VehColorController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new VehColorService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\VehModificationService;
|
||||
|
||||
class VehModificationController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new VehModificationService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\Brand;
|
||||
|
||||
class BrandLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = Brand::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\BrandSeries;
|
||||
|
||||
class BrandSeriesLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = BrandSeries::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\SysAccount;
|
||||
|
||||
class SysAccountLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysAccount::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\SysCurrency;
|
||||
|
||||
class SysCurrencyLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysCurrency::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\SysDictItem;
|
||||
|
||||
class SysDictItemLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysDictItem::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\SysDict;
|
||||
|
||||
class SysDictLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysDict::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\SysPort;
|
||||
|
||||
class SysPortLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysPort::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\VehColor;
|
||||
|
||||
class VehColorLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = VehColor::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\VehModification;
|
||||
|
||||
class VehModificationLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = VehModification::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\BrandSeriesValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\BrandSeries;
|
||||
use support\Request;
|
||||
|
||||
class BrandSeriesService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = BrandSeries::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = BrandSeriesValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询条件
|
||||
*/
|
||||
|
||||
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
||||
{
|
||||
$p = $request->all();
|
||||
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
switch ($scene) {
|
||||
case 'index':
|
||||
// ====== ====== 排序 ====== ======
|
||||
$config['order']['sort'] = 'desc';
|
||||
$config['order']['id'] = 'desc';
|
||||
|
||||
// ====== ====== 筛选 ====== ======
|
||||
$config['where']['brand_id'] = $p['brand_id'];
|
||||
// 状态
|
||||
if (isset($p['status']) && in_array($p['status'], [0,1])) {
|
||||
$config['where']['status'] = $p['status'];
|
||||
}
|
||||
// 关键字
|
||||
if (isset($p['keyword']) && $p['keyword']) {
|
||||
$k = '%' . $p['keyword'] . '%';
|
||||
foreach (['series_code','series_name'] as $col) {
|
||||
$config['orWhere'][] = [$col, 'like', $k];
|
||||
}
|
||||
}
|
||||
//$config['where']['status'] = 1;
|
||||
break;
|
||||
case 'show':
|
||||
$config['where']['id'] = $p['id'];
|
||||
//$config['where']['status'] = 1;
|
||||
break;
|
||||
case 'store':
|
||||
break;
|
||||
case 'update':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'destroy':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\BrandValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\Brand;
|
||||
use support\Request;
|
||||
|
||||
class BrandService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = Brand::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = BrandValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询条件
|
||||
*/
|
||||
|
||||
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
||||
{
|
||||
$p = $request->all();
|
||||
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
switch ($scene) {
|
||||
case 'index':
|
||||
// ====== ====== 排序 ====== ======
|
||||
$config['order']['sort'] = 'desc';
|
||||
$config['order']['id'] = 'desc';
|
||||
|
||||
// ====== ====== 筛选 ====== ======
|
||||
// 状态
|
||||
if (isset($p['status']) && in_array($p['status'], [0,1])) {
|
||||
$config['where']['status'] = $p['status'];
|
||||
}
|
||||
// 关键字
|
||||
if (isset($p['keyword']) && $p['keyword']) {
|
||||
$k = '%' . $p['keyword'] . '%';
|
||||
foreach (['brand_code','brand_name'] as $col) {
|
||||
$config['orWhere'][] = [$col, 'like', $k];
|
||||
}
|
||||
}
|
||||
//$config['where']['status'] = 1;
|
||||
break;
|
||||
case 'show':
|
||||
$config['where']['id'] = $p['id'];
|
||||
//$config['where']['status'] = 1;
|
||||
break;
|
||||
case 'store':
|
||||
break;
|
||||
case 'update':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'destroy':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\SysAccountValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysAccount;
|
||||
use support\Request;
|
||||
|
||||
class SysAccountService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysAccount::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = SysAccountValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询条件
|
||||
*/
|
||||
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
||||
{
|
||||
$p = $request->all();
|
||||
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
switch ($scene) {
|
||||
case 'index':
|
||||
// ====== ====== 排序 ====== ======
|
||||
$config['order']['sort'] = 'desc';
|
||||
$config['order']['id'] = 'desc';
|
||||
|
||||
// ====== ====== 筛选 ====== ======
|
||||
// 状态
|
||||
if (isset($p['status']) && in_array($p['status'], [0,1])) {
|
||||
$config['where']['status'] = $p['status'];
|
||||
}
|
||||
// 状态
|
||||
if (isset($p['type']) && $p['type']) {
|
||||
$config['where']['type'] = $p['type'];
|
||||
}
|
||||
// 关键字
|
||||
if (isset($p['keyword']) && $p['keyword']) {
|
||||
$k = '%' . $p['keyword'] . '%';
|
||||
foreach (['account_name','account_number','bank_name','bank_branch','description'] as $col) {
|
||||
$config['orWhere'][] = [$col, 'like', $k];
|
||||
}
|
||||
}
|
||||
//$config['where']['status'] = 1;
|
||||
break;
|
||||
case 'show':
|
||||
$config['where']['id'] = $p['id'];
|
||||
//$config['where']['status'] = 1;
|
||||
break;
|
||||
case 'store':
|
||||
break;
|
||||
case 'update':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'destroy':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\SysCurrencyValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysCurrency;
|
||||
use support\Request;
|
||||
|
||||
class SysCurrencyService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysCurrency::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = SysCurrencyValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造 CrudUtil 查询配置
|
||||
*/
|
||||
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
||||
{
|
||||
$p = $request->all();
|
||||
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
switch ($scene) {
|
||||
case 'default':
|
||||
$config['order']['id'] = 'desc';
|
||||
case 'index':
|
||||
break;
|
||||
case 'show':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'store':
|
||||
break;
|
||||
case 'update':
|
||||
case 'destroy':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\SysDictItemValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysDictItem;
|
||||
use support\Request;
|
||||
|
||||
class SysDictItemService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysDictItem::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = SysDictItemValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询条件
|
||||
*/
|
||||
protected function buildQueryConfig(Request $request, string $scene = 'index'): array
|
||||
{
|
||||
$p = $request->all();
|
||||
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
switch ($scene) {
|
||||
case 'index':
|
||||
// ====== ====== 排序 ====== ======
|
||||
$config['order']['sort'] = 'desc';
|
||||
|
||||
// ====== ====== 筛选 ====== ======
|
||||
|
||||
$config['where']['dict_id'] = $p['id'];
|
||||
// 状态
|
||||
if (isset($p['status']) && in_array($p['status'], [0,1])) {
|
||||
$config['where']['status'] = $p['status'];
|
||||
}
|
||||
// 关键字
|
||||
if (isset($p['keyword']) && $p['keyword']) {
|
||||
$k = '%' . $p['keyword'] . '%';
|
||||
foreach (['item_label','item_value','remark'] as $col) {
|
||||
$config['orWhere'][] = [$col, 'like', $k];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'update':
|
||||
case 'destroy':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'store':
|
||||
break;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\SysDictValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysDict;
|
||||
use support\Request;
|
||||
|
||||
class SysDictService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysDict::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = SysDictValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建查询条件
|
||||
*/
|
||||
protected function buildQueryConfig(Request $request, string $scene = 'index'): array
|
||||
{
|
||||
$p = $request->all();
|
||||
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
switch ($scene) {
|
||||
case 'index':
|
||||
// ====== ====== 排序 ====== ======
|
||||
$config['order']['id'] = 'desc';
|
||||
|
||||
// ====== ====== 筛选 ====== ======
|
||||
// 状态
|
||||
if (isset($p['status']) && in_array($p['status'], [0,1])) {
|
||||
$config['where']['status'] = $p['status'];
|
||||
}
|
||||
// 关键字
|
||||
if (isset($p['keyword']) && $p['keyword']) {
|
||||
$k = '%' . $p['keyword'] . '%';
|
||||
foreach (['dict_name','dict_code','description'] as $col) {
|
||||
$config['orWhere'][] = [$col, 'like', $k];
|
||||
}
|
||||
}
|
||||
|
||||
// ====== ====== 关联 ====== ======
|
||||
$config['with']['sysDictItem'][] = 'item_label';
|
||||
$config['with']['sysDictItem'][] = 'item_value';
|
||||
break;
|
||||
case 'show':
|
||||
$config['where']['id'] = $p['id'];
|
||||
// ====== ====== 关联 ====== ======
|
||||
$config['with']['sysDictItem'][] = 'item_label';
|
||||
$config['with']['sysDictItem'][] = 'item_value';
|
||||
break;
|
||||
case 'update':
|
||||
case 'destroy':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'store':
|
||||
break;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\SysPortValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysPort;
|
||||
use support\Request;
|
||||
|
||||
class SysPortService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysPort::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = SysPortValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询条件
|
||||
*/
|
||||
|
||||
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
||||
{
|
||||
$p = $request->all();
|
||||
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
switch ($scene) {
|
||||
case 'index':
|
||||
// ====== ====== 排序 ====== ======
|
||||
$config['order']['sort'] = 'desc';
|
||||
$config['order']['id'] = 'desc';
|
||||
|
||||
// ====== ====== 筛选 ====== ======
|
||||
// 状态
|
||||
if (isset($p['status']) && in_array($p['status'], [0,1])) {
|
||||
$config['where']['status'] = $p['status'];
|
||||
}
|
||||
// 关键字
|
||||
if (isset($p['keyword']) && $p['keyword']) {
|
||||
$k = '%' . $p['keyword'] . '%';
|
||||
foreach (['port_code','port_name'] as $col) {
|
||||
$config['orWhere'][] = [$col, 'like', $k];
|
||||
}
|
||||
}
|
||||
//$config['where']['status'] = 1;
|
||||
break;
|
||||
case 'show':
|
||||
$config['where']['id'] = $p['id'];
|
||||
//$config['where']['status'] = 1;
|
||||
break;
|
||||
case 'store':
|
||||
break;
|
||||
case 'update':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'destroy':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加前置处理
|
||||
*/
|
||||
public function beforeServiceStore($data, Request $request)
|
||||
{
|
||||
if(empty($data['lat']))
|
||||
unset($data['lat']);
|
||||
if(empty($data['lng']))
|
||||
unset($data['lng']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加前置处理
|
||||
*/
|
||||
public function beforeServiceUpdate($data, Request $request)
|
||||
{
|
||||
if(empty($data['lat']))
|
||||
unset($data['lat']);
|
||||
if(empty($data['lng']))
|
||||
unset($data['lng']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\VehColorValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\VehColor;
|
||||
|
||||
class VehColorService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = VehColor::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = VehColorValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\VehModificationValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\VehModification;
|
||||
use support\Request;
|
||||
|
||||
class VehModificationService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = VehModification::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = VehModificationValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询条件
|
||||
*/
|
||||
|
||||
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
||||
{
|
||||
$p = $request->all();
|
||||
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
switch ($scene) {
|
||||
case 'index':
|
||||
// ====== ====== 排序 ====== ======
|
||||
$config['order']['sort'] = 'desc';
|
||||
$config['order']['id'] = 'desc';
|
||||
|
||||
// ====== ====== 筛选 ====== ======
|
||||
// 状态
|
||||
if (isset($p['status']) && in_array($p['status'], [0,1])) {
|
||||
$config['where']['status'] = $p['status'];
|
||||
}
|
||||
// 状态
|
||||
if (isset($p['type']) && $p['type']) {
|
||||
$config['where']['type'] = $p['type'];
|
||||
}
|
||||
// 关键字
|
||||
if (isset($p['keyword']) && $p['keyword']) {
|
||||
$k = '%' . $p['keyword'] . '%';
|
||||
foreach (['code','name'] as $col) {
|
||||
$config['orWhere'][] = [$col, 'like', $k];
|
||||
}
|
||||
}
|
||||
//$config['where']['status'] = 1;
|
||||
break;
|
||||
case 'show':
|
||||
$config['where']['id'] = $p['id'];
|
||||
//$config['where']['status'] = 1;
|
||||
break;
|
||||
case 'store':
|
||||
break;
|
||||
case 'update':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'destroy':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class BrandSeriesValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class BrandValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SysAccountValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SysCurrencyValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SysDictItemValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SysDictValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SysPortValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VehColorValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VehModificationValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -3,6 +3,15 @@
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\admin\service\RoleService;
|
||||
use app\common\service\BrandSeriesService;
|
||||
use app\common\service\BrandService;
|
||||
use app\common\service\SysAccountService;
|
||||
use app\common\service\SysCurrencyService;
|
||||
use app\common\service\SysDictItemService;
|
||||
use app\common\service\SysDictService;
|
||||
use app\common\service\SysPortService;
|
||||
use app\common\service\VehColorService;
|
||||
use app\common\service\VehModificationService;
|
||||
use support\Request;
|
||||
use app\common\service\CorpService;
|
||||
use app\common\service\CorpFeishuAppService;
|
||||
@@ -76,6 +85,99 @@ class PresetController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function currency()
|
||||
{
|
||||
try {
|
||||
$result = (new SysCurrencyService)->getList();
|
||||
return $this->success($result, '获取货币列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function brand()
|
||||
{
|
||||
try {
|
||||
$result = (new BrandService)->getList();
|
||||
return $this->success($result, '获取品牌列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function series(Request $request)
|
||||
{
|
||||
try {
|
||||
$params = $request->all();
|
||||
$result = (new BrandSeriesService)->getList($params);
|
||||
return $this->success($result, '获取车系列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function account()
|
||||
{
|
||||
try {
|
||||
$result = (new SysAccountService)->getList();
|
||||
return $this->success($result, '获取账号列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function dict()
|
||||
{
|
||||
try {
|
||||
$result = (new SysDictService)->getList();
|
||||
return $this->success($result, '获取字典列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function dictItem(Request $request)
|
||||
{
|
||||
try {
|
||||
$params = $request->all();
|
||||
$result = (new SysDictItemService)->getList($params);
|
||||
return $this->success($result, '获取字典项列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function port()
|
||||
{
|
||||
try {
|
||||
$result = (new SysPortService)->getList();
|
||||
return $this->success($result, '获取港口列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function color(Request $request)
|
||||
{
|
||||
try {
|
||||
$params = $request->all();
|
||||
$result = (new VehColorService)->getList($params);
|
||||
return $this->success($result, '获取颜色列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function modification()
|
||||
{
|
||||
try {
|
||||
$result = (new VehModificationService)->getList();
|
||||
return $this->success($result, '获取货币列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function cacheClear()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\Brand;
|
||||
|
||||
class BrandLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = Brand::class;
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return Brand::where('status', 1)->orderBy('sort','desc')->get(['id', 'brand_code', 'brand_name', 'logo', 'description']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\BrandSeries;
|
||||
|
||||
class BrandSeriesLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = BrandSeries::class;
|
||||
|
||||
public function getList($where)
|
||||
{
|
||||
return BrandSeries::where('status', 1)->where($where)->orderBy('sort','desc')->get(['id', 'series_code', 'series_name', 'description']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\SysAccount;
|
||||
|
||||
class SysAccountLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysAccount::class;
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return SysAccount::where('status', 1)->orderBy('sort','desc')->get(['id', 'account_name', 'currency_id', 'account_number', 'bank_name', 'bank_branch', 'description']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\model\SysCurrency;
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
|
||||
class SysCurrencyLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysCurrency::class;
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return SysCurrency::where('status', 1)->get(['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'float_percent']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\SysDictItem;
|
||||
|
||||
class SysDictItemLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysDictItem::class;
|
||||
|
||||
public function getList($where)
|
||||
{
|
||||
return SysDictItem::where('status', 1)->where($where)->orderBy('sort','desc')->get(['id', 'item_label', 'item_value', 'remark', 'dict_id']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\SysDict;
|
||||
|
||||
class SysDictLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysDict::class;
|
||||
|
||||
public function getDictByCode($code)
|
||||
{
|
||||
return SysDict::where('status', 1)->where('code', $code)->orderBy('sort','desc')->first(['id']);
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return SysDict::where('status', 1)->get(['id', 'dict_name', 'dict_code', 'description']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\SysPort;
|
||||
|
||||
class SysPortLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysPort::class;
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return SysPort::where('status', 1)->orderBy('sort','desc')->get(['id', 'port_code', 'port_name', 'country_id', 'description']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\VehColor;
|
||||
|
||||
class VehColorLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = VehColor::class;
|
||||
|
||||
public function getList($where)
|
||||
{
|
||||
return VehColor::where('status', 1)->where($where)->orderBy('sort','desc')->get(['id', 'color_code', 'color_text']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\VehModification;
|
||||
|
||||
class VehModificationLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = VehModification::class;
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return VehModification::where('status', 1)->orderBy('sort','desc')->get(['id', 'code', 'name', 'type', 'price']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class Brand extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'brand';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'brand_code', 'brand_name', 'logo', 'country', 'description', 'status', 'sort', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class BrandSeries extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'brand_series';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'brand_id', 'series_code', 'series_name', 'description', 'status', 'sort', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class SysAccount extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'sys_account';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'account_name', 'account_type', 'account_number', 'account_holder', 'bank_name', 'bank_branch', 'daily_limit', 'single_limit', 'description', 'status', 'sort', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class SysCurrency extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'sys_currency';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'base_currency', 'float_percent', 'status', 'last_updated', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use support\Model;
|
||||
|
||||
class SysDict extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'sys_dict';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'dict_name', 'dict_code', 'description', 'status', 'created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
// 定义与 SysDictItem 的一对多关系
|
||||
public function sysDictItem()
|
||||
{
|
||||
return $this->hasMany(SysDictItem::class, 'dict_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use support\Model;
|
||||
|
||||
class SysDictItem extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'sys_dict_item';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'dict_id', 'item_label', 'item_value', 'sort', 'status', 'remark', 'created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
// 定义反向多对一关联
|
||||
public function sysDict()
|
||||
{
|
||||
return $this->belongsTo(SysDict::class, 'dict_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class SysPort extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'sys_port';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'port_code', 'port_name', 'country_id', 'lat', 'lng', 'description', 'status', 'sort', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class VehColor extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'veh_color';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'color_code', 'color_text', 'type', 'hex_code', 'rgb_code', 'status', 'sort', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class VehModification extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'veh_modification';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'code', 'name', 'type', 'description', 'price', 'status', 'sort', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\admin\validate\BrandSeriesValidate;
|
||||
use app\common\logic\BrandSeriesLogic;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\BrandSeries;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
|
||||
class BrandSeriesService
|
||||
{
|
||||
|
||||
protected $logic;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = (new BrandSeriesLogic());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统list
|
||||
*/
|
||||
public function getList($params)
|
||||
{
|
||||
if (empty($params['brand_id']))
|
||||
throw new BusinessException('品牌id不能为空');
|
||||
$where = [];
|
||||
if(isset($params['brand_id']) && $params['brand_id'])
|
||||
$where[] = ['brand_id', '=', $params['brand_id']];
|
||||
return $this->logic->getList($where);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\logic\BrandLogic;
|
||||
|
||||
class BrandService
|
||||
{
|
||||
|
||||
protected $logic;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = (new BrandLogic());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统list
|
||||
*/
|
||||
public function getList()
|
||||
{
|
||||
return $this->logic->getList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\admin\validate\SysAccountValidate;
|
||||
use app\common\logic\SysAccountLogic;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysAccount;
|
||||
use support\Request;
|
||||
|
||||
class SysAccountService
|
||||
{
|
||||
|
||||
protected $logic;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = (new SysAccountLogic());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统list
|
||||
*/
|
||||
public function getList()
|
||||
{
|
||||
return $this->logic->getList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\logic\SysCurrencyLogic;
|
||||
use app\common\logic\SystemsLogic;
|
||||
|
||||
class SysCurrencyService
|
||||
{
|
||||
|
||||
protected $logic;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = (new SysCurrencyLogic());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统list
|
||||
*/
|
||||
public function getList()
|
||||
{
|
||||
return $this->logic->getList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\admin\validate\SysDictItemValidate;
|
||||
use app\common\logic\SysDictItemLogic;
|
||||
use app\common\logic\SysDictLogic;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysDictItem;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
|
||||
class SysDictItemService
|
||||
{
|
||||
|
||||
protected $logic;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = (new SysDictItemLogic());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统list
|
||||
*/
|
||||
public function getList($params)
|
||||
{
|
||||
if (empty($params['dict_id']) && empty($params['dict_code']))
|
||||
throw new BusinessException('未明确要查询的字典组');
|
||||
$where = [];
|
||||
if(isset($params['dict_id']) && $params['dict_id'])
|
||||
$where[] = ['dict_id', '=', $params['dict_id']];
|
||||
if(isset($params['dict_code']) && $params['dict_code']){
|
||||
$dict = (new SysDictLogic)->getDictByCode($params['dict_code']);
|
||||
if (empty($dict['id']))
|
||||
throw new BusinessException('字典组code错误');
|
||||
$where[] = ['dict_id', '=', $dict['id']];
|
||||
}
|
||||
|
||||
return $this->logic->getList($where);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\admin\validate\SysDictValidate;
|
||||
use app\common\logic\SysDictLogic;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysDict;
|
||||
use support\Request;
|
||||
|
||||
class SysDictService
|
||||
{
|
||||
|
||||
protected $logic;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = (new SysDictLogic());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统list
|
||||
*/
|
||||
public function getList()
|
||||
{
|
||||
return $this->logic->getList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\admin\validate\SysPortValidate;
|
||||
use app\common\logic\SysPortLogic;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysPort;
|
||||
use support\Request;
|
||||
|
||||
class SysPortService
|
||||
{
|
||||
|
||||
protected $logic;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = (new SysPortLogic());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统list
|
||||
*/
|
||||
public function getList()
|
||||
{
|
||||
return $this->logic->getList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\admin\validate\VehColorValidate;
|
||||
use app\common\logic\VehColorLogic;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\VehColor;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
class VehColorService
|
||||
{
|
||||
|
||||
protected $logic;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = (new VehColorLogic());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统list
|
||||
*/
|
||||
public function getList($params)
|
||||
{
|
||||
if (empty($params['type']))
|
||||
throw new BusinessException('类型不能为空');
|
||||
$where = [];
|
||||
if(isset($params['type']) && $params['type'])
|
||||
$where[] = ['type', '=', $params['type']];
|
||||
return $this->logic->getList($where);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\admin\validate\VehModificationValidate;
|
||||
use app\common\logic\VehModificationLogic;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\VehModification;
|
||||
use support\Request;
|
||||
|
||||
class VehModificationService
|
||||
{
|
||||
|
||||
protected $logic;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = (new VehModificationLogic());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统list
|
||||
*/
|
||||
public function getList()
|
||||
{
|
||||
return $this->logic->getList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\inquiry\service\InquiryLogService;
|
||||
use app\common\model\CrmCustomer;
|
||||
use app\common\model\InquiryLog;
|
||||
use Webman\RedisQueue\Consumer;
|
||||
use app\common\model\User;
|
||||
use app\common\utils\FeishuMessage;
|
||||
use support\exception\BusinessException;
|
||||
use support\Log;
|
||||
use support\Model;
|
||||
|
||||
class InquiryToCrmNew implements Consumer
|
||||
{
|
||||
// 要消费的队列名
|
||||
public $queue = 'inquiry-to-crm-new';
|
||||
|
||||
// 连接名,对应 plugin/webman/redis-queue/redis.php 里的连接`
|
||||
public $connection = 'default';
|
||||
|
||||
// 消费
|
||||
public function consume($data)
|
||||
{
|
||||
|
||||
/*
|
||||
询单 与 CRM 之间的同步场景描述
|
||||
|
||||
添加(询单)
|
||||
添加 不发 不分 (不同步)1
|
||||
添加 发了 不分 (要同步)2
|
||||
添加 不发 分了 (要同步)3
|
||||
添加 不发 直分 (要同步)4
|
||||
|
||||
更新(询单)
|
||||
没发 没分 更新 (不同步)5
|
||||
没发 分过 更新 (要同步)6
|
||||
发过 没分 更新 (要同步)7
|
||||
发过 分过 更新 (要同步)8
|
||||
*/
|
||||
|
||||
try {
|
||||
// 获取询盘信息
|
||||
$info = InquiryLog::with(['channelInfo', 'countryInfo', 'enter'])->where('id', $data['id'])->first();
|
||||
|
||||
// 无论添加 或 更新,询单必然要存在
|
||||
if (!$info) {
|
||||
throw new BusinessException('询盘不存在:' . $data['id']);
|
||||
}
|
||||
|
||||
if ($info->status == 0 && $info->recipient == 0) {
|
||||
// 如果询单未发、未分,则不与crm同步,不做任何处理
|
||||
return true;
|
||||
}
|
||||
|
||||
// 更改库信息
|
||||
$this->syncCustomer($info);
|
||||
} catch (\Throwable $th) {
|
||||
throw $th;
|
||||
}
|
||||
}
|
||||
|
||||
public function pushWs($title, $content, $recipient = [])
|
||||
{
|
||||
$wsdata = [
|
||||
'sender_id' => 0,
|
||||
'sender_type' => 'system',
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'scene' => 1,
|
||||
'recipient' => $recipient
|
||||
];
|
||||
// 异步推送
|
||||
\Webman\RedisQueue\Redis::send('notice', $wsdata);
|
||||
}
|
||||
|
||||
public function syncCustomer(Model $info)
|
||||
{
|
||||
$uInfo = $this->recipientInfo($info);
|
||||
$crmCustomerInfo = CrmCustomer::where('sn', $info->order_no)->first();
|
||||
if ($crmCustomerInfo) {
|
||||
|
||||
// 消息推送
|
||||
if ($info->status == 2 && empty($crmCustomerInfo->user_id)) {
|
||||
// $notice = '分配';
|
||||
$title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
} else {
|
||||
if ($info->status == 2 && $crmCustomerInfo->user_id == $info->recipient) {
|
||||
// $notice = '更新';
|
||||
$title = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理';
|
||||
$content = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
} else {
|
||||
// $notice = '重新分配';
|
||||
$title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
}
|
||||
}
|
||||
|
||||
$udata = [
|
||||
<<<<<<< HEAD
|
||||
'corp_abbr' => $uInfo['corpId'],
|
||||
=======
|
||||
'corp_id' => $uInfo['corpId'],
|
||||
>>>>>>> feature/distinct
|
||||
'user_id' => $info->recipient,
|
||||
'channel_id' => $info->channel,
|
||||
'country_id' => $info->country,
|
||||
'magnitude' => $info->quality,
|
||||
'email' => $info->email,
|
||||
'phone' => $info->tel,
|
||||
'WhatsApp' => $info->whatsapp,
|
||||
'contacts' => $info->contacts,
|
||||
'desc_collect' => $info->content,
|
||||
];
|
||||
if (!$crmCustomerInfo->update($udata)) {
|
||||
throw new BusinessException('同步失败,更新客户线索失败');
|
||||
}
|
||||
} else {
|
||||
$crmCustomer = new CrmCustomer();
|
||||
$crmCustomer->sn = $info->order_no;
|
||||
<<<<<<< HEAD
|
||||
$crmCustomer->corp_abbr = $uInfo['corpId'];
|
||||
=======
|
||||
$crmCustomer->corp_id = $uInfo['corpId'];
|
||||
>>>>>>> feature/distinct
|
||||
$crmCustomer->user_id = $uInfo['recipient'];
|
||||
$crmCustomer->type = 1;
|
||||
$crmCustomer->channel_id = $info->channel;
|
||||
$crmCustomer->country_id = $info->country;
|
||||
$crmCustomer->magnitude = $info->quality;
|
||||
$crmCustomer->email = $info->email;
|
||||
$crmCustomer->phone = $info->tel;
|
||||
$crmCustomer->WhatsApp = $info->whatsapp;
|
||||
$crmCustomer->contacts = $info->contacts;
|
||||
$crmCustomer->desc_collect = $info->content;
|
||||
$crmCustomer->enter_user_id = $info->enter_user_id;
|
||||
$crmCustomer->obtain = time();
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
if(empty($uInfo['recipient'])){
|
||||
$crmCustomer->deleted_at = time();
|
||||
}
|
||||
>>>>>>> feature/distinct
|
||||
// 修改同步CRM状态
|
||||
$info->sync_crm = 1;
|
||||
// 保存
|
||||
if (!$crmCustomer->save() || !$info->save()) {
|
||||
throw new BusinessException('同步失败,创建客户线索失败');
|
||||
}
|
||||
|
||||
// 消息推送
|
||||
if ($info->status == 1) {
|
||||
// $notice = '发布';
|
||||
$title = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布';
|
||||
$content = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content);
|
||||
}
|
||||
|
||||
if ($info->status == 2) {
|
||||
// $notice = '分配';
|
||||
$title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function recipientInfo(Model $info)
|
||||
{
|
||||
$recipient = 0;
|
||||
$corpId = 0;
|
||||
$uinfo = null;
|
||||
if (!empty($info->recipient)) {
|
||||
$recipient = $info->recipient;
|
||||
$uinfo = User::where('id', $info->recipient)->first();
|
||||
if ($uinfo) {
|
||||
$corpId = $uinfo->corp_id;
|
||||
}
|
||||
}
|
||||
return [
|
||||
'recipient' => $recipient,
|
||||
'corpId' => $corpId,
|
||||
'uinfo' => $uinfo
|
||||
];
|
||||
}
|
||||
|
||||
// 消费失败回调
|
||||
/*
|
||||
$package = [
|
||||
'id' => 1357277951, // 消息ID
|
||||
'time' => 1709170510, // 消息时间
|
||||
'delay' => 0, // 延迟时间
|
||||
'attempts' => 2, // 消费次数
|
||||
'queue' => 'send-mail', // 队列名
|
||||
'data' => ['to' => 'tom@gmail.com', 'content' => 'hello'], // 消息内容
|
||||
'max_attempts' => 5, // 最大重试次数
|
||||
'error' => '错误信息' // 错误信息
|
||||
]
|
||||
*/
|
||||
public function onConsumeFailure(\Throwable $e, $package)
|
||||
{
|
||||
echo "consume failure\n";
|
||||
echo $e->getMessage() . "\n";
|
||||
// 无需反序列化
|
||||
var_export($package);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\inquiry\service\InquiryLogService;
|
||||
use app\common\model\CrmCustomer;
|
||||
use app\common\model\InquiryLog;
|
||||
use Webman\RedisQueue\Consumer;
|
||||
use app\common\model\User;
|
||||
use app\common\utils\FeishuMessage;
|
||||
use support\exception\BusinessException;
|
||||
use support\Log;
|
||||
use support\Model;
|
||||
|
||||
class InquiryToCrmNew implements Consumer
|
||||
{
|
||||
// 要消费的队列名
|
||||
public $queue = 'inquiry-to-crm-new';
|
||||
|
||||
// 连接名,对应 plugin/webman/redis-queue/redis.php 里的连接`
|
||||
public $connection = 'default';
|
||||
|
||||
// 消费
|
||||
public function consume($data)
|
||||
{
|
||||
|
||||
/*
|
||||
询单 与 CRM 之间的同步场景描述
|
||||
|
||||
添加(询单)
|
||||
添加 不发 不分 (不同步)1
|
||||
添加 发了 不分 (要同步)2
|
||||
添加 不发 分了 (要同步)3
|
||||
添加 不发 直分 (要同步)4
|
||||
|
||||
更新(询单)
|
||||
没发 没分 更新 (不同步)5
|
||||
没发 分过 更新 (要同步)6
|
||||
发过 没分 更新 (要同步)7
|
||||
发过 分过 更新 (要同步)8
|
||||
*/
|
||||
|
||||
try {
|
||||
// 获取询盘信息
|
||||
$info = InquiryLog::with(['channelInfo', 'countryInfo', 'enter'])->where('id', $data['id'])->first();
|
||||
|
||||
// 无论添加 或 更新,询单必然要存在
|
||||
if (!$info) {
|
||||
throw new BusinessException('询盘不存在:' . $data['id']);
|
||||
}
|
||||
|
||||
if ($info->status == 0 && $info->recipient == 0) {
|
||||
// 如果询单未发、未分,则不与crm同步,不做任何处理
|
||||
return true;
|
||||
}
|
||||
|
||||
// 更改库信息
|
||||
$this->syncCustomer($info);
|
||||
} catch (\Throwable $th) {
|
||||
throw $th;
|
||||
}
|
||||
}
|
||||
|
||||
public function pushWs($title, $content, $recipient = [])
|
||||
{
|
||||
$wsdata = [
|
||||
'sender_id' => 0,
|
||||
'sender_type' => 'system',
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'scene' => 1,
|
||||
'recipient' => $recipient
|
||||
];
|
||||
// 异步推送
|
||||
\Webman\RedisQueue\Redis::send('notice', $wsdata);
|
||||
}
|
||||
|
||||
public function syncCustomer(Model $info)
|
||||
{
|
||||
$uInfo = $this->recipientInfo($info);
|
||||
$crmCustomerInfo = CrmCustomer::where('sn', $info->order_no)->first();
|
||||
if ($crmCustomerInfo) {
|
||||
|
||||
// 消息推送
|
||||
if ($info->status == 2 && empty($crmCustomerInfo->user_id)) {
|
||||
// $notice = '分配';
|
||||
$title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
} else {
|
||||
if ($info->status == 2 && $crmCustomerInfo->user_id == $info->recipient) {
|
||||
// $notice = '更新';
|
||||
$title = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理';
|
||||
$content = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
} else {
|
||||
// $notice = '重新分配';
|
||||
$title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
}
|
||||
}
|
||||
|
||||
$udata = [
|
||||
'corp_abbr' => $uInfo['corpId'],
|
||||
'user_id' => $info->recipient,
|
||||
'channel_id' => $info->channel,
|
||||
'country_id' => $info->country,
|
||||
'magnitude' => $info->quality,
|
||||
'email' => $info->email,
|
||||
'phone' => $info->tel,
|
||||
'WhatsApp' => $info->whatsapp,
|
||||
'contacts' => $info->contacts,
|
||||
'desc_collect' => $info->content,
|
||||
];
|
||||
if (!$crmCustomerInfo->update($udata)) {
|
||||
throw new BusinessException('同步失败,更新客户线索失败');
|
||||
}
|
||||
} else {
|
||||
$crmCustomer = new CrmCustomer();
|
||||
$crmCustomer->sn = $info->order_no;
|
||||
$crmCustomer->corp_abbr = $uInfo['corpId'];
|
||||
$crmCustomer->user_id = $uInfo['recipient'];
|
||||
$crmCustomer->type = 1;
|
||||
$crmCustomer->channel_id = $info->channel;
|
||||
$crmCustomer->country_id = $info->country;
|
||||
$crmCustomer->magnitude = $info->quality;
|
||||
$crmCustomer->email = $info->email;
|
||||
$crmCustomer->phone = $info->tel;
|
||||
$crmCustomer->WhatsApp = $info->whatsapp;
|
||||
$crmCustomer->contacts = $info->contacts;
|
||||
$crmCustomer->desc_collect = $info->content;
|
||||
$crmCustomer->enter_user_id = $info->enter_user_id;
|
||||
$crmCustomer->obtain = time();
|
||||
// 修改同步CRM状态
|
||||
$info->sync_crm = 1;
|
||||
// 保存
|
||||
if (!$crmCustomer->save() || !$info->save()) {
|
||||
throw new BusinessException('同步失败,创建客户线索失败');
|
||||
}
|
||||
|
||||
// 消息推送
|
||||
if ($info->status == 1) {
|
||||
// $notice = '发布';
|
||||
$title = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布';
|
||||
$content = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content);
|
||||
}
|
||||
|
||||
if ($info->status == 2) {
|
||||
// $notice = '分配';
|
||||
$title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function recipientInfo(Model $info)
|
||||
{
|
||||
$recipient = 0;
|
||||
$corpId = 0;
|
||||
$uinfo = null;
|
||||
if (!empty($info->recipient)) {
|
||||
$recipient = $info->recipient;
|
||||
$uinfo = User::where('id', $info->recipient)->first();
|
||||
if ($uinfo) {
|
||||
$corpId = $uinfo->corp_id;
|
||||
}
|
||||
}
|
||||
return [
|
||||
'recipient' => $recipient,
|
||||
'corpId' => $corpId,
|
||||
'uinfo' => $uinfo
|
||||
];
|
||||
}
|
||||
|
||||
// 消费失败回调
|
||||
/*
|
||||
$package = [
|
||||
'id' => 1357277951, // 消息ID
|
||||
'time' => 1709170510, // 消息时间
|
||||
'delay' => 0, // 延迟时间
|
||||
'attempts' => 2, // 消费次数
|
||||
'queue' => 'send-mail', // 队列名
|
||||
'data' => ['to' => 'tom@gmail.com', 'content' => 'hello'], // 消息内容
|
||||
'max_attempts' => 5, // 最大重试次数
|
||||
'error' => '错误信息' // 错误信息
|
||||
]
|
||||
*/
|
||||
public function onConsumeFailure(\Throwable $e, $package)
|
||||
{
|
||||
echo "consume failure\n";
|
||||
echo $e->getMessage() . "\n";
|
||||
// 无需反序列化
|
||||
var_export($package);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\inquiry\service\InquiryLogService;
|
||||
use app\common\model\CrmCustomer;
|
||||
use app\common\model\InquiryLog;
|
||||
use Webman\RedisQueue\Consumer;
|
||||
use app\common\model\User;
|
||||
use app\common\utils\FeishuMessage;
|
||||
use support\exception\BusinessException;
|
||||
use support\Log;
|
||||
use support\Model;
|
||||
|
||||
class InquiryToCrmNew implements Consumer
|
||||
{
|
||||
// 要消费的队列名
|
||||
public $queue = 'inquiry-to-crm-new';
|
||||
|
||||
// 连接名,对应 plugin/webman/redis-queue/redis.php 里的连接`
|
||||
public $connection = 'default';
|
||||
|
||||
// 消费
|
||||
public function consume($data)
|
||||
{
|
||||
|
||||
/*
|
||||
询单 与 CRM 之间的同步场景描述
|
||||
|
||||
添加(询单)
|
||||
添加 不发 不分 (不同步)1
|
||||
添加 发了 不分 (要同步)2
|
||||
添加 不发 分了 (要同步)3
|
||||
添加 不发 直分 (要同步)4
|
||||
|
||||
更新(询单)
|
||||
没发 没分 更新 (不同步)5
|
||||
没发 分过 更新 (要同步)6
|
||||
发过 没分 更新 (要同步)7
|
||||
发过 分过 更新 (要同步)8
|
||||
*/
|
||||
|
||||
try {
|
||||
// 获取询盘信息
|
||||
$info = InquiryLog::with(['channelInfo', 'countryInfo', 'enter'])->where('id', $data['id'])->first();
|
||||
|
||||
// 无论添加 或 更新,询单必然要存在
|
||||
if (!$info) {
|
||||
throw new BusinessException('询盘不存在:' . $data['id']);
|
||||
}
|
||||
|
||||
if ($info->status == 0 && $info->recipient == 0) {
|
||||
// 如果询单未发、未分,则不与crm同步,不做任何处理
|
||||
return true;
|
||||
}
|
||||
|
||||
// 更改库信息
|
||||
$this->syncCustomer($info);
|
||||
} catch (\Throwable $th) {
|
||||
throw $th;
|
||||
}
|
||||
}
|
||||
|
||||
public function pushWs($title, $content, $recipient = [])
|
||||
{
|
||||
$wsdata = [
|
||||
'sender_id' => 0,
|
||||
'sender_type' => 'system',
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'scene' => 1,
|
||||
'recipient' => $recipient
|
||||
];
|
||||
// 异步推送
|
||||
\Webman\RedisQueue\Redis::send('notice', $wsdata);
|
||||
}
|
||||
|
||||
public function syncCustomer(Model $info)
|
||||
{
|
||||
$uInfo = $this->recipientInfo($info);
|
||||
$crmCustomerInfo = CrmCustomer::where('sn', $info->order_no)->first();
|
||||
if ($crmCustomerInfo) {
|
||||
|
||||
// 消息推送
|
||||
if ($info->status == 2 && empty($crmCustomerInfo->user_id)) {
|
||||
// $notice = '分配';
|
||||
$title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
} else {
|
||||
if ($info->status == 2 && $crmCustomerInfo->user_id == $info->recipient) {
|
||||
// $notice = '更新';
|
||||
$title = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理';
|
||||
$content = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
} else {
|
||||
// $notice = '重新分配';
|
||||
$title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
}
|
||||
}
|
||||
|
||||
$udata = [
|
||||
'corp_id' => $uInfo['corpId'],
|
||||
'user_id' => $info->recipient,
|
||||
'channel_id' => $info->channel,
|
||||
'country_id' => $info->country,
|
||||
'magnitude' => $info->quality,
|
||||
'email' => $info->email,
|
||||
'phone' => $info->tel,
|
||||
'WhatsApp' => $info->whatsapp,
|
||||
'contacts' => $info->contacts,
|
||||
'desc_collect' => $info->content,
|
||||
];
|
||||
if (!$crmCustomerInfo->update($udata)) {
|
||||
throw new BusinessException('同步失败,更新客户线索失败');
|
||||
}
|
||||
} else {
|
||||
$crmCustomer = new CrmCustomer();
|
||||
$crmCustomer->sn = $info->order_no;
|
||||
$crmCustomer->corp_id = $uInfo['corpId'];
|
||||
$crmCustomer->user_id = $uInfo['recipient'];
|
||||
$crmCustomer->type = 1;
|
||||
$crmCustomer->channel_id = $info->channel;
|
||||
$crmCustomer->country_id = $info->country;
|
||||
$crmCustomer->magnitude = $info->quality;
|
||||
$crmCustomer->email = $info->email;
|
||||
$crmCustomer->phone = $info->tel;
|
||||
$crmCustomer->WhatsApp = $info->whatsapp;
|
||||
$crmCustomer->contacts = $info->contacts;
|
||||
$crmCustomer->desc_collect = $info->content;
|
||||
$crmCustomer->enter_user_id = $info->enter_user_id;
|
||||
$crmCustomer->obtain = time();
|
||||
if(empty($uInfo['recipient'])){
|
||||
$crmCustomer->deleted_at = time();
|
||||
}
|
||||
// 修改同步CRM状态
|
||||
$info->sync_crm = 1;
|
||||
// 保存
|
||||
if (!$crmCustomer->save() || !$info->save()) {
|
||||
throw new BusinessException('同步失败,创建客户线索失败');
|
||||
}
|
||||
|
||||
// 消息推送
|
||||
if ($info->status == 1) {
|
||||
// $notice = '发布';
|
||||
$title = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布';
|
||||
$content = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content);
|
||||
}
|
||||
|
||||
if ($info->status == 2) {
|
||||
// $notice = '分配';
|
||||
$title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function recipientInfo(Model $info)
|
||||
{
|
||||
$recipient = 0;
|
||||
$corpId = 0;
|
||||
$uinfo = null;
|
||||
if (!empty($info->recipient)) {
|
||||
$recipient = $info->recipient;
|
||||
$uinfo = User::where('id', $info->recipient)->first();
|
||||
if ($uinfo) {
|
||||
$corpId = $uinfo->corp_id;
|
||||
}
|
||||
}
|
||||
return [
|
||||
'recipient' => $recipient,
|
||||
'corpId' => $corpId,
|
||||
'uinfo' => $uinfo
|
||||
];
|
||||
}
|
||||
|
||||
// 消费失败回调
|
||||
/*
|
||||
$package = [
|
||||
'id' => 1357277951, // 消息ID
|
||||
'time' => 1709170510, // 消息时间
|
||||
'delay' => 0, // 延迟时间
|
||||
'attempts' => 2, // 消费次数
|
||||
'queue' => 'send-mail', // 队列名
|
||||
'data' => ['to' => 'tom@gmail.com', 'content' => 'hello'], // 消息内容
|
||||
'max_attempts' => 5, // 最大重试次数
|
||||
'error' => '错误信息' // 错误信息
|
||||
]
|
||||
*/
|
||||
public function onConsumeFailure(\Throwable $e, $package)
|
||||
{
|
||||
echo "consume failure\n";
|
||||
echo $e->getMessage() . "\n";
|
||||
// 无需反序列化
|
||||
var_export($package);
|
||||
}
|
||||
}
|
||||
@@ -61,8 +61,17 @@ Route::group('/common', function () {
|
||||
Route::any('/feishu/app', [app\common\controller\PresetController::class, 'feishuApp']);
|
||||
Route::any('/systems', [app\common\controller\PresetController::class, 'systems']);
|
||||
Route::any('/roles', [app\common\controller\PresetController::class, 'roles']);
|
||||
Route::any('/currency', [app\common\controller\PresetController::class, 'currency']);
|
||||
Route::any('/cache/clear', [app\common\controller\PresetController::class, 'cacheClear']);
|
||||
Route::any('/menus', [app\common\controller\PresetController::class, 'menus']);
|
||||
Route::any('/brand', [app\common\controller\PresetController::class, 'brand']);
|
||||
Route::any('/brand/series', [app\common\controller\PresetController::class, 'series']);
|
||||
Route::any('/account', [app\common\controller\PresetController::class, 'account']);
|
||||
Route::any('/dict', [app\common\controller\PresetController::class, 'dict']);
|
||||
Route::any('/dictItem', [app\common\controller\PresetController::class, 'dictItem']);
|
||||
Route::any('/port', [app\common\controller\PresetController::class, 'port']);
|
||||
Route::any('/color', [app\common\controller\PresetController::class, 'color']);
|
||||
Route::any('/modification', [app\common\controller\PresetController::class, 'modification']);
|
||||
});
|
||||
|
||||
|
||||
@@ -194,6 +203,86 @@ Route::group('/admin', function () {
|
||||
Route::any('/destroy', [app\common\controller\VehVehicleSkuController::class, 'destroy']);
|
||||
});
|
||||
});
|
||||
|
||||
// 字典
|
||||
Route::group('/dict', function () {
|
||||
Route::any('/list', [app\admin\controller\SysDictController::class, 'index']);
|
||||
Route::any('/show', [app\admin\controller\SysDictController::class, 'show']);
|
||||
Route::any('/store', [app\admin\controller\SysDictController::class, 'store']);
|
||||
Route::any('/update', [app\admin\controller\SysDictController::class, 'update']);
|
||||
Route::any('/destroy', [app\admin\controller\SysDictController::class, 'destroy']);
|
||||
|
||||
Route::group('/item', function () {
|
||||
Route::any('/list', [app\admin\controller\SysDictItemController::class, 'index']);
|
||||
Route::any('/show', [app\admin\controller\SysDictItemController::class, 'show']);
|
||||
Route::any('/store', [app\admin\controller\SysDictItemController::class, 'store']);
|
||||
Route::any('/update', [app\admin\controller\SysDictItemController::class, 'update']);
|
||||
Route::any('/destroy', [app\admin\controller\SysDictItemController::class, 'destroy']);
|
||||
});
|
||||
});
|
||||
|
||||
// 货币
|
||||
Route::group('/currency', function () {
|
||||
Route::any('/list', [app\admin\controller\SysCurrencyController::class, 'index']);
|
||||
Route::any('/show', [app\admin\controller\SysCurrencyController::class, 'show']);
|
||||
Route::any('/store', [app\admin\controller\SysCurrencyController::class, 'store']);
|
||||
Route::any('/update', [app\admin\controller\SysCurrencyController::class, 'update']);
|
||||
Route::any('/destroy', [app\admin\controller\SysCurrencyController::class, 'destroy']);
|
||||
});
|
||||
|
||||
// 品牌
|
||||
Route::group('/brand', function () {
|
||||
Route::any('/list', [app\admin\controller\BrandController::class, 'index']);
|
||||
Route::any('/show', [app\admin\controller\BrandController::class, 'show']);
|
||||
Route::any('/store', [app\admin\controller\BrandController::class, 'store']);
|
||||
Route::any('/update', [app\admin\controller\BrandController::class, 'update']);
|
||||
Route::any('/destroy', [app\admin\controller\BrandController::class, 'destroy']);
|
||||
// 车系
|
||||
Route::group('/series', function () {
|
||||
Route::any('/list', [app\admin\controller\BrandSeriesController::class, 'index']);
|
||||
Route::any('/show', [app\admin\controller\BrandSeriesController::class, 'show']);
|
||||
Route::any('/store', [app\admin\controller\BrandSeriesController::class, 'store']);
|
||||
Route::any('/update', [app\admin\controller\BrandSeriesController::class, 'update']);
|
||||
Route::any('/destroy', [app\admin\controller\BrandSeriesController::class, 'destroy']);
|
||||
});
|
||||
});
|
||||
|
||||
// 汽车颜色
|
||||
Route::group('/color', function () {
|
||||
Route::any('/list', [app\admin\controller\VehColorController::class, 'index']);
|
||||
Route::any('/show', [app\admin\controller\VehColorController::class, 'show']);
|
||||
Route::any('/store', [app\admin\controller\VehColorController::class, 'store']);
|
||||
Route::any('/update', [app\admin\controller\VehColorController::class, 'update']);
|
||||
Route::any('/destroy', [app\admin\controller\VehColorController::class, 'destroy']);
|
||||
});
|
||||
|
||||
// 汽车改装项目
|
||||
Route::group('/modification', function () {
|
||||
Route::any('/list', [app\admin\controller\VehModificationController::class, 'index']);
|
||||
Route::any('/show', [app\admin\controller\VehModificationController::class, 'show']);
|
||||
Route::any('/store', [app\admin\controller\VehModificationController::class, 'store']);
|
||||
Route::any('/update', [app\admin\controller\VehModificationController::class, 'update']);
|
||||
Route::any('/destroy', [app\admin\controller\VehModificationController::class, 'destroy']);
|
||||
});
|
||||
|
||||
// 账户
|
||||
Route::group('/account', function () {
|
||||
Route::any('/list', [app\admin\controller\SysAccountController::class, 'index']);
|
||||
Route::any('/show', [app\admin\controller\SysAccountController::class, 'show']);
|
||||
Route::any('/store', [app\admin\controller\SysAccountController::class, 'store']);
|
||||
Route::any('/update', [app\admin\controller\SysAccountController::class, 'update']);
|
||||
Route::any('/destroy', [app\admin\controller\SysAccountController::class, 'destroy']);
|
||||
});
|
||||
|
||||
// 账户
|
||||
Route::group('/port', function () {
|
||||
Route::any('/list', [app\admin\controller\SysPortController::class, 'index']);
|
||||
Route::any('/show', [app\admin\controller\SysPortController::class, 'show']);
|
||||
Route::any('/store', [app\admin\controller\SysPortController::class, 'store']);
|
||||
Route::any('/update', [app\admin\controller\SysPortController::class, 'update']);
|
||||
Route::any('/destroy', [app\admin\controller\SysPortController::class, 'destroy']);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user