|
@@ -2,9 +2,13 @@
|
|
|
|
|
|
|
|
namespace app\admin\controller\user;
|
|
namespace app\admin\controller\user;
|
|
|
|
|
|
|
|
|
|
+use think\Db;
|
|
|
|
|
+use Exception;
|
|
|
|
|
+use app\common\model\Moneylog;
|
|
|
|
|
+use think\exception\DbException;
|
|
|
|
|
+use think\exception\PDOException;
|
|
|
use app\common\controller\Backend;
|
|
use app\common\controller\Backend;
|
|
|
-use app\common\library\Auth;
|
|
|
|
|
-
|
|
|
|
|
|
|
+use think\exception\ValidateException;
|
|
|
/**
|
|
/**
|
|
|
* 会员管理
|
|
* 会员管理
|
|
|
*
|
|
*
|
|
@@ -14,7 +18,7 @@ class User extends Backend
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
protected $relationSearch = true;
|
|
protected $relationSearch = true;
|
|
|
- protected $searchFields = 'id,username,nickname';
|
|
|
|
|
|
|
+ protected $searchFields = 'id,mobile';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @var \app\admin\model\User
|
|
* @var \app\admin\model\User
|
|
@@ -26,6 +30,7 @@ class User extends Backend
|
|
|
parent::_initialize();
|
|
parent::_initialize();
|
|
|
$this->model = model('User');
|
|
$this->model = model('User');
|
|
|
$this->assign('statusList', $this->model->getStatusList());
|
|
$this->assign('statusList', $this->model->getStatusList());
|
|
|
|
|
+ $this->assign('typeList', $this->model->getTypeList());
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -58,50 +63,231 @@ class User extends Backend
|
|
|
return $this->view->fetch();
|
|
return $this->view->fetch();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * 添加
|
|
|
|
|
|
|
+ * 余额 public function balance($ids = null)
|
|
|
|
|
+ * @param $ids
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ * @throws DbException
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
*/
|
|
*/
|
|
|
- public function add()
|
|
|
|
|
|
|
+ public function balance($ids = null)
|
|
|
{
|
|
{
|
|
|
- if ($this->request->isPost()) {
|
|
|
|
|
- $this->token();
|
|
|
|
|
|
|
+ $row = $this->model->get($ids);
|
|
|
|
|
+ if (!$row) {
|
|
|
|
|
+ $this->error(__('No Results were found'));
|
|
|
|
|
+ }
|
|
|
|
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
|
|
+ if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
|
|
+ $this->error(__('You have no permission'));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (false === $this->request->isPost()) {
|
|
|
|
|
+ $this->view->assign('row', $row);
|
|
|
|
|
+ return $this->view->fetch();
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = $this->request->post('row/a');
|
|
|
|
|
+ if (empty($params)) {
|
|
|
|
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
}
|
|
}
|
|
|
- return parent::add();
|
|
|
|
|
|
|
+ $params = $this->preExcludeFields($params);
|
|
|
|
|
+ $result = false;
|
|
|
|
|
+ Db::startTrans();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $balance = build_amount_compute($params['type'], $params['amount'], $row->balance);
|
|
|
|
|
+ //操作记录
|
|
|
|
|
+ Moneylog::create(['user_id'=> $params['id'],
|
|
|
|
|
+ 'from_id'=> $this->auth->id,
|
|
|
|
|
+ 'amount'=> $params['amount'],
|
|
|
|
|
+ 'balance'=> $balance
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $result = $row->allowField(true)->save(['balance'=>$balance]);
|
|
|
|
|
+ Db::commit();
|
|
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
|
|
+ Db::rollback();
|
|
|
|
|
+ $this->error($e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (false === $result) {
|
|
|
|
|
+ $this->error(__('No rows were updated'));
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 编辑
|
|
|
|
|
|
|
+ * 卡单
|
|
|
|
|
+ * @param $ids
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ * @throws DbException
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
*/
|
|
*/
|
|
|
- public function edit($ids = null)
|
|
|
|
|
|
|
+ public function cardslip($ids = null)
|
|
|
{
|
|
{
|
|
|
- if ($this->request->isPost()) {
|
|
|
|
|
- $this->token();
|
|
|
|
|
|
|
+ $row = $this->model->get($ids);
|
|
|
|
|
+ if (!$row) {
|
|
|
|
|
+ $this->error(__('No Results were found'));
|
|
|
|
|
+ }
|
|
|
|
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
|
|
+ if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
|
|
+ $this->error(__('You have no permission'));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (false === $this->request->isPost()) {
|
|
|
|
|
+
|
|
|
|
|
+ $task = json_decode($row->linit_task, true);
|
|
|
|
|
+ $row->which_start = $task['which_start']??'';
|
|
|
|
|
+ $row->min_amount = $task['min_amount']??'';
|
|
|
|
|
+ $row->max_amount = $task['max_amount']??'';
|
|
|
|
|
+ $row->income_multiple= $task['income_multiple']??'';
|
|
|
|
|
+ $this->view->assign('row', $row);
|
|
|
|
|
+ return $this->view->fetch();
|
|
|
}
|
|
}
|
|
|
|
|
+ $params = $this->request->post('row/a');
|
|
|
|
|
+ if (empty($params)) {
|
|
|
|
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = $this->preExcludeFields($params);
|
|
|
|
|
+ $result = false;
|
|
|
|
|
+ Db::startTrans();
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ unset($params['id']);
|
|
|
|
|
+ $result = $row->allowField(true)->save(['linit_task'=>json_encode($params)]);
|
|
|
|
|
+ Db::commit();
|
|
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
|
|
+ Db::rollback();
|
|
|
|
|
+ $this->error($e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (false === $result) {
|
|
|
|
|
+ $this->error(__('No rows were updated'));
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 收款
|
|
|
|
|
+ * @param $ids
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ * @throws DbException
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function collection($ids = null)
|
|
|
|
|
+ {
|
|
|
$row = $this->model->get($ids);
|
|
$row = $this->model->get($ids);
|
|
|
- $this->modelValidate = true;
|
|
|
|
|
if (!$row) {
|
|
if (!$row) {
|
|
|
$this->error(__('No Results were found'));
|
|
$this->error(__('No Results were found'));
|
|
|
}
|
|
}
|
|
|
- $this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
|
|
|
|
|
- return parent::edit($ids);
|
|
|
|
|
|
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
|
|
+ if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
|
|
+ $this->error(__('You have no permission'));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (false === $this->request->isPost()) {
|
|
|
|
|
+ $bank = json_decode($row->bank_info, true);
|
|
|
|
|
+ $row->real_name = $bank['real_name']??'';
|
|
|
|
|
+ $row->bank_name = $bank['bank_name']??'';
|
|
|
|
|
+ $row->bank_card = $bank['bank_card']??'';
|
|
|
|
|
+ $this->view->assign('row', $row);
|
|
|
|
|
+ return $this->view->fetch();
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = $this->request->post('row/a');
|
|
|
|
|
+ if (empty($params)) {
|
|
|
|
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = $this->preExcludeFields($params);
|
|
|
|
|
+ $result = false;
|
|
|
|
|
+ Db::startTrans();
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ $addr = $params['usdt_address'];
|
|
|
|
|
+ unset($params['id'],$params['usdt_address']);
|
|
|
|
|
+ $result = $row->allowField(true)->save(['usdt_address'=> $addr, 'bank_info'=>json_encode($params)]);
|
|
|
|
|
+ Db::commit();
|
|
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
|
|
+ Db::rollback();
|
|
|
|
|
+ $this->error($e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (false === $result) {
|
|
|
|
|
+ $this->error(__('No rows were updated'));
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * 删除
|
|
|
|
|
|
|
+ * 清0
|
|
|
|
|
+ * @param $ids
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ * @throws DbException
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
*/
|
|
*/
|
|
|
- public function del($ids = "")
|
|
|
|
|
|
|
+ public function clear($ids = null)
|
|
|
{
|
|
{
|
|
|
- if (!$this->request->isPost()) {
|
|
|
|
|
- $this->error(__("Invalid parameters"));
|
|
|
|
|
|
|
+ $row = $this->model->get($ids);
|
|
|
|
|
+ if (!$row) {
|
|
|
|
|
+ $this->error(__('No Results were found'));
|
|
|
|
|
+ }
|
|
|
|
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
|
|
+ if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
|
|
+ $this->error(__('You have no permission'));
|
|
|
|
|
+ }
|
|
|
|
|
+ $result = false;
|
|
|
|
|
+ try {
|
|
|
|
|
+ $result = $row->allowField(true)->save(['task_num'=>0]);
|
|
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
|
|
+ $this->error($e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (false === $result) {
|
|
|
|
|
+ $this->error(__('No rows were updated'));
|
|
|
}
|
|
}
|
|
|
- $ids = $ids ? $ids : $this->request->post("ids");
|
|
|
|
|
|
|
+ $this->success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 编辑
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param $ids
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ * @throws DbException
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ public function edit($ids = null)
|
|
|
|
|
+ {
|
|
|
$row = $this->model->get($ids);
|
|
$row = $this->model->get($ids);
|
|
|
- $this->modelValidate = true;
|
|
|
|
|
if (!$row) {
|
|
if (!$row) {
|
|
|
$this->error(__('No Results were found'));
|
|
$this->error(__('No Results were found'));
|
|
|
}
|
|
}
|
|
|
- Auth::instance()->delete($row['id']);
|
|
|
|
|
|
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
|
|
+ if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
|
|
+ $this->error(__('You have no permission'));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (false === $this->request->isPost()) {
|
|
|
|
|
+ $this->view->assign('row', $row);
|
|
|
|
|
+ return $this->view->fetch();
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = $this->request->post('row/a');
|
|
|
|
|
+ if (empty($params)) {
|
|
|
|
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = $this->preExcludeFields($params);
|
|
|
|
|
+ $result = false;
|
|
|
|
|
+ Db::startTrans();
|
|
|
|
|
+ try {
|
|
|
|
|
+ //是否采用模型验证
|
|
|
|
|
+ if ($this->modelValidate) {
|
|
|
|
|
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
|
|
|
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
|
|
+ $row->validateFailException()->validate($validate);
|
|
|
|
|
+ }
|
|
|
|
|
+ $result = $row->allowField(true)->save($params);
|
|
|
|
|
+ Db::commit();
|
|
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
|
|
+ Db::rollback();
|
|
|
|
|
+ $this->error($e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (false === $result) {
|
|
|
|
|
+ $this->error(__('No rows were updated'));
|
|
|
|
|
+ }
|
|
|
$this->success();
|
|
$this->success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|