登录
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\service\AuthService;
|
||||
use app\common\validate\UserValidate;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
|
||||
class AuthController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要头信息的方法
|
||||
*/
|
||||
protected $noNeedHeaderData = ['feishuAuth'];
|
||||
|
||||
protected $noNeedLogin = ['feishuScope', 'login', 'register', 'feishuAuth'];
|
||||
|
||||
|
||||
// 调试
|
||||
public function feishuAuth(Request $request)
|
||||
{
|
||||
try {
|
||||
$code = $request->all();
|
||||
return $this->success($code);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function feishuScope(Request $request)
|
||||
{
|
||||
try {
|
||||
$result = (new AuthService())->feishuAuthorize($request->get('app_id'), $request->system_code, $request->is_mob);
|
||||
return $this->success($result);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage().$e->getLine().$e->getFile());
|
||||
}
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->all();
|
||||
|
||||
if(empty($data['feishu_code']) || empty($data['app_id'])){
|
||||
throw new BusinessException('参数错误');
|
||||
}
|
||||
|
||||
$result = (new AuthService())->login($data);
|
||||
return $this->success($result, '登录成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage().$e->getLine().$e->getFile());
|
||||
}
|
||||
}
|
||||
|
||||
public function register(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->validate(new UserValidate(), $this->requestData($request), $request->login_type.'_register');
|
||||
$result = (new AuthService())->register($data);
|
||||
return $this->success($result, '注册成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function refresh(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->requestData($request);
|
||||
if (!$data['refresh_token'] || !$data['system_code']) return $this->error('参数缺失', 422);
|
||||
$result = (new AuthService())->refreshToken($data['refresh_token'], $data['system_code']);
|
||||
return $this->success($result, '刷新成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage(), 401);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public function perm(Request $request)
|
||||
// {
|
||||
// try {
|
||||
// $data = $this->requestData($request);
|
||||
// if (!$data['access_token'] || !$data['system_code']) return $this->error('参数缺失', 422);
|
||||
// $result = (new AuthService())->logout($data['access_token'], $data['system_code']);
|
||||
// return $this->success($result, '已登出');
|
||||
// } catch (\Throwable $e) {}
|
||||
// }
|
||||
|
||||
// public function verify(Request $request)
|
||||
// {
|
||||
// try {
|
||||
// $token = $request->post('access_token') ?: $request->header('authorization');
|
||||
// $systemCode = $request->post('system_code');
|
||||
// if (!$token || !$systemCode) return $this->error('参数缺失', 422);
|
||||
// $payload = (new AuthService())->verifyToken($token, $systemCode);
|
||||
// return $this->success($payload, '验证成功');
|
||||
// } catch (\Throwable $e) {
|
||||
// return $this->error($e->getMessage() ?: '无效或过期的token', 401);
|
||||
// }
|
||||
// }
|
||||
|
||||
// public function logout(Request $request)
|
||||
// {
|
||||
// $token = $request->post('access_token') ?: $request->header('Authorization');
|
||||
// $systemCode = $request->post('system_code') ?: $request->header('system_code');
|
||||
// (new AuthService())->logout($token, $systemCode);
|
||||
// return $this->success([], '已登出');
|
||||
// }
|
||||
|
||||
// public function blockToken(Request $request)
|
||||
// {
|
||||
// $token = $request->post('token');
|
||||
// $systemCode = $request->post('system_code');
|
||||
// if (!$token || !$systemCode) return $this->error('参数缺失', 422);
|
||||
// (new AuthService())->blockToken($token, $systemCode);
|
||||
// return $this->success([], '已强制停用该token');
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\controller;
|
||||
|
||||
use support\exception\BusinessException;
|
||||
use app\common\traits\ResponseTrait;
|
||||
use app\common\traits\DataTransformer;
|
||||
use think\Validate;
|
||||
use support\Request;
|
||||
|
||||
class BaseController
|
||||
{
|
||||
/**
|
||||
* 响应处理、数据格式化处理
|
||||
*/
|
||||
use ResponseTrait, DataTransformer;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
* @var Validate
|
||||
*/
|
||||
protected mixed $validator = null;
|
||||
|
||||
/**
|
||||
* @var Model
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
/**
|
||||
* 不登录不鉴权
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedLogin = [];
|
||||
|
||||
/**
|
||||
* 登录不鉴权
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedAuth = [];
|
||||
|
||||
/**
|
||||
* 不用头部数据
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedHeaderData = [];
|
||||
|
||||
/**
|
||||
* 数据限制
|
||||
* null 不做限制,任何管理员都可以查看该表的所有数据
|
||||
* auth 管理员能看到自己以及自己的子管理员插入的数据
|
||||
* personal 管理员只能看到自己插入的数据
|
||||
* @var string
|
||||
*/
|
||||
protected $dataLimit = null;
|
||||
|
||||
/**
|
||||
* 数据限制字段
|
||||
*/
|
||||
protected $dataLimitField = 'admin_id';
|
||||
|
||||
/**
|
||||
* 验证数据
|
||||
*
|
||||
* @param Validate $validator 验证器实例
|
||||
* @param array $data 待验证的数据
|
||||
* @param string $scene 验证场景
|
||||
* @return array 验证后的数据
|
||||
* @throws BusinessException 验证失败时抛出业务异常
|
||||
*/
|
||||
public function validate(Validate $validator, array $data, string $scene = ''): array
|
||||
{
|
||||
// 如果指定了验证场景,并且验证器支持场景方法,则设置验证场景
|
||||
if ($scene && method_exists($validator, 'scene')) {
|
||||
$validator->scene($scene);
|
||||
}
|
||||
// 执行数据验证
|
||||
if (!$validator->check($data)) {
|
||||
// 验证失败,抛出业务异常,异常信息为验证器返回的错误信息
|
||||
throw new BusinessException($validator->getError());
|
||||
}
|
||||
// 验证成功,返回原始数据
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数处理
|
||||
*/
|
||||
public function requestData(Request $request)
|
||||
{
|
||||
return $request->all() + $request->basic_data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\BrandService;
|
||||
use support\Request;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 抓取品牌系列
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function crawlSeries(Request $request){
|
||||
try {
|
||||
$result = $this->service->crawlSeries($request);
|
||||
if($result){
|
||||
return $this->success($result,'成功');
|
||||
}else{
|
||||
return $this->error('抓取任务提交失败');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建被抓取且选中的品牌系列
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function crawlSeriesCreate(Request $request){
|
||||
try {
|
||||
$result = $this->service->crawlSeriesCreate($request);
|
||||
if($result){
|
||||
return $this->success([],$result);
|
||||
}else{
|
||||
return $this->error('创建失败');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\BrandSeriesService;
|
||||
use support\Request;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 抓取系列车型
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function crawlModels(Request $request){
|
||||
try {
|
||||
$result = $this->service->crawlModel($request);
|
||||
if($result){
|
||||
return $this->success($result,'抓取成功');
|
||||
}else{
|
||||
return $this->error('抓取任务失败');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存抓取的系列车型
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function crawlModelCreate(Request $request){
|
||||
try {
|
||||
$result = $this->service->crawlModelCreate($request);
|
||||
if($result){
|
||||
return $this->success($result,'成功');
|
||||
}else{
|
||||
return $this->error('创建失败');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键词抓取品牌、车系、车型
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function crawlKeyword(Request $request){
|
||||
try {
|
||||
$result = $this->service->crawlKeyword($request);
|
||||
if($result){
|
||||
return $this->success($result,'抓取成功');
|
||||
}else{
|
||||
return $this->error('抓取任务失败');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存抓取的系列车型
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function crawlKeywordCreate(Request $request){
|
||||
try {
|
||||
$result = $this->service->crawlKeywordCreate($request);
|
||||
if($result){
|
||||
return $this->success($result,'成功');
|
||||
}else{
|
||||
return $this->error('创建失败');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\Country;
|
||||
use app\common\model\FinPaymentStock;
|
||||
use app\common\model\StockOrders;
|
||||
use app\common\model\SysAccount;
|
||||
use app\common\model\SysCurrency;
|
||||
use app\common\model\SysDictItem;
|
||||
use app\common\model\User;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\FinPaymentApplyService;
|
||||
|
||||
class FinPaymentApplyController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new FinPaymentApplyService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['doc_user_id'])) //内勤
|
||||
$data['doc_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
|
||||
if (isset($data['sales_user_id'])) //业务员
|
||||
$data['sales_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
|
||||
if (isset($data['corp_id'])) //公司(渠道)
|
||||
$data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??'';
|
||||
if (isset($data['account_id'])){ //收款账号
|
||||
$data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??'';
|
||||
$data['account_short_desc'] = SysAccount::where('id', $data['account_id'])->value('short_desc')??'';
|
||||
}
|
||||
if (isset($data['country_id'])) //付款来源国家
|
||||
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??'';
|
||||
if (isset($data['currency_id'])) //付款币种
|
||||
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??'';
|
||||
$OssService = new OssService();
|
||||
if (!empty($data['submit_files'])){
|
||||
$data['submit_files'] = json_decode($data['submit_files'], true);
|
||||
foreach ($data['submit_files'] as $key => $value) {
|
||||
$data['submit_files'][$key] = [
|
||||
'file_src' => $value['file_src'],
|
||||
'file_full' => $OssService->generatePrivateUrl($value['file_src']),
|
||||
'file_name' => $value['file_name'],
|
||||
];
|
||||
}
|
||||
}else{
|
||||
$data['submit_files'] = [];
|
||||
}
|
||||
|
||||
if (!empty($data['voucher_file'])){
|
||||
$data['voucher_file'] = json_decode($data['voucher_file'], true);
|
||||
foreach ($data['voucher_file'] as $key => $value) {
|
||||
$data['voucher_file'][$key] = [
|
||||
'file_src' => $value['file_src'],
|
||||
'file_full' => $OssService->generatePrivateUrl($value['file_src']),
|
||||
'file_name' => $value['file_name'],
|
||||
];
|
||||
}
|
||||
}else{
|
||||
$data['voucher_file'] = [];
|
||||
}
|
||||
|
||||
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['claimed_at'])){
|
||||
$data['enter_file_last'] = date('Y-m-d H:i:s', ($data['claimed_at']+86400)); //入账资料最后提交时间
|
||||
$data['claimed_at'] = date('Y-m-d H:i:s', $data['claimed_at']); //认领时间
|
||||
}
|
||||
if (isset($data['id'])){
|
||||
$finPaymentStock = FinPaymentStock::where('payment_apply_id', $data['id'])->get();
|
||||
$stock = [];
|
||||
$stock_order_no = [];
|
||||
foreach ($finPaymentStock as $v) {
|
||||
$stock[$v['pi_no']]['pi_no'] = $v['pi_no'];
|
||||
$stock[$v['pi_no']]['stock_id'][] = [$v['stock_id']];
|
||||
$stockOrders = StockOrders::where('id', $v['stock_id'])->first();
|
||||
$stock_order_no[] = $stockOrders['order_no'];
|
||||
}
|
||||
$data['stock'] = array_values($stock);
|
||||
$data['stock_order_no'] = $stock_order_no;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function showFormat($data)
|
||||
{
|
||||
if (isset($data['doc_user_id'])) //内勤
|
||||
$data['doc_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
|
||||
if (isset($data['sales_user_id'])) //业务员
|
||||
$data['sales_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
|
||||
if (isset($data['corp_id'])) //公司(渠道)
|
||||
$data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??'';
|
||||
if (isset($data['account_id'])){ //收款账号
|
||||
$data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??'';
|
||||
$data['account_short_desc'] = SysAccount::where('id', $data['account_id'])->value('short_desc')??'';
|
||||
}
|
||||
if (isset($data['country_id'])) //付款来源国家
|
||||
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??'';
|
||||
if (isset($data['currency_id'])) //付款币种
|
||||
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??'';
|
||||
$OssService = new OssService();
|
||||
if (!empty($data['submit_files'])){
|
||||
$data['submit_files'] = json_decode($data['submit_files'], true);
|
||||
foreach ($data['submit_files'] as $key => $value) {
|
||||
$data['submit_files'][$key] = [
|
||||
'file_src' => $value['file_src'],
|
||||
'file_full' => $OssService->generatePrivateUrl($value['file_src']),
|
||||
'file_name' => $value['file_name'],
|
||||
];
|
||||
}
|
||||
}else{
|
||||
$data['submit_files'] = [];
|
||||
}
|
||||
|
||||
if (!empty($data['voucher_file'])){
|
||||
$data['voucher_file'] = json_decode($data['voucher_file'], true);
|
||||
foreach ($data['voucher_file'] as $key => $value) {
|
||||
$data['voucher_file'][$key] = [
|
||||
'file_src' => $value['file_src'],
|
||||
'file_full' => $OssService->generatePrivateUrl($value['file_src']),
|
||||
'file_name' => $value['file_name'],
|
||||
];
|
||||
}
|
||||
}else{
|
||||
$data['voucher_file'] = [];
|
||||
}
|
||||
|
||||
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']);
|
||||
|
||||
$finPaymentStock = FinPaymentStock::where('payment_apply_id', $data['id'])->get();
|
||||
$stock = [];
|
||||
foreach ($finPaymentStock as $v) {
|
||||
$stock[$v['pi_no']]['pi_no'] = $v['pi_no'];
|
||||
$stock[$v['pi_no']]['stock_id'][] = [$v['stock_id']];
|
||||
}
|
||||
$data['stock'] = array_values($stock);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function delete(Request $request)
|
||||
{
|
||||
try {
|
||||
$id = $request->input('id');
|
||||
$raw = $this->service->delete($id);
|
||||
return $this->success($raw);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\Country;
|
||||
use app\common\model\FinPaymentApply;
|
||||
use app\common\model\FinPaymentStock;
|
||||
use app\common\model\SysAccount;
|
||||
use app\common\model\SysCurrency;
|
||||
use app\common\model\SysDictItem;
|
||||
use app\common\model\User;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\FinReceiptService;
|
||||
use support\Redis;
|
||||
use support\Request;
|
||||
|
||||
class FinReceiptController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new FinReceiptService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认入账
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function credit(Request $request)
|
||||
{
|
||||
try {
|
||||
$id = $request->input('id');
|
||||
$exchange_rate = $request->input('exchange_rate');
|
||||
if(empty($exchange_rate) || !is_numeric($exchange_rate)){
|
||||
return $this->error('请输入汇率');
|
||||
}
|
||||
$raw = $this->service->credit($id,$exchange_rate);
|
||||
return $this->success($raw);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function show(Request $request)
|
||||
{
|
||||
try {
|
||||
$raw = $this->service->serviceShow($request);
|
||||
$data = $this->transformData($raw, method_exists($this, 'showFormat')
|
||||
? [$this, 'showFormat']
|
||||
: null);
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return mixed 返回更新成功的数据或信息
|
||||
*/
|
||||
public function payment(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->validate($this->service->getValidator(), $request->post(), 'update');
|
||||
$res = $this->service->serviceUpdatePayment($request, $data);
|
||||
return $this->success([], '更新成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at'])){
|
||||
$data['claim_timeout'] = (($data['created_at'] < (time()-86400)) && empty($data['payment_apply_id'])) ?1:0;
|
||||
$data['claim_timeout_time'] = date('Y-m-d H:i:s', $data['created_at']+86400);
|
||||
$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['arrived_at']))
|
||||
$data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']);
|
||||
if (isset($data['received_at'])){
|
||||
$data['received_at'] = date('Y-m-d H:i:s', $data['received_at']);
|
||||
$voucher_no_timeout_hour = redis::get('voucher_no_timeout_hour');
|
||||
if(!empty($voucher_no_timeout_hour)){
|
||||
$data['voucher_no_timeout_time'] = date('Y-m-d H:i:s', time()+(60*60*$voucher_no_timeout_hour));
|
||||
}
|
||||
}
|
||||
if (isset($data['account_id'])) { //收款账号
|
||||
$data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??'';
|
||||
$data['account_short_desc'] = SysAccount::where('id', $data['account_id'])->value('short_desc')??'';
|
||||
}
|
||||
if (isset($data['country_id'])) //付款来源国家
|
||||
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??'';
|
||||
if (isset($data['currency_id'])) //付款币种
|
||||
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??'';
|
||||
|
||||
$OssService = new OssService();
|
||||
if (!empty($data['fx_receipt_file'])){
|
||||
$data['fx_receipt_file'] = json_decode($data['fx_receipt_file'], true);
|
||||
foreach ($data['fx_receipt_file'] as $key => $value) {
|
||||
$data['fx_receipt_file'][$key] = [
|
||||
'file_src' => $value['file_src'],
|
||||
'file_full' => $OssService->generatePrivateUrl($value['file_src']),
|
||||
'file_name' => $value['file_name'],
|
||||
];
|
||||
}
|
||||
}else{
|
||||
$data['fx_receipt_file'] = [];
|
||||
}
|
||||
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['arrived_at']))
|
||||
$data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']);
|
||||
if (isset($data['received_at']))
|
||||
$data['received_at'] = date('Y-m-d H:i:s', $data['received_at']);
|
||||
if (isset($data['account_id'])) { //收款账号
|
||||
$data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??'';
|
||||
$data['account_short_desc'] = SysAccount::where('id', $data['account_id'])->value('short_desc')??'';
|
||||
}
|
||||
if (isset($data['country_id'])) //付款来源国家
|
||||
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??'';
|
||||
if (isset($data['currency_id'])) //付款币种
|
||||
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??'';
|
||||
|
||||
$OssService = new OssService();
|
||||
if (!empty($data['fx_receipt_file'])){
|
||||
$data['fx_receipt_file'] = json_decode($data['fx_receipt_file'], true);
|
||||
foreach ($data['fx_receipt_file'] as $key => $value) {
|
||||
$data['fx_receipt_file'][$key] = [
|
||||
'file_src' => $value['file_src'],
|
||||
'file_full' => $OssService->generatePrivateUrl($value['file_src']),
|
||||
'file_name' => $value['file_name'],
|
||||
];
|
||||
}
|
||||
}else{
|
||||
$data['fx_receipt_file'] = [];
|
||||
}
|
||||
|
||||
//查询关联的付款记录
|
||||
if (!empty($data['payment_apply_id'])) {
|
||||
$paymentApply = FinPaymentApply::where('id', $data['payment_apply_id'])->first();
|
||||
if(!$paymentApply)
|
||||
return $data;
|
||||
$paymentApply = $paymentApply->toArray();
|
||||
$paymentApply['created_at'] = strtotime($paymentApply['created_at']);
|
||||
$paymentApply['updated_at'] = strtotime($paymentApply['updated_at']);
|
||||
$paymentApply = (new FinPaymentApplyController())->showFormat($paymentApply);
|
||||
$data['payment_apply'] = $paymentApply;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 收款记录统计
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function statistics(Request $request)
|
||||
{
|
||||
try {
|
||||
$raw = $this->service->statistics();
|
||||
return $this->success($raw);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\Country;
|
||||
use app\common\model\SysAccount;
|
||||
use app\common\model\SysCurrency;
|
||||
use app\common\model\User;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\FinReceiptHisService;
|
||||
use support\Request;
|
||||
|
||||
class FinReceiptHisController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new FinReceiptHisService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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['arrived_at']))
|
||||
$data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']);
|
||||
if (isset($data['received_at']))
|
||||
$data['received_at'] = date('Y-m-d H:i:s', $data['received_at']);
|
||||
if (isset($data['account_id'])) { //收款账号
|
||||
$data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??'';
|
||||
$data['account_short_desc'] = SysAccount::where('id', $data['account_id'])->value('short_desc')??'';
|
||||
}
|
||||
if (isset($data['country_id'])) //付款来源国家
|
||||
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??'';
|
||||
if (isset($data['currency_id'])) //付款币种
|
||||
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??'';
|
||||
if (!empty($data['fx_receipt_file'])){
|
||||
$data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']);
|
||||
}elseif (isset($data['fx_receipt_file'])){
|
||||
$data['fx_receipt_file_full'] = '';
|
||||
}
|
||||
|
||||
if (isset($data['created_by']))
|
||||
$data['created_by'] = User::where('id', $data['created_by'])->value('name')??'';
|
||||
if (isset($data['updated_by']))
|
||||
$data['updated_by'] = User::where('id', $data['updated_by'])->value('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']);
|
||||
if (isset($data['arrived_at']))
|
||||
$data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']);
|
||||
if (isset($data['received_at']))
|
||||
$data['received_at'] = date('Y-m-d H:i:s', $data['received_at']);
|
||||
if (isset($data['account_id'])){ //收款账号
|
||||
$data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??'';
|
||||
$data['account_short_desc'] = SysAccount::where('id', $data['account_id'])->value('short_desc')??'';
|
||||
}
|
||||
if (isset($data['country_id'])) //付款来源国家
|
||||
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??'';
|
||||
if (isset($data['currency_id'])) //付款币种
|
||||
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??'';
|
||||
if (!empty($data['fx_receipt_file'])){
|
||||
$data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']);
|
||||
}elseif (isset($data['fx_receipt_file'])){
|
||||
$data['fx_receipt_file_full'] = '';
|
||||
}
|
||||
|
||||
if (isset($data['created_by']))
|
||||
$data['created_by'] = User::where('id', $data['created_by'])->value('name')??'';
|
||||
if (isset($data['updated_by']))
|
||||
$data['updated_by'] = User::where('id', $data['updated_by'])->value('name')??'';
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionApproveService;
|
||||
|
||||
class InvRequisitionApproveController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionApproveService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionAttachmentService;
|
||||
|
||||
class InvRequisitionAttachmentController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionAttachmentService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionItemService;
|
||||
|
||||
class InvRequisitionItemController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionItemService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionItemReturnAttachmentService;
|
||||
|
||||
class InvRequisitionItemReturnAttachmentController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionItemReturnAttachmentService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\InvRequisitionItemReturnService;
|
||||
|
||||
class InvRequisitionItemReturnController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new InvRequisitionItemReturnService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,52 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\MessageNotificationsService;
|
||||
use app\common\model\MessageNotifications;
|
||||
use support\Request;
|
||||
|
||||
class MessageNotificationsController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new MessageNotificationsService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function push(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->validate($this->service->getValidator(), $request->post(), 'store');
|
||||
$res = $this->service->servicePush($request, $data);
|
||||
return $this->success($res, '推送成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\MessageUserStatusService;
|
||||
use support\Request;
|
||||
|
||||
class MessageUserStatusController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new MessageUserStatusService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['read_at']) && $data['read_at'] !== null) {
|
||||
$data['read_at'] = date('Y-m-d H:i:s', $data['read_at']);
|
||||
} else {
|
||||
$data['read_at'] = ' - ';
|
||||
}
|
||||
|
||||
if (isset($data['message']))
|
||||
$data['message']['created_at'] = date('Y-m-d H:i:s', $data['message']['created_at']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['read_at']) && $data['read_at'] !== null) {
|
||||
$data['read_at'] = date('Y-m-d H:i:s', $data['read_at']);
|
||||
} else {
|
||||
$data['read_at'] = ' - ';
|
||||
}
|
||||
|
||||
if (isset($data['message']))
|
||||
$data['message']['created_at'] = date('Y-m-d H:i:s', $data['message']['created_at']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function unReadFormat($data)
|
||||
{
|
||||
foreach ($data as &$item) {
|
||||
if (isset($item['read_at']) && $item['read_at'] !== null) {
|
||||
$item['read_at'] = date('Y-m-d H:i:s', $item['read_at']);
|
||||
} else {
|
||||
$item['read_at'] = ' - ';
|
||||
}
|
||||
|
||||
if (isset($item['message'])) {
|
||||
$item['message']['created_at'] = date('Y-m-d H:i:s', $item['message']['created_at']);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function read(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->validate($this->service->getValidator(), $request->post(), 'read');
|
||||
$this->service->serviceRead($request, $data);
|
||||
return $this->success([], '操作成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function listUnRead(Request $request)
|
||||
{
|
||||
try {
|
||||
$raw = $this->service->serviceListUnRead($request);
|
||||
$data = $this->transformData($raw, method_exists($this, 'unReadFormat')
|
||||
? [$this, 'unReadFormat']
|
||||
: null);
|
||||
$data = [
|
||||
'list' => $data,
|
||||
'counts' => count($data)
|
||||
];
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\common\utils\FeishuMessage;
|
||||
use app\inquiry\service\InquiryLogService;
|
||||
use app\common\model\CrmCustomer;
|
||||
use app\common\model\InquiryLog;
|
||||
use app\common\model\User;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
class NotifyController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不用头部数据
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedHeaderData = ['feishuCallback', 'feishuEvent'];
|
||||
|
||||
/**
|
||||
* 不登录不鉴权
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedLogin = ['feishuCallback', 'feishuEvent'];
|
||||
|
||||
/**
|
||||
* 飞书回调
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function feishuCallback(Request $request)
|
||||
{
|
||||
try {
|
||||
$param = $request->post();
|
||||
|
||||
// 解析数据
|
||||
// $param = json_decode($param['event'], true);
|
||||
$orderSn = $param['event']['action']['value'];
|
||||
if (strpos($orderSn, '"') !== false) {
|
||||
$orderSn = str_replace('"', '', $orderSn);
|
||||
}
|
||||
|
||||
// 处理询单&客户线索信息
|
||||
$openId = $param['event']['operator']['open_id'];
|
||||
|
||||
// 获取询单
|
||||
$order = InquiryLog::with(['channelInfo', 'countryInfo', 'enter'])->where('order_no', $orderSn)->first();
|
||||
if (!$order) {
|
||||
return $this->error('未找到询单记录');
|
||||
}
|
||||
|
||||
// 获取客户xians
|
||||
$customer = CrmCustomer::where('sn', $orderSn)->first();
|
||||
if (!$customer) {
|
||||
return $this->error('未找到客户线索');
|
||||
}
|
||||
|
||||
// 获取用户
|
||||
$uinfo = User::where('open_id', $openId)->first();
|
||||
|
||||
// 更新客户线索
|
||||
$customer->user_id = $uinfo->id;
|
||||
|
||||
// 更新询单数据
|
||||
$order->recipient = $uinfo->id;
|
||||
$order->status = 2;
|
||||
$order->t_time = time();
|
||||
|
||||
// 保存
|
||||
if (!$order->save() || !$customer->save()) {
|
||||
return $this->error('跟踪失败');
|
||||
}
|
||||
|
||||
// 获取飞书消息模板
|
||||
$feishuMessage = new FeishuMessage();
|
||||
$content = $feishuMessage->groupUpdateTemplates(
|
||||
(new InquiryLogService())->qualityName($order->quality),
|
||||
$order->order_no,
|
||||
$order->channelInfo ? $order->channelInfo->name : '',
|
||||
$order->countryInfo ? $order->countryInfo->cn_addr : '',
|
||||
$order->enter ? $order->enter->name : '',
|
||||
$order->r_time ? date('Y-m-d H:i:s', $order->r_time) : '',
|
||||
$order->t_time ? date('Y-m-d H:i:s', $order->t_time) : ''
|
||||
);
|
||||
|
||||
// 组装飞书消息模板
|
||||
$data = '{
|
||||
"toast": {
|
||||
"type": "success",
|
||||
"content": "操作成功"
|
||||
},
|
||||
"card": {
|
||||
"type": "raw",
|
||||
"data": '.$content.'
|
||||
}
|
||||
}';
|
||||
|
||||
// 响应消息
|
||||
return new Response(200, ['Content-Type' => 'application/json'], $data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function error($msg = '')
|
||||
{
|
||||
$data = '{
|
||||
"toast": {
|
||||
"type": "error",
|
||||
"content": "'.$msg.'"
|
||||
}
|
||||
}';
|
||||
return new Response(200, ['Content-Type' => 'application/json'], $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞书事件
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function feishuEvent(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
|
||||
var_dump($data);
|
||||
|
||||
return json($data);
|
||||
} catch (\Throwable $e) {
|
||||
return json($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
use app\common\service\SystemsService;
|
||||
use app\common\service\UserService;
|
||||
use support\Cache;
|
||||
use app\common\service\PermService;
|
||||
use app\common\service\UserGroupService;
|
||||
|
||||
class PresetController extends BaseController
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['corps', 'feishuApp', 'systems'];
|
||||
|
||||
protected $noNeedHeaderData = ['corps', 'feishuApp', 'systems'];
|
||||
|
||||
public function corps()
|
||||
{
|
||||
try {
|
||||
$result = (new CorpService())->getList();
|
||||
return $this->success($result, '获取公司列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function feishuApp(Request $request)
|
||||
{
|
||||
try {
|
||||
$corpId = $request->get('corp_id');
|
||||
$systemId = $request->get('system_id');
|
||||
$result = (new CorpFeishuAppService())->getFeishuApp($corpId, $systemId);
|
||||
return $this->success($result, '获取飞书应用信息');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function systems()
|
||||
{
|
||||
try {
|
||||
$result = (new SystemsService())->getList();
|
||||
return $this->success($result, '获取系统列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function users(Request $request)
|
||||
{
|
||||
try {
|
||||
$result = (new UserService())->getList($request);
|
||||
return $this->success($result, '获取用户列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function roles()
|
||||
{
|
||||
try {
|
||||
$result = (new RoleService)->getList();
|
||||
return $this->success($result, '获取角色列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
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(Request $request)
|
||||
{
|
||||
try {
|
||||
$params = $request->all();
|
||||
$result = (new SysPortService)->getList($params);
|
||||
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()
|
||||
{
|
||||
try {
|
||||
Cache::clear();
|
||||
return $this->success([], '操作成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function menus(Request $request)
|
||||
{
|
||||
try {
|
||||
$uid = $request->user->uid;
|
||||
$systemCode = $request->system_code;
|
||||
$permService = new PermService();
|
||||
$menuTree = $permService->getMenuTree($uid, $systemCode);
|
||||
$permissionCodes = $permService->getPermissionCodes($uid, $systemCode);
|
||||
$result = [
|
||||
'menu' => $menuTree,
|
||||
'permissions' => $permissionCodes
|
||||
];
|
||||
return $this->success($result, '获取菜单权限');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function userGroup(Request $request)
|
||||
{
|
||||
try {
|
||||
$result = (new UserGroupService)->userGroup($request);
|
||||
return $this->success($result, '获取分组');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function userGroupScene(Request $request)
|
||||
{
|
||||
try {
|
||||
$result = (new UserGroupService)->userGroupScene($request);
|
||||
return $this->success($result, '获取分组场景');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\PurchaseOrderItemsService;
|
||||
|
||||
class PurchaseOrderItemsController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new PurchaseOrderItemsService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,137 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\PurchaseOrdersService;
|
||||
use support\Request;
|
||||
|
||||
class PurchaseOrdersController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new PurchaseOrdersService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['records']) && count($data['records']) > 0) {
|
||||
foreach ($data['records'] as &$record) {
|
||||
$contractFile = $record['contract_file'] ? explode(',', $record['contract_file']) : [];
|
||||
$contractFileUrl = [];
|
||||
if (count($contractFile) > 0) {
|
||||
foreach ($contractFile as $file) {
|
||||
$contractFileUrl[] = (new \app\common\service\OssService)->generatePrivateUrl($file);
|
||||
}
|
||||
}
|
||||
$result = [
|
||||
'id' => $record['id'],
|
||||
'order_no' => $record['order_no'],
|
||||
'pi_no' => $record['pi_no'],
|
||||
'buyer_id' => $record['buyer_id'],
|
||||
'buyer_name' => $record['buyer_name'],
|
||||
'contract_file' => $contractFile,
|
||||
'contract_file_url' => $contractFileUrl,
|
||||
'status' => $record['status'],
|
||||
'status_text' => array_flip(\app\common\service\SysDictService::pluckKeyValueByCode('purchase_status'))[$record['status']],
|
||||
'remark' => $record['remark'],
|
||||
'created_at' => date('Y-m-d H:i:s', $record['created_at']),
|
||||
'updated_at' => date('Y-m-d H:i:s', $record['updated_at']),
|
||||
];
|
||||
$record = $result;
|
||||
}
|
||||
unset($record);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
$contractFile = $data['contract_file'] ? explode(',', $data['contract_file']) : [];
|
||||
$contractFileUrl = [];
|
||||
if (count($contractFile) > 0) {
|
||||
foreach ($contractFile as $file) {
|
||||
$contractFileUrl[] = (new \app\common\service\OssService)->generatePrivateUrl($file);
|
||||
}
|
||||
}
|
||||
$result = [
|
||||
'id' => $data['id'],
|
||||
'order_no' => $data['order_no'],
|
||||
'pi_no' => $data['pi_no'],
|
||||
'buyer_id' => $data['buyer_id'],
|
||||
'buyer_name' => $data['buyer_name'],
|
||||
'contract_file' => $contractFile,
|
||||
'contract_file_url' => $contractFileUrl,
|
||||
'status' => $data['status'],
|
||||
'remark' => $data['remark']
|
||||
];
|
||||
$temps = [];
|
||||
if (isset($data['items']) && count($data['items']) > 0) {
|
||||
foreach ($data['items'] as $record) {
|
||||
if (!in_array($record['stockOrder']['id'], array_keys($temps))) {
|
||||
$temps[$record['stockOrder']['id']] = [
|
||||
'id' => $record['stockOrder']['id'],
|
||||
'order_no' => $record['stockOrder']['order_no'],
|
||||
'salesperson_snapshot' => $record['stockOrder']['salesperson_snapshot'],
|
||||
'biz_date' => date('Y-m-d', $record['stockOrder']['biz_date'])
|
||||
];
|
||||
}
|
||||
$temps[$record['stockOrder']['id']]['stock_order_items'][] =[
|
||||
'id' => $record['stockOrderItems']['id'],
|
||||
'model_snapshot' => $record['stockOrderItems']['model_snapshot'],
|
||||
'unique_id' => $record['stockOrderItems']['unique_id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
$result['stock_order'] = array_values($temps);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 前置查询处理
|
||||
*
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function preQueryData(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->service->preQueryData($request->all());
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重提
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function resubmit(Request $request)
|
||||
{
|
||||
try {
|
||||
$raw = $this->service->serviceResubmit($request, $request->all());
|
||||
return $this->success($raw);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\ResourceService;
|
||||
use support\Request;
|
||||
|
||||
class ResourceController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new ResourceService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function allFormat($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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源树形结构
|
||||
*/
|
||||
public function listTree(Request $request)
|
||||
{
|
||||
try {
|
||||
$raw = $this->service->serviceListAll($request);
|
||||
$data = $this->transformData($raw, method_exists($this, 'allFormat')
|
||||
? [$this, 'allFormat']
|
||||
: null);
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单
|
||||
*/
|
||||
public function menuList(Request $request)
|
||||
{
|
||||
try {
|
||||
$raw = $this->service->serviceMenuList($request);
|
||||
$data = $this->transformData($raw, method_exists($this, 'allFormat')
|
||||
? [$this, 'allFormat']
|
||||
: null);
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单
|
||||
*/
|
||||
public function menuTreeList(Request $request)
|
||||
{
|
||||
try {
|
||||
$raw = $this->service->serviceMenuTreeList($request);
|
||||
$data = $this->transformData($raw, method_exists($this, 'allFormat')
|
||||
? [$this, 'allFormat']
|
||||
: null);
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\StockOrdersFilesService;
|
||||
|
||||
class StockOrdersFilesController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new StockOrdersFilesService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\SysOpLogService;
|
||||
|
||||
class SysOpLogController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SysOpLogService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,53 @@
|
||||
<?php
|
||||
namespace app\common\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,35 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\SysUpdateLogService;
|
||||
|
||||
class SysUpdateLogController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SysUpdateLogService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['update_time']))
|
||||
$data['update_time'] = date('Y-m-d H:i:s', $data['update_time']);
|
||||
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,302 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\service\OssService;
|
||||
use app\common\service\UploadedFilesService;
|
||||
use app\common\service\UploadService;
|
||||
use app\common\traits\ResponseTrait;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
use support\exception\BusinessException;
|
||||
use Shopwwi\WebmanFilesystem\Facade\Storage;
|
||||
|
||||
class UploadController
|
||||
{
|
||||
|
||||
use ResponseTrait;
|
||||
|
||||
protected $noNeedLogin = ['proxy'];
|
||||
|
||||
protected $noNeedHeaderData = ['proxy'];
|
||||
|
||||
public function upload(Request $request)
|
||||
{
|
||||
try {
|
||||
$scene = $request->input('scene', 'image');
|
||||
$file = $request->file('file');
|
||||
if ($file && $file->isValid()) {
|
||||
$fileName = md5($file->getUploadName() . time()).'.'.$file->getUploadExtension();
|
||||
$pathUrl = '/uploads/'.$scene.'/'.date('Ymd').'/'.$fileName;
|
||||
$fullPathUrl = public_path() . $pathUrl;
|
||||
$file->move($fullPathUrl);
|
||||
|
||||
$data = [
|
||||
'domain' => getenv('MAIN_DOMAIN'),
|
||||
'file_url' => $pathUrl,
|
||||
'full_url' => getenv('MAIN_DOMAIN') . $pathUrl,
|
||||
'scene' => $scene,
|
||||
];
|
||||
|
||||
// 记录文件信息到数据库
|
||||
try {
|
||||
$uploadedFilesService = new UploadedFilesService();
|
||||
$partition = $scene;
|
||||
$category = $request->input('category', 'general');
|
||||
|
||||
$fileInfo = [
|
||||
'file_name' => basename($fileName),
|
||||
'file_path' => $pathUrl,
|
||||
'file_size' => $file->getSize(),
|
||||
'file_type' => $file->getUploadMimeType(),
|
||||
'original_name' => $file->getUploadName(),
|
||||
];
|
||||
|
||||
$recordResult = $uploadedFilesService->recordFileInfo($fileInfo, $request, $partition, $category);
|
||||
$data['file_id'] = $recordResult['id'];
|
||||
$data['partition'] = $partition;
|
||||
$data['category'] = $category;
|
||||
} catch (\Throwable $e) {
|
||||
// 记录失败不影响上传结果,只记录日志
|
||||
Log::error('记录文件信息失败: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return $this->success($data, 'upload success');
|
||||
}
|
||||
return $this->error('file not found');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 上传单文件附件
|
||||
public function uploadFile(Request $request)
|
||||
{
|
||||
try {
|
||||
$scene = $request->input('scene');
|
||||
$file = $request->file('file');
|
||||
|
||||
if (!$file || !$file->isValid()) {
|
||||
return $this->error('上传失败');
|
||||
}
|
||||
if (empty($scene)) {
|
||||
// return $this->error('上传场景不能为空');
|
||||
$sceneUrl = '';
|
||||
}else{
|
||||
$sceneUrl = $scene . '/';
|
||||
}
|
||||
$originalName = $file->getUploadName();
|
||||
|
||||
$ossservice = new OssService();
|
||||
$mimes = $ossservice->getMimeTypes(['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'zip', 'rar']);
|
||||
|
||||
$result = Storage::adapter('oss')
|
||||
->path(config('oss.oss_main_dir') . $sceneUrl . date('Ymd'))
|
||||
->size(1024*1024*5)
|
||||
->extYes($mimes)
|
||||
->upload($file);
|
||||
|
||||
|
||||
$data = [
|
||||
'original_name' => $originalName,
|
||||
'file_name' => $result->file_name,
|
||||
'file_url' => $ossservice->generatePrivateUrl($result->file_name)
|
||||
];
|
||||
|
||||
// 记录文件信息到数据库
|
||||
$category = $request->input('category', 'general');
|
||||
$res = $this->recordFileInfo($result,$request,$file,$scene,$category);
|
||||
$data = array_merge($data, $res);
|
||||
|
||||
return $this->success($data);
|
||||
}catch (\Throwable $e){
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 上传单文件图片
|
||||
public function uploadImage(Request $request)
|
||||
{
|
||||
try {
|
||||
$scene = $request->input('scene');
|
||||
$file = $request->file('image');
|
||||
|
||||
if (!$file || !$file->isValid()) {
|
||||
return $this->error('上传失败');
|
||||
}
|
||||
if (empty($scene)) {
|
||||
// return $this->error('上传场景不能为空');
|
||||
$sceneUrl = '';
|
||||
}else{
|
||||
$sceneUrl = $scene . '/';
|
||||
}
|
||||
|
||||
$result = Storage::adapter('oss')
|
||||
->path(config('oss.oss_main_dir') . $sceneUrl . date('Ymd'))
|
||||
->size(1024*1024*5)
|
||||
->extYes(['image/jpeg','image/png'])
|
||||
->extNo(['image/gif'])
|
||||
->upload($file);
|
||||
|
||||
$ossservice = new OssService();
|
||||
|
||||
$data = [
|
||||
'href' => $result->file_name,
|
||||
'alt' => '',
|
||||
'url' => $ossservice->generatePrivateUrl($result->file_name)
|
||||
];
|
||||
|
||||
// 记录文件信息到数据库
|
||||
$category = $request->input('category', 'general');
|
||||
$res = $this->recordFileInfo($result,$request,$file,$scene,$category);
|
||||
$data = array_merge($data, $res);
|
||||
|
||||
return json(['errno' => 0, 'data' => $data]);
|
||||
// return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return json(['errno' => 1, 'message' => $e->getMessage()]);
|
||||
// return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function recordFileInfo($result, $request, $file, $scene, $category)
|
||||
{
|
||||
try {
|
||||
$uploadedFilesService = new UploadedFilesService();
|
||||
$partition = $scene;
|
||||
|
||||
$fileInfo = [
|
||||
'file_name' => basename($result->file_name),
|
||||
'file_path' => $result->file_name, // OSS存储路径
|
||||
'file_size' => $file->getSize(),
|
||||
'file_type' => $file->getUploadMimeType(),
|
||||
'original_name' => $file->getUploadName(),
|
||||
];
|
||||
|
||||
$partition = !empty($partition)?$partition:'other';
|
||||
$category = !empty($category)?$category:'other';
|
||||
$recordResult = $uploadedFilesService->recordFileInfo($fileInfo, $request, $partition, $category);
|
||||
$data = [];
|
||||
$data['file_id'] = $recordResult['id'];
|
||||
$data['partition'] = $partition;
|
||||
$data['category'] = $category;
|
||||
return $data;
|
||||
} catch (\Throwable $e) {
|
||||
// 记录失败不影响上传结果,只记录日志
|
||||
Log::error('记录文件信息失败: ' . $e->getMessage());
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件信息
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getFileInfo(Request $request)
|
||||
{
|
||||
try {
|
||||
$fileId = $request->input('id');
|
||||
|
||||
if (!$fileId) {
|
||||
return $this->error('文件ID不能为空');
|
||||
}
|
||||
|
||||
$uploadedFilesService = new UploadedFilesService();
|
||||
$fileInfo = $uploadedFilesService->getFileInfo($fileId);
|
||||
|
||||
if (!$fileInfo) {
|
||||
return $this->error('文件不存在');
|
||||
}
|
||||
|
||||
return $this->success($fileInfo);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error('获取文件信息失败: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function deleteFile(Request $request)
|
||||
{
|
||||
try {
|
||||
$fileId = $request->input('id');
|
||||
$path = $request->input('path');
|
||||
|
||||
$uploadedFilesService = new UploadedFilesService();
|
||||
if(!empty($path) && empty($fileId)){
|
||||
$where = ['file_path' => $path];
|
||||
$file = $uploadedFilesService->getFile($where);
|
||||
$fileId = $file->id;
|
||||
}elseif(empty($path) && !empty($fileId)){
|
||||
$where = ['id' => $fileId];
|
||||
$file = $uploadedFilesService->getFile($where);
|
||||
$path = $file->file_path;
|
||||
}
|
||||
if (!$fileId) {
|
||||
return $this->error('文件ID与路径不能为空');
|
||||
}
|
||||
|
||||
// 删除 OSS 上的文件
|
||||
$ossService = new OssService();
|
||||
$ossService->deleteFile($path);
|
||||
|
||||
$result = $uploadedFilesService->deleteFile($fileId);
|
||||
|
||||
if ($result) {
|
||||
return $this->success([], '文件删除成功');
|
||||
} else {
|
||||
return $this->error('文件删除失败');
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error('文件删除失败: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分区配置
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getPartitionConfig(Request $request)
|
||||
{
|
||||
try {
|
||||
$uploadedFilesService = new UploadedFilesService();
|
||||
$config = $uploadedFilesService->getPartitionConfig();
|
||||
|
||||
return $this->success($config);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error('获取分区配置失败: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function proxy(Request $request)
|
||||
{
|
||||
$filePath = $request->get('file'); // 原OSS文件路径
|
||||
try {
|
||||
// 生成签名URL
|
||||
$signedUrl = (new \app\common\service\OssService())->generatePrivateUrl($filePath);
|
||||
|
||||
// 获取图片数据并返回
|
||||
$imageData = file_get_contents($signedUrl);
|
||||
|
||||
// 根据文件类型设置Content-Type
|
||||
$mime = mime_content_type('data://application/octet-stream;base64,'.base64_encode($imageData));
|
||||
|
||||
return response($imageData, 200, [
|
||||
'Content-Type' => $mime,
|
||||
'Cache-Control' => 'public, max-age=600' // 客户端缓存10分钟
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response('Image not found '.$e->getMessage(), 404);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\UsedcarCrawlResultsService;
|
||||
|
||||
class UsedcarCrawlResultsController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new UsedcarCrawlResultsService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\UsedcarCrawlResultsImagesService;
|
||||
|
||||
class UsedcarCrawlResultsImagesController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new UsedcarCrawlResultsImagesService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,128 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use support\Request;
|
||||
use app\common\service\UserService;
|
||||
|
||||
class UserController extends BaseController
|
||||
{
|
||||
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new UserService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组员列表
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return mixed 返回分页数据及总数
|
||||
*/
|
||||
public function team(Request $request)
|
||||
{
|
||||
try {
|
||||
$raw = $this->service->serviceTeam($request);
|
||||
$data = $this->transformData($raw, method_exists($this, 'indexFormat')
|
||||
? [$this, 'indexFormat']
|
||||
: null);
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记组员离职
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return mixed 返回分页数据及总数
|
||||
*/
|
||||
public function resignMember(Request $request)
|
||||
{
|
||||
try {
|
||||
$userId = $request->get('user_id');
|
||||
if(empty($userId)){
|
||||
return $this->error('组员id不能为空');
|
||||
}
|
||||
$user = $this->service->resignMember($request);
|
||||
return $this->success($user, '获取用户信息');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息(登录后调用)
|
||||
*/
|
||||
public function info(Request $request)
|
||||
{
|
||||
try {
|
||||
$uid = $request->user->uid;
|
||||
$systemCode = $request->system_code;
|
||||
$result = (new UserService())->getUserInfo($uid, $systemCode);
|
||||
return $this->success($result, '获取用户信息');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
public function getUser(Request $request)
|
||||
{
|
||||
try {
|
||||
$uid = $request->user->uid;
|
||||
$corp_abbr = $request->basic_data['corp_abbr'];
|
||||
$result = (new UserService())->getUser($uid,$corp_abbr);
|
||||
return $this->success($result, '获取用户信息');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑用户
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
try {
|
||||
$uid = $request->user->uid;
|
||||
$data = $request->all();
|
||||
$result = (new UserService())->edit($uid,$data);
|
||||
unset($result['password']);
|
||||
unset($result['union_id']);
|
||||
unset($result['open_id']);
|
||||
unset($result['tenant_key']);
|
||||
return $this->success($result, '编辑成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
* @throws \Random\RandomException
|
||||
*/
|
||||
public function savePassword(Request $request)
|
||||
{
|
||||
try {
|
||||
$uid = $request->user->uid;
|
||||
$data = $request->all();
|
||||
$result = (new UserService())->savePassword($uid,$data);;
|
||||
return $this->success($result, '编辑成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\model\User;
|
||||
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']);
|
||||
if (isset($data['created_by']) && $data['created_by'])
|
||||
$data['created_by_name'] = User::where('id', $data['created_by'])->value('name');
|
||||
if (isset($data['updated_by']) && $data['updated_by'])
|
||||
$data['updated_by_name'] = User::where('id', $data['updated_by'])->value('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']);
|
||||
if (isset($data['created_by']) && $data['created_by'])
|
||||
$data['created_by_name'] = User::where('id', $data['created_by'])->value('name');
|
||||
if (isset($data['updated_by']) && $data['updated_by'])
|
||||
$data['updated_by_name'] = User::where('id', $data['updated_by'])->value('name');
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\VehDictI18nService;
|
||||
|
||||
class VehDictI18nController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new VehDictI18nService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\VehDictMappingService;
|
||||
|
||||
class VehDictMappingController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new VehDictMappingService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,47 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
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,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\VehMoneyValueService;
|
||||
|
||||
class VehMoneyValueController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new VehMoneyValueService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\VehVehicleListingService;
|
||||
|
||||
class VehVehicleListingController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new VehVehicleListingService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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,223 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\BrandSeries;
|
||||
use app\common\service\VehModificationService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\VehVehicleSkuService;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
|
||||
class VehVehicleSkuController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new VehVehicleSkuService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
return $this->error('请优先抓取车辆信息,如抓取不到相应车型请联系管理员,暂停手动录入车辆信息');
|
||||
try {
|
||||
$data = $this->validate($this->service->getValidator(), $request->post(), 'store');
|
||||
$res = $this->service->serviceStore($request, $data);
|
||||
return $this->success($res, '创建成功');
|
||||
} catch (\PDOException $e) {
|
||||
$errorCode = $e->getCode();
|
||||
$errorMessage = $e->getMessage();
|
||||
if ($errorCode == '23000') {
|
||||
if (strpos($errorMessage, "Duplicate entry") !== false && strpos($errorMessage, "uk_fingerprint") !== false) {
|
||||
return $this->error("该车辆指纹已存在,请勿重复提交");
|
||||
}
|
||||
// 其他类型的完整性约束错误
|
||||
throw new BusinessException("数据完整性错误", 0, $e);
|
||||
}
|
||||
// 重新抛出其他类型的异常
|
||||
throw $e;
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->validate($this->service->getValidator(), $request->post(), 'update');
|
||||
$res = $this->service->serviceUpdate($request, $data);
|
||||
return $this->success([], '更新成功');
|
||||
} catch (\PDOException $e) {
|
||||
$errorCode = $e->getCode();
|
||||
$errorMessage = $e->getMessage();
|
||||
if ($errorCode == '23000') {
|
||||
if (strpos($errorMessage, "Duplicate entry") !== false && strpos($errorMessage, "uk_fingerprint") !== false) {
|
||||
return $this->error("该车辆指纹已存在,请勿重复提交");
|
||||
}
|
||||
// 其他类型的完整性约束错误
|
||||
throw new BusinessException("数据完整性错误", 0, $e);
|
||||
}
|
||||
// 重新抛出其他类型的异常
|
||||
throw $e;
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function preset(Request $request){
|
||||
|
||||
|
||||
try {
|
||||
$series_id = $request->input('series_id');
|
||||
$series_code = BrandSeries::where('id', $series_id)->value('series_code');
|
||||
$data = [
|
||||
'series_code' => $series_code,
|
||||
];
|
||||
$result = $this->service->getList($data);
|
||||
return $this->success($result, '获取车型列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function fields_desc(Request $request)
|
||||
{
|
||||
$data = [
|
||||
'sku_code' , // 'SKU编码,系统生成',
|
||||
'fingerprint' , // '规格指纹(sha256)去重',
|
||||
'brand_code' , // '品牌代码,如 BYD、HYUNDAI、KIA',
|
||||
'brand_name' , // '品牌名称展示,如 比亚迪、现代、起亚',
|
||||
'series_code' , // '车系代码,如 ELANTRA、SONGPLUS',
|
||||
'series_name' , // '车系名称展示',
|
||||
'model_code' , // '车型/配置代码(工厂/内部编码)',
|
||||
'model_name' , // '车型/配置名称(可读,如 伊兰特 1.5L、海狮07)',
|
||||
'model_year' , // '年款(YYYY)',
|
||||
'trim_code' , // '版型代码(TRIM)',
|
||||
'trim_level_code' , // '配置等级代码(TRIM_LEVEL)',
|
||||
'edition_code' , // '特别版代码(EDITION)',
|
||||
'trim' , // '版型/细分配置(如 TOP旗舰版、荣耀版)',
|
||||
'trim_level' , // '配置等级(豪华型/旗舰型等,便于筛选)',
|
||||
'edition_name' , // '特别版/纪念版(如 荣耀版、致敬版等)',
|
||||
'body_type_code' , // '车身类型:SEDAN/SUV/HB/MPV/Pickup',
|
||||
'drive_type_code' , // '驱动:FWD/RWD/AWD/4WD',
|
||||
'motor_layout_code' , // '电驱/电机布置(MOTOR_LAYOUT):FWD/RWD/AWD/DM-i/DM-p 等',
|
||||
'fuel_type_code' , // '能源:GAS/HEV/PHEV/EV/EREV',
|
||||
'engine_disp_l' , // '排量(L),如 1.5;纯电为空',
|
||||
'engine_turbo' , // '0' COMMENT '是否涡轮(0/1)',
|
||||
'engine_power_kw' , // '最大功率(kW)',
|
||||
'battery_kwh' , // '电池容量(kWh)',
|
||||
'transmission_code' , // '变速箱:MT/AT/CVT/DCT/1SPEED',
|
||||
'gears' , // '挡位数(EV多为1)',
|
||||
'range_km' , // '续航里程(km)',
|
||||
'range_std_code' , // '续航标准:CLTC/WLTP/EPA/NEDC',
|
||||
'doors' , // '门数',
|
||||
'seats' , // '座位数',
|
||||
'weight_kg' , // '整备质量(kg)',
|
||||
'dimensions_mm' , // '尺寸(mm):{length,width,height,wheelbase}',
|
||||
'color_exterior_code' , // '外观色代码',
|
||||
'color_exterior_text' , // '外观色名称',
|
||||
'color_interior_code' , // '内饰色代码',
|
||||
'color_interior_text' , // '内饰色名称',
|
||||
'options_official' , // '官方选装(结构化 JSON)',
|
||||
'features' , // '功能/安全/智能配置(结构化 JSON)',
|
||||
'emission_std_code' , // '排放标准:CHN6/EURO6/EPA',
|
||||
'origin_country' , // '原产国 ISO-3166-1 alpha-2',
|
||||
'currency' , // 'CNY' COMMENT '币种 ISO-4217',
|
||||
'msrp' , // '建议零售价/参考价',
|
||||
'is_active' , // '1' COMMENT '启用(1)/禁用(0)',
|
||||
'corp_id' , // '0' COMMENT '租户/公司(全局库可写0)',
|
||||
'remark' , // '备注',
|
||||
'created_by' , // '0',
|
||||
'updated_by' , // '0',
|
||||
];
|
||||
|
||||
|
||||
$data = [
|
||||
'fingerprint' , // '规格指纹(sha256)去重',
|
||||
'brand_name' , // '品牌名称展示,如 比亚迪、现代、起亚',
|
||||
'series_name' , // '车系名称展示',
|
||||
'model_name' , // '车型/配置名称(可读,如 伊兰特 1.5L、海狮07)',
|
||||
'model_year' , // '年款(YYYY)',
|
||||
'trim' , // '版型/细分配置(如 TOP旗舰版、荣耀版)',
|
||||
'trim_level' , // '配置等级(豪华型/旗舰型等,便于筛选)',
|
||||
'edition_name' , // '特别版/纪念版(如 荣耀版、致敬版等)',
|
||||
'engine_disp_l' , // '排量(L),如 1.5;纯电为空',
|
||||
'engine_turbo' , // '0' COMMENT '是否涡轮(0/1)',
|
||||
'engine_power_kw' , // '最大功率(kW)',
|
||||
'battery_kwh' , // '电池容量(kWh)',
|
||||
'gears' , // '挡位数(EV多为1)',
|
||||
'range_km' , // '续航里程(km)',
|
||||
'doors' , // '门数',
|
||||
'seats' , // '座位数',
|
||||
'weight_kg' , // '整备质量(kg)',
|
||||
'dimensions_mm' , // '尺寸(mm):{length,width,height,wheelbase}',
|
||||
'color_exterior_text' , // '外观色名称',
|
||||
'color_interior_text' , // '内饰色名称',
|
||||
'options_official' , // '官方选装(结构化 JSON)',
|
||||
'features' , // '功能/安全/智能配置(结构化 JSON)',
|
||||
'origin_country' , // '原产国 ISO-3166-1 alpha-2',
|
||||
'currency' , // 'CNY' COMMENT '币种 ISO-4217',
|
||||
'msrp' , // '建议零售价/参考价',
|
||||
'is_active' , // '1' COMMENT '启用(1)/禁用(0)',
|
||||
'corp_id' , // '0' COMMENT '租户/公司(全局库可写0)',
|
||||
'remark' , // '备注',
|
||||
'created_by' , // '0',
|
||||
'updated_by' , // '0',
|
||||
|
||||
'body_type', // '车身类型'
|
||||
'drive_type', // '驱动:FWD/RWD/AWD/4WD',
|
||||
'motor_layout', // '电机布置(MOTOR_LAYOUT):FWD/RWD/AWD/DM-i/DM-p 等'
|
||||
'fuel_type', // '能源:GAS/HEV/PHEV/EV/EREV'
|
||||
'transmission', // '变速箱:MT/AT/CVT/DCT/1SPEED'
|
||||
'range_std', // '续航标准:CLTC/WLTP/EPA/NEDC'
|
||||
'emission_std', // '排放标准:CHN6/EURO6/EPA'
|
||||
|
||||
'sku_code' , // 'SKU编码,系统生成',
|
||||
'brand_code' , // '品牌代码,如 BYD、HYUNDAI、KIA',
|
||||
'series_code' , // '车系代码,如 ELANTRA、SONGPLUS',
|
||||
'model_code' , // '车型/配置代码(工厂/内部编码)',
|
||||
'trim_code' , // '版型代码(TRIM)',
|
||||
'trim_level_code' , // '配置等级代码(TRIM_LEVEL)',
|
||||
'edition_code' , // '特别版代码(EDITION)',
|
||||
'color_exterior_code' , // '外观色代码',
|
||||
'color_interior_code' , // '内饰色代码',
|
||||
|
||||
'body_type_code' , // '车身类型:SEDAN/SUV/HB/MPV/Pickup',
|
||||
'drive_type_code' , // '驱动:FWD/RWD/AWD/4WD',
|
||||
'motor_layout_code' , // '电驱/电机布置(MOTOR_LAYOUT):FWD/RWD/AWD/DM-i/DM-p 等',
|
||||
'fuel_type_code' , // '能源:GAS/HEV/PHEV/EV/EREV',
|
||||
'transmission_code' , // '变速箱:MT/AT/CVT/DCT/1SPEED',
|
||||
'range_std_code' , // '续航标准:CLTC/WLTP/EPA/NEDC',
|
||||
'emission_std_code' , // '排放标准:CHN6/EURO6/EPA',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\VehVehicleUnitService;
|
||||
|
||||
class VehVehicleUnitController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new VehVehicleUnitService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @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;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user