|
@@ -157,54 +157,6 @@ class Userwallet extends Api
|
|
|
$this->success('success',$list);
|
|
|
}
|
|
|
|
|
|
- //提现配置
|
|
|
- public function take_cash_config(){
|
|
|
-
|
|
|
- $data = [
|
|
|
- 'money' => model('wallet')->getwallet($this->auth->id,'money'),
|
|
|
- 'alipay_account' => '',
|
|
|
- 'min' => 1,
|
|
|
- 'max' => 1000,
|
|
|
- ];
|
|
|
-
|
|
|
- $this->success('success',$data);
|
|
|
- }
|
|
|
-
|
|
|
- //提现
|
|
|
- public function take_cash(){
|
|
|
- $money = floatval(input_post('money',0));
|
|
|
-
|
|
|
- if(empty($money)){
|
|
|
- $this->error();
|
|
|
- }
|
|
|
-
|
|
|
- if(empty($this->auth->idcard_status)){
|
|
|
- $this->error('请先完成实名认证');
|
|
|
- }
|
|
|
-
|
|
|
- $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id,'status'=>0])->find();
|
|
|
- if($check){
|
|
|
- $this->error('您已经申请了提现,请等待审核');
|
|
|
- }
|
|
|
-
|
|
|
- $user_money = model('wallet')->getwallet($this->auth->id,'money');
|
|
|
- if($money > $user_money){
|
|
|
- $this->error('提现金额不能大于可提现余额');
|
|
|
- }
|
|
|
-
|
|
|
- $data = [
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- 'number' => $money,
|
|
|
- 'status' => 0,
|
|
|
- 'createtime' => time(),
|
|
|
- 'updatetime' => time(),
|
|
|
- ];
|
|
|
-
|
|
|
- Db::name('take_cash')->insertGetId($data);
|
|
|
-
|
|
|
- //审核时候再扣,或者这里先扣,等需求方确认
|
|
|
- $this->success('申请成功请等待审核');
|
|
|
- }
|
|
|
|
|
|
//提现记录
|
|
|
public function take_cash_log(){
|
|
@@ -245,142 +197,7 @@ class Userwallet extends Api
|
|
|
$this->success('success',$return_data);
|
|
|
}
|
|
|
|
|
|
- //提现(废弃)
|
|
|
- public function withdrawal_feiqi() {
|
|
|
- if ($this->auth->idcard_status != 1) {
|
|
|
- $this->error('请先完成实名认证~');
|
|
|
- }
|
|
|
-
|
|
|
- $id = input('id', 0, 'intval');
|
|
|
- $type = input('type', 0, 'intval'); //账户类型:1=微信,2=支付宝
|
|
|
- if (!$id) {
|
|
|
- $this->error('您的网络开小差啦~');
|
|
|
- }
|
|
|
- $withdrawal_config = Db::name('withdrawal_config')->find($id);
|
|
|
- if (!$withdrawal_config) {
|
|
|
- $this->error('提现金额不存在~');
|
|
|
- }
|
|
|
- if ($withdrawal_config['is_show'] != 1) {
|
|
|
- $this->error('提现金额暂未开放~');
|
|
|
- }
|
|
|
- if ($withdrawal_config['money'] <= 0 || $withdrawal_config['real_money'] <= 0 || $withdrawal_config['money'] < $withdrawal_config['real_money']) {
|
|
|
- $this->error('提现金额异常~');
|
|
|
- }
|
|
|
- if (!in_array($type, [1, 2])) {
|
|
|
- $this->error('请选择提现账户~');
|
|
|
- }
|
|
|
- if ($type != 2) {
|
|
|
- $this->error('提现方式请选择支付宝');
|
|
|
- }
|
|
|
|
|
|
- //扣除金额
|
|
|
- $money = floatval($withdrawal_config['money']);
|
|
|
-
|
|
|
- $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id,'status'=>0])->find();
|
|
|
- if($check){
|
|
|
- $this->error('您已经申请了提现,请等待审核');
|
|
|
- }
|
|
|
- $time = strtotime(date('Y-m-d'));
|
|
|
- $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id, 'wallet_id'=>$id, 'createtime' => ['egt', $time]])->find();
|
|
|
- if($check){
|
|
|
- $this->error('您今日已经提现过该额度');
|
|
|
- }
|
|
|
-
|
|
|
- $user_money = model('wallet')->getwallet($this->auth->id,'money');
|
|
|
- if($money > $user_money){
|
|
|
- $this->error('可提现余额不足');
|
|
|
- }
|
|
|
-
|
|
|
- if ($type == 1) { //微信
|
|
|
- $alipay_account = '';
|
|
|
- } else { //支付宝
|
|
|
- $user_bank_info = Db::name('user_bank')->where(['user_id' => $this->auth->id, 'type' => 1])->find();
|
|
|
- if (!$user_bank_info) {
|
|
|
- $this->error('请先绑定支付宝');
|
|
|
- }
|
|
|
- $alipay_account = $user_bank_info['banknumber'];
|
|
|
- $realname = $user_bank_info['realname'];
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- $data = [
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- 'wallet_id' => $id,
|
|
|
- 'number' => $money,
|
|
|
- 'money' => $withdrawal_config['real_money'],
|
|
|
- 'alipay_account' => $alipay_account,
|
|
|
- 'status' => 0,
|
|
|
- 'createtime' => time(),
|
|
|
- 'updatetime' => time(),
|
|
|
- 'type' => $type,
|
|
|
- 'realname' => $realname
|
|
|
- ];
|
|
|
- //计算上级可获得金额
|
|
|
- if ($this->auth->intro_uid) {
|
|
|
- $data['intro_uid'] = $this->auth->intro_uid;
|
|
|
- //获取返利比率
|
|
|
- $intro_withdrawal_rebate_rate = (int)config('site.intro_withdrawal_rebate_rate');
|
|
|
- if ($intro_withdrawal_rebate_rate > 0 && $intro_withdrawal_rebate_rate <= 100) {
|
|
|
- //上级获得金额数量
|
|
|
- $intro_uid_money = number_format($money * $intro_withdrawal_rebate_rate / 100, 2, '.', '');
|
|
|
- if ($intro_uid_money > 0) {
|
|
|
- $data['intro_money'] = $intro_uid_money;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $msg = '申请成功请等待审核';
|
|
|
-
|
|
|
- //开启事务
|
|
|
- Db::startTrans();
|
|
|
- $log_id = Db::name('take_cash')->insertGetId($data);
|
|
|
- if (!$log_id) {
|
|
|
- Db::rollback();
|
|
|
- $this->error('您的网络开小差啦~');
|
|
|
- }
|
|
|
- if ($withdrawal_config['type'] == 1) { //秒到账,无需审核
|
|
|
- $info = Db::name('take_cash')->find($log_id);
|
|
|
- //扣钱
|
|
|
- $wallet_rs = model('wallet')->lockChangeAccountRemain($info['user_id'],0,'money',-$info['number'],15,'提现:'.$info['number'],'take_cash',$info['id']);
|
|
|
- if($wallet_rs['status'] === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error($wallet_rs['msg']);
|
|
|
- }
|
|
|
- //上级返利
|
|
|
- if ($info['intro_uid'] && $info['intro_money'] > 0) {
|
|
|
- $wallet_rs = model('wallet')->lockChangeAccountRemain($info['intro_uid'],$info['user_id'],'money',$info['intro_money'],66,'邀请人提现奖励:'.$info['number'],'take_cash',$info['id']);
|
|
|
- if($wallet_rs['status'] === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error($wallet_rs['msg']);
|
|
|
- }
|
|
|
- }
|
|
|
- //自动打款
|
|
|
- if ($info['type'] == 1) { //微信
|
|
|
-
|
|
|
- } elseif ($info['type'] == 2) { //支付宝
|
|
|
- $dakuanrs = $this->withdraw($info);
|
|
|
- if (!$dakuanrs) {
|
|
|
- Db::rollback();
|
|
|
- $this->error('打款失败');
|
|
|
- }
|
|
|
- }
|
|
|
- //修改提现记录状态
|
|
|
- $take_cash_result = Db::name('take_cash')->where(['id' => $log_id, 'status' => 0])->setField('status', 1);
|
|
|
- if (!$take_cash_result) {
|
|
|
- Db::rollback();
|
|
|
- $this->error('打款失败');
|
|
|
- }
|
|
|
-
|
|
|
- //系统消息
|
|
|
- $msg_id = \app\common\model\Message::addMessage($info['user_id'],'提现','您的提现已经到账');
|
|
|
-
|
|
|
- $msg = '提现成功';
|
|
|
- }
|
|
|
-
|
|
|
- Db::commit();
|
|
|
- //审核时候再扣,或者这里先扣,等需求方确认
|
|
|
- $this->success($msg);
|
|
|
- }
|
|
|
|
|
|
//提现
|
|
|
public function withdrawal() {
|
|
@@ -493,35 +310,7 @@ class Userwallet extends Api
|
|
|
$this->success($msg);
|
|
|
}
|
|
|
|
|
|
- //提现转账(新版2020-01-01)
|
|
|
- public function withdraw($info) {
|
|
|
- $data['out_biz_no'] = getMillisecond() . mt_rand(1, 1000); //商户订单号
|
|
|
- $data['trans_amount'] = $info['money']; //订单总金额,单位为元,精确到小数点后两位
|
|
|
- $data['product_code'] = 'TRANS_ACCOUNT_NO_PWD';//业务产品码,收发现金红包固定为:STD_RED_PACKET;单笔无密转账到支付宝账户固定为:TRANS_ACCOUNT_NO_PWD;单笔无密转账到银行卡固定为:TRANS_BANKCARD_NO_PWD
|
|
|
- $data['biz_scene'] = 'DIRECT_TRANSFER'; //描述特定的业务场景,可传的参数如下:PERSONAL_COLLECTION:C2C现金红包-领红包;DIRECT_TRANSFER:B2C现金红包、单笔无密转账到支付宝/银行卡
|
|
|
- $data['order_title'] = '知音佣金发放'; //转账业务的标题,用于在支付宝用户的账单里显示
|
|
|
-
|
|
|
- $data['payee_info']['identity'] = $info['alipay_account'];//收款方支付宝id或支付宝账户
|
|
|
-
|
|
|
- /*if ($info['alipay_type'] == 1) { //支付宝账户
|
|
|
- $data['payee_info']['identity_type'] = 'ALIPAY_LOGON_ID';
|
|
|
- //收款支付宝账号真实姓名, 不为空时支付宝会验证
|
|
|
- $data['payee_info']['name'] = $info['name'];
|
|
|
- } else { //支付宝id
|
|
|
- $data['payee_info']['identity_type'] = 'ALIPAY_USER_ID';
|
|
|
- $data['payee_info']['name'] = '';
|
|
|
- }*/
|
|
|
- //支付宝id
|
|
|
- $data['payee_info']['identity_type'] = 'ALIPAY_USER_ID';
|
|
|
- $data['payee_info']['name'] = '';
|
|
|
-
|
|
|
- //转账备注(支持200个英文/100个汉字)。当付款方为企业账户,且转账金额达到(大于等于)50000元,remark不能为空。收款方可见,会展示在收款用户的收支详情中。
|
|
|
- $data['remark'] = '知音佣金发放';
|
|
|
- require_once("../extend/AliPay/AliPay.php");
|
|
|
- $alipay =new \AliPay();
|
|
|
- $result =$alipay->AliPayWithdraw($data);
|
|
|
- return $result;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
//每日数据
|
|
|
public function todayincome() {
|