This commit is contained in:
weiz 2024-03-14 15:34:33 +08:00
parent 3aed792886
commit f4a553e78e
24 changed files with 245 additions and 570 deletions

View File

@ -123,6 +123,11 @@ class ContractController extends BaseAdminController
}
return $this->fail(ContractLogic::getError());
}
public function datas()
{
return $this->data(ContractLogic::datas());
}
}

View File

@ -1,21 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\custom;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\custom\CustomContactsLists;
use app\adminapi\logic\custom\CustomContactsLogic;

View File

@ -1,21 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\custom;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\custom\CustomLists;
use app\adminapi\logic\custom\CustomLogic;
@ -86,8 +71,11 @@ class CustomController extends BaseAdminController
public function delete()
{
$params = (new CustomValidate())->post()->goCheck('delete');
CustomLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = CustomLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(CustomLogic::getError());
}
@ -103,6 +91,11 @@ class CustomController extends BaseAdminController
$result = CustomLogic::detail($params);
return $this->data($result);
}
public function datas()
{
return $this->data(CustomLogic::datas());
}
}

View File

@ -1,21 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\custom;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\custom\CustomFollowLists;
use app\adminapi\logic\custom\CustomFollowLogic;

View File

@ -1,21 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\custom;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\custom\CustomServiceLists;
use app\adminapi\logic\custom\CustomServiceLogic;
@ -58,20 +43,36 @@ class CustomServiceController extends BaseAdminController
}
return $this->fail(CustomServiceLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/12 14:00
*/
public function edit(): \think\response\Json
{
$params = (new CustomServiceValidate())->post()->goCheck('edit');
$result = CustomServiceLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(CustomServiceLogic::getError());
}
/**
* @notes 编辑
* @notes 处理
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/12 14:00
*/
public function solve(): \think\response\Json
{
$params = (new CustomServiceValidate())->post()->goCheck('edit');
$result = CustomServiceLogic::edit($params);
$params = (new CustomServiceValidate())->post()->goCheck('check');
$result = CustomServiceLogic::check($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
return $this->success('处理成功', [], 1, 1);
}
return $this->fail(CustomServiceLogic::getError());
}

View File

@ -143,5 +143,10 @@ class ProjectController extends BaseAdminController
];
return $this->success('请求成功',$result);
}
public function datas()
{
return $this->data(ProjectLogic::datas());
}
}

View File

