From 87ff521c9793422dead5b77f908165ea7dec1bd9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 20 Oct 2023 18:46:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Statistics.php | 94 +++++++++++++++++++++++++++++++ route/api.php | 1 + 2 files changed, 95 insertions(+) diff --git a/app/controller/api/Statistics.php b/app/controller/api/Statistics.php index d1ad1eb5..0e21e1f0 100644 --- a/app/controller/api/Statistics.php +++ b/app/controller/api/Statistics.php @@ -114,4 +114,98 @@ class Statistics extends BaseController return app('json')->success(['page'=>$parmas['page'],'data'=>$list]); } + + /** + * 采购金额和销售金额统计 + */ + public function SupplyChainProductPriceCount() + { + $parmas = $this->request->param(); + if (isset($parmas['type']) && $parmas['type'] != '') { + switch ($parmas['type']) { + case 200: + $where[] = ['p.source','=',200]; + break; + case 300: + $where[] = ['p.source','=',300]; + break; + default: + return app('json')->fail('type:格式错误'); + break; + } + } else { + $where[] = ['p.source','=',0]; + } + if (!isset($parmas['start_time']) || $parmas['start_time'] == '') { + return app('json')->fail('start_time:格式错误'); + } + if (!isset($parmas['end_time']) || $parmas['end_time'] == '') { + return app('json')->fail('end_time:格式错误'); + } + if (!isset($parmas['mer_intention_id']) || $parmas['mer_intention_id'] == '') { + return app('json')->fail('mer_intention_id:格式错误'); + } + if (!isset($parmas['goods_id']) || $parmas['goods_id'] == '') { + return app('json')->fail('goods_id:格式错误'); + } + + $where[]=['p.create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; + $where[] = ['p.product_id','in',explode(',', $parmas['goods_id'])]; + $where[] = ['p.is_refund','=',0]; + $count=Db::name('store_order_product')->alias('p') + ->where($where) + ->join('store_order o','o.mer_id='.$parmas['mer_intention_id'].' and o.paid=1 and o.is_del=0') + ->sum('p.total_price'); + return app('json')->success(['procure_amount'=>$count]); + } + + /** + * 镇一般商户采购金额和销售金额统计 + */ + public function SupplyChainStreetProductPriceCount() + { + $parmas = $this->request->param(); + if (isset($parmas['type']) && $parmas['type'] != '') { + switch ($parmas['type']) { + case 200: + $where[] = ['p.source','=',200]; + break; + case 300: + $where[] = ['p.source','=',300]; + break; + default: + return app('json')->fail('type:格式错误'); + break; + } + } else { + $where[] = ['p.source','=',0]; + } + if (!isset($parmas['start_time']) || $parmas['start_time'] == '') { + return app('json')->fail('start_time:格式错误'); + } + if (!isset($parmas['end_time']) || $parmas['end_time'] == '') { + return app('json')->fail('end_time:格式错误'); + } + if (!isset($parmas['mer_intention_id']) || $parmas['mer_intention_id'] == '') { + return app('json')->fail('mer_intention_id:格式错误'); + } + if (!isset($parmas['goods_id']) || $parmas['goods_id'] == '') { + return app('json')->fail('goods_id:格式错误'); + } + if (isset($parmas['responsible_area']) && $parmas['responsible_area'] != '') { + $area[] = ['street_id','in',explode(',', $parmas['responsible_area'])]; + }else{ + return app('json')->fail('responsible_area:格式错误'); + } + $merchant=Db::name('merchant')->where('street_id','in',$area)->select(); + $where[]=['p.create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; + $where[] = ['p.product_id','in',explode(',', $parmas['goods_id'])]; + $where[] = ['p.is_refund','=',0]; + $count=Db::name('store_order_product')->alias('p') + ->where($where) + ->join('store_order o','o.mer_id in '.$parmas['mer_intention_id'].' and o.paid=1 and o.is_del=0') + ->sum('p.total_price'); + return app('json')->success(['procure_amount'=>$count]); + } + } diff --git a/route/api.php b/route/api.php index 93d56dd7..8bbf95b7 100644 --- a/route/api.php +++ b/route/api.php @@ -686,6 +686,7 @@ Route::group('api/', function () { Route::get('supply_chain_product_count', '/SupplyChainProductCount'); Route::get('supply_chain_product_stock_count', '/SupplyChainProductStockCount'); Route::get('product_list', '/ProductList'); + Route::get('supply_chain_product_price_count', '/SupplyChainProductPriceCount'); })->prefix('api.Statistics'); //滑块验证码