REAPI/app/merchant/controller/MerchantParams.php
mzeros 84856367e9 feat(openapi): 新增码速达API接口
- 添加AfterSales类处理售后服务相关接口
- 新增ContentTemplate控制器和模型用于内容模板管理
- 添加diandian渠道服务类
- 更新Feedov控制器和添加FeedovHfAuto命令类
- 新增autoCard视图用于自动发卡设置
2025-03-11 00:17:40 +08:00

122 lines
3.7 KiB
PHP

<?php
declare(strict_types=1);
namespace app\merchant\controller;
use app\merchant\service\MerchantService;
use app\setting\model\SystemParams;
use think\admin\Controller;
use think\admin\helper\QueryHelper;
use app\merchant\model\MerchantParams as MerchantParamsModel;
/**
* 商户参数管理
* @class SystemParams
* @package app\setting\controller
*/
class MerchantParams extends Controller
{
/**
* 系统参数管理
* @auth true
* @menu true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
// $this->mid = input('mid');
// $info = MerchantService::instance()->getInfo($this->mid);
// $this->title = '【' . $info['name'] . '】订单列表';
MerchantParamsModel::mQuery()->layTable(function () {
$this->mid = input('mid');
$info = MerchantService::instance()->getInfo($this->mid);
$this->title = '【' . $info['name'] . '】参数管理';
$this->types = MerchantParamsModel::types(false,$this->mid);
$this->type = $this->get['type'] ?? ($this->types[0] ?? '-');
}, static function (QueryHelper $query) {
$mid = input('mid');
// $query->where(['mid'=> $this->mid]);
$query->where(['deleted' => 0, 'mid' =>$mid])->equal('type');
$query->like('code,name,status')->dateBetween('create_at');
});
}
/**
* 添加系统参数
* @auth true
*/
public function add()
{
MerchantParamsModel::mForm('form');
}
/**
* 编辑系统参数
* @auth true
*/
public function edit()
{
MerchantParamsModel::mForm('form');
}
/**
* 表单数据处理
* @param array $data
* @throws \think\db\exception\DbException
*/
protected function _form_filter(array &$data)
{
if ($this->request->isGet()) {
$this->mid = input('mid');
$this->types = MerchantParamsModel::types(false,$this->mid);
$this->types[] = '系统内置商户通用参数';
$this->types[] = '--- ' . lang('新增类型') . ' ---';
$this->type = $this->get['type'] ?? ($this->types[0] ?? '-');
$this->systemParams = SystemParams::mk()->field('code,data_type,name,content')->where([['type','=','商户通用参数'],['deleted','=',0],['status','=',1]])->select()->toArray();
} else {
#判断是否在系统内置商户通用参数
if($data['type'] != '系统内置商户通用参数' && SystemParams::mk()->where([['code','=',$data['code']],['type','=','商户通用参数'],['deleted','=',0]])->count()>0){
$this->error("数据编码已经存在系统内置通用参数!请自行选择通用参数,不支持重复自定义!");
}
$map = [];
$map[] = ['deleted', '=', 0];
$map[] = ['mid', '=', $data['mid']];
$map[] = ['code', '=', $data['code']];
$map[] = ['type', '=', $data['type']];
$map[] = ['id', '<>', $data['id'] ?? 0];
if (MerchantParamsModel::mk()->where($map)->count() > 0) {
$this->error("数据编码已经存在!");
}
}
}
/**
* 修改参数状态
* @auth true
*/
public function state()
{
MerchantParamsModel::mSave($this->_vali([
'status.in:0,1' => '状态值范围异常!',
'status.require' => '状态值不能为空!',
]));
}
/**
* 删除参数记录
* @auth true
*/
public function remove()
{
MerchantParamsModel::mDelete();
}
}