@ -1,17 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\custom;
@ -59,13 +46,7 @@ class CustomContactsLists extends BaseAdminDataLists implements ListsSearchInter
*/
public function lists(): array
{
$params = $this->request->get(['custom_name']);
$where = [];
if(isset($params['custom_name']) && $params['custom_name'] != ''){
$custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id');
$where[] = ['custom_id','in',$custom_ids];
}
return CustomContacts::field('id,custom_id,name,position,phone,telephone,email,notes,annex')->where($this->searchWhere)->where($where)
return CustomContacts::field('id,custom_id,name,position,phone,telephone,email,notes')->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
@ -90,13 +71,7 @@ class CustomContactsLists extends BaseAdminDataLists implements ListsSearchInter
*/
public function count(): int
{
$params = $this->request->get(['custom_name']);
$where = [];
if(isset($params['custom_name']) && $params['custom_name'] != ''){
$custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id');
$where[] = ['custom_id','in',$custom_ids];
}
return CustomContacts::where($this->searchWhere)->where($where)->count();
return CustomContacts::where($this->searchWhere)->count();
}
/**

View File

@ -1,24 +1,9 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\custom;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsExcelInterface;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
use app\common\model\custom\Custom;
use app\common\model\custom\CustomFollow;
@ -58,28 +43,15 @@ class CustomFollowLists extends BaseAdminDataLists implements ListsSearchInterfa
*/
public function lists(): array
{
$params = $this->request->get(['custom_name','contacts']);
$where = [];
if(isset($params['custom_name']) && $params['custom_name'] != ''){
$custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id');
$where[] = ['custom_id','in',$custom_ids];
}
if(isset($params['contacts']) && $params['contacts'] != ''){
$custom_ids = Custom::where('custom_name','like','%'.$params['contacts'].'%')->column('id');
$where[] = ['custom_id','in',$custom_ids];
}
return CustomFollow::field('id,custom_id,name,date,types,executor,description,annex,coordinate,next_follow_date,add_user,update_user,create_time,update_time')
->where($this->searchWhere)->where($where)
return CustomFollow::field('id,custom_id,name,date,types,executor,description,annex,coordinate,next_follow_date')
->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
$item['types_text'] = $item->types_text;
$custom = Custom::field('name,master_name')->where('id',$item['custom_id'])->findOrEmpty();
$admin = Admin::where('id','in',[$item['add_user'],$item['update_user']])->column('name','id');
$item['custom_name'] = $custom['name'];
$item['custom_master_name'] = $custom['master_name'];
$item['add_user'] = $admin[$item['add_user']];
$item['update_user'] = $admin[$item['update_user']];
return $item;
})
->toArray();
@ -94,17 +66,7 @@ class CustomFollowLists extends BaseAdminDataLists implements ListsSearchInterfa
*/
public function count(): int
{
$params = $this->request->get(['custom_name','contacts']);
$where = [];
if(isset($params['custom_name']) && $params['custom_name'] != ''){
$custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id');
$where[] = ['custom_id','in',$custom_ids];
}
if(isset($params['contacts']) && $params['contacts'] != ''){
$custom_ids = Custom::where('custom_name','like','%'.$params['contacts'].'%')->column('id');
$where[] = ['custom_id','in',$custom_ids];
}
return CustomFollow::where($this->searchWhere)->where($where)->count();
return CustomFollow::where($this->searchWhere)->count();
}

View File

@ -1,27 +1,12 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\custom;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsExcelInterface;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
use app\common\model\custom\Custom;
use app\common\model\custom\CustomFollow;
use app\common\model\GeoArea;
use app\common\model\GeoCity;
use app\common\model\GeoProvince;
@ -60,25 +45,22 @@ class CustomLists extends BaseAdminDataLists implements ListsSearchInterface,Lis
*/
public function lists(): array
{
return Custom::field('id,name,custom_type,province,city,area,notes,master_name,master_position,master_telephone,master_phone,master_notes,add_user,create_time')
return Custom::field('id,name,custom_type,province,notes,master_name,master_position,master_telephone,master_phone,master_notes,add_user,create_time')
->where($this->searchWhere)->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
$item['custom_type_text'] = $item->custom_type_text;
$admin = Admin::field('id,name')->where('id',$item['add_user'])->findOrEmpty();
$province = GeoProvince::field('province_name')->where('province_code',$item['province'])->findOrEmpty();
$city = GeoCity::field('city_name')->where('city_code',$item['city'])->findOrEmpty();
$area = GeoArea::field('area_name')->where('area_code',$item['area'])->findOrEmpty();
$customFollow = CustomFollow::field('date,next_follow_date')->where('custom_id', $item['id'])->order('id', 'desc')->limit(1)->findOrEmpty();
$item['next_follow_date'] = $customFollow['next_follow_date'];
$item['last_follow_date'] = $customFollow['date'];
$item['follow_total'] = CustomFollow::where('custom_id', $item['id'])->count();
$item['add_user_name'] = $admin['name'];
$item['province_name'] = $province['province_name'];
$item['city_name'] = $city['city_name'];
$item['area_name'] = $area['area_name'];
unset($item['province'],$item['city'],$item['area'],$item['add_user']);
return $item;
->select()->each(function($data){
$admin = Admin::field('id,name')->where('id',$data['add_user'])->findOrEmpty();
$province = GeoProvince::field('province_name')->where('province_code',$data['province'])->findOrEmpty();
$city = GeoCity::field('city_name')->where('city_code',$data['city'])->findOrEmpty();
$customFollow = CustomFollow::field('date,next_follow_date')->where('custom_id', $data['id'])->order('id', 'desc')->limit(1)->findOrEmpty();
$data['next_follow_date'] = $customFollow['next_follow_date'];
$data['last_follow_date'] = $customFollow['date'];
$data['follow_total'] = CustomFollow::where('custom_id', $data['id'])->count();
$data['add_user_name'] = $admin['name'];
$data['province_name'] = $province['province_name'];
$data['city_name'] = $city['city_name'];
$data['custom_type_text'] = $data->custom_type_text;
unset($data['province'],$data['add_user']);
})
->toArray();
}

