success('ok', compact('version_code', 'apk')); } public function test(Request $request) { // var_dump(get_fil_price()); // if(!UserMiningMachine::sendGroupAward(10114, 7, 'FIL',0.28076800)){ // var_dump(UserMiningMachine::getErrorInfo()); // } // SystemUserTask::SmallGroupHashRate(1, 1); // UserMiningMachine::dayMining(); //// $money_types = MiningMachine::group('get_money_type')->field('COUNT(id),get_money_type')->select(); // $day_gets = []; // foreach ($money_types as $v) { // $day_gets[$v['get_money_type']] = get_hpool_price($v['get_money_type']); // } ////// var_dump($day_gets); //// // $uid = $request->post('uid', ''); // $umid = $request->post('umid', ''); // $num = $request->post('num', 0); // $price = $day_gets['XCH']; // $time = time(); // $day_get = bcmul($price, $num, 8); // $service_ratio = 0.8; // $day_service_get = bcmul($service_ratio, $day_get, 8); // $day_real_get = $day_service_get; // if ($day_real_get > 0) { // UserMining::create([ // 'umid' => $umid, // 'get_money' => $day_real_get, // 'get_money_type' => 'XCH', // 'add_time' => $time, // 'add_date' => date('Y-m-d', $time), // ]) && UserMoney::incomeMoney($uid, 'XCH', bcadd($day_real_get, 0, 8), 'mining', '挖矿', '第一阶段每日释放' . $day_get . 'XCH' . ',扣除技术服务费后实际到账' . $day_real_get . 'XCH') // && UserMiningMachine::sendGroupAward($uid, 'XCH', bcadd($day_real_get, 0, 8)) // && UserMiningMachine::sendSystemAward($uid, 'XCH', bcadd($day_real_get, 0, 8)); // } var_dump(MiningMachine::buyMachine(7, 10126, 3)); } public function fileCoinOverview(Request $request) { $res = do_request('https://filfox.info/api/v1/overview', [], null, false); $res = json_decode($res, true); $price = $res['price']; // if (!isset($res['code']) || $res['code'] != 200) $price = 0; $siteTotalPower = UserMiningMachine::where('get_money_type', 'in', 'FIL')->where('status', 'in', [1, 2])->sum('num'); $todayAdd = UserMiningMachine::where('get_money_type', 'in', 'FIL')->where('status', 'in', [1, 2])->whereTime('mining_start_time', 'today')->sum('num'); $coins = $res['dailyCoinsMined']; // var_dump($coins); $power = $res['totalQualityAdjPower']; $coins = bcdiv($coins, '1000000000000000000', 8); // var_dump($coins); $netTotalPower = bcdiv($power, bcpow(1024, 4), 8); $averageReward = bcdiv($coins, $netTotalPower, 8); return app('json')->successful(compact('netTotalPower', 'averageReward', 'todayAdd', 'siteTotalPower', 'price')); } public function fileMinerView(Request $request) { $miners = sys_config('fil_miner', ''); // var_dump($miners); $miners = explode(',', $miners); // var_dump($miners); $result = []; foreach ($miners as $v) { // var_dump($v); $res = do_request('https://filfox.info/api/v1/address/' . $v, [], null, false); $res = json_decode($res, true); // var_dump($res); $info = [ 'name' => $v, 'balance' => bcdiv($res['balance'], '1000000000000000000', 4), 'availableBalance' => bcdiv($res['miner']['availableBalance'], '1000000000000000000', 4), 'initialPledgeRequirement' => bcdiv($res['miner']['initialPledgeRequirement'], '1000000000000000000', 4), 'qualityAdjPower' => bcdiv($res['miner']['qualityAdjPower'], bcpow(1024, 4), 8), 'vestingFunds' => bcdiv($res['miner']['vestingFunds'], '1000000000000000000', 4), 'rank' => $res['miner']['qualityAdjPowerRank'], 'ratio' => bcdiv($res['miner']['qualityAdjPower'], $res['miner']['networkQualityAdjPower'], 8), 'weightedBlocksMined' => $res['miner']['weightedBlocksMined'], 'totalRewards' => bcdiv($res['miner']['totalRewards'], '1000000000000000000', 4), 'piece' => round(bcdiv(bcdiv($res['miner']['qualityAdjPower'], bcpow(1024, 3), 8), $res['miner']['sectors']['live'], 2)) ]; $result[] = $info; } return app('json')->successful($result); //return app('json')->successful(compact('netTotalPower', 'averageReward', 'todayAdd', 'siteTotalPower', 'price')); } public function TRC20CashAdmin(Request $request) { $trans_adds = UserMoney::field('money_type,address_TRC20')->select(); foreach ($trans_adds as $v) { if ($v['address_TRC20']) { $res = ZtPayService::instance()->get_balance(($v['money_type'] == "TRX") ? "TRX" : ($v['money_type'] . '_TRC20'), $v['address_TRC20']); // $res = json_decode($res, true); if (isset($res['data']['USDT']) && $res['data']['USDT'] > 0) { //执行转账 $address = 'TEn1gLWumRj1FfjQ927vSoQrUCqKhuiWV2';//归集总地址 if (isset($res['data']['TRX']) && $res['data']['TRX'] < 5) { $amount_address = 'TWkaVx6NW1q7LZxRW8BbhvqShP76EJPckZ';//手续费地址 $res2 = ZtPayService::instance()->transfer('TRX', $amount_address, $v['address_TRC20'], 5); var_dump('---------------------' . $v['address_TRC20'] . '----A---------------------'); var_dump($res2); } else { $res3 = ZtPayService::instance()->transfer(($v['money_type'] == "TRX") ? "TRX" : ($v['money_type'] . '_TRC20'), $v['address_TRC20'], $address, $res['data'][$v['money_type']]); var_dump('---------------------' . $v['address_TRC20'] . '----B---------------------'); var_dump(($v['money_type'] == "TRX") ? "TRX" : ($v['money_type'] . '_TRC20')); var_dump($address); var_dump($res['data'][$v['money_type']]); } } } } } /** * @param Request $request * @return mixed * @throws DataNotFoundException * @throws ModelNotFoundException * @throws \think\exception\DbException */ public function index(Request $request) { $banner = sys_data('routine_home_banner') ?: [];//TODO 首页banner图 $menus = sys_data('routine_home_menus') ?: [];//TODO 首页按钮 $roll = sys_data('routine_home_roll_news') ?: [];//TODO 首页滚动新闻 $activity = sys_data('routine_home_activity', 3) ?: [];//TODO 首页活动区域图片 $site_name = sys_config('site_name'); $routine_index_page = sys_data('routine_index_page'); $info['fastInfo'] = $routine_index_page[0]['fast_info'] ?? '';//sys_config('fast_info');//TODO 快速选择简介 $info['bastInfo'] = $routine_index_page[0]['bast_info'] ?? '';//sys_config('bast_info');//TODO 精品推荐简介 $info['firstInfo'] = $routine_index_page[0]['first_info'] ?? '';//sys_config('first_info');//TODO 首发新品简介 $info['salesInfo'] = $routine_index_page[0]['sales_info'] ?? '';//sys_config('sales_info');//TODO 促销单品简介 $logoUrl = sys_config('routine_index_logo');//TODO 促销单品简介 if (strstr($logoUrl, 'http') === false && $logoUrl) $logoUrl = sys_config('site_url') . $logoUrl; $logoUrl = str_replace('\\', '/', $logoUrl); $fastNumber = sys_config('fast_number', 0);//TODO 快速选择分类个数 $bastNumber = sys_config('bast_number', 0);//TODO 精品推荐个数 $firstNumber = sys_config('first_number', 0);//TODO 首发新品个数 $promotionNumber = sys_config('promotion_number', 0);//TODO 首发新品个数 $info['fastList'] = StoreCategory::byIndexList((int)$fastNumber, false);//TODO 快速选择分类个数 $info['bastList'] = StoreProduct::getBestProduct('id,image,store_name,cate_id,price,ot_price,IFNULL(sales,0) + IFNULL(ficti,0) as sales,unit_name', (int)$bastNumber, $request->uid(), false);//TODO 精品推荐个数 $info['firstList'] = StoreProduct::getNewProduct('id,image,store_name,cate_id,price,unit_name,IFNULL(sales,0) + IFNULL(ficti,0) as sales', (int)$firstNumber, $request->uid(), false);//TODO 首发新品个数 $info['bastBanner'] = sys_data('routine_home_bast_banner') ?? [];//TODO 首页精品推荐图片 $benefit = StoreProduct::getBenefitProduct('id,image,store_name,cate_id,price,ot_price,stock,unit_name', $promotionNumber);//TODO 首页促销单品 $lovely = sys_data('routine_home_new_banner') ?: [];//TODO 首发新品顶部图 $likeInfo = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,ot_price,unit_name', 3);//TODO 热门榜单 猜你喜欢 $couponList = StoreCouponIssue::getIssueCouponList($request->uid(), 3); if ($request->uid()) { $subscribe = WechatUser::where('uid', $request->uid())->value('subscribe') ? true : false; } else { $subscribe = true; } $newGoodsBananr = sys_config('new_goods_bananr'); $tengxun_map_key = sys_config('tengxun_map_key'); return app('json')->successful(compact('banner', 'menus', 'roll', 'info', 'activity', 'lovely', 'benefit', 'likeInfo', 'logoUrl', 'couponList', 'site_name', 'subscribe', 'newGoodsBananr', 'tengxun_map_key')); } /** * @param Request $request * @return mixed * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function cityArea(Request $request) { $province = SystemCity::where('level', 0)->where('parent_id', 0)->field('name,city_id')->select()->each(function ($item) { $item['city'] = SystemCity::where('level', 1) ->where('parent_id', $item['city_id']) ->field('name,city_id') ->select()->each(function ($sub_item) { $sub_item['area'] = SystemCity::where('level', 2) ->where('parent_id', $sub_item['city_id']) ->column('name'); unset($sub_item['city_id']); })->toArray(); unset($item['city_id']); }); return app('json')->success('ok', $province->toArray()); } /** * 获取分享配置 * @return mixed */ public function share() { $data['img'] = sys_config('wechat_share_img'); if (strstr($data['img'], 'http') === false) $data['img'] = sys_config('site_url') . $data['img']; $data['img'] = str_replace('\\', '/', $data['img']); $data['title'] = sys_config('wechat_share_title'); $data['synopsis'] = sys_config('wechat_share_synopsis'); return app('json')->successful(compact('data')); } /** * 获取个人中心菜单 * @param Request $request * @return mixed * @throws DataNotFoundException * @throws ModelNotFoundException * @throws \think\exception\DbException */ public function menu_user(Request $request) { $menusInfo = sys_data('routine_my_menus') ?? []; $user = $request->user(); $vipOpen = sys_config('vip_open'); $vipOpen = is_string($vipOpen) ? (int)$vipOpen : $vipOpen; foreach ($menusInfo as $key => &$value) { $value['pic'] = set_file_url($value['pic']); if ($value['id'] == 137 && !(intval(sys_config('store_brokerage_statu')) == 2 || $user->is_promoter == 1)) unset($menusInfo[$key]); if ($value['id'] == 174 && !StoreService::orderServiceStatus($user->uid)) unset($menusInfo[$key]); if (((!StoreService::orderServiceStatus($user->uid)) && (!SystemStoreStaff::verifyStatus($user->uid))) && $value['wap_url'] === '/order/order_cancellation') unset($menusInfo[$key]); if (((!StoreService::orderServiceStatus($user->uid)) && (!SystemStoreStaff::verifyStatus($user->uid))) && $value['wap_url'] === '/admin/order_cancellation/index') unset($menusInfo[$key]); if ((!StoreService::orderServiceStatus($user->uid)) && $value['wap_url'] === '/admin/order/index') unset($menusInfo[$key]); if ($value['wap_url'] == '/user/vip' && !$vipOpen) unset($menusInfo[$key]); if ($value['wap_url'] == '/customer/index' && !StoreService::orderServiceStatus($user->uid)) unset($menusInfo[$key]); } return app('json')->successful(['routine_my_menus' => $menusInfo]); } /** * 热门搜索关键字获取 * @return mixed * @throws DataNotFoundException * @throws ModelNotFoundException * @throws \think\exception\DbException */ public function search() { $routineHotSearch = sys_data('routine_hot_search') ?? []; $searchKeyword = []; if (count($routineHotSearch)) { foreach ($routineHotSearch as $key => &$item) { array_push($searchKeyword, $item['title']); } } return app('json')->successful($searchKeyword); } /** * 图片上传 * @param Request $request * @return mixed * @throws \Psr\SimpleCache\InvalidArgumentException */ public function upload_image(Request $request) { $data = UtilService::postMore([ ['filename', 'file'], ], $request); if (!$data['filename']) return app('json')->fail('参数有误'); if (Cache::has('start_uploads_' . $request->uid()) && Cache::get('start_uploads_' . $request->uid()) >= 100) return app('json')->fail('非法操作'); $upload_type = sys_config('upload_type', 1); $upload = new Upload((int)$upload_type, [ 'accessKey' => sys_config('accessKey'), 'secretKey' => sys_config('secretKey'), 'uploadUrl' => sys_config('uploadUrl'), 'storageName' => sys_config('storage_name'), 'storageRegion' => sys_config('storage_region'), ]); $info = $upload->to('store/comment')->validate()->move($data['filename']); if ($info === false) { return app('json')->fail($upload->getError()); } $res = $upload->getUploadInfo(); SystemAttachment::attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, $upload_type, $res['time'], 2); if (Cache::has('start_uploads_' . $request->uid())) $start_uploads = (int)Cache::get('start_uploads_' . $request->uid()); else $start_uploads = 0; $start_uploads++; Cache::set('start_uploads_' . $request->uid(), $start_uploads, 86400); $res['dir'] = path_to_url($res['dir']); if (strpos($res['dir'], 'http') === false) $res['dir'] = $request->domain() . $res['dir']; return app('json')->successful('图片上传成功!', ['name' => $res['name'], 'url' => $res['dir']]); } /** * 物流公司 * @return mixed */ public function logistics() { $expressList = Express::lst(); if (!$expressList) return app('json')->successful([]); return app('json')->successful($expressList->hidden(['code', 'id', 'sort', 'is_show'])->toArray()); } /** * 短信购买异步通知 * * @param Request $request * @return mixed */ public function sms_pay_notify(Request $request) { list($order_id, $price, $status, $num, $pay_time, $attach) = UtilService::postMore([ ['order_id', ''], ['price', 0.00], ['status', 400], ['num', 0], ['pay_time', time()], ['attach', 0], ], $request, true); if ($status == 200) { ChannelService::instance()->send('PAY_SMS_SUCCESS', ['price' => $price, 'number' => $num], [$attach]); return app('json')->successful(); } return app('json')->fail(); } /** * 记录用户分享 * @param Request $request * @return mixed */ public function user_share(Request $request) { return app('json')->successful(UserBill::setUserShare($request->uid())); } /** * 获取图片base64 * @param Request $request * @return mixed */ public function get_image_base64(Request $request) { list($imageUrl, $codeUrl) = UtilService::postMore([ ['image', ''], ['code', ''], ], $request, true); try { $codeTmp = $code = $codeUrl ? image_to_base64($codeUrl) : false; if (!$codeTmp) { $putCodeUrl = put_image($codeUrl); $code = $putCodeUrl ? image_to_base64($_SERVER['HTTP_HOST'] . '/' . $putCodeUrl) : false; $code ?? unlink($_SERVER["DOCUMENT_ROOT"] . '/' . $putCodeUrl); } $imageTmp = $image = $imageUrl ? image_to_base64($imageUrl) : false; if (!$imageTmp) { $putImageUrl = put_image($imageUrl); $image = $putImageUrl ? image_to_base64($_SERVER['HTTP_HOST'] . '/' . $putImageUrl) : false; $image ?? unlink($_SERVER["DOCUMENT_ROOT"] . '/' . $putImageUrl); } return app('json')->successful(compact('code', 'image')); } catch (\Exception $e) { return app('json')->fail($e->getMessage()); } } /** * 门店列表 * @return mixed */ public function store_list(Request $request) { list($latitude, $longitude, $page, $limit) = UtilService::getMore([ ['latitude', ''], ['longitude', ''], ['page', 1], ['limit', 10] ], $request, true); $list = SystemStore::lst($latitude, $longitude, $page, $limit); if (!$list) $list = []; $data['list'] = $list; $data['tengxun_map_key'] = sys_config('tengxun_map_key'); return app('json')->successful($data); } /** * 查找城市数据 * @param Request $request * @return mixed */ public function city_list(Request $request) { $list = CacheService::get('CITY_LIST', function () { $list = SystemCity::with('children')->field(['city_id', 'name', 'id', 'parent_id'])->where('parent_id', 0)->order('id asc')->select()->toArray(); $data = []; foreach ($list as &$item) { $value = ['v' => $item['city_id'], 'n' => $item['name']]; if ($item['children']) { foreach ($item['children'] as $key => &$child) { $value['c'][$key] = ['v' => $child['city_id'], 'n' => $child['name']]; unset($child['id'], $child['area_code'], $child['merger_name'], $child['is_show'], $child['level'], $child['lng'], $child['lat'], $child['lat']); if (SystemCity::where('parent_id', $child['city_id'])->count()) { $child['children'] = SystemCity::where('parent_id', $child['city_id'])->field(['city_id', 'name', 'id', 'parent_id'])->select()->toArray(); foreach ($child['children'] as $kk => $vv) { $value['c'][$key]['c'][$kk] = ['v' => $vv['city_id'], 'n' => $vv['name']]; } } } } $data[] = $value; } return $data; }, 0); return app('json')->successful($list); } /** * 查找城市数据 * @param Request $request * @return mixed */ public function data_center(Request $request) { $bt_all = sys_config('bt_sum', 0); $bt_circulate = UserMoney::where('money_type', 'BT')->sum('money'); $bt_destroy = UserMoneyOrder::where('money_type', 'BT')->where('to_uid', 0)->sum('money'); $bt_create_all = UserMoneyOrder::where('money_type', 'BT')->where('uid', 0)->sum('money'); $bt_create_today = UserMoneyOrder::whereTime('add_time', 'today')->where('money_type', 'BT')->where('uid', 0)->sum('money'); $bt = compact('bt_all', 'bt_circulate', 'bt_create_all', 'bt_create_today', 'bt_destroy'); return app('json')->successful('ok', compact('bt')); } public function checkMoney($money_type, Request $request) { $num = $request->get('num', 0); $price = 0; $list = sys_data('money_type'); foreach ($list as $v) { if ($v['code'] == $money_type) { $price = $v['price'] ? $v['price'] : CashTradeOrder::averagePrice($v['code']); } } return bcmul($num, $price, 2); } }