first commit
This commit is contained in:
@@ -0,0 +1,404 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2023-2024 美天智能科技
|
||||
* @author 李志强
|
||||
* @link http://www.meteteme.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\business\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\model\Business as BusinessList;
|
||||
use app\model\Businesscontact;
|
||||
use app\business\validate\BusinessCheck;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Index extends BaseController
|
||||
{
|
||||
public function nav()
|
||||
{
|
||||
return view();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
|
||||
$map1 = [
|
||||
['admin_id', '=', $this->uid],
|
||||
];
|
||||
$map2 = [
|
||||
['director_uid', '=', $this->uid],
|
||||
];
|
||||
$map4 = [
|
||||
['', 'exp', Db::raw("FIND_IN_SET({$this->uid},check_admin_ids)")],
|
||||
];
|
||||
$map5 = [
|
||||
['is_open', '=', 2],
|
||||
];
|
||||
|
||||
$rows = empty($param['limit']) ? get_md_contentconfig('app.page_size') : $param['limit'];
|
||||
|
||||
// 判断是否有筛选条件传递,如果有则使用筛选条件,否则使用默认条件
|
||||
$list = BusinessList::withoutField('')
|
||||
->where(function ($query) use ($param, $map1, $map2, $map4, $map5) {
|
||||
if (!empty($param['contact']) && !empty($param['name'])) {
|
||||
// 同时存在联系人和名称的情况
|
||||
$result = $query->where('contact', $param['contact'])->where('name', 'like', '%' . $param['name'] . '%')->find();
|
||||
if ($result === null) {
|
||||
return null;
|
||||
}
|
||||
} elseif (!empty($param['contact'])) {
|
||||
// 存在联系人的情况
|
||||
$query->where('contact', $param['contact']);
|
||||
} elseif (!empty($param['name'])) {
|
||||
// 存在名称的情况
|
||||
$query->where('name', 'like', '%' . $param['name'] . '%');
|
||||
} elseif (!empty($param['name_short'])) {
|
||||
// 存在名称的情况
|
||||
$query->where('name_short', 'like', '%' . $param['name_short'] . '%');
|
||||
} else {
|
||||
// 其他情况
|
||||
$query->where($map1)->whereor($map2)->whereor($map4)->whereor($map5);
|
||||
}
|
||||
})
|
||||
->where('delete_time', 0)
|
||||
->order('id desc')
|
||||
->paginate($rows, false, ['query' => $param])
|
||||
->each(function ($item, $key) {
|
||||
$item->director_name = Db::name('Admin')->where(['id' => $item->director_uid])->value('name');
|
||||
$item->admin_name = Db::name('Admin')->where(['id' => $item->admin_id])->value('name');
|
||||
$item->business = Db::name('Business')->where(['delete_time' => 0, 'id' => $item->id])->count();
|
||||
$item->content = Db::name('Business')->where(['delete_time' => 0, 'id' => $item->id])->value('content');
|
||||
$item->contact = Db::name('Businesscontact')->where(['business_id' => $item->id])->value('contact');
|
||||
$item->post = Db::name('Businesscontact')->where(['business_id' => $item->id])->value('post');
|
||||
$ids = Db::name('Business')->where(['delete_time' => 0, 'id' => $item->id])->column('id');
|
||||
});
|
||||
|
||||
|
||||
return table_assign(0, '', $list);
|
||||
} else {
|
||||
View::assign('user_info', get_login_admin());
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//获取客户列表
|
||||
public function getlists()
|
||||
{
|
||||
try {
|
||||
// 查询数据,分页设置每页10条
|
||||
$list = Db::name('Business')
|
||||
->alias('b')
|
||||
->field('b.id, b.name, b.name_short, b.company_address, a.nickname as director_uid') // 映射字段
|
||||
->leftJoin('Admin a', 'b.director_uid = a.id') // 联表 Admin 表
|
||||
->order('b.id desc') // 按 id 倒序排序
|
||||
->paginate(10); // 每页10条记录
|
||||
|
||||
// 返回成功响应
|
||||
return json([
|
||||
'code' => 1, // 成功状态码
|
||||
'msg' => '加载成功', // 提示信息
|
||||
'data' => $list->items(), // 当前页数据
|
||||
'pagination' => [
|
||||
'total' => $list->total(), // 总记录数
|
||||
'per_page' => $list->listRows(), // 每页条数
|
||||
'current_page' => $list->currentPage(), // 当前页码
|
||||
'last_page' => $list->lastPage() // 总页数
|
||||
]
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常并返回错误信息
|
||||
return json([
|
||||
'code' => 0, // 失败状态码
|
||||
'msg' => '获取失败: ' . $e->getMessage(), // 错误信息
|
||||
'data' => [] // 空数据
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//获取客户列表(无页码)
|
||||
public function getlistsmore()
|
||||
{
|
||||
try {
|
||||
// 查询数据
|
||||
$list = Db::name('Business')
|
||||
->alias('b')
|
||||
->field('b.id, b.name, b.name_short, a.nickname as director_uid') // 映射字段
|
||||
->leftJoin('Admin a', 'b.director_uid = a.id') // 联表 Admin 表
|
||||
->order('b.id desc') // 按 id 倒序排序
|
||||
->select();
|
||||
|
||||
// 返回成功响应
|
||||
return json([
|
||||
'code' => 1, // 成功状态码
|
||||
'msg' => '加载成功', // 提示信息
|
||||
'data' => $list, // 当前页数据
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常并返回错误信息
|
||||
return json([
|
||||
'code' => 0, // 失败状态码
|
||||
'msg' => '获取失败: ' . $e->getMessage(), // 错误信息
|
||||
'data' => [] // 空数据
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//新增客户(app端)
|
||||
public function addcustomer()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isPost()) {
|
||||
|
||||
// 新增逻辑
|
||||
$param['create_time'] = time();
|
||||
|
||||
$sid = BusinessList::strict(false)->field(true)->insertGetId($param);
|
||||
if ($sid) {
|
||||
add_log('add', $sid, $param);
|
||||
return json(["code" => 0, "msg" => "添加成功"]); // 返回JSON格式数据
|
||||
} else {
|
||||
return json(["code" => 1, "msg" => "添加失败"]); // 返回JSON格式数据
|
||||
}
|
||||
|
||||
} else {
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if ($id > 0) {
|
||||
$businessLists = BusinessList::where('id', $id)
|
||||
->field('id, name, email, phone, message, product, company, create_time')
|
||||
->find();
|
||||
if (empty($businessLists)) {
|
||||
return json(["code" => 1, "msg" => "信息不存在"]); // 返回JSON格式数据
|
||||
}
|
||||
}
|
||||
json(["code" => 0, "msg" => "编辑成功"]); // 返回JSON格式数据
|
||||
}
|
||||
}
|
||||
|
||||
//新增联系人(app端)
|
||||
public function addcontact()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isPost()) {
|
||||
|
||||
// 新增逻辑
|
||||
$param['create_time'] = time();
|
||||
|
||||
$sid = Businesscontact::strict(false)->field(true)->insertGetId($param);
|
||||
if ($sid) {
|
||||
add_log('add', $sid, $param);
|
||||
return json(["code" => 0, "msg" => "添加成功"]); // 返回JSON格式数据
|
||||
} else {
|
||||
return json(["code" => 1, "msg" => "添加失败"]); // 返回JSON格式数据
|
||||
}
|
||||
|
||||
} else {
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if ($id > 0) {
|
||||
$businesscontactLists = Businesscontact::where('id', $id)
|
||||
->field('id, name, email, phone, message, product, company, create_time')
|
||||
->find();
|
||||
if (empty($businesscontactLists)) {
|
||||
return json(["code" => 1, "msg" => "信息不存在"]); // 返回JSON格式数据
|
||||
}
|
||||
}
|
||||
json(["code" => 0, "msg" => "编辑成功"]); // 返回JSON格式数据
|
||||
}
|
||||
}
|
||||
|
||||
//获取联系人列表
|
||||
public function getcontactlist()
|
||||
{
|
||||
try {
|
||||
// 查询数据,分页设置每页10条
|
||||
$list = Db::name('Businesscontact')
|
||||
->alias('b')
|
||||
->field('b.id, b.contact, b.charge, b.post, b.phone, b.email, b.wechat, b.qq, a.name as business_id') // 映射字段
|
||||
->leftJoin('Business a', 'b.business_id = a.id') // 联表 Admin 表
|
||||
->order('b.id desc') // 按 id 倒序排序
|
||||
->select(); // 每页10条记录
|
||||
|
||||
// 返回成功响应
|
||||
return json([
|
||||
'code' => 1, // 成功状态码
|
||||
'msg' => '加载成功', // 提示信息
|
||||
'data' => $list,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常并返回错误信息
|
||||
return json([
|
||||
'code' => 0, // 失败状态码
|
||||
'msg' => '获取失败: ' . $e->getMessage(), // 错误信息
|
||||
'data' => [] // 空数据
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//添加
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isPost()) {
|
||||
// markdown数据处理
|
||||
if (isset($param['table-align'])) {
|
||||
unset($param['table-align']);
|
||||
}
|
||||
if (isset($param['docContent-html-code'])) {
|
||||
$param['content'] = $param['docContent-html-code'];
|
||||
$param['md_content'] = $param['docContent-markdown-doc'];
|
||||
unset($param['docContent-html-code']);
|
||||
unset($param['docContent-markdown-doc']);
|
||||
}
|
||||
if (isset($param['ueditorcontent'])) {
|
||||
$param['content'] = $param['ueditorcontent'];
|
||||
$param['md_content'] = '';
|
||||
}
|
||||
|
||||
try {
|
||||
if (!empty($param['id'])) {
|
||||
validate(BusinessCheck::class)->scene('edit')->check($param);
|
||||
$business = (new BusinessList())->detail($param['id']);
|
||||
if ($this->uid == $business['admin_id'] || $this->uid == $business['director_uid']) {
|
||||
$param['update_time'] = time();
|
||||
$res = BusinessList::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
if ($res) {
|
||||
add_log('edit', $param['id'], $param, $business);
|
||||
}
|
||||
return to_assign();
|
||||
} else {
|
||||
return to_assign(1, '只有创建人或者负责人才有权限编辑');
|
||||
}
|
||||
} else {
|
||||
validate(BusinessCheck::class)->scene('add')->check($param);
|
||||
$param['create_time'] = time();
|
||||
$param['admin_id'] = $this->uid;
|
||||
$param['director_uid'] = $this->uid;
|
||||
$sid = BusinessList::strict(false)->insertGetId($param);
|
||||
// if ($sid) {
|
||||
// add_log('add', $sid, $param);
|
||||
// $log_data = array(
|
||||
// 'module' => 'business',
|
||||
// 'id' => $sid,
|
||||
// 'new_content' => $param['name'],
|
||||
// 'field' => 'new',
|
||||
// 'action' => 'add',
|
||||
// 'admin_id' => $this->uid,
|
||||
// 'create_time' => time(),
|
||||
// );
|
||||
// Db::name('Log')->strict(false)->field(true)->insert($log_data);
|
||||
// }
|
||||
return to_assign();
|
||||
}
|
||||
} catch (ValidateException $e) {
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
} else {
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if ($id > 0) {
|
||||
$detail = (new BusinessList())->detail($id);
|
||||
if (empty($detail)) {
|
||||
return to_assign(1, '1.信息不存在');
|
||||
}
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//查看
|
||||
public function view()
|
||||
{
|
||||
$param = get_params();
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$detail = (new BusinessList())->detail($id);
|
||||
// print_r($id);
|
||||
if (empty($detail)) {
|
||||
return to_assign(1, '2.信息不存在');
|
||||
} else {
|
||||
$role_uid = [$detail['admin_id'], $detail['director_uid']];
|
||||
$role_edit = 'view';
|
||||
if (in_array($this->uid, $role_uid)) {
|
||||
$role_edit = 'edit';
|
||||
}
|
||||
$view_uid = $role_uid;
|
||||
if (!empty($detail['check_admin_ids'])) {
|
||||
$view_uid = array_merge($role_uid, explode(",", $detail['check_admin_ids']));
|
||||
}
|
||||
if (!in_array($this->uid, $view_uid) && $detail['is_open'] == 1) {
|
||||
return to_assign(1, '您没权限查看该信息');
|
||||
}
|
||||
$contact_array = Db::name('Businesscontact')
|
||||
->field('i.id,i.business_id,i.contact,i.post,i.phone,i.email,i.wechat,i.qq,a.name as admin_name')
|
||||
->alias('i')
|
||||
->join('Admin a', 'i.admin_id = a.id', 'LEFT')
|
||||
->join('Business b', 'i.business_id = b.id', 'LEFT')
|
||||
->order('i.create_time desc')
|
||||
->where(array('i.business_id' => $id))
|
||||
->where('i.delete_time', null)
|
||||
->select()->toArray();
|
||||
|
||||
$file_array = Db::name('FileInterfix')
|
||||
->field('i.id,i.topic_id,i.admin_id,f.name,f.filesize,f.filepath,a.name as admin_name')
|
||||
->alias('i')
|
||||
->join('File f', 'i.file_id = f.id', 'LEFT')
|
||||
->join('Admin a', 'i.admin_id = a.id', 'LEFT')
|
||||
->order('i.create_time desc')
|
||||
->where(array('i.topic_id' => $id, 'i.module' => 'business'))
|
||||
->select()->toArray();
|
||||
|
||||
$link_array = Db::name('LinkInterfix')
|
||||
->field('i.id,i.topic_id,i.admin_id,i.desc,i.url,a.name as admin_name')
|
||||
->alias('i')
|
||||
->join('Admin a', 'i.admin_id = a.id', 'LEFT')
|
||||
->order('i.create_time desc')
|
||||
->where(array('i.topic_id' => $id, 'i.module' => 'business', 'delete_time' => 0))
|
||||
->select()->toArray();
|
||||
View::assign('detail', $detail);
|
||||
View::assign('contact_array', $contact_array);
|
||||
View::assign('file_array', $file_array);
|
||||
View::assign('link_array', $link_array);
|
||||
View::assign('role_edit', $role_edit);
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete()
|
||||
{
|
||||
if (request()->isDelete()) {
|
||||
$id = get_params("id");
|
||||
$detail = Db::name('Business')->where('id', $id)->find();
|
||||
if ($detail['admin_id'] != $this->uid) {
|
||||
return to_assign(1, "你不是该客户的创建人,无权限删除");
|
||||
}
|
||||
if (Db::name('Business')->where('id', $id)->update(['delete_time' => time()]) !== false) {
|
||||
$log_data = array(
|
||||
'module' => 'business',
|
||||
'field' => 'delete',
|
||||
'action' => 'delete',
|
||||
'admin_id' => $this->uid,
|
||||
'old_content' => '',
|
||||
'new_content' => $detail['name'],
|
||||
'create_time' => time(),
|
||||
);
|
||||
Db::name('Log')->strict(false)->field(true)->insert($log_data);
|
||||
return to_assign(0, "删除成功");
|
||||
} else {
|
||||
return to_assign(0, "删除失败");
|
||||
}
|
||||
} else {
|
||||
return to_assign(1, "错误的请求");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2023-2024 美天智能科技
|
||||
* @author 李志强
|
||||
* @link http://www.meteteme.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\business\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\model\Supplier as SupplierList;
|
||||
use app\business\validate\SupplierCheck;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Supplier extends BaseController
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$rows = empty($param['limit']) ? get_md_contentconfig('app.page_size') : $param['limit'];
|
||||
|
||||
$list = SupplierList::whereNull('delete_time')
|
||||
->field('id, supplier_name, contact_name, contact_phone, contact_email, business_scope, company_size, remarks')
|
||||
->order('id desc')
|
||||
->paginate($rows, false);
|
||||
|
||||
return table_assign(0, '', $list->toArray());
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit()
|
||||
{
|
||||
$param = get_params();
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
|
||||
$supplier = SupplierList::where('id', $id)
|
||||
->field('id, supplier_name, company_size, registered_address, business_scope, contact_name, contact_phone, contact_email, contact_wechat, remarks, intention')
|
||||
->find();
|
||||
|
||||
if ($supplier) {
|
||||
View::assign('detail', $supplier);
|
||||
} else {
|
||||
View::assign('message', '没有详细数据');
|
||||
}
|
||||
|
||||
if (request()->isPost()) {
|
||||
$data = [
|
||||
'supplier_name' => $param['supplier_name'],
|
||||
'company_size' => $param['company_size'],
|
||||
'registered_address' => $param['registered_address'],
|
||||
'business_scope' => $param['business_scope'],
|
||||
'contact_name' => $param['contact_name'],
|
||||
'contact_phone' => $param['contact_phone'],
|
||||
'contact_email' => $param['contact_email'],
|
||||
'contact_wechat' => $param['contact_wechat'],
|
||||
'remarks' => $param['remarks'],
|
||||
'intention' => $param['intention'],
|
||||
'update_time' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
|
||||
$res = SupplierList::where('id', $id)->update($data);
|
||||
|
||||
if ($res) {
|
||||
return to_assign(2, '更新成功!');
|
||||
} else {
|
||||
return to_assign(1, '更新失败');
|
||||
}
|
||||
}
|
||||
|
||||
return view();
|
||||
}
|
||||
|
||||
//添加
|
||||
public function add()
|
||||
{
|
||||
|
||||
$param = get_params();
|
||||
if (request()->isPost()) {
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
$newsupplier = (new SupplierList())->detail($param['id']);
|
||||
try {
|
||||
validate(SupplierCheck::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['update_time'] = time();
|
||||
$res = SupplierList::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
if ($res) {
|
||||
add_log('edit', $param['id'], $param, $newsupplier);
|
||||
}
|
||||
return to_assign();
|
||||
} else {
|
||||
try {
|
||||
validate(SupplierCheck::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['create_time'] = date('Y-m-d H:i:s', time());
|
||||
$param['admin_id'] = $this->uid;
|
||||
$sid = SupplierList::strict(false)->field(true)->insertGetId($param);
|
||||
if ($sid) {
|
||||
add_log('add', $sid, $param);
|
||||
$log_data = array(
|
||||
'module' => 'plans',
|
||||
// 'id' => $sid,
|
||||
'new_content' => $param['supplier_name'],
|
||||
'field' => 'new',
|
||||
'action' => 'add',
|
||||
'admin_id' => $this->uid,
|
||||
'create_time' => time(),
|
||||
);
|
||||
Db::name('Log')->strict(false)->field(true)->insert($log_data);
|
||||
}
|
||||
return to_assign(2, '添加成功!');
|
||||
}
|
||||
} else {
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if ($id > 0) {
|
||||
$detail = (new SupplierList())->detail($id);
|
||||
if (empty($detail)) {
|
||||
return to_assign(1, '1.信息不存在');
|
||||
}
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete()
|
||||
{
|
||||
$request = request();
|
||||
if ($request->isDelete() || $request->isAjax()) {
|
||||
$id = get_params("id");
|
||||
$detail = Db::name('Supplier')->where('id', $id)->find();
|
||||
if (!isset($detail['id'])) {
|
||||
return to_assign(1, "账号不存在");
|
||||
}
|
||||
// Convert the current timestamp to a MySQL DATETIME format
|
||||
$currentDateTime = date('Y-m-d H:i:s', time());
|
||||
|
||||
if (Db::name('Supplier')->where('id', $id)->update(['delete_time' => $currentDateTime]) !== false) {
|
||||
$log_data = array(
|
||||
'module' => 'supplier',
|
||||
'field' => 'delete',
|
||||
'action' => 'delete',
|
||||
'admin_id' => $this->uid,
|
||||
'old_content' => '',
|
||||
'new_content' => '',
|
||||
'create_time' => time(),
|
||||
);
|
||||
Db::name('Log')->strict(false)->field(true)->insert($log_data);
|
||||
return to_assign(0, "删除成功");
|
||||
} else {
|
||||
return to_assign(0, "删除失败");
|
||||
}
|
||||
} else {
|
||||
return to_assign(1, "错误的请求");
|
||||
}
|
||||
}
|
||||
|
||||
//查看
|
||||
public function view()
|
||||
{
|
||||
$param = get_params();
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$detail = (new SupplierList())->detail($id);
|
||||
// print_r($id);
|
||||
if (empty($detail)) {
|
||||
return to_assign(1, '无法查询到详情信息');
|
||||
} else {
|
||||
View::assign('detail', $detail);
|
||||
// print_r($detail);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//开票信息填写(新增与编辑)
|
||||
public function invoice()
|
||||
{
|
||||
$param = get_params();
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
|
||||
$supplier = SupplierList::where('id', $id)
|
||||
->field('id, invoice_company_name, taxpayer_id, invoice_address, invoice_phone, bank_name, bank_account')
|
||||
->find();
|
||||
|
||||
if ($supplier) {
|
||||
View::assign('detail', $supplier);
|
||||
} else {
|
||||
View::assign('message', '没有详细数据');
|
||||
}
|
||||
|
||||
if (request()->isPost()) {
|
||||
$data = [
|
||||
'invoice_company_name' => $param['invoice_company_name'],
|
||||
'taxpayer_id' => $param['taxpayer_id'],
|
||||
'invoice_address' => $param['invoice_address'],
|
||||
'invoice_phone' => $param['invoice_phone'],
|
||||
'bank_name' => $param['bank_name'],
|
||||
'bank_account' => $param['bank_account'],
|
||||
'update_time' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
|
||||
$res = SupplierList::where('id', $id)->update($data);
|
||||
|
||||
if ($res) {
|
||||
return to_assign(2, '更新成功!');
|
||||
} else {
|
||||
return to_assign(1, '更新失败');
|
||||
}
|
||||
}
|
||||
|
||||
return view();
|
||||
}
|
||||
|
||||
//发送意向
|
||||
public function sendintention()
|
||||
{
|
||||
$param = get_params();
|
||||
|
||||
// 提取并检查必要参数
|
||||
$supplierName = isset($param['supplier_name']) ? trim($param['supplier_name']) : '';
|
||||
if (empty($supplierName)) {
|
||||
return json_encode(['status' => 0, 'message' => '供应商名称不能为空']);
|
||||
}
|
||||
|
||||
// 检查供应商名称是否重复
|
||||
$existingSupplier = SupplierList::where('supplier_name', $supplierName)->find();
|
||||
if ($existingSupplier) {
|
||||
return json_encode(['status' => 1, 'message' => '供应商名称已存在']);
|
||||
}
|
||||
|
||||
// 准备插入数据
|
||||
$data = [
|
||||
'supplier_name' => $supplierName,
|
||||
'contact_name' => isset($param['contact_name']) ? $param['contact_name'] : '',
|
||||
'contact_phone' => isset($param['contact_phone']) ? $param['contact_phone'] : '',
|
||||
'contact_email' => isset($param['contact_email']) ? $param['contact_email'] : '',
|
||||
'contact_wechat' => isset($param['contact_wechat']) ? $param['contact_wechat'] : '',
|
||||
'registered_address' => isset($param['registered_address']) ? $param['registered_address'] : '',
|
||||
'business_scope' => isset($param['business_scope']) ? $param['business_scope'] : '',
|
||||
'company_size' => isset($param['company_size']) ? $param['company_size'] : '',
|
||||
'intention' => isset($param['intention']) ? $param['intention'] : '',
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
|
||||
// 插入数据到数据库
|
||||
$res = SupplierList::insert($data);
|
||||
|
||||
if ($res) {
|
||||
return json_encode(['status' => 2, 'message' => '添加成功']);
|
||||
} else {
|
||||
return json_encode(['status' => 3, 'message' => '添加失败']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user