This commit is contained in:
mkm 2024-05-28 18:36:51 +08:00
parent 83c0e0b04a
commit dcb13b6f5b
7 changed files with 102 additions and 101 deletions

View File

@ -134,7 +134,7 @@ class OpurchaseclassController extends BaseAdminController
*/
public function storage_list()
{
$this->request->__set('storage_list',1);
// $this->request->__set('storage_list',1);
return $this->dataLists(new OpurchaseclassofferLists());
}
@ -147,8 +147,8 @@ class OpurchaseclassController extends BaseAdminController
$order_arr= Opurchaseclass::where('id',$id)->where('is_mer',2)->value('order_arr');
$arr=Opurchaseclass::where('id','in',explode(',',$order_arr))->where('is_mer',1)->value('order_arr');
if($arr){
$this->request->__set('class_value',['id'=>explode(',',$arr)]);
$this->request->__set('class_key',['in'=>['id']]);
// $this->request->__set('class_value',['id'=>explode(',',$arr)]);
// $this->request->__set('class_key',['in'=>['id']]);
}
return $this->dataLists(new CashierclassStreamLists());
}

View File

@ -64,20 +64,20 @@ class OpurchaseclassofferLists extends BaseAdminDataLists implements ListsSearch
$where[] = ['supplier_id', '=', $this->request->supplierId];
}
$this->where = $where;
if ($this->request->__get('storage_list') == 1) {
$list = OpurchaseGoodsOffer::where($this->searchWhere)
->where($where)
->limit($this->limitOffset, $this->limitLength)
->order('update_time', 'desc')
->select()->each(function ($item) {
$find = Goods::where('id', $item['goods_id'])->with('unitName')->find();
if ($find) {
$item['goods_name'] = $find['name'];
$item['unit_name'] = $find['unit_name'];
}
$item['supplier_name'] = Supplier::where('id', $item['supplier_id'])->value('mer_name');
})->toArray();
} else {
// if ($this->request->__get('storage_list') == 1) {
// $list = OpurchaseGoodsOffer::where($this->searchWhere)
// ->where($where)
// ->limit($this->limitOffset, $this->limitLength)
// ->order('update_time', 'desc')
// ->select()->each(function ($item) {
// $find = Goods::where('id', $item['goods_id'])->with('unitName')->find();
// if ($find) {
// $item['goods_name'] = $find['name'];
// $item['unit_name'] = $find['unit_name'];
// }
// $item['supplier_name'] = Supplier::where('id', $item['supplier_id'])->value('mer_name');
// })->toArray();
// } else {
$list = OpurchaseGoodsOffer::where($this->searchWhere)
->where($where)
->limit($this->limitOffset, $this->limitLength)
@ -90,7 +90,7 @@ class OpurchaseclassofferLists extends BaseAdminDataLists implements ListsSearch
}
$item['supplier_name'] = Supplier::where('id', $item['supplier_id'])->value('mer_name');
})->toArray();
}
// }
return $list;
}

View File

@ -56,9 +56,9 @@ class FinancialRecordController extends BaseApiController
{
$mer_id=$this->request->userInfo['merchant']['mer_id']??0;
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']]);
// $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();
@ -70,9 +70,9 @@ class FinancialRecordController extends BaseApiController
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']]);
// $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();

View File

@ -17,7 +17,7 @@ class GoodsController extends BaseApiController{
* 商品列表
*/
public function mer_list(){
$this->request->__set('mer_id',$this->request->userInfo['merchant']['mer_id']??0);
// $this->request->__set('mer_id',$this->request->userInfo['merchant']['mer_id']??0);
return $this->dataLists(new GoodsLists());
}

View File

@ -44,51 +44,52 @@ class FinancialRecordLists extends BaseAdminDataLists implements ListsSearchInte
*/
public function lists(): array
{
$class_value = $this->request->__get('class_value');
if ($class_value) {
$where = [
'type' => $class_value['type'],
'mer_id' => $class_value['mer_id'],
];
}else{
$where=[];
}
// $class_value = $this->request->__get('class_value');
// if ($class_value) {
// $where = [
// 'type' => $class_value['type'],
// 'mer_id' => $class_value['mer_id'],
// ];
// }else{
// $where=[];
// }
$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 {
$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;
});
}
// $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 {
// $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;
// });
// }
return $list?->toArray();
// return $list?->toArray();
return [];
}

View File

@ -98,20 +98,20 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface
}else{
$order['id'] = 'desc';
}
$mer_id=$this->request->__get('mer_id');
if($mer_id){
$goods_id=Db::name('merchant_bind_goods')->where('mer_id',$mer_id)->limit($this->limitOffset, $this->limitLength)->column('goods_id');
if($goods_id){
return Goods::where($this->searchWhere)->where('id','in',$goods_id)
->field(['id', 'name','brand','class','unit', 'sell', 'code','imgs','sales','spec'])
->with(['className','brandName','unitName'])
->order($order)
->select()
->toArray();
}else{
return [];
}
}
// $mer_id=$this->request->__get('mer_id');
// if($mer_id){
// $goods_id=Db::name('merchant_bind_goods')->where('mer_id',$mer_id)->limit($this->limitOffset, $this->limitLength)->column('goods_id');
// if($goods_id){
// return Goods::where($this->searchWhere)->where('id','in',$goods_id)
// ->field(['id', 'name','brand','class','unit', 'sell', 'code','imgs','sales','spec'])
// ->with(['className','brandName','unitName'])
// ->order($order)
// ->select()
// ->toArray();
// }else{
// return [];
// }
// }
return Goods::where($this->searchWhere)->where($where)
->field(['id', 'name','brand','class','unit', 'sell', 'code','imgs','sales','spec'])
->limit($this->limitOffset, $this->limitLength)
@ -143,10 +143,10 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface
$where[]=['class','=',$class_all];
}
}
$mer_id=$this->request->__get('mer_id');
if($mer_id){
return Db::name('merchant_bind_goods')->where('mer_id',$mer_id)->count();
}
// $mer_id=$this->request->__get('mer_id');
// if($mer_id){
// return Db::name('merchant_bind_goods')->where('mer_id',$mer_id)->count();
// }
return Goods::where($this->searchWhere)->where($where)->count();
}

View File

@ -22,24 +22,24 @@ trait ListsSearchTrait
return [];
}
$where = [];
$class_key=$this->request->__get('class_key');
if($class_key!==null){
foreach($class_key as $key => $value){
if(isset($search[$key])){
foreach($value as $v){ // 遍历class_key的值添加到search数组中
array_push($search[$key], $v); // 添加class_key的搜索条件
}
}else{
$search[$key] = [$value[0]]; // 创建新的搜索条件
}
}
}
// $class_key=$this->request->__get('class_key');
// if($class_key!==null){
// foreach($class_key as $key => $value){
// if(isset($search[$key])){
// foreach($value as $v){ // 遍历class_key的值添加到search数组中
// array_push($search[$key], $v); // 添加class_key的搜索条件
// }
// }else{
// $search[$key] = [$value[0]]; // 创建新的搜索条件
// }
// }
// }
$class_value=$this->request->__get('class_value'); // 获取class_value的值
if($class_value!==null){
$this->params=array_merge($this->params,$class_value);
// $class_value=$this->request->__get('class_value'); // 获取class_value的值
// if($class_value!==null){
// $this->params=array_merge($this->params,$class_value);
}
// }
foreach ($search as $whereType => $whereFields) {
switch ($whereType) {
case '=':