From 18f82d040f247c91ea70e79d4917fb4d2f4deffa Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 21 Jun 2024 14:01:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=B4=A2=E5=8A=A1?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E5=88=97=E8=A1=A8=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=E5=92=8C?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreFinanceFlowLists.php | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php b/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php index 3bf1fb6bc..6923aae37 100644 --- a/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php +++ b/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php @@ -51,7 +51,7 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt public function lists(): array { $field = [ - 'id','order_id', 'order_sn', 'create_time', 'other_uid', 'user_id', 'store_id', 'staff_id', 'financial_type', 'financial_pm', 'pay_type', 'type', 'number', 'status' + 'id', 'order_id', 'order_sn', 'create_time', 'other_uid', 'user_id', 'store_id', 'staff_id', 'financial_type', 'financial_pm', 'pay_type', 'type', 'number', 'status' ]; $this->searchWhere[] = ['financial_type', '=', 1]; $this->searchWhere[] = ['financial_pm', '=', 1]; @@ -82,7 +82,7 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt })->toArray(); foreach ($data as $key => $item) { - $list1= StoreFinanceFlow::where('order_id' ,$item['order_id'])->where('financial_type','>', 1)->field($field)->order('financial_pm','desc')->select()->each(function ($item) { + $list1 = StoreFinanceFlow::where('order_id', $item['order_id'])->where('financial_type', '>', 1)->field($field)->select()->each(function ($item) { if ($item['user_id'] <= 0) { $item['nickname'] = '游客'; } else { @@ -103,19 +103,24 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt $item['store_name'] = $item['store_id'] > 0 ? SystemStore::where('id', $item['store_id'])->value('name') : ''; $item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']); }); - $list2=UserSign::where('order_id',$item['order_sn'])->whereIn('user_ship',[2,3])->select(); - foreach($list2 as $k=>$v){ - $list2[$k]['id']='jf'.$v['id']; - $list2[$k]['order_sn']=$item['order_sn']; - $list2[$k]['store_name']=$item['store_name']; - $list2[$k]['financial_pm']=0; - $list2[$k]['nickname']=$v['uid']>0?User::where('id', $v['uid'])->value('nickname') . '|'.$v['uid']:'游客'; - $list2[$k]['number']='+'.$v['number']; - $list2[$k]['financial_type_name']=$v['title']; + $list2 = UserSign::where('order_id', $item['order_sn'])->whereIn('user_ship', [0, 2, 3])->select(); + foreach ($list2 as $k => $v) { + $list2[$k]['id'] = 'JF' . $v['id']; + $list2[$k]['order_sn'] = $item['order_sn']; + $list2[$k]['store_name'] = $item['store_name']; + $list2[$k]['financial_pm'] = 0; + $list2[$k]['nickname'] = $v['uid'] > 0 ? User::where('id', $v['uid'])->value('nickname') . '|' . $v['uid'] : '游客'; + $list2[$k]['number'] = '+' . $v['number']; + $list2[$k]['financial_type_name'] = $v['title']; $list2[$k]['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']); - } - $data[$key]['list']=array_merge($list1->toArray(),$list2->toArray()); + $list3 = array_merge($list1->toArray(), $list2->toArray()); + // 提取 financial_pm 字段到单独的数组 + $financial_pm = array_column($list3, 'financial_pm'); + + // 对 financial_pm 数组进行排序,这将影响原始数组 + array_multisort($financial_pm, SORT_ASC, $list3); + $data[$k]['list']=$list3; } return $data; }