uid, 'wap'); Session::delete('loginUid', 'wap'); return JsonService::successful('已退出登录'); } /** * 获取获取个人中心菜单 */ public function getPersonalCenterMenu() { $store_brokerage_statu = SystemConfigService::get('store_brokerage_statu'); if ($store_brokerage_statu == 1) { if (isset($this->userInfo['is_promoter'])) $is_statu = $this->userInfo['is_promoter'] > 0 ? 1 : 0; else $is_statu = 0; } else if ($store_brokerage_statu == 2) { $is_statu = 1; } $is_write_off = isset($this->userInfo['is_write_off']) ? $this->userInfo['is_write_off'] : 0; $business = isset($this->userInfo['business']) ? $this->userInfo['business'] : 0; $Info['menuList']=Recommend::getPersonalCenterMenuList($is_statu, $is_write_off, $business, $this->uid); if($business){ //追加讲师信息 $Info['teacherInfo']=MerchantModel::where(['uid'=>$this->uid,'is_del'=>0])->find(); if(!$Info['teacherInfo']){ $Info['teacherInfo']= InstitutionModel::where(['uid'=>$this->uid,'is_del'=>0])->find(); $Info['teacherInfo']['the_type_status'] = 1; }else{ $Info['teacherInfo']['the_type_status'] = 0; } } if ($this->uid) { $kefuInfo = (new KefuModel)->where('uid', $this->uid)->find(); if ($kefuInfo && $kefuInfo->status) { $Info['menuList'][] = [ 'id' => 9999, 'icon' => 'http://cremb-zsff.oss-cn-beijing.aliyuncs.com/d17f1202103121654537270.png', 'title' => '客服工作台', 'type' => 12 ]; } } return JsonService::successful($Info); } /** * 题库模块 */ public function questionModule() { $question = GroupDataService::getData('question_bank_module', 2); return JsonService::successful($question); } /**我的赠送 * @return mixed */ public function my_gift() { return $this->fetch(); } /**我的报名 * @return mixed */ public function sign_list() { return $this->fetch(); } /**获取核销订单信息 * @param int $type * @param string $order_id * @return mixed|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function sign_order($type = 2, $order_id = '') { if ($type == 2 && !$this->userInfo['is_write_off']) $this->failed('您没有权限!','verify_activity'); $order = EventSignUp::setWhere()->where('order_id', $order_id)->find(); if (!$order) $this->failed('订单不存在','verify_activity'); if(!EventWriteOffUser::be(['event_id' => $order['activity_id'], 'uid' => $this->uid, 'is_del' => 0])) $this->failed('您没有该活动的核销权限','verify_activity'); $this->assign(['type' => $type, 'order_id' => $order_id]); return $this->fetch(); } public function sign_order_api($type = 2, $order_id = '') { if ($type == 2 && !$this->userInfo['is_write_off']) $this->failed('您没有权限!','verify_activity'); $order = EventSignUp::setWhere()->where('order_id', $order_id)->find(); if (!$order) $this->failed('订单不存在','verify_activity'); if(!EventWriteOffUser::be(['event_id' => $order['activity_id'], 'uid' => $this->uid, 'is_del' => 0])) $this->failed('您没有该活动的核销权限','verify_activity'); return JsonService::successful(['type' => $type, 'order_id' => $order_id]); } /**报名详情 * @param string $order_id * @return mixed|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function sign_my_order($order_id = '') { $this->assign(['order_id' => $order_id]); return $this->fetch('order_verify'); } /**我的信息 * @return mixed */ public function user_info() { return $this->fetch(); } public function verify_activity() { return $this->fetch(); } /** * 手机号验证 */ public function validate_code() { list($phone, $code,) = UtilService::getMore([ ['phone', ''], ['code', ''], ], $this->request, true); if (!$phone) return JsonService::fail('请输入手机号码'); if (!$code) return JsonService::fail('请输入验证码'); $code = md5('is_phone_code' . $code); if (!SmsCode::CheckCode($phone, $code)) return JsonService::fail('验证码验证失败'); SmsCode::setCodeInvalid($phone, $code); return JsonService::successful('验证成功'); } /** * 信息保存 */ public function save_user_info() { $data = UtilService::postMore([ ['avatar', ''], ['nickname', ''], ['grade_id', 0] ], $this->request); if ($data['nickname'] != strip_tags($data['nickname'])) { $data['nickname'] = htmlspecialchars($data['nickname']); } if (!$data['nickname']) return JsonService::fail('用户昵称不能为空'); if (User::update($data, ['uid' => $this->uid])) return JsonService::successful('保存成功'); else return JsonService::fail('保存失败'); } /** * 保存手机号码 * @return mixed|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function save_phone() { if ($this->request->isAjax()) { list($phone, $code, $type) = UtilService::getMore([ ['phone', ''], ['code', ''], ['type', 0], ], $this->request, true); if (!$phone) return JsonService::fail('请输入手机号码'); if (!$code) return JsonService::fail('请输入验证码'); $code = md5('is_phone_code' . $code); if (!SmsCode::CheckCode($phone, $code)) return JsonService::fail('验证码验证失败'); SmsCode::setCodeInvalid($phone, $code); $user = User::where(['phone' => $phone, 'is_h5user' => 0])->find(); if ($type && $user) { if ($user['uid'] == $this->uid) { return JsonService::fail('不能绑定相同手机号'); } else if ($user['uid'] != $this->uid) { return JsonService::fail('当前手机号码已绑定微信用户'); } } else if ($type == 0 && $user) { if ($user) return JsonService::fail('当前手机号码已绑定微信用户'); } //查找H5手机号码账户 $phoneUser = PhoneUser::where(['phone' => $phone])->find(); //H5页面有注册过 if ($phoneUser && $phoneUser['uid'] != $this->uid) { //检测当前用户是否是H5用户 if (User::where('uid', $phoneUser['uid'])->value('is_h5user')) { $res = User::setUserRelationInfos($phone, $phoneUser['uid'], $this->uid); if ($res === false) return JsonService::fail(User::getErrorInfo()); } } else if ($phoneUser && $phoneUser['uid'] == $this->uid) { return JsonService::fail('不能绑定相同手机号'); } if (!isset($res)) User::update(['phone' => $phone], ['uid' => $this->uid]); return JsonService::successful('绑定成功'); } else { $this->assign('user_phone', $this->userInfo['phone']); return $this->fetch(); } } public function base_data_api() { if (isset($this->userInfo['overdue_time'])) $overdue_time = date('Y-m-d', $this->userInfo['overdue_time']); else $overdue_time = 0; return JsonService::successful([ 'site_name' => SystemConfigService::get('site_name'), 'store_switch' => SystemConfigService::get('store_switch'), 'isyue' => SystemConfigService::get('balance_switch'), 'phone' => $this->phone, 'isWechat' => $this->isWechat, 'is_official_account_switch' => SystemConfigService::get('official_account_switch'), 'userInfo' => $this->userInfo, 'overdue_time' => $overdue_time ]); } /** * 个人中心 * @return mixed * @throws \think\Exception */ public function index() { $store_brokerage_statu = SystemConfigService::get('store_brokerage_statu'); if ($store_brokerage_statu == 1) { if (isset($this->userInfo['is_promoter'])) $is_statu = $this->userInfo['is_promoter'] > 0 ? 1 : 0; else $is_statu = 0; } else if ($store_brokerage_statu == 2) { $is_statu = 1; } if (isset($this->userInfo['overdue_time'])) $overdue_time = date('Y-m-d', $this->userInfo['overdue_time']); else $overdue_time = 0; $this->assign([ 'store_switch' => SystemConfigService::get('store_switch'), 'collectionNumber' => SpecialRelation::where('uid', $this->uid)->count(), 'recordNumber' => SpecialRecord::where('uid', $this->uid)->count(), 'overdue_time' => $overdue_time, 'is_statu' => $is_statu, ]); return $this->fetch(); } /**虚拟币明细 * @return mixed */ public function gold_coin() { $gold_name = SystemConfigService::get('gold_name');//虚拟币名称 $this->assign(compact('gold_name')); return $this->fetch('coin_detail'); } public function gold_coin_api() { return JsonService::successful([ 'gold_name' => SystemConfigService::get('gold_name') ]); } /**签到 * @return mixed */ public function sign_in() { $urls = SystemConfigService::get('site_url') . '/'; $gold_name = SystemConfigService::get('gold_name');//虚拟币名称 $gold_coin = SystemConfigService::get('single_gold_coin');//签到获得虚拟币 $signed = UserSign::checkUserSigned($this->uid);//今天是否签到 $sign_image = $urls . "uploads/" . "poster_sign_" . $this->uid . ".png"; $signCount = UserSign::userSignedCount($this->uid);//累记签到天数 $this->assign(compact('signed', 'signCount', 'gold_name', 'gold_coin', 'sign_image')); return $this->fetch(); } public function sign_in_api() { $urls = SystemConfigService::get('site_url') . '/'; $gold_name = SystemConfigService::get('gold_name'); //虚拟币名称 $gold_coin = SystemConfigService::get('single_gold_coin'); //签到获得虚拟币 $signed = UserSign::checkUserSigned($this->uid); //今天是否签到 $sign_image = $urls . "uploads/" . "poster_sign_" . $this->uid . ".png"; $signCount = UserSign::userSignedCount($this->uid); //累记签到天数 return JsonService::successful(compact('signed', 'signCount', 'gold_name', 'gold_coin', 'sign_image')); } /**签到明细 * @return mixed */ public function sign_in_list() { return $this->fetch(); } public function address_api() { $address = UserAddress::getUserValidAddressList($this->uid, 'id,real_name,phone,province,city,district,detail,is_default'); return JsonService::successful(compact("address")); } /**地址列表 * @return mixed */ public function address() { $address = UserAddress::getUserValidAddressList($this->uid, 'id,real_name,phone,province,city,district,detail,is_default'); $this->assign([ 'address' => json_encode($address) ]); return $this->fetch(); } /**修改或添加地址 * @param string $addressId * @return mixed * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function edit_address($addressId = '', $cartId = 0) { if ($addressId && is_numeric($addressId) && UserAddress::be(['is_del' => 0, 'id' => $addressId, 'uid' => $this->uid])) { $addressInfo = UserAddress::find($addressId)->toArray(); } else { $addressInfo = []; } $addressInfo = json_encode($addressInfo); $this->assign(compact('addressInfo', 'cartId')); return $this->fetch(); } public function edit_address_api($addressId = '', $cartId = 0) { if ($addressId && is_numeric($addressId) && UserAddress::be(['is_del' => 0, 'id' => $addressId, 'uid' => $this->uid])) { $addressInfo = UserAddress::find($addressId)->toArray(); } else { $addressInfo = []; } return JsonService::successful(compact('addressInfo', 'cartId')); } /**订单详情 * @param string $uni * @return mixed|void */ public function order($uni = '') { if (!$uni || !$order = StoreOrder::getUserOrderDetail($this->uid, $uni)) $this->failed('查询订单不存在!'); $this->assign([ 'gold_name' => SystemConfigService::get('gold_name'), 'order' => StoreOrder::tidyOrder($order, true) ]); return $this->fetch(); } public function orderPinkOld($uni = '') { if (!$uni || !$order = StoreOrder::getUserOrderDetail($this->uid, $uni)) $this->failed('查询订单不存在!'); $this->assign([ 'order' => StoreOrder::tidyOrder($order, true) ]); return $this->fetch('order'); } /**获取订单 * @param int $type * @param int $page * @param int $limit * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function get_order_list($type = -1, $page = 1, $limit = 10) { return JsonService::successful(StoreOrder::getSpecialOrderList((int)$type, (int)$page, (int)$limit, $this->uid)); } /**我的拼课订单 * @return mixed */ public function order_list() { return $this->fetch(); } /**申请退款 * @param string $order_id * @return mixed */ public function refund_apply($order_id = '') { if (!$order_id || !$order = StoreOrder::getUserOrderDetail($this->uid, $order_id)) $this->failed('查询订单不存在!'); $this->assign([ 'order' => StoreOrder::tidyOrder($order, true, true), 'order_id' => $order_id ]); return $this->fetch(); } public function refund_apply_api($order_id = '') { if (!$order_id || !$order = StoreOrder::getUserOrderDetail($this->uid, $order_id)) JsonService::fail('查询订单不存在!'); return JsonService::successful([ 'order' => StoreOrder::tidyOrder($order, true, true), 'order_id' => $order_id ]); } /**评论页面 * @param string $unique * @return mixed|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function order_reply($unique = '') { if (!$unique || !StoreOrderCartInfo::be(['unique' => $unique]) || !($cartInfo = StoreOrderCartInfo::where('unique', $unique)->find())) $this->failed('评价产品不存在!'); $this->assign(['cartInfo' => $cartInfo]); return $this->fetch(); } public function order_reply_api($unique = '') { if (!$unique || !StoreOrderCartInfo::be(['unique' => $unique]) || !($cartInfo = StoreOrderCartInfo::where('unique', $unique)->find())) JsonService::fail('评价产品不存在!'); return JsonService::successful(['cartInfo' => $cartInfo]); } /**物流查询 * @param string $uni * @return mixed|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function express($uni = '') { if (!$uni || !($order = StoreOrder::getUserOrderDetail($this->uid, $uni))) $this->failed('查询订单不存在!'); if ($order['delivery_type'] != 'express' || !$order['delivery_id']) $this->failed('该订单不存在快递单号!'); $this->assign(['order' => StoreOrder::tidyOrder($order, true, true)]); return $this->fetch(); } public function express_api($uni = '') { if (!$uni || !($order = StoreOrder::getUserOrderDetail($this->uid, $uni))) JsonService::fail("查询订单不存在!"); if ($order['delivery_type'] != 'express' || !$order['delivery_id']) JsonService::fail('该订单不存在快递单号!'); return JsonService::successful([ 'order' => StoreOrder::tidyOrder($order, true, true) ]); } public function commission() { $uid = (int)Request::instance()->get('uid', 0); if (!$uid) $this->failed('用户不存在!'); $this->assign(['uid' => $uid]); return $this->fetch(); } /** * 关于我们 * @return mixed */ public function about_us() { $this->assign([ 'content' => get_config_content('about_us'), 'title' => '关于我们' ]); return $this->fetch('index/agree'); } public function about_us_api() { return JsonService::successful([ 'content' => get_config_content('about_us'), ]); } public function getUserGoldBill() { $user_info = $this->userInfo; list($page, $limit) = UtilService::getMore([ ['page', 1], ['limit', 20], ], $this->request, true); $where['uid'] = $user_info['uid']; $where['category'] = "gold_num"; return JsonService::successful(UserBill::getUserGoldBill($where, $page, $limit)); } /** * 余额明细 */ public function bill_detail() { return $this->fetch(); } /** * 我的关注 */ public function follow_lecturer() { return $this->fetch(); } }