feat: 修改财务流水列表功能,调整查询条件和展示内容

This commit is contained in:
mkm 2024-06-21 14:01:39 +08:00
parent 98cdcb682e
commit 18f82d040f

View File

@ -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;
}