修改要统计的表

This commit is contained in:
wangxiaowei 2024-11-06 10:43:33 +08:00
parent 5e85745aae
commit 022ad19939

@ -14,7 +14,6 @@ use app\common\model\user\User;
use app\common\server\UrlServer;
use think\facade\Config;
use think\facade\Db;
use app\common\model\localstore\LocalGoodsOrder;
class LocalStoreLogic extends Logic
{
@ -768,16 +767,18 @@ class LocalStoreLogic extends Logic
public static function countData($post, $user_id)
{
// ->where(['lso.state' => 1, 'lso.pay_shop_type' => 1, 'lso.lstore_id' => $data['lstore_id']])
$where = [
['lstore_id', '=', $post['lstore_id']],
['user_id', '=', $user_id],
['pay_shop_type', '=', 1],
['state', '=', 1]
];
$model = new LocalGoodsOrder();
$model = new LocalStoreOrder();
// 历史订单总和
$history_total_amount = $model->where($where)->sum('goods_total_price');
$history_total_amount = $model->where($where)->sum('total_amount');
// 本月业绩总和
$current_month_start = date('Y-m-01 00:00:00'); // 当月开始日期
@ -785,9 +786,9 @@ class LocalStoreLogic extends Logic
$current_month_total_amount = $model
->where($where)
->where([
['dtime', '>=', $current_month_start],
['dtime', '<=', $current_month_end]
])->sum('goods_total_price');
['create_time', '>=', $current_month_start],
['create_time', '<=', $current_month_end]
])->sum('total_amount');
// 上月业绩总和
$last_month_start = date('Y-m-01 00:00:00', strtotime('-1 month')); // 上月开始日期
@ -795,9 +796,9 @@ class LocalStoreLogic extends Logic
$last_month_total_amount = $model
->where($where)
->where([
['dtime', '>=', $last_month_start],
['dtime', '<=', $last_month_end]
])->sum('goods_total_price');
['create_time', '>=', $last_month_start],
['create_time', '<=', $last_month_end]
])->sum('total_amount');
// 当日营业额
$current_day_start = date('Y-m-d 00:00:00');
@ -805,9 +806,9 @@ class LocalStoreLogic extends Logic
$current_day_total_amount = $model
->where($where)
->where([
['dtime', '>=', $current_day_start],
['dtime', '<=', $current_day_end]
])->sum('goods_total_price');
['create_time', '>=', $current_day_start],
['create_time', '<=', $current_day_end]
])->sum('total_amount');
// 统计当日数据: 总共支付交易笔数 report = 1(日报) report = 2(月报)
$trade_where = $where;
@ -827,17 +828,17 @@ class LocalStoreLogic extends Logic
$filter_month_total_amount = $model
->where($where)
->where([
['dtime', '>=', $time_where['start']],
['dtime', '<=', $time_where['end']]
])->sum('goods_total_price');
['create_time', '>=', $time_where['start']],
['create_time', '<=', $time_where['end']]
])->sum('total_amount');
}
// 总共交易笔数
$count_trade = $model
->where($trade_where)
->where([
['dtime', '>=', $time_where['start']],
['dtime', '<=', $time_where['end']]
['create_time', '>=', $time_where['start']],
['create_time', '<=', $time_where['end']]
])->count();
// 支付成功交易笔数
@ -845,8 +846,8 @@ class LocalStoreLogic extends Logic
$success_trade = $model
->where($trade_where)
->where([
['dtime', '>=', $time_where['start']],
['dtime', '<=', $time_where['end']]
['create_time', '>=', $time_where['start']],
['create_time', '<=', $time_where['end']]
])->count();
// 单笔均价