View File

@ -1,20 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\custom;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsExcelInterface;
use app\common\lists\ListsSearchInterface;
@ -42,7 +28,7 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf
public function setSearch(): array
{
return [
'=' => ['project_id', 'classification', 'urgency', 'processing_result', 'processed_user'],
'=' => ['project_id', 'contract_id', 'classification', 'urgency', 'processing_result', 'processed_user'],
'%like%' => ['custom_service_code','name','receiver']
];
}
@ -59,44 +45,31 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf
*/
public function lists(): array
{
$params = $this->request->get(['custom_id','project_code','custom_name','contract_code']);
$params = $this->request->get(['custom_name']);
$where = [];
if(isset($params['custom_id']) && $params['custom_id'] != ''){
$project_ids = Project::where('custom_id',$params['custom_id'])->column('id');
$where[] = ['project_id','in',$project_ids];
}
if(isset($params['project_code']) && $params['project_code'] != ''){
$project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
$where[] = ['project_id','in',$project_ids];
}
if(isset($params['custom_name']) && $params['custom_name'] != ''){
$custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id');
$project_ids = Project::where('custom_id','in',$custom_ids)->column('id');
$where[] = ['project_id','in',$project_ids];
}
if(isset($params['contract_code']) && $params['contract_code'] != ''){
$contract_ids = Contract::where('contract_code','like','%'.$params['contract_code'].'%')->column('id');
$where[] = ['contract_id','in',$contract_ids];
}
return CustomService::field('id,custom_service_code,project_id,contract_id,name,receiver,date,classification,processing_result,urgency,processed_user,is_solve,done_date,score')
->where($this->searchWhere)->where($where)->limit($this->limitOffset, $this->limitLength)->order(['id' => 'desc'])
->select()->each(function($item){
$item['classification'] = $item->classification_text;
$item['processing_result'] = $item->processing_result_text;
$item['urgency'] = $item->urgency_text;
$item['is_solve_text'] = $item->is_solve_text;
$project = Project::field('custom_id,name,project_code')->where('id',$item['project_id'])->findOrEmpty();
$custom = Custom::field('name,master_name,master_phone')->where('id',$project['custom_id'])->findOrEmpty();
$contract = Contract::field('contract_code')->where('id',$item['contract_id'])->findOrEmpty();
$admin = Admin::field('name')->where('id',$item['processed_user'])->findOrEmpty();
$item['project_name'] = $project['name'];
$item['project_code'] = $project['project_code'];
$item['custom_name'] = $custom['name'];
$item['custom_master_name'] = $custom['master_name'];
$item['custom_master_phone'] = $custom['master_phone'];
$item['contract_code'] = $contract['contract_code'];
$item['processed_user'] = $admin['name'];
return $item;
->select()->each(function($data){
$project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
$custom = Custom::field('name,master_name,master_phone')->where('id',$project['custom_id'])->findOrEmpty();
$contract = Contract::field('contract_code')->where('id',$data['contract_id'])->findOrEmpty();
$admin = Admin::field('name')->where('id',$data['processed_user'])->findOrEmpty();
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$data['custom_name'] = $custom['name'];
$data['custom_master_name'] = $custom['master_name'];
$data['custom_master_phone'] = $custom['master_phone'];
$data['contract_code'] = $contract['contract_code'];
$data['processed_user'] = $admin['name'];
$data['classification'] = $data->classification_text;
$data['processing_result'] = $data->processing_result_text;
$data['urgency'] = $data->urgency_text;
$data['is_solve_text'] = $data->is_solve_text;
})
->toArray();
}
@ -109,25 +82,13 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf
*/
public function count(): int
{
$params = $this->request->get(['custom_id','project_code','custom_name','contract_code']);
$params = $this->request->get(['custom_name']);
$where = [];
if(isset($params['custom_id']) && $params['custom_id'] != ''){
$project_ids = Project::where('custom_id',$params['custom_id'])->column('id');
$where[] = ['project_id','in',$project_ids];
}
if(isset($params['project_code']) && $params['project_code'] != ''){
$project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
$where[] = ['project_id','in',$project_ids];
}
if(isset($params['custom_name']) && $params['custom_name'] != ''){
$custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id');
$project_ids = Project::where('custom_id','in',$custom_ids)->column('id');
$where[] = ['project_id','in',$project_ids];
}
if(isset($params['contract_code']) && $params['contract_code'] != ''){
$contract_ids = Contract::where('contract_code','like','%'.$params['contract_code'].'%')->column('id');
$where[] = ['contract_id','in',$contract_ids];
}
return CustomService::where($this->searchWhere)->where($where)->count();
}

View File

@ -260,4 +260,11 @@ class ContractLogic extends BaseLogic
return false;
}
}
public static function datas()
{
return Contract::field(['id','contract_name'])->order(['id' => 'desc'])->select()->each(function($data){
$data['projectinfo'] = 'ID' . $data['id'] . ' / 名称:' . $data['contract_name'];
})->toArray();
}
}

