新增市场经营-客户信息

This commit is contained in:
weiz 2024-04-01 15:37:35 +08:00
parent 6100c6fd44
commit adec12360b
10 changed files with 1144 additions and 0 deletions

View File

@ -0,0 +1,108 @@
<?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\marketing;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\marketing\MarketingCustomContactsLists;
use app\adminapi\logic\marketing\MarketingCustomContactsLogic;
use app\adminapi\validate\marketing\MarketingCustomContactsValidate;
/**
* 市场经营--客户信息--联系人控制器
* Class MarketingCustomContactsController
* @package app\adminapi\controller\marketing
*/
class MarketingCustomContactsController extends BaseAdminController
{
/**
* @notes 获取市场经营--客户信息--联系人列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function lists()
{
return $this->dataLists(new MarketingCustomContactsLists());
}
/**
* @notes 添加市场经营--客户信息--联系人
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function add()
{
$params = (new MarketingCustomContactsValidate())->post()->goCheck('add');
$result = MarketingCustomContactsLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(MarketingCustomContactsLogic::getError());
}
/**
* @notes 编辑市场经营--客户信息--联系人
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function edit()
{
$params = (new MarketingCustomContactsValidate())->post()->goCheck('edit');
$result = MarketingCustomContactsLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(MarketingCustomContactsLogic::getError());
}
/**
* @notes 删除市场经营--客户信息--联系人
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function delete()
{
$params = (new MarketingCustomContactsValidate())->post()->goCheck('delete');
MarketingCustomContactsLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取市场经营--客户信息--联系人详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function detail()
{
$params = (new MarketingCustomContactsValidate())->goCheck('detail');
$result = MarketingCustomContactsLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,116 @@
<?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\marketing;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\marketing\MarketingCustomLists;
use app\adminapi\logic\marketing\MarketingCustomLogic;
use app\adminapi\validate\marketing\MarketingCustomValidate;
/**
* 市场经营--客户信息控制器
* Class MarketingCustomController
* @package app\adminapi\controller\marketing
*/
class MarketingCustomController extends BaseAdminController
{
/**
* @notes 获取市场经营--客户信息列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function lists()
{
return $this->dataLists(new MarketingCustomLists());
}
/**
* @notes 添加市场经营--客户信息
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function add()
{
$params = (new MarketingCustomValidate())->post()->goCheck('add');
$result = MarketingCustomLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(MarketingCustomLogic::getError());
}
/**
* @notes 编辑市场经营--客户信息
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function edit()
{
$params = (new MarketingCustomValidate())->post()->goCheck('edit');
$result = MarketingCustomLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(MarketingCustomLogic::getError());
}
/**
* @notes 删除市场经营--客户信息
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function delete()
{
$params = (new MarketingCustomValidate())->post()->goCheck('delete');
$result = MarketingCustomLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(MarketingCustomLogic::getError());
}
/**
* @notes 获取市场经营--客户信息详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function detail()
{
$params = (new MarketingCustomValidate())->goCheck('detail');
$result = MarketingCustomLogic::detail($params);
return $this->data($result);
}
public function datas(): \think\response\Json
{
return $this->data(MarketingCustomLogic::datas());
}
}

View File

@ -0,0 +1,78 @@
<?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\marketing;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\marketing\MarketingCustomContacts;
/**
* 市场经营--客户信息--联系人列表
* Class MarketingCustomContactsLists
* @package app\adminapi\listsmarketing
*/
class MarketingCustomContactsLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function setSearch(): array
{
return [
'=' => ['custom_id'],
];
}
/**
* @notes 获取市场经营--客户信息--联系人列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function lists(): array
{
return MarketingCustomContacts::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($data) {
$data['gender_text'] = $data->gender_text;
})
->toArray();
}
/**
* @notes 获取市场经营--客户信息--联系人数量
* @return int
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function count(): int
{
return MarketingCustomContacts::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,89 @@
<?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\marketing;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\dept\Dept;
use app\common\model\GeoCity;
use app\common\model\GeoProvince;
use app\common\model\marketing\MarketingCustom;
/**
* 市场经营--客户信息列表
* Class MarketingCustomLists
* @package app\adminapi\listsmarketing
*/
class MarketingCustomLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function setSearch(): array
{
return [
'=' => ['important_level', 'dept_id', 'category', 'province', 'city'],
'%like%' => ['name', 'code', 'create_user'],
];
}
/**
* @notes 获取市场经营--客户信息列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function lists(): array
{
return MarketingCustom::withoutField('update_time,delete_time')->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($data) {
$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();
$data['dept_name'] = $dept['name'];
$data['province_name'] = !$province->isEmpty() ? $province['province_name'] : '';
$data['city_name'] = !$city->isEmpty() ? $city['city_name'] : '';
$data['important_level_text'] = $data->important_level_text;
$data['category_text'] = $data->category_text;
})
->toArray();
}
/**
* @notes 获取市场经营--客户信息数量
* @return int
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function count(): int
{
return MarketingCustom::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,125 @@
<?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\marketing;
use app\common\logic\BaseLogic;
use app\common\model\marketing\MarketingCustomContacts;
use think\facade\Db;
/**
* 市场经营--客户信息--联系人逻辑
* Class MarketingCustomContactsLogic
* @package app\adminapi\logic\marketing
*/
class MarketingCustomContactsLogic extends BaseLogic
{
/**
* @notes 添加市场经营--客户信息--联系人
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/01 14:26
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
MarketingCustomContacts::create([
'custom_id' => $params['custom_id'],
'name' => $params['name'],
'dept' => $params['dept'] ?? '',
'gender' => $params['gender'] ?? 0,
'job' => $params['job'] ?? '',
'mobile' => $params['mobile'] ?? '',
'telephone' => $params['telephone'] ?? '',
'email' => $params['email'] ?? '',
'qq' => $params['qq'] ?? '',
'remark' => $params['remark'] ?? '',
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑市场经营--客户信息--联系人
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/01 14:26
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
MarketingCustomContacts::where('id', $params['id'])->update([
'custom_id' => $params['custom_id'],
'name' => $params['name'],
'dept' => $params['dept'] ?? '',
'gender' => $params['gender'] ?? 0,
'job' => $params['job'] ?? '',
'mobile' => $params['mobile'] ?? '',
'telephone' => $params['telephone'] ?? '',
'email' => $params['email'] ?? '',
'qq' => $params['qq'] ?? '',
'remark' => $params['remark'] ?? '',
'update_time' => time()
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除市场经营--客户信息--联系人
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/01 14:26
*/
public static function delete(array $params): bool
{
return MarketingCustomContacts::destroy($params['id']);
}
/**
* @notes 获取市场经营--客户信息--联系人详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/04/01 14:26
*/
public static function detail($params): array
{
$data = MarketingCustomContacts::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
$data['gender_text'] = $data->gender_text;
return $data->toArray();
}
}

View File

@ -0,0 +1,225 @@
<?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\marketing;
use app\common\logic\BaseLogic;
use app\common\model\dept\Dept;
use app\common\model\GeoCity;
use app\common\model\GeoProvince;
use app\common\model\marketing\MarketingCustom;
use app\common\model\marketing\MarketingCustomContacts;
use think\facade\Db;
/**
* 市场经营--客户信息逻辑
* Class MarketingCustomLogic
* @package app\adminapi\logic\marketing
*/
class MarketingCustomLogic extends BaseLogic
{
/**
* @notes 添加市场经营--客户信息
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/01 14:26
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
$res = MarketingCustom::create([
'name' => $params['name'],
'sub_name' => $params['sub_name'] ?? '',
'code' => $params['code'] ?? '',
'important_level' => $params['important_level'],
'dept_id' => $params['dept_id'],
'category' => $params['category'],
'remark' => $params['remark'] ?? '',
'invoice_company' => $params['invoice_company'] ?? '',
'taxpayer_identification_number' => $params['taxpayer_identification_number'] ?? '',
'opening_bank' => $params['opening_bank'] ?? '',
'invoice_contact' => $params['invoice_contact'] ?? '',
'invoice_company_address' => $params['invoice_company_address'] ?? '',
'invoice_company_telephone' => $params['invoice_company_telephone'] ?? '',
'opening_bank_account' => $params['opening_bank_account'] ?? '',
'email' => $params['email'] ?? '',
'province' => $params['province'] ?? '',
'city' => $params['city'] ?? '',
'post_code' => $params['post_code'] ?? '',
'telephone' => $params['telephone'] ?? '',
'fax' => $params['fax'] ?? '',
'website' => $params['website'] ?? '',
'address' => $params['address'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'create_user' => $params['create_user'],
'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : time(),
]);
if (!empty($params['detail'])) {
foreach ($params['detail'] as $v) {
MarketingCustomContacts::create([
'custom_id' => $res->id,
'name' => $v['name'],
'dept' => $v['dept'] ?? '',
'gender' => $v['gender'] ?? 0,
'job' => $v['job'] ?? '',
'mobile' => $v['mobile'] ?? '',
'telephone' => $v['telephone'] ?? '',
'email' => $v['email'] ?? '',
'qq' => $v['qq'] ?? '',
'remark' => $v['remark'] ?? '',
]);
}
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑市场经营--客户信息
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/01 14:26
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
MarketingCustom::where('id', $params['id'])->update([
'name' => $params['name'],
'sub_name' => $params['sub_name'] ?? '',
'code' => $params['code'] ?? '',
'important_level' => $params['important_level'],
'dept_id' => $params['dept_id'],
'category' => $params['category'],
'remark' => $params['remark'] ?? '',
'invoice_company' => $params['invoice_company'] ?? '',
'taxpayer_identification_number' => $params['taxpayer_identification_number'] ?? '',
'opening_bank' => $params['opening_bank'] ?? '',
'invoice_contact' => $params['invoice_contact'] ?? '',
'invoice_company_address' => $params['invoice_company_address'] ?? '',
'invoice_company_telephone' => $params['invoice_company_telephone'] ?? '',
'opening_bank_account' => $params['opening_bank_account'] ?? '',
'email' => $params['email'] ?? '',
'province' => $params['province'] ?? '',
'city' => $params['city'] ?? '',
'post_code' => $params['post_code'] ?? '',
'telephone' => $params['telephone'] ?? '',
'fax' => $params['fax'] ?? '',
'website' => $params['website'] ?? '',
'address' => $params['address'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'create_user' => $params['create_user'],
'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : time(),
'update_time' => time()
]);
if (!empty($params['detail'])) {
foreach ($params['detail'] as $v) {
if (!empty($v['id'])) {
MarketingCustomContacts::where('id', $v['id'])->update([
'custom_id' => $params['id'],
'name' => $v['name'],
'dept' => $v['dept'] ?? '',
'gender' => $v['gender'] ?? 0,
'job' => $v['job'] ?? '',
'mobile' => $v['mobile'] ?? '',
'telephone' => $v['telephone'] ?? '',
'email' => $v['email'] ?? '',
'qq' => $v['qq'] ?? '',
'remark' => $v['remark'] ?? '',
'update_time' => time(),
]);
} else {
MarketingCustomContacts::create([
'custom_id' => $params['id'],
'name' => $v['name'],
'dept' => $v['dept'] ?? '',
'gender' => $v['gender'] ?? 0,
'job' => $v['job'] ?? '',
'mobile' => $v['mobile'] ?? '',
'telephone' => $v['telephone'] ?? '',
'email' => $v['email'] ?? '',
'qq' => $v['qq'] ?? '',
'remark' => $v['remark'] ?? '',
]);
}
}
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除市场经营--客户信息
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/01 14:26
*/
public static function delete(array $params): bool
{
$detail = MarketingCustomContacts::where('custom_id', 'in', $params['id'])->findOrEmpty();
if (!$detail->isEmpty()) {
return '此数据关联了联系人信息,需删除联系人信息';
}
return MarketingCustom::destroy($params['id']);
}
/**
* @notes 获取市场经营--客户信息详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/04/01 14:26
*/
public static function detail($params): array
{
$data = MarketingCustom::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
$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();
$data['dept_name'] = $dept['name'];
$data['province_name'] = !$province->isEmpty() ? $province['province_name'] : '';
$data['city_name'] = !$city->isEmpty() ? $city['city_name'] : '';
$data['important_level_text'] = $data->important_level_text;
$data['category_text'] = $data->category_text;
return $data->toArray();
}
public static function datas(): array
{
return MarketingCustom::field(['id', 'name'])->order(['id' => 'desc'])->select()->each(function ($data) {
$data['projectinfo'] = 'ID' . $data['id'] . ' / 名称:' . $data['name'];
})->toArray();
}
}

View File

@ -0,0 +1,124 @@
<?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\marketing;
use app\common\model\marketing\MarketingCustom;
use app\common\model\marketing\MarketingCustomContacts;
use app\common\validate\BaseValidate;
/**
* 市场经营--客户信息--联系人验证器
* Class MarketingCustomContactsValidate
* @package app\adminapi\validate\marketing
*/
class MarketingCustomContactsValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'custom_id' => 'require|checkCustom',
'name' => 'require',
'gender' => 'in:0,1',
'mobile' => 'mobile',
'email' => 'email',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'custom_id' => '客户id',
'name' => '姓名',
'dept' => '部门',
'gender' => '姓名 0-男 1-女',
'job' => '职务',
'mobile' => '手机',
'telephone' => '电话',
'email' => '邮箱',
'qq' => 'QQ',
'remark' => '备注',
];
/**
* @notes 添加场景
* @return MarketingCustomContactsValidate
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function sceneAdd()
{
return $this->only(['custom_id', 'name', 'dept', 'gender', 'job', 'mobile', 'telephone', 'email', 'qq', 'remark']);
}
/**
* @notes 编辑场景
* @return MarketingCustomContactsValidate
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function sceneEdit()
{
return $this->only(['id', 'custom_id', 'name', 'dept', 'gender', 'job', 'mobile', 'telephone', 'email', 'qq', 'remark']);
}
/**
* @notes 删除场景
* @return MarketingCustomContactsValidate
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function sceneDelete()
{
return $this->only(['id'])->remove('id', 'checkData');
}
/**
* @notes 详情场景
* @return MarketingCustomContactsValidate
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = MarketingCustomContacts::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '数据不存在' : true;
}
public function checkCustom($value): bool|string
{
$data = MarketingCustom::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '客户信息不存在' : true;
}
}

View File

@ -0,0 +1,194 @@
<?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\marketing;
use app\common\model\dept\Dept;
use app\common\model\dict\DictData;
use app\common\model\GeoCity;
use app\common\model\GeoProvince;
use app\common\model\marketing\MarketingCustom;
use app\common\model\marketing\MarketingCustomContacts;
use app\common\validate\BaseValidate;
/**
* 市场经营--客户信息验证器
* Class MarketingCustomValidate
* @package app\adminapi\validate\marketing
*/
class MarketingCustomValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'name' => 'require|unique:' . MarketingCustom::class,
'important_level' => 'require|checkImportantLevel',
'dept_id' => 'require|checkDept',
'category' => 'require|checkCategory',
'email' => 'email',
'province' => 'checkProvince',
'city' => 'checkCity',
'website' => 'url',
'create_user' => 'require',
'create_time' => 'require|dateFormat:Y-m-d H:i:s',
'annex' => 'checkAnnex',
'detail' => 'checkDetail'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'name' => '客户名称',
'sub_name' => '客户简称',
'code' => '客户编号',
'important_level' => '重要等级',
'dept_id' => '负责部门',
'category' => '客户分类',
'remark' => '备注',
'invoice_company' => '开票单位',
'taxpayer_identification_number' => '纳税人识别号',
'opening_bank' => '开户银行',
'invoice_contact' => '开票联系人',
'invoice_company_address' => '开票单位注册地址',
'invoice_company_telephone' => '开票单位电话',
'opening_bank_account' => '开户账号',
'email' => '电子邮箱',
'province' => '省份',
'city' => '城市',
'post_code' => '邮编',
'telephone' => '电话',
'fax' => '传真',
'website' => '网址',
'address' => '地址',
'create_user' => '录入人',
'create_time' => '录入日期',
];
/**
* @notes 添加场景
* @return MarketingCustomValidate
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 编辑场景
* @return MarketingCustomValidate
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function sceneEdit()
{
}
/**
* @notes 删除场景
* @return MarketingCustomValidate
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function sceneDelete()
{
return $this->only(['id'])->remove('id', 'checkData');
}
/**
* @notes 详情场景
* @return MarketingCustomValidate
* @author likeadmin
* @date 2024/04/01 14:26
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = MarketingCustom::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '数据不存在' : true;
}
public function checkImportantLevel($value): bool|string
{
$dict = DictData::where('type_value', 'custom_important_level')->column('value');
return !in_array($value, $dict) ? '重要等级数据值无效' : true;
}
public function checkDept($value): bool|string
{
$data = Dept::where('id', $value)->findOrEmpty();
return $data->isEmpty() ? '部门信息不存在' : true;
}
public function checkCategory($value): bool|string
{
$dict = DictData::where('type_value', 'custom_category')->column('value');
return !in_array($value, $dict) ? '客户分类数据值无效' : true;
}
public function checkProvince($value): bool|string
{
if (empty($value)) return true;
$data = GeoProvince::where('province_code', $value)->findOrEmpty();
return $data->isEmpty() ? '省份信息不存在' : true;
}
public function checkCity($value): bool|string
{
if (empty($value)) return true;
$data = GeoCity::where('city_code', $value)->findOrEmpty();
return $data->isEmpty() ? '城市信息不存在' : true;
}
public function checkDetail($value): bool|string
{
if (!isset($value) || $value == '') return true;
if (!is_array($value)) return '联系人数据格式错误';
foreach ($value as $k => $v) {
if (isset($v['id']) && !empty($v['id'])) {
$data = MarketingCustomContacts::where('id', $v['id'])->findOrEmpty();
if ($data->isEmpty()) {
return '第' . ($k + 1) . '行联系人信息不存在';
}
}
if (empty($v['name'])) {
return '联系人列表第' . ($k + 1) . '行姓名为空';
}
if (!empty($v['gender'])) {
if (!in_array($v['gender'], [0, 1])) return '联系人列表第' . ($k + 1) . '行性别数据错误';
}
}
return true;
}
}

View File

@ -0,0 +1,46 @@
<?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\marketing;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 市场经营--客户信息模型
* Class MarketingCustom
* @package app\common\model\marketing
*/
class MarketingCustom extends BaseModel
{
use SoftDelete;
protected $name = 'marketing_custom';
protected $deleteTime = 'delete_time';
public function getImportantLevelTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'custom_important_level')->column('name', 'value');
return !empty($data['important_level']) ? $dict[$data['important_level']] : '';
}
public function getCategoryTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'custom_category')->column('name', 'value');
return !empty($data['category']) ? $dict[$data['category']] : '';
}
}

View File

@ -0,0 +1,39 @@
<?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\marketing;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 市场经营--客户信息--联系人模型
* Class MarketingCustomContacts
* @package app\common\model\marketing
*/
class MarketingCustomContacts extends BaseModel
{
use SoftDelete;
protected $name = 'marketing_custom_contacts';
protected $deleteTime = 'delete_time';
public function getGenderTextAttr($value, $data)
{
$arr = [0 => '男', 1 => '女'];
return $data[$arr['gender']];
}
}