diff --git a/app/admin/controller/Statistics.php b/app/admin/controller/Statistics.php
index b084652..5d53f3a 100755
--- a/app/admin/controller/Statistics.php
+++ b/app/admin/controller/Statistics.php
@@ -775,7 +775,7 @@ class Statistics extends Base
];
// 计算利润和利润率
- $data['profit'] = $data['use_money'] - $data['sc_money'];
+ $data['profit'] = $data['use_money'] - ($data['sc_money'] - $data['re_money']);
$data['profit_rate'] = $data['use_money'] > 0 ? round(($data['profit'] / $data['use_money']) * 100, 2) : 0;
$data['is_negative'] = $data['profit'] < 0;
@@ -904,7 +904,7 @@ class Statistics extends Base
$totalFhMoney = floatval($fhMoneyQuery->sum('goodslist_money'));
// 计算总利润
- $totalProfit = $totalIncome - $totalCost;
+ $totalProfit = $totalIncome - ($totalCost - $totalReMoney);
// 返回汇总数据
$data = [
@@ -1339,7 +1339,7 @@ class Statistics extends Base
$totalFhMoney = floatval($fhMoneyQuery->sum('goodslist_money'));
// 计算总利润
- $totalProfit = $totalIncome - $totalCost;
+ $totalProfit = $totalIncome - ($totalCost - $totalReMoney);
// 返回汇总数据
return [
diff --git a/app/admin/view/Statistics/profit.html b/app/admin/view/Statistics/profit.html
index 79094de..d68f9a3 100755
--- a/app/admin/view/Statistics/profit.html
+++ b/app/admin/view/Statistics/profit.html
@@ -87,10 +87,10 @@
- ¥ 0.00
+ ¥ 0.00
@@ -299,12 +299,14 @@
}
},
{
- field: 'profit', title: '利润 ', width: 110, templet: function (d) {
+ field: 'profit', title: '利润 ', width: 110, templet: function (d) {
if (!d.loaded) {
return '
';
}
var colorClass = d.profit >= 0 ? 'layui-bg-green' : 'layui-bg-red';
- return '¥ ' + d.profit.toFixed(2) + '
';
+ // 构建详细计算公式展示
+ var detailCalc = d.use_money.toFixed(2) + ' - (' + d.sc_money.toFixed(2) + ' - ' + d.re_money.toFixed(2) + ') = ' + d.profit.toFixed(2);
+ return '¥ ' + d.profit.toFixed(2) + '
';
}
},
{
@@ -440,7 +442,7 @@
tr.find('td[data-field="single_box_profit_rate"] div').html('' + singleBoxProfitRate.toFixed(2) + '%');
var profitColorClass = data.profit >= 0 ? 'layui-bg-green' : 'layui-bg-red';
- tr.find('td[data-field="profit"] div').html('¥ ' + data.profit.toFixed(2) + '');
+ tr.find('td[data-field="profit"] div').html('¥ ' + data.profit.toFixed(2) + '');
var rateColorClass = data.profit_rate >= 0 ? 'layui-bg-green' : 'layui-bg-red';
tr.find('td[data-field="profit_rate"] div').html('' + data.profit_rate.toFixed(2) + '%');
@@ -469,6 +471,10 @@
$('#totalReMoney').text(summary.totalReMoney.toFixed(2));
$('#totalFhMoney').text(summary.totalFhMoney.toFixed(2));
+ // 设置总利润的计算详情
+ var calcDetail = summary.totalIncome.toFixed(2) + ' - (' + summary.totalCost.toFixed(2) + ' - ' + summary.totalReMoney.toFixed(2) + ') = ' + summary.totalProfit.toFixed(2);
+ $('#totalProfit').attr('data-calculation', calcDetail);
+
// 设置利润颜色
var profitElem = $('#totalProfit');
if (summary.totalProfit >= 0) {
@@ -577,6 +583,18 @@
time: 4000
});
});
+
+ // 为利润详情添加鼠标悬停事件(使用事件委托,处理动态加载的元素)
+ $(document).on('mouseenter', '.profit-detail', function () {
+ var that = this;
+ var calculation = $(that).data('calculation');
+ if (calculation) {
+ layer.tips(calculation, that, {
+ tips: [1, '#FF5722'],
+ time: 4000
+ });
+ }
+ });
}
});
diff --git a/app/common/model/GoodsExtend.php b/app/common/model/GoodsExtend.php
index b992fe6..d80bb21 100644
--- a/app/common/model/GoodsExtend.php
+++ b/app/common/model/GoodsExtend.php
@@ -42,15 +42,15 @@ class GoodsExtend extends Base
*/
public static function getGoodsExtendByGoodsId($goodsId, $goods_type)
{
- // 生成缓存键
- $redis = (new \app\common\server\RedisHelper())->getRedis();
- $cache_key = "goods_extend:{$goodsId}:{$goods_type}";
+ // // 生成缓存键
+ // $redis = (new \app\common\server\RedisHelper())->getRedis();
+ // $cache_key = "goods_extend:{$goodsId}:{$goods_type}";
- // 尝试从缓存获取数据
- $cached_data = $redis->get($cache_key);
- if ($cached_data) {
- return json_decode($cached_data, true);
- }
+ // // 尝试从缓存获取数据
+ // $cached_data = $redis->get($cache_key);
+ // if ($cached_data) {
+ // return json_decode($cached_data, true);
+ // }
$goods_extend = self::where('goods_id', $goodsId)->find();
if (!$goods_extend) {
@@ -74,10 +74,10 @@ class GoodsExtend extends Base
}
}
- // 将数据存入缓存,设置5分钟过期时间
- if ($goods_extend) {
- $redis->set($cache_key, json_encode($goods_extend), 300);
- }
+ // // 将数据存入缓存,设置5分钟过期时间
+ // if ($goods_extend) {
+ // $redis->set($cache_key, json_encode($goods_extend), 300);
+ // }
return $goods_extend;
}