getUserId(); $info = UserModel::get($user_id); $res = $info->delete(); $this->success('注销成功', $res); } /** * 用户信息 */ public function getInfo() { $user_id = $this->getUserId(); $info = UserModel::get($user_id); $info->openid = Db::name('third_party_user')->where('user_id', $user_id)->value('openid'); $info->js; if ($info['user_type'] == 3) { $info['js']['is_work'] = 0; if ($info['js']->js_time) { $week = date('w', time()); if (in_array($week, $info['js']->js_time->weeks)) { foreach ($info['js']->js_time->times as $vo) { if (strtotime($vo['js_end_time']) >= strtotime(date('H:i'))) { //在此处判断一下是否已经接单 $is_work = Db::name('js_order')->where('jiedan_js_id', $info['js']['id'])->where('status', 6)->find(); if (empty($is_work)) { $info['js']['is_work'] = 1; } else { $info['js']['is_work'] = 2; } } } } unset($info['js']->js_time); } } $info->is_agency = 0; if ($info->agency_id) { $info->is_agency = 1; $info->agency_id = 1; } else { $info->agency_id = 0; } $info->distributor_status = DistributorLogModel::where('user_id', $user_id)->value('chuli_status'); $info->fenxiaoshang = DistributorModel::get($info->distributor_id)['name']; unset($info['user_pass']); $this->success('ok', $info); } /** * 申请成为技师 */ public function applyJsPost() { $user_id = $this->getUserId(); $user_info = UserModel::get($user_id); $user_type = $user_info['user_type']; if ($user_type != 3) { $this->error('请先去师傅端注册!'); } $data['user_id'] = $user_id; $data['name'] = $this->request->param('name'); $phone = $this->request->param('phone'); $data['phone'] = $phone ?: $user_info['mobile']; // if (!$data['phone']) { // $this->error('请填写联系电话不可为空!'); // } $data['is_real_time'] = $this->request->param('is_real_time'); $data['is_make'] = $this->request->param('is_make'); $data['jianjie'] = $this->request->param('jianjie'); $data['sex'] = $this->request->param('sex'); $data['apply_num'] = 1; $data['identity'] = $this->request->param('identity/a'); $data['certificates'] = $this->request->param('certificates/a'); $data['pictures'] = $this->request->param('pictures/a'); $work = $this->request->param('work/a'); if (isset($work)) { $data['work'] = $work; } $JsModel = new JsModel(); // $js_id = $JsModel::where('phone',$data['phone'])->value('id'); // if($js_id){ // $this->error('此号码已认证,请到我的设置中修改信息!'); // } $info = $JsModel::where('user_id', $user_id)->find(); $JsTimeModel = new JsTimeModel(); if ($info) { $js_time['js_id'] = $info['id']; $js_time_info = Db::name('js_time')->where('js_id', $js_time['js_id'])->find(); if (!$js_time_info) { $js_time['times'] = [0 => ['js_start_time' => '00:00', 'js_end_time' => '23:59']]; $js_time['weeks'] = ['1', '2', '3', '4', '5', '6', '0']; $JsTimeModel->allowField(true)->isUpdate(false)->save($js_time); } $data['js_status'] = 0; $JsModel->allowField(true)->isUpdate(true)->save($data, ['id' => $info['id']]); $this->success('修改成功'); } else { $JsModel->applyJsPost($data); $js_time['js_id'] = $JsModel->id; $js_time_info = Db::name('js_time')->where('js_id', $js_time['js_id'])->find(); if (!$js_time_info) { $js_time['times'] = [0 => ['js_start_time' => '00:00', 'js_end_time' => '23:59']]; $js_time['weeks'] = ['1', '2', '3', '4', '5', '6', '0']; $JsTimeModel->allowField(true)->isUpdate(false)->save($js_time); } $this->success('申请成功'); } } /** * 申请项目 */ public function applyProjectPost() { $user_id = $this->getUserId(); $project_id = $this->request->param('project_id'); if (!$project_id) { $this->error('缺少project_id参数!'); } $user_type = UserModel::get($user_id)['user_type']; if ($user_type != 3) { $this->error('请先去师傅端注册!'); } $JsModel = new JsModel(); $js_id = $JsModel::where('user_id', $user_id)->value('id'); $res = $JsModel->applyProjectPost($js_id, $project_id); if ($res) { $this->success('申请成功'); } else { $this->error('无需重复申请!'); } } public function getDiscount() { $where = []; $status = $this->request->param('status'); if ($status || $status === '0') { $where['status'] = $status; } $where['user_id'] = $this->getUserId(); $UserDiscountModel = new UserDiscountModel(); $list = $UserDiscountModel->getList($where); $this->success('ok', $list); } /** * 用户修改信息 */ public function editInfo() { $user_id = $this->getUserId(); $data['avatar'] = $this->request->param('avatar'); $data['user_nickname'] = $this->request->param('user_nickname'); $UserMolde = new UserModel(); $UserMolde->allowField(true)->isUpdate(true)->save($data, ['id' => $user_id]); // $JsModel = new JsModel(); // $JsModel->allowField(true)->isUpdate(true)->save($data,['user_id'=>$user_id]); $this->success('修改成功'); } public function addIdea() { $data['user_id'] = $this->getUserId(); $data['idea'] = $this->request->param('idea'); $data['add_time'] = time(); Db::name('idea')->insert($data); $this->success('提交成功'); } public function getxiaji() { $page = $this->request->param('page', 1); $type = $this->request->param('type', 1); $userModel = new UserModel(); $user_id = $this->getUserId(); $fied = 'parent_id'; if ($type == 2) { $fied = 'parent_id1'; } $list = $userModel::where($fied, $user_id)->order('id', 'desc')->page($page, 20)->field('id,mobile,user_nickname,create_time')->select()->each(function ($list) { $list['mobile'] = preg_replace("/(\d{3})\d{4}(\d{4})/", "\$1****\$2", $list['mobile']); return $list; }); $this->success('ok', $list); } public function getMoneyLog() { $page = $this->request->param('page', 1); $list = Db::name('user_money_log')->where('user_id', $this->getUserId())->order('id', 'desc')->page($page, 20)->select(); $this->success('ok', $list); } /** * @throws \think\Exception * @throws \think\exception\PDOException *获取二维码 */ public function geterweima() { $user_id = $this->getUserId(); $erweima = UserModel::get($user_id)['erweima']; $referral = UserModel::get($user_id)['referral']; $value = 'http://' . $_SERVER['SERVER_NAME'] . '/h5/#/pages/zhuce/zhuce?yqm=' . $referral; if (!$erweima) { $res = qeCode($value, $this->request->controller(), $user_id); UserModel::where('id', $user_id)->update(['erweima' => $res]); $this->success('ok', ['erweima' => cmf_get_image_preview_url($res), 'url' => $value, 'referral' => $referral]); } else { $this->success('ok', ['erweima' => cmf_get_image_preview_url($erweima), 'url' => $value, 'referral' => $referral]); } } /** * @throws \think\Exception * 提现 */ public function addTx() { $data['user_id'] = $this->getUserId(); $data['tx_type'] = $this->request->param('tx_type'); $data['money'] = $this->request->param('money'); $data['zfb_name'] = $this->request->param('zfb_name'); $data['zfb_action'] = $this->request->param('zfb_action'); $data['order_sn'] = cmf_get_order_sn(); $user_balance = UserModel::get($this->getUserId())['balance']; if ($data['tx_type'] == 1) { $wx_openid = Db::name('third_party_user')->where('user_id', $data['user_id'])->where('union_id', '微信平台')->value('openid'); if (!$wx_openid) { $this->error('请先绑定wx_openid!'); } } else { $validate = new Validate([ 'zfb_name' => 'require', 'zfb_action' => 'require', ]); $validate->message([ 'zfb_name.require' => '支付宝姓名不可为空!', 'zfb_action.require' => '支付宝账号不可为空!', ]); if (!$validate->check($data)) { $this->error($validate->getError()); } } if ($data['money'] > $user_balance) { $this->error('余额不足!'); } if ($data['money'] < 0.01) { $this->error('提现余额不可小于0.01!'); } UserModel::where('id', $data['user_id'])->setDec('balance', $data['money']); $UserTxModel = new UserTxModel(); $UserTxModel->allowField(true)->isUpdate(false)->save($data); $log['user_id'] = $data['user_id']; $log['money'] = -$data['money']; $log['yue'] = $user_balance - $data['money']; $log['type'] = 99; $log['remark'] = '余额提现'; $log['add_time'] = time(); $log['obj_id'] = $UserTxModel->id; Db::name('user_money_log')->insert($log); $this->success('申请成功'); } /** * 申请代理 */ public function agencyapply() { $data['name'] = $this->request->param('name'); $data['mobile'] = $this->request->param('mobile'); $data['district'] = $this->request->param('district'); $data['add_time'] = time(); $data['user_id'] = $this->getUserId(); Db::name('user_apply_agency')->insert($data); $this->success('ok', '申请成功'); } }