98 lines
2.0 KiB
PHP
98 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace app\admin\logic\express;
|
|
|
|
|
|
use app\common\model\express\Express;
|
|
use app\common\logic\BaseLogic;
|
|
use think\facade\Db;
|
|
|
|
|
|
/**
|
|
* 快递公司逻辑
|
|
* Class ExpressLogic
|
|
* @package app\admin\logic\express
|
|
*/
|
|
class ExpressLogic extends BaseLogic
|
|
{
|
|
|
|
|
|
/**
|
|
* @notes 添加快递公司
|
|
* @param array $params
|
|
* @return bool
|
|
* @author likeadmin
|
|
* @date 2024/05/28 09:58
|
|
*/
|
|
public static function add(array $params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
Express::create([
|
|
'code' => $params['code'],
|
|
'name' => $params['name'],
|
|
'mark' => $params['mark']
|
|
]);
|
|
|
|
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/05/28 09:58
|
|
*/
|
|
public static function edit(array $params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
Express::where('id', $params['id'])->update([
|
|
'code' => $params['code'],
|
|
'name' => $params['name'],
|
|
'mark' => $params['mark']
|
|
]);
|
|
|
|
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/05/28 09:58
|
|
*/
|
|
public static function delete(array $params): bool
|
|
{
|
|
return Express::destroy($params['id']);
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取快递公司详情
|
|
* @param $params
|
|
* @return array
|
|
* @author likeadmin
|
|
* @date 2024/05/28 09:58
|
|
*/
|
|
public static function detail($params): array
|
|
{
|
|
return Express::findOrEmpty($params['id'])->toArray();
|
|
}
|
|
} |