user(); $broken_time = intval(sys_config('extract_time')); $search_time = time() - 86400 * $broken_time; //可提现佣金 //返佣 + $brokerage_commission = UserBill::where(['uid' => $user['uid'], 'category' => 'now_money', 'type' => 'brokerage']) ->where('add_time', '>', $search_time) ->where('pm', 1) ->where('status', 1) ->sum('number'); //退款退的佣金 - $refund_commission = UserBill::where(['uid' => $user['uid'], 'category' => 'now_money', 'type' => 'brokerage']) ->where('add_time', '>', $search_time) ->where('pm', 0) ->where('status', 1) ->sum('number'); $data['broken_commission'] = bcsub($brokerage_commission, $refund_commission, 2); if ($data['broken_commission'] < 0) $data['broken_commission'] = 0; // return $data; $data['brokerage_price'] = $user['brokerage_price']; //可提现佣金 $data['commissionCount'] = $data['brokerage_price'] - $data['broken_commission']; $extractBank = sys_config('user_extract_bank') ?? []; //提现银行 $extractBank = str_replace("\r\n", "\n", $extractBank);//防止不兼容 $data['extractBank'] = explode("\n", is_array($extractBank) ? (isset($extractBank[0]) ? $extractBank[0] : $extractBank) : $extractBank); $data['minPrice'] = sys_config('user_extract_min_price');//提现最低金额 return app('json')->successful($data); } /** * 提现申请 * @param Request $request * @return mixed */ public function cashold(Request $request) { $extractInfo = UtilService::postMore([ ['alipay_code', ''], ['extract_type', ''], ['money', 0], ['name', ''], ['bankname', ''], ['cardnum', ''], ['weixin', ''], ], $request); if (!$request->user()['is_real']) return app('json')->fail('提币请先进行实名认证'); if (!preg_match('/^(([1-9]\d*)|0)(\.\d{1-2})?$/', $extractInfo['money'])) return app('json')->fail('提现金额输入有误'); $user = $request->user(); $broken_time = intval(sys_config('extract_time')); $search_time = time() - 86400 * $broken_time; //可提现佣金 //返佣 + $brokerage_commission = UserBill::where(['uid' => $user['uid'], 'category' => 'now_money', 'type' => 'brokerage']) ->where('add_time', '>', $search_time) ->where('pm', 1) ->where('status', 1) ->sum('number'); //退款退的佣金 - $refund_commission = UserBill::where(['uid' => $user['uid'], 'category' => 'now_money', 'type' => 'brokerage']) ->where('add_time', '>', $search_time) ->where('pm', 0) ->where('status', 1) ->sum('number'); $data['broken_commission'] = bcsub($brokerage_commission, $refund_commission, 2); if ($data['broken_commission'] < 0) $data['broken_commission'] = 0; $data['brokerage_price'] = $user['brokerage_price']; //可提现佣金 $commissionCount = $data['brokerage_price'] - $data['broken_commission']; if ($extractInfo['money'] > $commissionCount) return app('json')->fail('可提现佣金不足'); if (!$extractInfo['cardnum'] == '') if (!preg_match('/^([1-9]{1})(\d{14}|\d{18})$/', $extractInfo['cardnum'])) return app('json')->fail('银行卡号输入有误'); if (UserExtract::userExtract($request->user(), $extractInfo)) return app('json')->successful('申请提现成功!'); else return app('json')->fail(UserExtract::getErrorInfo('提现失败')); } public function cash_calculator(Request $request) { $extractInfo = UtilService::postMore([ ['money', 0], ['money_type', ''], ], $request); // if (!preg_match('/^(([1-9]\d*)|0)(\.\d{1-8})?$/', $extractInfo['money'])) return app('json')->fail('提现金额输入有误'); $user = $request->user(); $money_type = sys_data('money_type'); foreach ($money_type as $v) { if ($v['code'] == $extractInfo['money_type']) { if (!$v['can_cash']) { return app('json')->fail('该币种不可提币'); } if ($v['cash_commission_count_type'] == 1) { $service = bcmul(bcdiv($v['cash_commission_ratio'], 100, 8), $extractInfo['money'], 8); } else { $service = $v['cash_commission_ratio']; } $service_type = $v['cash_commission_type']; if ($service >= $extractInfo['money']) { return app('json')->fail('提币量太少'); } } } if (!isset($service_type)) { return app('json')->fail('该币种不可提币'); } $extractInfo = array_merge($extractInfo, compact('service', 'service_type')); if ($extractInfo['money_type'] != $extractInfo['service_type']) { $extractInfo['extract_price'] = $extractInfo['money']; } else { $extractInfo['extract_price'] = bcsub($extractInfo['money'], $extractInfo['service'], 8); } $extractInfo['_money_type'] = init_money_type()[$extractInfo['money_type']]; $extractInfo['_service_type'] = init_money_type()[$extractInfo['service_type']]; return app('json')->success('ok', $extractInfo); } /** * 提现申请 * @param Request $request * @return mixed */ public function cash(Request $request) { $extractInfo = UtilService::postMore([ ['alipay_code', ''], ['extract_type', ''], ['money', 0], ['name', ''], ['bankname', ''], ['cardnum', ''], ['weixin', ''], ['money_type', ''], ['address', ''], ], $request); // if (!preg_match('/^(([1-9]\d*)|0)(\.\d{1-8})?$/', $extractInfo['money'])) return app('json')->fail('提现金额输入有误'); $user = $request->user(); // if (!$user['is_real']) return app('json')->fail('提币请先进行实名认证'); if ($extractInfo['money_type'] == 'brokerage') { $broken_time = intval(sys_config('extract_time')); $search_time = time() - 86400 * $broken_time; //可提现佣金 //返佣 + $brokerage_commission = UserBill::where(['uid' => $user['uid'], 'category' => 'now_money', 'type' => 'brokerage']) ->where('add_time', '>', $search_time) ->where('pm', 1) ->where('status', 1) ->sum('number'); //退款退的佣金 - $refund_commission = UserBill::where(['uid' => $user['uid'], 'category' => 'now_money', 'type' => 'brokerage']) ->where('add_time', '>', $search_time) ->where('pm', 0) ->where('status', 1) ->sum('number'); $data['broken_commission'] = bcsub($brokerage_commission, $refund_commission, 2); if ($data['broken_commission'] < 0) $data['broken_commission'] = 0; $data['brokerage_price'] = $user['brokerage_price']; //可提现佣金 $commissionCount = $data['brokerage_price'] - $data['broken_commission']; if ($extractInfo['money'] > $commissionCount) return app('json')->fail('可提现佣金不足'); if (!$extractInfo['cardnum'] == '') if (!preg_match('/^([1-9]{1})(\d{14}|\d{18})$/', $extractInfo['cardnum'])) return app('json')->fail('银行卡号输入有误'); $res = UserExtract::userExtract($user, $extractInfo); if ($res) { return app('json')->successful('申请提币成功!', ['data' => $res]); } else return app('json')->fail(UserExtract::getErrorInfo('提币失败')); } $money_type = sys_data('money_type'); foreach ($money_type as $v) { if ($v['code'] == $extractInfo['money_type']) { if (!$v['can_cash']) { return app('json')->fail('该币种不可提币'); } if ($v['less'] > $extractInfo['money']) { return app('json')->fail('该币种' . $v['less'] . '个起提'); } if ($v['cash_commission_count_type'] == 1) { $service = bcmul(bcdiv($v['cash_commission_ratio'], 100, 8), $extractInfo['money'], 8); } else { $service = $v['cash_commission_ratio']; } if ($service >= $extractInfo['money']) { return app('json')->fail('提币量太少'); } $service_type = $v['cash_commission_type']; } } if (!isset($service_type)) { return app('json')->fail('该币种不可提币'); } $extractInfo = array_merge($extractInfo, compact('service', 'service_type')); if ($extractInfo['money_type'] == 'GYJF') { if ($extractInfo['money'] > ActivityJoin::where('uid', $request->uid())->count() * 100000) { return app('json')->fail('每次参加互助最多可提100000拼团积分'); } } $money = UserMoney::initialUserMoney($request->uid(), $extractInfo['money_type']); $money2 = UserMoney::initialUserMoney($request->uid(), $service_type); if ($extractInfo['money_type'] != $service_type) { if ($extractInfo['money'] > $money['money']) return app('json')->fail('可提现佣金不足'); if ($service > $money2['money']) return app('json')->fail('用于支付手续费的' . init_money_type()[$service_type] . '不足'); } else { if ($extractInfo['money'] > $money['money']) return app('json')->fail('可提现佣金不足'); // if (bcadd($extractInfo['money'], $service, 8) > $money['money']) return app('json')->fail('可提现佣金不足'); } // if ($extractInfo['address'] == '') return app('json')->fail('钱包地址错误'); if (!$extractInfo['cardnum'] == '') if (!preg_match('/^([1-9]{1})(\d{14}|\d{18})$/', $extractInfo['cardnum'])) return app('json')->fail('银行卡号输入有误'); $res = UserExtract::userExtract($user, $extractInfo); if ($res) { return app('json')->successful('申请提币成功!', ['data' => $res]); } else return app('json')->fail(UserExtract::getErrorInfo('提币失败')); } public function lst(Request $request) { $where = UtilService::getMore([ ['limit', 10], ['page', 1], ], $request); $model = new UserExtractModel(); $model = $model->where('a.uid', $request->uid()); $model = $model->alias('a'); $model = $model->field('a.*,b.nickname'); $model = $model->join('user b', 'b.uid=a.uid', 'LEFT'); $model = $model->order('a.id desc'); $list = $model->page($where['page'], $where['limit'])->select(); return app('json')->successful('ok!', ['data' => $list]); } }