getList(false); $model = new UserModel; $list = $model->getList($gender, $search); return View::fetch('index', compact('list', 'shop', 'gender', 'search')); } /** * 用户列表 * @param string $gender * @param string $search * @return string * @throws \think\db\exception\DbException */ public function wx_index($gender = 'all', $search = '') { $list = \think\facade\Db::name('user_wx')->where([])->field('id,nickname,headimgurl,is_role,create_time')->select()->toArray(); foreach ($list as $key => $value) { $list[$key]['create_time'] = date('Y-m-d H:i:s'); $list[$key]['is_role'] = $value['is_role'] == 1 ? '核销员' : '用户'; } View::assign('list', $list); return View::fetch('wx_index'); } /** * 用户充值 *$recharge 接收表单数据(数组) *$source 0为充值余额,1为充值积分 */ public function recharge() { if ($this->request->isPost()) { $model = new RecordModel; $data = $this->postData('data'); if ($this->shop_mode == 10) { $data['shop_id'] = $this->shop_id; } if ($model->add($data)) { return $this->renderSuccess('添加成功', url('food.user/index')); } $error = $model->getError() ?: '添加失败'; return $this->renderError($error); } return redirect(url('food.user/index')); } /** * 用户充值 *$recharge 接收表单数据(数组) *$source 0为充值余额,1为充值积分 */ public function recharge1() { if ($this->request->isPost()) { $data = $this->request->post(); $info = \think\facade\Db::name('user_wx')->where(['id' => $data['id']])->update(['is_role' => $data['is_role']]); if ($info) { return $this->renderSuccess('成功', url('food.user/wx_index')); } return $this->renderError('失败'); } return redirect(url('food.user/wx_index')); } }