View File

@ -1,20 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\custom;
use app\common\model\custom\Custom;
use app\common\model\custom\CustomContacts;
use app\common\logic\BaseLogic;

View File

@ -1,20 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\custom;
use app\common\logic\BaseLogic;
use app\common\model\custom\Custom;
use app\common\model\custom\CustomFollow;
@ -44,13 +30,13 @@ class CustomFollowLogic extends BaseLogic
CustomFollow::create([
'custom_id' => $params['custom_id'],
'name' => $params['name'],
'date' => strtotime($params['date']),
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
'types' => $params['types'],
'description' => $params['description'] ?? '',
'annex' => $params['annex'] ?? null,
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'coordinate' => $params['coordinate'] ?? '',
'executor' => $params['executor'] ?? '',
'next_follow_date' => strtotime($params['next_follow_date']),
'next_follow_date' => !empty($params['next_follow_date']) ? strtotime($params['next_follow_date']) : 0,
'add_user' => $admin_id,
'update_user' => $admin_id
]);
@ -78,13 +64,13 @@ class CustomFollowLogic extends BaseLogic
CustomFollow::where('id', $params['id'])->update([
'custom_id' => $params['custom_id'],
'name' => $params['name'],
'date' => strtotime($params['date']),
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
'types' => $params['types'],
'description' => $params['description'] ?? '',
'annex' => $params['annex']? json_encode($params['annex']) : null,
'coordinate' => $params['coordinate'] ?? '',
'executor' => $params['executor'] ?? '',
'next_follow_date' => strtotime($params['next_follow_date']),
'next_follow_date' => !empty($params['next_follow_date']) ? strtotime($params['next_follow_date']) : 0,
'update_user' => $admin_id,
'update_time' => time()
]);

View File

