fix: API路由补齐+后台全面中文化
This commit is contained in:
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\AccountLog;
|
||||
use App\Currency;
|
||||
use App\Users;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class AccountLogController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
//获取type类型
|
||||
$type = array(
|
||||
AccountLog::ADMIN_LEGAL_BALANCE => '法币账户余额',
|
||||
AccountLog::ADMIN_LOCK_LEGAL_BALANCE => '法币账户锁定余额',
|
||||
AccountLog::ADMIN_CHANGE_BALANCE => '币币账户余额',
|
||||
AccountLog::ADMIN_LOCK_CHANGE_BALANCE => '币币账户锁定余额',
|
||||
AccountLog::ADMIN_LEVER_BALANCE => '杠杆账户余额',
|
||||
AccountLog::ADMIN_LOCK_LEVER_BALANCE => '杠杆账户锁定余额',
|
||||
AccountLog::ADMIN_MICRO_BALANCE => '期权账户余额', //后台调节期权账户余额
|
||||
AccountLog::ADMIN_LOCK_MICRO_BALANCE => '期权账户锁定余额', //后台调节期权账户锁定余额
|
||||
AccountLog::WALLET_CURRENCY_OUT => '法币账户转出至交易账户',
|
||||
AccountLog::WALLET_CURRENCY_IN => '交易账户转入至法币账户',
|
||||
9 => 'c2c划转期权',
|
||||
10 => '期权划转c2c',
|
||||
AccountLog::MICRO_TRADE_CLOSE_SETTLE => '期权平仓结算',
|
||||
AccountLog::USER_BUY_INSURANCE => '用户购买保险',
|
||||
AccountLog::USER_CLAIM_COMPENSATION => '赔偿用户',
|
||||
AccountLog::INSURANCE_RESCISSION1 => '保险解约,清除受保金额',
|
||||
AccountLog::INSURANCE_RESCISSION2 => '保险解约,清除保险金额',
|
||||
AccountLog::INSURANCE_RESCISSION_ADD => '保险解约,赔付用户',
|
||||
AccountLog::RETURN_INSURANCE_TRADE_FEE => '释放保险交易手续费',
|
||||
|
||||
|
||||
AccountLog::LOWER_REBATE => '下级返利',
|
||||
AccountLog::INSURANCE_MONEY => '用户持险生币',
|
||||
|
||||
AccountLog::LEGAL_USER_BUY => '用户购买商家法币成功',
|
||||
AccountLog::LEGAL_SELLER_BUY => '商家购买用户法币成功',
|
||||
AccountLog::TRANSACTIONOUT_SUBMIT_REDUCE => '提交卖出,扣除',
|
||||
AccountLog::TRANSACTIONIN_REDUCE => '买入扣除',
|
||||
|
||||
AccountLog::INVITATION_TO_RETURN => '邀请返佣金',
|
||||
AccountLog::ETH_EXCHANGE => '链上充币',
|
||||
|
||||
);
|
||||
$currency_type = Currency::all();
|
||||
return view("admin.account.index", [
|
||||
'types' => $type,
|
||||
'currency_type' => $currency_type
|
||||
]);
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$account = $request->get('account', '');
|
||||
$start_time = strtotime($request->get('start_time', 0));
|
||||
$end_time = strtotime($request->get('end_time', 0));
|
||||
$currency = $request->get('currency_type', 0);
|
||||
$type = $request->get('type', 0);
|
||||
$sign = $request->get('sign', 0);//正负号,0所有,1,正,-1,负号
|
||||
|
||||
$list = new AccountLog();
|
||||
if (!empty($currency)) {
|
||||
$list = $list->where('currency', $currency);
|
||||
}
|
||||
if (!empty($type)) {
|
||||
$list = $list->where('type', $type);
|
||||
}
|
||||
if (!empty($start_time)) {
|
||||
$list = $list->where('created_time', '>=', $start_time);
|
||||
}
|
||||
if (!empty($end_time)) {
|
||||
$list = $list->where('created_time', '<=', $end_time);
|
||||
}
|
||||
if (!empty($sign)) {
|
||||
if($sign > 0){
|
||||
$list = $list->where('value', '>', 0);
|
||||
}else{
|
||||
$list = $list->where('value', '<', 0);
|
||||
}
|
||||
|
||||
}
|
||||
//根据关联模型的时间
|
||||
/*if(!empty($start_time)){
|
||||
$list = $list->whereHas('walletLog', function ($query) use ($start_time) {
|
||||
$query->where('create_time','>=',$start_time);
|
||||
});
|
||||
}
|
||||
if(!empty($end_time)){
|
||||
$list = $list->whereHas('walletLog', function ($query) use ($end_time) {
|
||||
$query->where('create_time','<=',$end_time);
|
||||
});
|
||||
}*/
|
||||
if (!empty($account)) {
|
||||
$list = $list->whereHas('user', function ($query) use ($account) {
|
||||
$query->where("phone", 'like', '%' . $account . '%')->orwhere('email', 'like', '%' . $account . '%');
|
||||
});
|
||||
}
|
||||
|
||||
/* if (!empty($account_number)) {
|
||||
$list = $list->whereHas('user', function($query) use ($account_number) {
|
||||
$query->where('account_number','like','%'.$account_number.'%');
|
||||
} );
|
||||
}*/
|
||||
|
||||
if (!empty($type)) {
|
||||
$sum = $list->sum('value');
|
||||
}else{
|
||||
$sum = '选择日志类型进行统计';
|
||||
}
|
||||
|
||||
$list = $list->orderBy('id', 'desc')->paginate($limit);
|
||||
//dd($list->items());
|
||||
return response()->json(['code' => 0, 'data' => $list->items(), 'count' => $list->total(), 'sum'=>$sum]);
|
||||
}
|
||||
|
||||
public function view(Request $request)
|
||||
{
|
||||
$id = $request->get('id', null);
|
||||
$results = new AccountLog();
|
||||
$results = $results->where('id', $id)->first();
|
||||
if (empty($results)) {
|
||||
return $this->error('无此记录');
|
||||
}
|
||||
return view('admin.account.viewDetail', ['results' => $results]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function indexprofits()
|
||||
{
|
||||
$scene_list = AccountLog::where("type", "=", AccountLog::PROFIT_LOSS_RELEASE)->orderBy("created_time", "desc")->get()->toArray();
|
||||
// var_dump($scene_list);die;
|
||||
return view('admin.profits.index')->with('scene_list', $scene_list);
|
||||
}
|
||||
|
||||
public function listsprofits(Request $request)
|
||||
{
|
||||
$limit = $request->input('limit', 10);
|
||||
$prize_pool = AccountLog::whereHas('user', function ($query) use ($request) {
|
||||
$account_number = $request->input('account_number');
|
||||
if ($account_number) {
|
||||
$query->where('account_number', $account_number);
|
||||
}
|
||||
})->where(function ($query) use ($request) {
|
||||
// $scene = $request->input('scene', -1);
|
||||
$start_time = strtotime($request->input('start_time', null));
|
||||
$end_time = strtotime($request->input('end_time', null));
|
||||
// $scene != -1 && $query->where('scene', $scene);
|
||||
$start_time && $query->where('created_time', '>=', $start_time);
|
||||
$end_time && $query->where('created_time', '<=', $end_time);
|
||||
})->where("type", AccountLog::PROFIT_LOSS_RELEASE)->orderBy('id', 'desc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($prize_pool);
|
||||
}
|
||||
|
||||
public function countprofits(Request $request)
|
||||
{
|
||||
$count_data = AccountLog::selectRaw('1 as user_count')
|
||||
->selectRaw('sum(`value`) as value')
|
||||
->whereHas('user', function ($query) use ($request) {
|
||||
$account_number = $request->input('account_number');
|
||||
if ($account_number) {
|
||||
$query->where('account_number', $account_number)
|
||||
->orWhere('phone', $account_number)
|
||||
->orWhere('email', $account_number);
|
||||
}
|
||||
})->where(function ($query) use ($request) {
|
||||
//$scene = $request->input('scene', -1);
|
||||
$start_time = strtotime($request->input('start_time', null));
|
||||
$end_time = strtotime($request->input('end_time', null));
|
||||
//$scene != -1 && $query->where('scene', $scene);
|
||||
$start_time && $query->where('created_time', '>=', $start_time);
|
||||
$end_time && $query->where('created_time', '<=', $end_time);
|
||||
})->where("type", AccountLog::PROFIT_LOSS_RELEASE)->groupBy('user_id')->get();
|
||||
$user_count = $count_data->pluck('user_count')->sum();
|
||||
$reward_total = 0;
|
||||
$count_data->pluck('value')->each(function ($item, $key) use (&$reward_total) {
|
||||
$reward_total = bc_add($reward_total, $item);
|
||||
});
|
||||
return response()->json([
|
||||
'user_count' => $user_count,
|
||||
'reward_total' => $reward_total,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\Admin;
|
||||
use App\AdminRole;
|
||||
use App\Agent;
|
||||
use App\Users;
|
||||
use App\UsersWallet;
|
||||
use Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Earnp\GoogleAuthenticator\GoogleAuthenticator;
|
||||
use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator;
|
||||
|
||||
class AdminController extends Controller{
|
||||
|
||||
public function users(){
|
||||
$adminuser = Admin::where('id', '>', 0);
|
||||
if(session()->get('admin_is_super') != '1') {
|
||||
$adminuser->where('role_id', '>', 1);
|
||||
}
|
||||
$adminuser = $adminuser->get();
|
||||
$count = $adminuser -> count();
|
||||
return response()->json(['code'=>0,'count'=>$count,'msg'=>'','data'=>$adminuser]);
|
||||
}
|
||||
public function editAddress(){
|
||||
$id = Input::get('id',null);
|
||||
$address = Input::get('address');
|
||||
$address_2 = Input::get('address_2');
|
||||
$data = [
|
||||
'address_2' => $address_2,'address' => $address];
|
||||
|
||||
UsersWallet::where('id',$id)->update($data);
|
||||
|
||||
return $this->success('编辑成功');
|
||||
}
|
||||
public function add()
|
||||
{
|
||||
// if(session()->get('admin_is_super') != '1') {
|
||||
// abort(403);
|
||||
// }
|
||||
$id = Input::get('id',null);
|
||||
$google = ['secret'=>'','qrcode'=>''];
|
||||
if(empty($id)) {
|
||||
$adminUser = new Admin();
|
||||
}else{
|
||||
$adminUser = Admin::find($id);
|
||||
if($adminUser == null) {
|
||||
abort(404);
|
||||
}
|
||||
if(session()->get("admin_id") == $id){
|
||||
$google = GoogleAuthenticator::CreateSecret();
|
||||
$qrcode = new BaconQrCodeGenerator();
|
||||
$google['qrcode'] = $qrcode->encoding('UTF-8')->size(180)->margin(1)->generate($google['codeurl']);
|
||||
}
|
||||
}
|
||||
$roles = AdminRole::all();
|
||||
return view('admin.manager.add', ['admin_user' => $adminUser, 'roles' => $roles,'google'=>$google]);
|
||||
}
|
||||
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
// if(session()->get('admin_is_super') != '1') {
|
||||
// abort(403);
|
||||
// }
|
||||
$id = Input::get('id', null);
|
||||
$validator = Validator::make(Input::all(), [
|
||||
'username' => 'required',
|
||||
'role_id' => 'required|numeric'
|
||||
], [
|
||||
'username.required' => '姓名必须填写',
|
||||
'role_id.required' => '角色必须选择',
|
||||
'role_id.numeric' => '角色必须为数字'
|
||||
]);
|
||||
if(empty($id)) {
|
||||
$adminUser = new Admin();
|
||||
}else{
|
||||
$adminUser = Admin::find($id);
|
||||
if($adminUser == null) {
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
$password = Input::get('password', '');
|
||||
$authcode = Input::get('authcode', '');
|
||||
$google = Input::get('google', '');
|
||||
if(!empty($authcode)){
|
||||
if(!GoogleAuthenticator::CheckCode($google,$authcode)){
|
||||
$validator->errors()->add('authcode', '谷歌验证码错误');
|
||||
}
|
||||
$adminUser->google = $google;
|
||||
}
|
||||
$adminUser->role_id = Input::get('role_id', '0');
|
||||
if(Input::get('password', '') != '') {
|
||||
$adminUser->password = Users::MakePassword($password);
|
||||
}
|
||||
$validator->after(function($validator) use ($adminUser, $id)
|
||||
{
|
||||
if(empty($id)) {
|
||||
if (Admin::where('username', Input::get('username'))->exists()) {
|
||||
$validator->errors()->add('username', '用户已经存在');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$adminUser->username = Input::get('username', '');
|
||||
if($validator->fails()) {
|
||||
return $this->error($validator->errors()->first());
|
||||
}
|
||||
try {
|
||||
$adminUser->save();
|
||||
}catch (\Exception $ex){
|
||||
$validator->errors()->add('error', $ex->getMessage());
|
||||
return $this->error($validator->errors()->first());
|
||||
}
|
||||
return $this->success('添加成功');
|
||||
}
|
||||
|
||||
public function del()
|
||||
{
|
||||
$admin = Admin::find(Input::get('id'));
|
||||
if($admin == null) {
|
||||
abort(404);
|
||||
}
|
||||
$bool = $admin->delete();
|
||||
if($bool){
|
||||
return $this->success('删除成功');
|
||||
}else{
|
||||
return $this->error('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
public function agent(){
|
||||
|
||||
$admin = Agent::where('is_admin' , 1)->where('level' , 0)->first();
|
||||
|
||||
if ($admin != null ){
|
||||
return redirect(route('agent'));
|
||||
}else{
|
||||
$hkok = DB::table('admin')->where('id' , 1)->first();
|
||||
|
||||
if ($hkok != null ){
|
||||
$insertData = [];
|
||||
$insertData['user_id'] = $hkok->id;
|
||||
$insertData['username'] = $hkok->username;
|
||||
$insertData['password'] = $hkok->password;
|
||||
$insertData['level'] = 0;
|
||||
$insertData['is_admin'] = 1;
|
||||
$insertData['reg_time'] = time();
|
||||
$insertData['pro_loss'] = 100.00;
|
||||
$insertData['pro_ser'] = 100.00;
|
||||
|
||||
$id = DB::table('agent')->insertGetId($insertData);
|
||||
|
||||
if ($id>0){
|
||||
return redirect(route('agent'));
|
||||
}else{
|
||||
return $this->error('失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\AdminRole;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Validator;
|
||||
|
||||
class AdminRoleController extends Controller{
|
||||
|
||||
public function users()
|
||||
{
|
||||
// if(session()->get('admin_is_super') != '1') {
|
||||
// abort(403);
|
||||
// }
|
||||
$adminUses = AdminRole::all();
|
||||
return response()->json(['code'=>0,'data'=>$adminUses]);
|
||||
}
|
||||
|
||||
public function add(){
|
||||
|
||||
// if(session()->get('admin_is_super') != '1') {
|
||||
// abort(404);
|
||||
// }
|
||||
$id = Input::get('id',null);
|
||||
|
||||
if(empty($id)){
|
||||
$adminRole = New AdminRole();
|
||||
$adminRole -> is_super = 0;
|
||||
}else{
|
||||
$adminRole = AdminRole::find($id);
|
||||
if($adminRole == null) {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
return view('admin.manager.role_add', ['admin_role' => $adminRole]);
|
||||
}
|
||||
|
||||
public function postAdd(){
|
||||
// if(session()->get('admin_is_super') != '1') {
|
||||
// abort(403);
|
||||
// }
|
||||
$id = Input::get('id', null);
|
||||
|
||||
$validator = Validator::make(Input::all(), [
|
||||
'name' => 'required',
|
||||
], [
|
||||
'name.required' => '角色名称必须填写',
|
||||
]);
|
||||
|
||||
if(empty($id)) {
|
||||
$adminRole = new AdminRole();
|
||||
}else{
|
||||
$adminRole = AdminRole::find($id);
|
||||
if($adminRole == null) {
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
$adminRole->name = Input::get('name', '');
|
||||
$adminRole->is_super = Input::get('is_super', '');
|
||||
|
||||
if($validator->fails()) {
|
||||
return $this->error($validator->errors()->first());
|
||||
}
|
||||
try {
|
||||
$adminRole->save();
|
||||
}catch (\Exception $ex){
|
||||
$validator->errors()->add('error', $ex->getMessage());
|
||||
return $this->error($validator->errors()->first());
|
||||
}
|
||||
return $this->success('添加成功');
|
||||
}
|
||||
|
||||
public function del(Request $request){
|
||||
$id = $request->get('id');
|
||||
$admin_role = AdminRole::find($id);
|
||||
$bool = $admin_role->delete();
|
||||
if($bool){
|
||||
return $this->success('删除成功');
|
||||
}else{
|
||||
return $this->error('删除失败');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\AdminModule;
|
||||
use App\AdminModuleAction;
|
||||
use App\AdminRole;
|
||||
use App\AdminRolePermission;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class AdminRolePermissionController extends Controller{
|
||||
|
||||
public function update()
|
||||
{
|
||||
if(session()->get('admin_is_super') != '1') {
|
||||
abort(403);
|
||||
}
|
||||
$id = Input::get('id', '');
|
||||
$adminRole = AdminRole::find($id);
|
||||
if($adminRole == null) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$modules = AdminModule::all();
|
||||
$modules_data = [];
|
||||
foreach ($modules as $index=>$m)
|
||||
{
|
||||
$action = AdminModuleAction::where("admin_module_id",$m->id)->where("level",">=",0)->get();
|
||||
if (count($action)){
|
||||
$m->actions = $action;
|
||||
$modules_data[$index] = $m;
|
||||
}
|
||||
}
|
||||
$results = AdminRolePermission::where('role_id', $adminRole->id)->get();
|
||||
if(empty($results)){
|
||||
$permissions = [];
|
||||
}else{
|
||||
$results = $results->toArray();
|
||||
$permissions = [];
|
||||
foreach($results as $row) {
|
||||
$permissions[$row['module']][] = $row['action'];
|
||||
}
|
||||
}
|
||||
return view('admin.manager.role_permission', [
|
||||
'admin_role' => $adminRole,
|
||||
'modules' => $modules_data,
|
||||
'permissions' => $permissions,
|
||||
'success' => Session::get('success', null)
|
||||
]);
|
||||
}
|
||||
|
||||
public function postUpdate()
|
||||
{
|
||||
if(session()->get('admin_is_super') != '1') {
|
||||
abort(403);
|
||||
}
|
||||
$roleID = Input::get('id', null);
|
||||
|
||||
$role = AdminRole::find($roleID);
|
||||
if($role == null) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
AdminRolePermission::where('role_id', $roleID)->delete();
|
||||
foreach(Input::get('permission') as $module => $actions)
|
||||
{
|
||||
foreach($actions as $action)
|
||||
{
|
||||
$level = AdminModuleAction::where("action",$action)->first();
|
||||
$adminRolePermission = new AdminRolePermission();
|
||||
$adminRolePermission->role_id = $roleID;
|
||||
$adminRolePermission->module = $module;
|
||||
$adminRolePermission->action = $action;
|
||||
$adminRolePermission->level = $level->level;
|
||||
$adminRolePermission->admin_module_id = $level->admin_module_id;
|
||||
$adminRolePermission->name = $level->name;
|
||||
$adminRolePermission->save();
|
||||
}
|
||||
}
|
||||
return $this->success('修改成功');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\Process\Process;
|
||||
use App\Admin;
|
||||
use App\Users;
|
||||
use App\Currency;
|
||||
use App\UserLevelModel;
|
||||
use App\DualCurrency;
|
||||
use App\DualOrder;
|
||||
use App\AiCurrency;
|
||||
use App\AiOrder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AiController extends Controller
|
||||
{
|
||||
private $Month_E = array('01' => "Jan",
|
||||
'02' => "Feb",
|
||||
'03' => "Mar",
|
||||
'04' => "Apr",
|
||||
'05' => "May",
|
||||
'06' => "Jun",
|
||||
'07' => "Jul",
|
||||
'08' => "Aug",
|
||||
'09' => "Sep",
|
||||
'10' => "Oct",
|
||||
'11' => "Nov",
|
||||
'12' => "Dec");
|
||||
|
||||
public function index(){
|
||||
|
||||
return view('admin.ai.index');
|
||||
}
|
||||
|
||||
public function order(){
|
||||
|
||||
|
||||
return view('admin.ai.order');
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function order_lists(Request $request){
|
||||
|
||||
$limit = $request->get('limit', 20);
|
||||
$orderid = $request->get('orderid');
|
||||
$user_id = $request->get('user_id');
|
||||
$status = $request->get('status');
|
||||
|
||||
|
||||
$list = DB::table('ai_order')->join('ai_currency', 'ai_currency.id', '=', 'ai_order.ai_id');
|
||||
|
||||
if($orderid){
|
||||
$list->where('ai_order.orderid','LIKE','%'.$orderid.'%');
|
||||
}
|
||||
|
||||
if($status){
|
||||
$list->where('ai_order.status',$status);
|
||||
}
|
||||
|
||||
if($user_id){
|
||||
$list->where('ai_order.user_id',$user_id);
|
||||
}
|
||||
|
||||
$list = $list->select('ai_order.*','ai_currency.days')->orderBy('ai_order.id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function add(){
|
||||
$currencies = Currency::where('is_legal', 1)->get();
|
||||
$userlevel = UserLevelModel::where('status', 1)->get();
|
||||
return view('admin.ai.add')->with('currencies', $currencies)->with('userlevel', $userlevel);
|
||||
}
|
||||
|
||||
|
||||
public function editAiView(Request $request){
|
||||
$id = $request->get('id');
|
||||
if(empty($id)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$ai_currency = AiCurrency::where(['id'=>$id])->first();
|
||||
|
||||
$invest = $ai_currency->invest;
|
||||
|
||||
|
||||
$currencies = Currency::where('is_legal', 1)->get();
|
||||
$userlevel = UserLevelModel::where('status', 1)->get();
|
||||
// dump($dual_currency);die;
|
||||
return view('admin.ai.edit_ai',['results' => $ai_currency])->with('currencies', $currencies)->with('invest', $invest)->with('userlevel', $userlevel);
|
||||
}
|
||||
|
||||
//编辑项目
|
||||
public function editAi(Request $request){
|
||||
|
||||
$id = $request->post('id');
|
||||
$name = $request->post('name');
|
||||
$days = $request->post('days');
|
||||
$rate = $request->post('rate');
|
||||
$ratemax = $request->post('ratemax');
|
||||
$amount = $request->post('amount');
|
||||
$amax = $request->post('amax');
|
||||
$status = $request->post('status');
|
||||
$hot = $request->post('hot');
|
||||
$commission = $request->post('commission');
|
||||
// $total_number = $request->post('total_number');
|
||||
$invest = $request->post('invest');
|
||||
$investtr ='';
|
||||
foreach ($invest as $k=>$v){
|
||||
|
||||
$investtr .=$v.'+';
|
||||
}
|
||||
// $liquidateddamages = $request->post('liquidateddamages');
|
||||
|
||||
if(empty($days)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
if($rate >= $ratemax){
|
||||
// return $this->error('起始回报率不能大于最大回报率');
|
||||
}
|
||||
|
||||
|
||||
if($amount >= $amax){
|
||||
// return $this->error('起始金额不能大于最大金额');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$dual_currency = AiCurrency::where(['id'=>$id])->first();
|
||||
$dual_currency->invest = substr($investtr, 0, strlen($investtr) - 1);
|
||||
$dual_currency->total_number = 0;//$total_number;
|
||||
$dual_currency->remaining_number =0;// $total_number;
|
||||
$dual_currency->hot = $hot;
|
||||
$dual_currency->commission = $commission;
|
||||
$dual_currency->days = $days;
|
||||
$dual_currency->name = $name;//$days."天";
|
||||
$dual_currency->rate = $rate;
|
||||
$dual_currency->ratemax = $ratemax;
|
||||
$dual_currency->amount = $amount;
|
||||
$dual_currency->amax = $amax;
|
||||
$dual_currency->liquidateddamages = 0;//$liquidateddamages;
|
||||
$dual_currency->status = $status;
|
||||
$dual_currency->save();
|
||||
|
||||
return $this->success('操作成功');
|
||||
// return $this->success(['data'=>$dual_currency]);
|
||||
}
|
||||
|
||||
//删除项目
|
||||
public function del(Request $request){
|
||||
$id = $request->post('id');
|
||||
|
||||
// file_put_contents('/www/wwwroot/xb-dex/public/d.txt',time().$id.PHP_EOL,FILE_APPEND);
|
||||
$Zhiya_lk = AiCurrency::where('id',$id)->first();//->get();
|
||||
|
||||
|
||||
if(empty($Zhiya_lk)){
|
||||
return $this->error('不存在');
|
||||
}
|
||||
|
||||
if($id){
|
||||
//whereNotIn
|
||||
|
||||
AiCurrency::where('id', $id)->delete();
|
||||
|
||||
return $this->success('操作成功');
|
||||
}else{
|
||||
|
||||
return $this->error('失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//新增项目
|
||||
public function saveAi(Request $request){
|
||||
$data = $request->all();
|
||||
$days = $data['days'];
|
||||
$name = $data['name'];
|
||||
$amount = $data['amount'];
|
||||
$amax = $data['amax'];
|
||||
$rate = $data['rate'];
|
||||
$ratemax = $data['ratemax'];
|
||||
$hot = $data['hot'];
|
||||
$commission = $data['commission'];
|
||||
//$total_number = $data['total_number'];
|
||||
$invest = $data['invest'];
|
||||
$investtr ='';
|
||||
foreach ($invest as $k=>$v){
|
||||
|
||||
$investtr .=$v.'/';
|
||||
}
|
||||
// return $this->error($investtr);
|
||||
if($data['days'] && $data['ratemax'] && $data['rate'] && $data['amount'] && $data['amax']){
|
||||
|
||||
|
||||
|
||||
if($rate >= $ratemax){
|
||||
// return $this->error('起始回报率不能大于最大回报率');
|
||||
}
|
||||
if($amount >= $amax){
|
||||
// return $this->error('起始金额不能大于最大金额');
|
||||
}
|
||||
|
||||
// $_tp = $data['type'] =='call'? 'C':'P';
|
||||
|
||||
|
||||
$dual_currency = new AiCurrency();
|
||||
$dual_currency->invest = substr($investtr, 0, strlen($investtr) - 1);
|
||||
$dual_currency->total_number = 0;//$total_number;
|
||||
$dual_currency->remaining_number = 0;//$total_number;
|
||||
$dual_currency->hot = $hot;
|
||||
$dual_currency->commission = $commission;
|
||||
$dual_currency->days = $days;
|
||||
$dual_currency->name = $name;//$days."天";
|
||||
$dual_currency->rate = $data['rate'];
|
||||
$dual_currency->ratemax = $data['ratemax'];
|
||||
$dual_currency->amount = $data['amount'];
|
||||
$dual_currency->amax = $data['amax'];
|
||||
$dual_currency->liquidateddamages = 0;//$data['liquidateddamages'];
|
||||
|
||||
$dual_currency->created = date('Y-m-d',time());
|
||||
|
||||
|
||||
$dual_currency->save();
|
||||
|
||||
return $this->success('操作成功');
|
||||
}else{
|
||||
|
||||
return $this->error('必填项不能为空');
|
||||
}
|
||||
}
|
||||
|
||||
//获取实时价格
|
||||
public function getNewPrice(Request $request){
|
||||
$currency = $request->get('currency');
|
||||
$currencys = Currency::where('id',$currency)->get()->toArray();
|
||||
|
||||
return $this->success(['data'=>$currencys]);
|
||||
}
|
||||
|
||||
//理财设置
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 20);
|
||||
$status = $request->get('status');
|
||||
|
||||
$results = AiCurrency::where('id','>',1);
|
||||
|
||||
|
||||
if(isset($status)){
|
||||
$results->where('status',$status);
|
||||
}
|
||||
|
||||
// dump($results);die;
|
||||
$results = $results->orderBy('id', 'desc')->orderBy('status','desc')->paginate($limit);
|
||||
|
||||
|
||||
return $this->layuiData($results);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\AutoList;
|
||||
use App\Currency;
|
||||
use App\Users;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class AutoController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
return view('admin.auto.index');
|
||||
}
|
||||
|
||||
public function add(Request $request){
|
||||
$id = $request->get('id',null);
|
||||
if (empty($id)){
|
||||
$result = new AutoList();
|
||||
}else{
|
||||
$result = AutoList::find($id);
|
||||
}
|
||||
$currencies = Currency::where('id','>',0)->orderBy('id','desc')->get();
|
||||
$legals = Currency::where('is_legal',1)->orderBy('id','desc')->get();
|
||||
return view('admin.auto.add')->with(['currencies'=>$currencies,'legals'=>$legals,'result'=>$result]);
|
||||
}
|
||||
|
||||
public function postAdd(Request $request){
|
||||
$id = $request->get('id',null);
|
||||
$sell_account = $request->get('sell_account',null);
|
||||
$buy_account = $request->get('buy_account',null);
|
||||
$currency_id = $request->get('currency_id',null);
|
||||
$legal_id = $request->get('legal_id',null);
|
||||
$min_price = $request->get('min_price',null);
|
||||
$max_price = $request->get('max_price',null);
|
||||
$min_number = $request->get('min_number',null);
|
||||
$max_number = $request->get('max_number',null);
|
||||
$need_second = $request->get('need_second',null);
|
||||
|
||||
$messages = [
|
||||
'sell_account.required' => '卖家账号必填',
|
||||
'buy_account.required' => '买家账号必填',
|
||||
'currency_id.required' => '请选择交易币',
|
||||
'currency_id.integer' => '交易币值必须为整型',
|
||||
'legal_id.required' => '请选择法币',
|
||||
'legal_id.integer' => '法币值必须为整型',
|
||||
'min_price.required' => '请填写最低价格区间',
|
||||
'min_price.numeric' => '最低价格区间必须为数字',
|
||||
'max_price.required' => '请填写最高价格区间',
|
||||
'max_price.numeric' => '最高价格区间必须为数字',
|
||||
'min_number.required' => '请填写最低随机购买数量',
|
||||
'min_number.numeric' => '最低随机购买数量必须为数字',
|
||||
'max_number.required' => '请填写最高随机购买数量',
|
||||
'max_number.numeric' => '最高随机购买数量必须为数字',
|
||||
'need_second.required' => '请填写生成频率',
|
||||
'need_second.integer' => '生成频率必须为整型',
|
||||
];
|
||||
|
||||
//验证
|
||||
$validator = Validator::make($request->all(), [
|
||||
'sell_account' => 'required', //正则验证 如有多条不能用| 必须是数组 ['required','regex:/^[a-zA-Z0-9]$/']
|
||||
'buy_account' => 'required',
|
||||
'currency_id' => 'required|integer',
|
||||
'legal_id' => 'required|integer',
|
||||
'min_price' => 'required|numeric',
|
||||
'max_price' => 'required|numeric',
|
||||
'min_number' => 'required|numeric',
|
||||
'max_number' => 'required|numeric',
|
||||
'need_second' => 'required|integer',
|
||||
], $messages);
|
||||
|
||||
if ($validator->fails()){
|
||||
return $this->error($validator->errors()->first());
|
||||
}
|
||||
|
||||
$sell_user = Users::where('account_number',$sell_account)->first();
|
||||
if (empty($sell_user)) return $this->error('卖家用户不存在');
|
||||
$buy_user = Users::where('account_number',$buy_account)->first();
|
||||
if (empty($buy_user)) return $this->error('卖家账号不存在');
|
||||
$currency = Currency::find($currency_id);
|
||||
if (empty($currency)) return $this->error('交易币不存在');
|
||||
$legal = Currency::find($legal_id);
|
||||
if (empty($legal) || empty($legal->is_legal)) return $this->error('该币不是法币');
|
||||
if ($min_price >= $max_price) return $this->error('请设置正确的价格区间');
|
||||
if ($min_number >= $max_number) return $this->error('请填写正确的随机数量');
|
||||
if ($need_second <= 0) return $this->error('请填写正确的生成秒数');
|
||||
|
||||
$is = AutoList::where('currency_id',$currency_id)->where('legal_id',$legal_id)->first();
|
||||
|
||||
if (!empty($is) && empty($id)){
|
||||
return $this->error('该交易对已经有机器人了');
|
||||
}
|
||||
|
||||
if (empty($id)){
|
||||
$auto_list = new AutoList();
|
||||
$auto_list->create_time = time();
|
||||
|
||||
}else{
|
||||
$auto_list = AutoList::find($id);
|
||||
}
|
||||
try{
|
||||
$auto_list->buy_user_id = $buy_user->id;
|
||||
$auto_list->sell_user_id = $sell_user->id;
|
||||
$auto_list->currency_id = $currency_id;
|
||||
$auto_list->legal_id = $legal_id;
|
||||
$auto_list->min_price = $min_price;
|
||||
$auto_list->max_price = $max_price;
|
||||
$auto_list->min_number = $min_number;
|
||||
$auto_list->max_number = $max_number;
|
||||
$auto_list->need_second = $need_second;
|
||||
$auto_list->save();
|
||||
return $this->success('添加成功');
|
||||
}catch (\Exception $exception){
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function lists(Request $request){
|
||||
$limit = $request->get('limit');
|
||||
$results = AutoList::orderBy('id','desc')->paginate($limit);
|
||||
return $this->layuiData($results);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,755 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
|
||||
use App\AccountLog;
|
||||
use App\LegalDealSend;
|
||||
use App\LhBankAccount;
|
||||
use App\LhBankAccountLog;
|
||||
use App\LhBankTeamMember;
|
||||
use App\LhDepositOrder;
|
||||
use App\LhDepositOrderLog;
|
||||
use App\LhLoanOrder;
|
||||
use App\Logic\LhBankProfitLogic;
|
||||
use App\Setting;
|
||||
use App\Users;
|
||||
use App\UsersWallet;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Cache\RedisLock;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
|
||||
class BankController extends Controller
|
||||
{
|
||||
|
||||
public function test(){
|
||||
|
||||
$accountId = Input::get('id',171);
|
||||
LhBankProfitLogic::updateVipLevel($accountId);
|
||||
//
|
||||
//
|
||||
// LhBankProfitLogic::addInProcessingQueue(1);
|
||||
// LhBankProfitLogic::addInProcessingQueue(2);
|
||||
// LhBankProfitLogic::addInProcessingQueue(3);
|
||||
//
|
||||
// $res = LhBankProfitLogic::getProcessingQueue();
|
||||
//// var_dump($res);exit;
|
||||
// DB::beginTransaction();
|
||||
// try{
|
||||
// LhBankProfitLogic::saveDeposit($accountId,1000);
|
||||
// //存钱后更新M等级
|
||||
// LhBankProfitLogic::teamIncrement($accountId,1000);
|
||||
//
|
||||
// DB::commit();
|
||||
// }catch (\Exception $e){
|
||||
// DB::rollBack();
|
||||
// throw $e;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function dispatchInterest(){
|
||||
//查询开始时间在今天以前,状态是1的 结息时间小于今天的订单
|
||||
|
||||
$res = LhDepositOrder::where([
|
||||
'status' => 1,
|
||||
])->where('start_at','<',date("Y-m-d"))
|
||||
->where('last_settle_time','<',date("Y-m-d"))
|
||||
->orWhere('last_settle_time',null)
|
||||
->take(20) ->get();
|
||||
foreach($res as $order){
|
||||
LhDepositOrder::dispatchInterest($order->id);
|
||||
// if($order->end_at < date('Y-m-d')){
|
||||
// //todo 时间到了 释放存款
|
||||
// LhDepositOrder::where('id',$order->id)->update(['status' => 2]);
|
||||
// }
|
||||
}
|
||||
|
||||
return $this->success('success');
|
||||
}
|
||||
public function weekProfit(){
|
||||
$user_id = Users::getUserId();
|
||||
//判断是否有账号
|
||||
$res = LhBankAccount::where('uid',$user_id)->first();
|
||||
if(!$res){
|
||||
return $this->error('还未创建账户');
|
||||
}
|
||||
$beginDay = date('Y-m-d',strtotime('-8 day'));
|
||||
$res = LhDepositOrderLog::where('bank_account_id',$res->id)
|
||||
->where('interest_day','>',$beginDay)
|
||||
->groupBy('interest_day')
|
||||
->selectRaw('sum(interest_amount) as amount, interest_day')
|
||||
->get();
|
||||
return $this->success([
|
||||
'list'=>$res
|
||||
]);
|
||||
}
|
||||
|
||||
public function bankLog(Request $request){
|
||||
$user_id = Users::getUserId();
|
||||
//判断是否有账号
|
||||
$res = LhBankAccount::where('uid',$user_id)->first();
|
||||
if(!$res){
|
||||
return $this->error('还未创建账户');
|
||||
}
|
||||
$limit = $request->get('limit', 20);
|
||||
$page = $request->get('page', 1);
|
||||
$type = $request->get('type',null);
|
||||
$search = $request->get('search','');
|
||||
$where = [];
|
||||
if($type){
|
||||
$where['type'] = $type;
|
||||
}
|
||||
if($search){
|
||||
$where['description'] = $search;
|
||||
}
|
||||
$res = LhBankAccountLog::where('account_id',$res->id)
|
||||
->where($where)
|
||||
->orderBy('id','desc')
|
||||
->skip($limit*($page-1))->take($limit)
|
||||
->get();
|
||||
return $this->success([
|
||||
'list' => $res
|
||||
]);
|
||||
}
|
||||
|
||||
// public function newAccount(){
|
||||
// $user_id = Users::getUserId();
|
||||
// $user = Users::find($user_id);
|
||||
// if (!$user) {
|
||||
// return $this->error('用户不存在');
|
||||
// }
|
||||
// if($user->is_realname != 2){
|
||||
// return $this->error('请实名制');
|
||||
// };
|
||||
|
||||
// //判断是否有账号
|
||||
// $res = LhBankAccount::where('uid',$user_id)->first();
|
||||
// if($res){
|
||||
// return $this->error('已创建过账户');
|
||||
// }
|
||||
// //获取爸爸加过的团队 全部再加一次
|
||||
// if($user->parent_id){
|
||||
// $parentTeamList = LhBankTeamMember::getUserTeams($user->parent_id);
|
||||
// }
|
||||
// DB::beginTransaction();
|
||||
// try{
|
||||
// $model = new LhBankAccount();
|
||||
// $model->uid = $user_id;
|
||||
// $model->usdt_balance = LhBankAccount::INIT_BALANCE;
|
||||
// $model->p_uid = $user->parent_id;
|
||||
// $model->save();
|
||||
// if(isset($parentTeamList) && $parentTeamList){
|
||||
// foreach($parentTeamList as $team){
|
||||
// LhBankTeamMember::addTeamMember($team->leader_uid,$user_id,$team['generation']+1);
|
||||
// }
|
||||
// }
|
||||
// if($user->parent_id){
|
||||
// LhBankTeamMember::addTeamMember($user->parent_id,$user_id,1);
|
||||
// }
|
||||
|
||||
// DB::commit();
|
||||
// }catch (\Exception $e){
|
||||
// DB::rollBack();
|
||||
// return $this->error($e->getMessage());
|
||||
// }
|
||||
|
||||
// return $this->success('创建成功');
|
||||
// }
|
||||
|
||||
public function myAccount(){
|
||||
$user_id = Users::getUserId();
|
||||
|
||||
//判断是否有账号
|
||||
/** @var LhBankAccount $res */
|
||||
$res = LhBankAccount::where('uid',$user_id)->first();
|
||||
if(!$res){
|
||||
return $this->error(null);
|
||||
}
|
||||
else{
|
||||
$res->total_profit_df =0;
|
||||
$res->total_profit_usdt = 0;
|
||||
$res->last_day_profit_df = 0;
|
||||
$res->last_day_profit_usdt = 0;
|
||||
$res->total_value = 0;
|
||||
$res->total_invited = 0;
|
||||
$res->total_lock_usdt = LhDepositOrder::where('bank_account_id',$res->id)->where('status',1)->sum('usdt_amount');
|
||||
$res->total_lock_df = LhDepositOrder::where('bank_account_id',$res->id)->where('status',1)->sum('amount');
|
||||
return $this->success([
|
||||
'account_info' => $res,
|
||||
'usdt' => Setting::getValueByKey('AUTU_USDT_NUM',300),
|
||||
'df' => Setting::getValueByKey('AUTU_UNLOCK_NUM',1000)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function saveMoney(){
|
||||
$user_id = Users::getUserId();
|
||||
$amount = Input::get('amount','');
|
||||
//判断是否有账号
|
||||
$res = LhBankAccount::where('uid',$user_id)->first();
|
||||
if(!$res){
|
||||
return $this->error('您还未创建账户');
|
||||
}
|
||||
$amount = (float)$amount;
|
||||
|
||||
$legal = UsersWallet::where("user_id", $user_id)
|
||||
->where("currency", 3) //usdt
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
if (!$legal) {
|
||||
return $this->error("钱包未找到,请先添加钱包");
|
||||
}
|
||||
if($legal->change_balance < $amount){
|
||||
return $this->error('资金钱包余额不足');
|
||||
}
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
//先扣费
|
||||
$result = change_wallet_balance(
|
||||
$legal,
|
||||
4,
|
||||
-$amount,
|
||||
AccountLog::TRANSFER_TO_LH_ACCOUNT,
|
||||
'转账入余币宝',
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
serialize([])
|
||||
);
|
||||
$res->usdt_balance += $amount;
|
||||
$res->save();
|
||||
LhBankAccountLog::newLog($res->id,LhBankAccountLog::LOG_TYPE_USDT,$amount,'转账入金');
|
||||
Db::commit();
|
||||
}catch (\Exception $e){
|
||||
Db::rollBack();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
return $this->success('入金成功');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function config(Request $request){
|
||||
$page = $request->get('page');
|
||||
$list = DB::table('lh_deposit_config')->join('currency','currency.id','=','currency_id')
|
||||
->offset(($page-1)*10)->limit(10)
|
||||
->select(['currency.name as currency_name','currency.logo as currency_logo','lh_deposit_config.*'])
|
||||
->get();
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
public function newDeposit(Request $request){
|
||||
$id = $request->get('config_id');
|
||||
$amount = $request->get('amount');
|
||||
$config = DB::table('lh_deposit_config')->where('id',$id)->first();
|
||||
if(!$config){
|
||||
return $this->error('项目不存在');
|
||||
}
|
||||
if($amount < $config->save_min){
|
||||
return $this->error('最少存入数量为:'.$config->save_min);
|
||||
}
|
||||
//钱包
|
||||
$user_id = Users::getUserId();
|
||||
$legal = UsersWallet::where("user_id", $user_id)
|
||||
->where("currency", $config->currency_id) //usdt
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
$result = change_wallet_balance(
|
||||
$legal,
|
||||
4,
|
||||
-$amount,
|
||||
AccountLog::TRANSFER_TO_LH_ACCOUNT,
|
||||
'锁仓',
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
serialize([])
|
||||
);
|
||||
$order = LhDepositOrder::newOrder($user_id,$config->currency_id,$amount,$config->day,$config->interest_rate);
|
||||
|
||||
DB::commit();
|
||||
}catch (\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->error($e->getMessage());
|
||||
|
||||
}
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @author
|
||||
*/
|
||||
public function timeDeposit(){
|
||||
$user_id = Users::getUserId();
|
||||
$num = Input::get('num',0);
|
||||
$num = (int)$num;
|
||||
if($num <= 0){
|
||||
return $this->error('数量不可低于0');
|
||||
}
|
||||
//判断是否有账号
|
||||
$res = LhBankAccount::where('uid',$user_id)->first();
|
||||
if(!$res){
|
||||
return $this->error('您还未创建账户');
|
||||
}
|
||||
|
||||
$amount = Setting::getValueByKey('AUTU_USDT_NUM',300);
|
||||
$amount *= $num;
|
||||
$df_amount = Setting::getValueByKey('AUTU_UNLOCK_NUM',1000);
|
||||
$df_amount *= $num;
|
||||
if($res->usdt_balance < $amount){
|
||||
return $this->error('你的账户余额不足');
|
||||
}
|
||||
if($res->df_balance <= 0){
|
||||
return $this->error('你的冻结余额为0');
|
||||
}
|
||||
if($res->df_balance < $df_amount){
|
||||
$df_amount = $res->df_balance;
|
||||
// return $this->error('你的冻结余额不足'.$df_amount);
|
||||
}
|
||||
|
||||
$totalDeposit = LhBankAccount::getTotalDeposit($res->id);
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
$res->usdt_balance -= $amount;
|
||||
$res->df_balance -= $df_amount;
|
||||
$res->save();
|
||||
LhBankAccountLog::newLog($res->id,LhBankAccountLog::LOG_TYPE_USDT,-$amount,'解冻申请');
|
||||
LhBankAccountLog::newLog($res->id,LhBankAccountLog::LOG_TYPE_DF,-$df_amount,'解冻申请');
|
||||
$order = LhDepositOrder::newOrder($res->id,$df_amount,$amount);
|
||||
|
||||
DB::commit();
|
||||
}catch (\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->error($e->getMessage());
|
||||
|
||||
}
|
||||
return $this->success('存币成功');
|
||||
}
|
||||
|
||||
public function myDepositOrder(Request $request){
|
||||
$user_id = Users::getUserId();
|
||||
|
||||
$limit = $request->get('limit', 20);
|
||||
$page = $request->get('page', 1);
|
||||
$isCancel = $request->get('is_cancel',0);
|
||||
$status = $request->get('status',null);
|
||||
$where = [];
|
||||
if($isCancel){
|
||||
$where = [
|
||||
'is_cancel' => 1
|
||||
];
|
||||
}
|
||||
if($status){
|
||||
$where['status'] = $status;
|
||||
}
|
||||
|
||||
$res = LhDepositOrder::where('user_id',$user_id)
|
||||
->join('currency','currency.id','=','currency_id')
|
||||
->where($where)
|
||||
->orderBy('lh_deposit_order.id','desc')
|
||||
->skip($limit*($page-1))->take($limit)
|
||||
->get(['currency.name as currency_name','lh_deposit_order.id','amount','day_rate','total_interest','start_at','end_at','status']);
|
||||
return $this->success([
|
||||
'order_list' => $res
|
||||
]);
|
||||
}
|
||||
|
||||
public function cancelOrderNew(){
|
||||
$orderId = Input::get('id');
|
||||
$order = LhDepositOrder::find($orderId);
|
||||
if(!$order){
|
||||
return $this->error('找不到存单');
|
||||
}
|
||||
$user_id = Users::getUserId();
|
||||
if($order->user_id != $user_id){
|
||||
return $this->error('非法操作');
|
||||
}
|
||||
if($order->status!=1){
|
||||
return $this->error('存单状态异常');
|
||||
}
|
||||
$legal = UsersWallet::where("user_id", $user_id)
|
||||
->where("currency", $order->currency_id) //usdt
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
//扣钱
|
||||
$returnAmount = $order->amount-$order->cancel_fee;
|
||||
|
||||
$order->status = 2;
|
||||
$order->is_cancel = 1;
|
||||
$order->save();
|
||||
$result = change_wallet_balance(
|
||||
$legal,
|
||||
4,
|
||||
$returnAmount,
|
||||
AccountLog::BANK_WITHDRAW,
|
||||
'锁仓返还',
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
serialize([])
|
||||
);
|
||||
DB::commit();
|
||||
}catch (\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
return $this->success('毁约成功');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function cancelOrder(){
|
||||
return $this->error('功能暂不可用');
|
||||
$user_id = Users::getUserId();
|
||||
$res = LhBankAccount::where('uid',$user_id)->first();
|
||||
if(!$res){
|
||||
return $this->error('您还未创建账户');
|
||||
}
|
||||
$orderId = Input::get('id');
|
||||
$order = LhDepositOrder::find($orderId);
|
||||
if(!$order){
|
||||
return $this->error('找不到存单');
|
||||
}
|
||||
if($order->bank_account_id != $res->id){
|
||||
return $this->error('非法操作');
|
||||
}
|
||||
if($order->status != 1){
|
||||
return $this->error('存单状态异常');
|
||||
}
|
||||
$loan = LhLoanOrder::where(['bank_account_id'=>$res->id,'status' => 1])->first();
|
||||
if($loan) {
|
||||
return $this->error('你还有质押单,不可毁约');
|
||||
}
|
||||
//判断毁约期限
|
||||
if(strtotime('+30 day',strtotime($order->start_at)) < date("Y-m-d")){
|
||||
return $this->error('毁约时间已过');
|
||||
}
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
//扣钱
|
||||
$costRate = Setting::getValueByKey('CANCEL_DEPOSIT_ORDER_COST',20);
|
||||
$returnAmount = $order->amount * (1-$costRate/100);
|
||||
$balance = bc_add($res->usdt_balance,$returnAmount);
|
||||
$res->usdt_balance = $balance;
|
||||
$res->save();
|
||||
LhBankAccountLog::newLog($res->id,LhBankAccountLog::LOG_TYPE_USDT,$returnAmount,'毁约退款');
|
||||
$order->status = 2;
|
||||
$order->is_cancel = 1;
|
||||
$order->save();
|
||||
//更新自己账号等级
|
||||
LhBankProfitLogic::cancelOrderUpdate($res->id);
|
||||
DB::commit();
|
||||
}catch (\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
return $this->success('毁约成功');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提现至钱包
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Exception
|
||||
* @author
|
||||
*/
|
||||
public function withdraw(){
|
||||
$user_id = Users::getUserId();
|
||||
$res = LhBankAccount::where('uid',$user_id)->first();
|
||||
if(!$res){
|
||||
return $this->error('您还未创建账户');
|
||||
}
|
||||
$depositAmount = LhBankAccount::getTotalDeposit($res->id);
|
||||
$amount = Input::get('amount',0);
|
||||
if($amount<10){
|
||||
return $this->error('最少提币金额为10');
|
||||
}
|
||||
$type = Input::get('type',''); //1 usdt 2 dfone
|
||||
$withdrawFee = Setting::getValueByKey('LH_WITHDRAW_FEE',0);
|
||||
if($withdrawFee>100){
|
||||
return $this->error('提现失败,请联系管理员');
|
||||
}
|
||||
switch ($type){
|
||||
case 1:
|
||||
$legal = UsersWallet::where("user_id", $user_id)
|
||||
->where("currency", 3) //usdt
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
|
||||
//扣手续费
|
||||
change_wallet_balance(
|
||||
$legal,
|
||||
4,
|
||||
$amount,
|
||||
AccountLog::BANK_WITHDRAW,
|
||||
'理财账户提现',
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
serialize([])
|
||||
);
|
||||
LhBankAccountLog::newLog($res->id,LhBankAccountLog::LOG_TYPE_USDT,-$amount,'理财账户提现');
|
||||
DB::commit();
|
||||
}catch (\Exceptionq $e){
|
||||
DB::rollBack();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
return $this->error('维护中');
|
||||
$DfWallet = UsersWallet::getDF1Wallet($user_id);
|
||||
if(!$DfWallet){
|
||||
return $this->error('找不到钱包');
|
||||
}
|
||||
if($res->df_balance - $amount < 0){
|
||||
return $this->error('余额不足');
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
|
||||
$balance = bc_sub($res->df_balance,$amount);
|
||||
$res->df_balance = $balance;
|
||||
$res->save();
|
||||
$amount = bc_mul($amount,(1-($withdrawFee/100)));
|
||||
change_wallet_balance(
|
||||
$DfWallet,
|
||||
1,
|
||||
$amount,
|
||||
AccountLog::BANK_WITHDRAW,
|
||||
'余币宝提现',
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
serialize([])
|
||||
);
|
||||
LhBankAccountLog::newLog($res->id,LhBankAccountLog::LOG_TYPE_DF,-$amount,'提现');
|
||||
DB::commit();
|
||||
}catch (\Exceptionq $e){
|
||||
DB::rollBack();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return $this->error('错误类型');
|
||||
}
|
||||
return $this->success('提现成功');
|
||||
}
|
||||
|
||||
|
||||
public function loan(){
|
||||
$user_id = Users::getUserId();
|
||||
$res = LhBankAccount::where('uid',$user_id)->first();
|
||||
if(!$res){
|
||||
return $this->error('您还未创建账户');
|
||||
}
|
||||
$amount = Input::get('amount',0);
|
||||
if($amount<100){
|
||||
return $this->error('最少质押金额为100');
|
||||
}
|
||||
$type = Input::get('wallet_type',0);
|
||||
//验证当前质押单总额
|
||||
$totalLoan = LhLoanOrder::where([
|
||||
'bank_account_id' => $res->id,
|
||||
'status' => 1
|
||||
])->sum('amount');
|
||||
//查询当前存单金额
|
||||
$totalDeposit = LhBankAccount::getTotalDeposit($res->id);
|
||||
$maxLoan = bc_mul($totalDeposit,0.8,0);
|
||||
if($totalLoan+$amount > $maxLoan){
|
||||
return $this->error('总质押金额超出,你还可以质押:'.($maxLoan-$totalLoan));
|
||||
}
|
||||
$legal = UsersWallet::where("user_id", $user_id)
|
||||
->where("currency", 3) //usdt
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
|
||||
$redis = Redis::connection();
|
||||
$lock = new RedisLock($redis,'user_bank_loan_'.$user_id,10);
|
||||
if($lock->acquire()) {
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
//创建订单
|
||||
LhLoanOrder::newOrder($res->id,$amount);
|
||||
//贷款出账
|
||||
switch ($type){
|
||||
case 1:
|
||||
//资金钱包
|
||||
change_wallet_balance(
|
||||
$legal,
|
||||
1,
|
||||
+$amount,
|
||||
AccountLog::LH_LOAN,
|
||||
'质押入账',
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
serialize([])
|
||||
);
|
||||
break;
|
||||
case 2:
|
||||
change_wallet_balance(
|
||||
$legal,
|
||||
4,
|
||||
+$amount,
|
||||
AccountLog::LH_LOAN,
|
||||
'质押入账',
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
serialize([])
|
||||
);
|
||||
break;
|
||||
case 3:
|
||||
change_wallet_balance(
|
||||
$legal,
|
||||
4,
|
||||
+$amount,
|
||||
AccountLog::LH_LOAN,
|
||||
'质押入账',
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
serialize([])
|
||||
);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
$res->usdt_balance += $amount;
|
||||
$res->save();
|
||||
LhBankAccountLog::newLog($res->id,LhBankAccountLog::LOG_TYPE_USDT,$amount,'质押入账');
|
||||
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
$lock->release();
|
||||
}catch (\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->error('质押失败');
|
||||
}
|
||||
}
|
||||
return $this->success('质押成功');
|
||||
}
|
||||
|
||||
public function loanList(Request $request){
|
||||
$user_id = Users::getUserId();
|
||||
$res = LhBankAccount::where('uid',$user_id)->first();
|
||||
if(!$res){
|
||||
return $this->error('您还未创建账户');
|
||||
}
|
||||
$limit = $request->get('limit', 20);
|
||||
$page = $request->get('page', 1);
|
||||
$status = $request->get('status',null);
|
||||
$where = [];
|
||||
if($status){
|
||||
$where['status'] = $status;
|
||||
}
|
||||
$res = LhLoanOrder::where('bank_account_id',$res->id)
|
||||
->where($where)
|
||||
->orderBy('id','desc')
|
||||
->skip($limit*($page-1))->take($limit)
|
||||
->get();
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
public function repayment(Request $request){
|
||||
$user_id = Users::getUserId();
|
||||
$res = LhBankAccount::where('uid',$user_id)->first();
|
||||
if(!$res){
|
||||
return $this->error('您还未创建账户');
|
||||
}
|
||||
$is_zj_wallet = Input::get('is_zj_wallet',0);
|
||||
$amount = Input::get('amount',0);
|
||||
if($amount <0){
|
||||
return $this->error('还款金额有误');
|
||||
}
|
||||
//usdtWallet
|
||||
|
||||
if($is_zj_wallet){
|
||||
$legal = UsersWallet::where("user_id", $user_id)
|
||||
->where("currency", 3) //usdt
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
if (!$legal) {
|
||||
return $this->error("钱包未找到,请先添加钱包");
|
||||
}
|
||||
if($legal->legal_balance < $amount){
|
||||
return $this->error('资金钱包余额不足');
|
||||
}
|
||||
}else{
|
||||
if($amount> $res->usdt_balance){
|
||||
return $this->error('余币宝账号余额不足');
|
||||
}
|
||||
}
|
||||
|
||||
$orderId = Input::get('order_id');
|
||||
if(!$orderId){
|
||||
return $this->error('参数异常');
|
||||
}
|
||||
$order = LhLoanOrder::where(['id' => $orderId,'bank_account_id' => $res->id])->first();
|
||||
if(!$order){
|
||||
return $this->error('找不到质押单');
|
||||
}
|
||||
$maxReturn = ($order->amount+$order->total_interest)-$order->total_return;
|
||||
if($maxReturn<=0){
|
||||
return $this->error('已还清');
|
||||
}
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
//先判断还款金额是否超过所需还款金额
|
||||
if($amount - $maxReturn >= 0){
|
||||
$amount = $maxReturn;
|
||||
$status = 2;
|
||||
}else{
|
||||
$status = 1;
|
||||
}
|
||||
//扣款
|
||||
if(isset($legal)){
|
||||
change_wallet_balance(
|
||||
$legal,
|
||||
1,
|
||||
-$amount,
|
||||
AccountLog::TRANSFER_TO_LH_ACCOUNT,
|
||||
'转账入余币宝',
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
serialize([])
|
||||
);
|
||||
LhBankAccountLog::newLog($res->id,LhBankAccountLog::LOG_TYPE_USDT,+$amount,'资金账户转入余币宝');
|
||||
LhBankAccountLog::newLog($res->id,LhBankAccountLog::LOG_TYPE_USDT,-$amount,'质押还款');
|
||||
}else{
|
||||
$balance = bc_sub($res->usdt_balance,$amount,8);
|
||||
$res->usdt_balance = $balance;
|
||||
$res->save();
|
||||
LhBankAccountLog::newLog($res->id,LhBankAccountLog::LOG_TYPE_USDT,-$amount,'质押还款');
|
||||
}
|
||||
|
||||
//质押单更新
|
||||
$order->total_return = bc_add($order->total_return,$amount,8);
|
||||
$order->status = $status;
|
||||
$order->end_at = date("Y-m-d");
|
||||
$order->save();
|
||||
DB::commit();
|
||||
}catch (\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
return $this->success('还款成功');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,436 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Admin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\{
|
||||
Address, AccountLog, Currency,BindBoxSuccessOrder, UsersInsurance, InsuranceType, InsuranceClaimApply, Setting, Users, UserCashInfo, UserReal, UsersWallet,BindBox,BindBoxOrder,BindBoxQuotationLog,BindBoxRaityHouse
|
||||
};
|
||||
use App\Utils\Hash;
|
||||
|
||||
class BindBoxController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view("admin.bindBox.index");
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit');
|
||||
$code = $request->get('code', '');
|
||||
$status = $request->get('status', '');
|
||||
$pay_type = $request->get('pay_type', '');
|
||||
$name = $request->get('name', '');
|
||||
$rarity= $request->get('rarity', '');
|
||||
$user_id = $request->get('author', null);
|
||||
|
||||
|
||||
$list = BindBox::where(function ($query) use ($code) {
|
||||
if (!empty($code)) {
|
||||
$query->where('code', $code);
|
||||
}
|
||||
})->where(function ($query) use ($rarity) {
|
||||
if ($rarity != '') {
|
||||
$query->where('rarity', $rarity);
|
||||
}
|
||||
})->where(function ($query) use ($name) {
|
||||
if ($name != '') {
|
||||
$query->where('name', $name);
|
||||
}
|
||||
})->where(function ($query) use ($pay_type) {
|
||||
if ($pay_type != '') {
|
||||
$query->where('pay_type', $pay_type);
|
||||
}
|
||||
})->where(function ($query) use ($status) {
|
||||
if ($status != '') {
|
||||
$query->where('status', $status);
|
||||
}
|
||||
})->where(function ($query) use ($user_id) {
|
||||
if (!empty($user_id)) {
|
||||
$query->where('author', $user_id);
|
||||
}
|
||||
})->orderBy('id', 'desc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function add(){
|
||||
|
||||
$currency = Currency::where('is_display',1)->get();
|
||||
return view("admin.bindBox.add",['currency'=>$currency]);
|
||||
}
|
||||
|
||||
//添加NFT
|
||||
public function addNFT(Request $request){
|
||||
$author = $request->post('author');
|
||||
$_author = Users::where("id",$author)->first();
|
||||
|
||||
if(!$_author){
|
||||
return $this->error('用户不存在');
|
||||
}
|
||||
|
||||
$type = $request->post('type');
|
||||
$currency = $request->post('currency');
|
||||
$name = $request->post('name');
|
||||
$author_description = $request->post('author_description');
|
||||
$description = $request->post('description');
|
||||
$image = $request->post('image');
|
||||
$price = $request->post('price');
|
||||
$per_increase = $request->post('per_increase');
|
||||
$pay_type = $request->post('pay_type');
|
||||
$start_time = $request->post('start_time');
|
||||
$end_time = $request->post('end_time');
|
||||
$rarity = $request->post('rarity');
|
||||
$margin = $request->post('margin');
|
||||
$rarity_house_id = $request->post('rarity_house_id');
|
||||
|
||||
if(!$type || !$currency || !$name || !$image ||!$price ||!$pay_type ||!$rarity || !$start_time|| !$end_time){
|
||||
return $this->error('必填项!');
|
||||
}
|
||||
|
||||
if( strtotime($start_time) < time() ){
|
||||
return $this->error("The start time cannot be less than the current time!");
|
||||
}
|
||||
|
||||
if( strtotime($start_time) > strtotime($end_time) ){
|
||||
return $this->error("The start time cannot be less than the end_time!");
|
||||
}
|
||||
|
||||
if($pay_type == 1){ //一口价
|
||||
if($price<=0){
|
||||
return $this->error('价格不能为空');
|
||||
}
|
||||
}elseif($pay_type == 2){//竞拍
|
||||
if($price<=0){
|
||||
return $this->error('竞拍起始价不能为0');
|
||||
}
|
||||
if($per_increase<=0){
|
||||
return $this->error('竞拍加价价格不能小于0');
|
||||
}
|
||||
if($margin<=0){
|
||||
return $this->error('竞拍商品未设置保证金!');
|
||||
}
|
||||
}elseif($pay_type == 3){ //盲盒
|
||||
if($price<=0){
|
||||
return $this->error('价格不能为空');
|
||||
}
|
||||
if($rarity_house_id<=0){
|
||||
return $this->error('未选择开出的盲盒');
|
||||
}
|
||||
}else{
|
||||
return $this->error('交易类型错误');
|
||||
}
|
||||
|
||||
$nft = new BindBox();
|
||||
$nft->code = $this->getCode();
|
||||
$nft->type = $type;
|
||||
$nft->currency_id = $currency;
|
||||
$nft->name = $name;
|
||||
$nft->price = $price;
|
||||
$nft->image = $image;
|
||||
$nft->author_description = $author_description??'';
|
||||
$nft->author = $author;
|
||||
$nft->owner = $author;
|
||||
$nft->status = 1;
|
||||
$nft->start_time = $start_time;
|
||||
$nft->end_time = $end_time;
|
||||
$nft->created = date('Y-m-d H:i:s');
|
||||
$nft->updated = date('Y-m-d H:i:s');
|
||||
$nft->pay_type = $pay_type;
|
||||
$nft->margin = $margin ?? 0;
|
||||
$nft->per_increase = $per_increase??0;
|
||||
$nft->rarity_house_id = $rarity_house_id??0;
|
||||
if($pay_type == 2){
|
||||
$nft->resell_nft_status = 1;//新添加的默认为竞拍中
|
||||
|
||||
}
|
||||
if($pay_type == 3){
|
||||
$nft->rarity_status = 0;//盲盒状态未开启
|
||||
$bind_box_raity_house = BindBoxRaityHouse::where(['id'=>$rarity_house_id,'status'=>0])->first();
|
||||
if(!$bind_box_raity_house){
|
||||
return $this->error('选择的盲盒不可用');
|
||||
}
|
||||
$bind_box_raity_house->status =1; //此盲盒已被使用
|
||||
$bind_box_raity_house->save();
|
||||
}
|
||||
$nft->chain = 'HX'; //汇信链
|
||||
$nft->rarity = $rarity;//稀有度
|
||||
$nft->save();
|
||||
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
|
||||
public function edit(Request $request){
|
||||
$nft = BindBox::where('id',$request->get('id'))->first();
|
||||
|
||||
return view("admin.bindBox.edit",['results'=>$nft]);
|
||||
}
|
||||
|
||||
//编辑NFT
|
||||
public function editNFT(Request $request){
|
||||
$code = $request->post('code');
|
||||
$price = $request->post('price');
|
||||
$rarity = $request->post('rarity');
|
||||
$start_time = $request->post('start_time');
|
||||
$end_time = $request->post('end_time');
|
||||
$per_increase = $request->post('per_increase');
|
||||
|
||||
if(!$price || !$rarity ||!$start_time || !$end_time ||!$code){
|
||||
return $this->error('参数错误!');
|
||||
}
|
||||
$bind_box = BindBox::where('code',$code)->first();
|
||||
if($bind_box->lock_order ==1 ){
|
||||
return $this->error('等待支付,不可编辑');
|
||||
}
|
||||
|
||||
if($bind_box->resell_nft_status ==1 ){
|
||||
return $this->error('NFT竞拍中不可编辑');
|
||||
}
|
||||
$bind_box->price = $price;
|
||||
$bind_box->start_time = $start_time;
|
||||
$bind_box->end_time = $end_time;
|
||||
$bind_box->per_increase = $per_increase;
|
||||
$bind_box->rarity = $rarity;
|
||||
$bind_box->save();
|
||||
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
|
||||
|
||||
public function order(){
|
||||
$currency = Currency::where('is_display',1)->get();
|
||||
|
||||
return view("admin.bindBox.order",['currency'=>$currency]);
|
||||
}
|
||||
|
||||
//NFT交易记录
|
||||
public function orderList(Request $request){
|
||||
$limit = $request->get('limit');
|
||||
$code = $request->get('code');
|
||||
$buyer_id = $request->get('buyer_id');
|
||||
$currency_id = $request->get('currency_id');
|
||||
|
||||
|
||||
$list = BindBoxOrder::where(function ($query) use ($code) {
|
||||
if (!empty($code)) {
|
||||
$query->where('code', $code);
|
||||
}
|
||||
})->where(function ($query) use ($currency_id) {
|
||||
if (!empty($currency_id)) {
|
||||
$query->where('currency_id', $currency_id);
|
||||
}
|
||||
})->where(function ($query) use ($buyer_id) {
|
||||
if (!empty($buyer_id)) {
|
||||
$query->where('buyer_id', $buyer_id);
|
||||
}
|
||||
})->orderBy('id', 'desc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function quotation(){
|
||||
$currency = Currency::where('is_display',1)->get();
|
||||
|
||||
return view("admin.bindBox.quotation",['currency'=>$currency]);
|
||||
}
|
||||
|
||||
//出价记录
|
||||
public function quotationList(Request $request){
|
||||
$limit = $request->get('limit');
|
||||
$code = $request->get('code');
|
||||
$status = $request->get('status');
|
||||
$buyer_id = $request->get('buyer_id');
|
||||
$currency_id = $request->get('currency_id');
|
||||
|
||||
|
||||
$list = BindBoxQuotationLog::where(function ($query) use ($code) {
|
||||
if (!empty($code)) {
|
||||
$query->where('code', $code);
|
||||
}
|
||||
})->where(function ($query) use ($currency_id) {
|
||||
if (!empty($currency_id)) {
|
||||
$query->where('currency_id', $currency_id);
|
||||
}
|
||||
})->where(function ($query) use ($status) {
|
||||
if (!empty($status)) {
|
||||
$query->where('status', $status);
|
||||
}
|
||||
})->where(function ($query) use ($buyer_id) {
|
||||
if (!empty($buyer_id)) {
|
||||
$query->where('buyer_id', $buyer_id);
|
||||
}
|
||||
})->orderBy('id', 'desc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($list);
|
||||
|
||||
}
|
||||
|
||||
//获取盲盒仓库
|
||||
public function getRarityHouse(Request $request){
|
||||
$rarity = $request->post('rarity');//稀有度
|
||||
$rarity_house = BindBoxRaityHouse::where(['rarity'=>$rarity,'status'=>0])->get();
|
||||
|
||||
return json_encode(['rarity_house'=>$rarity_house]);
|
||||
}
|
||||
|
||||
public function rarity_house(){
|
||||
|
||||
return view("admin.bindBox.rarity_house");
|
||||
}
|
||||
|
||||
//盲盒列表
|
||||
public function rarity_house_list(Request $request){
|
||||
|
||||
$limit = $request->get('limit');
|
||||
$name = $request->get('name');
|
||||
$rarity = $request->get('rarity');
|
||||
|
||||
|
||||
$list = BindBoxRaityHouse::where(function ($query) use ($name) {
|
||||
if (!empty($name)) {
|
||||
$query->where('name', 'like' ,"%$name%");
|
||||
}
|
||||
})->where(function ($query) use ($rarity) {
|
||||
if (!empty($rarity)) {
|
||||
$query->where('rarity', $rarity);
|
||||
}
|
||||
})->orderBy('id', 'desc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function add_rarity_house_view(){
|
||||
|
||||
return view("admin.bindBox.add_rarity_house_view");
|
||||
}
|
||||
|
||||
public function add_rarity_house(Request $request){
|
||||
|
||||
$file = $request->post('file');
|
||||
$rarity = $request->post('rarity');
|
||||
$name = $request->post('name');
|
||||
|
||||
if(!$file || !$rarity){
|
||||
return $this->error('必填项不能为空');
|
||||
}
|
||||
$BindBoxRaityHouse = new BindBoxRaityHouse();
|
||||
$BindBoxRaityHouse->file= $file;
|
||||
$BindBoxRaityHouse->rarity = $rarity;
|
||||
$BindBoxRaityHouse->name = $name??'未命名';
|
||||
$BindBoxRaityHouse->status = 0;
|
||||
$BindBoxRaityHouse->created = date('Y-m-d H:i:s',time());
|
||||
$BindBoxRaityHouse->save();
|
||||
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
|
||||
public function edit_rarity_house_view(Request $request){
|
||||
$id = $request->get('id');
|
||||
$BindBoxRaityHouse = BindBoxRaityHouse::where('id',$id)->first();
|
||||
|
||||
return view("admin.bindBox.edit_rarity_house_view",['results'=>$BindBoxRaityHouse]);
|
||||
}
|
||||
|
||||
public function edit_rarity_house(Request $request){
|
||||
$id = $request->post('id');
|
||||
$file = $request->post('file');
|
||||
$rarity = $request->post('rarity');
|
||||
$name = $request->post('name');
|
||||
|
||||
if(!$file || !$rarity){
|
||||
return $this->error('必填项不能为空');
|
||||
}
|
||||
|
||||
$BindBoxRaityHouse = BindBoxRaityHouse::where('id',$id)->first();
|
||||
|
||||
$bind_box = BindBox::where('rarity_house_id',$id)->where('rarity',$BindBoxRaityHouse->rarity)->first();
|
||||
|
||||
if($BindBoxRaityHouse->status == 1 && $bind_box){ // 已被使用 并且开启 不可编辑
|
||||
return $this->error('盲盒已开启,不可编辑');
|
||||
}elseif($bind_box && $BindBoxRaityHouse->status == 0){ //盲盒已经被购买 未开启
|
||||
$BindBoxRaityHouse->file= $file;
|
||||
$BindBoxRaityHouse->save();
|
||||
}else{//未被使用
|
||||
$BindBoxRaityHouse->name= $name;
|
||||
$BindBoxRaityHouse->file= $file;
|
||||
$BindBoxRaityHouse->rarity = $rarity;
|
||||
$BindBoxRaityHouse->save();
|
||||
}
|
||||
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function success_order(){
|
||||
|
||||
return view("admin.bindBox.success_order");
|
||||
}
|
||||
|
||||
public function success_order_list(Request $request){
|
||||
|
||||
$limit = $request->get('limit');
|
||||
$user_id = $request->get('user_id');
|
||||
$is_pay = $request->get('is_pay');
|
||||
$code = $request->get('code');
|
||||
|
||||
|
||||
$list = BindBoxSuccessOrder::where(function ($query) use ($user_id) {
|
||||
if (!empty($user_id)) {
|
||||
$query->where('user_id', 'like' ,"%$user_id%");
|
||||
}
|
||||
})->where(function ($query) use ($code) {
|
||||
if (!empty($code)) {
|
||||
$query->where('code', $code);
|
||||
}
|
||||
})->where(function ($query) use ($is_pay) {
|
||||
if (!empty($is_pay)) {
|
||||
$query->where('is_pay', $is_pay);
|
||||
}
|
||||
})->orderBy('id', 'desc')->orderBy('is_expired', 'ASC')->paginate($limit);
|
||||
|
||||
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
private function getCode(){
|
||||
$code = '0x' . Hash::createCode();
|
||||
$count = BindBox::where('code',$code)->count();
|
||||
if($count>0){
|
||||
$this->getCode();
|
||||
}else{
|
||||
return $code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function del(Request $request){
|
||||
$id = $request->post('id');
|
||||
if(is_array($id)){
|
||||
$ids = $id;
|
||||
}else{
|
||||
$ids = [$id];
|
||||
}
|
||||
|
||||
$bind_boxs = BindBox::whereIn('id',$ids)->get();
|
||||
if(!$bind_boxs){
|
||||
return $this->error('NFT不存在');
|
||||
}
|
||||
foreach ($bind_boxs as $bind_box){
|
||||
if($bind_box->lock_order ==1 ){
|
||||
return $this->error('等待支付,不可删除');
|
||||
}
|
||||
|
||||
if($bind_box->resell_nft_status ==1 ){
|
||||
return $this->error('NFT竞拍中不可删除');
|
||||
}
|
||||
$bind_box->delete();
|
||||
}
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\BossAccount;
|
||||
use App\LhDepositOrder;
|
||||
use App\LhBankAccount;
|
||||
use App\LhLoanOrder;
|
||||
use App\AccountLog;
|
||||
use App\Currency;
|
||||
use App\UsersWallet;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BossController extends Controller
|
||||
{
|
||||
//管理员取消订单 存量超过一天结算收益扣除违约金
|
||||
public function cancelOrder(Request $request){
|
||||
$orderId = $request->get('id');
|
||||
$order = LhDepositOrder::find($orderId);
|
||||
if(!$order){
|
||||
return $this->error('找不到存单');
|
||||
}
|
||||
if($order->status!=1){
|
||||
return $this->error('存单状态不可操作');
|
||||
}
|
||||
$legal = UsersWallet::where("user_id", $order->user_id)
|
||||
->where("currency", $order->currency_id) //usdt
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
//扣钱
|
||||
$returnAmount = $order->amount-$order->cancel_fee;
|
||||
$order->status = 2;
|
||||
$order->is_cancel = 1;
|
||||
$order->save();
|
||||
$result = change_wallet_balance(
|
||||
$legal,
|
||||
4,
|
||||
$returnAmount,
|
||||
AccountLog::MINING_BUY,
|
||||
'锁仓返还',
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
serialize([])
|
||||
);
|
||||
DB::commit();
|
||||
}catch (\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
return $this->success('毁约成功');
|
||||
|
||||
}
|
||||
|
||||
public function bossList(Request $request){
|
||||
$limit = $request->get('limit', 20);
|
||||
$account = $request->get('phone','');
|
||||
$pid = $request->get('p_id','');
|
||||
$where = [];
|
||||
if($pid){
|
||||
$where['p_uid'] = $pid;
|
||||
}
|
||||
|
||||
$res = BossAccount::join('users as u','uid','=','u.id')
|
||||
->leftJoin('users as dad','dad.id','=','p_uid')
|
||||
->select(['u.id','boss_account.p_uid','u.account_number','u.email','dad.phone as parent_phone','dad.account_number as parent_account','u.phone','total_invited','total_active','total_profit','balance'])
|
||||
->where(function($q)use($account){
|
||||
if($account){
|
||||
$q->where('u.account_number','=',$account)->orWhere('u.email','=',$account);
|
||||
}
|
||||
})->where($where)
|
||||
->orderBy('p_uid','asc')
|
||||
->paginate($limit);
|
||||
return $this->layuiData($res);
|
||||
return $this->success(['list' => $res]);
|
||||
|
||||
}
|
||||
public function bossListView(){
|
||||
return view('admin.boss.boss_list');
|
||||
}
|
||||
|
||||
public function depositOrderList(Request $request){
|
||||
$limit = $request->get('limit', 20);
|
||||
$where = [];
|
||||
$account = $request->get('search');
|
||||
$status = $request->get('status');
|
||||
$cancel = $request->get('is_cancel',null);
|
||||
if($status){
|
||||
$where['lh_deposit_order.status'] = $status;
|
||||
}
|
||||
if($cancel !== null){
|
||||
$where['is_cancel'] = $cancel;
|
||||
}
|
||||
$res = LhDepositOrder::join('currency as c','c.id','=','currency_id')
|
||||
->join('users as u','user_id','=','u.id')
|
||||
->where(function($q)use($account){
|
||||
if($account){
|
||||
$q->where('u.account_number','=',$account)->orWhere('u.email','=',$account);
|
||||
}
|
||||
})->where($where)
|
||||
->select(['u.id as uid','u.account_number','u.email','u.phone','lh_deposit_order.*','c.name as currency_name'])
|
||||
->orderBy('lh_deposit_order.id','desc')
|
||||
->paginate($limit);
|
||||
return $this->layuiData($res);
|
||||
|
||||
}
|
||||
public function depositOrderView(){
|
||||
return view('admin.boss.lh_order_list');
|
||||
}
|
||||
|
||||
|
||||
public function depositConfig(Request $request){
|
||||
$currencyId = $request->get('currency_id');
|
||||
$limit = $request->get('limit', 20);
|
||||
// var_dump($currencyId);exit;
|
||||
$where = [];
|
||||
if($where){
|
||||
$where['currency_id'] = $currencyId;
|
||||
}
|
||||
$list = DB::table('lh_deposit_config')->join('currency','currency.id','=','currency_id')->where($where)->select(['currency.name as currency_name','lh_deposit_config.*'])->orderBy('lh_deposit_config.id', 'asc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
public function addConfig(Request $request){
|
||||
$currencyId = $request->get('currency_id');
|
||||
$day = $request->get('day');
|
||||
$rate = $request->get('rate');
|
||||
$intro = $request->get('intro');
|
||||
$save_min = $request->get('save_min');
|
||||
// $output = $request->get('out_currency_id');
|
||||
$res = DB::table('lh_deposit_config')->where('currency_id',$currencyId)->where('day',$day)->first();
|
||||
if($res){
|
||||
return $this->error('存在重复的期限');
|
||||
}
|
||||
DB::table('lh_deposit_config')->insert([
|
||||
'day' => $day,
|
||||
'interest_rate' => $rate,
|
||||
'intro' => $intro,
|
||||
'currency_id' => $currencyId,
|
||||
'save_min' => $save_min,
|
||||
'created_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
return $this->success('创建成功');
|
||||
}
|
||||
|
||||
public function depositConfigView(){
|
||||
return view('admin.boss.config');
|
||||
}
|
||||
public function depositConfigAddView(){
|
||||
$currency = Currency::all();
|
||||
return view('admin.boss.config_add',['currencies'=>$currency]);
|
||||
}
|
||||
public function depositConfigEditView(Request $request){
|
||||
$configId = $request->get('id');
|
||||
$model = DB::table('lh_deposit_config')->where('id',$configId)->first();
|
||||
$currency = Currency::where('id',$model->currency_id)->first();
|
||||
$model->currency_name = $currency->name;
|
||||
return view('admin.boss.config_edit',['model' => $model]);
|
||||
}
|
||||
public function depositConfigDelete(Request $request){
|
||||
$configId = $request->get('id');
|
||||
DB::table('lh_deposit_config')->where('id',$configId)->delete();
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
|
||||
public function editConfig(Request $request){
|
||||
$configId = $request->get('id');
|
||||
$day = $request->get('day');
|
||||
$rate = $request->get('rate');
|
||||
$intro = $request->get('intro');
|
||||
$save_min = $request->get('save_min');
|
||||
$model = DB::table('lh_deposit_config')->where('id',$configId)->first();
|
||||
if(!$model){
|
||||
return $this->error('找不到此期限');
|
||||
}
|
||||
$res = DB::table('lh_deposit_config')->where('id','<>',$configId)->where('currency_id',$model->currency_id)->where('day',$day)->first();
|
||||
if($res){
|
||||
return $this->error('存在重复的期限');
|
||||
}
|
||||
DB::table('lh_deposit_config')->where('id',$configId)->update([
|
||||
'day' => $day,
|
||||
// 'total_rate' => $rate,
|
||||
'interest_rate' => $rate,
|
||||
'save_min' => $save_min,
|
||||
'intro' => $intro
|
||||
// 'created_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
return $this->success('编辑成功');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function loanOrderView(){
|
||||
return view('admin.boss.loan_list');
|
||||
}
|
||||
public function loanOrderList(Request $request){
|
||||
$limit = $request->get('limit', 20);
|
||||
$where = [];
|
||||
$account = $request->get('search');
|
||||
$status = $request->get('status');
|
||||
if($status){
|
||||
$where['lh_loan_order.status'] = $status;
|
||||
}
|
||||
$res = LhLoanOrder::join('lh_bank_account as b','bank_account_id','=','b.id')
|
||||
->join('users as u','uid','=','u.id')
|
||||
->where(function($q)use($account){
|
||||
if($account){
|
||||
$q->where('u.account_number','=',$account)->orWhere('u.email','=',$account);
|
||||
}
|
||||
})->where($where)
|
||||
->select(['u.id as uid','u.account_number','u.email','u.phone','lh_loan_order.*'])
|
||||
->orderBy('lh_loan_order.id','desc')
|
||||
->paginate($limit);
|
||||
return $this->layuiData($res);
|
||||
}
|
||||
|
||||
public function lhAccount(Request $request){
|
||||
$user_id = $request->get('user_id');
|
||||
$account = LhBankAccount::where('uid',$user_id)->first();
|
||||
if(!$account){
|
||||
return [];
|
||||
}
|
||||
return $this->success($account);
|
||||
}
|
||||
public function editLhAccountView(){
|
||||
return view('admin.boss.edit_lh_account');
|
||||
}
|
||||
public function editLhAccount(Request $request){
|
||||
$id = $request->get('id');
|
||||
$account = LhBankAccount::where('id',$id)->first();
|
||||
if(!$account){
|
||||
return $this->error('找不到账户');
|
||||
}
|
||||
|
||||
$account->df_balance = $request->get('df_balance');
|
||||
$account->usdt_balance = $request->get('usdt_balance');
|
||||
$account->save();
|
||||
return $this->success('');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function unlockOrder(Request $request){
|
||||
$account = $request->get('search');
|
||||
$limit = $request->get('limit', 20);
|
||||
$res = DB::table('wallet_unlock_order')->join('users as u','user_id','=','u.id')
|
||||
->where(function($q)use($account){
|
||||
if($account){
|
||||
$q->where('u.account_number','=',$account)->orWhere('u.email','=',$account);
|
||||
}
|
||||
})->orderBy('wallet_unlock_order.id','desc')
|
||||
->select(['u.account_number','u.email','u.phone','wallet_unlock_order.*'])
|
||||
->paginate($limit);
|
||||
return $this->layuiData($res);
|
||||
}
|
||||
public function unlockOrderView(){
|
||||
return view('admin.boss.unlock_order');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use App\C2cDeal;
|
||||
use App\Currency;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class C2cDealController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
//买入交易总额
|
||||
$aaaa=C2cDeal::leftJoin("c2c_deal_send","c2c_deal.legal_deal_send_id","=","c2c_deal_send.id")->where("c2c_deal_send.type","=","sell")->select("c2c_deal.*","c2c_deal_send.type")->get();
|
||||
$buy_all_number=0;
|
||||
foreach($aaaa as $key=>$value)
|
||||
{
|
||||
$buy_all_number=$buy_all_number+$value->number;
|
||||
}
|
||||
|
||||
//卖出交易总额
|
||||
$bbbb=C2cDeal::leftJoin("c2c_deal_send","c2c_deal.legal_deal_send_id","=","c2c_deal_send.id")->where("c2c_deal_send.type","=","buy")->select("c2c_deal.*","c2c_deal_send.type")->get();
|
||||
$sell_all_number=0;
|
||||
foreach($bbbb as $key=>$value)
|
||||
{
|
||||
$sell_all_number=$sell_all_number+$value->number;
|
||||
}
|
||||
|
||||
// $currency = Currency::where('is_legal', 1)->orderBy('id', 'desc')->get();//获取法币
|
||||
//return view('admin.legal.deal', ['currency' => $currency]);
|
||||
return view('admin.c2c.deal',['sell_all_number' => $sell_all_number,'buy_all_number'=>$buy_all_number]);
|
||||
}
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$account_number = $request->get('account_number', '');
|
||||
$seller_number = $request->get('seller_number', '');
|
||||
$type = $request->get('type', '');
|
||||
// $currency_id = $request->get('currency_id', 0);
|
||||
$result = new C2cDeal();
|
||||
if (!empty($account_number)) {
|
||||
$result = $result->whereHas('user', function ($query) use ($account_number) {
|
||||
$query->where('account_number', 'like', '%' . $account_number . '%');
|
||||
});
|
||||
}
|
||||
if (!empty($seller_number)) {
|
||||
|
||||
$result = $result->whereHas('seller', function ($query) use ($seller_number) {
|
||||
$query->where('account_number', 'like', '%' . $seller_number . '%');
|
||||
});
|
||||
}
|
||||
|
||||
if (!empty($type)) {
|
||||
$result = $result->whereHas('legalDealSend', function ($query) use ($type) {
|
||||
$query->where('type', $type);
|
||||
});
|
||||
|
||||
}
|
||||
// if (!empty($currency_id)) {
|
||||
// $result = $result->whereHas('legalDealSend', function ($query) use ($currency_id) {
|
||||
// $query->where('currency_id', $currency_id);
|
||||
// });
|
||||
// }
|
||||
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
//导出c2c交易信息
|
||||
public function csv(Request $request)
|
||||
{
|
||||
|
||||
// $limit = $request->get('limit', 10);
|
||||
$account_number = $request->get('account_number', '');
|
||||
$seller_number = $request->get('seller_number', '');
|
||||
$type = $request->get('type', '');
|
||||
// var_dump($account_number);var_dump($seller_number);var_dump($type);
|
||||
// $currency_id = $request->get('currency_id', 0);
|
||||
$result = new C2cDeal();
|
||||
if (!empty($account_number)) {
|
||||
$result = $result->whereHas('user', function ($query) use ($account_number) {
|
||||
$query->where('account_number', 'like', '%' . $account_number . '%');
|
||||
});
|
||||
}
|
||||
if (!empty($seller_number)) {
|
||||
|
||||
$result = $result->whereHas('seller', function ($query) use ($seller_number) {
|
||||
$query->where('account_number', 'like', '%' . $seller_number . '%');
|
||||
});
|
||||
}
|
||||
|
||||
if (!empty($type)) {
|
||||
$result = $result->whereHas('legalDealSend', function ($query) use ($type) {
|
||||
$query->where('type', $type);
|
||||
});
|
||||
|
||||
}
|
||||
// if (!empty($currency_id)) {
|
||||
// $result = $result->whereHas('legalDealSend', function ($query) use ($currency_id) {
|
||||
// $query->where('currency_id', $currency_id);
|
||||
// });
|
||||
// }
|
||||
|
||||
$data = $result->orderBy('id', 'desc')->get();
|
||||
// var_dump($data->toArray());die;
|
||||
|
||||
|
||||
// $data = C2cDeal::all()->toArray();
|
||||
return Excel::create('交易信息', function ($excel) use ($data) {
|
||||
$excel->sheet('交易信息', function ($sheet) use ($data) {
|
||||
$sheet->cell('A1', function ($cell) {
|
||||
$cell->setValue('ID');
|
||||
});
|
||||
$sheet->cell('B1', function ($cell) {
|
||||
$cell->setValue('交易需求id');
|
||||
});
|
||||
$sheet->cell('C1', function ($cell) {
|
||||
$cell->setValue('用户交易账号');
|
||||
});
|
||||
$sheet->cell('D1', function ($cell) {
|
||||
$cell->setValue('真实姓名');
|
||||
});
|
||||
$sheet->cell('E1', function ($cell) {
|
||||
$cell->setValue('买入/卖出');
|
||||
});
|
||||
$sheet->cell('F1', function ($cell) {
|
||||
$cell->setValue('支付方式');
|
||||
});
|
||||
$sheet->cell('G1', function ($cell) {
|
||||
$cell->setValue('单价');
|
||||
});
|
||||
|
||||
|
||||
$sheet->cell('H1', function ($cell) {
|
||||
$cell->setValue('交易量');
|
||||
});
|
||||
$sheet->cell('I1', function ($cell) {
|
||||
$cell->setValue('交易币');
|
||||
});
|
||||
$sheet->cell('J1', function ($cell) {
|
||||
$cell->setValue('交易总金额');
|
||||
});
|
||||
$sheet->cell('K1', function ($cell) {
|
||||
$cell->setValue('交易状态');
|
||||
});
|
||||
$sheet->cell('L1', function ($cell) {
|
||||
$cell->setValue('交易时间');
|
||||
});
|
||||
$sheet->cell('M1', function ($cell) {
|
||||
$cell->setValue('确认时间');
|
||||
});
|
||||
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $key => $value) {
|
||||
if($value["type"]=="buy")
|
||||
{
|
||||
$value["type"]="卖出";
|
||||
}
|
||||
elseif($value["type"]=="sell")
|
||||
{
|
||||
$value["type"]="买入";
|
||||
}
|
||||
if($value["is_sure"]==0)
|
||||
{
|
||||
$value["is_sure"]="未完成";
|
||||
}elseif($value["is_sure"]==1)
|
||||
{
|
||||
$value["is_sure"]="已完成";
|
||||
}
|
||||
elseif($value["is_sure"]==2)
|
||||
{
|
||||
$value["is_sure"]="取消";
|
||||
}
|
||||
elseif($value["is_sure"]==3)
|
||||
{
|
||||
$value["is_sure"]="已付款";
|
||||
}
|
||||
// var_dump($value["type"]);die;
|
||||
$i = $key + 2;
|
||||
$sheet->cell('A' . $i, $value['id']);
|
||||
$sheet->cell('B' . $i, $value['legal_deal_send_id']);
|
||||
$sheet->cell('C' . $i, $value['account_number']);
|
||||
$sheet->cell('D' . $i, $value['user_realname']);
|
||||
$sheet->cell('E' . $i, $value['type']);
|
||||
$sheet->cell('F' . $i, $value['way_name']);
|
||||
$sheet->cell('G' . $i, $value['price']);
|
||||
$sheet->cell('H' . $i, $value['number']);
|
||||
$sheet->cell('I' . $i, $value['currency_name']);
|
||||
$sheet->cell('J' . $i, $value['deal_money']);
|
||||
$sheet->cell('K' . $i, $value['is_sure']);
|
||||
$sheet->cell('L' . $i, $value['format_create_time']);
|
||||
$sheet->cell('M' . $i, $value['format_update_time']);
|
||||
}
|
||||
}
|
||||
});
|
||||
})->download('xlsx');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use App\C2cDealSend;
|
||||
use App\Currency;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class C2cDealSendController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
|
||||
return view('admin.c2c.index');
|
||||
}
|
||||
public function list(Request $request){
|
||||
$limit = $request->get('limit', 10);
|
||||
$account_number = $request->get('account_number', '');
|
||||
//$seller_name = $request->get('seller_name', '');
|
||||
$type = $request->get('type', '');
|
||||
// $currency_id = $request->get('currency_id', 0);
|
||||
$result = new C2cDealSend();
|
||||
|
||||
if(!empty($account_number)){
|
||||
|
||||
$result = $result->whereHas('user', function ($query) use ($account_number) {
|
||||
$query->where('account_number', 'like', '%' . $account_number . '%');
|
||||
});
|
||||
}
|
||||
|
||||
if (!empty($type)) {
|
||||
|
||||
$result = $result->where('type', $type);
|
||||
}
|
||||
// if (!empty($currency_id)) {
|
||||
|
||||
// $result = $result->where('currency_id', $currency_id);
|
||||
// }
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
|
||||
//撤销
|
||||
public function sendBack(Request $request){
|
||||
$id = $request->get('id',0);
|
||||
if (empty($id)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$send = C2cDealSend::find($id);
|
||||
if (empty($send)){
|
||||
return $this->error('无此记录');
|
||||
}
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
C2cDealSend::sendBack($id);
|
||||
DB::commit();
|
||||
return $this->success('发布撤回成功,此发布改变为已完成状态');
|
||||
}catch (\Exception $exception){
|
||||
DB::rollback();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\C2cMerchant;
|
||||
use App\C2cMerchantOrder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class C2cMerchantController extends Controller
|
||||
{
|
||||
public function index() { return view('manages.c2c_merchant.index'); }
|
||||
public function orderIndex() { return view('manages.c2c_merchant.orders'); }
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$data = C2cMerchant::orderBy('sort', 'desc')->orderBy('id', 'desc')
|
||||
->paginate($request->input('limit', 20));
|
||||
return $this->layuiData($data);
|
||||
}
|
||||
|
||||
public function save(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
$fields = $request->only([
|
||||
'name','logo','available_qty','min_amount','max_amount','unit_price',
|
||||
'crypto_currency','fiat_currency','payment_methods','rating',
|
||||
'contact_type','contact_link','status','sort'
|
||||
]);
|
||||
foreach (['unit_price','available_qty','min_amount','max_amount','rating','sort'] as $k) {
|
||||
if (!isset($fields[$k]) || $fields[$k] === '') $fields[$k] = 0;
|
||||
}
|
||||
if (empty($fields['name'])) return $this->error('Name is required');
|
||||
|
||||
if ($id) {
|
||||
C2cMerchant::where('id', $id)->update($fields);
|
||||
} else {
|
||||
C2cMerchant::create($fields);
|
||||
}
|
||||
return $this->success('OK');
|
||||
}
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
C2cMerchant::destroy($request->input('id'));
|
||||
return $this->success('Deleted');
|
||||
}
|
||||
|
||||
public function orderList(Request $request)
|
||||
{
|
||||
$query = C2cMerchantOrder::query()
|
||||
->leftJoin('users', 'c2c_merchant_order.user_id', '=', 'users.id')
|
||||
->leftJoin('c2c_merchant', 'c2c_merchant_order.merchant_id', '=', 'c2c_merchant.id')
|
||||
->select(
|
||||
'c2c_merchant_order.*',
|
||||
'users.phone as user_phone',
|
||||
'users.email as user_email',
|
||||
'c2c_merchant.name as merchant_name'
|
||||
);
|
||||
|
||||
$merchant_id = $request->input('merchant_id');
|
||||
if ($merchant_id) $query->where('c2c_merchant_order.merchant_id', $merchant_id);
|
||||
|
||||
$status = $request->input('status');
|
||||
if ($status !== null && $status !== '' && $status !== 'all') {
|
||||
$query->where('c2c_merchant_order.status', intval($status));
|
||||
}
|
||||
|
||||
$data = $query->orderBy('c2c_merchant_order.id', 'desc')
|
||||
->paginate($request->input('limit', 20));
|
||||
|
||||
$statusMap = [0 => 'Pending', 1 => 'Completed', 2 => 'Cancelled', 3 => 'Expired'];
|
||||
$dirMap = ['buy' => 'Buy', 'sell' => 'Sell'];
|
||||
foreach ($data as $item) {
|
||||
$item->status_text = $statusMap[$item->status] ?? '';
|
||||
$item->direction_text = $dirMap[$item->direction] ?? $item->direction;
|
||||
}
|
||||
return $this->layuiData($data);
|
||||
}
|
||||
|
||||
public function completeOrder(Request $request)
|
||||
{
|
||||
$id = intval($request->input('id'));
|
||||
$order = C2cMerchantOrder::find($id);
|
||||
if (!$order) return $this->error('Order not found');
|
||||
if ($order->status != 0) return $this->error('Order already processed');
|
||||
|
||||
$order->update(['status' => 1]);
|
||||
return $this->success('Completed');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Currency;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\FeedBack;
|
||||
use App\Users;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\CandyTransfer;
|
||||
|
||||
class CandyTransferController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
return view('admin.candytransfer.index');
|
||||
}
|
||||
public function candytransfer_List(Request $request){
|
||||
$limit = $request->get('limit', 20);
|
||||
$page = $request->get('page', 1);
|
||||
$account_number = $request->get('account_number', '');
|
||||
|
||||
// var_dump($account_number);die;
|
||||
$feedback = new CandyTransfer();
|
||||
if(!empty($account_number)){
|
||||
$account_number=Users::where("account_number",$account_number)->first()->id;
|
||||
$feedback = $feedback->where("from_user_id", '=', $account_number)->orwhere("to_user_id", '=', $account_number);
|
||||
|
||||
}
|
||||
$feedbackList = $feedback->orderBy('id', 'desc')->paginate($limit, ['*'], 'page', $page);
|
||||
// dd($result);
|
||||
return $this->layuiData($feedbackList);
|
||||
}
|
||||
public function feedBackDetail(Request $request){
|
||||
$id = $request->get('id', '');
|
||||
$feedback = FeedBack::find($id);
|
||||
return view('admin.candytransfer.detail',['feedback'=> $feedback]);
|
||||
}
|
||||
public function feedBackDel(Request $request){
|
||||
$id = $request->get('id', '');
|
||||
$res = FeedBack::deatory($id);
|
||||
if($res){
|
||||
return $this->success('删除成功');
|
||||
}else{
|
||||
return $this->error('请重试');
|
||||
}
|
||||
}
|
||||
public function reply(Request $request){
|
||||
$id = $request->get('id', '');
|
||||
$reply_content = $request->get('reply_content', '');
|
||||
if(empty($id)||empty($reply_content)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$feedback = FeedBack::find($id);
|
||||
$feedback->reply_content = $reply_content;
|
||||
$feedback->is_reply = 1;
|
||||
$feedback->reply_time = time();
|
||||
$feedback->save();
|
||||
return $this->success('回复成功');
|
||||
}
|
||||
//导出用户列表至excel
|
||||
public function csv()
|
||||
{
|
||||
$data = FeedBack::all()->toArray();
|
||||
return Excel::create('反馈数据', function ($excel) use ($data) {
|
||||
$excel->sheet('反馈数据', function ($sheet) use ($data) {
|
||||
$sheet->cell('A1', function ($cell) {
|
||||
$cell->setValue('ID');
|
||||
});
|
||||
$sheet->cell('B1', function ($cell) {
|
||||
$cell->setValue('账户名');
|
||||
});
|
||||
$sheet->cell('C1', function ($cell) {
|
||||
$cell->setValue('反馈内容');
|
||||
});
|
||||
$sheet->cell('D1', function ($cell) {
|
||||
$cell->setValue('回复内容');
|
||||
});
|
||||
$sheet->cell('E1', function ($cell) {
|
||||
$cell->setValue('反馈时间');
|
||||
});
|
||||
$sheet->cell('F1', function ($cell) {
|
||||
$cell->setValue('回复时间');
|
||||
});
|
||||
$sheet->cell('G1', function ($cell) {
|
||||
$cell->setValue('状态');
|
||||
});
|
||||
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $key => $value) {
|
||||
$i = $key + 2;
|
||||
$sheet->cell('A' . $i, $value['id']);
|
||||
$sheet->cell('B' . $i, $value['account_number']);
|
||||
$sheet->cell('C' . $i, $value['content']);
|
||||
$sheet->cell('D' . $i, $value['reply_content']);
|
||||
$sheet->cell('E' . $i, $value['create_time']);
|
||||
$sheet->cell('F' . $i, $value['reply_time']);
|
||||
$sheet->cell('G' . $i, $value['is_reply']);
|
||||
}
|
||||
}
|
||||
});
|
||||
})->download('xlsx');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 提币控制器
|
||||
*/
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\UsersWalletOut;
|
||||
use App\UsersWallet;
|
||||
use App\AccountLog;
|
||||
use App\Currency;
|
||||
use App\Setting;
|
||||
use App\Users;
|
||||
use App\Utils\RPC;
|
||||
use App\DAO\BlockChain;
|
||||
use App\UserCashInfo;
|
||||
use App\UserCashInfoInternational;
|
||||
|
||||
class CashbController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('admin.cashb.index');
|
||||
}
|
||||
|
||||
public function cashbList(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 20);
|
||||
$account_number = $request->input('account_number', '');
|
||||
$user_id = $request->input('user_id', '');
|
||||
// file_put_contents('/www/wwwroot/crypto/public/t.txt',$user_id."---".$account_number);
|
||||
$userWalletOut = new UsersWalletOut();
|
||||
$userWalletOutList = $userWalletOut->whereHas('user', function ($query) use ($account_number,$user_id) {
|
||||
if ($account_number != '') {
|
||||
$query->where('phone', $account_number)
|
||||
->orWhere('account_number', $account_number)
|
||||
->orWhere('email', $account_number)
|
||||
->orWhere('id', $account_number);
|
||||
}
|
||||
if ($user_id != '') {
|
||||
$query->where('id', $user_id);
|
||||
}
|
||||
})->orderBy('id', 'desc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($userWalletOutList);
|
||||
}
|
||||
|
||||
public function show(Request $request)
|
||||
{
|
||||
$id = $request->get('id', '');
|
||||
if (!$id) {
|
||||
return $this->error('参数小错误');
|
||||
}
|
||||
$walletout = UsersWalletOut::find($id);
|
||||
$card_info = null;
|
||||
$card_info_data = [];
|
||||
if ($walletout->type == 1) { // 提现到银行卡
|
||||
$card_info = UserCashInfo::where('user_id', $walletout->user_id)->first();
|
||||
} else if ($walletout->type == 2) { // 提现到国际卡
|
||||
// 获取表单设置
|
||||
$forms = Setting::getValueByKey("form_international");
|
||||
$list = explode("\n", $forms);
|
||||
$lang = session('lang', 'en');
|
||||
$langs = ['en', 'zh', 'hk', 'fra', 'jp', 'kor', 'spa', 'th'];
|
||||
$new_forms = [];
|
||||
|
||||
$card_info = UserCashInfoInternational::where('user_id', $walletout->user_id)->first();
|
||||
$data = explode("\n", $card_info->data);
|
||||
$card_info_data = [];
|
||||
foreach ($list as $i => $item) {
|
||||
$_item = explode('|', $item); // 多语言用|分隔开,分别是en|zh|hk|fra|jp|kor|spa|th
|
||||
$_values = [];
|
||||
foreach ($langs as $_k => $_lang) {
|
||||
try {
|
||||
$_values[$_lang] = $_item[$_k];
|
||||
} catch (\Exception $e) {
|
||||
$_values[$_lang] = $_item[0];
|
||||
}
|
||||
}
|
||||
$new_forms[] = $_values[$lang];
|
||||
try{
|
||||
$card_info_data[$_values[$lang]] = $data[$i];
|
||||
} catch (\Exception $e) {
|
||||
$card_info_data[$_values[$lang]] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
$use_chain_api = Setting::getValueByKey('use_chain_api', 0);
|
||||
return view('admin.cashb.edit', ['wallet_out' => $walletout,'use_chain_api' => $use_chain_api, 'card_info'=>$card_info, 'card_info_data' => $card_info_data]);
|
||||
|
||||
}
|
||||
|
||||
//test
|
||||
public function done(Request $request)
|
||||
{
|
||||
set_time_limit(0);
|
||||
$id = $request->get('id', '');
|
||||
$method = $request->get('method', '');
|
||||
$notes = $request->get('notes', '');
|
||||
$verificationcode = $request->input('verificationcode', '');
|
||||
$txid = $request->input('txid', '');
|
||||
if (!$id) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$wallet_out = UsersWalletOut::where('status', '<=', 1)->lockForUpdate()->findOrFail($id);
|
||||
$number = $wallet_out->number;
|
||||
$real_number = bc_mul($wallet_out->number, bc_sub(1, bc_div($wallet_out->rate, 100)));
|
||||
$user_id = $wallet_out->user_id;
|
||||
$currency = 3;//$wallet_out->currency;dapp只有USDC =3
|
||||
$currency_type = $wallet_out->currency_type;
|
||||
|
||||
$currency_model = Currency::find($currency);
|
||||
|
||||
$contract_address = $currency_model->contract_address;
|
||||
$total_account = $currency_model->total_account;
|
||||
|
||||
|
||||
$user_wallet = UsersWallet::where('user_id', $user_id)->where('currency', $currency)->lockForUpdate()->first();
|
||||
|
||||
if ($method == 'done') {//确认提币
|
||||
// $key = $currency_model->origin_key;
|
||||
// //以太坊确认提币后。返回成功执行后台操作ldh
|
||||
// $chain_address = $wallet_out->address;
|
||||
// if (empty($total_account) || empty($key)) {
|
||||
// throw new \Exception('请检查您的币种设置:(');
|
||||
// }
|
||||
// if (!in_array($currency_type, ['eth', 'erc20', 'usdt', 'btc'])) {
|
||||
// throw new \Exception('币种类型暂不支持:(');
|
||||
// }
|
||||
// if ($currency_type == 'erc20') {
|
||||
// if (empty($contract_address)) {
|
||||
// throw new \Exception('币种设置缺少合约地址:(');
|
||||
// }
|
||||
// }
|
||||
// $use_chain_api = Setting::getValueByKey('use_chain_api', 0);
|
||||
// if ($use_chain_api == 1) {
|
||||
// //调用链上接口
|
||||
// if ($verificationcode == '') {
|
||||
// throw new Exception('请填写验证码');
|
||||
// }
|
||||
// $params = [
|
||||
// 'currency_name' => $currency_model->name,
|
||||
// 'chain_address' => $chain_address,
|
||||
// 'real_number' => $wallet_out->real_number,
|
||||
// 'total_account' => $total_account,
|
||||
// 'key' => $key
|
||||
// ];
|
||||
// $query_str = md5(http_build_query($params));
|
||||
// if (Cache::has($query_str)) {
|
||||
// throw new \Exception('请勿重复操作,以免给您带来损失,建议用区块链浏览器查询该提币地址的交易记录');
|
||||
// }
|
||||
// Cache::put($query_str, 1, 5);
|
||||
// $transfer_result = BlockChain::transfer($currency_model->name, $currency_model->type, $chain_address, $wallet_out->real_number, $total_account, $key, 3, 0, $verificationcode);
|
||||
// if (isset($transfer_result['code']) && $transfer_result['code'] == 0) {
|
||||
// //链上请求成功
|
||||
// $wallet_out->txid = $transfer_result['txid']; //写入信息
|
||||
// } else {
|
||||
// throw new \Exception('链上请求出错:(' . ' 错误信息:' . $transfer_result);
|
||||
// }
|
||||
// }else{
|
||||
// if ($txid == '') {
|
||||
// throw new Exception('当前提币没有使用接口,请填写交易哈希以便于用户查询');
|
||||
// }
|
||||
// $wallet_out->txid = $txid;
|
||||
|
||||
// }
|
||||
$wallet_out->status = 2;//提币成功状态
|
||||
$wallet_out->notes = $notes;//反馈的信息
|
||||
$wallet_out->verificationcode = $verificationcode;
|
||||
$wallet_out->update_time = time();
|
||||
$wallet_out->save();
|
||||
$change_result = change_wallet_balance($user_wallet, 4, -$number, AccountLog::WALLETOUTDONE, '提币成功', true);
|
||||
if ($change_result !== true) {
|
||||
throw new Exception($change_result);
|
||||
}
|
||||
} else {
|
||||
$wallet_out->status = 3;//提币失败状态
|
||||
$wallet_out->notes = $notes;//反馈的信息
|
||||
$wallet_out->verificationcode = $verificationcode;
|
||||
$wallet_out->update_time = time();
|
||||
|
||||
$wallet_out->save();
|
||||
$change_result = change_wallet_balance($user_wallet, 4, -$number, AccountLog::WALLETOUTBACK, '提币失败,锁定余额减少', true);
|
||||
if ($change_result !== true) {
|
||||
throw new Exception($change_result);
|
||||
}
|
||||
$change_result = change_wallet_balance($user_wallet, 4, $number, AccountLog::WALLETOUTBACK, '提币失败,锁定余额撤回');
|
||||
if ($change_result !== true) {
|
||||
throw new Exception($change_result);
|
||||
}
|
||||
}
|
||||
DB::commit();
|
||||
return $this->success('操作成功:)');
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//导出用户列表至excel
|
||||
public function csv()
|
||||
{
|
||||
$data = USersWalletOut::all()->toArray();
|
||||
return Excel::create('提币记录', function ($excel) use ($data) {
|
||||
$excel->sheet('提币记录', function ($sheet) use ($data) {
|
||||
$sheet->cell('A1', function ($cell) {
|
||||
$cell->setValue('ID');
|
||||
});
|
||||
$sheet->cell('B1', function ($cell) {
|
||||
$cell->setValue('账户名');
|
||||
});
|
||||
$sheet->cell('C1', function ($cell) {
|
||||
$cell->setValue('虚拟币');
|
||||
});
|
||||
$sheet->cell('D1', function ($cell) {
|
||||
$cell->setValue('提币数量');
|
||||
});
|
||||
$sheet->cell('E1', function ($cell) {
|
||||
$cell->setValue('手续费');
|
||||
});
|
||||
$sheet->cell('F1', function ($cell) {
|
||||
$cell->setValue('实际提币');
|
||||
});
|
||||
$sheet->cell('G1', function ($cell) {
|
||||
$cell->setValue('提币地址');
|
||||
});
|
||||
$sheet->cell('H1', function ($cell) {
|
||||
$cell->setValue('反馈信息');
|
||||
});
|
||||
$sheet->cell('I1', function ($cell) {
|
||||
$cell->setValue('状态');
|
||||
});
|
||||
$sheet->cell('J1', function ($cell) {
|
||||
$cell->setValue('提币时间');
|
||||
});
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $key => $value) {
|
||||
$i = $key + 2;
|
||||
if ($value['status'] == 1) {
|
||||
$value['status'] = '申请提币';
|
||||
} else if ($value['status'] == 2) {
|
||||
$value['status'] = '提币成功';
|
||||
} else {
|
||||
$value['status'] = '提币失败';
|
||||
}
|
||||
$sheet->cell('A' . $i, $value['id']);
|
||||
$sheet->cell('B' . $i, $value['account_number']);
|
||||
$sheet->cell('C' . $i, $value['currency_name']);
|
||||
$sheet->cell('D' . $i, $value['number']);
|
||||
$sheet->cell('E' . $i, $value['rate']);
|
||||
$sheet->cell('F' . $i, $value['real_number']);
|
||||
$sheet->cell('G' . $i, $value['address']);
|
||||
$sheet->cell('H' . $i, $value['notes']);
|
||||
$sheet->cell('I' . $i, $value['status']);
|
||||
$sheet->cell('I' . $i, $value['create_time']);
|
||||
}
|
||||
}
|
||||
});
|
||||
})->download('xlsx');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Admin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\{
|
||||
Address, AccountLog, Currency, UsersInsurance, InsuranceType, InsuranceClaimApply, Setting, Users, UserCashInfo, UserReal, UsersWallet
|
||||
};
|
||||
|
||||
class ClaimController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
//保险类型
|
||||
$ins_type = InsuranceType::where('status', 1)->get();
|
||||
return view("admin.claim.index")->with('ins_type', $ins_type);
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit');
|
||||
$start_time = $request->get('start_time', '');
|
||||
$end_time = $request->get('end_time', '');
|
||||
$status = $request->get('apply_status', -1);
|
||||
$type = $request->get('type', -1);
|
||||
|
||||
$mobile = $request->get('mobile', '');
|
||||
$name = $request->get('name', null);
|
||||
|
||||
$list = InsuranceClaimApply::where(function ($query) use ($start_time) {
|
||||
if (!empty($start_time)) {
|
||||
$query->where('created_at', '>=', $start_time);
|
||||
}
|
||||
})->where(function ($query) use ($end_time) {
|
||||
if (!empty($end_time)) {
|
||||
$query->where('created_at', '<=', $end_time);
|
||||
}
|
||||
})->where(function ($query) use ($status) {
|
||||
if ($status != -1) {
|
||||
$query->where('apply_status', $status);
|
||||
}
|
||||
})->where(function ($query) use ($type) {
|
||||
if ($type != -1) {
|
||||
$query->where('insurance_type', $type);
|
||||
}
|
||||
})->where(function ($query) use ($mobile) {
|
||||
if (!empty($mobile)) {
|
||||
$user = Users::where('account_number', $mobile)->first();
|
||||
if (!empty($user)) {
|
||||
$query->where('user_id', $user->id);
|
||||
}
|
||||
}
|
||||
})->where(function($query) use ($name){
|
||||
if(!empty($name)){
|
||||
$query->whereHas('user',function ($query) use ($name){
|
||||
$query->whereHas('userReal',function ($query) use ($name){
|
||||
$query->where('name',$name);
|
||||
});
|
||||
});
|
||||
}
|
||||
})->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认索赔
|
||||
*/
|
||||
public function affirm(Request $request)
|
||||
{
|
||||
$claim_apply_id = $request->get('id', 0);
|
||||
$claim_apply = InsuranceClaimApply::find($claim_apply_id);
|
||||
$admin = session()->get('admin_username');
|
||||
if (!$claim_apply) {
|
||||
return $this->error('错误参数');
|
||||
}
|
||||
if ($claim_apply->apply_status) {
|
||||
return $this->error('该理赔已处理');
|
||||
}
|
||||
$user_insurance = UsersInsurance::where('id', $claim_apply->user_insurance_id)->first();
|
||||
//保险类型
|
||||
$insurance_type = $user_insurance->insurance_type;
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$user_wallet = UsersWallet::where('user_id', $claim_apply->user_id)
|
||||
->where('currency', $insurance_type->currency_id)
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
|
||||
|
||||
switch ($insurance_type->claim_direction) {
|
||||
case 1:
|
||||
//索赔清除用户受保金额
|
||||
change_wallet_balance($user_wallet, 5, -$user_wallet->insurance_balance,
|
||||
AccountLog::USER_CLAIM_COMPENSATION, '保险赔偿用户[清除受保金额]', false);
|
||||
|
||||
//将保险受保金额给予用户保险账户
|
||||
change_wallet_balance($user_wallet, 5, $claim_apply->compensate,
|
||||
AccountLog::USER_CLAIM_COMPENSATION, '保险赔偿用户[赔偿受保金额]', false);
|
||||
break;
|
||||
case 2:
|
||||
//将用户的保险状态改变
|
||||
$user_insurance->status = 0;
|
||||
$user_insurance->rescinded_at = \Carbon\Carbon::now()->toDateTimeString();
|
||||
$user_insurance->rescinded_type = 1;//解约类型
|
||||
$user_insurance->save();
|
||||
//索赔清除用户受保金额
|
||||
change_wallet_balance($user_wallet, 5, -$user_wallet->insurance_balance,
|
||||
AccountLog::USER_CLAIM_COMPENSATION, '保险赔偿用户[清除受保金额]', false);
|
||||
|
||||
//将保险受保金额给予用户的期权账户
|
||||
change_wallet_balance($user_wallet, 4, $claim_apply->compensate,
|
||||
AccountLog::USER_CLAIM_COMPENSATION, '保险赔偿用户[赔偿受保金额]', false);
|
||||
|
||||
change_wallet_balance($user_wallet, 5, -$user_wallet->lock_insurance_balance,
|
||||
AccountLog::INSURANCE_RESCISSION2, '保险解约,扣除保险金额', true);
|
||||
break;
|
||||
default:
|
||||
throw new \Exception('未知受保金额去向状态');
|
||||
}
|
||||
//更改索赔状态
|
||||
$user_insurance->claim_status=0;
|
||||
$user_insurance->save();
|
||||
|
||||
//更改申请状态
|
||||
$claim_apply->apply_status = 1;
|
||||
$claim_apply->operator = $admin;
|
||||
$claim_apply->save();
|
||||
DB::commit();
|
||||
return $this->success('处理成功!');
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return $this->error('处理失败:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拒绝
|
||||
*/
|
||||
public function reject(Request $request)
|
||||
{
|
||||
$claim_apply_id = $request->get('id', 0);
|
||||
$claim_apply = InsuranceClaimApply::find($claim_apply_id);
|
||||
if (!$claim_apply) {
|
||||
return $this->error('错误参数');
|
||||
}
|
||||
$user_insurance = UsersInsurance::find($claim_apply->user_insurance_id);
|
||||
$refuse_reason = $request->get('refuse_reason', '');
|
||||
$admin = session()->get('admin_username');
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$user_insurance->claim_status = 0;
|
||||
$user_insurance->save();
|
||||
|
||||
$claim_apply->refuse_reason = $refuse_reason;
|
||||
$claim_apply->operator = $admin;
|
||||
$claim_apply->apply_status = 2;
|
||||
$claim_apply->save();
|
||||
DB::commit();
|
||||
return $this->success('成功');
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return $this->success('失败:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\CoinTrade;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Logic\CoinTradeLogic;
|
||||
|
||||
|
||||
class CoinTradeController extends Controller
|
||||
{
|
||||
public function tradeList(Request $request){
|
||||
$where = [];
|
||||
$account = $request->get('search','');
|
||||
$limit = $request->get('limit', 20);
|
||||
$status = $request->get('status');
|
||||
$type = $request->get('type');
|
||||
if($status){
|
||||
$where['coin_trade.status'] = $status;
|
||||
}
|
||||
if($type){
|
||||
$where['coin_trade.type'] = $type;
|
||||
}
|
||||
$res = CoinTrade::join('users as u','u_id','=','u.id')
|
||||
->join('currency as c','currency_id' ,'=','c.id')
|
||||
->join('currency as l','legal_id','=','l.id')
|
||||
->where($where)
|
||||
->where(function($q)use($account){
|
||||
if($account){
|
||||
$q->where('u.account_number','=',$account)->orWhere('u.email','=',$account);
|
||||
}})
|
||||
->select(['u.id','u.account_number','coin_trade.*','l.name as legal_name','c.name as currency_name'])
|
||||
->orderBy('coin_trade.id','desc')
|
||||
->paginate($limit);
|
||||
return $this->layuiData($res);
|
||||
}
|
||||
public function finishTrade(Request $request){
|
||||
$id = $request->get('id');
|
||||
$coinTrade = CoinTrade::find($id);
|
||||
if($coinTrade->status != 1){
|
||||
return $this->error('不在交易中状态');
|
||||
}
|
||||
try{
|
||||
CoinTradeLogic::forceMatchTrade($coinTrade->id);
|
||||
}catch (\Exception $e){
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
public function index(){
|
||||
return view('admin.cointrade.index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
public function ajaxReturn($data='', $info='', $status=0)
|
||||
{
|
||||
$result = array(
|
||||
'data' => $data, //数据或其它信息
|
||||
'info' => $info, //提示信息
|
||||
'status' => $status //1成功, 0失败
|
||||
);
|
||||
return response()->json($result);
|
||||
}
|
||||
public function error($message)
|
||||
{
|
||||
return response()->json(['type' => 'error', 'message' => $message]);
|
||||
}
|
||||
public function success($message)
|
||||
{
|
||||
return response()->json(['type' => 'ok', 'message' => $message]);
|
||||
}
|
||||
|
||||
|
||||
public function layuiData($paginateObj,$extra_data = '')
|
||||
{
|
||||
return response()->json([
|
||||
'code' => 0,
|
||||
'msg' => '',
|
||||
'count' => $paginateObj->total(),
|
||||
'data' => $paginateObj->items(),
|
||||
'extra_data' => $extra_data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function layui_table($pagination)
|
||||
{
|
||||
$count = $pagination->total();
|
||||
$items = $pagination->items();
|
||||
$result = array(
|
||||
'code' => 0,
|
||||
'msg' => '',
|
||||
'count' => $count,
|
||||
'data' => $items,
|
||||
);
|
||||
return json_encode($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,785 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\Process\Process;
|
||||
use App\Currency;
|
||||
use App\CurrencyClass;
|
||||
use App\CurrencyMatch;
|
||||
use App\CurrencyContact;
|
||||
use App\Setting;
|
||||
use App\UsersWallet;
|
||||
use App\Users;
|
||||
|
||||
class CurrencyController extends Controller
|
||||
{
|
||||
public function cclass()
|
||||
{
|
||||
return view('admin.currency.class');
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('admin.currency.index');
|
||||
}
|
||||
|
||||
public function add(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
if (empty($id)) {
|
||||
$result = new Currency();
|
||||
} else {
|
||||
$result = Currency::find($id);
|
||||
}
|
||||
|
||||
// $result->price_max = Setting::getValueByKey($result->name.'_PRICE_MAX', 0);
|
||||
// $result->price_min = Setting::getValueByKey($result->name.'_PRICE_MIN', 0);
|
||||
return view('admin.currency.add')->with('result', $result);
|
||||
}
|
||||
|
||||
public function class_transfer(Request $request){
|
||||
$id = $request->get('id', 0);
|
||||
$currency = CurrencyClass::find($id);
|
||||
|
||||
|
||||
if (empty($currency)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
|
||||
if ($currency->is_display == 1) {
|
||||
$currency->is_display = 0;
|
||||
|
||||
} else {
|
||||
$currency->is_display = 1;
|
||||
|
||||
}
|
||||
try {
|
||||
$currency->save();
|
||||
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function is_open(Request $request){
|
||||
$id = $request->get('id', 0);
|
||||
$currency = Currency::find($id);
|
||||
|
||||
if (empty($currency)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
|
||||
if ($currency->is_open == 1) {
|
||||
$currency->is_open = 0;
|
||||
$data['is_open'] = 0;
|
||||
} else {
|
||||
$currency->is_open = 1;
|
||||
$data['is_open'] = 1;
|
||||
}
|
||||
try {
|
||||
$currency->save();
|
||||
CurrencyMatch::where('currency_id', $id)->update($data);
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function is_transfer(Request $request){
|
||||
$id = $request->get('id', 0);
|
||||
$currency = Currency::find($id);
|
||||
if (empty($currency)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
|
||||
if ($currency->is_transfer == 1) {
|
||||
$currency->is_transfer = 0;
|
||||
} else {
|
||||
$currency->is_transfer = 1;
|
||||
}
|
||||
try {
|
||||
$currency->save();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
$address_erc=$request->get('address_erc')??"";
|
||||
$address_omni=$request->get('address_omni')??"";
|
||||
$issue_num=$request->get('issue_num',0)??0;
|
||||
$content=$request->get('content','')??'';
|
||||
$id = $request->get('id', 0);
|
||||
$name = $request->get('name', '');
|
||||
$real_name = $request->get('real_name', '');
|
||||
$vcode= $request->get('vcode', '');
|
||||
$sort = $request->get('sort', 0) ?? 0;
|
||||
$logo = $request->get('logo', '') ?? '';
|
||||
$type = $request->get('type', '') ?? '';
|
||||
$is_legal = $request->get('is_legal', 0) ?? 0;
|
||||
$is_lever = $request->get('is_lever', 0) ?? 0;
|
||||
$is_match = $request->get('is_match', 0) ?? 0;
|
||||
$is_micro = $request->get('is_micro', 0);
|
||||
$micro_min = $request->get('micro_min', 0);
|
||||
$micro_max = $request->get('micro_max', 0);
|
||||
$micro_holdtrade_max = $request->input('micro_holdtrade_max', 0); //最大下单笔数
|
||||
$price = $request->get('price', 0);
|
||||
$min_number = $request->get('min_number',0);
|
||||
$max_number = $request->get('max_number', 0);
|
||||
$rate = $request->get('rate', 0) ?? 0;
|
||||
$rmb_relation = $request->get('rmb_relation', 0) ?? 0;
|
||||
//$total_account = $request->get('total_account', '') ?? '';
|
||||
$micro_trade_fee = $request->get('micro_trade_fee', 0)??0;
|
||||
//$key = $request->get('key', '') ?? '';
|
||||
$contract_address = $request->get('contract_address', '') ?? '';
|
||||
$decimal_scale = $request->get('decimal_scale', 18);
|
||||
$chain_fee = $request->get('chain_fee', 0);
|
||||
$insurancable = $request->get('insurancable', 0);
|
||||
$verificationcode = $request->input('verificationcode', '');
|
||||
$enabled = $request->get('enabled', 0);
|
||||
$min_unit = $request->get('min_unit', 0);
|
||||
$count = $request->get('count', 0);
|
||||
// $price_max = $request->get('price_max',2);
|
||||
// $price_min = $request->get('price_min',1);
|
||||
|
||||
//自定义验证错误信息
|
||||
$messages = [
|
||||
'required' => ':attribute 为必填字段',
|
||||
];
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required',
|
||||
'sort' => 'required',
|
||||
'type' => 'required',
|
||||
], $messages);
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$projectname = config('app.name');
|
||||
//如果验证不通过
|
||||
if ($validator->fails()) {
|
||||
throw new \Exception($validator->errors()->first());
|
||||
}
|
||||
$currency = Currency::findOrNew($id);
|
||||
|
||||
$has = Currency::where('name', $name)->first();
|
||||
|
||||
if (empty($id) && !empty($has)) {
|
||||
throw new \Exception('币种 ' . $name . ' 已存在');
|
||||
}
|
||||
|
||||
// $chain_client = app('LbxChainServer');
|
||||
|
||||
// if ($currency->total_account != $total_account) {
|
||||
// if ($verificationcode == '') {
|
||||
// throw new \Exception('请先填写验证码再操作');
|
||||
// } else {
|
||||
// $uri = '/v3/wallet/changeaddress';
|
||||
// $response = $chain_client->request('post', $uri, [
|
||||
// 'form_params' => [
|
||||
// 'projectname' => $projectname,
|
||||
// 'coin' => strtoupper($currency->type),
|
||||
// 'address' => $total_account,
|
||||
// 'verificationcode' => $verificationcode,
|
||||
// ],
|
||||
// ]);
|
||||
// $result = json_decode($response->getBody()->getContents(), true);
|
||||
// if (!isset($result['code']) || $result['code'] != 0) {
|
||||
// throw new \Exception($result['msg'] ?? '请求发生错误');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
$currency->address_omni=$address_omni;
|
||||
$currency->address_erc=$address_erc;
|
||||
$currency->micro_trade_fee=$micro_trade_fee;
|
||||
$currency->issue_num=$issue_num;
|
||||
$currency->content=$content;
|
||||
$currency->name = $name;
|
||||
$currency->real_name = $real_name;
|
||||
$currency->vcode = $vcode;
|
||||
$currency->sort = intval($sort);
|
||||
$currency->logo = $logo;
|
||||
$currency->is_legal = $is_legal;
|
||||
$currency->is_lever = $is_lever;
|
||||
$currency->is_match = $is_match;
|
||||
$currency->is_micro = $is_micro;
|
||||
$currency->min_number = $min_number;
|
||||
$currency->max_number = $max_number;
|
||||
$currency->micro_holdtrade_max = $micro_holdtrade_max;
|
||||
$currency->rate = $rate;
|
||||
$currency->price = $price;
|
||||
$currency->micro_min = $micro_min;
|
||||
$currency->micro_max = $micro_max;
|
||||
$currency->rmb_relation = $rmb_relation;
|
||||
//$currency->total_account = $total_account;
|
||||
$currency->decimal_scale = $decimal_scale;
|
||||
$currency->insurancable = $insurancable;
|
||||
$currency->chain_fee = $chain_fee; //链上手续费
|
||||
// if ($key != '********' ) {
|
||||
// $uri = '/v3/wallet/encrypt';
|
||||
// $response = $chain_client->request('post', $uri, [
|
||||
// 'form_params' => [
|
||||
// 'projectname' => $projectname,
|
||||
// 'p' => $key,
|
||||
// ],
|
||||
// ]);
|
||||
// $result = json_decode($response->getBody()->getContents(), true);
|
||||
// if (!isset($result['code']) || $result['code'] != 0) {
|
||||
// throw new \Exception($result['msg'] ?? '请求发生错误');
|
||||
// }
|
||||
// $currency->key = $result['data']['k'];
|
||||
// }
|
||||
|
||||
$oldmin_unit=$currency->min_unit;
|
||||
$oldcount=$currency->count;
|
||||
$currency->enabled = $enabled;
|
||||
$currency->min_unit = $min_unit;
|
||||
$currency->count = $count;
|
||||
|
||||
$currency->contract_address = $contract_address;
|
||||
$currency->type = $type;
|
||||
$currency->is_display = 1;
|
||||
|
||||
if($enabled==1){
|
||||
if($min_unit!=$oldmin_unit || $count!=$oldcount){
|
||||
// $currency->yujicontact= bcadd($currency->oncontact,$count,4);
|
||||
$currency->oncontact=0;
|
||||
|
||||
}
|
||||
}else{
|
||||
$currency->yujicontact=0;
|
||||
$currency->oncontact=0;
|
||||
}
|
||||
|
||||
|
||||
$result = $currency->save();//保存币种
|
||||
if($result){
|
||||
CurrencyContact::where('currency_id', $id)->delete();
|
||||
$data['sort'] = intval($sort);
|
||||
CurrencyMatch::where('currency_id', $id)->update($data);
|
||||
}
|
||||
|
||||
// Setting::updateValueByKey($currency->name.'_PRICE_MAX', $price_max);
|
||||
// Setting::updateValueByKey($currency->name.'_PRICE_MIN', $price_min);
|
||||
|
||||
DB::commit();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
return $this->error('操作失败:' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
public function setInAddress(Request $request)
|
||||
{
|
||||
$id = $request->route('id', 0);
|
||||
$currency = Currency::findOrFail($id);
|
||||
return view('admin.currency.set_in_address', [
|
||||
'currency' => $currency,
|
||||
]);
|
||||
}
|
||||
|
||||
public function setOutAddress(Request $request)
|
||||
{
|
||||
$id = $request->route('id', 0);
|
||||
$currency = Currency::findOrFail($id);
|
||||
return view('admin.currency.set_out_address', [
|
||||
'currency' => $currency,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置转入钱包地址
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function postSetInAddress(Request $request)
|
||||
{
|
||||
try {
|
||||
$id = $request->input('id', 0);
|
||||
$verificationcode = $request->input('verificationcode', '');
|
||||
$collect_account = $request->input('collect_account', '');
|
||||
$currency = Currency::findOrFail($id);
|
||||
if ($verificationcode == '') {
|
||||
throw new \Exception('请先填写验证码再操作');
|
||||
}
|
||||
if ($collect_account == '' || $collect_account == $currency->total_account) {
|
||||
throw new \Exception('转入地址不能为空或与转出地址相同');
|
||||
}
|
||||
$projectname = config('app.name');
|
||||
$chain_client = app('LbxChainServer');
|
||||
// 更改转入地址
|
||||
$uri = '/v3/wallet/changeinaddress';
|
||||
$response = $chain_client->request('post', $uri, [
|
||||
'form_params' => [
|
||||
'projectname' => $projectname,
|
||||
'coin' => strtoupper($currency->type),
|
||||
'address' => $collect_account,
|
||||
'verificationcode' => $verificationcode,
|
||||
],
|
||||
]);
|
||||
$result = json_decode($response->getBody()->getContents(), true);
|
||||
if (!isset($result['code']) || $result['code'] != 0) {
|
||||
throw new \Exception($result['msg'] ?? '请求发生错误');
|
||||
}
|
||||
$currency->collect_account = $collect_account;
|
||||
$currency->save();
|
||||
return $this->success('操作完成');
|
||||
} catch (\Throwable $th) {
|
||||
return $this->error($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置转出钱包地址
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function postSetOutAddress(Request $request)
|
||||
{
|
||||
try {
|
||||
$id = $request->input('id', 0);
|
||||
$verificationcode = $request->input('verificationcode', '');
|
||||
$total_account = $request->input('total_account', '');
|
||||
$key = $request->input('key', '');
|
||||
$encrypt_key = '';
|
||||
$currency = Currency::findOrFail($id);
|
||||
if ($verificationcode == '') {
|
||||
throw new \Exception('请先填写验证码再操作');
|
||||
}
|
||||
if ($total_account == '' || $total_account == $currency->collect_account) {
|
||||
throw new \Exception('转出地址不能为空或与归拢地址不能相同');
|
||||
}
|
||||
$projectname = config('app.name');
|
||||
$chain_client = app('LbxChainServer');
|
||||
// 更改转出地址
|
||||
$uri = '/v3/wallet/changeoutaddress';
|
||||
$response = $chain_client->request('post', $uri, [
|
||||
'form_params' => [
|
||||
'projectname' => $projectname,
|
||||
'coin' => strtoupper($currency->type),
|
||||
'address' => $total_account,
|
||||
'verificationcode' => $verificationcode,
|
||||
],
|
||||
]);
|
||||
$result = json_decode($response->getBody()->getContents(), true);
|
||||
if (!isset($result['code']) || $result['code'] != 0) {
|
||||
throw new \Exception($result['msg'] ?? '请求发生错误');
|
||||
}
|
||||
$auto_encrypt_private = Setting::getValueByKey('auto_encrypt_private', 1);
|
||||
if ($key != '********' && $key != '') {
|
||||
if ($auto_encrypt_private) {
|
||||
$uri = '/v3/wallet/encrypt';
|
||||
$response = $chain_client->request('post', $uri, [
|
||||
'form_params' => [
|
||||
'projectname' => $projectname,
|
||||
'p' => $key,
|
||||
],
|
||||
]);
|
||||
$result = json_decode($response->getBody()->getContents(), true);
|
||||
if (!isset($result['code']) || $result['code'] != 0) {
|
||||
throw new \Exception($result['msg'] ?? '请求发生错误');
|
||||
}
|
||||
$encrypt_key = $result['data']['k'];
|
||||
} else {
|
||||
$encrypt_key = '';
|
||||
}
|
||||
}
|
||||
$currency->key = $encrypt_key;
|
||||
$currency->total_account = $total_account;
|
||||
$currency->save();
|
||||
return $this->success('操作完成');
|
||||
} catch (\Throwable $th) {
|
||||
return $this->error($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 20);
|
||||
$insurable = $request->get('insurancable', null);
|
||||
$result = new Currency();
|
||||
|
||||
if($insurable){
|
||||
$result->where('insurancable',1);
|
||||
}
|
||||
|
||||
// $account_number = $request->get('account_number','');
|
||||
|
||||
$result = $result->orderBy('sort', 'asc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
public function listsclass(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 20);
|
||||
$insurable = $request->get('is_display', null);
|
||||
$result = new CurrencyClass();
|
||||
|
||||
if($insurable){
|
||||
$result->where('is_display',1);
|
||||
}
|
||||
|
||||
// $account_number = $request->get('account_number','');
|
||||
|
||||
$result = $result->orderBy('sort', 'asc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$acceptor = Currency::find($id);
|
||||
if (empty($acceptor)) {
|
||||
return $this->error('无此币种');
|
||||
}
|
||||
try {
|
||||
$acceptor->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function isDisplay(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$currency = Currency::find($id);
|
||||
if (empty($currency)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
if ($currency->is_display == 1) {
|
||||
$currency->is_display = 0;
|
||||
} else {
|
||||
$currency->is_display = 1;
|
||||
}
|
||||
try {
|
||||
$currency->save();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
public function isInsurancable(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$currency = Currency::find($id);
|
||||
if (empty($currency)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
if ($currency->insurancable == 1) {
|
||||
$currency->insurancable = 0;
|
||||
} else {
|
||||
$currency->insurancable = 1;
|
||||
}
|
||||
try {
|
||||
$currency->save();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function executeCurrency(Request $request)
|
||||
{
|
||||
$id = intval($request->get('id', 0));
|
||||
$is_execute = Setting::getValueByKey('currency_' . $id, 0);
|
||||
if ($is_execute == 1) {
|
||||
return $this->error('该币上币程序正在后台执行中');
|
||||
} elseif ($is_execute == 2) {
|
||||
return $this->error('该币已经运行过上币程序');
|
||||
} else {
|
||||
$path = base_path();
|
||||
$process = new Process('nohup php artisan execute_currency ' . $id . ' >./execute_currency.log 2>&1 &', $path); //第一个参数是运行的命令,命令方式跟 Linux 一致,第二个参数是可以执行此条命令的路径
|
||||
//上边那个是交易所的上币逻辑,下边这个是钱包的上币逻辑
|
||||
//$process = new Process('nohup php artisan make_wallet ' . $id . ' >./execute_currency.log 2>&1 &', $path); //第一个参数是运行的命令,命令方式跟 Linux 一致,第二个参数是可以执行此条命令的路径
|
||||
$process->run();
|
||||
return $this->success('开始在后台执行上币脚本');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 交易对显示
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function match()
|
||||
{
|
||||
return view('admin.currency.match');
|
||||
}
|
||||
|
||||
public function matchList(Request $request)
|
||||
{
|
||||
$legal_id = $request->route('legal_id');
|
||||
$limit = $request->input('limit', 10);
|
||||
$legal = Currency::find($legal_id);
|
||||
$matchs = $legal->quotation()->paginate($limit);
|
||||
return $this->layuiData($matchs);
|
||||
}
|
||||
|
||||
public function addMatch($legal_id)
|
||||
{
|
||||
$is_legal = Currency::where('id', $legal_id)->value('is_legal');
|
||||
if (!$is_legal) {
|
||||
abort(403, '指定币种不是法币,不能添加交易对');
|
||||
}
|
||||
$currencies = Currency::where('id', '<>', $legal_id)->get();
|
||||
$market_from_names = CurrencyMatch::enumMarketFromNames();
|
||||
return view('admin.currency.match_add')->with('currencies', $currencies)
|
||||
->with('market_from_names', $market_from_names);
|
||||
}
|
||||
|
||||
public function postAddMatch(Request $request, $legal_id)
|
||||
{
|
||||
$is_legal = Currency::where('id', $legal_id)->value('is_legal');
|
||||
if (!$is_legal) {
|
||||
return $this->error('指定币种不是法币,不能添加交易对');
|
||||
}
|
||||
$currency_id = $request->input('currency_id');
|
||||
$is_display = $request->input('is_display', 1);
|
||||
$market_from = $request->input('market_from', 0);
|
||||
$open_transaction = $request->input('open_transaction', 0);
|
||||
$open_lever = $request->input('open_lever', 0);
|
||||
$open_microtrade = $request->input('open_microtrade', 0);
|
||||
$open_coin_trade = $request->input('open_coin_trade', 0);
|
||||
$lever_share_num = $request->input('lever_share_num', 1);
|
||||
$coin_trade_success = $request->input('coin_trade_success', 0);
|
||||
$spread = $request->input('spread', 0);
|
||||
$overnight = $request->input('overnight', 0);
|
||||
$lever_trade_fee = $request->input('lever_trade_fee', 0);
|
||||
$lever_min_share = $request->input('lever_min_share', 0);
|
||||
$lever_max_share = $request->input('lever_max_share', 0);
|
||||
$fluctuate_min = $request->input('fluctuate_min', 0);
|
||||
$fluctuate_max = $request->input('fluctuate_max', 0);
|
||||
$risk_group_result = $request->input('risk_group_result', 0);
|
||||
$cate = $request->input('category');
|
||||
$min = $request->input('min',0);
|
||||
//检测交易对是否已存在
|
||||
$exist = CurrencyMatch::where('currency_id', $currency_id)
|
||||
->where('legal_id', $legal_id)
|
||||
->first();
|
||||
if ($exist) {
|
||||
return $this->error('对应交易对已存在');
|
||||
}
|
||||
CurrencyMatch::unguard();
|
||||
$currency_match = CurrencyMatch::create([
|
||||
'legal_id' => $legal_id,
|
||||
'currency_id' => $currency_id,
|
||||
'is_display' => $is_display,
|
||||
'market_from' => $market_from,
|
||||
'open_transaction' => $open_transaction,
|
||||
'open_lever' => $open_lever,
|
||||
'open_microtrade' => $open_microtrade,
|
||||
'open_coin_trade' => $open_coin_trade,
|
||||
'lever_share_num' => $lever_share_num,
|
||||
'lever_trade_fee' => $lever_trade_fee,
|
||||
'fluctuate_min' => $fluctuate_min,
|
||||
'fluctuate_max' => $fluctuate_max,
|
||||
'risk_group_result' => $risk_group_result,
|
||||
'spread' => $spread,
|
||||
'overnight' => $overnight,
|
||||
'lever_min_share' => $lever_min_share,
|
||||
'lever_max_share' => $lever_max_share,
|
||||
'category' => $cate,
|
||||
'min' => $min,
|
||||
'create_time' => time(),
|
||||
'coin_trade_success' => $coin_trade_success,
|
||||
]);
|
||||
CurrencyMatch::reguard();
|
||||
|
||||
$all=DB::table("currency_matches")->where("market_from",1)->where("is_display",1)->select("id","currency_id","legal_id")->get();
|
||||
$all=json_decode(json_encode($all),true);
|
||||
foreach ($all as $k=>$v){
|
||||
$one=DB::table("currency")->where("id",$v["currency_id"])->select("name")->first();
|
||||
$legal=DB::table("currency")->where("id",$v["legal_id"])->select("name")->first();
|
||||
$all[$k]["name"]=$one->name;
|
||||
$all[$k]["legal_name"]=$legal->name;
|
||||
}
|
||||
$str="<?php".PHP_EOL;
|
||||
$str.='return ['.PHP_EOL;
|
||||
$str.='"tasks_matches"=>['.PHP_EOL;
|
||||
foreach ($all as $k=>$v){
|
||||
if($k>0){
|
||||
$str.=','.PHP_EOL;
|
||||
}
|
||||
$str.='['.PHP_EOL;
|
||||
$str.='"id"=>'.$v["id"].','.PHP_EOL;
|
||||
$str.='"currency_id"=>'.$v["currency_id"].','.PHP_EOL;
|
||||
$str.='"legal_id"=>'.$v["legal_id"].','.PHP_EOL;
|
||||
$str.='"name"=>"'.$v["name"].'"'.','.PHP_EOL;
|
||||
$str.='"legal_name"=>"'.$v["legal_name"].'"'.PHP_EOL;
|
||||
$str.=']';
|
||||
}
|
||||
// $str.=json_encode($all).PHP_EOL;
|
||||
$str.=']'.PHP_EOL.'];'.PHP_EOL;
|
||||
WFile("../config/tasks_matches.php",$str);
|
||||
|
||||
return isset($currency_match->id) ? $this->success('添加成功') : $this->error('添加失败');
|
||||
}
|
||||
|
||||
public function editMatch($id)
|
||||
{
|
||||
|
||||
$currency_match = CurrencyMatch::where('currency_id',$id)->first();
|
||||
if (!$currency_match) {
|
||||
abort(403, '指定交易对不存在');
|
||||
}
|
||||
$market_from_names = CurrencyMatch::enumMarketFromNames();
|
||||
$currencies = Currency::where('id', '<>', $currency_match->legal_id)->get();
|
||||
$var = compact('currency_match', 'currencies', 'market_from_names');
|
||||
return view('admin.currency.match_add', $var);
|
||||
}
|
||||
|
||||
public function postEditMatch(Request $request, $id)
|
||||
{
|
||||
$currency_id = $request->input('currency_id');
|
||||
$is_display = $request->input('is_display', 1);
|
||||
$market_from = $request->input('market_from', 0);
|
||||
$open_transaction = $request->input('open_transaction', 0);
|
||||
$open_lever = $request->input('open_lever', 0);
|
||||
$open_microtrade = $request->input('open_microtrade', 0);
|
||||
$open_coin_trade = $request->input('open_coin_trade', 0);
|
||||
$coin_trade_success = $request->input('coin_trade_success', 0);
|
||||
$lever_share_num = $request->input('lever_share_num', 1);
|
||||
$spread = $request->input('spread', 0);
|
||||
$overnight = $request->input('overnight', 0);
|
||||
$lever_trade_fee = $request->input('lever_trade_fee', 0);
|
||||
$lever_min_share = $request->input('lever_min_share', 0);
|
||||
$lever_max_share = $request->input('lever_max_share', 0);
|
||||
$fluctuate_min = $request->input('fluctuate_min', 0);
|
||||
$fluctuate_max = $request->input('fluctuate_max', 0);
|
||||
$risk_group_result = $request->input('risk_group_result', 0);
|
||||
$cate = $request->input('category');
|
||||
$min = $request->input('min',0);
|
||||
$currency_match = CurrencyMatch::where('currency_id',$id)->first();//CurrencyMatch::find($id);
|
||||
if (!$currency_match) {
|
||||
abort(403, '指定交易对不存在');
|
||||
}
|
||||
CurrencyMatch::unguard();
|
||||
$result = $currency_match->fill([
|
||||
'currency_id' => $currency_id,
|
||||
'is_display' => $is_display,
|
||||
'market_from' => $market_from,
|
||||
'open_transaction' => $open_transaction,
|
||||
'open_lever' => $open_lever,
|
||||
'open_microtrade' => $open_microtrade,
|
||||
'open_coin_trade' => $open_coin_trade,
|
||||
'lever_share_num' => $lever_share_num,
|
||||
'lever_trade_fee' => $lever_trade_fee,
|
||||
'fluctuate_min' => $fluctuate_min,
|
||||
'fluctuate_max' => $fluctuate_max,
|
||||
'risk_group_result' => $risk_group_result,
|
||||
'spread' => $spread,
|
||||
'overnight' => $overnight,
|
||||
'lever_min_share' => $lever_min_share,
|
||||
'lever_max_share' => $lever_max_share,
|
||||
'category' => $cate,
|
||||
'min' => $min,
|
||||
'create_time' => time(),
|
||||
'coin_trade_success' => $coin_trade_success,
|
||||
])->save();
|
||||
CurrencyMatch::reguard();
|
||||
|
||||
$all=DB::table("currency_matches")->where("market_from",1)->where("is_display",1)->select("id","currency_id","legal_id")->get();
|
||||
$all=json_decode(json_encode($all),true);
|
||||
foreach ($all as $k=>$v){
|
||||
$one=DB::table("currency")->where("id",$v["currency_id"])->select("name")->first();
|
||||
$legal=DB::table("currency")->where("id",$v["legal_id"])->select("name")->first();
|
||||
$all[$k]["name"]=$one->name;
|
||||
$all[$k]["legal_name"]=$legal->name;
|
||||
}
|
||||
$str="<?php".PHP_EOL;
|
||||
$str.='return ['.PHP_EOL;
|
||||
$str.='"tasks_matches"=>['.PHP_EOL;
|
||||
foreach ($all as $k=>$v){
|
||||
if($k>0){
|
||||
$str.=','.PHP_EOL;
|
||||
}
|
||||
$str.='['.PHP_EOL;
|
||||
$str.='"id"=>'.$v["id"].','.PHP_EOL;
|
||||
$str.='"currency_id"=>'.$v["currency_id"].','.PHP_EOL;
|
||||
$str.='"legal_id"=>'.$v["legal_id"].','.PHP_EOL;
|
||||
$str.='"name"=>"'.$v["name"].'"'.','.PHP_EOL;
|
||||
$str.='"legal_name"=>"'.$v["legal_name"].'"'.PHP_EOL;
|
||||
$str.=']';
|
||||
}
|
||||
// $str.=json_encode($all).PHP_EOL;
|
||||
$str.=']'.PHP_EOL.'];'.PHP_EOL;
|
||||
WFile("../config/tasks_matches.php",$str);
|
||||
return $result ? $this->success('保存成功') : $this->error('保存失败');
|
||||
}
|
||||
|
||||
public function delMatch($id)
|
||||
{
|
||||
$result = CurrencyMatch::destroy($id);
|
||||
|
||||
$all=DB::table("currency_matches")->where("market_from",1)->where("is_display",1)->select("id","currency_id","legal_id")->get();
|
||||
$all=json_decode(json_encode($all),true);
|
||||
foreach ($all as $k=>$v){
|
||||
$one=DB::table("currency")->where("id",$v["currency_id"])->select("name")->first();
|
||||
$legal=DB::table("currency")->where("id",$v["legal_id"])->select("name")->first();
|
||||
$all[$k]["name"]=$one->name;
|
||||
$all[$k]["legal_name"]=$legal->name;
|
||||
}
|
||||
$str="<?php".PHP_EOL;
|
||||
$str.='return ['.PHP_EOL;
|
||||
$str.='"tasks_matches"=>['.PHP_EOL;
|
||||
foreach ($all as $k=>$v){
|
||||
if($k>0){
|
||||
$str.=','.PHP_EOL;
|
||||
}
|
||||
$str.='['.PHP_EOL;
|
||||
$str.='"id"=>'.$v["id"].','.PHP_EOL;
|
||||
$str.='"currency_id"=>'.$v["currency_id"].','.PHP_EOL;
|
||||
$str.='"legal_id"=>'.$v["legal_id"].','.PHP_EOL;
|
||||
$str.='"name"=>"'.$v["name"].'"'.','.PHP_EOL;
|
||||
$str.='"legal_name"=>"'.$v["legal_name"].'"'.PHP_EOL;
|
||||
$str.=']';
|
||||
}
|
||||
// $str.=json_encode($all).PHP_EOL;
|
||||
$str.=']'.PHP_EOL.'];'.PHP_EOL;
|
||||
WFile("../config/tasks_matches.php",$str);
|
||||
return $result ? $this->success('删除成功') : $this->error('删除失败');
|
||||
}
|
||||
|
||||
public function microMatch(Request $request)
|
||||
{
|
||||
return view('admin.setting.currency_risk');
|
||||
}
|
||||
|
||||
public function microMatchList(Request $request)
|
||||
{
|
||||
$limit = $request->input('limit', 10);
|
||||
$risk = $request->input('risk', -2);
|
||||
$currency_match = CurrencyMatch::where('open_microtrade', 1)
|
||||
->when($risk != -2, function ($query) use ($risk) {
|
||||
$query->where('risk_group_result', $risk);
|
||||
})
|
||||
->paginate($limit);
|
||||
$items = $currency_match->getCollection();
|
||||
$items->transform(function ($item, $key) {
|
||||
return $item->append('risk_group_result_name');
|
||||
});
|
||||
$currency_match->setCollection($items);
|
||||
return $this->layuiData($currency_match);
|
||||
}
|
||||
|
||||
public function microRisk(Request $request)
|
||||
{
|
||||
$ids = $request->input('ids', []);
|
||||
$risk = $request->input('risk', 0);
|
||||
$affect_rows = CurrencyMatch::whereIn('id', $ids)->update(['risk_group_result' => $risk]);
|
||||
return $this->success($affect_rows . '个交易对设置成功');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\CurrencyDepositOrder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Currency;
|
||||
use App\CurrencyDeposit;
|
||||
use App\LhDepositOrder;
|
||||
class CurrencyDepositController extends Controller
|
||||
{
|
||||
public function currencyConfig(Request $request){
|
||||
$currencyId = $request->route('currency_id');
|
||||
$limit = $request->get('limit', 20);
|
||||
// var_dump($currencyId);exit;
|
||||
$list = CurrencyDeposit::where('currency_id',$currencyId)->orderBy('id', 'asc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function newConfig(Request $request){
|
||||
$currencyId = $request->get('currency_id');
|
||||
$day = $request->get('day');
|
||||
$rate = $request->get('rate');
|
||||
$save_min = $request->get('save_min');
|
||||
$output = $request->get('out_currency_id');
|
||||
$res = DB::table('currency_deposit')->where('currency_id',$currencyId)->where('day',$day)->where('output_currency_id',$output)->first();
|
||||
if($res){
|
||||
return $this->error('存在重复的期限');
|
||||
}
|
||||
DB::table('currency_deposit')->insert([
|
||||
'day' => $day,
|
||||
'output_currency_id' => $output,
|
||||
'total_interest_rate' => $rate,
|
||||
'currency_id' => $currencyId,
|
||||
'save_min' => $save_min,
|
||||
'created_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
return $this->success('创建成功');
|
||||
}
|
||||
|
||||
public function deleteConfig(Request $request){
|
||||
$configId = $request->get('id');
|
||||
DB::table('currency_deposit')->where('id',$configId)->delete();
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
public function editConfig(Request $request){
|
||||
$configId = $request->get('id');
|
||||
$day = $request->get('day');
|
||||
$rate = $request->get('rate');
|
||||
$save_min = $request->get('save_min');
|
||||
$model = DB::table('currency_deposit')->where('id',$configId)->first();
|
||||
if(!$model){
|
||||
return $this->error('找不到次期限');
|
||||
}
|
||||
$res = DB::table('currency_deposit')->where('id','<>',$configId)->where('currency_id',$model->currency_id)->where('day',$day)->first();
|
||||
if($res){
|
||||
return $this->error('存在重复的期限');
|
||||
}
|
||||
DB::table('currency_deposit')->where('id',$configId)->update([
|
||||
'day' => $day,
|
||||
// 'total_rate' => $rate,
|
||||
'total_interest_rate' => $rate,
|
||||
'save_min' => $save_min,
|
||||
// 'created_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
return $this->success('创建成功');
|
||||
}
|
||||
|
||||
public function orderList(Request $request){
|
||||
$account = $request->get('account_number');
|
||||
$currencyId = $request->get('currency_id');
|
||||
$status = $request->get('status');
|
||||
$limit = $request->get('limit', 20);
|
||||
$page = $request->get('page', 1);
|
||||
$where = [];
|
||||
if($currencyId){
|
||||
$where['currency_id'] = $currencyId;
|
||||
}
|
||||
if($status){
|
||||
$where['lh_deposit_order.status'] = $status;
|
||||
}
|
||||
|
||||
// $model = new CurrencyDepositOrder();
|
||||
// $list = $model->join('users','users.id','=','u_id')->join('currency','currency.id','=','currency_id')
|
||||
// ->where(function($q)use($account){
|
||||
// if($account){
|
||||
// $q->where('users.account_number','=',$account)->orWhere('users.email','=',$account);
|
||||
// }
|
||||
// })->where($where)->orderBy('currency_deposit_order.created_at','desc')
|
||||
// ->select(['currency.name as currency_name','users.account_number','currency_deposit_order.*'])
|
||||
// ->paginate($limit);
|
||||
// $list = LhDepositOrder::join('currency','currency.id','=','currency_id')
|
||||
// ->where($where)
|
||||
// ->orderBy('lh_deposit_order.id','desc')
|
||||
// ->skip($limit*($page-1))->take($limit)
|
||||
// ->get(['currency.name as currency_name','lh_deposit_order.id','amount','day_rate','total_interest','start_at','end_at','status'])
|
||||
// ->paginate($limit);
|
||||
$model = new LhDepositOrder();
|
||||
$list = $model->join('users','users.id','=','user_id')->join('currency','currency.id','=','currency_id')
|
||||
->where(function($q)use($account){
|
||||
if($account){
|
||||
$q->where('users.account_number','=',$account)->orWhere('users.email','=',$account);
|
||||
}
|
||||
})->where($where)->orderBy('lh_deposit_order.created_at','desc')
|
||||
->select(['currency.name as currency_name','users.account_number','lh_deposit_order.*'])
|
||||
->paginate($limit);
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
public function orderView(){
|
||||
return view('admin.currency.order_list');
|
||||
}
|
||||
|
||||
public function addConfigView(Request $request){
|
||||
$currencies = Currency::where('id', '>', 0)->get();
|
||||
return view('admin.currency.add_config')->with('currencies', $currencies);
|
||||
|
||||
}
|
||||
|
||||
public function editConfigView(Request $request){
|
||||
return view('admin.currency.edit_config');
|
||||
}
|
||||
|
||||
public function configView(){
|
||||
return view('admin.currency.config');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\Currency;
|
||||
use App\CurrencyProjectOrder;
|
||||
use App\CurrencyProject;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\UsersWallet;
|
||||
use App\AccountLog;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class CurrencyProjectController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function projectDetail(Request $request){
|
||||
$id = $request->get('project_id');
|
||||
$project = CurrencyProject::find($id);
|
||||
return $this->success($project);
|
||||
}
|
||||
|
||||
public function projectList(Request $request){
|
||||
$limit = $request->get('limit', 20);
|
||||
$model = new CurrencyProject();
|
||||
$currency_id = $request->get('currency_id');
|
||||
$where = [];
|
||||
if($currency_id){
|
||||
$where['currency_id'] = $currency_id;
|
||||
}
|
||||
$list = $model->where($where)->paginate($limit);
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function newProject(Request $request){
|
||||
$currencyId = $request->get('currency_id');
|
||||
$payCurrencyId = $request->get('pay_currency_id');
|
||||
$title = $request->get('title');
|
||||
$summary = $request->get('summary');
|
||||
$content = $request->get('content');
|
||||
$startAt = $request->get('start_at');
|
||||
$endAt = $request->get('end_at');
|
||||
$whiteBook = $request->get('white_book');
|
||||
$price = $request->get('price');
|
||||
$link = $request->get('link');
|
||||
$logo = $request->get('logo');
|
||||
$min = $request->get('min',0);
|
||||
$amount = $request->get('amount');
|
||||
$sellBegin = $request->get('sell_begin',null);
|
||||
|
||||
if(empty($amount) ||empty($currencyId) || empty($title) || empty($summary) || empty($content) || empty($startAt) || empty($endAt) || empty($whiteBook) || empty($link)){
|
||||
return $this->error('内容不能为空');
|
||||
}
|
||||
$currency = Currency::find($currencyId);
|
||||
if(!$currency){
|
||||
return $this->error('币种不存在');
|
||||
}
|
||||
$payCurrency = Currency::find($payCurrencyId);
|
||||
if(!$payCurrency){
|
||||
return $this->error('支付币种不存在');
|
||||
}
|
||||
// $res = CurrencyProject::where('currency_id',$currencyId)->first();
|
||||
// if($res){
|
||||
// return $this->error('该币种已成立项目,不能重复');
|
||||
// }
|
||||
if(strtotime($startAt) < time() || strtotime($endAt) < time()){
|
||||
return $this->error('开始时间与结束时间不得早于当前时间');
|
||||
}
|
||||
if($sellBegin && strtotime($sellBegin) < strtotime($endAt)){
|
||||
return $this->error('配售时间不得早于结束时间');
|
||||
}
|
||||
if(empty($request->input('total_apply')) || empty($request->input('win_rate'))){
|
||||
return $this->error('中奖配置不能为空');
|
||||
}
|
||||
CurrencyProject::insert([
|
||||
'currency_id' => $currencyId,
|
||||
'title' => $title,
|
||||
'summary' => $summary,
|
||||
'content' => $content,
|
||||
'white_book' => $whiteBook,
|
||||
'link' => $link,
|
||||
'price' => $price,
|
||||
'pay_currency_id' => $payCurrencyId,
|
||||
'start_at' => $startAt,
|
||||
'end_at' => $endAt,
|
||||
'logo' => $logo,
|
||||
'sell_begin' => $sellBegin,
|
||||
'min' => $min,
|
||||
'amount' => $amount,
|
||||
'sell_amount' => $request->input('sell_amount',0),
|
||||
'total_apply' => $request->input('total_apply'),
|
||||
'win_rate' => $request->input('win_rate')
|
||||
|
||||
]);
|
||||
return $this->success('创建成功');
|
||||
}
|
||||
|
||||
public function editProject(Request $request){
|
||||
$projectId = $request->get('project_id');
|
||||
$title = $request->get('title');
|
||||
$summary = $request->get('summary');
|
||||
$content = $request->get('content');
|
||||
$startAt = $request->get('start_at');
|
||||
$price = $request->get('price');
|
||||
$endAt = $request->get('end_at');
|
||||
$whiteBook = $request->get('white_book');
|
||||
$logo = $request->get('logo');
|
||||
$link = $request->get('link');
|
||||
$min = $request->get('min',0);
|
||||
$sellBegin = $request->get('sell_begin',null);
|
||||
$amount = $request->get('amount',0);
|
||||
if(empty($amount) || empty($projectId) || empty($title) || empty($summary) || empty($content) || empty($startAt) || empty($endAt) || empty($whiteBook) || empty($link)){
|
||||
return $this->error('内容不能为空');
|
||||
}
|
||||
|
||||
$project = CurrencyProject::find($projectId);
|
||||
if(!$project){
|
||||
return $this->error('找不到此项目');
|
||||
}
|
||||
if(strtotime($project->start_at) < time()){
|
||||
// return $this->error('项目已开启,不可编辑');
|
||||
}
|
||||
if($project->status == 2){
|
||||
return $this->error('此项目已完结');
|
||||
}
|
||||
if($sellBegin && strtotime($sellBegin) < strtotime($endAt)){
|
||||
return $this->error('配售时间不得早于结束时间');
|
||||
}
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'summary' => $summary,
|
||||
'content' => $content,
|
||||
'white_book' => $whiteBook,
|
||||
'price' => $price,
|
||||
'link' => $link,
|
||||
'start_at' => $startAt,
|
||||
'logo' => $logo,
|
||||
'end_at' => $endAt,
|
||||
'sell_begin' => $sellBegin,
|
||||
'min' => $min,
|
||||
'amount' =>$amount,
|
||||
'sell_amount' => $request->input('sell_amount',0),
|
||||
'total_apply' => $request->input('total_apply'),
|
||||
'win_rate' => $request->input('win_rate')
|
||||
];
|
||||
CurrencyProject::where('id',$projectId)->update($data);
|
||||
return $this->success('创建成功');
|
||||
}
|
||||
|
||||
|
||||
public function projectOrderList(Request $request){
|
||||
$id = $request->get('project_id');
|
||||
$project = CurrencyProject::find($id);
|
||||
$limit = $request->get('limit');
|
||||
$type = $request->get('type');
|
||||
$search = $request->get('search');
|
||||
$status = $request->get('status');
|
||||
if(!$project){
|
||||
return $this->error('找不到项目');
|
||||
}
|
||||
$where = [];
|
||||
if($type){
|
||||
$where['currency_project_order.type'] = $type;
|
||||
}
|
||||
if($status){
|
||||
$where['currency_project_order.status'] = $status;
|
||||
}
|
||||
$model = CurrencyProjectOrder::join('users','users.id','=','u_id');
|
||||
if($search){
|
||||
$model = $model->where("phone", 'like', '%' . $account . '%')
|
||||
->orwhere('email', 'like', '%' . $account . '%')
|
||||
->orWhere('account_number', 'like', '%' . $account . '%');
|
||||
}
|
||||
$orders =$model->where('project_id',$id)->where($where)
|
||||
->select(['currency_project_order.*','users.account_number'])->paginate($limit);
|
||||
return $this->layuiData($orders);
|
||||
}
|
||||
|
||||
public function confirmSell(Request $request){
|
||||
$order_id = $request->get('order_id');
|
||||
$amount = $request->get('amount');
|
||||
if(empty($order_id) || empty($amount)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$order = CurrencyProjectOrder::find($order_id);
|
||||
if(!$order){
|
||||
return $this->error('找不到订单');
|
||||
}
|
||||
if($order->type != 3){
|
||||
return $this->error('订单类型异常');
|
||||
}
|
||||
if($order->status != 2){
|
||||
return $this->error('订单状态异常');
|
||||
}
|
||||
$price = bc_div($order->total_price,$amount,8);
|
||||
$op_wallet = UsersWallet::where('user_id',$order->u_id)
|
||||
->where('currency',$order->currency_id)
|
||||
->first();
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
$result = change_wallet_balance($op_wallet,
|
||||
4,
|
||||
$amount,
|
||||
AccountLog::IEO_OPERATION,
|
||||
'ieo order');
|
||||
$order->price = $price;
|
||||
$order->coin_amount = $amount;
|
||||
$order->status = 3;
|
||||
$order->save();
|
||||
DB::commit();
|
||||
}catch (\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
public function confirmSellView(){
|
||||
return view('admin.currency.confirm_sell');
|
||||
}
|
||||
|
||||
public function projectOrderView(){
|
||||
return view('admin.currency.project_orders');
|
||||
}
|
||||
|
||||
public function projectView(){
|
||||
return view('admin.currency.project_list');
|
||||
}
|
||||
public function projectDetailView(){
|
||||
|
||||
$id = Input::get('id',0);
|
||||
$info = null;
|
||||
if ($id){
|
||||
$info = CurrencyProject::find($id);
|
||||
}
|
||||
|
||||
$currencies = Currency::where('id', '>', 0)->get();
|
||||
return view('admin.currency.project_detail')->with('currencies', $currencies)
|
||||
->with('info',$info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\Process\Process;
|
||||
use App\Admin;
|
||||
use App\AdminRole;
|
||||
use App\AdminRolePermission;
|
||||
use App\Users;
|
||||
|
||||
class DefaultController extends Controller
|
||||
{
|
||||
|
||||
public function login()
|
||||
{
|
||||
$username = Input::get('username', '');
|
||||
$password = Input::get('password', '');
|
||||
if (empty($username)) {
|
||||
return $this->error('用户名必须填写');
|
||||
}
|
||||
if (empty($password)) {
|
||||
return $this->error('密码必须填写');
|
||||
}
|
||||
$password = Users::MakePassword($password);
|
||||
$admin = Admin::where('username', $username)->where('password', $password)->first();
|
||||
if (empty($admin)) {
|
||||
return $this->error('用户名密码错误');
|
||||
} else {
|
||||
$role = AdminRole::find($admin->role_id);
|
||||
if (empty($role)) {
|
||||
return $this->error('账号异常');
|
||||
} else {
|
||||
session()->put('admin_username', $admin->username);
|
||||
session()->put('admin_id', $admin->id);
|
||||
session()->put('admin_role_id', $admin->role_id);
|
||||
session()->put('admin_is_super', $role->is_super);
|
||||
return $this->success('登陆成功');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function login1()
|
||||
{
|
||||
return view('admin.login1');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$admin_role = AdminRolePermission::where("role_id", session()->get('admin_role_id'))->get();
|
||||
$admin_role_data = array();
|
||||
foreach ($admin_role as $r) {
|
||||
array_push($admin_role_data, $r->action);
|
||||
}
|
||||
return view('admin.indexnew')->with("admin_role_data", $admin_role_data);;
|
||||
}
|
||||
|
||||
public function indexnew()
|
||||
{
|
||||
$admin_role = AdminRolePermission::where("role_id", session()->get('admin_role_id'))->get();
|
||||
$admin_role_data = array();
|
||||
foreach ($admin_role as $r) {
|
||||
array_push($admin_role_data, $r->action);
|
||||
}
|
||||
return view('admin.index')->with("admin_role_data", $admin_role_data);;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getVerificationCode(Request $request)
|
||||
{
|
||||
$http_client = app('LbxChainServer');
|
||||
|
||||
$uri = '/v3/wallet/verification';
|
||||
|
||||
$response = $http_client->request('post', $uri, [
|
||||
'form_params' => [
|
||||
'projectname' => config('app.name'),
|
||||
],
|
||||
]);
|
||||
$result = json_decode($response->getBody()->getContents(), true);
|
||||
if (isset($result['code']) && $result['code'] == 0) {
|
||||
return $this->success('发送成功');
|
||||
} else {
|
||||
return $this->error($result['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\Process\Process;
|
||||
use App\Admin;
|
||||
use App\Users;
|
||||
use App\Currency;
|
||||
use App\DualCurrency;
|
||||
use App\DualOrder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DualController extends Controller
|
||||
{
|
||||
private $Month_E = array('01' => "Jan",
|
||||
'02' => "Feb",
|
||||
'03' => "Mar",
|
||||
'04' => "Apr",
|
||||
'05' => "May",
|
||||
'06' => "Jun",
|
||||
'07' => "Jul",
|
||||
'08' => "Aug",
|
||||
'09' => "Sep",
|
||||
'10' => "Oct",
|
||||
'11' => "Nov",
|
||||
'12' => "Dec");
|
||||
|
||||
public function index(){
|
||||
|
||||
return view('admin.dual.index');
|
||||
}
|
||||
|
||||
public function order(){
|
||||
|
||||
|
||||
return view('admin.dual.order');
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function order_lists(Request $request){
|
||||
|
||||
$limit = $request->get('limit', 20);
|
||||
$orderid = $request->get('orderid');
|
||||
$user_id = $request->get('user_id');
|
||||
$status = $request->get('status');
|
||||
|
||||
|
||||
$list = DB::table('dual_order')->join('dual_currency', 'dual_currency.id', '=', 'dual_order.dual_id');
|
||||
|
||||
if($orderid){
|
||||
$list->where('dual_order.orderid','LIKE','%'.$orderid.'%');
|
||||
}
|
||||
|
||||
if($status){
|
||||
$list->where('dual_order.status',$status);
|
||||
}
|
||||
|
||||
if($user_id){
|
||||
$list->where('dual_order.user_id',$user_id);
|
||||
}
|
||||
|
||||
$list = $list->select('dual_order.*','dual_currency.days')->orderBy('dual_order.id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function add(){
|
||||
$currencies = Currency::where('is_legal', 1)->get();
|
||||
return view('admin.dual.add')->with('currencies', $currencies);
|
||||
}
|
||||
|
||||
|
||||
public function editDualView(Request $request){
|
||||
$id = $request->get('id');
|
||||
if(empty($id)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$dual_currency = DualCurrency::where(['id'=>$id])->first();
|
||||
|
||||
$invest = $dual_currency->invest;
|
||||
|
||||
|
||||
$currencies = Currency::where('is_legal', 1)->get();
|
||||
// dump($dual_currency);die;
|
||||
return view('admin.dual.edit_dual',['results' => $dual_currency])->with('currencies', $currencies)->with('invest', $invest);
|
||||
}
|
||||
|
||||
//编辑项目
|
||||
public function editDual(Request $request){
|
||||
|
||||
$id = $request->post('id');
|
||||
$name = $request->post('name');
|
||||
$days = $request->post('days');
|
||||
$rate = $request->post('rate');
|
||||
$ratemax = $request->post('ratemax');
|
||||
$amount = $request->post('amount');
|
||||
$amax = $request->post('amax');
|
||||
$status = $request->post('status');
|
||||
$hot = $request->post('hot');
|
||||
$commission = $request->post('commission');
|
||||
$total_number = $request->post('total_number');
|
||||
$invest = $request->post('invest');
|
||||
$investtr ='';
|
||||
foreach ($invest as $k=>$v){
|
||||
|
||||
$investtr .=$v.'+';
|
||||
}
|
||||
$liquidateddamages = $request->post('liquidateddamages');
|
||||
|
||||
if(empty($days)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
if($rate >= $ratemax){
|
||||
return $this->error('起始回报率不能大于最大回报率');
|
||||
}
|
||||
|
||||
|
||||
if($amount >= $amax){
|
||||
return $this->error('起始金额不能大于最大金额');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$dual_currency = DualCurrency::where(['id'=>$id])->first();
|
||||
$dual_currency->invest = substr($investtr, 0, strlen($investtr) - 1);
|
||||
$dual_currency->total_number = $total_number;
|
||||
$dual_currency->remaining_number = $total_number;
|
||||
$dual_currency->hot = $hot;
|
||||
$dual_currency->commission = $commission;
|
||||
$dual_currency->days = $days;
|
||||
$dual_currency->name = $name;//$days."天";
|
||||
$dual_currency->rate = $rate;
|
||||
$dual_currency->ratemax = $ratemax;
|
||||
$dual_currency->amount = $amount;
|
||||
$dual_currency->amax = $amax;
|
||||
$dual_currency->liquidateddamages = $liquidateddamages;
|
||||
$dual_currency->status = $status;
|
||||
$dual_currency->save();
|
||||
|
||||
return $this->success('操作成功');
|
||||
// return $this->success(['data'=>$dual_currency]);
|
||||
}
|
||||
|
||||
//删除项目
|
||||
public function del(Request $request){
|
||||
$id = $request->post('id');
|
||||
|
||||
// file_put_contents('/www/wwwroot/xb-dex/public/d.txt',time().$id.PHP_EOL,FILE_APPEND);
|
||||
$Zhiya_lk = DualCurrency::where('id',$id)->first();//->get();
|
||||
|
||||
|
||||
if(empty($Zhiya_lk)){
|
||||
return $this->error('不存在');
|
||||
}
|
||||
|
||||
if($id){
|
||||
//whereNotIn
|
||||
|
||||
DualCurrency::where('id', $id)->delete();
|
||||
|
||||
return $this->success('操作成功');
|
||||
}else{
|
||||
|
||||
return $this->error('失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//新增项目
|
||||
public function saveDual(Request $request){
|
||||
$data = $request->all();
|
||||
$days = $data['days'];
|
||||
$name = $data['name'];
|
||||
$amount = $data['amount'];
|
||||
$amax = $data['amax'];
|
||||
$rate = $data['rate'];
|
||||
$ratemax = $data['ratemax'];
|
||||
$hot = $data['hot'];
|
||||
$commission = $data['commission'];
|
||||
$total_number = $data['total_number'];
|
||||
$invest = $data['invest'];
|
||||
$investtr ='';
|
||||
foreach ($invest as $k=>$v){
|
||||
|
||||
$investtr .=$v.'+';
|
||||
}
|
||||
// return $this->error($investtr);
|
||||
if($data['days'] && $data['ratemax'] && $data['rate'] && $data['liquidateddamages'] && $data['amount'] && $data['amax']){
|
||||
|
||||
|
||||
|
||||
if($rate >= $ratemax){
|
||||
return $this->error('起始回报率不能大于最大回报率');
|
||||
}
|
||||
if($amount >= $amax){
|
||||
return $this->error('起始金额不能大于最大金额');
|
||||
}
|
||||
|
||||
// $_tp = $data['type'] =='call'? 'C':'P';
|
||||
|
||||
|
||||
$dual_currency = new DualCurrency();
|
||||
$dual_currency->invest = substr($investtr, 0, strlen($investtr) - 1);
|
||||
$dual_currency->total_number = $total_number;
|
||||
$dual_currency->remaining_number = $total_number;
|
||||
$dual_currency->hot = $hot;
|
||||
$dual_currency->commission = $commission;
|
||||
$dual_currency->days = $days;
|
||||
$dual_currency->name = $name;//$days."天";
|
||||
$dual_currency->rate = $data['rate'];
|
||||
$dual_currency->ratemax = $data['ratemax'];
|
||||
$dual_currency->amount = $data['amount'];
|
||||
$dual_currency->amax = $data['amax'];
|
||||
$dual_currency->liquidateddamages = $data['liquidateddamages'];
|
||||
|
||||
$dual_currency->created = date('Y-m-d',time());
|
||||
|
||||
|
||||
$dual_currency->save();
|
||||
|
||||
return $this->success('操作成功');
|
||||
}else{
|
||||
|
||||
return $this->error('必填项不能为空');
|
||||
}
|
||||
}
|
||||
|
||||
//获取实时价格
|
||||
public function getNewPrice(Request $request){
|
||||
$currency = $request->get('currency');
|
||||
$currencys = Currency::where('id',$currency)->get()->toArray();
|
||||
|
||||
return $this->success(['data'=>$currencys]);
|
||||
}
|
||||
|
||||
//理财设置
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 20);
|
||||
$status = $request->get('status');
|
||||
|
||||
$results = DualCurrency::where('id','>',1);
|
||||
|
||||
|
||||
if(isset($status)){
|
||||
$results->where('status',$status);
|
||||
}
|
||||
|
||||
// dump($results);die;
|
||||
$results = $results->orderBy('id', 'desc')->orderBy('status','desc')->paginate($limit);
|
||||
|
||||
|
||||
return $this->layuiData($results);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Currency;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\FeedBack;
|
||||
use App\Users;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class FeedBackController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
return view('admin.feedback.index');
|
||||
}
|
||||
public function feedbackList(Request $request){
|
||||
$limit = $request->get('limit', 20);
|
||||
$page = $request->get('page', 1);
|
||||
$account_number = $request->get('account_number', '');
|
||||
$feedback = new FeedBack();
|
||||
if(!empty($account_number)){
|
||||
$feedback = $feedback->whereHas('user', function ($query) use ($account_number) {
|
||||
$query->where("account_number", 'like', '%' . $account_number . '%');
|
||||
});
|
||||
}
|
||||
$feedbackList = $feedback->orderBy('id', 'desc')->paginate($limit, ['*'], 'page', $page);
|
||||
// dd($result);
|
||||
return $this->layuiData($feedbackList);
|
||||
}
|
||||
public function feedBackDetail(Request $request){
|
||||
$id = $request->get('id', '');
|
||||
$feedback = FeedBack::find($id);
|
||||
return view('admin.feedback.detail',['feedback'=> $feedback]);
|
||||
}
|
||||
public function feedBackDel(Request $request){
|
||||
$id = $request->get('id', '');
|
||||
$res = FeedBack::find($id)->delete();
|
||||
if($res){
|
||||
return $this->success('删除成功');
|
||||
}else{
|
||||
return $this->error('请重试');
|
||||
}
|
||||
}
|
||||
public function reply(Request $request){
|
||||
$id = $request->get('id', '');
|
||||
$reply_content = $request->get('reply_content', '');
|
||||
if(empty($id)||empty($reply_content)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$feedback = FeedBack::find($id);
|
||||
$feedback->reply_content = $reply_content;
|
||||
$feedback->is_reply = 1;
|
||||
$feedback->reply_time = time();
|
||||
$feedback->save();
|
||||
return $this->success('回复成功');
|
||||
}
|
||||
//导出用户列表至excel
|
||||
public function csv()
|
||||
{
|
||||
$data = FeedBack::all()->toArray();
|
||||
return Excel::create('反馈数据', function ($excel) use ($data) {
|
||||
$excel->sheet('反馈数据', function ($sheet) use ($data) {
|
||||
$sheet->cell('A1', function ($cell) {
|
||||
$cell->setValue('ID');
|
||||
});
|
||||
$sheet->cell('B1', function ($cell) {
|
||||
$cell->setValue('账户名');
|
||||
});
|
||||
$sheet->cell('C1', function ($cell) {
|
||||
$cell->setValue('反馈内容');
|
||||
});
|
||||
$sheet->cell('D1', function ($cell) {
|
||||
$cell->setValue('回复内容');
|
||||
});
|
||||
$sheet->cell('E1', function ($cell) {
|
||||
$cell->setValue('反馈时间');
|
||||
});
|
||||
$sheet->cell('F1', function ($cell) {
|
||||
$cell->setValue('回复时间');
|
||||
});
|
||||
$sheet->cell('G1', function ($cell) {
|
||||
$cell->setValue('状态');
|
||||
});
|
||||
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $key => $value) {
|
||||
$i = $key + 2;
|
||||
$sheet->cell('A' . $i, $value['id']);
|
||||
$sheet->cell('B' . $i, $value['account_number']);
|
||||
$sheet->cell('C' . $i, $value['content']);
|
||||
$sheet->cell('D' . $i, $value['reply_content']);
|
||||
$sheet->cell('E' . $i, $value['create_time']);
|
||||
$sheet->cell('F' . $i, $value['reply_time']);
|
||||
$sheet->cell('G' . $i, $value['is_reply']);
|
||||
}
|
||||
}
|
||||
});
|
||||
})->download('xlsx');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\{
|
||||
Address, AccountLog, Currency, FlashAgainst, IdCardIdentit, Setting, Users, UserCashInfo, UserReal, UsersWallet
|
||||
};
|
||||
|
||||
class FlashAgainstController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
return view("admin.flashagainst.index");
|
||||
}
|
||||
|
||||
public function lists(Request $request){
|
||||
$limit=$request->get('limit');
|
||||
$start_time=$request->get('start_time','');
|
||||
$status=$request->get('status',-1);
|
||||
$end_time=$request->get('end_time','');
|
||||
$mobile=$request->get('mobile','');
|
||||
|
||||
$list=FlashAgainst::where(function ($query) use ($start_time){
|
||||
if (!empty($start_time)){
|
||||
$query->where('create_time','>=',strtotime($start_time));
|
||||
}
|
||||
})->where(function ($query) use ($end_time){
|
||||
if (!empty($end_time)){
|
||||
$query->where('create_time','>=',strtotime($end_time));
|
||||
}
|
||||
})->where(function ($query) use ($status){
|
||||
if ($status!=-1){
|
||||
$query->where('status',$status);
|
||||
}
|
||||
})->where(function ($query) use ($mobile){
|
||||
if (!empty($mobile)){
|
||||
$user=Users::where('account_number',$mobile)->first();
|
||||
if (!empty($user)){
|
||||
$query->where('user_id',$user->id);
|
||||
}
|
||||
}
|
||||
})->orderBy('id','desc')->paginate($limit);
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function affirm(Request $request){
|
||||
$id=$request->get('id','');
|
||||
if (empty($id)) return $this->error('参数错误');
|
||||
$result=FlashAgainst::find($id);
|
||||
if (empty($result)) return $this->error('参数错误');
|
||||
if ($result->status==1) return $this->error('已经通过,无法二次通过');
|
||||
if ($result->status==2) return $this->error('已经驳回,无法通过');
|
||||
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
$l_wallet=UsersWallet::where('user_id',$result->user_id)->where('currency',$result->left_currency_id)->lockForUpdate()->first();
|
||||
$r_wallet=UsersWallet::where('user_id',$result->user_id)->where('currency',$result->right_currency_id)->lockForUpdate()->first();
|
||||
if (empty($l_wallet)||empty($r_wallet)){
|
||||
DB::rollBack();
|
||||
return $this->error('钱包不存在');
|
||||
}
|
||||
|
||||
$result2=change_wallet_balance($l_wallet,2,-$result->num,AccountLog::DEBIT_BALANCE_MINUS_LOCK,'闪兑扣除锁定金额',true);
|
||||
if ($result2!==true){
|
||||
DB::rollBack();
|
||||
return $this->error('操作失败');
|
||||
}
|
||||
$result1=change_wallet_balance($r_wallet,4,$result->absolute_quantity,AccountLog::DEBIT_BALANCE_ADD,'闪兑通过,增加余额');
|
||||
|
||||
if ($result1 !== true){
|
||||
|
||||
DB::rollBack();
|
||||
return $this->error('操作失败');
|
||||
}
|
||||
$result->status=1;
|
||||
$result->review_time=time();
|
||||
$result->save();
|
||||
DB::commit();
|
||||
return $this->success('成功');
|
||||
|
||||
}catch (\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->error($e->getMessage().'----'.$e->getLine());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function reject(Request $request){
|
||||
$id=$request->get('id','');
|
||||
if (empty($id)) return $this->error('参数错误');
|
||||
$result=FlashAgainst::find($id);
|
||||
if (empty($result)) return $this->error('参数错误');
|
||||
if ($result->status==1) return $this->error('已经通过,无法驳回');
|
||||
if ($result->status==2) return $this->error('已经驳回,无法二次驳回');
|
||||
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
$l_wallet=UsersWallet::where('user_id',$result->user_id)->where('currency',$result->left_currency_id)->lockForUpdate()->first();
|
||||
|
||||
if (empty($l_wallet)){
|
||||
DB::rollBack();
|
||||
return $this->error('钱包不存在');
|
||||
}
|
||||
|
||||
$result2=change_wallet_balance($l_wallet,2,-$result->num,AccountLog::DEBIT_BALANCE_MINUS_LOCK,'闪兑扣除锁定金额',true);
|
||||
if ($result2!==true){
|
||||
DB::rollBack();
|
||||
return $this->error('操作失败');
|
||||
}
|
||||
$result1= change_wallet_balance($l_wallet,2,$result->num,AccountLog::DEBIT_BALANCE_ADD_REJECT,'闪兑驳回,增加余额');
|
||||
if ($result1!==true){
|
||||
DB::rollBack();
|
||||
return $this->error('操作失败');
|
||||
}
|
||||
$result->status=2;
|
||||
$result->review_time=time();
|
||||
$result->save();
|
||||
|
||||
DB::commit();
|
||||
return $this->success('成功');
|
||||
|
||||
}catch (\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->error('操作失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\LeverTransaction;
|
||||
use App\UsersWallet;
|
||||
use App\Currency;
|
||||
use App\CurrencyMatch;
|
||||
use App\MarketHour;
|
||||
use App\CurrencyQuotation;
|
||||
use App\Users;
|
||||
|
||||
class HazardRateController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$currencies = Currency::where('is_legal', 1)->get();
|
||||
return view('admin.lever.hazard.index')->with('currencies', $currencies);
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
return view('admin.lever.hazard.handle');
|
||||
}
|
||||
|
||||
public function postHandle(Request $request)
|
||||
{
|
||||
$trade_id = $request->input('id', 0);
|
||||
$update_price = $request->input('update_price', 0);
|
||||
$write_market = $request->input('write_market', 0);
|
||||
if ($trade_id <= 0 || $update_price <= 0) {
|
||||
return $this->error('参数不合法');
|
||||
}
|
||||
$time = microtime(true);
|
||||
$trade = LeverTransaction::where('status', LeverTransaction::TRANSACTION)->find($trade_id);
|
||||
if (!$trade) {
|
||||
return $this->error('交易不存在或已平仓');
|
||||
}
|
||||
$legal_id = $trade->legal;
|
||||
$legal = Currency::find($legal_id);
|
||||
$currency_id = $trade->currency;
|
||||
$currency = Currency::find($currency_id);
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
//MarketHour::batchWriteMarketData($currency_id, $legal_id, 0, $update_price, 3, intval($time));
|
||||
if ($write_market) {
|
||||
|
||||
MarketHour::batchEsearchMarket($currency->name, $legal->name, $update_price, intval($time)); //更新esearch行情价格
|
||||
$result = CurrencyQuotation::getInstance($legal_id, $currency_id)->updateData(['now_price' => $update_price]); //更新数据库价格
|
||||
if (!$result) {
|
||||
throw new \Exception('更新每日价格失败');
|
||||
}
|
||||
}
|
||||
|
||||
LeverTransaction::newPrice($legal_id, $currency_id, $update_price, $time);
|
||||
DB::commit();
|
||||
return $this->success('向系统发送价格成功');
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->input('limit', 10);
|
||||
$legal_id = $request->input('legal_id', -1);
|
||||
$type = $request->input('type', -1);
|
||||
$operate = $request->input('operate', -1);
|
||||
$hazard_rate = $request->input('hazard_rate', 0);
|
||||
$user_id = $request->input('user_id', 0);
|
||||
|
||||
$user_hazard = LeverTransaction::where('status', LeverTransaction::TRANSACTION)
|
||||
->where(function ($query) use ($user_id, $type, $legal_id) {
|
||||
!empty($user_id) && $query->where('user_id', $user_id);
|
||||
($type != -1 && in_array($type, [1, 2])) && $query->where('type', $type);
|
||||
$legal_id != -1 && $query->where('legal', $legal_id);
|
||||
})
|
||||
->orderBy('id', 'desc')
|
||||
->paginate($limit);
|
||||
|
||||
$items = $user_hazard->getCollection();
|
||||
$items->transform(function ($item, $key) use ($legal_id) {
|
||||
$user_wallet = UsersWallet::where('currency', $legal_id)
|
||||
->where('user_id', $item->user_id)
|
||||
->first();
|
||||
$sell_user = Users::where('id',$item->user_id)->first();
|
||||
// var_dump($item->user_id);
|
||||
// $user_info = DB::table('users')->where('id','=', $item->user_id)->select();
|
||||
$item->setAppends(['symbol', 'mobile', 'account_number', 'type_name', 'profits']);
|
||||
$hazard_rate = LeverTransaction::getWalletHazardRate($user_wallet);
|
||||
$balance = $user_wallet->lever_balance ?? 0;
|
||||
$item->setAttribute('lever_balance', $balance)->setAttribute('email', $sell_user)
|
||||
->setAttribute('hazard_rate', $hazard_rate);
|
||||
return $item;
|
||||
});
|
||||
if ($operate != -1 && !empty($hazard_rate)) {
|
||||
switch ($operate) {
|
||||
case 1:
|
||||
$operate_symbol = '>=';
|
||||
break;
|
||||
case 2:
|
||||
$operate_symbol = '<=';
|
||||
break;
|
||||
default:
|
||||
$operate_symbol = null;
|
||||
break;
|
||||
}
|
||||
$items = $items->where('hazard_rate', $operate_symbol, $hazard_rate);
|
||||
}
|
||||
$user_hazard->setCollection($items);
|
||||
return $this->layuiData($user_hazard);
|
||||
}
|
||||
|
||||
public function total()
|
||||
{
|
||||
$currencies = Currency::where('is_legal', 1)->get();
|
||||
return view('admin.lever.hazard.total')->with('currencies', $currencies);
|
||||
}
|
||||
|
||||
public function totalLists(Request $request)
|
||||
{
|
||||
$limit = $request->input('limit', 10);
|
||||
$legal_id = $request->input('legal_id', -1);
|
||||
$type = $request->input('type', -1);
|
||||
$operate = $request->input('operate', -1);
|
||||
$hazard_rate = $request->input('hazard_rate', 0);
|
||||
/*
|
||||
SELECT
|
||||
`user_id`,
|
||||
SUM((case `type` when 1 then update_price-price when 2 then price-update_price END)) AS profits_total,
|
||||
SUM(caution_money) AS caution_money_total
|
||||
FROM lever_transaction
|
||||
WHERE `status`=0
|
||||
GROUP BY user_id
|
||||
*/
|
||||
if($legal_id == -1){
|
||||
$legal_id=Currency::where('name','USDC')->first()->id??-1;
|
||||
}
|
||||
$user_hazard = LeverTransaction::where('status', LeverTransaction::TRANSACTION)
|
||||
->where(function ($query) use ($type, $legal_id) {
|
||||
($type != -1 && in_array($type, [1, 2])) && $query->where('type', $type);
|
||||
$legal_id != -1 && $query->where('legal', $legal_id);
|
||||
})
|
||||
->select('user_id')
|
||||
->selectRaw('SUM((CASE `type` WHEN 1 THEN `update_price` - `price` WHEN 2 THEN `price` - `update_price` END) * `number` * `multiple`) AS `profits_total`')
|
||||
->selectRaw('SUM(`caution_money`) AS `caution_money_total`')
|
||||
->groupBy('user_id')
|
||||
->paginate($limit);
|
||||
$items = $user_hazard->getCollection();
|
||||
$items->transform(function ($item, $key) use ($legal_id) {
|
||||
$user_wallet = UsersWallet::where('currency', $legal_id)
|
||||
->where('user_id', $item->user_id)
|
||||
->first();
|
||||
$item->setAppends(['mobile', 'account_number']);
|
||||
$hazard_rate = LeverTransaction::getWalletHazardRate($user_wallet);
|
||||
$balance = $user_wallet->lever_balance ?? 0;
|
||||
$item->setAttribute('lever_balance', $balance)
|
||||
->setAttribute('hazard_rate', floatval($hazard_rate));
|
||||
return $item;
|
||||
});
|
||||
if ($operate != -1 && !empty($hazard_rate)) {
|
||||
switch ($operate) {
|
||||
case 1:
|
||||
$operate_symbol = '>=';
|
||||
break;
|
||||
case 2:
|
||||
$operate_symbol = '<=';
|
||||
break;
|
||||
default:
|
||||
$operate_symbol = null;
|
||||
break;
|
||||
}
|
||||
$items = $items->where('hazard_rate', $operate_symbol, $hazard_rate);
|
||||
}
|
||||
$user_hazard->setCollection($items);
|
||||
return $this->layuiData($user_hazard);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Currency;
|
||||
use App\InsuranceType;
|
||||
use App\UsersInsurance;
|
||||
use Illuminate\Foundation\Auth\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class InsuranceController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('admin.insurance.index');
|
||||
}
|
||||
|
||||
public function add(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
if (empty($id)) {
|
||||
$result = new InsuranceType();
|
||||
} else {
|
||||
$result = InsuranceType::find($id);
|
||||
}
|
||||
$currency = Currency::where('insurancable', 1)->get();
|
||||
return view('admin.insurance.add')->with([
|
||||
'result' => $result,
|
||||
'currency' => $currency
|
||||
]);
|
||||
}
|
||||
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$data = $request->except('id');
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
InsuranceType::updateOrCreate(
|
||||
['id' => $id],
|
||||
$data
|
||||
);
|
||||
DB::commit();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$result = new InsuranceType();
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
public function del(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$result = InsuranceType::find($id);
|
||||
if (empty($result)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
try {
|
||||
$result->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 开关
|
||||
*/
|
||||
public function changeStatus(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$insurance_type = InsuranceType::find($id);
|
||||
if (empty($insurance_type)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
if ($insurance_type->status == 1) {
|
||||
$insurance_type->status = 0;
|
||||
} else {
|
||||
$insurance_type->status = 1;
|
||||
}
|
||||
try {
|
||||
$insurance_type->save();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function changeAutoClaim(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$insurance_type = InsuranceType::find($id);
|
||||
if (empty($insurance_type)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
if ($insurance_type->auto_claim == 1) {
|
||||
$insurance_type->auto_claim = 0;
|
||||
} else {
|
||||
$insurance_type->auto_claim = 1;
|
||||
}
|
||||
try {
|
||||
$insurance_type->save();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function changeTAdd1(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$insurance_type = InsuranceType::find($id);
|
||||
if (empty($insurance_type)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
if ($insurance_type->is_t_add_1 == 1) {
|
||||
$insurance_type->is_t_add_1 = 0;
|
||||
} else {
|
||||
$insurance_type->is_t_add_1 = 1;
|
||||
}
|
||||
try {
|
||||
$insurance_type->save();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
//============保险单===========
|
||||
|
||||
public function orderIndex()
|
||||
{
|
||||
return view('admin.insurance.order_index');
|
||||
}
|
||||
|
||||
public function orderLists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$mobile = $request->get('mobile', '');
|
||||
$name = $request->get('name', null);
|
||||
$type = $request->get('type', -1);
|
||||
$status = $request->get('status', -1);
|
||||
|
||||
|
||||
$result = new UsersInsurance();
|
||||
$result = $result->where(function ($query) use ($mobile) {
|
||||
if (!empty($mobile)) {
|
||||
$user = User::where('account_number', $mobile)->first();
|
||||
if (!empty($user)) {
|
||||
$query->where('user_id', $user->id);
|
||||
}
|
||||
}
|
||||
})->where(function($query) use ($name){
|
||||
if(!empty($name)){
|
||||
$query->whereHas('user',function ($query) use ($name){
|
||||
$query->whereHas('userReal',function ($query) use ($name){
|
||||
$query->where('name',$name);
|
||||
});
|
||||
});
|
||||
}
|
||||
})->where(function ($query) use ($type){
|
||||
if ($type != -1) {
|
||||
$query->whereHas('insurance_type',function ($query) use ($type){
|
||||
$query->where('type',$type);
|
||||
});
|
||||
}
|
||||
})->where(function ($query) use ($status){
|
||||
if ($status != -1) {
|
||||
$query->where('status',$status);
|
||||
}
|
||||
});
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\InsuranceRule;
|
||||
use App\InsuranceType;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\Process\Process;
|
||||
use App\MicroNumber;
|
||||
use App\MicroOrder;
|
||||
use App\MicroSecond;
|
||||
use App\Currency;
|
||||
use App\CurrencyMatch;
|
||||
use App\Setting;
|
||||
use App\UsersWallet;
|
||||
use App\Users;
|
||||
|
||||
class InsuranceRuleController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('admin.insurancerule.index');
|
||||
}
|
||||
|
||||
public function add(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
if (empty($id)) {
|
||||
$result = new InsuranceRule();
|
||||
} else {
|
||||
$result = InsuranceRule::find($id);
|
||||
}
|
||||
$insurance_type = InsuranceType::all();
|
||||
|
||||
return view('admin.insurancerule.add')->with('result', $result)->with('insurance_type', $insurance_type);
|
||||
}
|
||||
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$existing_number = $request->get('existing_number', '');
|
||||
$amount = $request->get('amount', '');
|
||||
$place_an_order_max = $request->get('place_an_order_max', '');
|
||||
$insurance_type_id = $request->get('insurance_type_id', '');
|
||||
|
||||
if (empty($id)) {
|
||||
$result = new InsuranceRule();
|
||||
} else {
|
||||
$result = InsuranceRule::find($id);
|
||||
if ($result == null) {
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
$result->insurance_type_id = $insurance_type_id;
|
||||
$result->amount = $amount;
|
||||
$result->place_an_order_max = $place_an_order_max;
|
||||
$result->existing_number = $existing_number;
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$result->save(); //保存币种
|
||||
DB::commit();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$result = new InsuranceRule();
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
public function del(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$result = InsuranceRule::find($id);
|
||||
if (empty($result)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
try {
|
||||
$result->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
use App\AccountLog;
|
||||
use App\Users;
|
||||
use App\Setting;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class InviteController extends Controller{
|
||||
|
||||
|
||||
|
||||
//邀请返佣
|
||||
public function return(){
|
||||
return view("admin.invite.return");
|
||||
}
|
||||
|
||||
public function returnList(Request $request){
|
||||
$limit = $request->get('limit',10);
|
||||
$account = $request->get('account','');
|
||||
|
||||
$list = New AccountLog();
|
||||
|
||||
if (!empty($account)) {
|
||||
$list = $list->whereHas('user', function($query) use ($account) {
|
||||
$query->where("phone",'like','%'.$account.'%')->orwhere('email','like','%'.$account.'%');
|
||||
} );
|
||||
}
|
||||
|
||||
$list = $list->where('type', AccountLog::INVITATION_TO_RETURN)-> orderBy('id','desc')->paginate($limit);
|
||||
return response()->json(['code' => 0, 'data' => $list->items(), 'count' => $list->total()]);
|
||||
}
|
||||
|
||||
public function del(Request $request){
|
||||
$id = $request->get('id');
|
||||
$accountlog = AccountLog::find($id);
|
||||
if(empty($accountlog)){
|
||||
$this->error("记录未找到");
|
||||
}
|
||||
|
||||
try {
|
||||
$accountlog->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $ex) {
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//会员推荐关系图
|
||||
public function childs(){
|
||||
|
||||
return view("admin.invite.childs");
|
||||
}
|
||||
|
||||
|
||||
public function getTree()
|
||||
{
|
||||
|
||||
|
||||
$data = Users::orderBy('id','asc')->get()->toArray();
|
||||
$list=$this->getSubTree($data);
|
||||
|
||||
return response()->json(['code' => 0, 'data' => $list]);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getSubTree($data, $id = 0, $level = 0)
|
||||
{
|
||||
$list = array();
|
||||
foreach ($data as $key => $value) {
|
||||
$val=[];
|
||||
$val['parent_id'] = strval($value['parent_id']);
|
||||
if ($val['parent_id'] == $id) {
|
||||
$val['id'] = $value['id'];
|
||||
$val['name'] = $value['account_number'];
|
||||
$val['level'] = $level;
|
||||
$val['children'] =self::getSubTree($data, $value['id'], $level + 1);
|
||||
|
||||
$list[] = $val;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
//邀请背景图
|
||||
public function bgIndex(){
|
||||
return view("admin.invite.bgIndex");
|
||||
}
|
||||
|
||||
public function bgList(Request $request){
|
||||
$limit = $request->get('limit',10);
|
||||
|
||||
$list = New InviteBg();
|
||||
|
||||
$list = $list->orderBy('id','desc')->paginate($limit);
|
||||
return response()->json(['code' => 0, 'data' => $list->items(), 'count' => $list->total()]);
|
||||
}
|
||||
|
||||
public function bgdel(Request $request){
|
||||
$id = $request->get('id');
|
||||
$bg = InviteBg::find($id);
|
||||
if(empty($bg)){
|
||||
$this->error("图片未找到");
|
||||
}
|
||||
|
||||
try {
|
||||
$bg->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $ex) {
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function edit(Request $request){
|
||||
|
||||
$id = $request->get('id',0);
|
||||
if (empty($id)){
|
||||
$bg=New InviteBg();
|
||||
$bg->create_time=time();
|
||||
}else{
|
||||
$bg = InviteBg::find($id);
|
||||
}
|
||||
|
||||
return view('admin.invite.edit',['res'=>$bg]);
|
||||
}
|
||||
|
||||
public function doedit(){
|
||||
$id = Input::get("id");
|
||||
$pic= Input::get("pic");
|
||||
if(empty($pic)){
|
||||
return $this->error('图片必须上传');
|
||||
}
|
||||
if (empty($id)){
|
||||
$bg=New InviteBg();
|
||||
$bg->create_time=time();
|
||||
}else{
|
||||
$bg = InviteBg::find($id);
|
||||
}
|
||||
$bg->pic=$pic;
|
||||
try {
|
||||
$bg->save();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $ex) {
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function share(){
|
||||
$share_title = Setting::getValueByKey('share_title','');
|
||||
$share_content = Setting::getValueByKey('share_content','');
|
||||
$share_url = Setting::getValueByKey('share_url','');
|
||||
|
||||
return view('admin.invite.share',['title'=>$share_title,'content'=>$share_content,'url'=>$share_url]);
|
||||
|
||||
}
|
||||
|
||||
public function postShare(Request $request){
|
||||
$title = Input::get("share_title");
|
||||
$content= Input::get("share_content");
|
||||
$url= Input::get("share_url");
|
||||
|
||||
if(empty($title) || empty($content) || empty($url)){
|
||||
return $this->error('请填写完整信息');
|
||||
|
||||
}
|
||||
$data = $request->all();
|
||||
|
||||
try {
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
Setting::updateValueByKey($key,$value);
|
||||
}
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getTopUsers(Request $request)
|
||||
{
|
||||
$page = $request->get('page',1);
|
||||
$limit = $request->get('limit',10);
|
||||
|
||||
|
||||
$lists = DB::table('users')
|
||||
->where('parent_id',0)
|
||||
->select('id','account_number','parent_id')
|
||||
->paginate($limit);
|
||||
foreach ($lists->items() as &$item) {
|
||||
$item->hasChildren = false;
|
||||
$count = DB::table('users')->where('parent_id',$item->id)->count();
|
||||
if ($count > 0){
|
||||
$item->hasChildren = true;
|
||||
}
|
||||
}
|
||||
unset($item);
|
||||
|
||||
$result = array('data' => $lists->items(), 'page' => $page, 'pages' => $lists->lastPage(), 'total' => $lists->total());
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
public function getSonByPid(Request $request)
|
||||
{
|
||||
$pid = $request->get('pid');
|
||||
|
||||
|
||||
$lists = DB::table('users')
|
||||
->where('parent_id',$pid)
|
||||
->select('id','account_number','parent_id')
|
||||
->get();
|
||||
foreach ($lists as &$item) {
|
||||
$item->hasChildren = false;
|
||||
$count = DB::table('users')->where('parent_id',$item->id)->count();
|
||||
if ($count > 0){
|
||||
$item->hasChildren = true;
|
||||
}
|
||||
}
|
||||
unset($item);
|
||||
|
||||
return $this->success($lists);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,380 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
use App\UsersWallet;
|
||||
use App\AccountLog;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\LegalDealSend;
|
||||
use Illuminate\Http\Request;
|
||||
use App\LegalDeal;
|
||||
use App\Currency;
|
||||
use App\Seller;
|
||||
use App\Users;
|
||||
|
||||
class LegalDealController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
$currency = Currency::where('is_legal', 1)->orderBy('id', 'desc')->get();//获取法币
|
||||
|
||||
|
||||
$start =strtotime(date('Y-m-d 00:00:00'));
|
||||
$end = strtotime(date('Y-m-d H:i:s'));
|
||||
|
||||
//获取当天购买USDT
|
||||
$aaaa=LegalDeal::leftJoin("legal_deal_send","legal_deal.legal_deal_send_id","=","legal_deal_send.id")->where("legal_deal_send.type","=","sell")->where("legal_deal.create_time",">",$start)->where("legal_deal.is_sure","=",1)->select("legal_deal.*","legal_deal_send.type")->get();
|
||||
$todaybuy_usdt=0;
|
||||
foreach($aaaa as $key=>$value)
|
||||
{
|
||||
$todaybuy_usdt=$todaybuy_usdt+$value->number;
|
||||
}
|
||||
|
||||
//获取当天出售USDT
|
||||
$bbbb=LegalDeal::leftJoin("legal_deal_send","legal_deal.legal_deal_send_id","=","legal_deal_send.id")->where("legal_deal_send.type","=","buy")->where("legal_deal.create_time",">",$start)->where("legal_deal.is_sure","=",1)->select("legal_deal.*","legal_deal_send.type")->get();
|
||||
$todaysell_usdt=0;
|
||||
foreach($bbbb as $key=>$value)
|
||||
{
|
||||
$todaysell_usdt=$todaysell_usdt+$value->number;
|
||||
}
|
||||
|
||||
//USDT购买总数
|
||||
$cccc=LegalDeal::leftJoin("legal_deal_send","legal_deal.legal_deal_send_id","=","legal_deal_send.id")->where("legal_deal_send.type","=","sell")->where("legal_deal.is_sure","=",1)->select("legal_deal.*","legal_deal_send.type")->get();
|
||||
$buyall_usdt=0;
|
||||
foreach($cccc as $key=>$value)
|
||||
{
|
||||
$buyall_usdt=$buyall_usdt+$value->number;
|
||||
}
|
||||
|
||||
//USDT出售总数
|
||||
$dddd=LegalDeal::leftJoin("legal_deal_send","legal_deal.legal_deal_send_id","=","legal_deal_send.id")->where("legal_deal_send.type","=","buy")->where("legal_deal.is_sure","=",1)->select("legal_deal.*","legal_deal_send.type")->get();
|
||||
$sellall_usdt=0;
|
||||
foreach($dddd as $key=>$value)
|
||||
{
|
||||
$sellall_usdt=$sellall_usdt+$value->number;
|
||||
}
|
||||
|
||||
//usdt总冻结数量
|
||||
$eeee=UsersWallet::leftjoin("currency","users_wallet.currency","=","currency.id")->where("currency.name","=","USDC")->select("users_wallet.*","currency.name")->get();
|
||||
$all_lock_legal_balance=0;
|
||||
foreach($eeee as $key=>$value)
|
||||
{
|
||||
$all_lock_legal_balance=$all_lock_legal_balance+$value->lock_legal_balance;
|
||||
}
|
||||
|
||||
|
||||
//usdt总可用余额
|
||||
$ffff=UsersWallet::leftjoin("currency","users_wallet.currency","=","currency.id")->where("currency.name","=","USDC")->select("users_wallet.*","currency.name")->get();
|
||||
$all_usdt_can_use=0;
|
||||
foreach($ffff as $key=>$value)
|
||||
{
|
||||
$all_usdt_can_use=$all_usdt_can_use+$value->legal_balance;
|
||||
}
|
||||
|
||||
return view('admin.legal.deal', ['currency' => $currency,'todaybuy_usdt'=>$todaybuy_usdt,'todaysell_usdt'=>$todaysell_usdt,'buyall_usdt'=>$buyall_usdt,'sellall_usdt'=>$sellall_usdt,'all_lock_legal_balance'=>$all_lock_legal_balance,'all_usdt_can_use'=>$all_usdt_can_use]);
|
||||
}
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$account_number = $request->get('account_number', '');
|
||||
$seller_name = $request->get('seller_name', '');
|
||||
$type = $request->get('type', '');
|
||||
$currency_id = $request->get('currency_id', 0);
|
||||
$result = new LegalDeal();
|
||||
if (!empty($account_number)) {
|
||||
$result = $result->whereHas('user', function ($query) use ($account_number) {
|
||||
$query->where('account_number', 'like', '%' . $account_number . '%');
|
||||
});
|
||||
}
|
||||
if (!empty($seller_name))
|
||||
{
|
||||
$result = $result->whereHas('seller', function ($query) use ($seller_name) {
|
||||
$query->where('name', 'like', '%' . $seller_name . '%');
|
||||
});
|
||||
// var_dump($seller_name);die;
|
||||
}
|
||||
|
||||
if (!empty($type)) {
|
||||
$result = $result->whereHas('legalDealSend', function ($query) use ($type) {
|
||||
$query->where('type', $type);
|
||||
});
|
||||
|
||||
}
|
||||
if (!empty($currency_id)) {
|
||||
$result = $result->whereHas('legalDealSend', function ($query) use ($currency_id) {
|
||||
$query->where('currency_id', $currency_id);
|
||||
});
|
||||
}
|
||||
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
//var_dump($result->toArray());die;
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 后台取消订单
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function adminLegalDealCancel(Request $request) //tian add
|
||||
{
|
||||
$id = $request->get('id', null);
|
||||
if (empty($id)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$legal_deal = LegalDeal::find($id);
|
||||
if (empty($legal_deal)) {
|
||||
return $this->error('无此记录');
|
||||
}
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
// if ($legal_deal->is_sure > 0) {
|
||||
// DB::rollback();
|
||||
// return $this->error('该订单已操作,请勿取消666');
|
||||
// }
|
||||
$user_id = Users::getUserId();
|
||||
// if ($legal_deal->type == 'sell') { //用户端-购买
|
||||
// if ($user_id != $legal_deal->user_id) {
|
||||
// DB::rollback();
|
||||
// return $this->error('对不起,您无权操作');
|
||||
// }
|
||||
// } elseif ($legal_deal->type == 'buy') {//用户端出售
|
||||
// $seller = Seller::find($legal_deal->seller_id);
|
||||
// if ($user_id == $legal_deal->user_id) {
|
||||
// DB::rollback();
|
||||
// return $this->error('对不起,您无权操作');
|
||||
// }
|
||||
// }
|
||||
// $number = $legal_deal->number;
|
||||
// $legal_deal_send = LegalDealSend::LockForUpdate()->find($legal_deal->legal_deal_send_id);
|
||||
// $users_wallet = UsersWallet::where('user_id', $user_id)->where('currency', $legal_deal_send->currency_id)->first();
|
||||
// if ($legal_deal_send->type == 'buy') { //求购
|
||||
// // do something
|
||||
//// if ($users_wallet->legal_balance < $number){
|
||||
//// DB::rollback();
|
||||
//// return $this->error('您的法币余额不足');
|
||||
//// }
|
||||
//// $legal_deal_send->surplus_number += $legal_deal->number;//
|
||||
// $legal_deal_send->surplus_number = bc_add($legal_deal_send->surplus_number,$legal_deal->number,5);//
|
||||
// if ($legal_deal_send->surplus_number > 0) {
|
||||
// $legal_deal_send->is_done = 0;
|
||||
// }
|
||||
// $data_wallet1 = [
|
||||
// 'balance_type' => 1,
|
||||
// 'wallet_id' => $users_wallet->id,
|
||||
// 'lock_type' => 0,
|
||||
// 'create_time' => time(),
|
||||
// 'before' => $users_wallet->legal_balance,
|
||||
// 'change' => $legal_deal->number,
|
||||
// 'after' => bc_add($users_wallet->legal_balance, $legal_deal->number, 5),
|
||||
// ];
|
||||
// $data_wallet2 = [
|
||||
// 'balance_type' => 1,
|
||||
// 'wallet_id' => $users_wallet->id,
|
||||
// 'lock_type' => 1,
|
||||
// 'create_time' => time(),
|
||||
// 'before' => $users_wallet->lock_legal_balance,
|
||||
// 'change' => -$legal_deal->number,
|
||||
// 'after' => bc_sub($users_wallet->legal_balance, $legal_deal->number, 5),
|
||||
// ];
|
||||
//// $users_wallet->legal_balance += $legal_deal->number;
|
||||
// $users_wallet->legal_balance = bc_add($users_wallet->legal_balance,$legal_deal->number,5);
|
||||
//// $users_wallet->lock_legal_balance -= $legal_deal->number;
|
||||
// $users_wallet->lock_legal_balance = bc_sub($users_wallet->lock_legal_balance,$legal_deal->number,5);
|
||||
// $users_wallet->save();
|
||||
// $legal_deal_send->save();
|
||||
//
|
||||
// AccountLog::insertLog(
|
||||
// [
|
||||
// 'user_id' => $user_id,
|
||||
// 'value' => $legal_deal->number,
|
||||
// 'info' => '取消出售给商家法币',
|
||||
// 'type' => AccountLog::LEGAL_DEAL_USER_SELL_CANCEL,
|
||||
// 'currency' => $legal_deal_send->currency_id
|
||||
// ],
|
||||
// $data_wallet1
|
||||
// );
|
||||
// AccountLog::insertLog(
|
||||
// [
|
||||
// 'user_id' => $user_id,
|
||||
// 'value' => -$legal_deal->number,
|
||||
// 'info' => '取消出售给商家法币',
|
||||
// 'type' => AccountLog::LEGAL_DEAL_USER_SELL_CANCEL,
|
||||
// 'currency' => $legal_deal_send->currency_id
|
||||
// ],
|
||||
// $data_wallet2
|
||||
// );
|
||||
// } elseif ($legal_deal_send->type == 'sell') { //出售
|
||||
//// $legal_deal_send->surplus_number += $legal_deal->number;
|
||||
// $legal_deal_send->surplus_number = bc_add($legal_deal_send->surplus_number,$legal_deal->number,5);
|
||||
// if ($legal_deal_send->surplus_number > 0) {
|
||||
// $legal_deal_send->is_done = 0;
|
||||
// }
|
||||
// $legal_deal_send->save();
|
||||
// }
|
||||
// $legal_deal->is_sure = 2;
|
||||
// $legal_deal->save();
|
||||
// $legal_deal->update_time = time();
|
||||
// $legal_send = LegalDealSend::find($legal_deal->legal_deal_send_id);
|
||||
// $legal_send->surplus_number += $legal_deal->number;
|
||||
// $legal_send->save();
|
||||
LegalDeal::cancelLegalDealById($id);
|
||||
DB::commit();
|
||||
return $this->success('操作成功,订单已取消');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollback();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//后台确认收到付款,订单状态改为完成
|
||||
//商家卖法币(后台确定,将币拨到用户)
|
||||
public function adminDoSure(Request $request)
|
||||
{
|
||||
$id = $request->get('id', null);
|
||||
if (empty($id)) return $this->error('参数错误');
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$legal_deal = LegalDeal::find($id);
|
||||
if (empty($legal_deal)) {
|
||||
DB::rollback();
|
||||
return $this->error('无此记录');
|
||||
}
|
||||
if ($legal_deal->is_sure == 1) {
|
||||
DB::rollback();
|
||||
return $this->error('该订单还未付款或已经操作过');
|
||||
}
|
||||
$seller = Seller::lockForUpdate()->find($legal_deal->seller_id);
|
||||
|
||||
$legal_send = LegalDealSend::find($legal_deal->legal_deal_send_id);
|
||||
if (empty($legal_send)) {
|
||||
DB::rollback();
|
||||
return $this->error('订单异常');
|
||||
}
|
||||
// if ($legal_send->type == 'buy') {
|
||||
// DB::rollback();
|
||||
// return $this->error('您不能确认该订单');
|
||||
// }
|
||||
$user_wallet = UsersWallet::where('user_id', $legal_deal->user_id)
|
||||
->where('currency', $legal_send->currency_id)
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
$seller_user_wallet = UsersWallet::where('user_id', $seller->user_id)
|
||||
->where('currency', $legal_send->currency_id)
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
if (empty($user_wallet)) {
|
||||
DB::rollback();
|
||||
return $this->error('该用户没有此币种钱包');
|
||||
}
|
||||
|
||||
//更新交易状态
|
||||
$legal_deal->is_sure = 1;
|
||||
$legal_deal->update_time = time();
|
||||
$legal_deal->save();
|
||||
|
||||
//减少商家法币锁定余额
|
||||
|
||||
$seller->lock_seller_balance = bc_sub($seller->lock_seller_balance,$legal_deal->number,5);
|
||||
change_wallet_balance($seller_user_wallet, 1,-$legal_deal->number,AccountLog::LEGAL_USER_BUY,"用户购买商家法币,解除商家法币冻结", true);
|
||||
|
||||
//增加用户法币余额
|
||||
change_wallet_balance($user_wallet, 1,$legal_deal->number,AccountLog::LEGAL_USER_BUY,'在 ' . $seller->name . ' 购买法币成功');
|
||||
|
||||
|
||||
$seller->save();
|
||||
|
||||
DB::commit();
|
||||
return $this->success('确认成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollback();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//商家购买用户法币(后台确定,将币拨到商家)
|
||||
public function admin_userDoSure(Request $request) //用户确认收款 后台确认
|
||||
{
|
||||
$id = $request->get('id', null);
|
||||
if (empty($id)) return $this->error('参数错误');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$legal_deal = LegalDeal::find($id);
|
||||
if (empty($legal_deal)) {
|
||||
DB::rollback();
|
||||
return $this->error('无此记录');
|
||||
}
|
||||
if ($legal_deal->is_sure != 3) {
|
||||
DB::rollback();
|
||||
return $this->error('该订单还未付款或已经操作过');
|
||||
}
|
||||
if ($legal_deal->is_sure == 1) {
|
||||
DB::rollback();
|
||||
return $this->error('该订单已经操作过');
|
||||
}
|
||||
|
||||
$user_id = Users::getUserId();
|
||||
$user = Users::find($user_id);
|
||||
// if ($legal_deal->user_id != $user_id) {
|
||||
// DB::rollback();
|
||||
// return $this->error('对不起,您无权操作');
|
||||
// }
|
||||
$legal_send = LegalDealSend::find($legal_deal->legal_deal_send_id);
|
||||
if (empty($legal_send)) {
|
||||
DB::rollback();
|
||||
return $this->error('订单异常');
|
||||
}
|
||||
// if ($legal_send->type == 'sell') {
|
||||
// DB::rollback();
|
||||
// return $this->error('您不能确认该订单');
|
||||
// }
|
||||
$seller = Seller::find($legal_deal->seller_id);
|
||||
$user_wallet = UsersWallet::where('user_id', $legal_deal->user_id)
|
||||
->where('currency', $legal_send->currency_id)
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
|
||||
$seller_user_wallet = UsersWallet::where('user_id', $seller->user_id)
|
||||
->where('currency', $legal_send->currency_id)
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
if (empty($user_wallet)) {
|
||||
DB::rollback();
|
||||
return $this->error('该用户没有此币种钱包');
|
||||
}
|
||||
|
||||
if (empty($seller)) {
|
||||
DB::rollback();
|
||||
return $this->error('商家不存在');
|
||||
}
|
||||
|
||||
//更新交易状态
|
||||
$legal_deal->is_sure = 1;
|
||||
$legal_deal->update_time = time();
|
||||
$legal_deal->save();
|
||||
|
||||
//减少用户法币锁定余额
|
||||
|
||||
change_wallet_balance($user_wallet, 1,-$legal_deal->number,AccountLog::LEGAL_SELLER_BUY,'卖币成功',true);
|
||||
|
||||
//增加商家法币余额
|
||||
change_wallet_balance($seller_user_wallet, 1,$legal_deal->number,AccountLog::LEGAL_SELLER_BUY,"商家购买用户法币,增加商家法币");
|
||||
|
||||
DB::commit();
|
||||
return $this->success('确认成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollback();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\LegalDeal;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use App\LegalDealSend;
|
||||
use App\Currency;
|
||||
|
||||
class LegalDealSendController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
|
||||
$currency = Currency::where('is_legal',1)->orderBy('id','desc')->get();//获取法币
|
||||
return view('admin.legal.index',['currency'=> $currency]);
|
||||
}
|
||||
public function list(Request $request){
|
||||
$limit = $request->get('limit', 10);
|
||||
//$account_number = $request->get('account_number', '');
|
||||
$seller_name = $request->get('seller_name', '');
|
||||
$type = $request->get('type', '');
|
||||
$currency_id = $request->get('currency_id', 0);
|
||||
$result = new LegalDealSend();
|
||||
|
||||
if(!empty($seller_name)){
|
||||
|
||||
$result = $result->whereHas('seller', function ($query) use ($seller_name) {
|
||||
$query->where('name', 'like', '%' . $seller_name . '%');
|
||||
});
|
||||
}
|
||||
|
||||
if (!empty($type)) {
|
||||
|
||||
$result = $result->where('type', $type);
|
||||
}
|
||||
if (!empty($currency_id)) {
|
||||
|
||||
$result = $result->where('currency_id', $currency_id);
|
||||
}
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\Process\Process;
|
||||
use App\Admin;
|
||||
use App\Users;
|
||||
use App\Currency;
|
||||
use App\UsersWallet;
|
||||
use App\AccountLog;
|
||||
use App\UserJiedai;
|
||||
use App\Defi;
|
||||
use App\DefiOrder;
|
||||
use App\DualCurrency;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LendingController extends Controller
|
||||
{
|
||||
private $Month_E = array('01' => "Jan",
|
||||
'02' => "Feb",
|
||||
'03' => "Mar",
|
||||
'04' => "Apr",
|
||||
'05' => "May",
|
||||
'06' => "Jun",
|
||||
'07' => "Jul",
|
||||
'08' => "Aug",
|
||||
'09' => "Sep",
|
||||
'10' => "Oct",
|
||||
'11' => "Nov",
|
||||
'12' => "Dec");
|
||||
|
||||
public function index(){
|
||||
|
||||
return view('admin.lending.index');
|
||||
}
|
||||
|
||||
public function order(){
|
||||
|
||||
|
||||
return view('admin.lending.order');
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function order_lists(Request $request){
|
||||
|
||||
$limit = $request->get('limit', 20);
|
||||
$htcode = $request->get('htcode');
|
||||
$user_id = $request->get('user_id');
|
||||
|
||||
$list = DB::table('defi_order');
|
||||
|
||||
if (!empty($htcode)) {
|
||||
$list = $list->where('htcode',$htcode);
|
||||
}
|
||||
|
||||
if($user_id){
|
||||
$list->where('user_id',$user_id);
|
||||
}
|
||||
|
||||
$list = $list->orderBy('id', 'desc')->paginate($limit);
|
||||
file_put_contents('/www/wwwroot/crypto/public/t.txt',json_encode($list));
|
||||
|
||||
foreach ($list as $v){
|
||||
// $v->create_time = date('Y-m-d H:i:s',$v->create_time);
|
||||
}
|
||||
|
||||
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function add(){
|
||||
return view('admin.lending.add');
|
||||
}
|
||||
|
||||
|
||||
public function editLendingView(Request $request){
|
||||
$id = $request->get('id');
|
||||
if(empty($id)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$dual_currency = DB::table('defi')->where(['id'=>$id])->first();
|
||||
// dump($dual_currency);die;
|
||||
return view('admin.lending.edit_lending',['results' => $dual_currency]);
|
||||
}
|
||||
|
||||
//删除项目
|
||||
public function del(Request $request){
|
||||
$id = $request->post('id');
|
||||
|
||||
// file_put_contents('/www/wwwroot/xb-dex/public/d.txt',time().$id.PHP_EOL,FILE_APPEND);
|
||||
$Zhiya_lk = Defi::where('id',$id)->first();//->get();
|
||||
|
||||
|
||||
if(empty($Zhiya_lk)){
|
||||
return $this->error('不存在');
|
||||
}
|
||||
|
||||
if($id){
|
||||
//whereNotIn
|
||||
|
||||
DB::table('defi')->where('id', $id)->delete();
|
||||
|
||||
return $this->success('操作成功');
|
||||
}else{
|
||||
|
||||
return $this->error('失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//编辑项目
|
||||
public function editLending(Request $request){
|
||||
$id = $request->post('id');
|
||||
// $title = $request->post('title');
|
||||
$days = $request->post('days');
|
||||
// $hk_type = $request->post('hk_type');
|
||||
//$amount = $request->post('amount');
|
||||
// $amax = $request->post('amax');
|
||||
$bilv = $request->post('bilv');
|
||||
$percent = $request->post('percent');
|
||||
$opaymentlv = $request->post('opaymentlv');
|
||||
$fwamount = $request->post('fwamount');
|
||||
if(empty($id)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$dual_currency = Defi::where(['id'=>$id])->first();
|
||||
|
||||
if($bilv >100){
|
||||
return $this->error('利率有误');
|
||||
}
|
||||
// $dual_currency->title = $title;
|
||||
$dual_currency->days = $days;
|
||||
// $dual_currency->amount = $amount;
|
||||
// $dual_currency->amax = $amax;
|
||||
// $dual_currency->hk_type = $hk_type;
|
||||
$dual_currency->bilv = $bilv;
|
||||
$dual_currency->percent = $percent;
|
||||
$dual_currency->fwamount = $fwamount;
|
||||
$dual_currency->opaymentlv = $opaymentlv;
|
||||
$dual_currency->save();
|
||||
|
||||
|
||||
return $this->success(['data'=>$dual_currency]);
|
||||
}
|
||||
|
||||
//新增项目
|
||||
public function saveLending(Request $request){
|
||||
$data = $request->all();
|
||||
|
||||
// $amount = $data['amount'];
|
||||
// $title = $data['title'];
|
||||
$days = $data['days'];
|
||||
$bilv = $data['bilv'];
|
||||
$percent = $data['percent'];
|
||||
$opaymentlv = $data['opaymentlv'];
|
||||
$fwamount = $data['fwamount'];
|
||||
// $hk_type = $data['hk_type'];
|
||||
if($days && $bilv){
|
||||
if($bilv >= 100){
|
||||
return $this->error('利率不能大于100%');
|
||||
}
|
||||
|
||||
$dual_currency = new Defi();
|
||||
|
||||
// $dual_currency->amount = $amount;
|
||||
// $dual_currency->title = $title;
|
||||
$dual_currency->days = $days;
|
||||
$dual_currency->bilv = $bilv;
|
||||
$dual_currency->percent = $percent;
|
||||
$dual_currency->fwamount = $fwamount;
|
||||
$dual_currency->opaymentlv = $opaymentlv;
|
||||
// $dual_currency->hk_type = $hk_type;
|
||||
$dual_currency->status = 1;
|
||||
$dual_currency->type = 1;
|
||||
$dual_currency->addtime = date("Y-m-d H:i:s",time());
|
||||
|
||||
|
||||
$dual_currency->save();
|
||||
|
||||
return $this->success('操作成功');
|
||||
}else{
|
||||
|
||||
return $this->error('必填项不能为空');
|
||||
}
|
||||
}
|
||||
|
||||
//获取实时价格
|
||||
public function getNewPrice(Request $request){
|
||||
$currency = $request->get('currency');
|
||||
$currencys = Currency::where('id',$currency)->get()->toArray();
|
||||
|
||||
return $this->success(['data'=>$currencys]);
|
||||
}
|
||||
|
||||
//理财设置
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 20);
|
||||
$status = $request->get('status');
|
||||
|
||||
// $results = DualCurrency::where('id','>',1);
|
||||
|
||||
$results =DB::table('defi');//->orderBy('id', 'asc')->paginate($limit); lk_zhiya
|
||||
|
||||
if(isset($status)){
|
||||
$results->where('status',$status);
|
||||
}
|
||||
|
||||
// dump($results);die;
|
||||
$results = $results->orderBy('id', 'desc')->orderBy('status','desc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($results);
|
||||
}
|
||||
|
||||
public function show(Request $request)
|
||||
{
|
||||
$id = $request->get('id', '');
|
||||
if (!$id) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$walletout = DefiOrder::find($id);
|
||||
|
||||
// $use_chain_api = Setting::getValueByKey('use_chain_api', 0);
|
||||
return view('admin.lending.edit', ['wallet_out' => $walletout]);
|
||||
|
||||
}
|
||||
|
||||
//test
|
||||
public function done(Request $request)
|
||||
{
|
||||
set_time_limit(0);
|
||||
$id = $request->post('id', '');
|
||||
$user_id = $request->post('user_id', 0);
|
||||
$amount = $request->post('amount', 0);
|
||||
$method = $request->get('method', '');
|
||||
|
||||
if (!$id || !$user_id) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$wallet_out = DefiOrder::where('review_status', 1)->lockForUpdate()->findOrFail($id);
|
||||
|
||||
|
||||
|
||||
$user_wallet = UsersWallet::where('user_id', $user_id)->where('currency', 3)->lockForUpdate()->first(); //lockForUpdate()->
|
||||
|
||||
if ($method == 'done') {//确认提币
|
||||
|
||||
$wallet_out->review_status = 2;//提币成功状态
|
||||
$wallet_out->status = 0;//反馈的信息
|
||||
|
||||
$wallet_out->review_time = date('Y-m-d H:i:s',time()+$wallet_out->days*24*60*60);
|
||||
$wallet_out->save();
|
||||
$change_result = change_wallet_balance($user_wallet, 2, $amount, AccountLog::USER_LOAN_ORDER_BUY, '借贷放款成功');
|
||||
|
||||
if ($change_result !== true) {
|
||||
throw new Exception($change_result);
|
||||
}
|
||||
} else {
|
||||
$wallet_out->review_status = 3;//提币失败状态
|
||||
|
||||
|
||||
$wallet_out->review_time = date('Y-m-d H:i:s',time());
|
||||
|
||||
$wallet_out->save();
|
||||
|
||||
}
|
||||
DB::commit();
|
||||
return $this->success('操作成功:)');
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//test
|
||||
public function cancle(Request $request)
|
||||
{
|
||||
set_time_limit(0);
|
||||
$id = $request->post('id', '');
|
||||
|
||||
|
||||
if (!$id) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$wallet_out = DefiOrder::where('review_status', 1)->lockForUpdate()->findOrFail($id);
|
||||
|
||||
|
||||
|
||||
|
||||
$wallet_out->review_status = 3;//提币失败状态
|
||||
|
||||
|
||||
$wallet_out->review_time = time();
|
||||
|
||||
$wallet_out->save();
|
||||
|
||||
|
||||
DB::commit();
|
||||
return $this->success('操作成功:)');
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Algebra;
|
||||
use App\Level;
|
||||
use App\UserAlgebra;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\Process\Process;
|
||||
use App\MicroNumber;
|
||||
use App\MicroOrder;
|
||||
use App\MicroSecond;
|
||||
use App\Currency;
|
||||
use App\CurrencyMatch;
|
||||
use App\Setting;
|
||||
use App\UsersWallet;
|
||||
use App\Users;
|
||||
|
||||
class LevelController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('admin.level.index');
|
||||
}
|
||||
|
||||
public function add(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
if (empty($id)) {
|
||||
$result = new Level();
|
||||
} else {
|
||||
$result = Level::find($id);
|
||||
}
|
||||
|
||||
return view('admin.level.add')->with('result', $result);
|
||||
}
|
||||
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$id = $request->get('id', 0);
|
||||
$name = $request->get('name', '');
|
||||
$fill_currency = $request->get('fill_currency', '');
|
||||
$direct_drive_price = $request->get('direct_drive_price', '');
|
||||
$direct_drive_count = $request->get('direct_drive_count', '');
|
||||
$max_algebra = $request->get('max_algebra', '');
|
||||
$level = $request->get('level', '');
|
||||
if (empty($id)) {
|
||||
$levelModel = new Level();
|
||||
} else {
|
||||
$levelModel = Level::find($id);
|
||||
if ($levelModel == null) {
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
$levelModel->name = $name;
|
||||
$levelModel->fill_currency = $fill_currency;
|
||||
$levelModel->direct_drive_price = $direct_drive_price;
|
||||
$levelModel->direct_drive_count = $direct_drive_count;
|
||||
$levelModel->max_algebra = $max_algebra;
|
||||
$levelModel->level = $level;
|
||||
|
||||
$levelModel->save(); //保存币种
|
||||
DB::commit();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$result = new Level();
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
public function del(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$result = Level::find($id);
|
||||
if (empty($result)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
try {
|
||||
$result->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//micro_seconds
|
||||
|
||||
public function algebraIndex()
|
||||
{
|
||||
return view('admin.level.algebra_index');
|
||||
}
|
||||
|
||||
public function algebraAdd(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
if (empty($id)) {
|
||||
$result = new Algebra();
|
||||
} else {
|
||||
$result = Algebra::find($id);
|
||||
}
|
||||
// $currencies = Currency::where('is_micro',1)->get();
|
||||
|
||||
return view('admin.level.algebra_add')->with('result', $result);
|
||||
}
|
||||
|
||||
public function algebraPostAdd(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$name = $request->get('name', '');
|
||||
$algebra = $request->get('algebra', '');
|
||||
$rate = $request->get('rate', '');
|
||||
|
||||
if (empty($id)) {
|
||||
$result = new Algebra();
|
||||
} else {
|
||||
$result = Algebra::find($id);
|
||||
if ($result == null) {
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
$result->name = $name;
|
||||
$result->algebra = $algebra;
|
||||
$result->rate = $rate;
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$result->save(); //保存币种
|
||||
DB::commit();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function algebraLists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$result = new Algebra();
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
public function algebraDel(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$result = Algebra::find($id);
|
||||
if (empty($result)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
try {
|
||||
$result->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function levelOrderIndex(){
|
||||
|
||||
return view('admin.level.orders');
|
||||
}
|
||||
|
||||
public function levelOrderList(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$ent_time=$request->get('end_time','');
|
||||
$start_time=$request->get('start_time','');
|
||||
$account=$request->get('account','');
|
||||
$result = new UserAlgebra();
|
||||
$result = $result->where(function ($query) use ($ent_time,$start_time,$account){
|
||||
|
||||
if (!empty($ent_time)){
|
||||
$query->where('created_at','<=',$ent_time);
|
||||
}
|
||||
|
||||
if (!empty($start_time)){
|
||||
$query->where('created_at','>=',$start_time);
|
||||
}
|
||||
if (!empty($account)){
|
||||
$user=Users::where('phone',$account)->Orwhere('email',$account)->first();
|
||||
if (!empty($account)){
|
||||
$query->where('user_id',$user->id);
|
||||
}
|
||||
}
|
||||
})->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\Process\Process;
|
||||
use App\LeverMultiple;
|
||||
use App\CurrencyMatch;
|
||||
use App\Setting;
|
||||
use App\UsersWallet;
|
||||
use App\Users;
|
||||
use App\Currency;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
|
||||
class LeverMultipleController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
return view('admin.levermultiple.index');
|
||||
}
|
||||
public function add()
|
||||
{
|
||||
$res=Currency::where("name","!=","USDC")->get();
|
||||
return view('admin.levermultiple.add', [
|
||||
'currency' => $res
|
||||
]);
|
||||
}
|
||||
|
||||
public function doadd(Request $request)
|
||||
{
|
||||
|
||||
$aaaaaaa=new LeverMultiple();
|
||||
$aaaaaaa->value= Input::get('value', '');
|
||||
$aaaaaaa->type=Input::get('type', '');
|
||||
$aaaaaaa->currency_id=Input::get('currency_id', '');
|
||||
//var_dump($aaaaaaa);die;
|
||||
try {
|
||||
$aaaaaaa->save();
|
||||
}catch (\Exception $ex){
|
||||
|
||||
}
|
||||
return $this->success('添加成功');
|
||||
}
|
||||
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$name = $request->get('name', '');
|
||||
// $token = $request->get('token','');
|
||||
// $get_address = $request->get('get_address','');
|
||||
$sort = $request->get('sort', 0);
|
||||
$logo = $request->get('logo', '');
|
||||
$type = $request->get('type', '');
|
||||
$is_legal = $request->get('is_legal', '');
|
||||
$is_lever = $request->get('is_lever', '');
|
||||
$is_match = $request->get('is_match', '');
|
||||
$min_number = $request->get('min_number', 0);
|
||||
$rate = $request->get('rate', 0);
|
||||
$total_account = $request->get('total_account', 0);
|
||||
$key = $request->get('key', 0);
|
||||
$contract_address = $request->get('contract_address', 0);
|
||||
//自定义验证错误信息
|
||||
$messages = [
|
||||
'required' => ':attribute 为必填字段',
|
||||
];
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required',
|
||||
'sort' => 'required',
|
||||
'type' => 'required',
|
||||
'is_legal' => 'required',
|
||||
'is_lever' => 'required',
|
||||
|
||||
// 'logo'=>'required',
|
||||
], $messages);
|
||||
|
||||
//如果验证不通过
|
||||
if ($validator->fails()) {
|
||||
return $this->error($validator->errors()->first());
|
||||
}
|
||||
$has = Currency::where('name', $name)->first();
|
||||
if (empty($id) && !empty($has)) {
|
||||
return $this->error($name . ' 已存在');
|
||||
}
|
||||
if (empty($id)) {
|
||||
$currency = new Currency();
|
||||
$currency->create_time = time();
|
||||
} else {
|
||||
$currency = Currency::find($id);
|
||||
}
|
||||
$currency->name = $name;
|
||||
// $acceptor->token = $token;
|
||||
// $acceptor->get_address = $get_address;
|
||||
$currency->sort = intval($sort);
|
||||
$currency->logo = $logo;
|
||||
$currency->is_legal = $is_legal;
|
||||
$currency->is_lever = $is_lever;
|
||||
$currency->is_match = $is_match;
|
||||
$currency->min_number = $min_number;
|
||||
$currency->rate = $rate;
|
||||
$currency->total_account = $total_account;
|
||||
$currency->key = $key;
|
||||
$currency->contract_address = $contract_address;
|
||||
$currency->type = $type;
|
||||
$currency->is_display = 1;
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$currency->save();//保存币种
|
||||
// if(empty($id)){// 如果是添加新币 //没添加一种交易币,就给用户添加一个交易币钱包
|
||||
// $currency_id = Currency::where('name',$name)->first()->id;
|
||||
// $users = Users::all();
|
||||
// foreach ($users as $key => $value) {
|
||||
// $userWallet = new UsersWallet();
|
||||
// $userWallet->user_id = $value->id;
|
||||
// $userWallet->currency = $currency_id;
|
||||
// $userWallet->create_time = time();
|
||||
// $userWallet->save();
|
||||
// }
|
||||
// }
|
||||
DB::commit();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
// $limit = $request->get('limit', 10);
|
||||
// $account_number = $request->get('account_number','');
|
||||
$result = new LeverMultiple();
|
||||
$count=$result::all()->count();
|
||||
$result = $result->orderBy('currency_id','asc')->get()->toArray();
|
||||
// var_dump($result);die;
|
||||
foreach($result as $key=>$value)
|
||||
{
|
||||
if($value['type']==1)
|
||||
{
|
||||
$result[$key]['type']="倍数";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result[$key]['type']="手数";
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(['code' => 0, 'data' => $result, 'count' => $count]);
|
||||
}
|
||||
|
||||
|
||||
public function del()
|
||||
{
|
||||
$admin = LeverMultiple::find(Input::get('id'));
|
||||
if($admin == null) {
|
||||
abort(404);
|
||||
}
|
||||
$bool = $admin->delete();
|
||||
if($bool){
|
||||
return $this->success('删除成功');
|
||||
}else{
|
||||
return $this->error('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit(Request $request){
|
||||
|
||||
$id = $request->get('id',0);
|
||||
if (empty($id)){
|
||||
return $this->error("参数错误");
|
||||
}
|
||||
|
||||
$result = LeverMultiple::find($id);
|
||||
//
|
||||
// $res=UserCashInfo::where('user_id',$id)->first();
|
||||
|
||||
return view('admin.levermultiple.edit',['result'=>$result]);
|
||||
}
|
||||
|
||||
//编辑用户信息
|
||||
public function doedit(){
|
||||
$password = Input::get("value");
|
||||
$id = Input::get("id");
|
||||
if (empty($id)) return $this->error("参数错误");
|
||||
$user = LeverMultiple::find($id);
|
||||
$user->value=$password;
|
||||
if (empty($user)) return $this->error("数据未找到");
|
||||
// DB::beginTransaction();
|
||||
try {
|
||||
|
||||
$aa=$user->save();
|
||||
// var_dump($aa);die;
|
||||
return $this->success('编辑成功');
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 交易对显示
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function match()
|
||||
{
|
||||
return view('admin.currency.match');
|
||||
}
|
||||
|
||||
public function matchList(Request $request)
|
||||
{
|
||||
$legal_id = $request->route('legal_id');
|
||||
$limit = $request->input('limit', 10);
|
||||
$legal = Currency::find($legal_id);
|
||||
$matchs = $legal->quotation()->paginate($limit);
|
||||
return $this->layuiData($matchs);
|
||||
}
|
||||
|
||||
public function addMatch($legal_id)
|
||||
{
|
||||
$is_legal = Currency::where('id', $legal_id)->value('is_legal');
|
||||
if (!$is_legal) {
|
||||
abort(403, '指定币种不是法币,不能添加交易对');
|
||||
}
|
||||
$currencies = Currency::where('id', '<>', $legal_id)->get();
|
||||
$market_from_names = CurrencyMatch::enumMarketFromNames();
|
||||
return view('admin.currency.match_add')->with('currencies', $currencies)
|
||||
->with('market_from_names', $market_from_names);
|
||||
}
|
||||
|
||||
public function postAddMatch(Request $request, $legal_id)
|
||||
{
|
||||
$is_legal = Currency::where('id', $legal_id)->value('is_legal');
|
||||
if (!$is_legal) {
|
||||
return $this->error('指定币种不是法币,不能添加交易对');
|
||||
}
|
||||
$currency_id = $request->input('currency_id');
|
||||
$is_display = $request->input('is_display', 1);
|
||||
$market_from = $request->input('market_from', 0);
|
||||
$open_transaction = $request->input('open_transaction', 0);
|
||||
$open_lever = $request->input('open_lever', 0);
|
||||
$lever_share_num = $request->input('lever_share_num', 1);
|
||||
$spread = $request->input('spread', 0);
|
||||
$overnight = $request->input('overnight', 0);
|
||||
$lever_trade_fee = $request->input('lever_trade_fee', 0);
|
||||
//检测交易对是否已存在
|
||||
$exist = CurrencyMatch::where('currency_id', $currency_id)
|
||||
->where('legal_id', $legal_id)
|
||||
->first();
|
||||
if ($exist) {
|
||||
return $this->error('对应交易对已存在');
|
||||
}
|
||||
CurrencyMatch::unguard();
|
||||
$currency_match = CurrencyMatch::create([
|
||||
'legal_id' => $legal_id,
|
||||
'currency_id' => $currency_id,
|
||||
'is_display' => $is_display,
|
||||
'market_from' => $market_from,
|
||||
'open_transaction' => $open_transaction,
|
||||
'open_lever' => $open_lever,
|
||||
'lever_share_num' => $lever_share_num,
|
||||
'lever_trade_fee' => $lever_trade_fee,
|
||||
'spread' => $spread,
|
||||
'overnight' => $overnight,
|
||||
'create_time' => time(),
|
||||
]);
|
||||
CurrencyMatch::reguard();
|
||||
return isset($currency_match->id) ? $this->success('添加成功') : $this->error('添加失败');
|
||||
}
|
||||
|
||||
public function editMatch($id)
|
||||
{
|
||||
$currency_match = CurrencyMatch::find($id);
|
||||
if (!$currency_match) {
|
||||
abort(403, '指定交易对不存在');
|
||||
}
|
||||
$market_from_names = CurrencyMatch::enumMarketFromNames();
|
||||
$currencies = Currency::where('id', '<>', $currency_match->legal_id)->get();
|
||||
$var = compact('currency_match', 'currencies', 'market_from_names');
|
||||
return view('admin.currency.match_add', $var);
|
||||
}
|
||||
|
||||
public function postEditMatch(Request $request, $id)
|
||||
{
|
||||
$currency_id = $request->input('currency_id');
|
||||
$is_display = $request->input('is_display', 1);
|
||||
$market_from = $request->input('market_from', 0);
|
||||
$open_transaction = $request->input('open_transaction', 0);
|
||||
$open_lever = $request->input('open_lever', 0);
|
||||
$lever_share_num = $request->input('lever_share_num', 1);
|
||||
$spread = $request->input('spread', 0);
|
||||
$overnight = $request->input('overnight', 0);
|
||||
$lever_trade_fee = $request->input('lever_trade_fee', 0);
|
||||
$currency_match = CurrencyMatch::find($id);
|
||||
if (!$currency_match) {
|
||||
abort(403, '指定交易对不存在');
|
||||
}
|
||||
CurrencyMatch::unguard();
|
||||
$result = $currency_match->fill([
|
||||
'currency_id' => $currency_id,
|
||||
'is_display' => $is_display,
|
||||
'market_from' => $market_from,
|
||||
'open_transaction' => $open_transaction,
|
||||
'open_lever' => $open_lever,
|
||||
'lever_share_num' => $lever_share_num,
|
||||
'lever_trade_fee' => $lever_trade_fee,
|
||||
'spread' => $spread,
|
||||
'overnight' => $overnight,
|
||||
'create_time' => time(),
|
||||
])->save();
|
||||
CurrencyMatch::reguard();
|
||||
return $result ? $this->success('保存成功') : $this->error('保存失败');
|
||||
}
|
||||
|
||||
public function delMatch($id)
|
||||
{
|
||||
$result = CurrencyMatch::destroy($id);
|
||||
return $result ? $this->success('删除成功') : $this->error('删除失败');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Currency;
|
||||
use App\LeverTransaction;
|
||||
|
||||
class LeverTransactionController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$currencies = Currency::where('is_legal', 1)->get();
|
||||
return view('admin.lever.hazard.index', [
|
||||
'currencies' => $currencies,
|
||||
]);
|
||||
}
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$limit = $request->input('limit', 10);
|
||||
$legal_id = $request->input('legal_id', 0);
|
||||
$type = $request->input('type', 0);
|
||||
$operate = $request->input('operate', -1);
|
||||
$hazard_rate = $request->input('hazard_rate', 0);
|
||||
$user_hazard = LeverTransaction::where('status', LeverTransaction::TRANSACTION)
|
||||
->where(function ($query) use ($type, $legal_id) {
|
||||
($type != -1 && in_array($type, [1, 2])) && $query->where('type', $type);
|
||||
$legal_id != -1 && $query->where('legal', $legal_id);
|
||||
})
|
||||
->select('user_id')
|
||||
->selectRaw('SUM((CASE `type` WHEN 1 THEN `update_price` - `price` WHEN 2 THEN `price` - `update_price` END) * `number` * `multiple`) AS `profits_total`')
|
||||
->selectRaw('SUM(`caution_money`) AS `caution_money_total`')
|
||||
->selectRaw('SUM(`origin_caution_money`) AS `origin_caution_money_total`')
|
||||
->groupBy('user_id')
|
||||
->paginate($limit);
|
||||
$items = $user_hazard->getCollection();
|
||||
$items->transform(function ($item, $key) use ($legal_id) {
|
||||
$user_wallet = UsersWallet::where('currency', $legal_id)
|
||||
->where('user_id', $item->user_id)
|
||||
->first();
|
||||
$item->setAppends(['mobile', 'account_number']);
|
||||
$hazard_rate = LeverTransaction::getWalletHazardRate($user_wallet);
|
||||
$balance = $user_wallet->lever_balance ?? 0;
|
||||
$item->setAttribute('lever_balance', $balance)
|
||||
->setAttribute('hazard_rate', $hazard_rate);
|
||||
return $item;
|
||||
});
|
||||
if ($operate != -1 && !empty($hazard_rate)) {
|
||||
switch ($operate) {
|
||||
case 1:
|
||||
$operate_symbol = '>=';
|
||||
break;
|
||||
case 2:
|
||||
$operate_symbol = '<=';
|
||||
break;
|
||||
default:
|
||||
$operate_symbol = null;
|
||||
break;
|
||||
}
|
||||
$items = $items->where('hazard_rate', $operate_symbol, $hazard_rate);
|
||||
}
|
||||
$user_hazard->setCollection($items);
|
||||
return $this->layuiData($user_hazard);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\Process\Process;
|
||||
use App\LeverMultiple;
|
||||
use App\CurrencyMatch;
|
||||
use App\Setting;
|
||||
use App\UsersWallet;
|
||||
use App\WalletLog;
|
||||
use App\UsersWalletOut;
|
||||
use App\Users;
|
||||
use App\Currency;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use App\Levertolegal;
|
||||
use App\AccountLog;
|
||||
|
||||
|
||||
class LevertolegalController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('admin.levertolegal.index');
|
||||
}
|
||||
public function add()
|
||||
{
|
||||
return view('admin.levertolegal.add');
|
||||
}
|
||||
|
||||
public function doadd(Request $request)
|
||||
{
|
||||
|
||||
$aaaaaaa=new LeverMultiple();
|
||||
$aaaaaaa->value= Input::get('value', '');
|
||||
$aaaaaaa->type=Input::get('type', '');
|
||||
//var_dump($aaaaaaa);die;
|
||||
try {
|
||||
$aaaaaaa->save();
|
||||
}catch (\Exception $ex){
|
||||
|
||||
}
|
||||
return $this->success('添加成功');
|
||||
}
|
||||
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$name = $request->get('name', '');
|
||||
// $token = $request->get('token','');
|
||||
// $get_address = $request->get('get_address','');
|
||||
$sort = $request->get('sort', 0);
|
||||
$logo = $request->get('logo', '');
|
||||
$type = $request->get('type', '');
|
||||
$is_legal = $request->get('is_legal', '');
|
||||
$is_lever = $request->get('is_lever', '');
|
||||
$is_match = $request->get('is_match', '');
|
||||
$min_number = $request->get('min_number', 0);
|
||||
$rate = $request->get('rate', 0);
|
||||
$total_account = $request->get('total_account', 0);
|
||||
$key = $request->get('key', 0);
|
||||
$contract_address = $request->get('contract_address', 0);
|
||||
//自定义验证错误信息
|
||||
$messages = [
|
||||
'required' => ':attribute 为必填字段',
|
||||
];
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required',
|
||||
'sort' => 'required',
|
||||
'type' => 'required',
|
||||
'is_legal' => 'required',
|
||||
'is_lever' => 'required',
|
||||
|
||||
// 'logo'=>'required',
|
||||
], $messages);
|
||||
|
||||
//如果验证不通过
|
||||
if ($validator->fails()) {
|
||||
return $this->error($validator->errors()->first());
|
||||
}
|
||||
$has = Currency::where('name', $name)->first();
|
||||
if (empty($id) && !empty($has)) {
|
||||
return $this->error($name . ' 已存在');
|
||||
}
|
||||
if (empty($id)) {
|
||||
$currency = new Currency();
|
||||
$currency->create_time = time();
|
||||
} else {
|
||||
$currency = Currency::find($id);
|
||||
}
|
||||
$currency->name = $name;
|
||||
// $acceptor->token = $token;
|
||||
// $acceptor->get_address = $get_address;
|
||||
$currency->sort = intval($sort);
|
||||
$currency->logo = $logo;
|
||||
$currency->is_legal = $is_legal;
|
||||
$currency->is_lever = $is_lever;
|
||||
$currency->is_match = $is_match;
|
||||
$currency->min_number = $min_number;
|
||||
$currency->rate = $rate;
|
||||
$currency->total_account = $total_account;
|
||||
$currency->key = $key;
|
||||
$currency->contract_address = $contract_address;
|
||||
$currency->type = $type;
|
||||
$currency->is_display = 1;
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$currency->save();//保存币种
|
||||
// if(empty($id)){// 如果是添加新币 //没添加一种交易币,就给用户添加一个交易币钱包
|
||||
// $currency_id = Currency::where('name',$name)->first()->id;
|
||||
// $users = Users::all();
|
||||
// foreach ($users as $key => $value) {
|
||||
// $userWallet = new UsersWallet();
|
||||
// $userWallet->user_id = $value->id;
|
||||
// $userWallet->currency = $currency_id;
|
||||
// $userWallet->create_time = time();
|
||||
// $userWallet->save();
|
||||
// }
|
||||
// }
|
||||
DB::commit();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
// $limit = $request->get('limit', 10);
|
||||
// $account_number = $request->get('account_number','');
|
||||
$result = new Levertolegal();
|
||||
$count=$result::all()->count();
|
||||
$result = $result->leftjoin("users","lever_tolegal.user_id","=","users.id")->where("lever_tolegal.type","=",1)->orderBy("lever_tolegal.add_time","desc")->select("lever_tolegal.*","users.phone")->get()->toArray();
|
||||
foreach($result as $key=>$value)
|
||||
{
|
||||
$result[$key]["add_time"]=date("Y-m-d H:i:s",$value["add_time"]);
|
||||
$result[$key]["type"]="杠杆转法币";
|
||||
}
|
||||
// var_dump($result);die;
|
||||
|
||||
return response()->json(['code' => 0, 'data' => $result, 'count' => $count]);
|
||||
}
|
||||
|
||||
//审核
|
||||
public function addshow(Request $request)
|
||||
{
|
||||
$id = $request->get('id',null);
|
||||
$res= Levertolegal::find($id);
|
||||
|
||||
|
||||
$data = $res->toArray();
|
||||
|
||||
return view('admin.levertolegal.update',['result'=>$data]);
|
||||
}
|
||||
////审核通过
|
||||
public function postAddyes(Request $request)
|
||||
{
|
||||
$id = $request->post('id',null);
|
||||
$user_id = $request->post('user_id',null);
|
||||
$number= $request->post('number',null);
|
||||
|
||||
//查询出usdt币的id
|
||||
$usdt_id=Currency::where("name","=","USDC")->first()->id;
|
||||
|
||||
|
||||
//查询出对应的钱包对象
|
||||
$usdt_users_wallet=UsersWallet::where("currency","=",$usdt_id)->where("user_id","=",$user_id)->first();
|
||||
// var_dump($usdt_users_wallet);;die;
|
||||
|
||||
|
||||
|
||||
$data_wallet1 = [
|
||||
'balance_type' => 3,//余额类型:1.法币,2.币币,3.杆杠
|
||||
'wallet_id' => $usdt_users_wallet->id,
|
||||
'lock_type' => 0,
|
||||
'create_time' => time(),
|
||||
'before' => $usdt_users_wallet->lever_balance,
|
||||
'change' => $number,
|
||||
'after' => bc_sub($usdt_users_wallet->lever_balance, $number, 5),
|
||||
];
|
||||
$data_wallet2 = [
|
||||
'balance_type' => 1,//余额类型:1.法币,2.币币,3.杆杠
|
||||
'wallet_id' => $usdt_users_wallet->id,
|
||||
'lock_type' => 0,
|
||||
'create_time' => time(),
|
||||
'before' => $usdt_users_wallet->legal_balance,
|
||||
'change' => $number,
|
||||
'after' => bc_add($usdt_users_wallet->legal_balance, $number, 5),
|
||||
];
|
||||
// $usdt_users_wallet->lever_balance = $usdt_users_wallet->lever_balance - $number;
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$usdt_users_wallet->legal_balance = $usdt_users_wallet->legal_balance + $number;
|
||||
//解冻冻结余额
|
||||
// var_dump($number);die;
|
||||
$usdt_users_wallet->lock_lever_balance = $usdt_users_wallet->lock_lever_balance - $number;
|
||||
$usdt_users_wallet->save();
|
||||
|
||||
//更改审核状态为通过
|
||||
$status_res=new Levertolegal();
|
||||
$status11=$status_res->find($id);
|
||||
$status11->status=2;//1:未审核 2:审核通过 3:审核不通过
|
||||
$status11->save();
|
||||
|
||||
AccountLog::insertLog([
|
||||
'user_id' => $user_id,
|
||||
'value' => -$number,
|
||||
'currency' => $usdt_id,
|
||||
'info' => AccountLog::getTypeInfo(AccountLog::WALLET_LEVEL_LEGAL_OUT),//杠杆转法币审核通过,杠杆减少
|
||||
'type' => AccountLog::WALLET_LEVEL_LEGAL_OUT,
|
||||
], $data_wallet1);
|
||||
AccountLog::insertLog([
|
||||
'user_id' => $user_id,
|
||||
'value' => $number,
|
||||
'currency' => $usdt_id,
|
||||
'info' => AccountLog::getTypeInfo(AccountLog::WALLET_LEVEL_LEGAL_IN),//杠杆转法币审核通过,法币增加
|
||||
'type' => AccountLog::WALLET_LEVEL_LEGAL_IN,
|
||||
], $data_wallet2);
|
||||
DB::commit();
|
||||
return $this->success('划转成功');
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
//审核不通过
|
||||
public function postAddno(Request $request)
|
||||
{
|
||||
$id = $request->post('id',null);
|
||||
$user_id = $request->post('user_id',null);
|
||||
$number= $request->post('number',null);
|
||||
|
||||
//查询出usdt币的id
|
||||
$usdt_id=Currency::where("name","=","USDC")->first()->id;
|
||||
|
||||
|
||||
//查询出对应的钱包对象
|
||||
$usdt_users_wallet=UsersWallet::where("currency","=",$usdt_id)->where("user_id","=",$user_id)->first();
|
||||
|
||||
try {
|
||||
$usdt_users_wallet->lever_balance = $usdt_users_wallet->lever_balance + $number;
|
||||
//审核不通过解冻冻结余额
|
||||
$usdt_users_wallet->lock_lever_balance = $usdt_users_wallet->lock_lever_balance - $number;
|
||||
$usdt_users_wallet->save();
|
||||
|
||||
//更改审核状态为通过
|
||||
$status_res=new Levertolegal();
|
||||
$status11=$status_res->find($id);
|
||||
$status11->status=3;//1:未审核 2:审核通过 3:审核不通过
|
||||
$status11->save();
|
||||
|
||||
$usdt_users_wallet->save();
|
||||
AccountLog::newinsertLog([
|
||||
'user_id' => $user_id,
|
||||
'value' => $number,
|
||||
'currency' => $usdt_id,
|
||||
'info' => AccountLog::getTypeInfo(AccountLog::WALLET_JIEDONGGANGGAN),
|
||||
'type' => AccountLog::WALLET_JIEDONGGANGGAN,
|
||||
]);
|
||||
DB::commit();
|
||||
|
||||
return $this->success('审核不通过!');
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function del()
|
||||
{
|
||||
$admin = LeverMultiple::find(Input::get('id'));
|
||||
if($admin == null) {
|
||||
abort(404);
|
||||
}
|
||||
$bool = $admin->delete();
|
||||
if($bool){
|
||||
return $this->success('删除成功');
|
||||
}else{
|
||||
return $this->error('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit(Request $request){
|
||||
|
||||
$id = $request->get('id',0);
|
||||
if (empty($id)){
|
||||
return $this->error("参数错误");
|
||||
}
|
||||
|
||||
$result = LeverMultiple::find($id);
|
||||
//
|
||||
// $res=UserCashInfo::where('user_id',$id)->first();
|
||||
|
||||
return view('admin.levermultiple.edit',['result'=>$result]);
|
||||
}
|
||||
|
||||
//编辑用户信息
|
||||
public function doedit(){
|
||||
$password = Input::get("value");
|
||||
$id = Input::get("id");
|
||||
if (empty($id)) return $this->error("参数错误");
|
||||
$user = LeverMultiple::find($id);
|
||||
$user->value=$password;
|
||||
if (empty($user)) return $this->error("数据未找到");
|
||||
// DB::beginTransaction();
|
||||
try {
|
||||
|
||||
$aa=$user->save();
|
||||
// var_dump($aa);die;
|
||||
return $this->success('编辑成功');
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 交易对显示
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function match()
|
||||
{
|
||||
return view('admin.currency.match');
|
||||
}
|
||||
|
||||
public function matchList(Request $request)
|
||||
{
|
||||
$legal_id = $request->route('legal_id');
|
||||
$limit = $request->input('limit', 10);
|
||||
$legal = Currency::find($legal_id);
|
||||
$matchs = $legal->quotation()->paginate($limit);
|
||||
return $this->layuiData($matchs);
|
||||
}
|
||||
|
||||
public function addMatch($legal_id)
|
||||
{
|
||||
$is_legal = Currency::where('id', $legal_id)->value('is_legal');
|
||||
if (!$is_legal) {
|
||||
abort(403, '指定币种不是法币,不能添加交易对');
|
||||
}
|
||||
$currencies = Currency::where('id', '<>', $legal_id)->get();
|
||||
$market_from_names = CurrencyMatch::enumMarketFromNames();
|
||||
return view('admin.currency.match_add')->with('currencies', $currencies)
|
||||
->with('market_from_names', $market_from_names);
|
||||
}
|
||||
|
||||
public function postAddMatch(Request $request, $legal_id)
|
||||
{
|
||||
$is_legal = Currency::where('id', $legal_id)->value('is_legal');
|
||||
if (!$is_legal) {
|
||||
return $this->error('指定币种不是法币,不能添加交易对');
|
||||
}
|
||||
$currency_id = $request->input('currency_id');
|
||||
$is_display = $request->input('is_display', 1);
|
||||
$market_from = $request->input('market_from', 0);
|
||||
$open_transaction = $request->input('open_transaction', 0);
|
||||
$open_lever = $request->input('open_lever', 0);
|
||||
$lever_share_num = $request->input('lever_share_num', 1);
|
||||
$spread = $request->input('spread', 0);
|
||||
$overnight = $request->input('overnight', 0);
|
||||
$lever_trade_fee = $request->input('lever_trade_fee', 0);
|
||||
//检测交易对是否已存在
|
||||
$exist = CurrencyMatch::where('currency_id', $currency_id)
|
||||
->where('legal_id', $legal_id)
|
||||
->first();
|
||||
if ($exist) {
|
||||
return $this->error('对应交易对已存在');
|
||||
}
|
||||
CurrencyMatch::unguard();
|
||||
$currency_match = CurrencyMatch::create([
|
||||
'legal_id' => $legal_id,
|
||||
'currency_id' => $currency_id,
|
||||
'is_display' => $is_display,
|
||||
'market_from' => $market_from,
|
||||
'open_transaction' => $open_transaction,
|
||||
'open_lever' => $open_lever,
|
||||
'lever_share_num' => $lever_share_num,
|
||||
'lever_trade_fee' => $lever_trade_fee,
|
||||
'spread' => $spread,
|
||||
'overnight' => $overnight,
|
||||
'create_time' => time(),
|
||||
]);
|
||||
CurrencyMatch::reguard();
|
||||
return isset($currency_match->id) ? $this->success('添加成功') : $this->error('添加失败');
|
||||
}
|
||||
|
||||
public function editMatch($id)
|
||||
{
|
||||
$currency_match = CurrencyMatch::find($id);
|
||||
if (!$currency_match) {
|
||||
abort(403, '指定交易对不存在');
|
||||
}
|
||||
$market_from_names = CurrencyMatch::enumMarketFromNames();
|
||||
$currencies = Currency::where('id', '<>', $currency_match->legal_id)->get();
|
||||
$var = compact('currency_match', 'currencies', 'market_from_names');
|
||||
return view('admin.currency.match_add', $var);
|
||||
}
|
||||
|
||||
public function postEditMatch(Request $request, $id)
|
||||
{
|
||||
$currency_id = $request->input('currency_id');
|
||||
$is_display = $request->input('is_display', 1);
|
||||
$market_from = $request->input('market_from', 0);
|
||||
$open_transaction = $request->input('open_transaction', 0);
|
||||
$open_lever = $request->input('open_lever', 0);
|
||||
$lever_share_num = $request->input('lever_share_num', 1);
|
||||
$spread = $request->input('spread', 0);
|
||||
$overnight = $request->input('overnight', 0);
|
||||
$lever_trade_fee = $request->input('lever_trade_fee', 0);
|
||||
$currency_match = CurrencyMatch::find($id);
|
||||
if (!$currency_match) {
|
||||
abort(403, '指定交易对不存在');
|
||||
}
|
||||
CurrencyMatch::unguard();
|
||||
$result = $currency_match->fill([
|
||||
'currency_id' => $currency_id,
|
||||
'is_display' => $is_display,
|
||||
'market_from' => $market_from,
|
||||
'open_transaction' => $open_transaction,
|
||||
'open_lever' => $open_lever,
|
||||
'lever_share_num' => $lever_share_num,
|
||||
'lever_trade_fee' => $lever_trade_fee,
|
||||
'spread' => $spread,
|
||||
'overnight' => $overnight,
|
||||
'create_time' => time(),
|
||||
])->save();
|
||||
CurrencyMatch::reguard();
|
||||
return $result ? $this->success('保存成功') : $this->error('保存失败');
|
||||
}
|
||||
|
||||
public function delMatch($id)
|
||||
{
|
||||
$result = CurrencyMatch::destroy($id);
|
||||
return $result ? $this->success('删除成功') : $this->error('删除失败');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\Ltc;
|
||||
use App\LtcBuy;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class LtcController extends Controller{
|
||||
|
||||
public function index(){
|
||||
return view("admin.ltc.index");
|
||||
}
|
||||
|
||||
public function lists(Request $request){
|
||||
$limit = $request->get('limit',10);
|
||||
$list = new Ltc();
|
||||
$list = $list->orderBy('id','desc')->paginate($limit);
|
||||
return response()->json(['code'=>0,'data'=>$list->items(),'count'=>$list->total()]);
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$level = Ltc::getLevelName();
|
||||
return view('admin.ltc.add',['levelName'=>$level]);
|
||||
}
|
||||
|
||||
public function postAdd(Request $request){
|
||||
$name = $request->get('name','');
|
||||
$profile = $request->get('profile','');
|
||||
$detail = $request->get('detail','');
|
||||
$price = $request->get('price','');
|
||||
$number = $request->get('number','');
|
||||
$thumbnail = $request->get('thumbnail','');
|
||||
if(empty($name)){
|
||||
return $this->error('请输入名称');
|
||||
}
|
||||
if(empty($profile)){
|
||||
return $this->error('请输入简介');
|
||||
}
|
||||
if(empty($detail)){
|
||||
return $this->error('请输入详情');
|
||||
}
|
||||
if(empty($price)){
|
||||
return $this->error('请输入价格');
|
||||
}
|
||||
if(empty($number)){
|
||||
return $this->error('请输入数量');
|
||||
}
|
||||
if(empty($thumbnail)){
|
||||
return $this->error("请上传图片");
|
||||
}
|
||||
|
||||
$id = $request->get('id','');
|
||||
if(empty($id)){
|
||||
$result = new Ltc();
|
||||
}else{
|
||||
$result = Ltc::find($id);
|
||||
}
|
||||
try{
|
||||
$result->name = $name;
|
||||
$result->profile = $profile;
|
||||
$result->detail = $detail;
|
||||
$result->price = $price;
|
||||
$result->number = $number;
|
||||
$result->thumbnail = $thumbnail;
|
||||
$result->create_time = time();
|
||||
$result->save();
|
||||
return $this->success('添加成功');
|
||||
}catch (\Exception $e){
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$id = Input::get('id',null);
|
||||
if(empty($id)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$result = Ltc::find($id);
|
||||
if(empty($result)){
|
||||
return $this->error('无此数据');
|
||||
}
|
||||
$level = Ltc::getLevelName();
|
||||
return view('admin.ltc.add', ['result'=>$result,'levelName'=>$level]);
|
||||
}
|
||||
|
||||
public function del(Request $request){
|
||||
$id = $request->get('id','');
|
||||
if(empty($id)){
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$result = Ltc::find($id);
|
||||
try{
|
||||
$result->delete();
|
||||
return $this->success('删除成功');
|
||||
}catch(\Exception $e){
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function buyList(Request $request){
|
||||
$limit = $request->get('limit',10);
|
||||
$result = new LtcBuy();
|
||||
$result = $result->orderBy('id','desc')->paginate($limit);
|
||||
return response()->json(['code'=>0,'data'=>$result->items(),'count'=>$result->total()]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Admin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\{
|
||||
MailMessage,
|
||||
Users,
|
||||
UserChat
|
||||
};
|
||||
use App\Utils\Hash;
|
||||
|
||||
class MailMessageController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view("admin.message.index");
|
||||
}
|
||||
|
||||
public function list(Request $request){
|
||||
$limit = $request->get('limit');
|
||||
$start_time = strtotime($request->get('start_time', 0));
|
||||
$end_time = strtotime($request->get('end_time', 0));
|
||||
|
||||
$list = MailMessage::where(function ($query) use ($start_time) {
|
||||
if (!empty($start_time)) {
|
||||
$query->where('create_time', '>=', $start_time);
|
||||
}
|
||||
})->where(function ($query) use ($end_time) {
|
||||
if ($end_time != '') {
|
||||
$query->where('create_time', '<=', $end_time);
|
||||
}
|
||||
})->orderBy('id', 'desc')->paginate($limit);
|
||||
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function add(){
|
||||
$user_list = Users::all();
|
||||
return view("admin.message.add", [
|
||||
'user_list' => $user_list
|
||||
]);
|
||||
}
|
||||
|
||||
public function postAdd(Request $request){
|
||||
$userIds = Input::get("userIds");
|
||||
$title = Input::get("title");
|
||||
$content = Input::get("content");
|
||||
$abstract = Input::get("abstract");
|
||||
|
||||
if (empty($title) || empty($content)) return $this->error("参数错误");
|
||||
|
||||
|
||||
DB::beginTransaction();
|
||||
$mailMessage = new MailMessage();
|
||||
try {
|
||||
|
||||
$mailMessage->user_ids = $userIds ?? '';
|
||||
$mailMessage->title = $title ?? '';
|
||||
$mailMessage->content = $content ?? '';
|
||||
$mailMessage->status = 1;
|
||||
$mailMessage->abstract = $abstract;
|
||||
$mailMessage->create_time = time();
|
||||
$mailMessage->save();
|
||||
|
||||
DB::commit();
|
||||
$send = ['type' => 'mail_message', 'period' => true];
|
||||
UserChat::sendChat($send);
|
||||
return $this->success('保存发送成功');
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function post_add(Request $request){
|
||||
$userIds = Input::get("userIds");
|
||||
$title = Input::get("title");
|
||||
$content = Input::get("content");
|
||||
|
||||
if (empty($title) || empty($content)) return $this->error("参数错误");
|
||||
|
||||
|
||||
DB::beginTransaction();
|
||||
$mailMessage = new MailMessage();
|
||||
try {
|
||||
|
||||
$mailMessage->user_ids = $userIds ?? '';
|
||||
$mailMessage->title = $title ?? '';
|
||||
$mailMessage->content = $content ?? '';
|
||||
$mailMessage->status = 0;
|
||||
$mailMessage->abstract = $abstract;
|
||||
$mailMessage->create_time = time();
|
||||
$mailMessage->save();
|
||||
|
||||
DB::commit();
|
||||
return $this->success('保存成功');
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function del(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
$userreal = MailMessage::find($id);
|
||||
if (empty($userreal)) {
|
||||
$this->error("信息未找到");
|
||||
}
|
||||
try {
|
||||
|
||||
$userreal->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $ex) {
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function fs(Request $request){
|
||||
$id = $request->get('id');
|
||||
$userreal = MailMessage::find($id);
|
||||
if (empty($userreal)) {
|
||||
$this->error("信息未找到");
|
||||
}
|
||||
try {
|
||||
$userreal -> status = 1;
|
||||
$userreal->save();
|
||||
return $this->success('发送成功');
|
||||
} catch (\Exception $ex) {
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\UsersWallet;
|
||||
use App\Users;
|
||||
use App\Currency;
|
||||
use App\MarketDay;
|
||||
use App\MarketHour;
|
||||
|
||||
class marketController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('admin.market.index');
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$legal = Currency::where('is_legal', 1)->where('is_display', 1)->get();
|
||||
$currency = Currency::where('is_display', 1)->get();
|
||||
|
||||
return view('admin.market.add')->with(['rest' => $legal, 'list' => $currency]);
|
||||
}
|
||||
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
$currency_id = $request->get('currency_id', 0);
|
||||
$legal_id = $request->get('legal_id', '');
|
||||
$start_price = $request->get('start_price', 0);
|
||||
$end_price = $request->get('end_price', '');
|
||||
$type = $request->get('type', '');
|
||||
$highest = $request->get('highest', '');
|
||||
$mminimum = $request->get('mminimum', '');
|
||||
$number = $request->get('number', 0);
|
||||
$times = $request->get('start_time', 0);
|
||||
if ($legal_id == $currency_id) {
|
||||
return $this->error('法币和币种不能一样');
|
||||
}
|
||||
if (empty($start_price) || empty($end_price) || empty($highest) || empty($mminimum)) {
|
||||
return $this->error('请把数据填写完整');
|
||||
}
|
||||
if ($type == 0) {
|
||||
$market = new MarketDay();
|
||||
$times = date('Y-m-d', strtotime($times));
|
||||
$market->times = $times;
|
||||
} else {
|
||||
$market = new MarketHour();
|
||||
$market->type = $type;
|
||||
$times = strtotime($times);
|
||||
$market->day_time = $times;
|
||||
}
|
||||
|
||||
$market->currency_id = $currency_id;
|
||||
$market->legal_id = $legal_id;
|
||||
$market->start_price = $start_price;
|
||||
$market->end_price = $end_price;
|
||||
$market->highest = $highest;
|
||||
$market->mminimum = $mminimum;
|
||||
$market->number = $number;
|
||||
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$market->save();//保存币种
|
||||
|
||||
DB::commit();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
//行情数据展示
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 20);
|
||||
//$account_number = $request->get('account_number','');
|
||||
$result = new MarketHour();
|
||||
$result = $result->orderBy('id', 'asc')->orderBy('id', 'desc')->paginate($limit);
|
||||
foreach ($result as $k => $v) {
|
||||
$legal = Currency::find($v->legal_id);
|
||||
$v->legal_name = $legal->name;
|
||||
$currency = Currency::find($v->currency_id);
|
||||
$v->currency_name = $currency->name;
|
||||
$v->day_time=date("Y-m-d H:i:s",$v->day_time);
|
||||
}
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$acceptor = MarketDay::find($id);
|
||||
if (empty($acceptor)) {
|
||||
return $this->error('无此记录');
|
||||
}
|
||||
try {
|
||||
$acceptor->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function isDisplay(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$currency = Currency::find($id);
|
||||
if (empty($currency)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
if ($currency->is_display == 1) {
|
||||
$currency->is_display = 0;
|
||||
} else {
|
||||
$currency->is_display = 1;
|
||||
}
|
||||
try {
|
||||
$currency->save();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\Process\Process;
|
||||
use App\MicroNumber;
|
||||
use App\MicroOrder;
|
||||
use App\MicroSecond;
|
||||
use App\Currency;
|
||||
use App\CurrencyMatch;
|
||||
use App\Setting;
|
||||
use App\UsersWallet;
|
||||
use App\Users;
|
||||
|
||||
class MicroController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('admin.micro.index');
|
||||
}
|
||||
|
||||
public function add(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
if (empty($id)) {
|
||||
$result = new MicroNumber();
|
||||
} else {
|
||||
$result = MicroNumber::find($id);
|
||||
}
|
||||
$currencies = Currency::where('is_micro', 1)->get();
|
||||
|
||||
return view('admin.micro.add')->with('result', $result)->with('currencies', $currencies);
|
||||
}
|
||||
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$currency_id = $request->get('currency_id', '');
|
||||
$number = $request->get('number', '');
|
||||
|
||||
if (empty($id)) {
|
||||
$micro_number = new MicroNumber();
|
||||
} else {
|
||||
$micro_number = MicroNumber::find($id);
|
||||
if ($micro_number == null) {
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
$micro_number->currency_id = $currency_id;
|
||||
$micro_number->number = $number;
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$micro_number->save(); //保存币种
|
||||
DB::commit();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$result = new MicroNumber();
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
public function del(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$nicro_number = MicroNumber::find($id);
|
||||
if (empty($nicro_number)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
try {
|
||||
$nicro_number->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//micro_seconds
|
||||
|
||||
public function secondsIndex()
|
||||
{
|
||||
return view('admin.micro.seconds_index');
|
||||
}
|
||||
|
||||
public function secondsAdd(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
if (empty($id)) {
|
||||
$result = new MicroSecond();
|
||||
} else {
|
||||
$result = MicroSecond::find($id);
|
||||
}
|
||||
// $currencies = Currency::where('is_micro',1)->get();
|
||||
|
||||
return view('admin.micro.seconds_add')->with('result', $result);
|
||||
}
|
||||
|
||||
public function secondsPostAdd(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$seconds = $request->get('seconds', '');
|
||||
$status = $request->get('status', '');
|
||||
$profit_ratio = $request->get('profit_ratio', '');
|
||||
$loss_ratio = $request->get('loss_ratio', '');
|
||||
$max_amount = $request->get('max_amount', '');
|
||||
$min_amount = $request->get('min_amount', '');
|
||||
if (empty($id)) {
|
||||
$result = new MicroSecond();
|
||||
} else {
|
||||
$result = MicroSecond::find($id);
|
||||
if ($result == null) {
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
$result->seconds = $seconds;
|
||||
$result->profit_ratio = $profit_ratio;
|
||||
$result->loss_ratio = $loss_ratio;
|
||||
$result->status = $status;
|
||||
$result->max_amount = $max_amount;
|
||||
$result->min_amount = $min_amount;
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$result->save(); //保存币种
|
||||
DB::commit();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function secondsLists(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$result = new MicroSecond();
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
public function secondsDel(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$result = MicroSecond::find($id);
|
||||
if (empty($result)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
try {
|
||||
$result->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function secondsStatus(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$result = MicroSecond::find($id);
|
||||
if (empty($result)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
if ($result->status == 1) {
|
||||
$result->status = 0;
|
||||
} else {
|
||||
$result->status = 1;
|
||||
}
|
||||
try {
|
||||
$result->save();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function order()
|
||||
{
|
||||
$currencies = Currency::where('is_micro', 1)->get();
|
||||
$currency_matches = CurrencyMatch::where('open_microtrade', 1)->get();
|
||||
return view('admin.micro.orders')
|
||||
->with('currencies', $currencies)
|
||||
->with('currency_matches', $currency_matches);
|
||||
}
|
||||
|
||||
public function orderList(Request $request)
|
||||
{
|
||||
$currency_id = $request->input('currency_id', -1);
|
||||
$match_id = $request->input('match_id', -1);
|
||||
$type = $request->input('type', -1);
|
||||
$account = $request->input('account', '');
|
||||
$name = $request->input('name', '');
|
||||
$limit = $request->input('limit', 10);
|
||||
$status = $request->input('status', -1);
|
||||
$start = $request->input("start_time", '');
|
||||
$end = $request->input("end_time", '');
|
||||
$pre_profit_result = $request->input('pre_profit_result', -2);
|
||||
$profit_result = $request->input('profit_result', -2);
|
||||
|
||||
$results = MicroOrder::with(['currency', 'currencyMatch', 'user'])
|
||||
->when($currency_id != -1, function ($query) use ($currency_id) {
|
||||
$query->where('currency_id', $currency_id);
|
||||
})->when($match_id != -1, function ($query) use ($match_id) {
|
||||
$query->where('match_id', $match_id);
|
||||
})->when($type != -1, function ($query) use ($type) {
|
||||
$query->where('type', $type);
|
||||
})->when($status != -1, function ($query) use ($status) {
|
||||
$query->where('status', $status);
|
||||
})->when($pre_profit_result != -2, function ($query) use ($pre_profit_result) {
|
||||
$query->where('pre_profit_result', $pre_profit_result);
|
||||
})->when($profit_result != -2, function ($query) use ($profit_result) {
|
||||
$query->where('profit_result', $profit_result);
|
||||
})->when($account != '' || $name != '', function ($query) use ($account, $name) {
|
||||
$query->whereHas('user', function ($query) use ($account, $name) {
|
||||
$account != '' && $query->where("phone", 'like', '%' . $account . '%')->orwhere('email', 'like', '%' . $account . '%');
|
||||
$query->when($name != '', function ($query) use ($name) {
|
||||
$query->whereHas('userReal', function ($query) use ($name) {
|
||||
$query->where("name", 'like', '%' . $name . '%');
|
||||
});
|
||||
});
|
||||
});
|
||||
})->when($start !='', function ($query) use ($start) {
|
||||
$query->where('created_at','>=', $start);
|
||||
})->when($end !='', function ($query) use ($end) {
|
||||
$query->where('created_at','<=', $end);
|
||||
})->orderBy('id', 'desc')
|
||||
->paginate($limit);
|
||||
$items = $results->getCollection();
|
||||
$items->transform(function ($item, $key) {
|
||||
return $item->append('pre_profit_result_name')->makeVisible('pre_profit_result');
|
||||
});
|
||||
$results->setCollection($items);
|
||||
return $this->layuiData($results);
|
||||
}
|
||||
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
if (empty($id)) {
|
||||
return $this->error("参数错误");
|
||||
}
|
||||
|
||||
$result = MicroOrder::findOrNew($id);
|
||||
|
||||
return view('admin.micro.edit', ['result' => $result]);
|
||||
}
|
||||
|
||||
//编辑用户信息
|
||||
public function editPost()
|
||||
{
|
||||
|
||||
$risk = Input::get('risk', 0);
|
||||
|
||||
$id = Input::get("id");
|
||||
|
||||
if (empty($id)) return $this->error("参数错误");
|
||||
|
||||
$res = MicroOrder::find($id);
|
||||
if (empty($res)) {
|
||||
return $this->error("数据未找到");
|
||||
}
|
||||
if ($res->status != 1) {
|
||||
return $this->error("数据状态下不能修改");
|
||||
}
|
||||
|
||||
$res->pre_profit_result = $risk;
|
||||
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
$res->save();
|
||||
|
||||
DB::commit();
|
||||
return $this->success('编辑成功');
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function batchRisk(Request $request)
|
||||
{
|
||||
try {
|
||||
$ids = $request->input('ids', []);
|
||||
$risk = $request->input('risk', 0);
|
||||
if (empty($ids)) {
|
||||
throw new \Exception('请先选择要处理的交易');
|
||||
}
|
||||
if (!in_array($risk, [-1, 0, 1])) {
|
||||
throw new \Exception('输赢类型不正确');
|
||||
}
|
||||
$affect_rows = MicroOrder::where('status', MicroOrder::STATUS_OPENED)
|
||||
->whereIn('id', $ids)
|
||||
->update([
|
||||
'pre_profit_result' => $risk,
|
||||
]);
|
||||
return $this->success('本次提交:' . count($ids) . '条,设置成功:' . $affect_rows . '条');
|
||||
} catch (\Throwable $th) {
|
||||
return $this->error($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Currency;
|
||||
use App\CurrencyMatch;
|
||||
use App\MarketHour;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use App\MyQuotation as NeedleModel;
|
||||
|
||||
class MyQuotation extends \App\Http\Controllers\Admin\Controller
|
||||
{
|
||||
//
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
$bases=DB::table("currency_matches")->where("market_from",2)->select("currency_id")->get();
|
||||
$bases=json_decode(json_encode($bases),true);
|
||||
foreach ($bases as $k=>$v){
|
||||
$one=DB::table("currency")->where("id",$v["currency_id"])->select("id","name")->first();
|
||||
$bases[$k]["name"]=$one->name;
|
||||
}
|
||||
// var_dump($bases);die;
|
||||
$base=$request->get("base",$bases[0]["name"]);
|
||||
|
||||
$news = NeedleModel::where("base",$base)->orderBy('id', 'desc')->paginate(10);
|
||||
$news->appends(['base'=>$base])->render();
|
||||
$data = [
|
||||
'currencys' => $currencys = CurrencyMatch::where('market_from', 3)->get(),
|
||||
'news' => $news
|
||||
];
|
||||
$res=[
|
||||
'data' => $data,
|
||||
"bases"=>$bases,
|
||||
"base"=>$base
|
||||
];
|
||||
//$res->appends(['base'=>$base])->render();
|
||||
|
||||
return view('admin.needle.quotation', $res);
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
|
||||
$param = [
|
||||
'index' => 'market.quotation',
|
||||
'type' => 'doc',//$type,
|
||||
'body' => [
|
||||
'query' => [
|
||||
'bool' => [
|
||||
'must' => [
|
||||
['match' => ['base' => $request->get('currency')]],
|
||||
],
|
||||
],
|
||||
],
|
||||
'sort' => [
|
||||
'itime' => ['order' => 'asc']
|
||||
],
|
||||
'size' => $request->get('limit'),
|
||||
'from' => ($request->get('page') - 1) * $request->get('limit')
|
||||
],
|
||||
];
|
||||
$esclient = MarketHour::getEsearchClient();
|
||||
$result = $esclient->search($param);
|
||||
$total = 0;
|
||||
$data = [];
|
||||
if (isset($result['hits'])) {
|
||||
$data = array_column($result['hits']['hits'], '_source');
|
||||
$total = $result['hits']['total']['value'];
|
||||
}
|
||||
$res = ['code' => 0,
|
||||
'msg' => '',
|
||||
'count' => $total,
|
||||
'data' => $data];
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$param = [
|
||||
'index' => 'market.quotation',
|
||||
'type' => 'doc',//$type,
|
||||
];
|
||||
}
|
||||
|
||||
public function reset(Request $request)
|
||||
{
|
||||
$param = [
|
||||
'index' => 'market.quotation',
|
||||
];
|
||||
$eclient = MarketHour::getEsearchClient();
|
||||
$eclient->indices()->delete($param);
|
||||
|
||||
foreach (['5min', '15min', '30min', '60min', '1day', '1week', '1mon'] as $v) {
|
||||
try {
|
||||
$param = [
|
||||
'index' => 'market.kline.' . $v,
|
||||
];
|
||||
$eclient = MarketHour::getEsearchClient();
|
||||
$eclient->indices()->delete($param);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return ['code' => 1];
|
||||
}
|
||||
|
||||
public static function needleList($num = 0, $name)
|
||||
{
|
||||
$esclient = MarketHour::getEsearchClient();
|
||||
|
||||
$param = [
|
||||
'index' => 'market.quotation',
|
||||
'type' => 'doc',//$type,
|
||||
'body' => [
|
||||
'query' => [
|
||||
'bool' => [
|
||||
'must' => [
|
||||
['match' => ['base' => $_POST]],
|
||||
['match' => ['base-currency' => $base_currency]],
|
||||
['match' => ['quote-currency' => $quote_currency]],
|
||||
],
|
||||
'filter' => [
|
||||
'range' => [
|
||||
'id' => [
|
||||
'gte' => $from,
|
||||
'lte' => $to,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'sort' => [
|
||||
],
|
||||
'size' => 20,
|
||||
'from' => 20
|
||||
],
|
||||
];
|
||||
$result = $esclient->search($param);
|
||||
if (isset($result['hits'])) {
|
||||
$data = [];
|
||||
// foreach($result['hits']['hits'] as $val)
|
||||
// {
|
||||
// $val['_source'];
|
||||
// }
|
||||
$data = array_column($result['hits']['hits'], '_source');
|
||||
|
||||
return $data;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
// $news_query = NeedleModel::where(function ($query) use ($cId) {
|
||||
// $cId > 0 && $query->where('id', $cId);
|
||||
// })->orderBy('id', 'desc');
|
||||
$news = $num != 0 ? $news_query->paginate($num) : $news_query->get();
|
||||
return $news;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Http\Request;
|
||||
use App\News as NewsModel;
|
||||
use App\NewsCategory;
|
||||
use App\NewsDiscuss;
|
||||
use DB;
|
||||
use Validator;
|
||||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
use ValidatesRequests;
|
||||
|
||||
|
||||
/**
|
||||
* @c_id integer 新闻分类
|
||||
* @keyword string 关键词
|
||||
* @num integer 每页记录数,为0则不分页
|
||||
*/
|
||||
|
||||
public static function newsList($cId = 0, $keyword = '', $lang = '', $num = 0)
|
||||
{
|
||||
$keyword = '%' . $keyword . '%';
|
||||
$news_query = NewsModel::where(function ($query) use ($cId, $keyword, $lang) {
|
||||
!empty($keyword) && $query->where('title', 'like', $keyword);
|
||||
$cId > 0 && $query->where('c_id', $cId);
|
||||
!empty($lang) && $query->where('lang', $lang);
|
||||
})->orderBy('id', 'desc');
|
||||
$news = $num != 0 ? $news_query->paginate($num) : $news_query->get();
|
||||
return $news;
|
||||
}
|
||||
|
||||
/**
|
||||
* @num integer 每页记录数,为0则不分页
|
||||
* @id integer 分类ID,为0则返回所有
|
||||
*/
|
||||
|
||||
public static function newsCateList($num = 0, $id = 0)
|
||||
{
|
||||
if($id == 0) {
|
||||
if($num != 0) {
|
||||
$discuss = NewsCategory::orderBy('id', 'desc')->paginate($num);
|
||||
} else {
|
||||
$discuss = NewsCategory::orderBy('id', 'desc')->get();
|
||||
}
|
||||
} else {
|
||||
if($num != 0) {
|
||||
$discuss = NewsCategory::where('id', $id)->orderBy('id', 'asc')->paginate($num);
|
||||
} else {
|
||||
$discuss = NewsCategory::where('id', $id)->orderBy('id', 'asc')->get();
|
||||
}
|
||||
}
|
||||
return $discuss;
|
||||
}
|
||||
|
||||
/**
|
||||
* @nId integer 所属新闻ID
|
||||
* @num integer 每页记录数,为0则不分页
|
||||
*/
|
||||
|
||||
public static function newsDiscussList($nId = 0, $num = 0)
|
||||
{
|
||||
if($nId == 0) {
|
||||
return false;
|
||||
} else {
|
||||
if($num != 0) {
|
||||
$discuss = NewsDiscuss::where('n_id', $nId)->orderBy('id', 'desc')->paginate($num);
|
||||
} else {
|
||||
$discuss = NewsDiscuss::where('n_id', $nId)->orderBy('id', 'desc')->get();
|
||||
}
|
||||
}
|
||||
return $discuss;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台新闻列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function index(Request $request, $c_id = 0, $keyword = '')
|
||||
{
|
||||
$c_id = intval($request->input('c_id', '0'));
|
||||
$keyword = trim($request->input('keyword', ''));
|
||||
$lang = trim($request->input('lang', ''));
|
||||
$cateList = NewsCategory::all();
|
||||
$news = self::newsList($c_id, $keyword, $lang, 10);
|
||||
$lang_list = NewsModel::getLangeList();
|
||||
$count = count($news);
|
||||
$data = [
|
||||
'count'=> $count,
|
||||
'news' => $news->appends([
|
||||
'c_id' => $c_id,
|
||||
'keyword' => $keyword,
|
||||
'lang' => $lang,
|
||||
]),
|
||||
'cateList' => $cateList,
|
||||
];
|
||||
return view('admin.news.index', [
|
||||
'data'=> $data,
|
||||
'lang_list' => $lang_list,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台添加新闻表单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function add(Request $request)
|
||||
{
|
||||
$cateList = NewsCategory::all();
|
||||
$lang_list = NewsModel::getLangeList();
|
||||
return view('admin.news.add', [
|
||||
'cateList' => $cateList,
|
||||
'langList' => $lang_list
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理添加新闻表单数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
$news = new NewsModel();
|
||||
$this->validate($request, [
|
||||
'title' => 'required|min:1|max:128',
|
||||
'c_id' => 'required|integer',
|
||||
'author' => 'required|min:1|max:64',
|
||||
'content' => 'required',
|
||||
'lang' => 'required',
|
||||
]);
|
||||
$news->title = $request->input('title');
|
||||
$news->c_id = $request->input('c_id');
|
||||
$news->recommend = $request->input('recommend', 0);
|
||||
$thumbnail = $request->input('thumbnail', "");
|
||||
$cover = $request->input('cover', "");
|
||||
$news->thumbnail = empty($thumbnail) ? URL("images/zwtp.png"):$thumbnail;
|
||||
$news->cover = empty($cover) ? URL("images/zwtp.png"):$cover;
|
||||
$news->audit = $request->input('audit', 0);
|
||||
$news->display = $request->input('display', 0);
|
||||
$news->discuss = $request->input('discuss', 0);
|
||||
$news->author = $request->input('author', '管理员') ;
|
||||
$news->views = $request->input('views', 0);
|
||||
$news->create_time = $request->input('create_time') == date('Y-m-d') ? strtotime(date('Y-m-d H:i:s')) : strtotime($request->input('create_time'));
|
||||
$news->browse_grant = $request->input('browse_grant');
|
||||
$news->keyword = $request->input('keyword', '') ?? '';
|
||||
$news->abstract = $request->input('abstract', '') ?? '';
|
||||
$news->content = $request->input('content', '') ?? '';
|
||||
$news->lang = $request->input('lang', 'zh');
|
||||
$news->sorts = $request->input('sorts', 0);
|
||||
$result = $news->save();
|
||||
return $result ? $this->success('添加成功!') : $this->error('添加失败!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑新闻表单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function edit(Request $request, $id = 0)
|
||||
{
|
||||
$news = NewsModel::find($id);
|
||||
$cateList = NewsCategory::all();
|
||||
$lang_list = NewsModel::getLangeList();
|
||||
$data = [
|
||||
'news' => $news,
|
||||
'cateList' => $cateList,
|
||||
'langList' => $lang_list,
|
||||
];
|
||||
return view('admin.news.add', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理编辑表单数据
|
||||
*/
|
||||
|
||||
public function postEdit(Request $request, $id = 0)
|
||||
{
|
||||
$news = NewsModel::find($id);
|
||||
$cateList = NewsCategory::all();
|
||||
$this->validate($request, [
|
||||
'title' => 'required|min:1|max:128',
|
||||
'author' => 'required|min:1|max:64',
|
||||
'content' => 'required',
|
||||
'c_id' => 'required|integer|min:1',
|
||||
'lang' => 'required',
|
||||
]);
|
||||
$news->title = $request->input('title');
|
||||
$news->c_id = $request->input('c_id');
|
||||
$thumbnail = $request->input('thumbnail', "");
|
||||
$cover = $request->input('cover', "");
|
||||
$news->thumbnail = empty($thumbnail) ? URL("images/zwtp.png"):$thumbnail;
|
||||
$news->cover = empty($cover) ? URL("images/zwtp.png"):$cover;
|
||||
$news->recommend = $request->input('recommend', 0);
|
||||
$news->audit = $request->input('audit', 0);
|
||||
$news->display = $request->input('display', 0);
|
||||
$news->discuss = $request->input('discuss', 0);
|
||||
$news->author = $request->input('author', '管理员');
|
||||
$news->views = $request->input('views', 0);
|
||||
$news->create_time = $request->input('create_time') == date('Y-m-d') ? strtotime(date('Y-m-d H:i:s')) : strtotime($request->input('create_time'));
|
||||
$news->browse_grant = $request->input('browse_grant');
|
||||
$news->keyword = $request->input('keyword', '');
|
||||
$news->abstract = $request->input('abstract', '');
|
||||
$news->content = $request->input('content', '');
|
||||
$news->lang = $request->input('lang', 'zh');
|
||||
$news->sorts = $request->input('sorts', 0);
|
||||
$result = $news->save();
|
||||
return $result ? $this->success('编辑成功!') : $this->error('编辑失败!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台删除新闻
|
||||
* @param $id 新闻ID
|
||||
* @param $togetherDel 同评论一起删除
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function del(Request $request, $id = 0, $togetherDel = 0)
|
||||
{
|
||||
//判断新闻对应评论是否一同删除
|
||||
$result = false;
|
||||
$s = 0;
|
||||
if($togetherDel) {
|
||||
DB::beginTransaction();
|
||||
NewsDiscuss::where('n_id', $id)->delete() && $s++;
|
||||
NewsModel::destroy($id) && $s++;
|
||||
$result = $s == 2;
|
||||
$result ? DB::commit() : DB::rollBack();
|
||||
} else {
|
||||
$result = NewsModel::destroy($id);
|
||||
}
|
||||
return $result ? $this->success('删除成功!') : $this->error('删除失败!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台新闻分类列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function cateIndex(Request $request)
|
||||
{
|
||||
$count = NewsCategory::count();
|
||||
$newsCate = self::newsCateList(10);
|
||||
$data = ['count' => $count, 'newsCate' => $newsCate];
|
||||
return view('admin.news.cateIndex', ['data'=> $data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX动态获取分类
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public function getCateList()
|
||||
{
|
||||
$newsCate = self::newsCateList();
|
||||
$count = $newsCate->count();
|
||||
$data = [
|
||||
'count' => $count,
|
||||
'cate' => $newsCate
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加新闻分类表单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function cateAdd(Request $request)
|
||||
{
|
||||
return view('admin.news.cateAdd');
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理添加分类数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public function postCateAdd(Request $request)
|
||||
{
|
||||
$cate = new NewsCategory();
|
||||
$this->validate($request, [
|
||||
'name' => 'required|min:1|max:128',
|
||||
]);
|
||||
$cate->name = $request->input('name', '');
|
||||
$cate->sorts = $request->input('sorts', 0);
|
||||
$cate->is_show = $request->input('is_show', 1);
|
||||
$result = $cate->save();
|
||||
return $result ? $this->success('添加成功!') : $this->error('添加失败!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑新闻分类表单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function cateEdit(Request $request, $id = 0)
|
||||
{
|
||||
$cate = NewsCategory::find($id);
|
||||
return view('admin.news.cateAdd', $cate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理编辑新闻分类数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function PostCateEdit(Request $request, $id = 0)
|
||||
{
|
||||
$cate = NewsCategory::find($id);
|
||||
$this->validate($request, [
|
||||
'name' => 'required|min:1|max:128',
|
||||
]);
|
||||
$cate->name = $request->input('name', '');
|
||||
$cate->sorts = $request->input('sorts', 0);
|
||||
$cate->is_show = $request->input('is_show', 1);
|
||||
$result = $cate->save();
|
||||
return $result ? $this->success('修改成功!') : $this->error('修改失败!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台删除新闻分类
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function cateDel(Request $request, $id = 0)
|
||||
{
|
||||
//需要先判断所属分类下是否有新闻
|
||||
$count = NewsModel::where('c_id', $id)->count();
|
||||
if($count > 0) {
|
||||
return $this->error('删除失败,原因:对应分类下有新闻!');
|
||||
} else {
|
||||
$result = NewsCategory::destroy($id);
|
||||
return $result ? $this->success('删除成功!') : $this->error('删除失败!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新闻评论列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function discussIndex(Request $request, $nId = 0)
|
||||
{
|
||||
$newsDiscuss = self::newsDiscussList($nId, 20);
|
||||
$news = NewsModel::find($nId);
|
||||
$data = [
|
||||
'news' => $news,
|
||||
'newsDiscuss' => $newsDiscuss
|
||||
];
|
||||
return view('admin.news.discussIndex', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX获取评论列表
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public function getDisscussList(Request $request, $nId = 0)
|
||||
{
|
||||
$count = NewsDiscuss::where('n_id', $nId)->count();
|
||||
$newsCate = self::newsDiscussList($nId);
|
||||
$data = [
|
||||
'count' => $count,
|
||||
'cate' => $newsCate
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换新闻评论显示状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function discussShowToggle(Request $request, $id = 0)
|
||||
{
|
||||
if($id !=0) {
|
||||
$discuss = NewsDiscuss::find($id);
|
||||
$discuss->status = 1 - intval($discuss->status);
|
||||
$result = $discuss->save();
|
||||
return $result ? $this->success('显示状态改变成功!') : $this->error('显示状态改变失败!');
|
||||
} else {
|
||||
return $this->error('ID传参错误');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除新闻评论
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public function discussDel(Request $request, $id = 0)
|
||||
{
|
||||
if($id !=0) {
|
||||
$result = NewsDiscuss::destroy($id);
|
||||
return $result ? $this->success('删除成功!') : $this->error('删除失败!');
|
||||
} else {
|
||||
return $this->error('ID传参错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Cache\RedisLock;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Http\Request;
|
||||
use App\PayUserInfo;
|
||||
|
||||
class PayController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view("admin.user.pay_info_log");
|
||||
}
|
||||
|
||||
public function payLog(Request $request){
|
||||
$limit = $request->get('limit', 10);
|
||||
$userId = $request->get('user_id', '');
|
||||
$status = $request->get('status', '');
|
||||
$start_time = $request->get('start_time', '');
|
||||
$end_time = $request->get('end_time', '');
|
||||
$list = PayUserInfo::where(function ($query) use ($userId) {
|
||||
if (!empty($userId)) {
|
||||
$query->where('user_id', $userId);
|
||||
}
|
||||
}) -> where(function ($query) use ($status) {
|
||||
if ($status != '') {
|
||||
$query->where('status', $status);
|
||||
}
|
||||
}) -> where(function ($query) use ($start_time) {
|
||||
if (!empty($start_time)) {
|
||||
$query->where('create_time', '>=', strtotime($start_time));
|
||||
}
|
||||
}) -> where(function ($query) use ($end_time) {
|
||||
if (!empty($end_time)) {
|
||||
$query->where('create_time', '<=', strtotime($end_time));
|
||||
}
|
||||
}) ->orderBy('id', 'asc') -> paginate($limit);
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
public function closeNofity(Request $request){
|
||||
$id = $request->get('id');
|
||||
$payUserInfo = PayUserInfo::where("id",$id) ->first();
|
||||
if (empty($payUserInfo)){
|
||||
return $this->error('数据信息错误');
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$payUserInfo -> notify_status = 1;
|
||||
$payUserInfo -> save();
|
||||
DB::commit();
|
||||
return $this->success("操作成功");
|
||||
} catch (\Exception $_var_6) {
|
||||
DB::rollBack();
|
||||
return $this->error("关闭通知失败".$_var_6);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\PrizePool;
|
||||
|
||||
class PrizePoolController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$scene_list = PrizePool::enumScene();
|
||||
return view('admin.prizepool.index')->with('scene_list', $scene_list);
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->input('limit', 10);
|
||||
$prize_pool = PrizePool::whereHas('toUser', function ($query) use ($request) {
|
||||
$account_number = $request->input('account_number');
|
||||
if ($account_number) {
|
||||
$query->where('account_number', $account_number)
|
||||
->orWhere('phone', $account_number)
|
||||
->orWhere('email', $account_number);
|
||||
}
|
||||
})->where(function ($query) use ($request) {
|
||||
$scene = $request->input('scene', -1);
|
||||
$start_time = strtotime($request->input('start_time', null));
|
||||
$end_time = strtotime($request->input('end_time', null));
|
||||
$scene != -1 && $query->where('scene', $scene);
|
||||
$start_time && $query->where('create_time', '>=', $start_time);
|
||||
$end_time && $query->where('create_time', '<=', $end_time);
|
||||
})->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($prize_pool);
|
||||
}
|
||||
|
||||
public function count(Request $request)
|
||||
{
|
||||
$count_data = PrizePool::selectRaw('1 as user_count')
|
||||
->selectRaw('sum(`reward_qty`) as reward_qty')
|
||||
->whereHas('toUser', function ($query) use ($request) {
|
||||
$account_number = $request->input('account_number');
|
||||
if ($account_number) {
|
||||
$query->where('account_number', $account_number)
|
||||
->orWhere('phone', $account_number)
|
||||
->orWhere('email', $account_number);
|
||||
}
|
||||
})->where(function ($query) use ($request) {
|
||||
$scene = $request->input('scene', -1);
|
||||
$start_time = strtotime($request->input('start_time', null));
|
||||
$end_time = strtotime($request->input('end_time', null));
|
||||
$scene != -1 && $query->where('scene', $scene);
|
||||
$start_time && $query->where('create_time', '>=', $start_time);
|
||||
$end_time && $query->where('create_time', '<=', $end_time);
|
||||
})->groupBy('to_user_id')->get();
|
||||
$user_count = $count_data->pluck('user_count')->sum();
|
||||
$reward_total = 0;
|
||||
$count_data->pluck('reward_qty')->each(function ($item, $key) use (&$reward_total) {
|
||||
$reward_total = bc_add($reward_total, $item);
|
||||
});
|
||||
return response()->json([
|
||||
'user_count' => $user_count,
|
||||
'reward_total' => $reward_total,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: 杨圣新
|
||||
* Date: 2018/10/26
|
||||
* Time: 16:39
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\Currency;
|
||||
use App\Robot;
|
||||
use App\Users;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class RobotController extends Controller
|
||||
{
|
||||
|
||||
public function start(){
|
||||
$id = request()->input('id', 0);
|
||||
$robot = Robot::find($id);
|
||||
switch ($robot->status){
|
||||
case 0:
|
||||
$robot->status = 1;
|
||||
break;
|
||||
case 1:
|
||||
$robot->status = 0;
|
||||
break;
|
||||
}
|
||||
$robot->save();
|
||||
return $this->success('保存成功');
|
||||
}
|
||||
/**添加一个机器人
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isMethod('GET')) {
|
||||
|
||||
$id = request()->input('id', 0);
|
||||
if (empty($id)) {
|
||||
$result = new Robot();
|
||||
} else {
|
||||
$result = Robot::find($id);
|
||||
}
|
||||
$currencies = Currency::where('is_display', 1)->orderBy('id', 'desc')->get();
|
||||
$legals = Currency::where('is_display', 1)->where('is_legal', 1)->orderBy('id', 'desc')->get();
|
||||
|
||||
return view('admin.robot.add')->with(['currencies' => $currencies, 'legals' => $legals, 'result' => $result]);
|
||||
}
|
||||
|
||||
if (request()->isMethod('POST')) {
|
||||
$data['buy_user'] = request()->input('buy_user', '');
|
||||
$data['sell_user'] = request()->input('sell_user', '');
|
||||
$data['currency_id'] = request()->input('currency_id', 0);
|
||||
$data['legal_id'] = request()->input('legal_id', 0);
|
||||
$data['number_max'] = request()->input('number_max', 0);
|
||||
$data['number_min'] = request()->input('number_min', 0);
|
||||
$data['second'] = request()->input('second', '');
|
||||
$data['float_number_up'] = request()->input('float_number_up', '0.00000');
|
||||
$data['float_number_down'] = request()->input('float_number_down', '0.00000');
|
||||
|
||||
foreach ($data as $v) if (!$v) return $this->error('请填写完整表单');
|
||||
|
||||
$buy_user = Users::where('phone', $data['buy_user'])->first();
|
||||
$sell_user = Users::where('phone', $data['sell_user'])->first();
|
||||
|
||||
if (!$buy_user) return $this->error('找不到买家');
|
||||
if (!$sell_user) return $this->error('找不到卖家');
|
||||
if (!is_numeric($data['number_max']) || !is_numeric($data['number_min'])) return $this->error('上下限只能是数字');
|
||||
if ($data['number_max'] < $data['number_min']) return $this->error('错误的上下限');
|
||||
if (!is_numeric($data['float_number_up']) || !is_numeric($data['float_number_down'])) return $this->error('价格浮动数只能是数字');
|
||||
if ($data['float_number_up'] < 0 || $data['float_number_down'] < 0) return $this->error('价格浮动数不能为负数');
|
||||
|
||||
|
||||
$id = request()->input('id', 0);
|
||||
|
||||
if ($id) {
|
||||
$robot = Robot::find($id);
|
||||
} else {
|
||||
$robot = new Robot();
|
||||
$robot->create_time = time();
|
||||
}
|
||||
|
||||
$data['sell'] = request()->input('sell', 0);
|
||||
$data['buy'] = request()->input('buy', 0);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$robot->buy_user_id = $buy_user->id;
|
||||
$robot->sell_user_id = $sell_user->id;
|
||||
$robot->currency_id = $data['currency_id'];
|
||||
$robot->legal_id = $data['legal_id'];
|
||||
$robot->number_max = $data['number_max'];
|
||||
$robot->number_min = $data['number_min'];
|
||||
$robot->second = $data['second'];
|
||||
$robot->float_number_down = $data['float_number_down'];
|
||||
$robot->float_number_up = $data['float_number_up'];
|
||||
$robot->sell = $data['sell'];
|
||||
$robot->buy = $data['buy'];
|
||||
|
||||
$info = $robot->save();
|
||||
if (!$info) throw new \Exception('保存失败');
|
||||
|
||||
DB::commit();
|
||||
return $this->success('保存成功');
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**返回页面
|
||||
*
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
return view('admin.robot.list');
|
||||
}
|
||||
|
||||
/**返回列表数据
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function listData()
|
||||
{
|
||||
$limit = request()->input('limit', 10);
|
||||
$list = Robot::paginate($limit);
|
||||
return $this->layuiData($list);
|
||||
}
|
||||
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$id = request()->input('id', 0);
|
||||
$robot = Robot::find($id);
|
||||
|
||||
if (!$robot) return $this->error('找不到这个机器人');
|
||||
|
||||
if ($robot->status == Robot::START) return $this->error('机器人正在运行,不能删除');
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$info = $robot->delete();
|
||||
if (!$info) throw new \Exception('删除失败');
|
||||
|
||||
DB::commit();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Bank;
|
||||
use App\Currency;
|
||||
use App\LegalDeal;
|
||||
use App\LegalDealSend;
|
||||
use App\Seller;
|
||||
use App\UserReal;
|
||||
use App\Users;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
class SellerController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view("admin.seller.index");
|
||||
}
|
||||
public function status(Request $request)
|
||||
{
|
||||
$EWLCuXv = $request->get("id", 0);
|
||||
$VslANFv = Seller::find($EWLCuXv);
|
||||
if (empty($VslANFv)) {
|
||||
return $this->error("参数错误");
|
||||
}
|
||||
if ($VslANFv->status == 1) {
|
||||
$VslANFv->status = 0;
|
||||
} else {
|
||||
$VslANFv->status = 1;
|
||||
}
|
||||
try {
|
||||
$VslANFv->save();
|
||||
return $this->success("操作成功");
|
||||
} catch (\Exception $MBiuMjv) {
|
||||
return $this->error($MBiuMjv->getMessage());
|
||||
}
|
||||
}
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$mOViITQ = $request->get("limit", 10);
|
||||
$PVVHhIv = $request->get("account_number", "");
|
||||
$lSZwmpQ = new Seller();
|
||||
if (!empty($PVVHhIv)) {
|
||||
$wBUciPQ = Users::where("account_number", "like", "%" . $PVVHhIv . "%")->get()->pluck("id");
|
||||
$lSZwmpQ = $lSZwmpQ->whereIn("user_id", $wBUciPQ);
|
||||
}
|
||||
$lSZwmpQ = $lSZwmpQ->orderBy("id", "desc")->paginate($mOViITQ);
|
||||
return $this->layuiData($lSZwmpQ);
|
||||
}
|
||||
public function add(Request $request)
|
||||
{
|
||||
$wzCTTIQ = $request->get("id", 0);
|
||||
if (empty($wzCTTIQ)) {
|
||||
$bSHyBhv = new Seller();
|
||||
$bSHyBhv->create_time = time();
|
||||
} else {
|
||||
$bSHyBhv = Seller::find($wzCTTIQ);
|
||||
}
|
||||
$sYOdeDQ = Bank::all();
|
||||
$ZlIsRIv = Currency::where("is_legal", 1)->orderBy("id", "desc")->get();
|
||||
return view("admin.seller.add")->with(["result" => $bSHyBhv, "banks" => $sYOdeDQ, "currencies" => $ZlIsRIv]);
|
||||
}
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
$sYwmMfv = $request->get("id", 0);
|
||||
$ElrRcJv = $request->get("account_number", "");
|
||||
$lhxBpkJ = $request->get("name", "");
|
||||
$lHYNMJv = $request->get("mobile", "");
|
||||
$GlYdHdJ = $request->get("currency_id", "");
|
||||
$LIltKOQ = $request->get("wechat_nickname", "");
|
||||
$ZpUjYWv = $request->get("wechat_account", "");
|
||||
$UrCMwzJ = $request->get("ali_nickname", "");
|
||||
$yBzscSQ = $request->get("ali_account", "");
|
||||
$jUDYFGv = $request->get("bank_account", "");
|
||||
$iElciLQ = $request->get("bank_address", "");
|
||||
$ZivQULJ = $request->get("bank_name", "");
|
||||
$LlQbUxJ = ["required" => ":attribute 为必填字段"];
|
||||
$NhGlCFQ = Validator::make($request->all(), ["account_number" => "required", "name" => "required", "mobile" => "required", "currency_id" => "required", "wechat_account" => "required", "ali_account" => "required", "bank_account" => "required", "bank_address" => "required", "bank_name" => "required"], $LlQbUxJ);
|
||||
if ($NhGlCFQ->fails()) {
|
||||
return $this->error($NhGlCFQ->errors()->first());
|
||||
}
|
||||
$xDIOduJ = Users::where("account_number", $ElrRcJv)->first();
|
||||
if (empty($xDIOduJ)) {
|
||||
return $this->error("找不到此交易账号的用户");
|
||||
}
|
||||
$WgatXjQ = UserReal::where("user_id", $xDIOduJ->id)->where("review_status", 2)->first();
|
||||
if (empty($WgatXjQ)) {
|
||||
return $this->error("此用户还未通过实名认证");
|
||||
}
|
||||
$RXmFpAQ = Currency::find($GlYdHdJ);
|
||||
if (empty($RXmFpAQ)) {
|
||||
return $this->error("币种不存在");
|
||||
}
|
||||
if (empty($RXmFpAQ->is_legal)) {
|
||||
return $this->error("该币不是法币");
|
||||
}
|
||||
$YCUGrXv = Seller::where("name", $lhxBpkJ)->where("user_id", "!=", $xDIOduJ->id)->where("currency_id", $GlYdHdJ)->first();
|
||||
if (empty($sYwmMfv) && !empty($YCUGrXv)) {
|
||||
return $this->error("此法币 " . $lhxBpkJ . " 商家名称已存在");
|
||||
}
|
||||
$FrqBwlQ = Seller::where("user_id", $xDIOduJ->id)->where("currency_id", $GlYdHdJ)->first();
|
||||
if (!empty($FrqBwlQ) && empty($sYwmMfv)) {
|
||||
return $this->error("此用户已是此法币商家");
|
||||
}
|
||||
if (empty($sYwmMfv)) {
|
||||
$ctlmbJQ = new Seller();
|
||||
$ctlmbJQ->create_time = time();
|
||||
} else {
|
||||
$ctlmbJQ = Seller::find($sYwmMfv);
|
||||
}
|
||||
$JYlcgxv = Bank::where("name", $ZivQULJ)->first();
|
||||
if ($JYlcgxv) {
|
||||
$GzlYeZJ = $JYlcgxv->id;
|
||||
} else {
|
||||
$AMBtlKv = new Bank();
|
||||
$GzlYeZJ = $AMBtlKv->insertGetId(["name" => $ZivQULJ]);
|
||||
}
|
||||
$ctlmbJQ->user_id = $xDIOduJ->id;
|
||||
$ctlmbJQ->name = $lhxBpkJ;
|
||||
$ctlmbJQ->mobile = $lHYNMJv;
|
||||
$ctlmbJQ->currency_id = $GlYdHdJ;
|
||||
$ctlmbJQ->wechat_nickname = $LIltKOQ;
|
||||
$ctlmbJQ->wechat_account = $ZpUjYWv;
|
||||
$ctlmbJQ->ali_nickname = $UrCMwzJ;
|
||||
$ctlmbJQ->ali_account = $yBzscSQ;
|
||||
$ctlmbJQ->bank_id = intval($GzlYeZJ);
|
||||
$ctlmbJQ->bank_account = $jUDYFGv;
|
||||
$ctlmbJQ->bank_address = $iElciLQ;
|
||||
$ctlmbJQ->status = 1;
|
||||
try {
|
||||
$ctlmbJQ->save();
|
||||
return $this->success("操作成功");
|
||||
} catch (\Exception $OLncirv) {
|
||||
return $this->error($OLncirv->getMessage());
|
||||
}
|
||||
}
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$CMGNquQ = $request->get("id", 0);
|
||||
$zULfAdQ = Seller::find($CMGNquQ);
|
||||
if (empty($zULfAdQ)) {
|
||||
return $this->error("无此用户");
|
||||
}
|
||||
try {
|
||||
$zULfAdQ->delete();
|
||||
return $this->success("删除成功");
|
||||
} catch (\Exception $nXnYPCJ) {
|
||||
return $this->error($nXnYPCJ->getMessage());
|
||||
}
|
||||
}
|
||||
public function sendBack(Request $request)
|
||||
{
|
||||
$nffuTUJ = $request->get("id", 0);
|
||||
if (empty($nffuTUJ)) {
|
||||
return $this->error("参数错误");
|
||||
}
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$EazxunJ = LegalDealSend::lockForUpdate()->find($nffuTUJ);
|
||||
if (empty($EazxunJ)) {
|
||||
DB::rollback();
|
||||
return $this->error("无此记录");
|
||||
}
|
||||
if ($EazxunJ->is_shelves != 2) {
|
||||
throw new \Exception("必须下架后才可以撤销");
|
||||
}
|
||||
if ($EazxunJ->is_done != 0) {
|
||||
throw new \Exception("当前发布状态无法撤销");
|
||||
}
|
||||
if (bc_comp($EazxunJ->surplus_number) <= 0) {
|
||||
throw new \Exception("当前发布剩余数量不足,无法撤销");
|
||||
}
|
||||
LegalDealSend::sendBack($nffuTUJ);
|
||||
DB::commit();
|
||||
return $this->success("发布撤回成功,此发布改变为已完成状态");
|
||||
} catch (\Exception $sCvTfzJ) {
|
||||
DB::rollback();
|
||||
return $this->error($sCvTfzJ->getMessage());
|
||||
}
|
||||
}
|
||||
public function sendDel(Request $request)
|
||||
{
|
||||
$PWlKXSv = $request->get("id", 0);
|
||||
if (empty($PWlKXSv)) {
|
||||
return $this->error("参数错误");
|
||||
}
|
||||
$HyztDwQ = LegalDealSend::isHasIncompleteness($PWlKXSv);
|
||||
if ($HyztDwQ) {
|
||||
return $this->error("该发布信息下有未完成订单,请先运行撤回发布再来删除");
|
||||
}
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$XNldeIJ = LegalDealSend::lockForUpdate()->find($PWlKXSv);
|
||||
if (empty($XNldeIJ)) {
|
||||
return $this->error("无此记录");
|
||||
}
|
||||
$UZfwGZQ = LegalDeal::where("legal_deal_send_id", $PWlKXSv)->get();
|
||||
if (!empty($UZfwGZQ)) {
|
||||
foreach ($UZfwGZQ as $XilJuhv) {
|
||||
$XilJuhv->delete();
|
||||
}
|
||||
}
|
||||
if ($XNldeIJ->type == "sell") {
|
||||
if ($XNldeIJ->surplus_number > 0) {
|
||||
$GhxsTBJ = Seller::lockForUpdate()->find($XNldeIJ->seller_id);
|
||||
if (!empty($GhxsTBJ)) {
|
||||
$cTAvPXv = $GhxsTBJ->user_id;
|
||||
$egjCciv = UsersWallet::lockForUpdate()->where("user_id", $cTAvPXv)->where("currency", $GhxsTBJ->currency_id)->first();
|
||||
$NelPScQ = change_wallet_balance($egjCciv, 1, -$XNldeIJ->surplus_number, AccountLog::SELLER_BACK_SEND, "系统删除", true);
|
||||
if ($NelPScQ !== true) {
|
||||
throw new \Exception("删除失败:减少冻结资金失败");
|
||||
}
|
||||
$uhhTkFv = change_wallet_balance($egjCciv, 1, $XNldeIJ->surplus_number, AccountLog::SELLER_BACK_SEND, "系统删除");
|
||||
if ($uhhTkFv !== true) {
|
||||
throw new \Exception("删除失败:增加余额失败");
|
||||
}
|
||||
$GhxsTBJ->lock_seller_balance = bc_sub($GhxsTBJ->lock_seller_balance, $XNldeIJ->surplus_number, 5);
|
||||
$GhxsTBJ->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
$XNldeIJ->delete();
|
||||
DB::commit();
|
||||
return $this->success("删除成功");
|
||||
} catch (\Exception $fnqRLxJ) {
|
||||
DB::rollback();
|
||||
return $this->error($fnqRLxJ->getMessage());
|
||||
}
|
||||
}
|
||||
public function is_shelves(Request $request)
|
||||
{
|
||||
$PkBDliJ = $request->get("id", 0);
|
||||
$XAqRljJ = $request->get("is_shelves", 1);
|
||||
if (empty($PkBDliJ)) {
|
||||
return $this->error("参数错误");
|
||||
}
|
||||
$iZKliEv = LegalDealSend::find($PkBDliJ);
|
||||
if (empty($iZKliEv)) {
|
||||
return $this->error("无此记录");
|
||||
}
|
||||
if (empty($iZKliEv->is_shelves)) {
|
||||
$iZKliEv->is_shelves = 1;
|
||||
$iZKliEv->save();
|
||||
}
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
if ($iZKliEv->is_shelves == 1) {
|
||||
$iZKliEv->is_shelves = 2;
|
||||
} elseif ($iZKliEv->is_shelves == 2) {
|
||||
$iZKliEv->is_shelves = 1;
|
||||
}
|
||||
$iZKliEv->save();
|
||||
DB::commit();
|
||||
return $this->success("操作成功");
|
||||
} catch (\Exception $BIZQdDJ) {
|
||||
DB::rollback();
|
||||
return $this->error($BIZQdDJ->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Setting;
|
||||
use App\ReceivingBankCard;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class SettingController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$settingList = Setting::all()->toArray();
|
||||
$setting = [];
|
||||
foreach ($settingList as $key => $value) {
|
||||
$setting[$value['key']] = $value['value'];
|
||||
}
|
||||
// $receivingList = ReceivingBankCard::all();
|
||||
return view('admin.setting.base', ['setting' => $setting]);
|
||||
}
|
||||
|
||||
public function bankCard(Request $request){
|
||||
$limit = $request->get('limit', 10);
|
||||
$list = ReceivingBankCard::orderBy('id','desc') -> paginate($limit);
|
||||
return response()->json(['code' => 0, 'data' => $list->items(), 'count' => $list->total()]);
|
||||
}
|
||||
|
||||
public function bankAdd(Request $request){
|
||||
if ($request->isMethod('post')) {
|
||||
try {
|
||||
$receivingBankCard = new ReceivingBankCard();
|
||||
$receivingBankCard -> currency_logo = Input::get('currency_logo', '');
|
||||
$receivingBankCard -> currency_name = Input::get('currency_name', '');
|
||||
$receivingBankCard -> pay_way_name = Input::get('pay_way_name', '');
|
||||
$receivingBankCard -> commissions = Input::get('commissions', '');
|
||||
$receivingBankCard -> account_name = Input::get('account_name', '');
|
||||
$receivingBankCard -> iban = Input::get('iban', '');
|
||||
$receivingBankCard -> beneficiary_country = Input::get('beneficiary_country', '');
|
||||
$receivingBankCard -> bank_code = Input::get('bank_code', '');
|
||||
$receivingBankCard -> bank_name = Input::get('bank_name', '');
|
||||
$receivingBankCard -> bank_address = Input::get('bank_address', '');
|
||||
$receivingBankCard->save();
|
||||
}catch (\Exception $ex){
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
return $this->success('添加成功');
|
||||
}else{
|
||||
return view('admin.setting.bankAdd');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function editBankCard(Request $request){
|
||||
$id = $request->get('id');
|
||||
$bankCard = ReceivingBankCard::where("id", $id)->first();
|
||||
if ($request->isMethod('post')) {
|
||||
try {
|
||||
$bankCard -> currency_logo = Input::get('currency_logo', '');
|
||||
$bankCard -> currency_name = Input::get('currency_name', '');
|
||||
$bankCard -> pay_way_name = Input::get('pay_way_name', '');
|
||||
$bankCard -> commissions = Input::get('commissions', '');
|
||||
$bankCard -> account_name = Input::get('account_name', '');
|
||||
$bankCard -> iban = Input::get('iban', '');
|
||||
$bankCard -> beneficiary_country = Input::get('beneficiary_country', '');
|
||||
$bankCard -> bank_code = Input::get('bank_code', '');
|
||||
$bankCard -> bank_name = Input::get('bank_name', '');
|
||||
$bankCard -> bank_address = Input::get('bank_address', '');
|
||||
$bankCard->save();
|
||||
}catch (\Exception $ex){
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
return $this->success('编辑成功');
|
||||
}else{
|
||||
return view('admin.setting.bankEdit',['bankCard' => $bankCard]);
|
||||
}
|
||||
}
|
||||
|
||||
public function delBankCard(Request $request){
|
||||
$id = $request->get('id');
|
||||
$bankCard = ReceivingBankCard::where("id", $id)->first();
|
||||
if (empty($bankCard)) {
|
||||
$this->error("信息未找到");
|
||||
}
|
||||
try {
|
||||
$bankCard->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $ex) {
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function index_second(){
|
||||
$settingList = Setting::all()->toArray();
|
||||
$setting = [];
|
||||
foreach ($settingList as $key => $value) {
|
||||
$setting[$value['key']] = $value['value'];
|
||||
}
|
||||
// var_dump($setting);
|
||||
return view('admin.setting.index_second', ['setting' => $setting]);
|
||||
}
|
||||
|
||||
public function dataSetting()
|
||||
{
|
||||
$settingList = Setting::all()->toArray();
|
||||
$setting = [];
|
||||
foreach ($settingList as $key => $value) {
|
||||
$setting[$value['key']] = $value['value'];
|
||||
}
|
||||
return view('admin.setting.data', ['setting' => $setting]);
|
||||
}
|
||||
|
||||
public function postAdd(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
$generation = $request->input('generation');
|
||||
$reward_ratio = $request->input('reward_ratio');
|
||||
$need_has_trades = $request->input('need_has_trades');
|
||||
unset($data['generation'], $data['reward_ratio'], $data['need_has_trades']);
|
||||
$lever_fee_options = compact('generation', 'reward_ratio', 'need_has_trades');
|
||||
$lever_fee_options = make_multi_array(['generation', 'reward_ratio', 'need_has_trades'], count($generation), $lever_fee_options);
|
||||
|
||||
$generation = array_column($lever_fee_options, 'generation');
|
||||
$reward_ratio = array_column($lever_fee_options, 'reward_ratio');
|
||||
array_multisort($generation, SORT_ASC, SORT_NUMERIC, $lever_fee_options);
|
||||
|
||||
$data['lever_fee_options'] = serialize($lever_fee_options);
|
||||
try {
|
||||
foreach ($data as $key => $value) {
|
||||
$setting = Setting::where('key', $key)->first();
|
||||
|
||||
if (!$setting) {
|
||||
$setting = new Setting();
|
||||
$setting->key = $key;
|
||||
}
|
||||
|
||||
$setting->value = $value;
|
||||
$setting->save();
|
||||
}
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function dogeneralaccount(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
foreach ($data as $key => $value) {
|
||||
switch ($key) {
|
||||
case 'contract_address':
|
||||
break;
|
||||
case 'total_account_address':
|
||||
break;
|
||||
case 'total_account_key':
|
||||
break;
|
||||
}
|
||||
Setting::updateValueByKey($key, $value);
|
||||
}
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class SettingsController extends Controller{
|
||||
|
||||
public function index(){
|
||||
$bouns = Setting::getValueByKey('user_bonus');
|
||||
$ecology = Setting::getValueByKey('ecology_bonus');
|
||||
$bonus = json_decode($bouns);
|
||||
$ecology = json_decode($ecology);
|
||||
return view('admin.settings.index',['bouns'=>$bonus,'ecology'=>$ecology]);
|
||||
}
|
||||
public function base()
|
||||
{
|
||||
$rate_exchange = Setting::getValueByKey('rate_exchange');
|
||||
$company_eth_address = Setting::getValueByKey('company_eth_address');
|
||||
$lock_daily_return = Setting::getValueByKey('lock_daily_return');
|
||||
$version = Setting::getValueByKey('version','1.0');
|
||||
$transaction_fee = Setting::getValueByKey('transaction_fee',[]);
|
||||
$transaction_fee = @json_decode($transaction_fee,true);
|
||||
|
||||
$results = array(
|
||||
'rate_exchange' => $rate_exchange,
|
||||
'lock_daily_return' => $lock_daily_return,
|
||||
'company_eth_address' => $company_eth_address,
|
||||
'version' => $version,
|
||||
);
|
||||
return view('admin.settings.base', ['results' => $results,"transaction_fee"=>$transaction_fee]);
|
||||
}
|
||||
public function setBase(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
|
||||
$transaction_fee = array(
|
||||
"service_one_min"=>$data["service_one_min"],
|
||||
"service_one_max"=>$data["service_one_max"],
|
||||
"service_one_proportion"=>$data["service_one_proportion"],
|
||||
"service_two_min"=>$data["service_two_min"],
|
||||
"service_two_max"=>$data["service_two_max"],
|
||||
"service_two_proportion"=>$data["service_two_proportion"],
|
||||
"service_three_min"=>$data["service_three_min"],
|
||||
"service_three_max"=>$data["service_three_max"],
|
||||
"service_three_proportion"=>$data["service_three_proportion"],
|
||||
);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (isset($transaction_fee[$key])){
|
||||
continue;
|
||||
}
|
||||
switch ($key) {
|
||||
case 'rate_exchange':
|
||||
break;
|
||||
case 'company_eth_address':
|
||||
break;
|
||||
case 'lock_daily_return':
|
||||
break;
|
||||
case 'version':
|
||||
break;
|
||||
}
|
||||
Setting::updateValueByKey($key, $value);
|
||||
}
|
||||
|
||||
$transaction_fee = json_encode($transaction_fee);
|
||||
Setting::updateValueByKey("transaction_fee", $transaction_fee);
|
||||
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
public function Insert(){
|
||||
$bouns = Input::get('bonus','');
|
||||
$total_arr = Input::get('total_arr','');
|
||||
$ecology = Input::get('ecology','');
|
||||
$ecology_arr = Input::get('ecology_arr','');
|
||||
|
||||
$total_arr = json_encode($total_arr);
|
||||
$ecology_arr = json_encode($ecology_arr);
|
||||
|
||||
if(empty($bouns) || empty($total_arr)){
|
||||
return $this->error('日均收益参数错误');
|
||||
}
|
||||
if(empty($ecology) || empty($ecology_arr)){
|
||||
return $this->error('推广奖励参数错误');
|
||||
}
|
||||
// $first_result = Setting::where('key',$bouns)->where('value',$total_arr)->first();
|
||||
// if(!empty($first_result)){
|
||||
// return $this->success('已设置过该奖金');
|
||||
// }
|
||||
// $second_result = Setting::where('key',$ecology)->where('value',$ecology_arr)->first();
|
||||
// if(!empty($second_result)){
|
||||
// return $this->success('已设置过该推广奖励');
|
||||
// }
|
||||
try{
|
||||
Setting::updateValueByKey($bouns,$total_arr);
|
||||
Setting::updateValueByKey($ecology,$ecology_arr);
|
||||
return $this->success('设置成功');
|
||||
}catch (\Exception $e){
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use App\ChargeReq;
|
||||
use App\MicroOrder;
|
||||
use App\UsersWalletOut;
|
||||
use App\CoinTrade;
|
||||
use App\LeverTransaction;
|
||||
use App\UserReal;
|
||||
use App\PayUserInfo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TipsController extends Controller
|
||||
{
|
||||
public function tips(Request $request)
|
||||
{
|
||||
$type = $request->get('type');
|
||||
|
||||
// if ($type == 1){
|
||||
// $count = CoinTrade::where('status',1)->count();
|
||||
|
||||
// $code = $count == 0 ? 200 : 100;
|
||||
|
||||
// return ['code'=>$code,'type'=>$type];
|
||||
// }
|
||||
|
||||
// if ($type == 2){
|
||||
// $count = CoinTrade::where('status',1)->count();
|
||||
|
||||
// $code = $count == 0 ? 200 : 100;
|
||||
|
||||
// return ['code'=>$code,'type'=>$type];
|
||||
// }
|
||||
if ($type == 3){
|
||||
|
||||
$count = MicroOrder::whereHas('user')->where('status',1)->count();
|
||||
|
||||
$code = $count == 0 ? 200 : 100;
|
||||
|
||||
return ['code'=>$code,'type'=>$type];
|
||||
}
|
||||
|
||||
if ($type == 6){
|
||||
|
||||
$count = ChargeReq::whereHas('user')->where('status',1)->count();
|
||||
|
||||
$code = $count == 0 ? 200 : 100;
|
||||
|
||||
return ['code'=>$code,'type'=>$type];
|
||||
}
|
||||
|
||||
if ($type == 7){
|
||||
|
||||
$count = UserReal::whereHas('user')->where('review_status',1)->count();
|
||||
|
||||
$code = $count == 0 ? 200 : 100;
|
||||
|
||||
return ['code'=>$code,'type'=>$type];
|
||||
}
|
||||
|
||||
if ($type == 8){
|
||||
$count = UsersWalletOut::whereHas('user')->where('status',1)->count();
|
||||
|
||||
$code = $count == 0 ? 200 : 100;
|
||||
|
||||
return ['code'=>$code,'type'=>$type];
|
||||
}
|
||||
|
||||
if($type == 99){
|
||||
$count = PayUserInfo::where('notify_status',0) -> where('status',1) ->count();
|
||||
$code = $count == 0 ? 200 : 100;
|
||||
return ['code'=>$code,'type'=>$type];
|
||||
}
|
||||
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Agent;
|
||||
use App\AgentMoneylog;
|
||||
use App\Setting;
|
||||
use App\AccountLog;
|
||||
use App\Transaction;
|
||||
use App\TransactionComplete;
|
||||
use App\TransactionIn;
|
||||
use App\TransactionOut;
|
||||
use App\Users;
|
||||
use App\Currency;
|
||||
use App\LeverTransaction;
|
||||
use App\TransactionOrder;
|
||||
use App\TransactionOrdercopy;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
class TransactionController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$_var_0 = Currency::all();
|
||||
return view("admin.transaction.index", ["currency" => $_var_0]);
|
||||
}
|
||||
public function lists()
|
||||
{
|
||||
$_var_1 = Input::get("limit", 10);
|
||||
$_var_2 = Input::get("account_number", "");
|
||||
$_var_3 = Input::get("type", "");
|
||||
$_var_4 = Input::get("currency", "");
|
||||
$_var_5 = Input::get("status", "");
|
||||
$_var_6 = new Transaction();
|
||||
if (!empty($_var_2)) {
|
||||
$users = Users::where("account_number", "like", "%" . $_var_2 . "%")->get()->pluck("id");
|
||||
$_var_6 = $_var_6->where(function ($query) use($users) {
|
||||
$query->whereIn("from_user_id", $users);
|
||||
});
|
||||
}
|
||||
if (!empty($_var_3)) {
|
||||
$_var_6 = $_var_6->where("type", "=", $_var_3);
|
||||
}
|
||||
if (!empty($_var_4)) {
|
||||
$_var_6 = $_var_6->where("currency", $_var_4);
|
||||
}
|
||||
if (!empty($_var_5)) {
|
||||
$_var_6 = $_var_6->where("status", $_var_5);
|
||||
}
|
||||
$_var_7 = $_var_6->orderBy("id", "desc")->paginate($_var_1);
|
||||
return response()->json(["code" => 0, "data" => $_var_7->items(), "count" => $_var_7->total()]);
|
||||
}
|
||||
public function completeIndex()
|
||||
{
|
||||
return view("admin.transaction.complete");
|
||||
}
|
||||
public function inIndex()
|
||||
{
|
||||
return view("admin.transaction.in");
|
||||
}
|
||||
public function outIndex()
|
||||
{
|
||||
return view("admin.transaction.out");
|
||||
}
|
||||
public function cnyIndex()
|
||||
{
|
||||
return view("admin.transaction.cny");
|
||||
}
|
||||
public function completeList(Request $request)
|
||||
{
|
||||
$_var_8 = $request->get("limit", 10);
|
||||
$_var_9 = $request->get("account_number", "");
|
||||
$_var_10 = new TransactionComplete();
|
||||
if (!empty($_var_9)) {
|
||||
$_var_11 = Users::where("account_number", "like", "%" . $_var_9 . "%")->get()->pluck("id");
|
||||
$_var_10 = $_var_10->whereIn("user_id", $_var_11);
|
||||
}
|
||||
$_var_10 = $_var_10->orderBy("id", "desc")->paginate($_var_8);
|
||||
return $this->layuiData($_var_10);
|
||||
}
|
||||
public function inList(Request $request)
|
||||
{
|
||||
$_var_12 = $request->get("limit", 10);
|
||||
$_var_13 = $request->get("account_number", "");
|
||||
$_var_14 = new TransactionIn();
|
||||
if (!empty($_var_13)) {
|
||||
$_var_15 = Users::where("account_number", "like", "%" . $_var_13 . "%")->get()->pluck("id");
|
||||
$_var_14 = $_var_14->whereIn("user_id", $_var_15);
|
||||
}
|
||||
$_var_14 = $_var_14->orderBy("id", "desc")->paginate($_var_12);
|
||||
return $this->layuiData($_var_14);
|
||||
}
|
||||
public function outList(Request $request)
|
||||
{
|
||||
$_var_16 = $request->get("limit", 10);
|
||||
$_var_17 = $request->get("account_number", "");
|
||||
$_var_18 = new TransactionOut();
|
||||
if (!empty($_var_17)) {
|
||||
$_var_19 = Users::where("account_number", "like", "%" . $_var_17 . "%")->get()->pluck("id");
|
||||
$_var_18 = $_var_18->whereIn("user_id", $_var_19);
|
||||
}
|
||||
$_var_18 = $_var_18->orderBy("id", "desc")->paginate($_var_16);
|
||||
return $this->layuiData($_var_18);
|
||||
}
|
||||
public function cnyList(Request $request)
|
||||
{
|
||||
$_var_20 = $request->get("limit", 10);
|
||||
$_var_21 = $request->get("account_number", "");
|
||||
$_var_22 = new AccountLog();
|
||||
if (!empty($_var_21)) {
|
||||
$_var_23 = Users::where("account_number", "like", "%" . $_var_21 . "%")->get()->pluck("id");
|
||||
$_var_22 = $_var_22->whereIn("user_id", $_var_23);
|
||||
}
|
||||
$_var_24 = array(13, 14, 15, 20, 22, 24);
|
||||
$_var_22 = $_var_22->whereIn("type", $_var_24)->orderBy("id", "desc")->paginate($_var_20);
|
||||
return $this->layuiData($_var_22);
|
||||
}
|
||||
public function Leverdeals_show()
|
||||
{
|
||||
return view("admin.leverdeals.list");
|
||||
}
|
||||
public function Leverdeals(Request $request)
|
||||
{
|
||||
$_var_25 = $request->input("limit", 20);
|
||||
$id = $request->input("id", 0);
|
||||
$username = $request->input("phone", "");
|
||||
$status = $request->input("status", 10);
|
||||
$type = $request->input("type", 0);
|
||||
$legal_id = $request->input("legal_id", -1);
|
||||
$start = $request->input("start", "");
|
||||
$end = $request->input("end", "");
|
||||
$_var_26 = LeverTransaction::whereHas("user", function ($query) use($username) {
|
||||
$username != "" && $query->where("account_number", $username)->orWhere("id", $username);
|
||||
})->where(function ($query) use($id, $status, $type, $legal_id) {
|
||||
$id != 0 && $query->where("id", $id);
|
||||
$legal_id != -1 && $query->where("legal", $legal_id);
|
||||
$status != 10 && in_array($status, [LeverTransaction::ENTRUST, LeverTransaction::BUY, LeverTransaction::CLOSED, LeverTransaction::CANCEL, LeverTransaction::CLOSING]) && $query->where("status", $status);
|
||||
$type > 0 && in_array($type, [1, 2]) && $query->where("type", $type);
|
||||
})->where(function ($query) use($start, $end) {
|
||||
!empty($start) && $query->where("create_time", ">=", strtotime($start . " 0:0:0"));
|
||||
!empty($end) && $query->where("create_time", "<=", strtotime($end . " 23:59:59"));
|
||||
});
|
||||
$_var_27 = clone $_var_26;
|
||||
$_var_28 = $_var_27->select([DB::raw("SUM((CASE `type` WHEN 1 THEN `update_price` - `price` WHEN 2 THEN `price` - `update_price` END) * `number`* `multiple`) AS `balance1`"), DB::raw("sum(origin_caution_money) as balance2"), DB::raw("sum(trade_fee) as balance3")])->first();
|
||||
$_var_28 && ($_var_28 = $_var_28->setAppends([]));
|
||||
$_var_29 = $_var_26->orderBy("id", "desc")->paginate($_var_25);
|
||||
$_var_30 = $_var_29->getCollection();
|
||||
$_var_30->transform(function ($item, $key) {
|
||||
$item->setAppends(["symbol", "account_number", "profits", "time"]);
|
||||
return $item;
|
||||
});
|
||||
return $this->layuiData($_var_29, ["total" => $_var_28]);
|
||||
}
|
||||
public function csv(Request $request)
|
||||
{
|
||||
$_var_31 = $request->input("id", 0);
|
||||
$_var_32 = $request->input("phone", "");
|
||||
$_var_33 = $request->input("status", 10);
|
||||
$_var_34 = $request->input("type", 0);
|
||||
$_var_35 = $request->input("start", "");
|
||||
$_var_36 = $request->input("end", "");
|
||||
$_var_37 = [];
|
||||
if ($_var_31 > 0) {
|
||||
$_var_37[] = ["lever_transaction.id", "=", $_var_31];
|
||||
}
|
||||
if (!empty($_var_32)) {
|
||||
$_var_38 = DB::table("users")->where("account_number", $_var_32)->first();
|
||||
if ($_var_38 !== null) {
|
||||
$_var_37[] = ["lever_transaction.user_id", "=", $_var_38->id];
|
||||
}
|
||||
}
|
||||
if ($_var_33 != 10 && in_array($_var_33, [LeverTransaction::ENTRUST, LeverTransaction::BUY, LeverTransaction::CLOSED, LeverTransaction::CANCEL, LeverTransaction::CLOSING])) {
|
||||
$_var_37[] = ["lever_transaction.status", "=", $_var_33];
|
||||
}
|
||||
if ($_var_34 > 0 && in_array($_var_34, [1, 2])) {
|
||||
$_var_37[] = ["type", "=", $_var_34];
|
||||
}
|
||||
if (!empty($_var_35) && !empty($_var_36)) {
|
||||
$_var_37[] = ["lever_transaction.create_time", ">", strtotime($_var_35 . " 0:0:0")];
|
||||
$_var_37[] = ["lever_transaction.create_time", "<", strtotime($_var_36 . " 23:59:59")];
|
||||
}
|
||||
$_var_39 = TransactionOrdercopy::leftjoin("users", "lever_transaction.user_id", "=", "users.id")->select("lever_transaction.*", "users.phone")->whereIn("lever_transaction.status", [LeverTransaction::ENTRUST, LeverTransaction::BUY, LeverTransaction::CLOSED, LeverTransaction::CANCEL, LeverTransaction::CLOSING])->where($_var_37)->get();
|
||||
foreach ($_var_39 as $_var_40 => $_var_41) {
|
||||
$_var_39[$_var_40]["create_time"] = date("Y-m-d H:i:s", $_var_41->create_time);
|
||||
$_var_39[$_var_40]["transaction_time"] = date("Y-m-d H:i:s", substr($_var_41->transaction_time, 0, strpos($_var_41->transaction_time, ".")));
|
||||
$_var_39[$_var_40]["update_time"] = date("Y-m-d H:i:s", substr($_var_41->update_time, 0, strpos($_var_41->update_time, ".")));
|
||||
$_var_39[$_var_40]["handle_time"] = date("Y-m-d H:i:s", substr($_var_41->handle_time, 0, strpos($_var_41->handle_time, ".")));
|
||||
$_var_39[$_var_40]["complete_time"] = date("Y-m-d H:i:s", substr($_var_41->complete_time, 0, strpos($_var_41->complete_time, ".")));
|
||||
}
|
||||
$data = $_var_39;
|
||||
return Excel::create("杠杆交易", function ($excel) use($data) {
|
||||
$excel->sheet("杠杆交易", function ($sheet) use($data) {
|
||||
$sheet->cell("A1", function ($cell) {
|
||||
$cell->setValue("ID");
|
||||
});
|
||||
$sheet->cell("B1", function ($cell) {
|
||||
$cell->setValue("用户名");
|
||||
});
|
||||
$sheet->cell("C1", function ($cell) {
|
||||
$cell->setValue("交易手续费");
|
||||
});
|
||||
$sheet->cell("D1", function ($cell) {
|
||||
$cell->setValue("隔夜费金额");
|
||||
});
|
||||
$sheet->cell("E1", function ($cell) {
|
||||
$cell->setValue("交易类型");
|
||||
});
|
||||
$sheet->cell("F1", function ($cell) {
|
||||
$cell->setValue("当前状态");
|
||||
});
|
||||
$sheet->cell("G1", function ($cell) {
|
||||
$cell->setValue("原始价格");
|
||||
});
|
||||
$sheet->cell("H1", function ($cell) {
|
||||
$cell->setValue("开仓价格");
|
||||
});
|
||||
$sheet->cell("I1", function ($cell) {
|
||||
$cell->setValue("当前价格");
|
||||
});
|
||||
$sheet->cell("J1", function ($cell) {
|
||||
$cell->setValue("手数");
|
||||
});
|
||||
$sheet->cell("K1", function ($cell) {
|
||||
$cell->setValue("倍数");
|
||||
});
|
||||
$sheet->cell("L1", function ($cell) {
|
||||
$cell->setValue("初始保证金");
|
||||
});
|
||||
$sheet->cell("M1", function ($cell) {
|
||||
$cell->setValue("当前可用保证金");
|
||||
});
|
||||
$sheet->cell("N1", function ($cell) {
|
||||
$cell->setValue("创建时间");
|
||||
});
|
||||
$sheet->cell("O1", function ($cell) {
|
||||
$cell->setValue("价格刷新时间");
|
||||
});
|
||||
$sheet->cell("P1", function ($cell) {
|
||||
$cell->setValue("平仓时间");
|
||||
});
|
||||
$sheet->cell("Q1", function ($cell) {
|
||||
$cell->setValue("完成时间");
|
||||
});
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $_var_42 => $_var_43) {
|
||||
if ($_var_43["type"] == 1) {
|
||||
$_var_43["type"] = "买入";
|
||||
} else {
|
||||
$_var_43["type"] = "卖出";
|
||||
}
|
||||
if ($_var_43["status"] == 0) {
|
||||
$_var_43["status"] = "挂单中";
|
||||
} elseif ($_var_43["status"] == 1) {
|
||||
$_var_43["status"] = "交易中";
|
||||
} elseif ($_var_43["status"] == 2) {
|
||||
$_var_43["status"] = "平仓中";
|
||||
} elseif ($_var_43["status"] == 3) {
|
||||
$_var_43["status"] = "已平仓";
|
||||
} elseif ($_var_43["status"] == 4) {
|
||||
$_var_43["status"] = "已撤单";
|
||||
}
|
||||
$_var_44 = $_var_42 + 2;
|
||||
$sheet->cell("A" . $_var_44, $_var_43["id"]);
|
||||
$sheet->cell("B" . $_var_44, $_var_43["phone"]);
|
||||
$sheet->cell("C" . $_var_44, $_var_43["trade_fee"]);
|
||||
$sheet->cell("D" . $_var_44, $_var_43["overnight_money"]);
|
||||
$sheet->cell("E" . $_var_44, $_var_43["type"]);
|
||||
$sheet->cell("F" . $_var_44, $_var_43["status"]);
|
||||
$sheet->cell("G" . $_var_44, $_var_43["origin_price"]);
|
||||
$sheet->cell("H" . $_var_44, $_var_43["price"]);
|
||||
$sheet->cell("I" . $_var_44, $_var_43["update_price"]);
|
||||
$sheet->cell("J" . $_var_44, $_var_43["share"]);
|
||||
$sheet->cell("K" . $_var_44, $_var_43["multiple"]);
|
||||
$sheet->cell("L" . $_var_44, $_var_43["origin_caution_money"]);
|
||||
$sheet->cell("M" . $_var_44, $_var_43["caution_money"]);
|
||||
$sheet->cell("N" . $_var_44, $_var_43["create_time"]);
|
||||
$sheet->cell("O" . $_var_44, $_var_43["update_time"]);
|
||||
$sheet->cell("P" . $_var_44, $_var_43["handle_time"]);
|
||||
$sheet->cell("Q" . $_var_44, $_var_43["complete_time"]);
|
||||
}
|
||||
}
|
||||
});
|
||||
})->download("xlsx");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\TransactionLegal;
|
||||
use App\Currency;
|
||||
|
||||
class TransactionLegalController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
//$currency = Currency::all();
|
||||
$currency = Currency::where('type',1)->get();//获取法币
|
||||
// var_dump($currency);
|
||||
return view('admin.transaction.legal',['currency'=> $currency]);
|
||||
}
|
||||
public function list(Request $request){
|
||||
$limit = $request->get('limit', 10);
|
||||
$account_number = $request->get('account_number', '');
|
||||
$type = $request->get('type', '');
|
||||
$currency = $request->get('currency', '');
|
||||
$result = new TransactionLegal();
|
||||
if(!empty($account_number)){
|
||||
$result = $result->whereHas('user', function ($query) use ($account_number) {
|
||||
$query->where('account_number', 'like', '%' . $account_number . '%');
|
||||
});
|
||||
}
|
||||
if (!empty($type)) {
|
||||
$result = $result->where('type', $type);
|
||||
}
|
||||
if (!empty($currency)) {
|
||||
$result = $result->where('currency', $currency);
|
||||
}
|
||||
$result = $result->orderBy('id', 'desc')->paginate($limit);
|
||||
return $this->layuiData($result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\DAO\UploaderDAO;
|
||||
|
||||
class UeditorController extends Controller
|
||||
{
|
||||
|
||||
private function getConfig()
|
||||
{
|
||||
$config = [
|
||||
"imageActionName" => "uploadimage",
|
||||
"imageFieldName" => "upfile",
|
||||
"imageMaxSize" => 2048000,
|
||||
"imageAllowFiles" => [
|
||||
".png",
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".gif",
|
||||
".bmp"
|
||||
],
|
||||
"imageCompressEnable" => true,
|
||||
"imageCompressBorder" => 1600,
|
||||
"imageInsertAlign" => "none",
|
||||
"imageUrlPrefix" => "",
|
||||
"imagePathFormat" => "/upload/ueditor/image/{yyyy}{mm}{dd}/{time}{rand =>6}",
|
||||
"scrawlActionName" => "uploadscrawl",
|
||||
"scrawlFieldName" => "upfile",
|
||||
"scrawlPathFormat" => "/upload/ueditor/image/{yyyy}{mm}{dd}/{time}{rand =>6}",
|
||||
"scrawlMaxSize" => 2048000,
|
||||
"scrawlUrlPrefix" => "",
|
||||
"scrawlInsertAlign" => "none",
|
||||
"snapscreenActionName" => "uploadimage",
|
||||
"snapscreenPathFormat" => "/upload/ueditor/image/{yyyy}{mm}{dd}/{time}{rand =>6}",
|
||||
"snapscreenUrlPrefix" => "",
|
||||
"snapscreenInsertAlign" => "none",
|
||||
"catcherLocalDomain" => [
|
||||
"127.0.0.1",
|
||||
"localhost",
|
||||
"img.tradingview.com"
|
||||
],
|
||||
"catcherActionName" => "catchimage",
|
||||
"catcherFieldName" => "source",
|
||||
"catcherPathFormat" => "/upload/ueditor/image/{yyyy}{mm}{dd}/{time}{rand =>6}",
|
||||
"catcherUrlPrefix" => "",
|
||||
"catcherMaxSize" => 2048000,
|
||||
"catcherAllowFiles" => [
|
||||
".png",
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".gif",
|
||||
".bmp"
|
||||
],
|
||||
"videoActionName" => "uploadvideo",
|
||||
"videoFieldName" => "upfile",
|
||||
"videoPathFormat" => "/upload/ueditor/video/{yyyy}{mm}{dd}/{time}{rand =>6}",
|
||||
"videoUrlPrefix" => "",
|
||||
"videoMaxSize" => 102400000,
|
||||
"videoAllowFiles" => [
|
||||
".flv",
|
||||
".swf",
|
||||
".mkv",
|
||||
".avi",
|
||||
".rm",
|
||||
".rmvb",
|
||||
".mpeg",
|
||||
".mpg",
|
||||
".ogg",
|
||||
".ogv",
|
||||
".mov",
|
||||
".wmv",
|
||||
".mp4",
|
||||
".webm",
|
||||
".mp3",
|
||||
".wav",
|
||||
".mid"
|
||||
],
|
||||
"fileActionName" => "uploadfile",
|
||||
"fileFieldName" => "upfile",
|
||||
"filePathFormat" => "/upload/ueditor/file/{yyyy}{mm}{dd}/{time}{rand =>6}",
|
||||
"fileUrlPrefix" => "",
|
||||
"fileMaxSize" => 51200000,
|
||||
"fileAllowFiles" => [
|
||||
".png",
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".gif",
|
||||
".bmp",
|
||||
".flv",
|
||||
".swf",
|
||||
".mkv",
|
||||
".avi",
|
||||
".rm",
|
||||
".rmvb",
|
||||
".mpeg",
|
||||
".mpg",
|
||||
".ogg",
|
||||
".ogv",
|
||||
".mov",
|
||||
".wmv",
|
||||
".mp4",
|
||||
".webm",
|
||||
".mp3",
|
||||
".wav",
|
||||
".mid",
|
||||
".rar",
|
||||
".zip",
|
||||
".tar",
|
||||
".gz",
|
||||
".7z",
|
||||
".bz2",
|
||||
".cab",
|
||||
".iso",
|
||||
".doc",
|
||||
".docx",
|
||||
".xls",
|
||||
".xlsx",
|
||||
".ppt",
|
||||
".pptx",
|
||||
".pdf",
|
||||
".txt",
|
||||
".md",
|
||||
".xml"
|
||||
],
|
||||
"imageManagerActionName" => "listimage",
|
||||
"imageManagerListPath" => "/upload/ueditor/image/",
|
||||
"imageManagerListSize" => 20,
|
||||
"imageManagerUrlPrefix" => "",
|
||||
"imageManagerInsertAlign" => "none",
|
||||
"imageManagerAllowFiles" => [
|
||||
".png",
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".gif",
|
||||
".bmp"
|
||||
],
|
||||
"fileManagerActionName" => "listfile",
|
||||
"fileManagerListPath" => "/upload/ueditor/file/",
|
||||
"fileManagerUrlPrefix" => "",
|
||||
"fileManagerListSize" => 20,
|
||||
"fileManagerAllowFiles" => [
|
||||
".png",
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".gif",
|
||||
".bmp",
|
||||
".flv",
|
||||
".swf",
|
||||
".mkv",
|
||||
".avi",
|
||||
".rm",
|
||||
".rmvb",
|
||||
".mpeg",
|
||||
".mpg",
|
||||
".ogg",
|
||||
".ogv",
|
||||
".mov",
|
||||
".wmv",
|
||||
".mp4",
|
||||
".webm",
|
||||
".mp3",
|
||||
".wav",
|
||||
".mid",
|
||||
".rar",
|
||||
".zip",
|
||||
".tar",
|
||||
".gz",
|
||||
".7z",
|
||||
".bz2",
|
||||
".cab",
|
||||
".iso",
|
||||
".doc",
|
||||
".docx",
|
||||
".xls",
|
||||
".xlsx",
|
||||
".ppt",
|
||||
".pptx",
|
||||
".pdf",
|
||||
".txt",
|
||||
".md",
|
||||
".xml"
|
||||
]
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
public function ueditor(Request $request)
|
||||
{
|
||||
$action = $request->input('action', '');
|
||||
$config = $this->getConfig();
|
||||
switch ($action) {
|
||||
case 'config':
|
||||
return $this->getConfig();
|
||||
/* 上传图片 */
|
||||
case 'uploadimage':
|
||||
/* 上传涂鸦 */
|
||||
case 'uploadscrawl':
|
||||
/* 上传视频 */
|
||||
case 'uploadvideo':
|
||||
/* 上传文件 */
|
||||
case 'uploadfile':
|
||||
$field_name = str_ireplace('upload', '', $action) . 'FieldName';
|
||||
$field = $config[$field_name];
|
||||
$file = $request->file($field);
|
||||
$result = UploaderDAO::fileUpload($file, 'ueditor');
|
||||
break;
|
||||
/* 列出图片 */
|
||||
case 'listimage':
|
||||
//$result = include("action_list.php");
|
||||
break;
|
||||
/* 列出文件 */
|
||||
case 'listfile':
|
||||
//$result = include("action_list.php");
|
||||
break;
|
||||
|
||||
/* 抓取远程文件 */
|
||||
case 'catchimage':
|
||||
//$result = include("action_crawler.php");
|
||||
break;
|
||||
|
||||
default:
|
||||
$result = array(
|
||||
'state' => '请求地址出错'
|
||||
);
|
||||
break;
|
||||
}
|
||||
return response()->json($result);
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* 会员等级配置
|
||||
*/
|
||||
class UserGradeSettingController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$data = Setting::query()->where('key', 'user_grade_setting')->first();
|
||||
$values = json_decode($data->value);
|
||||
|
||||
$ordinary_setting = collect($values)->where('grade', 1)->first();
|
||||
$vip_setting = collect($values)->where('grade', 2)->first();
|
||||
$svip_setting = collect($values)->where('grade', 3)->first();
|
||||
$setting['ordinary'] = collect($ordinary_setting)->toArray();
|
||||
$setting['vip'] = collect($vip_setting)->toArray();
|
||||
$setting['svip'] = collect($svip_setting)->toArray();
|
||||
|
||||
return view("admin.userGradeSetting.index", [
|
||||
'setting' => $setting
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = [
|
||||
[
|
||||
'grade' => 1,
|
||||
'ore_pool_income' => $request->ordinary_ore_pool_income,
|
||||
'delivery_contract_30s_switch' => $request->ordinary_delivery_contract_30s_switch,
|
||||
'transaction_service_change' => $request->ordinary_transaction_service_change,
|
||||
'withdraw_coin_service_change' => $request->ordinary_withdraw_coin_service_change
|
||||
],
|
||||
[
|
||||
'grade' => 2,
|
||||
'ore_pool_income' => $request->vip_ore_pool_income,
|
||||
'delivery_contract_30s_switch' => $request->vip_delivery_contract_30s_switch,
|
||||
'transaction_service_change' => $request->vip_transaction_service_change,
|
||||
'withdraw_coin_service_change' => $request->vip_withdraw_coin_service_change
|
||||
],
|
||||
[
|
||||
'grade' => 3,
|
||||
'ore_pool_income' => $request->svip_ore_pool_income,
|
||||
'delivery_contract_30s_switch' => $request->svip_delivery_contract_30s_switch,
|
||||
'transaction_service_change' => $request->svip_transaction_service_change,
|
||||
'withdraw_coin_service_change' => $request->svip_withdraw_coin_service_change
|
||||
],
|
||||
];
|
||||
Setting::query()->updateOrCreate([
|
||||
'key' => 'user_grade_setting'
|
||||
], [
|
||||
'value' => json_encode($data),
|
||||
'notes' => '会员等级权益配置'
|
||||
]);
|
||||
|
||||
return $this->success('操作成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,344 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\DAO\PrizePool\CandySender;
|
||||
use App\DAO\UserDAO;
|
||||
use App\PrizePool;
|
||||
use App\Setting;
|
||||
use App\Users;
|
||||
use App\UserReal;
|
||||
use App\IdCardIdentity;
|
||||
use App\Events\RealNameEvent;
|
||||
|
||||
class UserRealController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view("admin.userReal.index");
|
||||
}
|
||||
|
||||
//用户列表
|
||||
public function list(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$account = $request->get('account', '');
|
||||
$review_status_s = $request->get('review_status_s', 0);
|
||||
|
||||
$list = new UserReal();
|
||||
if (!empty($account)) {
|
||||
$list = $list->whereHas('user', function ($query) use ($account) {
|
||||
$query->where("phone", 'like', '%' . $account . '%')->orwhere('email', 'like', '%' . $account . '%');
|
||||
});
|
||||
}
|
||||
if(!empty($review_status_s)){
|
||||
$list = $list->where('review_status',$review_status_s);
|
||||
}
|
||||
|
||||
$list = $list->orderBy('id', 'desc')->paginate($limit);
|
||||
return response()->json(['code' => 0, 'data' => $list->items(), 'count' => $list->total()]);
|
||||
}
|
||||
|
||||
public function detail(Request $request)
|
||||
{
|
||||
|
||||
$id = $request->get('id', 0);
|
||||
if (empty($id)) {
|
||||
return $this->error("参数错误");
|
||||
}
|
||||
|
||||
$result = UserReal::find($id);
|
||||
|
||||
$imageServerUrl = Setting::getValueByKey('image_server_url', '');
|
||||
|
||||
if(!empty($result -> front_pic)){
|
||||
$result -> front_pic = $imageServerUrl.$result ->front_pic;
|
||||
}
|
||||
|
||||
if(!empty($result -> reverse_pic)){
|
||||
$result -> reverse_pic = $imageServerUrl.$result ->reverse_pic;
|
||||
}
|
||||
|
||||
return view('admin.userReal.info', ['result' => $result,'imageServerUrl' => $imageServerUrl]);
|
||||
}
|
||||
|
||||
public function del(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
$userreal = UserReal::find($id);
|
||||
if (empty($userreal)) {
|
||||
$this->error("认证信息未找到");
|
||||
}
|
||||
try {
|
||||
|
||||
$userreal->delete();
|
||||
return $this->success('删除成功');
|
||||
} catch (\Exception $ex) {
|
||||
return $this->error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//状态审核
|
||||
public function auth(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$userreal = UserReal::find($id);
|
||||
if (empty($userreal)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
if ($userreal->review_status == 1) {
|
||||
//从未认证到认证
|
||||
//查询users表判断是否为第一次实名认证
|
||||
$user = Users::find($userreal->user_id);
|
||||
$is_realname = $user->is_realname;
|
||||
if ($is_realname == 1) {
|
||||
//1:未实名认证过 2:实名认证过
|
||||
$real_zhitui = Users::where("is_realname", "=", 2)->where("parent_id", "=", $userreal->user_id)->count();//实名认证过的有效直推人数
|
||||
//获取下级的总人数
|
||||
$member = Users::get()->toArray();
|
||||
$real_teamnumber = $this->GetTeamMember($member, $userreal->user_id);//实名认证过的团队人数
|
||||
$candy_number = 10;
|
||||
$user->candy_number = $candy_number;
|
||||
$user->push_status = 1;
|
||||
$top_upnumber = $user->top_upnumber;
|
||||
|
||||
//开始记录日志
|
||||
$candy_sender = new CandySender();
|
||||
PrizePool::send(
|
||||
$candy_sender,
|
||||
$sender = 0,
|
||||
$user->candy_number,
|
||||
$user,
|
||||
$user,
|
||||
//PrizePool::CERTIFICATION,//const CERTIFICATION = 1; //实名认证奖励
|
||||
$user->account_number . '实名认证通证奖励10个通证',
|
||||
$attach_data = []
|
||||
);
|
||||
|
||||
if (3 <= $real_zhitui) {
|
||||
//给自己加通证 +20
|
||||
$user->candy_number = $user->candy_number + 20;
|
||||
$user->push_status = 2;
|
||||
|
||||
$candy_sender = new CandySender();
|
||||
PrizePool::send(
|
||||
$candy_sender,
|
||||
$sender = 0,
|
||||
20,
|
||||
$user,
|
||||
$from_user = null,
|
||||
//PrizePool::CERTIFICATION,//const CERTIFICATION = 1; //实名认证奖励
|
||||
'满足直推3人实名送20个通证',
|
||||
$attach_data = []
|
||||
);
|
||||
}
|
||||
if ($real_zhitui >= 5 && $real_teamnumber >= 15 && $top_upnumber >= 100) {
|
||||
$user->candy_number = $user->candy_number + 50;
|
||||
$user->push_status = 3;
|
||||
$candy_sender = new CandySender();
|
||||
PrizePool::send(
|
||||
$candy_sender,
|
||||
$sender = 0,
|
||||
50,
|
||||
$user,
|
||||
$from_user = null,
|
||||
//PrizePool::CERTIFICATION,//const CERTIFICATION = 1; //实名认证奖励
|
||||
'满足直推5人,实名认证团队15人充值达100美金;送50通证',
|
||||
$attach_data = []
|
||||
);
|
||||
}
|
||||
if ($real_zhitui >= 10 && $real_teamnumber >= 50 && $top_upnumber >= 1000) {
|
||||
$user->candy_number = $user->candy_number + 300;
|
||||
$user->push_status = 4;
|
||||
$candy_sender = new CandySender();
|
||||
PrizePool::send(
|
||||
$candy_sender,
|
||||
$sender = 0,
|
||||
300,
|
||||
$user,
|
||||
$from_user = null,
|
||||
//PrizePool::CERTIFICATION,//const CERTIFICATION = 1; //实名认证奖励
|
||||
'满足直推10人;实名认证,团队50人;充值达1000美金以上,送300通证',
|
||||
$attach_data = []
|
||||
);
|
||||
}
|
||||
if ($real_zhitui >= 30 && $real_teamnumber >= 100 && $top_upnumber >= 10000) {
|
||||
$user->candy_number = $user->candy_number + 1300;
|
||||
$user->push_status = 5;
|
||||
$candy_sender = new CandySender();
|
||||
PrizePool::send(
|
||||
$candy_sender,
|
||||
$sender = 0,
|
||||
1300,
|
||||
$user,
|
||||
$from_user = null,
|
||||
//PrizePool::CERTIFICATION,//const CERTIFICATION = 1; //实名认证奖励
|
||||
'满足直推30人,团队100人,充值1万送1300个',
|
||||
$attach_data = []
|
||||
);
|
||||
}
|
||||
if ($real_zhitui >= 50 && $real_teamnumber >= 200 && $top_upnumber >= 100000) {
|
||||
$user->candy_number = $user->candy_number + 30000;
|
||||
$user->push_status = 6;
|
||||
$candy_sender = new CandySender();
|
||||
PrizePool::send(
|
||||
$candy_sender,
|
||||
$sender = 0,
|
||||
30000,
|
||||
$user,
|
||||
$from_user = null,
|
||||
//PrizePool::CERTIFICATION,//const CERTIFICATION = 1; //实名认证奖励
|
||||
'直推50人实名认证,团队200人,充值金额达10万USDC,送30000通证',
|
||||
$attach_data = []
|
||||
);
|
||||
}
|
||||
$user->real_teamnumber = $real_teamnumber;
|
||||
$user->is_realname = 2;
|
||||
$user->save();//自己实名认证获取通证结束
|
||||
|
||||
}
|
||||
$userreal->review_status = 2;
|
||||
} else if ($userreal->review_status == 2) {
|
||||
$userreal->review_status = 1;
|
||||
} else {
|
||||
$userreal->review_status = 1;
|
||||
}
|
||||
try {
|
||||
$userreal->save();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public function autherror(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$userreal = UserReal::find($id);
|
||||
if (empty($userreal)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$user = Users::find($userreal->user_id);
|
||||
if (!$user) {
|
||||
return $this->error('用户不存在');
|
||||
}
|
||||
|
||||
$userreal->review_status = 4;
|
||||
|
||||
try {
|
||||
$userreal->save();
|
||||
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function auth(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$userreal = UserReal::find($id);
|
||||
if (empty($userreal)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$user = Users::find($userreal->user_id);
|
||||
if (!$user) {
|
||||
return $this->error('用户不存在');
|
||||
}
|
||||
if ($userreal->review_status == 1) {
|
||||
//从未认证到认证
|
||||
//查询users表判断是否为第一次实名认证
|
||||
$is_realname = $user->is_realname;
|
||||
if ($is_realname != 2) {
|
||||
//1:未实名认证过 2:实名认证过
|
||||
|
||||
$user->is_realname = 2;
|
||||
|
||||
$user->save();//自己实名认证获取通证结束
|
||||
//判断自己上级的的触发奖励
|
||||
//UserDAO::addCandyNumber($user);
|
||||
}
|
||||
$userreal->review_status = 2;
|
||||
} else if ($userreal->review_status == 2) {
|
||||
$userreal->review_status = 1;
|
||||
} else {
|
||||
$userreal->review_status = 1;
|
||||
}
|
||||
try {
|
||||
$userreal->save();
|
||||
//用户实名事件
|
||||
if ($userreal->review_status == 2) {
|
||||
event(new RealNameEvent($user, $userreal));
|
||||
}
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//认证高级用户
|
||||
public function setAdvancedUser(Request $request)
|
||||
{
|
||||
$id = $request->get('id', 0);
|
||||
$userreal = UserReal::find($id);
|
||||
if (empty($userreal)) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$user = Users::find($userreal->user_id);
|
||||
if (!$user) {
|
||||
return $this->error('用户不存在');
|
||||
}
|
||||
|
||||
if($userreal->review_status == 2 && $userreal->advanced_user==1){
|
||||
$userreal->advanced_user = 2;//null还没有提交过高级审核 1 等待审核的 2 已通过高级审核
|
||||
}else if($userreal->review_status != 2){
|
||||
return $this->success('请先审核用户信息');
|
||||
}else if($userreal->advanced_user == 2){
|
||||
return $this->success('已经审核过');
|
||||
}else if(!$userreal->advanced_user){
|
||||
return $this->error('该用户还未提交高级审核');
|
||||
}
|
||||
|
||||
try {
|
||||
$userreal->save();
|
||||
return $this->success('操作成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->error($exception->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//递归查询用户下级所有人数
|
||||
public function GetTeamMember($members, $mid)
|
||||
{
|
||||
$Teams = array();//最终结果
|
||||
$mids = array($mid);//第一次执行时候的用户id
|
||||
do {
|
||||
$othermids = array();
|
||||
$state = false;
|
||||
foreach ($mids as $valueone) {
|
||||
foreach ($members as $key => $valuetwo) {
|
||||
if ($valuetwo['parent_id'] == $valueone) {
|
||||
//实名认证通过的团队人数
|
||||
$Teams[] = $valuetwo['id'];//找到我的下级立即添加到最终结果中
|
||||
$othermids[] = $valuetwo['id'];//将我的下级id保存起来用来下轮循环他的下级
|
||||
// array_splice($members,$key,1);//从所有会员中删除他
|
||||
$state = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$mids = $othermids;//foreach中找到的我的下级集合,用来下次循环
|
||||
} while ($state == true);
|
||||
//$Teams=Users::where("parents_path","like","%$mid%")->where("is_realname","=",2)->count();
|
||||
$Teams = Users::whereIn("id", $Teams)->where("is_realname", "=", 2)->count();
|
||||
return $Teams;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\{Currency, UsersWallet};
|
||||
USE App\DAO\BlockChain;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Jobs\UpdateBalance;
|
||||
|
||||
class WalletController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$currencies = Currency::all();
|
||||
return view('admin.wallet.index', ['currencies' => $currencies]);
|
||||
}
|
||||
|
||||
public function lists(Request $request)
|
||||
{
|
||||
$limit = $request->input('limit', 10);
|
||||
$query = UsersWallet::whereHas('user', function ($query) use ($request) {
|
||||
$account_number = $request->input('account_number', '');
|
||||
$account_number != '' && $query->where('account_number', $account_number)->orWhere('phone', $account_number)->orWhere('email', $account_number)->orWhere('id', $account_number);
|
||||
})->where(function ($query) use ($request) {
|
||||
$currency = $request->input('currency', -1);
|
||||
$address = $request->input('address', '');
|
||||
$currency != -1 && $query->where('currency', $currency);
|
||||
$address != '' && $query->where('address', $address);
|
||||
});
|
||||
$query_total = clone $query;
|
||||
$total = $query_total->select([
|
||||
DB::raw('sum(legal_balance) as legal_balance'),
|
||||
DB::raw('sum(lock_legal_balance) as lock_legal_balance'),
|
||||
DB::raw('sum(change_balance) as change_balance'),
|
||||
DB::raw('sum(lock_change_balance) as lock_change_balance'),
|
||||
DB::raw('sum(lever_balance) as lever_balance'),
|
||||
DB::raw('sum(lock_lever_balance) as lock_lever_balance'),
|
||||
])->first();
|
||||
$total = $total->setAppends([]);
|
||||
$user_wallet = $query->orderBy('old_balance', 'desc')->paginate($limit);
|
||||
$list = $user_wallet->getCollection();
|
||||
$list->transform(function ($item, $key) {
|
||||
$item->append('account_number');
|
||||
return $item;
|
||||
});
|
||||
$user_wallet->setCollection($list);
|
||||
return $this->layuiData($user_wallet, ['total' => $total]);
|
||||
}
|
||||
|
||||
public function updateBalance(Request $request)
|
||||
{
|
||||
$id = $request->input('id', 0);
|
||||
$wallet = UsersWallet::find($id);
|
||||
if (!$wallet) {
|
||||
return $this->error('钱包不存在');
|
||||
}
|
||||
//更改为队列方式更新
|
||||
UpdateBalance::dispatch($wallet)->onQueue('update:block:balance');
|
||||
return $this->success('更新请求已经发送到队列中,请稍后再查询');
|
||||
}
|
||||
|
||||
/**
|
||||
* 代入手续费
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function transferPoundage(Request $request)
|
||||
{
|
||||
$id = $request->input('id', 0);
|
||||
$refresh_balance = $request->input('refresh_balance', 0);
|
||||
try {
|
||||
$wallet = UsersWallet::find($id);
|
||||
throw_unless($wallet, new \Exception('钱包不存在'));
|
||||
$result = BlockChain::transferPoundage($wallet, $refresh_balance);
|
||||
return $this->success('请求成功,交易哈希:' . ($result['txid'] ?? $result['data']['txHex']));
|
||||
} catch (\Throwable $th) {
|
||||
return $this->error($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 钱包归拢
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function collect(Request $request)
|
||||
{
|
||||
$id = $request->input('id', 0);
|
||||
$refresh_balance = $request->input('refresh_balance', 0);
|
||||
try {
|
||||
$wallet = UsersWallet::find($id);
|
||||
throw_unless($wallet, new \Exception('钱包不存在'));
|
||||
$result = BlockChain::collect($wallet, $refresh_balance);
|
||||
return $this->success('请求成功,HASH:' . $result['txid']);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->error($th->getMessage().$th->getFile().$th->getLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user