Files
huangjingfen/pro_v3.5.1/app/controller/admin/v1/other/Express.php
panchengyong c1e74d8e68 chore(php): 统一 ScottPan 文件头与注释域名替换
- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明

Made-with: Cursor
2026-03-29 11:22:58 +08:00

160 lines
3.9 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | Author: ScottPan Team
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\other;
use app\controller\admin\AuthController;
use app\services\other\ExpressServices;
use think\annotation\Inject;
/**
* 物流
* Class Express
* @package app\controller\admin\v1\freight
*/
class Express extends AuthController
{
/**
* @var ExpressServices
*/
#[Inject]
protected ExpressServices $services;
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['keyword', '']
]);
return $this->success($this->services->getExpressList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
return $this->success($this->services->createForm());
}
/**
* 保存新建的资源
*
* @return \think\Response
*/
public function save()
{
$data = $this->request->postMore([
'name',
'code',
['sort', 0],
['is_show', 0]]);
if (!$data['name']) return $this->fail('请输入公司名称');
$this->services->save($data);
return $this->success('添加公司成功!');
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
//
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
return $this->success($this->services->updateForm((int)$id));
}
/**
* 保存更新的资源
*
* @param int $id
* @return \think\Response
*/
public function update($id)
{
$data = $this->request->postMore([
['account', ''],
['key', ''],
['net_name', ''],
['sort', 0],
['is_show', 0]]);
if (!$expressInfo = $this->services->get($id)) return $this->fail('编辑的记录不存在!');
if ($expressInfo['partner_id'] == 1 && !$data['account']) {
return $this->fail('请输入月结账号');
}
if ($expressInfo['partner_key'] == 1 && !$data['key']) {
return $this->fail('请输入月结密码');
}
if ($expressInfo['net'] == 1 && !$data['net_name']) {
return $this->fail('请输入取件网点');
}
$expressInfo->account = $data['account'];
$expressInfo->key = $data['key'];
$expressInfo->net_name = $data['net_name'];
$expressInfo->sort = $data['sort'];
$expressInfo->is_show = $data['is_show'];
$expressInfo->status = 1;
$expressInfo->save();
return $this->success('修改成功!');
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if (!$id) return $this->fail('参数错误,请重新打开');
$res = $this->services->delete($id);
if (!$res)
return $this->fail('删除失败,请稍候再试!');
else
return $this->success('删除成功!');
}
/**
* 修改状态
* @param int $id
* @param string $status
* @return mixed
*/
public function set_status($id = 0, $status = '')
{
if ($status == '' || $id == 0) return $this->fail('参数错误');
$this->services->update($id, ['is_show' => $status]);
return $this->success($status == 0 ? '隐藏成功' : '显示成功');
}
/**
* 同步平台快递公司
* @return mixed
*/
public function syncExpress()
{
$this->services->syncExpress();
return $this->success('同步成功');
}
}