123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace app\admin\controller\user;
- use app\common\controller\Backend;
- use think\Db;
- /**
- * 会员管理
- *
- * @icon fa fa-user
- */
- class User extends Backend
- {
- /**
- * User模型对象
- * @var \app\admin\model\User
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\User;
- $this->view->assign("statusList", $this->model->getStatusList());
- }
- /**
- * 查看
- */
- public function index()
- {
- //当前是否为关联查询
- $this->relationSearch = false;
- //设置过滤方法
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = $this->model
- ->with(['wallet'])
- ->where($where)
- ->order($sort, $order)
- ->paginate($limit);
- foreach ($list as $row) {
- $row->getRelation('wallet')->visible(['score']);
- }
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
- /**
- * 增加积分
- */
- public function scoreadd(){
- $id = input('id',0);
- if($this->request->isAjax()){
- $score = input('score',0);
- $remark = input('remark','');
- if($score == 0){
- $this->error('积分不能为0');
- }
- if($score > 0){
- $logtype = 1;
- }else{
- $logtype = 2;
- }
- Db::startTrans();
- $rs_wallet = model('wallet')->lockChangeAccountRemain($id,'score',$score,$logtype,$remark,'admin',$this->auth->id);
- if($rs_wallet['status'] == false){
- Db::rollback();
- $this->error($rs_wallet['msg']);
- }
- Db::commit();
- $this->success('操作完成');
- }
- $row = Db::name('user')->where('id',$id)->find();
- $this->assign('row',$row);
- $this->assign('id',$id);
- return $this->view->fetch();
- }
- }
|