diff --git a/app/Admin/Actions/User/AddContractControl.php b/app/Admin/Actions/User/AddContractControl.php new file mode 100644 index 0000000..57a91e6 --- /dev/null +++ b/app/Admin/Actions/User/AddContractControl.php @@ -0,0 +1,102 @@ +modal($id); + + return << + {$this->title} + +HTML; + } + + protected function modal($id) + { + // 工具表单 + $form = new \App\Admin\Forms\ContractRisknew(); + + // 通过 Admin::html 方法设置模态窗HTML + Admin::html( + << + + +HTML + ); + } + + /** + * Handle the action request. + * + * @param Request $request + * + * @return Response + */ + public function handle(Request $request) + { + // dump($this->getKey()); + + // return $this->response()->success('Processed successfully.')->redirect('/'); + } + + /** + * @return string|array|void + */ + public function confirm() + { + // return ['Confirm?', 'contents']; + } + + /** + * @param Model|Authenticatable|HasPermissions|null $user + * + * @return bool + */ + protected function authorize($user): bool + { + return true; + } + + /** + * @return array + */ + protected function parameters() + { + return []; + } +} diff --git a/app/Admin/Controllers/ContractRisknewController.php b/app/Admin/Controllers/ContractRisknewController.php new file mode 100644 index 0000000..bc879a0 --- /dev/null +++ b/app/Admin/Controllers/ContractRisknewController.php @@ -0,0 +1,95 @@ +title('新合约风控') + // ->body(new Card(new \App\Admin\Forms\ContractRisknew())); + // } + + protected function grid() + { + $pcc = PlatformContractControl::query()->orderByDesc('id'); + return Grid::make($pcc, function (Grid $grid) { + // $aa = DB::select('select * from contract_position'); + + if (Admin::user()->can('addSystemUser')) { + $grid->tools([new AddContractControl()]); + } + + $grades = AgentGrade::getCachedGradeOption(); + + $grid->id; + + + $grid->column('symbol','币种名称'); + $grid->column('now_price','操作价格'); + $grid->column('blacktime','回调时间'); + $grid->column('time','操作时间')->display(function ($v) { + return date('Y-m-d H:i:s', $v); + });; + + + $grid->disableViewButton(); + $grid->disableCreateButton(); + //$grid->disableEditButton(); + $grid->disableDeleteButton(); + $grid->disableBatchDelete(); + + $grid->filter(function (Grid\Filter $filter) use ($grades) { + $filter->between('created_at', "时间")->date()->width(4); + $filter->equal('whethertopromote', '币种名称')->select(function (){ + $symbols = config('coin.exchange_symbols'); + $PlatformCurrency = []; + foreach ($symbols as $key=>$val){ + $PlatformCurrency[]= $key; + // var_dump($key); + } + return $PlatformCurrency; + + })->width(2); + }); + }) + ->title('新合约风控'); + } + + public function symbolDetal(Request $request){ + $cd = Cache::store('redis')->get('swap:' . $request['symbol'] . '_detail'); + if($cd){ + $cd['highest'] = $cd['price'] * 1.1; + $cd['minimum'] = $cd['price'] * 0.9; + } + + return $cd; + } +} diff --git a/app/Admin/Forms/ContractRisknew.php b/app/Admin/Forms/ContractRisknew.php new file mode 100644 index 0000000..a092d86 --- /dev/null +++ b/app/Admin/Forms/ContractRisknew.php @@ -0,0 +1,578 @@ + $input['symbol'], + 'blacktime' => $input['blacktime'], + 'now_price' => $input['nowprice'], + 'time' => time(), + ]; + $cd = Cache::store('redis')->get('swap:' . $input['symbol'] . '_detail'); + if($cd){ + $cd['highest'] = $cd['price'] * 1.1; + $cd['minimum'] = $cd['price'] * 0.9; + } + if($input['nowprice']>$cd['highest'] || $input['nowprice']<$cd['minimum']){ + return $this->error('控制价格不在范围内'); + } + + PlatformContractControl::query()->insert($coin_up); + + $dotime = time(); + $now_min_s = date('s', $dotime); + + + if ($now_min_s >= 55) { + return $this->error('最后5秒不给更新'); + } + // if ($now_min_s <= 5) { + // return $this->error('开始5秒不给更新'); + // } + $NumberOfRecovery = $input['blacktime']; + $symbols = ContractPair::query()->pluck('symbol'); + $PlatformCoin = config('coin.exchange_symbols'); + foreach ($PlatformCoin as $val => $key) { + $PlatformCoinNew[] = $val; + } + $data['count'] = $input['nowprice']; + $doit = $this->PlatformCurrencyRiskControlTotalProcessing($input['symbol'], $data, time(),$NumberOfRecovery); + // var_dump($symbols); + return $this->success('Processed successfully.'); + exit(); + foreach ($symbols as $symbol) { + if (!empty($input[$symbol])) { + $risk_key = 'fkJson:' . $symbol . '/USDT'; + $data = $input[$symbol]; + if (in_array($symbol, $PlatformCoinNew)) { + // if ($input[$symbol]['enabled'] == 1) { + $dotime = strtotime(date('Y-m-d ', time()) . $input[$symbol]['strat_time']); + // $doit = $this->PlatformCurrencyRiskControlTotalProcessing('AAAAA', $input[$symbol]); + // if ($input[$symbol]['pin'] == 1) { + // $doit = $this->PlatformCurrencyRiskControlTotalProcessing($symbol, $input[$symbol], $dotime); + // } else { + // $doit = $this->PlatformCurrencyRiskControlTotalProcessing($symbol, $input[$symbol], time()); + // } + $doit = $this->PlatformCurrencyRiskControlTotalProcessing($symbol, $input[$symbol], time(),$NumberOfRecovery); + if ($doit) { + return $this->error($doit); + } + // } + } + // !blank($risk) + $old_data = json_decode(Redis::get($risk_key), true); + if($old_data['now_time'] ==strtotime(date("Y-m-d H:i:00"))){ + return $this->error('此根还在路上,请下一分钟再操作'); + } + if(empty($old_data['now_time']) || $old_data['enabled'] == 1 || $data['enabled'] == 1){ + $data['now_time'] = strtotime(date("Y-m-d H:i:00")); + + if($data['enabled'] == 1 && $old_data['enabled'] == 1){ + // // 二次改价 + $data['back_count'] = $old_data['count']; + }elseif ($data['enabled'] == 0 && $old_data['enabled'] == 1){ + // // 关闭风控 + $data['back_count'] = $data['count']; + }else{ + // // 开启风控 + $data['back_count'] = $data['count']; + } + + }else{ + if(empty($old_data['now_time'])){ + $old_data['now_time'] = strtotime(date("Y-m-d H:i:00"))-180; + } + $data['now_time'] = $old_data['now_time']; + } + + Redis::set($risk_key, json_encode($data)); + } + } + + // return $this->error('Your error message.'); + + + } + + /** + * Notes: 平台币风控处理不走队列 + * @param $coin 币名称 + * @param $data 风控数据 + * User: torsenli + * Date: 2022/3/20 + * Time: 22:12 + */ + public function PlatformCurrencyRiskControlTotalProcessing($coin, $data,$dotime,$NumberOfRecovery = 35) + { + $now_time = strtotime(date('Y-m-d H:i', $dotime) . ":00"); + $now_min = date('i', $dotime); + $now_min_s = date('s', $dotime); + $decimal = 100000; + + if ($now_min_s >= 55) { + return "最后5秒不给更新"; + } + + $symbols = config('coin.exchange_symbols'); + + $coins = []; + $kk = 1; + foreach ($symbols as $symbol => $model) { + $coins[$symbol] = $model; + $kk++; + } + + // todo 测试固定model + $model = $coins[$coin]; + // $model = "App\Models\DataAaaaa"; + + // 更新当前一分钟数据 + // 获取当前一分钟数据 + $one_min_date = $model::query()->where('Date', $now_time)->where('is_1min', 1)->first()->toArray(); + Log::info($one_min_date); + // 判断是涨还是跌 + if ($one_min_date['Open'] < $data['count']) { + $UpsAndDowns = 1; + } else { + $UpsAndDowns = 0; + } + // 更新当前一分钟收盘数据 + $this->UpdateTheCurrentMinute($UpsAndDowns, $data['count'], $now_time, $model, $one_min_date); + + + // 随机回调15-25条一分钟 + // $NumberOfRecovery = mt_rand(15, 25); + // $NumberOfRecovery = 35; + $end_open = $model::query()->where('Date', $now_time + $NumberOfRecovery * 60)->where('is_1min', 1)->first()->toArray(); + + // 判断修复,是涨还是跌 + if ($end_open['Open'] > $data['count']) { + $high_price = $end_open['Open']; + $low_price = $data['count']; + } else { + $high_price = $data['count']; + $low_price = $end_open['Open']; + } + $open_price = $data['count']; + $close_price = $end_open['Open']; + + // 更新缓存最高最低 + // $periods = ['5min', '15min', '30min', '60min']; + // foreach ($periods as $period){ + // Log::info($coin); + // $old_per = Cache::store('redis')->get('swap:' . $coin . '_kline_' . $period); + // Log::info($old_per); + // // + // $old_per['high'] = $old_per['open']; + // $old_per['low'] = $old_per['open']; + // Cache::store('redis')->put('swap:' . $coin . '_kline_' . $period,$old_per); + // } + + + // 生成随机修复分钟数 + $period2_seconds = 60; + $periodCount = $NumberOfRecovery; + $periodsTrend = []; + $unit = custom_number_format(bcMath(($high_price - $low_price), $NumberOfRecovery - 1, '/', 8), 8); + $ups_downs_high = abs(floor($unit * $decimal * 5)); //高 + $ups_downs_value = abs(floor($unit * 2 * $decimal)); //值 + $ups_downs_low = floor($close_price); //低 + + $points = linspace($open_price, $close_price, $periodCount); + + + for ($i = 0; $i < $NumberOfRecovery; $i++) { + if ($end_open['Open'] > $data['count']) { + $thresholdValue = 60; + } else { + $thresholdValue = 40; + } + + $periodsTrend[$now_time + ($i * $period2_seconds)] = mt_rand(1, 100) <= $thresholdValue ? 1 : 2; + $prev = $model::query()->where('is_1min', 1)->where('Date', $now_time + ($i * $period2_seconds))->first(); // 上一条K线 + $close_point = $points[$i] * $decimal; + $current = $now_time + 60; + $open = $prev['Close'] * $decimal; + $up_or_down = mt_rand(1, 100); + $first = array_first($periodsTrend, function ($v, $k) use ($current, $period2_seconds) { + return $current >= $k && $current < ($k + $period2_seconds); + }); + + // dd($current); + + if ($first == 1) { + $value = 60; + } else { + $value = 40; + } + + // dd($ups_downs_low,$ups_downs_value,$ups_downs_high); + if ($up_or_down <= $value) { + // 涨 + $close = mt_rand($close_point, $close_point + mt_rand($ups_downs_low, $ups_downs_high)); + $high = mt_rand($close, $close + mt_rand($ups_downs_low, $ups_downs_value)); + $low = mt_rand($close - mt_rand($ups_downs_low, $ups_downs_value), $close); + } else { + // 跌 + $close = mt_rand($close_point - mt_rand($ups_downs_low, $ups_downs_high), $close_point); + $high = mt_rand($close, $close + mt_rand($ups_downs_value, $ups_downs_high)); + $low = mt_rand($close - mt_rand($ups_downs_low, $ups_downs_value), $close); + } + $high = max($open, $close, $high, $low); + $low = min($open, $close, $high, $low); + + // dd($open,$close,$high,$low,$close_point); + + $open = $open / $decimal; + $close = $close / $decimal; + $high = $high / $decimal; + $low = $low / $decimal; + if ($i + 1 == $NumberOfRecovery) { + $close = $end_open['Open']; + } + $data_new = ['open' => $open, 'close' => $close, 'high' => $high, 'low' => $low]; + // $data_new_after = ['Open' => $open, 'Close' => $close, 'High' => $high, 'Low' => $low,'time'=>date("Y-m-d H:i:s", $now_time + ($i * $period2_seconds)+60)]; + $data_new_after = ['Open' => $open, 'Close' => $close, 'High' => $high, 'Low' => $low, 'LastClose' => $close]; + // $cc['time'] = date("Y-m-d H:i:s", $now_time); + $model::query()->where('Date', $now_time + ($i * $period2_seconds) + 60)->where('is_1min', 1)->update($data_new_after); + // dump($data_new_after); + // Log::info(11111); + $this->OtherPeriod($now_time + ($i * $period2_seconds), $data_new, $model); + // dd($open, $close, $high, $low); + } + // dd($cc); + + + } + + /** + * Notes: 更新当前1分钟k线 + * @param $UpsAndDowns 涨跌0为涨1为跌 + * @param $UpdateValue 目标值 + * @param $Timing 定时时间 + * User: torsenli + * Date: 2022/3/20 + * Time: 18:00 + */ + public function UpdateTheCurrentMinute($UpsAndDowns, $UpdateValue, $Timing = null, $model, $one_min_date = null) + { + // Log::info(2222); + if ($UpsAndDowns > 0) { + if($UpdateValue>=$one_min_date['High']){ + $hight = $UpdateValue; + }else{ + $hight = $one_min_date['High']; + } + + $model::query()->where('Date', $Timing)->where('is_1min', 1)->update(['High' => $hight, 'Close' => $UpdateValue, 'LastClose' => $UpdateValue]); + // $model::query()->where('Date', $Timing + 60)->where('is_1min', 1)->update(['Low' => $UpdateValue, 'Open' => $UpdateValue]); + + // $data_new_one = ['open' => $one_min_date['Open'], 'close' => $UpdateValue, 'high' => $one_min_date['High'], 'low' => $UpdateValue]; + + + $data_new_one = ['open' => $one_min_date['Open'], 'close' => $UpdateValue, 'high' => $hight, 'low' => $one_min_date['Low']]; + $this->OtherPeriod($Timing, $data_new_one, $model); + } else { + if($UpdateValue<=$one_min_date['Low']) { + $low = $UpdateValue; + }else{ + $low = $one_min_date['Low']; + } + $model::query()->where('Date', $Timing)->where('is_1min', 1)->update(['Low' => $low, 'Close' => $UpdateValue, 'LastClose' => $UpdateValue]); + // $model::query()->where('Date', $Timing + 60)->where('is_1min', 1)->update(['High' => $UpdateValue, 'Open' => $UpdateValue]); + + $data_new_one = ['open' => $one_min_date['Open'], 'close' => $UpdateValue, 'high' => $one_min_date['High'], 'low' => $low]; + $this->OtherPeriod($Timing, $data_new_one, $model); + } + } + + /** + * Notes: 更新其他时段值 + * @param $now_time + * @param $data + * @param $model + * User: torsenli + * Date: 2022/3/22 + * Time: 17:39 + */ + public function OtherPeriod($now_time, $data, $model) + { + + // $testtime = '1647959640'; + // $testtime = strtotime('2022-03-22 22:29:00'); + $testtime = $now_time; + $now_time = $testtime; + $now_min = date('i', $now_time); + $is_in = strtotime(date('Y-m-d H:', $testtime) . $now_min . ":00"); + + + $other_min['is_5min']['uup'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 5) * 5 . ":00")- 60 * 5; + $other_min['is_5min']['start'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 5) * 5 . ":00"); + $other_min['is_5min']['end'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 5) * 5 . ":00") + 60 * 4; + $other_min['is_5min']['next'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 5) * 5 . ":00") + 60 * 5; + $other_min['is_15min']['uup'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 15) * 15 . ":00") - 60 * 15; + $other_min['is_15min']['start'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 15) * 15 . ":00"); + $other_min['is_15min']['end'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 15) * 15 . ":00") + 60 * 15 - 60; + $other_min['is_15min']['next'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 15) * 15 . ":00") + 60 * 15; + $other_min['is_30min']['uup'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 30) * 30 . ":00")-60 * 30; + $other_min['is_30min']['start'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 30) * 30 . ":00"); + $other_min['is_30min']['end'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 30) * 30 . ":00") + 60 * 30 - 60; + $other_min['is_30min']['next'] = strtotime(date('Y-m-d H:', $testtime) . intval($now_min / 30) * 30 . ":00") + 60 * 30; + $other_min['is_1h']['uup'] = strtotime(date('Y-m-d H:', $testtime) . "00:00")-60 * 60; + $other_min['is_1h']['start'] = strtotime(date('Y-m-d H:', $testtime) . "00:00"); + $other_min['is_1h']['end'] = strtotime(date('Y-m-d H:', $testtime) . "00:00") + 60 * 60 - 60; + $other_min['is_1h']['next'] = strtotime(date('Y-m-d H:', $testtime) . "00:00") + 60 * 60; + + foreach ($other_min as $val => $key) { + + Log::info(11111); + Log::info(date('Y-m-d H:i:s', $is_in)); + // 如果不是当前时间段跳过 + // if($is_in != $key['end']){ + // continue; + // } + Log::info($val); + Log::info(date('Y-m-d H:i:s', $is_in)); + Log::info(date('Y-m-d H:i:s', $key['start'])); + Log::info(date('Y-m-d H:i:s', $key['end'])); + + + $open = $model::query()->where('is_1min', 1)->where('Date', $key['start'])->value('Open'); + $close = $model::query()->where('is_1min', 1)->where('Date', $key['end'])->value('Close'); + $high = $model::query()->where('is_1min', 1)->whereBetween('Date', [$key['start'], $key['end']])->max('High'); + $low = $model::query()->where('is_1min', 1)->whereBetween('Date', [$key['start'], $key['end']])->min('Low'); + $volume = $model::query()->where('is_1min', 1)->whereBetween('Date', [$key['start'], $key['end']])->sum('Volume'); + $amount = $model::query()->where('is_1min', 1)->whereBetween('Date', [$key['start'], $key['end']])->sum('Amount'); + + $model::query()->where('Date', $key['start'])->where($val, 1)->update( + [ + 'Open' => $open, + 'Close' => $close, + 'High' => $high, + 'Low' => $low, + 'LastClose' => $close, + 'Volume' => $volume, + 'Amount' => $amount, + ] + ); + + + + + // + // // 更新当前时间段最高最低 + // $other_time_date = $model::query()->where('Date', $now_time)->where('is_1min', 1)->first()->toArray(); + // $up_date['High'] = $high = max($other_time_date['Open'], $other_time_date['High'], $other_time_date['Low'], $other_time_date['Close'], $data['open'], $data['close'], $data['high'], $data['low']); + // $up_date['Low'] = $low = min($other_time_date['Open'], $other_time_date['High'], $other_time_date['Low'], $other_time_date['Close'], $data['open'], $data['close'], $data['high'], $data['low']); + // // $test_date[] = ['high' => $high, 'low' => $low, 'oldhigh' => $other_time_date['High'], 'oldlow' => $other_time_date['Low']]; + // // 如果是时间段开始时间更新开盘 + // if ($now_time === $key['start']) { + // $uup_data = $model::query()->where('Date', $key['uup'])->where($val, 1)->first()->toArray(); + // $up_date['Open'] = $open = $uup_data['Close']; + // // Log::info($data['open']); + // // Log::info($key['start']); + // // Log::info($uup_data['Close']); + // // Log::info($val); + // // Log::info($now_time); + // if($val == 'is_15min'){ + // Log::info($val); + // // Log::info($uup_data); + // Log::info($key['start']); + // Log::info($key['uup']); + // Log::info($key['next']); + // } + // } + // // 如果是时间段收盘时间更新收盘 + // if ($now_time === $key['end']) { + // $up_date['Close'] = $close = $data['close']; + // $up_date['LastClose'] = $close = $data['close']; + // $next_line['Open'] = $data['close']; + // $model::query()->where('Date', $key['next'])->where($val, 1)->update($next_line); + // } + // // $up_date['time'] = date("Y-m-d H:i:s", $now_time); + // // $up_date['type'] = $val; + // // $up_date['kkyk'] = date("Y-m-d H:i:s", $now_time - 60); + // // $up_date['k1kyk'] = date("Y-m-d H:i:s", $key['start']); + // // $up_date['k2kyk'] = date("Y-m-d H:i:s", $key['end']); + // $model::query()->where('Date', $key['start'])->where($val, 1)->update($up_date); + // + // + // + // + + + + + + //更新缓存 + // Log::info($key['start']); + // Log::info($now_time); + // $period = 'is_'. $val; + + // 可能有用 + // $now_high = $model::query()->where('is_1min', 1)->whereBetween('Date', [$key['start'],$now_time])->max('High'); + // $now_low = $model::query()->where('is_1min', 1)->whereBetween('Date', [$key['start'],$now_time])->min('Low'); + + + // $low = DataRao::query()->where('is_1min', 1)->whereBetween('Date', [$where_start, $where_end])->min('Low'); + // $now_high = $model::query()->whereBetween('Date', $key['start'],$now_time)->where($period, 1)->max('High'); + // $now_low = $model::query()->whereBetween('Date', $key['start'],$now_time)->where($period, 1)->max('Low'); + // $periods = ['5min', '15min', '30min', '60min']; + // foreach ($periods as $period){ + // Log::info($coin); + + // 可能有用 + // $old_per = Cache::store('redis')->get('swap:' . $other_time_date['Symbol'] . '_kline_' . $val); + // $old_per['high'] = $now_high; + // $old_per['low'] = $now_low; + + + + + // Log::info($now_high); + // Log::info($old_per); + // // + // $old_per['high'] = $old_per['open']; + // $old_per['low'] = $old_per['open']; + + // 可能有用 + // Cache::store('redis')->put('swap:' . $other_time_date['Symbol'] . '_kline_' . $val,$old_per); + + + + + // } + + // unset($up_date); + } + // dd($up_date); + + + } + + /** + * Build a form here. + */ + public function form() + { + $this->radio('symbol','选择币种')->options(function (){ + $symbols = config('coin.exchange_symbols'); + $PlatformCurrency = []; + foreach ($symbols as $key=>$val){ + $PlatformCurrency[$key]= $key; + // var_dump($key); + } + return $PlatformCurrency; + + })->required(); + + // $this->text('rise','涨')->required(); + // $this->text('fall','跌')->required(); + $this->text('nowprice','结束价格')->required()->help('当前价格'); + $this->text('blacktime','回复时间')->default(function (){ + $aa = rand(10,25); + return $aa; + })->required()->help('回复时间'); + // $this->text('password')->required(); + // $this->text('InitializeUSDT', '初始化USDT')->default(0); + // $this->text('pid', '邀请人UID')->default(11); + // $this->text('referrer', '代理商UID')->default(11)->help('为空时默认与上级ID相等'); + $this->display(['现价'])->with(function($val){ + return ""; + }); + $this->display(['最高价'])->with(function($val){ + return ""; + }); + $this->display(['最低价'])->with(function($val){ + return ""; + }); + + Admin::script(" + $('input[type=radio]').change(function(){ + var val = $('input[name=symbol]:checked').val(); + $.post({url:'symbol-detal',data:{symbol:val},success:function(result){ + $('#current_price').html(result.price); + $('#highest').html(result.highest); + $('#minimum').html(result.minimum); + }}); + }); + "); + // $symbols = ContractPair::query()->pluck('symbol'); + // $index = 1; + // foreach ($symbols as $symbol) { + // $func = function () use ($symbol) { + // // 获取风控任务 + // $risk_key = 'fkJson:' . $symbol . '/USDT'; + // $risk = json_decode(Redis::get($risk_key), true); + // $this->row(function ($row) use ($symbol, $risk) { + // $minUnit = $risk['minUnit'] ?? 0; + // $count = $risk['count'] ?? 0; + // $enabled = $risk['enabled'] ?? 0; + // $strat_time = $risk['strat_time'] ?? 0; + // //$end_time = $risk['end_time'] ?? 0; + // $pin = $risk['pin'] ?? 0; + // + // $row->width(3)->text($symbol . '.' . 'minUnit', '单位')->default($minUnit); + // $row->width(3)->text($symbol . '.' . 'count', '计数')->default($count); + // $row->time($symbol . '.' . 'strat_time', '开始时间')->default($strat_time); + // //$row->time($symbol . '.' . 'end_time', '结束时间')->default($end_time); + // $row->width(3)->switch($symbol . '.' . 'enabled', '开关')->default($enabled); + // $row->width(3)->switch($symbol . '.' . 'pin', '是否指定时间')->default($pin); + // + // }); + // }; + // // 第一个参数是选项卡标题,第二个参数是内容,第三个参数是是否选中 + // $title = $symbol . '合约'; + // if ($index == 1) { + // $this->tab($title, $func, true); + // } else { + // $this->tab($title, $func); + // } + // $index++; + // } + } + + /** + * The data of the form. + * + * @return array + */ + public function default() + { + return []; + } +} diff --git a/app/Admin/routes.php b/app/Admin/routes.php index 5ec4369..da5ccbf 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -89,6 +89,7 @@ Route::group([ $router->resource('inside-trade-deal-robot', 'InsideTradeDealRobotController'); $router->resource('contract-deal-robot', 'ContractDealRobotController'); $router->resource('contract-risk', 'ContractRiskController'); + $router->resource('contract-risknew', 'ContractRisknewController'); $router->resource('contract-share', 'ContractShareController'); // 法币交易 diff --git a/app/BlockControl/Controllers/ContractRisknewController.php b/app/BlockControl/Controllers/ContractRisknewController.php new file mode 100644 index 0000000..1ff7f8b --- /dev/null +++ b/app/BlockControl/Controllers/ContractRisknewController.php @@ -0,0 +1,22 @@ +title('新风控') + ->body(new Card(new \App\BlockControl\Forms\ContractRisknew())); + } +} diff --git a/app/BlockControl/Forms/ContractRisknew.php b/app/BlockControl/Forms/ContractRisknew.php new file mode 100644 index 0000000..32386e0 --- /dev/null +++ b/app/BlockControl/Forms/ContractRisknew.php @@ -0,0 +1,81 @@ +pluck('symbol'); + foreach ($symbols as $symbol) { + if (!empty($input[$symbol])) { + $risk_key = 'fkJson:' . $symbol . '/USDT'; + $data = $input[$symbol]; + Redis::set($risk_key, json_encode($data)); + } + } + + // return $this->error('Your error message.'); + + return $this->success('Processed successfully.'); + } + + /** + * Build a form here. + */ + public function form() + { + $symbols = ContractPair::query()->pluck('symbol'); + + $index = 1; + foreach ($symbols as $symbol) { + $func = function () use ($symbol) { + // 获取风控任务 + $risk_key = 'fkJson:' . $symbol . '/USDT'; + $risk = json_decode(Redis::get($risk_key), true); + $this->row(function ($row) use ($symbol, $risk) { + $minUnit = $risk['minUnit'] ?? 0; + $count = $risk['count'] ?? 0; + $enabled = $risk['enabled'] ?? 0; + + $row->width(3)->text($symbol . '.' . 'minUnit', '单位')->default($minUnit); + $row->width(3)->text($symbol . '.' . 'count', '计数')->default($count); + $row->width(3)->switch($symbol . '.' . 'enabled', '开关')->default($enabled); + }); + }; + // 第一个参数是选项卡标题,第二个参数是内容,第三个参数是是否选中 + $title = $symbol . '合约'; + if ($index == 1) { + $this->tab($title, $func, true); + } else { + $this->tab($title, $func); + } + $index++; + } + } + + /** + * The data of the form. + * + * @return array + */ + public function default() + { + return []; + } +} diff --git a/app/BlockControl/routes.php b/app/BlockControl/routes.php index 63464b6..71b9d65 100644 --- a/app/BlockControl/routes.php +++ b/app/BlockControl/routes.php @@ -23,6 +23,7 @@ Route::group([ $router->get('/', 'HomeController@index'); $router->resource('contract-risk', 'ContractRiskController'); + $router->resource('contract-risknew', 'ContractRisknewController'); // 控盘行情 $router->resource('kline-robot', 'KlineRobotController'); diff --git a/app/Http/Controllers/Api/V1/LoginController.php b/app/Http/Controllers/Api/V1/LoginController.php index 433060c..34f276f 100644 --- a/app/Http/Controllers/Api/V1/LoginController.php +++ b/app/Http/Controllers/Api/V1/LoginController.php @@ -198,7 +198,7 @@ class LoginController extends ApiController 'code' => 'required|string', //验证码 'password' => 'required|string|confirmed:password_confirmation|min:8|max:16', //密码 'password_confirmation' => 'required', //确认密码 - 'gc_code' => 'required', + // 'gc_code' => 'required', 'invite_code' => '', //邀请码 ])) return $vr; diff --git a/app/Http/Controllers/Appapi/V1/LoginController.php b/app/Http/Controllers/Appapi/V1/LoginController.php index 529df02..02e432d 100644 --- a/app/Http/Controllers/Appapi/V1/LoginController.php +++ b/app/Http/Controllers/Appapi/V1/LoginController.php @@ -184,14 +184,12 @@ class LoginController extends ApiController $account = $request->input('email'); + // return $this->success($account); // if($this->agent->isDesktop()){ // $token = $request->input('token'); // if( ($checkResult = checkSliderVerify($account,$token)) !== true ) return $this->error(0,$checkResult); // } - Log::info($request->input('gc_key')); - Log::info(1111); - Log::info($account); - Log::info($_SERVER["REMOTE_ADDR"]); + $type = $request->input('type', 1); if ($type == 1) { //注册验证码 diff --git a/app/Models/PlatformContractControl.php b/app/Models/PlatformContractControl.php new file mode 100644 index 0000000..a6d9c22 --- /dev/null +++ b/app/Models/PlatformContractControl.php @@ -0,0 +1,23 @@ + $class) { if($coin1 == 'AAAAA'){ @@ -138,7 +138,7 @@ class Events } }, [$periods, $coin1, $class]); - Timer::add(5, function ($coin1, $class) { + Timer::add($seconds, function ($coin1, $class) { $coin1_symbol = $coin1; $kline = $class::query()->where('Date', '<', time())->where('is_1min', 1)->orderByDesc('Date')->first(); $day_kline = $class::query()->where('Date', Carbon::yesterday()->getTimestamp())->where('is_day', 1)->orderByDesc('Date')->first();