合并代码

This commit is contained in:
zpc 2025-05-16 19:16:30 +08:00
commit 4e2bb8eb89
3 changed files with 48 additions and 42 deletions

View File

@ -1577,8 +1577,8 @@ class User extends Base
IFNULL(sum(price),0) money_1, IFNULL(sum(price),0) money_1,
IFNULL(sum(use_money),0) money_2, IFNULL(sum(use_money),0) money_2,
IFNULL(sum(price)+SUM(use_money),0) use_money, 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=2 and goodslist_type<3 {$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, (select IFNULL(sum(goodslist_money),0) sc_money from order_list where user_id=o.user_id and status=0 and goodslist_type<3 {$whereUser3}) bb_money,
(TRUNCATE(u.money2/100, 2)) money2, (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 (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 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
@ -1654,7 +1654,7 @@ class User extends Base
$whereUser .= " and o.addtime > {$start_time} and o.addtime < {$end_time}"; $whereUser .= " and o.addtime > {$start_time} and o.addtime < {$end_time}";
$whereUser1 = " and addtime > {$start_time} and addtime < {$end_time}"; $whereUser1 = " and addtime > {$start_time} and addtime < {$end_time}";
$whereUser2 = " and choice_time > {$start_time} and choice_time < {$end_time}"; $whereUser2 = " and choice_time > {$start_time} and choice_time < {$end_time}";
$whereUser3 = " and addtime < {$start_time} "; $whereUser3 = " and addtime < {$end_time} ";
} }
} }
@ -1675,40 +1675,44 @@ class User extends Base
} }
} }
// 构建SQL查询 - 不应用分页限制,获取全部数据 // 构建SQL查询 - 不应用分页限制,获取全部数据
$sql = "select c.* from ( $sql = "select c.* from (
select t.*, select t.*,
(CASE (CASE
WHEN t.use_money>0 THEN (t.use_money-t.fh_money-t.bb_money-t.sy_money) WHEN t.use_money>0 THEN (t.use_money-t.fh_money-t.bb_money-t.sy_money)
ELSE 0 ELSE 0
END) yue_money END) yue_money
from ( from (
SELECT o.user_id, u.uid, u.nickname, u.headimg, u.mobile, SELECT o.user_id, u.uid, u.nickname, u.headimg, u.mobile,
u.money, u.money,
u.integral, u.integral,
count(1) orderCount, count(1) orderCount,
sum(IFNULL(order_zhe_total,0)) order_zhe_total, sum(IFNULL(order_zhe_total,0)) order_zhe_total,
IFNULL(sum(price),0) money_1, IFNULL(sum(price),0) money_1,
IFNULL(sum(use_money),0) money_2, IFNULL(sum(use_money),0) money_2,
IFNULL(sum(price)+SUM(use_money),0) use_money, 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=2 and goodslist_type<3 {$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, (select IFNULL(sum(goodslist_money),0) sc_money from order_list where user_id=o.user_id and status=0 and goodslist_type<3 {$whereUser3}) bb_money,
(TRUNCATE(u.money2/100, 2)) money2, (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 (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 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"; ) c order by yue_money desc";
//添加日志记录
\think\facade\Log::info($sql); //添加日志记录
\think\facade\Log::info($sql);
// 执行查询 // 执行查询
$list = \think\facade\Db::query($sql); $list = \think\facade\Db::query($sql);
// 处理结果数据 // 处理结果数据
foreach ($list as &$item) { foreach ($list as &$item) {
// 处理图片URL
$item['headimg'] = empty($item['headimg']) ? '' : imageUrl($item['headimg']);
// 格式化数值 // 格式化数值
$item['money'] = floatval($item['money']); $item['money'] = floatval($item['money']);
$item['integral'] = floatval($item['integral']); $item['integral'] = floatval($item['integral']);
$item['money2'] = floatval($item['money2']*100); $item['money2'] = floatval($item['money2']);
$item['sy_money'] = floatval($item['sy_money']*100);
$item['order_zhe_total'] = floatval($item['order_zhe_total']); $item['order_zhe_total'] = floatval($item['order_zhe_total']);
$item['money_1'] = floatval($item['money_1']); $item['money_1'] = floatval($item['money_1']);
$item['money_2'] = floatval($item['money_2']); $item['money_2'] = floatval($item['money_2']);
@ -1760,7 +1764,7 @@ class User extends Base
'P' => '剩余达达券', 'P' => '剩余达达券',
'Q' => '亏损/盈利状态', 'Q' => '亏损/盈利状态',
'R' => '亏损/盈利金额', 'R' => '亏损/盈利金额',
'S' => '利润值' // 'S' => '利润值'
]; ];
foreach ($headers as $key => $val) { foreach ($headers as $key => $val) {
@ -1788,7 +1792,7 @@ class User extends Base
$sheet->setCellValue('M' . $row, $item['use_money']); $sheet->setCellValue('M' . $row, $item['use_money']);
$sheet->setCellValue('N' . $row, $item['fh_money']); $sheet->setCellValue('N' . $row, $item['fh_money']);
$sheet->setCellValue('O' . $row, $item['bb_money']); $sheet->setCellValue('O' . $row, $item['bb_money']);
$sheet->setCellValue('P' . $row, "用户剩余:".$item['sy_money']); $sheet->setCellValue('P' . $row, $item['sy_money']);
$sheet->setCellValue('Q' . $row, $item['profit_status']); $sheet->setCellValue('Q' . $row, $item['profit_status']);
$sheet->setCellValue('R' . $row, $item['profit_value']); $sheet->setCellValue('R' . $row, $item['profit_value']);
$sheet->setCellValue('S' . $row, $item['yue_money']); $sheet->setCellValue('S' . $row, $item['yue_money']);
@ -1798,12 +1802,12 @@ class User extends Base
// 亏损标红 // 亏损标红
$sheet->getStyle('Q' . $row)->getFont()->getColor()->setARGB('FFFF0000'); $sheet->getStyle('Q' . $row)->getFont()->getColor()->setARGB('FFFF0000');
$sheet->getStyle('R' . $row)->getFont()->getColor()->setARGB('FFFF0000'); $sheet->getStyle('R' . $row)->getFont()->getColor()->setARGB('FFFF0000');
$sheet->getStyle('S' . $row)->getFont()->getColor()->setARGB('FFFF0000'); // $sheet->getStyle('S' . $row)->getFont()->getColor()->setARGB('FFFF0000');
} else { } else {
// 盈利标绿 // 盈利标绿
$sheet->getStyle('Q' . $row)->getFont()->getColor()->setARGB('FF008000'); $sheet->getStyle('Q' . $row)->getFont()->getColor()->setARGB('FF008000');
$sheet->getStyle('R' . $row)->getFont()->getColor()->setARGB('FF008000'); $sheet->getStyle('R' . $row)->getFont()->getColor()->setARGB('FF008000');
$sheet->getStyle('S' . $row)->getFont()->getColor()->setARGB('FF008000'); // $sheet->getStyle('S' . $row)->getFont()->getColor()->setARGB('FF008000');
} }
$row++; $row++;

View File

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

View File

@ -65,14 +65,8 @@ class MiniProgramPlatform extends BasePlatform
$currentMinute = (int) date('i'); $currentMinute = (int) date('i');
$currentTime = $currentHour * 100 + $currentMinute; $currentTime = $currentHour * 100 + $currentMinute;
// if ($currentTime < 800 || $currentTime >= 2200) {
// return [
// 'status' => 0,
// 'data' => [],
// 'msg' => '支付未开放请在08:00-22:00范围内购买'
// ];
// }
$data += ['user' => null, 'price' => 0, 'title' => '', 'attach' => 'order_wxs', 'pre' => 'MH_']; $data += ['user' => null, 'price' => 0, 'title' => '', 'attach' => 'order_wxs', 'pre' => 'MH_'];
[ [
'user' => $user, 'user' => $user,
@ -97,11 +91,19 @@ class MiniProgramPlatform extends BasePlatform
] ]
]; ];
} }
return [ return [
'status' => 0, 'status' => 0,
'data' => [], 'data' => [],
'msg' => '小程序支付通道维护中请联系客服下载app。' 'msg' => '小程序支付通道维护中请联系客服下载app。'
]; ];
if ($currentTime < 800 || $currentTime >= 2200) {
return [
'status' => 0,
'data' => [],
'msg' => '支付未开放请在08:00-22:00范围内购买'
];
}
$title = mb_substr($title, 0, 30); $title = mb_substr($title, 0, 30);
$prefix = $this->GetPrefix(); $prefix = $this->GetPrefix();