place->user; $data['user']['mobile'] = \Dever\Helper\Str::hide($this->place->user['mobile']); if ($data['user']['type'] == 2) { $data['user']['mobile'] = '临时用户,请先绑定手机号'; } # 优惠券 $data['user']['coupon'] = Dever::db('puser/coupon')->count(['uid' => $this->place->uid, 'status' => 1]); # 礼品卡 $data['user']['gift'] = Dever::db('puser/gift')->count(['uid' => $this->place->uid, 'status' => 1]); # 权益包 $data['user']['perk'] = Dever::db('puser/perk')->count(['uid' => $this->place->uid, 'status' => 1]); $data['role'] = []; $role = Dever::db('prole/info')->select(['status' => 1], ['col' => 'id,name,info']); # 获取用户的身份 $user_role = Dever::load(\Prole\Lib\User::class)->getList($this->place->uid); $data['role_info'] = []; if ($role) { foreach ($role as $v) { $level = Dever::db('prole/level')->find(['info_id' => $v['id']]); if (!$level) { continue; } if (isset($user_role[$v['id']])) { $v['subname'] = $user_role[$v['id']]; $v['button'] = '了解详情'; } else { $v['subname'] = '未开通'; $v['button'] = '立即开通'; } if (!$data['role_info']) { $data['role_info'] = $v; } $data['role'][] = $v; } } # 获取所有积分 $data['score'] = Dever::db('pscore/info')->select(['status' => 1], ['col' => 'id,name']); # 获取用户的积分 $user_score = Dever::load(\Pscore\Lib\User::class)->getList($this->place->uid); if ($data['score']) { foreach ($data['score'] as &$score) { $score['num'] = $user_score[$score['id']] ?? '0.00'; } } # 获取待付款 $data['order_1'] = Dever::db('porder/source')->count(['uid' => $this->place->uid, 'status' => 1]); # 待发货 $data['order_2'] = Dever::db('porder/source')->count(['uid' => $this->place->uid, 'status' => 2]); # 待收货 $data['order_3'] = Dever::db('porder/source')->count(['uid' => $this->place->uid, 'status' => ['in', '3,4']]); # 待评价 $data['order_4'] = Dever::db('porder/source')->count(['uid' => $this->place->uid, 'review_status' => 2]); # 获取用户管理信息 $data['sales'] = Dever::load(\Psales\Lib\Info::class)->getList($this->place->uid); return $data; } # 仅获取用户信息 public function my() { $data['user'] = $this->place->user; return $data; } # 上传图片 public function upload() { $file = Dever::input('file', '!empty', '上传文件错误'); $uid = $this->place->uid; return Dever::load(\Upload\Lib\Save::class)->init(7, 1, false, false)->act($file, 'png', $uid); } # 更新我的信息 public function update() { $update = []; $name = Dever::input('name'); if ($name) { $this->place->user['name'] = $update['name'] = $name; } $avatar = Dever::input('avatar'); if ($avatar) { $this->place->user['avatar'] = $update['avatar'] = $avatar; } $sign = Dever::input('sign'); if ($sign) { $this->place->user['sign'] = $update['sign'] = $sign; } $sex = Dever::input('sex'); if ($sex) { $this->place->user['sex'] = $update['sex'] = $sex; } $weixin = Dever::input('weixin'); if ($weixin) { $this->place->user['weixin'] = $update['weixin'] = $weixin; } if ($update) { Dever::db('puser/info')->update($this->place->uid, $update); } return $this->place->user; } # 修改密码 public function pwd() { # 大于8位字符,至少包含:小写字母、大写字母、数字、特殊字符 //$pwd = Dever::input('pwd', '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$/', '密码'); $pwd = Dever::input('pwd', 'is_string', '密码'); $code = Dever::input('code', 'is_string', '验证码'); Dever::load(\Msg\Lib\Template::class)->check('user_code', $this->place->user['mobile'], $code); $update = Dever::load(\Manage\Lib\Util::class)->createPwd($pwd); Dever::db('puser/info')->update($this->place->uid, $update); } # 发送短信验证码 public function sms() { $data = Dever::load(\Msg\Lib\Template::class)->send('user_code', ['mobile' => $this->place->user['mobile']], [], 'place'); return $data; } # 我的分享 public function invite() { # 代理邀请码 $data['code'] = Dever::load(\Invite\Lib\Code::class)->get($this->place->uid); $data['parent'] = 2; # 获取我的上级 $relation = Dever::load(\Invite\Lib\Relation::class)->getParent($this->place->uid); if ($relation) { $data['parent'] = 1; $data['parent_info'] = Dever::db('puser/info')->find($relation['uid'], ['col' => 'id,name,avatar']); } return $data; } # 我的下级列表 public function getGroup() { $data['parent'] = 2; # 获取我的上级 $relation = Dever::load(\Invite\Lib\Relation::class)->getParent($this->place->uid); if ($relation) { $data['parent'] = 1; $data['parent_info'] = Dever::db('puser/info')->find($relation['uid'], ['col' => 'id,name,avatar,cdate']); if ($data['parent_info']) { $data['parent_info']['cdate_str'] = date('Y-m-d H:i:s', $data['parent_info']['cdate']); } } $relation = Dever::load(\Invite\Lib\Relation::class)->getChild($this->place->uid); $data['list'] = []; if ($relation) { foreach ($relation as $k => $v) { $data['list'][$k] = Dever::db('puser/info')->find($v['to_uid'], ['col' => 'id,name,avatar,num_order']); if ($data['list'][$k]) { $data['list'][$k]['cdate_str'] = date('Y-m-d H:i:s', $v['cdate']); # 获取订单数 $data['list'][$k]['order'] = $data['list'][$k]['num_order'] . '单'; } } } $data['page'] = Dever::page('total'); return $data; } # 填写邀请码,添加上级 public function addParent() { $relation = Dever::load(\Invite\Lib\Relation::class)->getParent($this->place->uid); if ($relation) { Dever::error('您已经有上级了'); } $invite = Dever::input('invite', 'is_numeric', '请填写邀请码'); $parent_uid = Dever::load(\Invite\Lib\Code::class)->getUid($invite); if (!$parent_uid) { Dever::error('邀请码不存在'); } $parent = Dever::db('puser/info')->find($parent_uid); if (!$parent) { Dever::error('邀请码不存在'); } Dever::load(\Invite\Lib\Relation::class)->set($parent_uid, $this->place->uid); Dever::db('puser/info')->update($this->place->uid, ['parent_uid' => $parent_uid]); return 'ok'; } # 获取邀请码 public function code() { $account = Dever::input('platform', 'is_string', '账户', 'weixin'); $env = Dever::input('env', 'is_numeric', '运行环境', 3); $sales_type = Dever::input('sales_type'); $sales_id = Dever::input('sales_id'); $type = Dever::input('type'); if (!$type) { $type = 0; } if (!$sales_type || !$sales_id) { $sales_type = $this->place->info['sales_type']; $sales_id = $this->place->info['sales_id']; } $result = Dever::load(\Place\Lib\Info::class)->share($this->place->info['id'], $sales_type, $sales_id, $this->place->uid, false, $type); # 小程序 $data['qrcode'] = $result['applet']['wechat']; $data['link'] = $result['h5']; $data['path'] = $result['path']; return $data; } }