优化了代码逻辑,增加了余额明细功能,并修改了搜索条件设置方式。
This commit is contained in:
parent
5550cc8c94
commit
e9df9d9041
@ -148,7 +148,7 @@ class OpurchaseclassController extends BaseAdminController
|
|||||||
$arr=Opurchaseclass::where('id','in',explode(',',$order_arr))->where('is_mer',1)->value('order_arr');
|
$arr=Opurchaseclass::where('id','in',explode(',',$order_arr))->where('is_mer',1)->value('order_arr');
|
||||||
if($arr){
|
if($arr){
|
||||||
$this->request->__set('class_value',['id'=>explode(',',$arr)]);
|
$this->request->__set('class_value',['id'=>explode(',',$arr)]);
|
||||||
$this->request->__set('class_key',['in'=>'id']);
|
$this->request->__set('class_key',['in'=>['id']]);
|
||||||
}
|
}
|
||||||
return $this->dataLists(new CashierclassStreamLists());
|
return $this->dataLists(new CashierclassStreamLists());
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,27 @@ class FinancialRecordController extends BaseApiController
|
|||||||
*/
|
*/
|
||||||
public function api_lists()
|
public function api_lists()
|
||||||
{
|
{
|
||||||
$this->request->__set('is_detail',1);
|
$mer_id=$this->request->userInfo['merchant']['mer_id']??0;
|
||||||
return $this->dataLists((new FinancialRecordLists));
|
if($mer_id!=0){
|
||||||
|
$this->request->__set('is_detail',1);
|
||||||
|
$this->request->__set('class_value',['mer_id'=>$mer_id,'type'=>1]);
|
||||||
|
$this->request->__set('class_key',['='=>['mer_id','type']]);
|
||||||
|
return $this->dataLists((new FinancialRecordLists));
|
||||||
|
}
|
||||||
|
return $this->success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 余额明细
|
||||||
|
*/
|
||||||
|
public function supplier_list(){
|
||||||
|
$id=$this->request->userInfo['supplier']['id']??0;
|
||||||
|
if($id!=0){
|
||||||
|
$this->request->__set('is_detail',1);
|
||||||
|
$this->request->__set('class_value',['mer_id'=>$id,'type'=>3]);
|
||||||
|
$this->request->__set('class_key',['='=>['mer_id','type']]);
|
||||||
|
return $this->dataLists((new FinancialRecordLists));
|
||||||
|
}
|
||||||
|
return $this->success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,45 +44,47 @@ class FinancialRecordLists extends BaseAdminDataLists implements ListsSearchInte
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$mer_id = $this->request->userInfo['merchant']['mer_id'] ?? 0;
|
$class_value = $this->request->__get('class_value');
|
||||||
if ($mer_id <= 0) {
|
if ($class_value) {
|
||||||
return [];
|
$where = [
|
||||||
}
|
'type' => $class_value['type'],
|
||||||
$where = [
|
'mer_id' => $class_value['mer_id'],
|
||||||
'type' => 1,
|
];
|
||||||
'mer_id' => $mer_id,
|
|
||||||
];
|
|
||||||
$this->where = $where;
|
|
||||||
$searchWhere=$this->searchWhere;
|
|
||||||
$is_detail=$this->request->__get('is_detail');
|
|
||||||
if($is_detail==1){
|
|
||||||
$list = FinancialRecord::where($this->searchWhere)
|
|
||||||
->where($where)
|
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
|
||||||
->order('create_time','desc')
|
|
||||||
->select()->each(function ($item) {
|
|
||||||
$item['user_nickname']='';
|
|
||||||
if($item['user_id']!=0){
|
|
||||||
$item['user_nickname']=User::where('id',$item['user_id'])->value('nickname');
|
|
||||||
}
|
|
||||||
$item['financial_pm']=$item['financial_pm']==0?"支出":"获得";
|
|
||||||
return $item;
|
|
||||||
});
|
|
||||||
}else{
|
}else{
|
||||||
|
$where=[];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->where = $where;
|
||||||
|
$searchWhere = $this->searchWhere;
|
||||||
|
$is_detail = $this->request->__get('is_detail');
|
||||||
|
if ($is_detail == 1) {
|
||||||
$list = FinancialRecord::where($this->searchWhere)
|
$list = FinancialRecord::where($this->searchWhere)
|
||||||
->where($where)
|
->where($where)
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->field("FROM_UNIXTIME(create_time, '%Y-%m-%d') as record_date, SUM(number) as total_amount")
|
->order('create_time', 'desc')
|
||||||
->group('record_date')
|
->select()->each(function ($item) {
|
||||||
->order('record_date')
|
$item['user_nickname'] = '';
|
||||||
->select()->each(function ($item) use($where,$searchWhere) {
|
if ($item['user_id'] != 0) {
|
||||||
$cashier_total_amount=FinancialRecord::where($where)->where($searchWhere)->where('financial_type',OrderEnum::CASHIER_ORDER_PAY)->sum('number');
|
$item['user_nickname'] = User::where('id', $item['user_id'])->value('nickname');
|
||||||
$item['cashier_total_amount'] = $cashier_total_amount;
|
}
|
||||||
$cashier_cash_total_amount=FinancialRecord::where($where)->where($searchWhere)->where('financial_type',OrderEnum::CASHIER_CASH_ORDER_PAY)->sum('number');
|
$item['financial_pm'] = $item['financial_pm'] == 0 ? "支出" : "获得";
|
||||||
$item['cashier_cash_total_amount'] = $cashier_cash_total_amount;
|
return $item;
|
||||||
$platofrm_total_amount=FinancialRecord::where($where)->where($searchWhere)->where('financial_type',OrderEnum::USER_ORDER_PAY)->sum('number');
|
});
|
||||||
$item['platofrm_total_amount'] = $platofrm_total_amount;
|
} else {
|
||||||
});
|
$list = FinancialRecord::where($this->searchWhere)
|
||||||
|
->where($where)
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->field("FROM_UNIXTIME(create_time, '%Y-%m-%d') as record_date, SUM(number) as total_amount")
|
||||||
|
->group('record_date')
|
||||||
|
->order('record_date')
|
||||||
|
->select()->each(function ($item) use ($where, $searchWhere) {
|
||||||
|
$cashier_total_amount = FinancialRecord::where($where)->where($searchWhere)->where('financial_type', OrderEnum::CASHIER_ORDER_PAY)->sum('number');
|
||||||
|
$item['cashier_total_amount'] = $cashier_total_amount;
|
||||||
|
$cashier_cash_total_amount = FinancialRecord::where($where)->where($searchWhere)->where('financial_type', OrderEnum::CASHIER_CASH_ORDER_PAY)->sum('number');
|
||||||
|
$item['cashier_cash_total_amount'] = $cashier_cash_total_amount;
|
||||||
|
$platofrm_total_amount = FinancialRecord::where($where)->where($searchWhere)->where('financial_type', OrderEnum::USER_ORDER_PAY)->sum('number');
|
||||||
|
$item['platofrm_total_amount'] = $platofrm_total_amount;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,9 +26,11 @@ trait ListsSearchTrait
|
|||||||
if($class_key!==null){
|
if($class_key!==null){
|
||||||
foreach($class_key as $key => $value){
|
foreach($class_key as $key => $value){
|
||||||
if(isset($search[$key])){
|
if(isset($search[$key])){
|
||||||
array_push($search[$key], $value); // 添加class_key的搜索条件
|
foreach($value as $v){ // 遍历class_key的值,添加到search数组中
|
||||||
|
array_push($search[$key], $v); // 添加class_key的搜索条件
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
$search[$key] = [$value]; // 创建新的搜索条件
|
$search[$key] = [$value[0]]; // 创建新的搜索条件
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user