初始化项目
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\store\controller;
|
||||
|
||||
use app\store\model\store\User;
|
||||
use app\store\model\Bank as BankModel;
|
||||
|
||||
/**
|
||||
* 物流公司管理控制器
|
||||
* Class Goods
|
||||
* @package app\store\controller
|
||||
*/
|
||||
class Bank extends Controller
|
||||
{
|
||||
/**
|
||||
* 银行账户列表
|
||||
* @param null $status
|
||||
* @param string $search_name
|
||||
* @return mixed
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function index($status = null, $search_name = '')
|
||||
{
|
||||
// 银行账户列表
|
||||
$model = new BankModel;
|
||||
$list = $model->getList($status, $search_name, 'all',false,15,$this->powerScope());
|
||||
return $this->fetch('index', compact('list'));
|
||||
}
|
||||
/**
|
||||
* 添加账户列表
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (!$this->request->isAjax()) {
|
||||
// 人员列表
|
||||
$admin = User::getAll();
|
||||
$user = $this->getUserInfo();
|
||||
return $this->fetch('add',compact('admin','user'));
|
||||
}
|
||||
$model = new BankModel;
|
||||
$bank_id = $model->add($this->postData('bank'));
|
||||
if ($bank_id !== false) {
|
||||
if($this->postData('bank')['status'] == 1) {
|
||||
$BankModel = new BankModel;
|
||||
$BankModel->setOtherStatus($bank_id,$this->postData('bank')['store_user_id']);
|
||||
}
|
||||
return $this->renderSuccess('添加成功', url('bank/index'));
|
||||
}
|
||||
return $this->renderError($model->getError() ?: '添加失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改账户列表状态
|
||||
* @param $bank_id
|
||||
* @param boolean $status
|
||||
* @return array
|
||||
*/
|
||||
public function state($bank_id, $status)
|
||||
{
|
||||
// 商品详情
|
||||
$model = BankModel::detail($bank_id);
|
||||
if (!$model->setStatus($status)) {
|
||||
return $this->renderError('操作失败');
|
||||
}
|
||||
if($status == 1) {
|
||||
$BankModel = new BankModel;
|
||||
$BankModel->setOtherStatus($bank_id,$model['store_user_id']);
|
||||
}
|
||||
return $this->renderSuccess('操作成功');
|
||||
}
|
||||
/**
|
||||
* 银行账户编辑
|
||||
* @param $bank_id
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function edit($bank_id)
|
||||
{
|
||||
// 物流公司详情
|
||||
$model = BankModel::detail($bank_id);
|
||||
if (!$this->request->isAjax()) {
|
||||
// 人员列表
|
||||
$admin = User::getAll();
|
||||
$user = $this->getUserInfo();
|
||||
return $this->fetch('edit', compact('model','admin','user'));
|
||||
}
|
||||
// 更新记录
|
||||
if ($model->edit($this->postData('bank'))) {
|
||||
if($this->postData('bank')['status'] == 1) {
|
||||
$BankModel = new BankModel;
|
||||
$BankModel->setOtherStatus($bank_id,$model['store_user_id']);
|
||||
}
|
||||
return $this->renderSuccess('更新成功', url('bank/index'));
|
||||
}
|
||||
$error = $model->getError() ?: '更新失败';
|
||||
return $this->renderError($error);
|
||||
}
|
||||
/**
|
||||
* 删除银行账户
|
||||
* @param $bank_id
|
||||
* @return array
|
||||
*/
|
||||
public function delete($bank_id)
|
||||
{
|
||||
// 商品详情
|
||||
$model = BankModel::detail($bank_id);
|
||||
if (!$model->setDelete($bank_id)) {
|
||||
return $this->renderError('删除失败');
|
||||
}
|
||||
return $this->renderSuccess('删除成功');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user