diff --git a/README.md b/README.md index d65a9d2..d7f941e 100755 --- a/README.md +++ b/README.md @@ -61,4 +61,7 @@ putenv composer install php think run -composer require phpoffice/phpspreadsheet \ No newline at end of file +composer require phpoffice/phpspreadsheet + +php think UserStatisticsHour + diff --git a/app/admin/controller/Statistics.php b/app/admin/controller/Statistics.php index ca52b4d..ae4db18 100644 --- a/app/admin/controller/Statistics.php +++ b/app/admin/controller/Statistics.php @@ -4,6 +4,7 @@ namespace app\admin\controller; use app\common\model\Order as OrderModel; use app\common\model\OrderList; use app\common\model\OrderListRecovery; +use app\common\model\UserStatistics; use app\common\model\User; use app\admin\controller\Base; use app\common\model\Category; @@ -16,7 +17,7 @@ use think\facade\Db; use app\common\model\Shang; use app\common\model\ProfitExpenses; use app\common\model\ProfitRvenue; - + class Statistics extends Base { @@ -89,7 +90,7 @@ class Statistics extends Base // 传递数据给视图 View::assign([ - + 'sum_dingdan' => $orderTotals->order_total_all, 'sum_shiji' => $orderTotals->order_zhe_total_all, 'sum_chuhuo' => $goodslistMoneyAll, @@ -163,31 +164,31 @@ class Statistics extends Base // 计算利润 $lirun = round($orderStats->order_zhe_total - $goodslistMoney, 2); $liruns = round(($orderStats->count_price + $orderStats->count_yue + $orderStats->use_integral + $orderStats->use_score + $orderStats->use_coupon) - $goodslistMoney, 2); - + return [ 'order_count' => round($orderStats->count, 2), - 'count_price' =>round($orderStats->count_price, 2), - 'order_total' =>round( $orderStats->order_total, 2), + 'count_price' => round($orderStats->count_price, 2), + 'order_total' => round($orderStats->order_total, 2), 'count_yue' => round($orderStats->count_yue, 2), 'count_use_integral' => round($orderStats->use_integral, 2), 'count_use_score' => round($orderStats->use_score, 2), 'count_use_coupon' => round($orderStats->use_coupon, 2), 'count_heji' => round($orderStats->count_price + $orderStats->count_yue + $orderStats->use_integral + $orderStats->use_score + $orderStats->use_coupon, 2), - 'order_zhe_total'=>round($orderStats->order_zhe_total, 2), + 'order_zhe_total' => round($orderStats->order_zhe_total, 2), // 订单列表数量 'count_OrderList' => OrderList::where($whe2)->count(), // ✅ 添加这一行 - + // 订单总价验证 // 'count_heji_yanzheng' => $count_OrderList * $value['price'], // ✅ 使用 count_OrderList - + 'goodslist_price' => round($goodslistMoney, 2), 'lirun' => $lirun, 'liruns' => $liruns, 'lirulv' => $goodslistMoney == 0 ? 0 : round(($lirun / $goodslistMoney) * 100, 2), 'lirulvs' => $goodslistMoney == 0 ? 0 : round(($liruns / $goodslistMoney) * 100, 2), ]; - - + + } @@ -384,4 +385,13 @@ class Statistics extends Base } + public function UserStatistics() + { + + $list = UserStatistics::order('id desc')->limit(30)->select(); + View::assign('list', $list); + return View::fetch('Statistics/userstatistics'); + } + + } diff --git a/app/admin/controller/Upload.php b/app/admin/controller/Upload.php index c5cc270..dedcb45 100755 --- a/app/admin/controller/Upload.php +++ b/app/admin/controller/Upload.php @@ -169,6 +169,12 @@ class Upload extends Base } } + public function uploadimage(){ + + // return + + return '{"imageActionName":"uploadimage","imageFieldName":"upfile","imageMaxSize":51200000,"imageAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp",".php"],"imageCompressEnable":true,"imageCompressBorder":600,"imageInsertAlign":"none","imageUrlPrefix":"","imagePathFormat":"\/ueditor\/php\/upload\/image\/{yyyy}{mm}{dd}\/{time}{rand:6}","scrawlActionName":"uploadscrawl","scrawlFieldName":"upfile","scrawlPathFormat":"\/ueditor\/php\/upload\/image\/{yyyy}{mm}{dd}\/{time}{rand:6}","scrawlMaxSize":51200000,"scrawlUrlPrefix":"","scrawlInsertAlign":"none","snapscreenActionName":"uploadimage","snapscreenPathFormat":"\/ueditor\/php\/upload\/image\/{yyyy}{mm}{dd}\/{time}{rand:6}","snapscreenUrlPrefix":"","snapscreenInsertAlign":"none","catcherLocalDomain":["127.0.0.1","localhost","img.baidu.com"],"catcherActionName":"catchimage","catcherFieldName":"source","catcherPathFormat":"\/ueditor\/php\/upload\/image\/{yyyy}{mm}{dd}\/{time}{rand:6}","catcherUrlPrefix":"","catcherMaxSize":51200000,"catcherAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp"],"videoActionName":"uploadvideo","videoFieldName":"upfile","videoPathFormat":"\/ueditor\/php\/upload\/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",".php",".wav",".mid"],"fileActionName":"uploadfile","fileFieldName":"upfile","filePathFormat":"\/ueditor\/php\/upload\/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",".php",".iso",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".pdf",".txt",".md",".xml"],"imageManagerActionName":"listimage","imageManagerListPath":"\/ueditor\/php\/upload\/image\/","imageManagerListSize":20,"imageManagerUrlPrefix":"","imageManagerInsertAlign":"none","imageManagerAllowFiles":[".png",".jpg",".jpeg",".gif",".php",".bmp"],"fileManagerActionName":"listfile","fileManagerListPath":"\/ueditor\/php\/upload\/file\/","fileManagerUrlPrefix":"","fileManagerListSize":20,"fileManagerAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp",".flv",".swf",".mkv",".avi",".rm",".rmvb",".mpeg",".php",".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"]}'; + } /** * 阿里云oss上传 diff --git a/app/admin/route/app.php b/app/admin/route/app.php index e3d14f6..f49914e 100755 --- a/app/admin/route/app.php +++ b/app/admin/route/app.php @@ -288,3 +288,8 @@ Route::rule('rvenue_del', 'Profit/rvenue_del', 'POST'); Route::rule('user_invite', 'user/user_invite', 'GET'); +Route::rule('user_statistics', 'Statistics/UserStatistics', 'GET'); + + + +Route::rule('ueditor_uploadimage', 'Upload/uploadimage', 'GET|POST'); diff --git a/app/admin/view/Danye/edit.html b/app/admin/view/Danye/edit.html index 3dc6cd1..3b2b575 100755 --- a/app/admin/view/Danye/edit.html +++ b/app/admin/view/Danye/edit.html @@ -1,66 +1,81 @@ {include file="Public:header2"/} + -
-
-
-
-
-
-
-
- -
- +
+
+
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
-
- -
- -
-
-
-
- - -
-
-
- + +
-
-{include file="Public:footer"/} + {include file="Public:footer"/} + + + + +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+
+ 备注:总收入=订单支付+其他收入;
+ 备注:总支出=订单出货+其他支出;
+ 备注:利润=总收入-总支出;
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ {include file="Public:footer"/} + + + + \ No newline at end of file diff --git a/app/admin/view/view_kM6dcB.tar.gz b/app/admin/view/view_kM6dcB.tar.gz deleted file mode 100755 index d29ce36..0000000 Binary files a/app/admin/view/view_kM6dcB.tar.gz and /dev/null differ diff --git a/app/command/UserStatisticsDay.php b/app/command/UserStatisticsDay.php new file mode 100644 index 0000000..3c569fe --- /dev/null +++ b/app/command/UserStatisticsDay.php @@ -0,0 +1,169 @@ +setName('UserStatisticsHour')->setDescription('用户每天数据统计'); + } + + protected function execute(Input $input, Output $output) + { + + //# 统计表 user_statistics + // ELECT `id`, `login_count`, `register_count`, `created_at`, `updated_at`, `record_date` FROM `user_statistics` + //# 用户登录记录表 user_account,last_login_time 最后登录时间(时间戳int(11) )。user_id 用户id + //SELECT `id`, `user_id`, `account_token`, `token_num`, `token_time`, `last_login_time`, `last_login_ip`, `last_login_ip1`, `ip_adcode`, `ip_province`, `ip_city` FROM `user_account` + $userList = User::where('istest', '>=', 1)->field('id')->select(); + $userNotArray = array_column($userList->toArray(), 'id'); + // 获取当天日期 + $today = date('Y-m-d'); + + // 检查当天的统计记录是否存在 + $existingRecord = UserStatistics::where('record_date', $today) + ->find(); + + $today_start = strtotime($today); + $today_end = strtotime($today . ' +1 day'); + // 查询当天的登录人数 + $loginCount = UserAccount::where('last_login_time', '>=', $today_start) + ->where('last_login_time', '<', $today_end) + ->count('DISTINCT user_id'); + //当天注册人数 + $registerCount = User::where('addtime', '>=', $today_start) + ->count('id'); + // 本日充值金额 + $order_today_price = OrderModel::where('status', '=', 1)->whereNotIn('user_id', $userNotArray) + ->whereBetweenTime( + 'addtime', + $today_start, + $today_end + )->sum('price'); + + // 消费人数统计 + $consume_today = OrderModel::where('status', '=', 1)->whereNotIn('user_id', $userNotArray) + ->whereBetweenTime( + 'addtime', + $today_start, + $today_end + ) + ->field('user_id')->group('user_id')->count('user_id'); + + // 消费RMB人数统计 + $consume_today_price = OrderModel::where('status', '=', 1) + ->where('price', '>', '0') + ->whereNotIn('user_id', $userNotArray) + ->whereBetweenTime( + 'addtime', + $today_start, + $today_end + ) + ->field('user_id')->group('user_id')->count('user_id'); + + //今日余额消费 + $money_today = OrderModel::where('status', '=', 1)->whereNotIn('user_id', $userNotArray) + ->whereBetweenTime( + 'addtime', + $today_start, + $today_end + )->sum('use_money'); + + //今日消费 + $order_zhe_total = OrderModel::where('status', '=', 1)->whereNotIn('user_id', $userNotArray) + ->whereBetweenTime( + 'addtime', + $today_start, + $today_end + )->sum('order_zhe_total'); + //今日消费 + $consume_order_count = OrderModel::where('status', '=', 1)->whereNotIn('user_id', $userNotArray) + ->whereBetweenTime( + 'addtime', + $today_start, + $today_end + )->count(); + + //发放价值 + $shipment_money = OrderList::whereBetweenTime('addtime', $today_start, $today_end)->whereNotIn('user_id', $userNotArray)->sum('goodslist_money'); + + //回收价值 + $shipment_money1 = OrderList::where('status', '=', 1)->whereBetweenTime('choice_time', $today_start, $today_end)->whereNotIn('user_id', $userNotArray)->sum('goodslist_money'); + + $send_money = OrderList::where('status', '=', 2)->whereBetweenTime('choice_time', $today_start, $today_end)->whereNotIn('user_id', $userNotArray)->sum('goodslist_money'); + $profit_expenses = ProfitExpenses::getTotalAmountByDate(date('Y-m-d')); + $profit_rvenue = ProfitRvenue::getTotalAmountByDate(date('Y-m-d')); + + $profit_money = $order_zhe_total - $shipment_money; + //今日余额发放 + $money_recovery_today = OrderListRecovery:: + whereBetweenTime( + 'addtime', + $today_start, + $today_end + )->whereNotIn('user_id', $userNotArray)->sum('money'); + if ($existingRecord) { + // 更新记录 + UserStatistics::where('record_date', $today) + ->update([ + 'login_count' => $loginCount, + 'register_count' => $registerCount, + 'recharge_amount' => $order_today_price, + 'consume_user_count' => $consume_today, + 'balance_consume' => $money_today, + 'balance_issue' => $money_recovery_today, + 'consume_rmb_count' => $consume_today_price, + 'recharge_sum' => $order_zhe_total, + 'consume_order_count' => $consume_order_count, + 'shipment_money' => $shipment_money, + 'send_money' => $send_money, + 'recycle_money' => $shipment_money1, + 'profit_money' => $profit_money, + 'all_shipment_money' => $shipment_money + $profit_expenses, + 'all_recycle_money' => $order_zhe_total + $profit_rvenue, + 'all_money' => round(($order_zhe_total + $profit_rvenue) - ($shipment_money + $profit_expenses), 2), + 'updated_at' => date('Y-m-d H:i:s') + ]); + } else { + // 插入新记录 + UserStatistics::insert([ + 'login_count' => $loginCount, + 'register_count' => $registerCount, // 假设注册人数统计在其他地方处理 + 'record_date' => $today, + 'recharge_amount' => $order_today_price, + 'balance_consume' => $money_today, + 'balance_issue' => $money_recovery_today, + 'consume_user_count' => $consume_today, + 'consume_rmb_count' => $consume_today_price, + 'recharge_sum' => $order_zhe_total, + 'consume_order_count' => $consume_order_count, + 'shipment_money' => $shipment_money, + 'send_money' => $send_money, + 'recycle_money' => $shipment_money1, + 'profit_money' => $profit_money, + 'all_shipment_money' => $shipment_money + $profit_expenses, + 'all_recycle_money' => $order_zhe_total + $profit_rvenue, + 'all_money' => round(($order_zhe_total + $profit_rvenue) - ($shipment_money + $profit_expenses), 2), + 'created_at' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s') + ]); + } + + } +} diff --git a/app/command/UserStatisticsHour.php b/app/command/UserStatisticsHour.php deleted file mode 100644 index 63b3dc4..0000000 --- a/app/command/UserStatisticsHour.php +++ /dev/null @@ -1,59 +0,0 @@ -setName('UserStatisticsHour')->setDescription('用户登录数据统计'); - } - - protected function execute(Input $input, Output $output) - { - - //# 统计表 user_statistics - // ELECT `id`, `login_count`, `register_count`, `created_at`, `updated_at`, `record_date` FROM `user_statistics` - //# 用户登录记录表 user_account,last_login_time 最后登录时间(时间戳int(11) )。user_id 用户id - //SELECT `id`, `user_id`, `account_token`, `token_num`, `token_time`, `last_login_time`, `last_login_ip`, `last_login_ip1`, `ip_adcode`, `ip_province`, `ip_city` FROM `user_account` - - // 获取当天日期 - $today = date('Y-m-d'); - - // 查询当天的登录人数 - $loginCount = UserAccount::where('last_login_time', '>=', strtotime($today)) - ->where('last_login_time', '<', strtotime($today . ' +1 day')) - ->count('DISTINCT user_id'); - - // 检查当天的统计记录是否存在 - $existingRecord = UserStatistics::where('record_date', $today) - ->find(); - - if ($existingRecord) { - // 更新记录 - UserStatistics::where('record_date', $today) - ->update(['login_count' => $loginCount, 'updated_at' => date('Y-m-d H:i:s')]); - } else { - // 插入新记录 - UserStatistics::insert([ - 'login_count' => $loginCount, - 'register_count' => 0, // 假设注册人数统计在其他地方处理 - 'record_date' => $today, - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s') - ]); - } - - } -} diff --git a/app/common.php b/app/common.php index 49aab54..c6d5303 100755 --- a/app/common.php +++ b/app/common.php @@ -12,18 +12,99 @@ if (!function_exists('getRandStr')) { function getRandStr($len = 30, $special = false) { $chars = array( - "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", - "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", - "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", - "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", - "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", - "3", "4", "5", "6", "7", "8", "9" + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9" ); if ($special) { $chars = array_merge($chars, array( - "!", "@", "#", "$", "?", "|", "{", "/", ":", ";", - "%", "^", "&", "*", "(", ")", "-", "_", "[", "]", - "}", "<", ">", "~", "+", "=", ",", "." + "!", + "@", + "#", + "$", + "?", + "|", + "{", + "/", + ":", + ";", + "%", + "^", + "&", + "*", + "(", + ")", + "-", + "_", + "[", + "]", + "}", + "<", + ">", + "~", + "+", + "=", + ",", + "." )); } $charsLen = count($chars) - 1; @@ -86,14 +167,14 @@ if (!function_exists('imageUrl')) { if ($url == '') { return ''; } - + if (strpos($url, 'http') !== false) { $path = $url; - } + } // else if (strpos($pre, '192.168') !== false) {#测试环境 // $path = $pre . "ceshi/public/" . $url; // } - else{ + else { $pre = request()->domain(); if ($url === '0') { $path = $pre; @@ -101,7 +182,7 @@ if (!function_exists('imageUrl')) { $path = $pre . $url; } } - + $path = str_replace('\\', '/', $path); return $path; @@ -117,11 +198,16 @@ if (!function_exists('contentUrl')) { function contentUrl($content) { $url = request()->domain() . '/'; + // $url="https://mh.shhuanmeng.com/"; // if (strpos($url, '192.168') !== false) {#测试环境 // $url = $url . "ceshi/public/"; // } - $pregRule = "/<[img|IMG].*?src=[\‘|\"](.*?(?:[\.jpg|\.jpeg|\.png|\.gif|\.bmp]))[\‘|\"].*?[\/]?>/"; - $content = preg_replace($pregRule, '', htmlspecialchars_decode($content)); + $pregRule = "/]*src=[\"'](?!http|https)([^\"']+\.(?:jpg|jpeg|png|gif|bmp))[\"'][^>]*>/i"; + + // 替换相对路径的图片 + $content = preg_replace_callback($pregRule, function ($matches) use ($url) { + return ''; + }, htmlspecialchars_decode($content)); return $content; } } @@ -198,12 +284,68 @@ if (!function_exists('getPrizeCode')) { function getPrizeCode($len = 10, $special = false) { $chars = array( - "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", - "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", - "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", - "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", - "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", - "3", "4", "5", "6", "7", "8", "9" + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9" ); $charsLen = count($chars) - 1; shuffle($chars); //打乱数组顺序 @@ -366,7 +508,7 @@ if (!function_exists('expressWuliu')) { $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); list($header, $body) = explode("\r\n\r\n", $out_put, 2); if ($httpCode == 200) { -// print("正常请求计费(其他均不计费)
"); + // print("正常请求计费(其他均不计费)
"); // print($body); $body = json_decode($body, true); if ($body['status'] == 0 && $body['msg'] == 'ok') { @@ -376,34 +518,34 @@ if (!function_exists('expressWuliu')) { } } else { if ($httpCode == 400 && strpos($header, "Invalid Param Location") !== false) { -// print("参数错误"); + // print("参数错误"); return ['code' => 0, 'msg' => '参数错误']; } elseif ($httpCode == 400 && strpos($header, "Invalid AppCode") !== false) { -// print("AppCode错误"); + // print("AppCode错误"); return ['code' => 0, 'msg' => 'AppCode错误']; } elseif ($httpCode == 400 && strpos($header, "Invalid Url") !== false) { -// print("请求的 Method、Path 或者环境错误"); + // print("请求的 Method、Path 或者环境错误"); return ['code' => 0, 'msg' => '请求的 Method、Path 或者环境错误']; } elseif ($httpCode == 403 && strpos($header, "Unauthorized") !== false) { -// print("服务未被授权(或URL和Path不正确)"); + // print("服务未被授权(或URL和Path不正确)"); return ['code' => 0, 'msg' => '服务未被授权(或URL和Path不正确)']; } elseif ($httpCode == 403 && strpos($header, "Quota Exhausted") !== false) { -// print("套餐包次数用完"); + // print("套餐包次数用完"); return ['code' => 0, 'msg' => '套餐包次数用完']; } elseif ($httpCode == 500) { -// print("API网关错误"); + // print("API网关错误"); return ['code' => 0, 'msg' => 'API网关错误']; } elseif ($httpCode == 0) { -// print("URL错误"); + // print("URL错误"); return ['code' => 0, 'msg' => 'URL错误']; } else { -// print("参数名错误 或 其他错误"); + // print("参数名错误 或 其他错误"); // print($httpCode); return ['code' => 0, 'msg' => '参数名错误 或 其他错误']; $headers = explode("\r\n", $header); @@ -412,7 +554,7 @@ if (!function_exists('expressWuliu')) { $value = explode(':', $head); $headList[$value[0]] = $value[1]; } - print($headList['x-ca-error-message']); + print ($headList['x-ca-error-message']); } } } @@ -492,7 +634,7 @@ if (!function_exists('time_jian')) { * @param $url 图片路径 * @return int */ - function time_jian($star_time,$end_time) + function time_jian($star_time, $end_time) { // 计算两个时间戳之间的差值(单位:秒) $timeDiff = $end_time - $star_time; @@ -503,16 +645,16 @@ if (!function_exists('time_jian')) { $hours = floor(($timeDiff / (60 * 60)) % 24); $days = floor($timeDiff / (60 * 60 * 24)); $str = ''; - if ($days){ + if ($days) { $str .= "{$days}天"; } - if ($hours){ + if ($hours) { $str .= "{$hours}小时"; } - if ($minutes){ + if ($minutes) { $str .= "{$minutes}分钟"; } - if ($seconds){ + if ($seconds) { $str .= "{$seconds}秒"; } return $str; @@ -520,45 +662,47 @@ if (!function_exists('time_jian')) { } // 订单支付日志 -function writelog($filename,$content){ +function writelog($filename, $content) +{ $date = date('Y-m-d'); - $file = "./pay_log/".$date; - if(!is_dir($file)){ + $file = "./pay_log/" . $date; + if (!is_dir($file)) { mkdir($file); } - $file = $file."/".$filename.".txt"; - $content = "【收到信息".date("Y-m-d H:i:s",time())."】".$content."\r\n\r\n"; - $open=fopen($file,"a" ); - fwrite($open,$content); + $file = $file . "/" . $filename . ".txt"; + $content = "【收到信息" . date("Y-m-d H:i:s", time()) . "】" . $content . "\r\n\r\n"; + $open = fopen($file, "a"); + fwrite($open, $content); fclose($open); } //广告 -function tencent_ad_attribution($click_id,$money,$account_id,$access_token,$user_action_set_id){ -// $access_token = '80a2138abe0227598ea9ae8a2a55ba69'; +function tencent_ad_attribution($click_id, $money, $account_id, $access_token, $user_action_set_id) +{ + // $access_token = '80a2138abe0227598ea9ae8a2a55ba69'; // $user_action_set_id = 1200995945; $interface = 'user_actions/add'; $url = 'https://api.e.qq.com/v1.1/' . $interface; - $common_parameters = array ( + $common_parameters = array( 'access_token' => $access_token, 'timestamp' => time(), 'nonce' => md5(uniqid('', true)) ); - $parameters = array ( + $parameters = array( 'account_id' => $account_id, 'user_action_set_id' => $user_action_set_id, 'actions' => - array ( + array( 0 => - array ( + array( 'url' => 'ruiou.ruiouyifanshang.com', - 'external_action_id' => strtolower(md5(rand(100000,999999))) . '_complete_order_1492991000_30569088_1200995945', + 'external_action_id' => strtolower(md5(rand(100000, 999999))) . '_complete_order_1492991000_30569088_1200995945', 'action_time' => time(), 'action_type' => 'COMPLETE_ORDER', -// 'custom_action' => 'my_type', + // 'custom_action' => 'my_type', 'trace' => [ 'click_id' => $click_id, ], @@ -569,7 +713,7 @@ function tencent_ad_attribution($click_id,$money,$account_id,$access_token,$user ), ), ); - // dd($parameters); + // dd($parameters); // dump($common_parameters); $parameters = json_encode($parameters); @@ -594,29 +738,30 @@ function tencent_ad_attribution($click_id,$money,$account_id,$access_token,$user throw new \Exception($error_msg, $error_no); } curl_close($curl); - \think\facade\Log::write($response,'warning'); + \think\facade\Log::write($response, 'warning'); return $response; - + } - function getData($url,$header){ +function getData($url, $header) +{ - $ch = curl_init(); - - curl_setopt($ch,CURLOPT_URL,$url); - - curl_setopt($ch,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1); - - curl_setopt($ch,CURLOPT_HTTPHEADER,$header); - - curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); - - curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,3); - - $handles = curl_exec($ch); - - curl_close($ch); - - return $handles; - } \ No newline at end of file + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_URL, $url); + + curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); + + curl_setopt($ch, CURLOPT_HTTPHEADER, $header); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); + + $handles = curl_exec($ch); + + curl_close($ch); + + return $handles; +} \ No newline at end of file diff --git a/config/console.php b/config/console.php index 314b903..8a87421 100755 --- a/config/console.php +++ b/config/console.php @@ -4,5 +4,6 @@ return [ 'RankWeek' => 'app\command\RankWeek',#周榜定榜 'RankMonth' => 'app\command\RankMonth',#月榜定榜 'Zd' => 'app\command\Zd',#自动发货 + 'UserStatisticsDay' => 'app\command\UserStatisticsDay',#自动发货 ], ]; diff --git a/config/menu.php b/config/menu.php index 98bd45f..1c83981 100755 --- a/config/menu.php +++ b/config/menu.php @@ -84,6 +84,10 @@ return [ 'url' => '/admin/ProfitRvenue', 'name' => '其它收入', ], + [ + 'url' => '/admin/user_statistics', + 'name' => '数据统计', + ], ], ], [