123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- <?php
- /**
- *
- * User: anyluck
- * Date: 2020/6/3
- * Time: 13:13
- */
- namespace app\web\controller;
- use app\common\controller\Orde;
- use app\common\model\About;
- use app\common\model\Bond;
- use app\common\model\BondFinance;
- use app\common\model\CommissionFinance;
- use app\common\model\Feedback;
- use app\common\model\GeneralFinance;
- use app\common\model\GeneralTransfer;
- use app\common\model\Message;
- use app\common\model\Notice;
- use app\common\model\Problem;
- use app\common\model\System;
- use app\common\model\User;
- use app\common\model\UserLevel;
- use app\common\model\UserMessage;
- use app\common\model\VendibilityFinance;
- use app\web\model\Team;
- use app\web\model\Tripartite;
- use think\facade\Db;
- class My extends Base
- {
- // todo 个人中心
- // 获取个人信息
- public function index()
- {
- // 给用户加活跃度
- $where["id"]=$this->user_id;
- $update["update_time"]=time();
- User::update($update,$where);
- json_result(200, "", $this->user);
- }
- // 更新头像
- public function update_image()
- {
- $image = input("image");
- if (!$image) json_result(400, "请上传图片路径");
- $where["id"] = $this->user_id;
- $update["image"] = $image;
- User::update($update, $where);
- json_result(200, "设置成功");
- }
- // 更新用户名
- public function update_name()
- {
- $name = input("name");
- $where["id"] = $this->user_id;
- $update["name"] = $name;
- User::update($update, $where);
- json_result(200, "设置成功");
- }
- // 更新手机号码
- public function update_phone()
- {
- $phone = input("phone");
- if (!$phone) json_result(400, "请输入手机号");
- $code = input("code");
- if (!$code) json_result(400, "请输入验证码");
- $rest = Tripartite::push_code($phone, 0);
- if ($rest != $code) {
- json_result(400, "验证码错误");
- }
- $where["id"] = $this->user_id;
- $update["phone"] = $phone;
- User::update($update, $where);
- json_result(200, "设置成功");
- }
- // 更新邮箱
- public function update_mail()
- {
- $phone = input("mail");
- if (!$phone) json_result(400, "请输入邮箱");
- $code = input("code");
- if (!$code) json_result(400, "请输入验证码");
- $rest = Tripartite::push_code($phone, 1);
- if ($rest != $code) {
- json_result(400, "验证码错误");
- }
- $where["id"] = $this->user_id;
- $update["mail"] = $phone;
- User::update($update, $where);
- json_result(200, "设置成功");
- }
- // 显示收账信息
- public function receivable_show()
- {
- $where["user_id"] = $this->user_id;
- $user_message = UserMessage::where($where)->find();
- if (!$user_message) {// 没有数据就添加数据
- $add["user_id"] = $this->user_id;
- UserMessage::create($add);
- $user_message = UserMessage::where($where)->find();
- }
- json_result(200,"",$user_message);
- }
- // 修改收账信息
- public function update_receivable()
- {
- $id = input("id");
- if (!$id) json_result(400, "请上传更新id");
- $data["phone"] = input("phone");
- $data["name"] = input("name");
- $data["bank_name"] = input("bank_name");
- $data["bank_number"] = input("bank_number");
- $data["bank_branch"] = input("bank_branch");
- $data["ali_pay"] = input("ali_pay");
- $data["wx_pay"] = input("wx_pay");
- $data["ali_pay_image"] = input("ali_pay_image");
- $data["wx_pay_image"] = input("wx_pay_image");
- $where["id"] = $id;
- UserMessage::update($data, $where);
- json_result(200, "操作成功");
- }
- // 消息 获取最新的三条数据
- public function notice()
- {
- $notice = Message::where(["type" => 0,"user_id"=>$this->user_id])->order("id desc")->find(); // 公告
- $message_jiaoyi = Message::where(["type" => 2,"user_id"=>$this->user_id])->order("id desc")->find();// 交易
- $message_zijin = Message::where(["type" => 1,"user_id"=>$this->user_id])->order("id desc")->find();// 资金
- $data["notice"] = $notice?:new \ArrayObject();
- $data["message_jiaoyi"] = $message_jiaoyi?:new \ArrayObject();
- $data["message_zijin"] = $message_zijin?:new \ArrayObject();
- json_result(200, "", $data);
- }
- // 消息列表
- public function notice_list()
- {
- $type = input("type") ?: 0;
- $page = input("page") ?: 1;
- $limit = input("limit") ?: 10;
- $where["type"] = $type;
- $where["user_id"] = $this->user_id;
- $list = Message::where($where)->order("id desc,status asc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
- $item["add_time"] = date("Y-m-d H:i", $item["add_time"]);
- return $item;
- });
- json_result(200, "", $list);
- }
- // 更新消息是否已读
- public function notice_status()
- {
- $id = input("id");
- $where["id"] = $id;
- $update["status"] = 1;
- Message::update($update, $where);
- json_result(200);
- }
- // 反馈意见
- public function feedback()
- {
- $content = input("content");
- $image = input("image");
- $add["user_id"] = $this->user_id;
- $add["content"] = $content;
- $add["image"] = $image;
- $add["add_time"] = time();
- Feedback::create($add);
- json_result(200, "反馈成功");
- }
- // 常见问题
- public function problem()
- {
- $page = input("page") ?: 1;
- $limit = input("limit") ?: 10;
- $list = Problem::order("id desc")->field("id,name")->paginate(['list_rows' => $limit, 'page' => $page]);
- json_result(200, "", $list);
- }
- // 常见问题详情
- public function problem_show()
- {
- $id = input("id");
- $where["id"] = $id;
- $data = Problem::where($where)->find();
- json_result(200, "", $data);
- }
- // 修改密码
- public function update_pwd()
- {
- // $phone=input("phone");// 系统内置手机号或邮件
- $yuan = input("ypwd");
- if (!$yuan) json_result(400, "请输入原密码");
- $pwd = input("pwd");
- if (!$pwd) json_result(400, "请输入新密码");
- $where["id"] = $this->user_id;
- $update["pwd"] = password_hash($pwd, PASSWORD_DEFAULT);;
- $user = User::where($where)->find();
- // 查看原密码是否错误
- if (!password_verify($yuan, $user->pwd)) {
- json_result(400, "原密码错误");
- }
- // if ($user->pwd == $update["pwd"]) {
- // json_result(400, "原密码不能和新密码一样");
- // }
- User::update($update, $where);
- json_result(200, "设置成功");
- }
- // 关于我们
- public function about()
- {
- $where["id"] = 1;
- $about = About::where($where)->find();
- json_result(200, "", $about);
- }
- // 我的推广显示页面
- public function extension()
- {
- $where["pid"] = $this->user_id;
- $count = User::where($where)->count();
- $data["push"] = $count;
- $data["team"] = Team::all_tem($this->user_id);
- json_result(200, "", $data);
- }
- // 直推列表
- public function extension_list()
- {
- $pid = input("pid");
- $page = input("page") ?: 1;
- $limit = input("limit") ?: 10;
- $where = [];
- if ($pid) {
- $where["pid"] = $pid;
- } else {
- $where["pid"] = $this->user_id;
- }
- $list = User::where($where)->order("id desc")->field("id,image,phone,name,mail,add_time")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
- // 统计人数
- $where["pid"] = $item["id"];
- $count = User::where($where)->count();
- $item["team"] = $count;
- if ($item["add_time"]) {
- $item["add_time"] = date("Y-m-d H:i", $item["add_time"]);
- }
- return $item;
- });
- json_result(200,"",$list);
- }
- // 可售额度
- public function vendibility_list()
- {//lm_vendibility_finance
- $page = input("page") ?: 1;
- $limit = input("limit") ?: 10;
- $where["user_id"]=$this->user_id;
- $list = VendibilityFinance::where($where)->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
- if ($item["add_time"]) {
- $item["add_time"] = date("Y-m-d H:i", $item["add_time"]);
- }
- return $item;
- });
- json_result(200,"",$list);
- }
- // 保证金交易明细
- public function bond_list()
- {
- $page = input("page") ?: 1;
- $limit = input("limit") ?: 10;
- $where["user_id"]=$this->user_id;
- $list = BondFinance::where($where)->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
- if ($item["add_time"]) {
- $item["add_time"] = date("Y-m-d H:i", $item["add_time"]);
- }
- return $item;
- });
- json_result(200,"",$list);
- }
- //佣金记录
- public function commission_list()
- {
- $page = input("page") ?: 1;
- $limit = input("limit") ?: 10;
- $where["user_id"]=$this->user_id;
- $list = CommissionFinance::where($where)->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) {
- if ($item["add_time"]) {
- $item["add_time"] = date("Y-m-d H:i", $item["add_time"]);
- }
- return $item;
- });
- json_result(200,"",$list);
- }
- // 充值和提现保证金
- public function bond()
- {
- $money=input("money");if (!$money)json_result(400,"请输入提现金额");
- $type=input("type")?:0;//0 充值 1 提现
- // 直接处理转账成功
- if ($type==0){
- if ($this->user->money<$money){
- json_result(400,"当前账号通证余额不足");
- }
- }else{
- // 查看账号余额
- if ($this->user->ensure_money<$money){
- json_result(400,"账号保证金不足");
- }
- }
- // 直接转账操作
- Orde::bond_transfer($this->user,$this->user_id,$money,$this->user->ensure_money,$type);
- // 添加记录
- $add["money"]=$money;
- $add["type"]=$type;
- $add["status"]=0;
- $add["add_time"]=time();
- $add["user_id"]=$this->user_id;
- Bond::create($add);
- json_result(200,"申请成功");
- }
- // 通证充值
- public function general()
- {
- $money=input("money");
- $actual_money=input("actual_money");
- $charge_money=input("charge_money");
- $add["money"]=$money;
- $add["user_id"]=$this->user_id;
- $add["actual_money"]=$actual_money;
- $add["charge_money"]=$charge_money;
- $add["status"]=0;
- $add["add_time"]=time();
- GeneralFinance::create($add);
- // 添加转账操作
- json_result(200,"申请成功");
- }
- //通证转账
- public function general_transfer()
- {
- $account=input("account");
- $money=input("money");
- if ($money>$this->user->money){
- json_result(400,"账号通证余额不足");
- }
- $where["phone|mail"]=$account;
- $user=User::where($where)->find();
- if (!$user){
- json_result(200,"账号不存在");
- }
- // 查找无限级
- $team=Team::father($this->user_id,$user->id);
- if (!$team){
- json_result(400,"非同一个直推链不能转账");
- }
- $add["user_id"]=$this->user_id;
- $add["puser_id"]=$user->id;
- $add["account"]=$account;
- $add["money"]=$money;
- $add["status"]=0;
- $add["add_time"]=time();
- GeneralTransfer::create($add);
- $jmoney=$this->user["money"]-$money;
- $name=$this->user["name"];
- Orde::transfer($this->user_id,$user->id,$money,$jmoney,$name);
- json_result(200,"转账成功");
- }
- // 转账验证密码
- public function transfer_pwd()
- {
- $pwd=input("pwd");if (!$pwd)json_result(400,"请输入密码");
- if (!password_verify($pwd,$this->user->pwd)){
- json_result(400,"密码错误");
- }
- json_result(200,"密码正确");
- }
- // 购买通证显示页面
- public function general_show()
- {
- $where["level"]=$this->user["vip_level"];
- $level=UserLevel::where($where)->find();
- $data["vip_level"]=$this->user["vip_level"];
- $data["vip_bili"]=$level->bili;
- $data["tong_money"]=$this->user->money;
- $system=System::where(["type"=>"shouk"])->field("name,value")->select();
- foreach ($system as $v){
- if ($v->name=="usdt"){
- $data["usdt"]=$v->value?:"";
- }else{
- $data["code"]=$v->value?:"";
- }
- }
- json_result(200,"",$data);
- }
- }
|