This commit is contained in:
youda 2025-05-09 23:57:09 +08:00
parent 9136611d97
commit 31c371235d
9 changed files with 268 additions and 67 deletions

View File

@ -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
]);
}
}

View File

@ -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');

View File

@ -62,8 +62,8 @@
<!-- 订单统计模板 -->
<script type="text/html" id="orderStatTpl">
<p>支付次数: {{d.orderCount || 0}}</p>
<p>订单总额: {{d.order_zhe_total || 0}}</p>
<p>支付成功次数: {{d.orderCount || 0}}</p>
<p>订单总额: {{d.order_zhe_total || 0}}</p>
<p>RMB支付: {{d.money_1 || 0}}</p>
<p>钻石支付: {{d.money_2 || 0}}</p>
</script>
@ -71,7 +71,37 @@
<!-- 用户利润模板 -->
<script type="text/html" id="profitTpl">
<p style="color: {{d.yue_money > 0 ? '#FF5722' : '#5FB878'}};">{{d.yue_money > 0 ? '亏损' : '盈利'}}: {{Math.abs(d.yue_money)}}</p>
<p> 支付金额({{d.use_money}}-发货金额({{d.fh_money}}-背包金额({{d.bb_money}}- 用户剩余达达券({{d.money2}}= {{d.yue_money}}</p>
<p> 支付金额({{d.use_money}}-发货金额({{d.fh_money}}-背包金额({{d.bb_money}}- 最后剩余达达券({{d.sy_money}}= {{d.yue_money}}</p>
</script>
<!-- 支付金额模板 -->
<script type="text/html" id="useMoneyTpl">
<div style="color: #FF5722;">
<i class="layui-icon layui-icon-rmb"></i> {{d.use_money || 0}}
</div>
</script>
<!-- 发货金额模板 -->
<script type="text/html" id="fhMoneyTpl">
<div style="color: #5FB878;">
<i class="layui-icon layui-icon-rmb"></i> {{d.fh_money || 0}}
</div>
</script>
<!-- 背包金额模板 -->
<script type="text/html" id="bbMoneyTpl">
<div style="color: #1E9FFF;">
<i class="layui-icon layui-icon-rmb"></i> {{d.bb_money || 0}}
</div>
</script>
<!-- 剩余达达券模板 -->
<script type="text/html" id="money2Tpl">
<div style="color: #FFB800; cursor: pointer;" lay-event="showMoney2Records">
用户当天剩余达达券:{{d.sy_money*100 || 0}} <i class="layui-icon layui-icon-diamond"></i><br />
用户目前达达券:{{d.money2*100 || 0}}
</div>
</script>
</div>
</div>
@ -79,6 +109,29 @@
</div>
</div>
<!-- 达达券记录弹窗 -->
<div id="money2RecordsDialog" style="display: none; padding: 15px;">
<div class="layui-form layui-form-pane" style="margin-bottom: 15px;">
<div class="layui-form-item">
<label class="layui-form-label">时间范围</label>
<div class="layui-input-inline" style="width: 300px;">
<input type="text" name="dialog_time_range" id="dialog_time_range" autocomplete="off"
placeholder="请选择时间范围" class="layui-input">
</div>
<div class="layui-inline">
<button class="layui-btn" id="dialogSearch">
<i class="layui-icon layui-icon-search"></i> 搜索
</button>
<button class="layui-btn layui-btn-primary" id="dialogReset">
<i class="layui-icon layui-icon-refresh"></i> 重置
</button>
</div>
</div>
</div>
<!-- 达达券记录表格 -->
<table id="money2RecordsTable" lay-filter="money2RecordsTable"></table>
</div>
{include file="Public:footer3" /}
<script>
@ -111,10 +164,10 @@
{ field: 'userInfo', title: '用户信息', templet: '#userInfoTpl', width: 240 },
{ field: 'currencyInfo', title: '用户货币', templet: '#currencyInfoTpl', width: 200 },
{ field: 'orderStat', title: '订单统计', templet: '#orderStatTpl', width: 180 },
{ field: 'use_money', title: '支付金额', width: 120, sort: true },
{ field: 'fh_money', title: '发货金额', width: 120, sort: true },
{ field: 'bb_money', title: '背包金额', width: 120, sort: true },
{ field: 'money2', title: '剩余达达券', width: 120, sort: true },
{ field: 'use_money', title: '支付金额', width: 120, sort: true, templet: '#useMoneyTpl' },
{ field: 'fh_money', title: '发货金额', width: 120, sort: true, templet: '#fhMoneyTpl' },
{ field: 'bb_money', title: '背包金额', width: 120, sort: true, templet: '#bbMoneyTpl' },
{ field: 'money2', title: '最后剩余达达券', width: 160, sort: true, templet: '#money2Tpl' },
{ field: 'yue_money', title: '亏损/盈利', minWidth: 260, templet: '#profitTpl' }
]],
parseData: function (res) {
@ -178,5 +231,81 @@
layer.msg('正在导出,请稍候...', {icon: 6});
});
// 监听表格行工具事件
table.on('tool(profit-loss-table)', function(obj){
var data = obj.data;
if(obj.event === 'showMoney2Records'){
// 弹出达达券记录弹窗
var layerIndex = layer.open({
type: 1,
title: '用户达达券记录',
area: ['900px', '600px'],
content: $('#money2RecordsDialog'),
success: function(){
// 日期范围选择器
laydate.render({
elem: '#dialog_time_range',
type: 'date',
range: true,
value: $('#time_range').val() // 默认使用主页面的时间范围
});
// 初始化达达券记录表格
renderMoney2RecordsTable(data.user_id, $('#time_range').val());
// 弹窗中的搜索按钮事件
$('#dialogSearch').off('click').on('click', function(){
renderMoney2RecordsTable(data.user_id, $('#dialog_time_range').val());
});
// 弹窗中的重置按钮事件
$('#dialogReset').off('click').on('click', function(){
$('#dialog_time_range').val('');
renderMoney2RecordsTable(data.user_id, '');
});
}
});
}
});
// 渲染达达券记录表格
function renderMoney2RecordsTable(userId, timeRange) {
table.render({
elem: '#money2RecordsTable',
url: '/admin/get_user_money2_records',
method: 'post',
where: {
user_id: userId,
time_range: timeRange
},
page: true,
limits: [10, 20, 50, 100],
limit: 10,
cols: [[
{ type: 'numbers', title: '序号', width: 60 },
{ field: 'change_money', title: '变化金额', width: 120,
templet: function(d){
var color = d.change_money > 0 ? '#5FB878' : '#FF5722';
return '<span style="color: '+ color +'">' + d.change_money + '</span>';
}
},
{ field: 'money', title: '剩余达达券', width: 120 },
{ field: 'content', title: '描述', minWidth: 300 },
{ field: 'addtime_fmt', title: '操作时间', width: 180 }
]],
parseData: function (res) {
return {
"code": res.code === 0 ? 0 : 1,
"msg": res.msg,
"count": res.count,
"data": res.data
};
},
response: {
statusCode: 0
}
});
}
});
</script>

View File

@ -26,7 +26,7 @@ class Config extends Base
return $this->renderSuccess('获取成功', [
'good_type' => $goodsTypeList,
'app_setting' => $app_setting,
'version' => '109'
'version' => '110'
]);
}

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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()

View File

@ -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;

View File

@ -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');