@ -1,27 +1,15 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\custom;
use app\common\model\custom\Custom;
use app\common\logic\BaseLogic;
use app\common\model\custom\CustomContacts;
use app\common\model\custom\CustomFollow;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
use app\common\model\GeoArea;
use app\common\model\GeoCity;
use app\common\model\GeoProvince;
use app\common\model\project\Project;
use think\facade\Db;
@ -45,8 +33,7 @@ class CustomLogic extends BaseLogic
{
Db::startTrans();
try {
$other_contacts = $params['other_contacts'];
$customRes = Custom::create([
$res = Custom::create([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'name' => $params['name'],
@ -72,10 +59,10 @@ class CustomLogic extends BaseLogic
'bank_account' => $params['bank_account'] ?? '',
'add_user' => $admin_id,
]);
if(!empty($other_contacts)){
foreach($other_contacts as $v){
if(!empty($params['other_contacts'])){
foreach($params['other_contacts'] as $v){
CustomContacts::create([
'custom_id' => $customRes->id,
'custom_id' => $res->id,
'name' => $v['name'],
'position' => $v['position'] ?? '',
'phone' => $v['phone'] ?? '',
@ -152,20 +139,17 @@ class CustomLogic extends BaseLogic
*/
public static function delete(array $params): bool
{
Db::startTrans();
try {
$custom_contacts_ids = CustomContacts::where('custom_id',$params['id'])->column('id');
$custom_follow_ids = CustomFollow::where('custom_id',$params['id'])->column('id');
Custom::destroy($params['id']);
CustomContacts::destroy($custom_contacts_ids);
CustomFollow::destroy($custom_follow_ids);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
$contact = CustomContacts::where('custom_id','in',$params['id'])->findOrEmpty();
if(!$contact->isEmpty()){
self::setError('此数据关联了联系人信息,需删除联系人信息');
return false;
}
$project = Project::where('custom_id','in',$params['id'])->findOrEmpty();
if(!$project->isEmpty()){
self::setError('此数据关联了项目信息,需删除项目信息');
return false;
}
return Custom::destroy($params['id']);
}
@ -178,18 +162,27 @@ class CustomLogic extends BaseLogic
*/
public static function detail($params): array
{
$custom = Custom::findOrEmpty($params['id']);
$custom['org_name'] = $custom->org->name;
$custom['dept_name'] = $custom->dept->name;
$custom['custom_type_text'] = $custom->custom_type_text;
$custom['credit_rating_text'] = $custom->credit_rating_text;
$province = GeoProvince::field('province_name')->where('province_code',$custom['province'])->findOrEmpty();
$city = GeoCity::field('city_name')->where('city_code',$custom['city'])->findOrEmpty();
$area = GeoArea::field('area_name')->where('area_code',$custom['area'])->findOrEmpty();
$custom['province_name'] = $province['province_name'];
$custom['city_name'] = $city['city_name'];
$custom['area_name'] = $area['area_name'];
unset($custom['org'],$custom['dept']);
return $custom->toArray();
$data = Custom::findOrEmpty($params['id']);
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
$province = GeoProvince::field('province_name')->where('province_code',$data['province'])->findOrEmpty();
$city = GeoCity::field('city_name')->where('city_code',$data['city'])->findOrEmpty();
$area = GeoArea::field('area_name')->where('area_code',$data['area'])->findOrEmpty();
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
$data['province_name'] = $province['province_name'];
$data['city_name'] = $city['city_name'];
$data['area_name'] = $area['area_name'];
$data['custom_type_text'] = $data->custom_type_text;
$data['credit_rating_text'] = $data->credit_rating_text;
unset($data['org'],$data['dept']);
return $data->toArray();
}
public static function datas()
{
return Custom::field(['id','name'])->order(['id' => 'desc'])->select()->each(function($data){
$data['projectinfo'] = 'ID' . $data['id'] . ' / 名称:' . $data['name'];
})->toArray();
}
}

View File

@ -1,20 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\custom;
use app\common\logic\BaseLogic;
use app\common\model\auth\Admin;
use app\common\model\contract\Contract;
@ -48,7 +34,7 @@ class CustomServiceLogic extends BaseLogic
'custom_service_code' => data_unique_code('售后工单'),
'project_id' => $params['project_id'],
'contract_id' => $params['contract_id'],
'date' => strtotime($params['date']),
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
'classification' => $params['classification'],
'urgency' => $params['urgency'],
'receiver' => $params['receiver'],
@ -66,16 +52,50 @@ class CustomServiceLogic extends BaseLogic
return false;
}
}
/**
* @notes 编辑
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/12 14:00
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
CustomService::where('id',$params['id'])->update([
'project_id' => $params['project_id'],
'contract_id' => $params['contract_id'],
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
'classification' => $params['classification'],
'urgency' => $params['urgency'],
'receiver' => $params['receiver'],
'processed_user' => $params['processed_user'],
'name' => $params['name'],
'description' => $params['description'] ?? '',
'notes' => $params['notes'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'update_time' => time(),
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑
* @notes 处理
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/12 14:00
*/
public static function edit(array $params): bool
public static function check(array $params): bool
{
Db::startTrans();
try {
@ -83,7 +103,7 @@ class CustomServiceLogic extends BaseLogic
'processing_result' => $params['processing_result'],
'processing_process' => $params['processing_process'] ?? '',
'processing_hours' => $params['processing_hours'],
'done_date' => strtotime($params['done_date']),
'done_date' => !empty($params['done_date']) ? strtotime($params['done_date']) : 0,
'score' => $params['score'],
'is_solve' => $params['is_solve'],
'feedback' => $params['feedback'] ?? '',

View File

@ -188,4 +188,11 @@ class ProjectLogic extends BaseLogic
$data['unit_nature_text'] = $data->unit_nature_text;
return $data->toArray();
}
public static function datas()
{
return Project::field(['id','name'])->order(['id' => 'desc'])->select()->each(function($data){
$data['projectinfo'] = 'ID' . $data['id'] . ' / 名称:' . $data['name'];
})->toArray();
}
}

View File

@ -1,20 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\custom;
use app\common\model\custom\Custom;
use app\common\model\custom\CustomContacts;
use app\common\validate\BaseValidate;
@ -41,16 +27,14 @@ class CustomContactsValidate extends BaseValidate
'annex' => 'checkAnnex',
];
protected $message = [
'id.require' => '缺少必要参数',
'custom_id.require' => '请选择客户',
'name.require' => '请填写姓名',
'phone.mobile' => '手机号码格式错误',
'phone.unique' => '手机号码已存在',
'email.email' => '邮箱格式错误',
protected $field = [
'id' => '数据id',
'custom_id' => '客户id',
'name' => '姓名',
'phone' => '手机',
'email' => '邮箱',
];
/**
* @notes 添加场景
* @return CustomContactsValidate
@ -100,17 +84,7 @@ class CustomContactsValidate extends BaseValidate
{
$custom = Custom::where('id',$value)->findOrEmpty();
if($custom->isEmpty()){
return '客户不存在';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
if(!is_array($value)){
return '附件格式错误';
}
return '客户信息不存在';
}
return true;
}

View File

@ -1,20 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\custom;
use app\common\model\custom\Custom;
use app\common\model\dict\DictData;
use app\common\validate\BaseValidate;
@ -42,14 +28,13 @@ class CustomFollowValidate extends BaseValidate
'annex' => 'checkAnnex',
];
protected $message = [
'id.require' => '缺少必要参数',
'name.require' => '请填写主题',
'custom_id.require' => '请选择客户',
'date.require' => '请选择日期',
'date.dateFormat' => '日期格式错误',
'types.require' => '请选择类型',
'next_follow_date.dateFormat' => '下次回访日期格式错误',
protected $field = [
'id' => '数据id',
'name' => '主题',
'custom_id' => '客户id',
'date' => '日期',
'types' => '类型',
'next_follow_date' => '下次回访日期',
];
/**
@ -101,7 +86,7 @@ class CustomFollowValidate extends BaseValidate
{
$custom = Custom::where('id',$value)->findOrEmpty();
if($custom->isEmpty()){
return '客户不存在';
return '客户信息不存在';
}
return true;
}
@ -115,16 +100,6 @@ class CustomFollowValidate extends BaseValidate
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
if(!is_array($value)){
return '附件格式错误';
}
}
return true;
}
public function checkNext($value,$rule,$data): bool|string
{
if(!empty($value)){

View File

@ -1,20 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\custom;
use app\common\model\auth\Admin;
use app\common\model\contract\Contract;
use app\common\model\dict\DictData;
@ -52,29 +38,21 @@ class CustomServiceValidate extends BaseValidate
'is_solve' => 'require|in:0,1',
];
protected $message = [
'id.require' => '缺少必要参数',
'project_id.require' => '请选择项目',
'contract_id.require' => '请选择项目合同',
'date.require' => '请选择日期',
'date.dateFormat' => '日期格式错误',
'classification.require' => '请选择分类',
'urgency.require' => '请选择紧急程度',
'receiver.require' => '请填写接待人',
'processed_user.require' => '请选择指定处理人',
'name.require' => '请填写投诉主题',
'annex' => 'checkAnnex',
'processing_result.require' => '请填写处理结果',
'processing_hours.require' => '请填写花费工时',
'processing_hours.float' => '花费工时值必须是数字',
'processing_hours.egt' => '花费工时值必须大于等于0',
'done_date.require' => '请选择完成日期',
'done_date.dateFormat' => '完成日期格式错误',
'score.require' => '请填写评分',
'score.integer' => '评分值必须是整数',
'score.egt' => '评分值必须大于等于0',
'is_solve.require' => '请选择问题是否解决',
'is_solve.in' => '问题是否解决选项值错误',
protected $field = [
'id' => '数据id',
'project_id' => '项目id',
'contract_id' => '合同id',
'date' => '日期',
'classification' => '分类',
'urgency' => '紧急程度',
'receiver' => '接待人',
'processed_user' => '指定处理人',
'name' => '投诉主题',
'processing_result' => '处理结果',
'processing_hours' => '花费工时',
'done_date' => '完成日期',
'score' => '客户评分',
'is_solve' => '是否解决',
];
@ -92,15 +70,29 @@ class CustomServiceValidate extends BaseValidate
->remove('done_date',true)
->remove('score',true)->remove('is_solve',true);
}
/**
* @notes 编辑场景
* @return CustomServiceValidate
* @author likeadmin
* @date 2023/11/12 14:00
*/
public function sceneEdit()
{
return $this->remove('processing_result',true)
->remove('processing_hours',true)
->remove('done_date',true)
->remove('score',true)->remove('is_solve',true);
}
/**
* @notes 编辑场景
* @notes 处理场景
* @return CustomServiceValidate
* @author likeadmin
* @date 2023/11/12 14:00
*/
public function sceneEdit()
public function sceneCheck()
{
return $this->only(['id','processing_result','processing_hours','done_date','score','is_solve']);
}
@ -138,15 +130,12 @@ class CustomServiceValidate extends BaseValidate
return true;
}
public function checkContract($value,$rule,$data): bool|string
public function checkContract($value,$rule,$params): bool|string
{
$contract = Contract::where('id',$value)->findOrEmpty();
$contract = Contract::where('id',$value)->where('project_id',$params['project_id'])->findOrEmpty();
if($contract->isEmpty()){
return '项目合同不存在';
}
if($contract['project_id'] != $data['project_id']){
return '该合同不属于选择的项目';
}
return true;
}
@ -177,19 +166,9 @@ class CustomServiceValidate extends BaseValidate
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
if(!is_array($value)){
return '附件格式错误';
}
}
return true;
}
public function checkProRes($value): bool|string
{
$dictData = DictData::where('type_value','custom_service_solv_result')->column('value');
$dictData = DictData::where('type_value','custom_service_solve_result')->column('value');
if(!in_array($value,$dictData)){
return '处理结果无效';
}

View File

@ -1,17 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\custom;
use app\common\model\custom\Custom;
@ -46,23 +33,20 @@ class CustomValidate extends BaseValidate
'master_email' => 'email',
'other_contacts' => 'checkContacts'
];
protected $message = [
'id.require' => '缺少必要参数',
'org_id.require' => '请选择组织',
'dept_id.require' => '请选择部门',
'name.require' => '请填写客户名称',
'name.unique' => '客户名称已存在',
'custom_type.require' => '请选择客户属性',
'phone.require' => '请填写客户电话',
'credit_rating.require' => '请选择信用度',
'master_name.require' => '请填写主要负责人姓名',
'master_phone.mobile' => '主要负责人手机号格式错误',
'master_email.email' => '主要负责人邮箱格式错误',
];
protected $field = [
'id' => '数据id',
'org_id' => '组织id',
'dept_id' => '部门id',
'name' => '客户名称',
'custom_type' => '客户属性',
'phone' => '电话',
'credit_rating' => '信用度',
'master_name' => '主要负责人姓名',
'master_phone' => '主要负责人手机',
'master_email' => '主要负责人邮箱',
];
/**
* @notes 添加场景
* @return CustomValidate
@ -114,19 +98,16 @@ class CustomValidate extends BaseValidate
{
$org = Orgs::where('id',$value)->findOrEmpty();
if($org->isEmpty()){
return '组织不存在';
return '组织信息不存在';
}
return true;
}
public function checkDept($value,$rule,$data): bool|string
public function checkDept($value,$rule,$params): bool|string
{
$dept = Dept::where('id',$value)->findOrEmpty();
$dept = Dept::where('id',$value)->where('org_id',$params['org_id'])->findOrEmpty();
if($dept->isEmpty()){
return '部门不存在';
}
if($dept['org_id'] != $data['org_id']){
return '部门无效';
return '部门信息不存在';
}
return true;
}
@ -152,15 +133,13 @@ class CustomValidate extends BaseValidate
public function checkContacts($value): bool|string
{
if(empty($value) || !is_array($value)){
return '其他联系人数据格式错误';
return '其他联系人列表数据格式错误';
}
foreach($value as $v){
if(empty($v['name'])){
return '请填写联系人姓名';
}
foreach($value as $k=>$v){
if(empty($v['name'])) return '其他联系人列表第'.($k+1).'行姓名为空';
if(isset($v['annex']) && $v['annex'] != ''){
if(!is_array($v['annex'])){
return '联系人附件格式错误';
return '其他联系人列表第'.($k+1).'行附件格式错误';
}
}
}

View File

@ -1,23 +1,8 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\custom;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use app\common\model\GeoProvince;
use think\model\concern\SoftDelete;
@ -31,34 +16,6 @@ class Custom extends BaseModel
use SoftDelete;
protected $name = 'custom';
protected $deleteTime = 'delete_time';
public function province()
{
return $this->hasOne(GeoProvince::class, 'province_code','province');
}
/**
* @notes 关联org
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/12/20 11:01
*/
public function org()
{
return $this->hasOne(\app\common\model\dept\Orgs::class, 'id', 'org_id');
}
/**
* @notes 关联dept
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/12/20 11:01
*/
public function dept()
{
return $this->hasOne(\app\common\model\dept\Dept::class, 'id', 'dept_id');
}
public function getCustomTypeTextAttr($value,$data){
$dict = DictData::where('type_value','custom_type')->column('name','value');

View File

@ -29,8 +29,4 @@ class CustomContacts extends BaseModel
use SoftDelete;
protected $name = 'custom_contacts';
protected $deleteTime = 'delete_time';
public function getAnnexAttr($value){
return !empty($value) ? json_decode($value) : null;
}
}

View File

@ -1,20 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\custom;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
@ -35,11 +21,6 @@ class CustomFollow extends BaseModel
{
return empty($value) ? '' : date('Y-m-d', $value);
}
public function getAnnexAttr($value)
{
return !empty($value) ? json_decode($value,true) : '';
}
public function getNextFollowDateAttr($value): string
{

View File

@ -1,20 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\custom;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
@ -52,7 +38,7 @@ class CustomService extends BaseModel
}
public function getProcessingResultTextAttr($value,$data){
$dict = DictData::where('type_value','custom_service_solv_result')->column('name','value');
$dict = DictData::where('type_value','custom_service_solve_result')->column('name','value');
return !empty($data['processing_result']) ? $dict[$data['processing_result']] : '';
}
@ -61,10 +47,5 @@ class CustomService extends BaseModel
$is_solve = [0=>'未解决',1=>'已解决'];
return $is_solve[$data['is_solve']];
}
public function getAnnexAttr($value)
{
return !empty($value) ? json_decode($value,true) : '';
}
}