From 31c371235dfc300a33b3c558b7e07d1e3d39cd99 Mon Sep 17 00:00:00 2001 From: youda Date: Fri, 9 May 2025 23:57:09 +0800 Subject: [PATCH] 11 --- app/admin/controller/User.php | 133 ++++++++++++---- app/admin/route/app.php | 1 + .../view/User/user_profit_loss_list.html | 143 +++++++++++++++++- app/api/controller/Config.php | 2 +- app/api/controller/Login.php | 4 +- app/api/controller/Other.php | 13 ++ app/common/server/platform/H5Platform.php | 6 +- .../server/platform/MiniProgramPlatform.php | 6 +- route/app.php | 27 +--- 9 files changed, 268 insertions(+), 67 deletions(-) diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php index 118ff67..f0b30f5 100755 --- a/app/admin/controller/User.php +++ b/app/admin/controller/User.php @@ -1526,7 +1526,8 @@ class User extends Base $where = []; $whereUser = 'u.status=1 and u.istest=0 and o.status=1'; $whereUser1 = ''; - + $whereUser2 = ''; + $whereUser3 = ''; // 处理时间范围参数 if (!empty($param['time_range'])) { $dates = explode(' - ', $param['time_range']); @@ -1536,7 +1537,9 @@ class User extends Base $end_time = strtotime($dates[1] . ' 23:59:59'); // 只有当提供了时间范围时,才添加时间条件 $whereUser .= " and o.addtime > {$start_time} and o.addtime < {$end_time}"; - $whereUser1 = "and addtime < {$end_time}"; + $whereUser1 = " and addtime > {$start_time} and addtime < {$end_time}"; + $whereUser2 = " and choice_time > {$start_time} and choice_time < {$end_time}"; + $whereUser3 = " and addtime < {$end_time} "; } } @@ -1558,10 +1561,11 @@ class User extends Base } // 构建SQL查询 + // 构建SQL查询 - 不应用分页限制,获取全部数据 $sql = "select c.* from ( select t.*, (CASE - WHEN t.use_money>0 THEN (t.use_money-t.fh_money-t.bb_money-t.money2) + WHEN t.use_money>0 THEN (t.use_money-t.fh_money-t.bb_money-t.sy_money) ELSE 0 END) yue_money from ( @@ -1573,11 +1577,14 @@ class User extends Base IFNULL(sum(price),0) money_1, IFNULL(sum(use_money),0) money_2, IFNULL(sum(price)+SUM(use_money),0) use_money, - (select IFNULL(sum(goodslist_money),0) sc_money from order_list where user_id=o.user_id and status=2 {$whereUser1}) fh_money, - (select IFNULL(sum(goodslist_money),0) sc_money from order_list where user_id=o.user_id and status=0 {$whereUser1}) bb_money, - (TRUNCATE(u.money2/100, 2)) money2 + (select IFNULL(sum(goodslist_money),0) sc_money from order_list where user_id=o.user_id and status=2 {$whereUser2}) fh_money, + (select IFNULL(sum(goodslist_money),0) sc_money from order_list where user_id=o.user_id and status=0 {$whereUser3}) bb_money, + (TRUNCATE(u.money2/100, 2)) money2, + (TRUNCATE(IFNULL((SELECT money FROM profit_money2 where user_id=o.user_id {$whereUser1} order by id desc LIMIT 1),0)/100, 2)) sy_money FROM `order` o LEFT join `user` u ON o.user_id=u.id where {$whereUser} group by o.user_id ) t where use_money>0 ) c order by yue_money desc"; + //添加日志记录 + \think\facade\Log::info($sql); // 分页处理 $page = isset($param['page']) ? intval($param['page']) : 1; @@ -1634,7 +1641,8 @@ class User extends Base $where = []; $whereUser = 'u.status=1 and u.istest=0 and o.status=1'; $whereUser1 = ''; - + $whereUser2 = ''; + $whereUser3 = ''; // 处理时间范围参数 if (!empty($param['time_range'])) { $dates = explode(' - ', $param['time_range']); @@ -1644,7 +1652,9 @@ class User extends Base $end_time = strtotime($dates[1] . ' 23:59:59'); // 只有当提供了时间范围时,才添加时间条件 $whereUser .= " and o.addtime > {$start_time} and o.addtime < {$end_time}"; - $whereUser1 = "and addtime < {$end_time}"; + $whereUser1 = " and addtime > {$start_time} and addtime < {$end_time}"; + $whereUser2 = " and choice_time > {$start_time} and choice_time < {$end_time}"; + $whereUser3 = " and addtime < {$start_time} "; } } @@ -1665,28 +1675,30 @@ class User extends Base } } - // 构建SQL查询 - 不应用分页限制,获取全部数据 - $sql = "select c.* from ( - select t.*, - (CASE - WHEN t.use_money>0 THEN (t.use_money-t.fh_money-t.bb_money-t.money2) - ELSE 0 - END) yue_money - from ( - SELECT o.user_id, u.uid, u.nickname, u.headimg, u.mobile, - u.money, - u.integral, - count(1) orderCount, - sum(IFNULL(order_zhe_total,0)) order_zhe_total, - IFNULL(sum(price),0) money_1, - IFNULL(sum(use_money),0) money_2, - IFNULL(sum(price)+SUM(use_money),0) use_money, - (select IFNULL(sum(goodslist_money),0) sc_money from order_list where user_id=o.user_id and status=2 {$whereUser1}) fh_money, - (select IFNULL(sum(goodslist_money),0) sc_money from order_list where user_id=o.user_id and status=0 {$whereUser1}) bb_money, - (TRUNCATE(u.money2/100, 2)) money2 - FROM `order` o LEFT join `user` u ON o.user_id=u.id where {$whereUser} group by o.user_id ) t where use_money>0 - ) c order by yue_money desc"; - + // 构建SQL查询 - 不应用分页限制,获取全部数据 + $sql = "select c.* from ( + select t.*, + (CASE + WHEN t.use_money>0 THEN (t.use_money-t.fh_money-t.bb_money-t.sy_money) + ELSE 0 + END) yue_money + from ( + SELECT o.user_id, u.uid, u.nickname, u.headimg, u.mobile, + u.money, + u.integral, + count(1) orderCount, + sum(IFNULL(order_zhe_total,0)) order_zhe_total, + IFNULL(sum(price),0) money_1, + IFNULL(sum(use_money),0) money_2, + IFNULL(sum(price)+SUM(use_money),0) use_money, + (select IFNULL(sum(goodslist_money),0) sc_money from order_list where user_id=o.user_id and status=2 {$whereUser2}) fh_money, + (select IFNULL(sum(goodslist_money),0) sc_money from order_list where user_id=o.user_id and status=0 {$whereUser3}) bb_money, + (TRUNCATE(u.money2/100, 2)) money2, + (TRUNCATE(IFNULL((SELECT money FROM profit_money2 where user_id=o.user_id {$whereUser1} order by id desc LIMIT 1),0)/100, 2)) sy_money + FROM `order` o LEFT join `user` u ON o.user_id=u.id where {$whereUser} group by o.user_id ) t where use_money>0 + ) c order by yue_money desc"; + //添加日志记录 + \think\facade\Log::info($sql); // 执行查询 $list = \think\facade\Db::query($sql); @@ -1695,7 +1707,8 @@ class User extends Base // 格式化数值 $item['money'] = floatval($item['money']); $item['integral'] = floatval($item['integral']); - $item['money2'] = floatval($item['money2']); + $item['money2'] = floatval($item['money2']*100); + $item['sy_money'] = floatval($item['sy_money']*100); $item['order_zhe_total'] = floatval($item['order_zhe_total']); $item['money_1'] = floatval($item['money_1']); $item['money_2'] = floatval($item['money_2']); @@ -1775,7 +1788,7 @@ class User extends Base $sheet->setCellValue('M' . $row, $item['use_money']); $sheet->setCellValue('N' . $row, $item['fh_money']); $sheet->setCellValue('O' . $row, $item['bb_money']); - $sheet->setCellValue('P' . $row, $item['money2']); + $sheet->setCellValue('P' . $row, "用户剩余:".$item['sy_money']); $sheet->setCellValue('Q' . $row, $item['profit_status']); $sheet->setCellValue('R' . $row, $item['profit_value']); $sheet->setCellValue('S' . $row, $item['yue_money']); @@ -1833,4 +1846,60 @@ class User extends Base return $user ? $user['id'] : 0; } } + + /** + * 获取用户达达券记录 + */ + public function getUserMoney2Records() + { + $param = input(); + + // 验证参数 + if (empty($param['user_id'])) { + return json(['code' => 1, 'msg' => '缺少用户ID参数']); + } + + // 分页参数 + $page = isset($param['page']) ? intval($param['page']) : 1; + $limit = isset($param['limit']) ? intval($param['limit']) : 10; + $offset = ($page - 1) * $limit; + + // 时间范围处理 + $whereTime = ''; + if (!empty($param['time_range'])) { + $dates = explode(' - ', $param['time_range']); + if (count($dates) == 2) { + $start_time = strtotime($dates[0]); + $end_time = strtotime($dates[1] . ' 23:59:59'); + $whereTime = " and addtime > {$start_time} and addtime < {$end_time}"; + } + } + + // 获取总记录数 + $countSql = "SELECT COUNT(*) as count FROM profit_money2 WHERE user_id = :user_id {$whereTime}"; + $count = \think\facade\Db::query($countSql, ['user_id' => $param['user_id']])[0]['count']; + + // 构建SQL查询并添加分页 + $sql = "SELECT (change_money/100) change_money, (money/100) money, content, FROM_UNIXTIME(addtime) as addtime_fmt, addtime + FROM profit_money2 + WHERE user_id = :user_id {$whereTime} + ORDER BY id desc + LIMIT {$offset}, {$limit}"; + + // 执行查询 + $list = \think\facade\Db::query($sql, ['user_id' => $param['user_id']]); + + // 处理数据,将达达券值转换为显示格式(乘以100) + foreach ($list as &$item) { + $item['change_money'] = floatval($item['change_money']) * 100; + $item['money'] = floatval($item['money']) * 100; + } + + return json([ + 'code' => 0, + 'msg' => '', + 'count' => $count, + 'data' => $list + ]); + } } diff --git a/app/admin/route/app.php b/app/admin/route/app.php index 9c0525f..38d4728 100755 --- a/app/admin/route/app.php +++ b/app/admin/route/app.php @@ -40,6 +40,7 @@ Route::rule('user_profit_loss', 'User/user_profit_loss', 'GET|POST'); Route::rule('user_profit_loss_list', 'User/userProfitLossList', 'GET'); Route::rule('get_user_profit_loss', 'User/getUserProfitLoss', 'POST'); Route::rule('export_user_profit_loss', 'User/exportUserProfitLoss', 'GET'); +Route::rule('get_user_money2_records', 'User/getUserMoney2Records', 'POST'); Route::rule('user_shangdai', 'User/user_shangdai', 'GET|POST'); Route::rule('vip', 'User/vip', 'GET|POST'); Route::rule('vip_edit', 'User/vip_edit', 'GET|POST'); diff --git a/app/admin/view/User/user_profit_loss_list.html b/app/admin/view/User/user_profit_loss_list.html index 5a5cb60..7a2f112 100644 --- a/app/admin/view/User/user_profit_loss_list.html +++ b/app/admin/view/User/user_profit_loss_list.html @@ -62,8 +62,8 @@ @@ -71,7 +71,37 @@ + + + + + + + + + + + + @@ -79,6 +109,29 @@ + + {include file="Public:footer3" /} \ No newline at end of file diff --git a/app/api/controller/Config.php b/app/api/controller/Config.php index 0c1f619..adfb962 100755 --- a/app/api/controller/Config.php +++ b/app/api/controller/Config.php @@ -26,7 +26,7 @@ class Config extends Base return $this->renderSuccess('获取成功', [ 'good_type' => $goodsTypeList, 'app_setting' => $app_setting, - 'version' => '109' + 'version' => '110' ]); } diff --git a/app/api/controller/Login.php b/app/api/controller/Login.php index 4269a2e..e07d0c9 100755 --- a/app/api/controller/Login.php +++ b/app/api/controller/Login.php @@ -884,13 +884,13 @@ class Login extends Base $redis = (new RedisHelper())->getRedis(); $redisKey = "VerificationCode:{$mobile}"; $redisCode = $redis->get($redisKey); - if ($code != "9999") { + // if ($code != "9999") { if (empty($redisCode) || $redisCode != $code) { $logMessages[] = '验证码错误: ' . $code . ',正确验证码: ' . $redisCode; Log::error(end($logMessages)); return $this->renderError('验证码错误'); } - } + // } // 验证通过后删除Redis中的验证码 $redis->del($redisKey); diff --git a/app/api/controller/Other.php b/app/api/controller/Other.php index f7b6f4f..32c0d97 100644 --- a/app/api/controller/Other.php +++ b/app/api/controller/Other.php @@ -264,4 +264,17 @@ class Other extends Base return $this->renderError('设置失败: ' . $e->getMessage()); } } + + /** + * 下载APP + * 重定向到CDN下载地址 + */ + public function downloadApp() + { + // 这里替换成你的实际CDN下载地址 + $downloadUrl = 'https://image.zfunbox.cn/apk/app-release-v1.0.0.apk'; + + // 重定向到下载地址 + return redirect($downloadUrl); + } } diff --git a/app/common/server/platform/H5Platform.php b/app/common/server/platform/H5Platform.php index 20b6fb9..a7adad7 100644 --- a/app/common/server/platform/H5Platform.php +++ b/app/common/server/platform/H5Platform.php @@ -71,9 +71,9 @@ class H5Platform extends BasePlatform // 生成新的支付通知URL $notifyUrl = generatePayNotifyUrl($payment_type, $order_type, $user_id, $order_no, $callback_nonce_str); $is_test = $user['istest']; - if ($is_test == 2) { - $price = 0.01; - } + // if ($is_test == 2) { + // $price = 0.01; + // } $returnUrl = urldecode($returnUrl); //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) $result = Factory::payment() diff --git a/app/common/server/platform/MiniProgramPlatform.php b/app/common/server/platform/MiniProgramPlatform.php index e8c329a..6ad6ed1 100644 --- a/app/common/server/platform/MiniProgramPlatform.php +++ b/app/common/server/platform/MiniProgramPlatform.php @@ -101,9 +101,9 @@ class MiniProgramPlatform extends BasePlatform // 生成新的支付通知URL $notifyUrl = generatePayNotifyUrl($payment_type, $order_type, $user_id, $order_no, $callback_nonce_str); $is_test = $user['istest']; - if ($is_test == 2) { - $price = 0.01; - } + // if ($is_test == 2) { + // $price = 0.01; + // } $params['appid'] = $this->wx_appid; $params['mch_id'] = $this->getMchId(); $params['nonce_str'] = $nonce_str; diff --git a/route/app.php b/route/app.php index 33ca415..7535ba7 100755 --- a/route/app.php +++ b/route/app.php @@ -10,26 +10,15 @@ // +---------------------------------------------------------------------- use think\facade\Route; -Route::get('think', function () { - // $absolutePath = realpath('./public/img_poster.jpg'); - $currentDir = getcwd(); - $absolutePath = $currentDir . '/public/img_poster.jpg'; - return $absolutePath; -}); +// Route::get('think', function () { +// // $absolutePath = realpath('./public/img_poster.jpg'); +// $currentDir = getcwd(); +// $absolutePath = $currentDir . '/public/img_poster.jpg'; +// return $absolutePath; +// }); Route::get('hello/:name', 'index/hello'); -Route::get('baji', function () { - // return 'hello'; - // return view('baji'); - $wxServer = new \app\common\server\Wx($this->app); - $user_base = $wxServer->generateUrlLink(); - header("Location: " . $user_base); - exit(); -}); -Route::get('baji1', function () { - // return 'hello'; - return view('baji'); -}); - +Route::get('downloadApp', 'Other/downloadApp'); + \ No newline at end of file