|
@@ -13,167 +13,83 @@ class Usercenter extends Api
|
|
|
protected $noNeedLogin = [];
|
|
|
protected $noNeedRight = '*';
|
|
|
|
|
|
- //提现账号添加
|
|
|
- public function bankadd() {
|
|
|
- $realname = input('realname', '', 'trim'); //账户真实姓名
|
|
|
- $banknumber = input('banknumber', '', 'trim'); //卡号或账号
|
|
|
- $bankname = input('bankname', '', 'trim'); //银行名称
|
|
|
-
|
|
|
-
|
|
|
- if ($realname === '' || iconv_strlen($realname, 'utf-8') > 30) {
|
|
|
- $this->error('账号姓名1-30位');
|
|
|
- }
|
|
|
- if ($banknumber === '' || iconv_strlen($banknumber, 'utf-8') > 50) {
|
|
|
- $this->error('账号1-50位');
|
|
|
- }
|
|
|
- if ($bankname === '' || iconv_strlen($bankname, 'utf-8') > 50) {
|
|
|
- $this->error('银行名称1-50位');
|
|
|
- }
|
|
|
-
|
|
|
- //添加
|
|
|
- $count = Db::name('user_bank')->where(['user_id' => $this->auth->id])->count('id');
|
|
|
- if ($count) {
|
|
|
- $this->error('您已经拥有该类型账号,不能再添加');
|
|
|
- }
|
|
|
-
|
|
|
- $data['user_id'] = $this->auth->id;
|
|
|
- $data['realname'] = $realname;
|
|
|
- $data['banknumber'] = $banknumber;
|
|
|
- $data['bankname'] = $bankname;
|
|
|
- $data['createtime'] = time();
|
|
|
-
|
|
|
- $rs = Db::name('user_bank')->insertGetId($data);
|
|
|
- if (!$rs) {
|
|
|
- $this->error('添加失败');
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('添加成功');
|
|
|
+ //生成我的视频海报
|
|
|
+ //生成邀请码二维码图片
|
|
|
+ public function inviteimage($introcode) {
|
|
|
+ $params['text'] = config('h5_url') . '/#/pages/home/index?introcode=' . $introcode;
|
|
|
+ $qrcode_service = \addons\qrcode\library\Service::qrcode($params);
|
|
|
+// $mimetype = 'image/png';
|
|
|
+// $response = Response::create()->header("Content-Type", $mimetype);
|
|
|
+
|
|
|
+ // 直接显示二维码
|
|
|
+// header('Content-Type: ' . $qrcode_service->getContentType());
|
|
|
+// $response->content($qrcode_service->writeString());
|
|
|
+ $qrcodePath = ROOT_PATH . 'public/uploads/qrcode/';
|
|
|
+ if (!is_dir($qrcodePath)) {
|
|
|
+ @mkdir($qrcodePath);
|
|
|
+ }
|
|
|
+ if (is_really_writable($qrcodePath)) {
|
|
|
+ $filename = md5(implode('', $params)) . '.png';
|
|
|
+ $filePath = $qrcodePath . $filename;
|
|
|
+ $qrcode_service->writeFile($filePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ return '/uploads/qrcode/' . $filename;
|
|
|
}
|
|
|
|
|
|
- //提现账号编辑
|
|
|
- public function bankedit(){
|
|
|
- $id = input('id', 0, 'intval'); //账号id
|
|
|
- $realname = input('realname', '', 'trim'); //账户真实姓名
|
|
|
- $banknumber = input('banknumber', '', 'trim'); //卡号或账号
|
|
|
- $bankname = input('bankname', '', 'trim'); //银行名称
|
|
|
-
|
|
|
-
|
|
|
- if ($realname === '' || iconv_strlen($realname, 'utf-8') > 30) {
|
|
|
- $this->error('账号姓名1-30位');
|
|
|
- }
|
|
|
- if ($banknumber === '' || iconv_strlen($banknumber, 'utf-8') > 50) {
|
|
|
- $this->error('账号1-50位');
|
|
|
- }
|
|
|
- if ($bankname === '' || iconv_strlen($bankname, 'utf-8') > 50) {
|
|
|
- $this->error('银行名称1-50位');
|
|
|
- }
|
|
|
-
|
|
|
- //查询账号是否存在
|
|
|
- $info = Db::name('user_bank')->where(['id' => $id, 'user_id' => $this->auth->id])->find();
|
|
|
- if (!$info) {
|
|
|
- $this->error('账号不存在');
|
|
|
- }
|
|
|
-
|
|
|
- $data['realname'] = $realname;
|
|
|
- $data['banknumber'] = $banknumber;
|
|
|
- $data['bankname'] = $bankname;
|
|
|
- $data['updatetime'] = time();
|
|
|
+ //生成视频分享海报
|
|
|
+ public function shareposter() {
|
|
|
|
|
|
- $rs = Db::name('user_bank')->where(['id' => $id])->update($data);
|
|
|
- if ($rs === false) {
|
|
|
- $this->error('修改失败');
|
|
|
- }
|
|
|
+ $inviteimage = $this->inviteimage($this->auth->introcode);
|
|
|
|
|
|
- $this->success('修改成功');
|
|
|
- }
|
|
|
+ $data = [
|
|
|
|
|
|
- //提现账号信息
|
|
|
- public function bankinfo() {
|
|
|
-
|
|
|
- $info = Db::name('user_bank')->where(['user_id' => $this->auth->id])->find();
|
|
|
- if (!$info) {
|
|
|
- $info = (object)[];
|
|
|
- }
|
|
|
+ [
|
|
|
+ "left"=> "100px",
|
|
|
+ "top"=> "424px",
|
|
|
+ "type"=> "nickname",
|
|
|
+ "width"=> "166px",
|
|
|
+ "height"=> "38px",
|
|
|
+ "size"=> "11px",
|
|
|
+ "color"=> "#333333",
|
|
|
+ "content" => '邀请码:'.$this->auth->introcode,
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ "left"=> "90px",
|
|
|
+ "top"=> "260px",
|
|
|
+ "type"=> "img",
|
|
|
+ "width"=> "140px",
|
|
|
+ "height"=> "140px",
|
|
|
+ "src"=> httpurllocal($inviteimage)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
|
|
|
+ ],
|
|
|
|
|
|
- $this->success('账户信息', $info);
|
|
|
- }
|
|
|
-
|
|
|
- //提现
|
|
|
- public function moneywithdraw() {
|
|
|
- $id = input('id', 0, 'intval'); //提现账号id
|
|
|
- $money = input('money', '', 'trim');
|
|
|
- if (!$id) {
|
|
|
- $this->error('请选择提现账号');
|
|
|
- }
|
|
|
- $bankinfo = Db::name('user_bank')->where(['id' => $id, 'user_id' => $this->auth->id])->find();
|
|
|
- if (!$bankinfo) {
|
|
|
- $this->error('账号不存在');
|
|
|
- }
|
|
|
- if (!preg_match('/^[0-9]+(.[0-9]{1,8})?$/', $money) || $money <= 0) {
|
|
|
- $this->error('请输入正确提现金额');
|
|
|
- }
|
|
|
+ ];
|
|
|
|
|
|
- //余额查询
|
|
|
- $user_money = model('wallet')->getWallet($this->auth->id,'money');
|
|
|
- if ($user_money < $money) {
|
|
|
- $this->error('余额不足');
|
|
|
- }
|
|
|
|
|
|
- //查询最低最高提现金额
|
|
|
- $min_withdrawal_money = config('site.min_withdrawal_money') ? config('site.min_withdrawal_money') : 1;
|
|
|
- $max_withdrawal_money = config('site.max_withdrawal_money') ? config('site.max_withdrawal_money') : 50000;
|
|
|
- if ($money < $min_withdrawal_money) {
|
|
|
- $this->error('最低提现金额' . $min_withdrawal_money . '元');
|
|
|
- }
|
|
|
- if ($money > $max_withdrawal_money) {
|
|
|
- $this->error('最高提现金额' . $max_withdrawal_money . '元');
|
|
|
- }
|
|
|
+ $data = json_encode($data, 320);
|
|
|
|
|
|
- //查询提现手续费百分比
|
|
|
- $withdrawal_service_fee = (int)config('site.withdrawal_service_fee') ? : 0;
|
|
|
- if ($withdrawal_service_fee < 0 || $withdrawal_service_fee >= 100) {
|
|
|
- $this->error('提现手续费异常');
|
|
|
- }
|
|
|
+ $poster = [
|
|
|
+ 'id' => 1,
|
|
|
+ 'title' => '测试',
|
|
|
+ 'waittext' => '您的专属海报正在拼命生成中,请等待片刻...',
|
|
|
+ 'bg_image' => '/assets/img/posteruserbg.png',
|
|
|
+ 'data' => $data,
|
|
|
+ 'status' => 'normal',
|
|
|
+ 'weigh' => 0,
|
|
|
+ 'createtime' => 1653993709,
|
|
|
+ 'updatetime' => 1653994259,
|
|
|
+ ];
|
|
|
|
|
|
- $real_money = bcdiv(bcmul($money,bcsub(100,$withdrawal_service_fee)),100);
|
|
|
-
|
|
|
- $data['order_no'] = createUniqueNo('T',$this->auth->id);
|
|
|
- $data['user_id'] = $this->auth->id;
|
|
|
- $data['amount'] = $money;
|
|
|
- $data['money'] = $real_money;
|
|
|
- $data['user_bank_id'] = $id;
|
|
|
- $data['realname'] = $bankinfo['realname'];
|
|
|
- $data['banknumber'] = $bankinfo['banknumber'];
|
|
|
- $data['bankname'] = $bankinfo['bankname'];
|
|
|
- $data['status'] = 0;
|
|
|
- $data['createtime'] = time();
|
|
|
-
|
|
|
- //开启事务
|
|
|
- Db::startTrans();
|
|
|
- //添加提现记录
|
|
|
- $log_id = Db::name('user_withdraw')->insertGetId($data);
|
|
|
- if (!$log_id) {
|
|
|
- Db::rollback();
|
|
|
- $this->error('申请提现失败');
|
|
|
- }
|
|
|
+ $image = new \addons\poster\library\Image();
|
|
|
+ $imgurl = $image->createPosterImage_user($poster, $this->auth->getUser());
|
|
|
|
|
|
- $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,'money',$money,4,'提现','user_withdraw',$log_id);
|
|
|
- if ($rs_wallet['status'] == false) {
|
|
|
- $this->error($rs_wallet['msg']);
|
|
|
- Db::rollback();
|
|
|
+ if (!$imgurl) {
|
|
|
+ $this->error('生成海报出错');
|
|
|
}
|
|
|
+ $imgurl = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"] . '/' . $imgurl;
|
|
|
|
|
|
- Db::commit();
|
|
|
- $this->success('申请提现成功,请等待审核');
|
|
|
- }
|
|
|
-
|
|
|
- //用户钱包流水
|
|
|
- public function moneylog(){
|
|
|
- $list = Db::name('user_money_log')->field('id,change_value,log_type,createtime')->where('user_id',$this->auth->id)->page($this->page,$this->listrow)->select();
|
|
|
- foreach($list as $key => &$val){
|
|
|
- $val['log_type_text'] = model('wallet')->getlogtype($val['log_type']);
|
|
|
- }
|
|
|
+ //echo '<html><body><img src="'.$imgurl.'"></body></html>';
|
|
|
|
|
|
- $this->success('success',$list);
|
|
|
+ $this->success('', $imgurl);
|
|
|
}
|
|
|
}
|