149 lines
4.7 KiB
PHP
149 lines
4.7 KiB
PHP
<?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;
|
||
|
||
|
||
use app\common\model\StoreUser;
|
||
use app\common\model\teastore\TeaStoreCity;
|
||
use app\common\model\TeaStoreReal;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\service\FileService;
|
||
use think\facade\Config;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* TeaStoreReal逻辑
|
||
* Class TeaStoreRealLogic
|
||
* @package app\adminapi\logic
|
||
*/
|
||
class TeaStoreRealLogic extends BaseLogic
|
||
{
|
||
public static function lists($data){
|
||
// 如果 $data 是 Json 响应对象,先获取其数据
|
||
if ($data instanceof \think\response\Json) {
|
||
$data = $data->getData();
|
||
}
|
||
foreach($data['data']['lists'] as $key=>$value){
|
||
// $data['data']['lists'][$key]['license_img'] = FileService::getImgUrl($value['license_img']);
|
||
$data['data']['lists'][$key]['city_name'] = TeaStoreCity::where("id",$value['city_id'])->value("name");
|
||
}
|
||
return $data;
|
||
}
|
||
|
||
/**
|
||
* @notes 添加
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2026/02/01 21:50
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
TeaStoreReal::create([
|
||
'user_id' => $params['user_id'],
|
||
'operation_type' => $params['operation_type'],
|
||
'license_img' => $params['license_img'],
|
||
'username' => $params['username'],
|
||
'mobile' => $params['mobile'],
|
||
'city_id' => $params['city_id'],
|
||
'address' => $params['address'],
|
||
'suggest' => $params['suggest'],
|
||
'status' => $params['status'],
|
||
'create_time' => strtotime($params['create_time']),
|
||
'shenhe_time' => strtotime($params['shenhe_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 2026/02/01 21:50
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
$passwordSalt = Config::get('project.unique_identification');
|
||
$password = create_password("123456", $passwordSalt);
|
||
StoreUser::create([
|
||
'nickname' => $params['username'],
|
||
'account' => $params['mobile'],
|
||
'password' => $password,
|
||
'mobile' => $params['mobile'],
|
||
'create_time'=>time()
|
||
]);
|
||
TeaStoreReal::where('id', $params['id'])->update([
|
||
// 'user_id' => $params['user_id'],
|
||
// 'operation_type' => $params['operation_type'],
|
||
// 'license_img' => $params['license_img'],
|
||
// 'username' => $params['username'],
|
||
// 'mobile' => $params['mobile'],
|
||
// 'city_id' => $params['city_id'],
|
||
// 'address' => $params['address'],
|
||
// 'suggest' => $params['suggest'],
|
||
'status' => $params['status'],
|
||
// 'create_time' => strtotime($params['create_time']),
|
||
// 'shenhe_time' => strtotime($params['shenhe_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 2026/02/01 21:50
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return TeaStoreReal::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2026/02/01 21:50
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
return TeaStoreReal::findOrEmpty($params['id'])->toArray();
|
||
}
|
||
} |