feat(admin): 添加订单列表统计功能

- 在 BeforehandOrderController 中添加 statistics_count 方法处理统计请求
- 在 BeforehandOrderLogic 中实现 statisticsCount 方法进行订单统计
- 统计内容包括不同状态的订单数量,如未出库、已出库、未入库、已入库等
- 优化了代码格式,调整了部分缩进和空格
This commit is contained in:
mkm 2025-01-09 17:58:39 +08:00
parent 3d897d5dda
commit 222dcbfcbb
3 changed files with 97 additions and 33 deletions

View File

@ -37,7 +37,15 @@ class BeforehandOrderController extends BaseAdminController
{
return $this->dataLists(new BeforehandOrderLists());
}
/**
* 列表统计
*/
public function statistics_count()
{
$params=$this->request->get();
$data=BeforehandOrderLogic::statisticsCount($params);
return $this->data($data);
}
public function warehousing_lists()
{
return $this->dataLists(new BeforehandOrderTwoLists());

View File

@ -948,4 +948,56 @@ class BeforehandOrderLogic extends BaseLogic
$model->save();
}
/**
* 统计
*/
public static function statisticsCount($params)
{
$where = [];
if ($params['warehouse_type'] > 0) {
switch ($params['warehouse_type']) {
case 1:
$where[] = ['is_outbound', '=', 0];
$where[] = ['order_type', '<>', 5];
break;
case 2:
$where[] = ['is_outbound', '=', 1];
break;
case 3:
$where[] = ['is_warehousing', '=', 0];
break;
case 4:
$where[] = ['is_warehousing', '=', 1];
break;
default:
break;
}
}
$orderCounts = BeforehandOrder::where('order_type', 'in', [1, 2, 3, 4, 5, 7, 8])
->group('order_type')
->where(['order_type', Db::raw('count(*) as count')])
->column('count', 'order_type');
d($orderCounts);
$order_type_1 = BeforehandOrder::where([['order_type', '=', 1]])->count();
$order_type_2 = BeforehandOrder::where([['order_type', '=', 2]])->count();
$order_type_3 = BeforehandOrder::where([['order_type', '=', 3]])->count();
$order_type_4 = BeforehandOrder::where([['order_type', '=', 4]])->count();
$order_type_5 = BeforehandOrder::where([['order_type', '=', 5]])->count();
$order_type_7 = BeforehandOrder::where([['order_type', '=', 7]])->count();
$order_type_8 = BeforehandOrder::where([['order_type', '=', 8]])->count();
$outbound_0 = BeforehandOrder::where([['is_outbound', '=', 0], ['order_type', '<>', 5]])->count();
$outbound_1 = BeforehandOrder::where([['is_outbound', '=', 1]])->count();
$warehousing_0 = BeforehandOrder::where([['is_warehousing', '=', 0]])->count();
$warehousing_1 = BeforehandOrder::where([['is_warehousing', '=', 1]])->count();
return [
'outbound_0' => $outbound_0,
'outbound_1' => $outbound_1,
'warehousing_0' => $warehousing_0,
'warehousing_1' => $warehousing_1,
];
}
}

View File

@ -71,12 +71,16 @@ class DemoLogic extends BaseLogic
//活动价
$find42 = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', 42)->find();
if ($find42) {
$find42->save(['price' => bcadd($v['price4'], 0, 2)]);
if($v['price9']>0){
$find42->save(['price' => bcadd($v['price9'], 0, 2)]);
}
} else {
if($v['price9']>0){
StoreProductGroupPrice::insert(['product_id' => $v['product_id'], 'group_id' => 42, 'price' => bcadd($v['price9'], 0, 2), 'price_type' => 3, 'base_rate' =>0]);
}
}
}
}
public static function test2($store_id, $srr)
{