From f363de8995890fd5178516156238638df7b0aa4f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 20 Nov 2023 10:35:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A7=8D=E5=85=BB=E6=AE=96?= =?UTF-8?q?=E6=88=B7=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Statistics.php | 63 ++++++++++++++++++++++++------- route/api.php | 1 + 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/app/controller/api/Statistics.php b/app/controller/api/Statistics.php index e94d16d3..85f6bbb1 100644 --- a/app/controller/api/Statistics.php +++ b/app/controller/api/Statistics.php @@ -109,11 +109,11 @@ class Statistics extends BaseController if (isset($parmas['keyword']) && $parmas['keyword'] != '') { $where[] = ['store_name', 'like', '%' . $parmas['keyword'] . '%']; } - $count=Db::name('store_product')->where($where)->count(); + $count = Db::name('store_product')->where($where)->count(); $list = Db::name('store_product')->where($where)->page($parmas['page']) ->field('product_id,store_name,image,price') ->limit(10)->select(); - return app('json')->success(['page' => $parmas['page'], 'data' => $list,'count'=>$count]); + return app('json')->success(['page' => $parmas['page'], 'data' => $list, 'count' => $count]); } /** @@ -149,7 +149,7 @@ class Statistics extends BaseController if (!isset($parmas['goods_id']) || $parmas['goods_id'] == '') { return app('json')->fail('goods_id:格式错误'); } - $mer_id=Db::name('merchant_intention')->where('mer_intention_id', $parmas['mer_intention_id'])->value('mer_id'); + $mer_id = Db::name('merchant_intention')->where('mer_intention_id', $parmas['mer_intention_id'])->value('mer_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]; @@ -231,7 +231,7 @@ class Statistics extends BaseController // return app('json')->fail('type:格式错误'); // } $area[] = ['street_id', 'in', explode(',', $parmas['responsible_area'])]; - $area[] = ['type_id', '=',17]; + $area[] = ['type_id', '=', 17]; $merchant = Db::name('merchant')->where($area)->column('mer_id'); if (!$merchant) { @@ -262,17 +262,52 @@ class Statistics extends BaseController if (!isset($parmas['phone']) || $parmas['phone'] == '') { return app('json')->fail('phone:格式错误'); } - $user_id= Db::name('user')->where('account',$parmas['phone'])->value('uid'); - if(!$user_id){ + $user_id = Db::name('user')->where('account', $parmas['phone'])->value('uid'); + if (!$user_id) { return app('json')->fail('查询的手机号用户不存在'); } - $where[]=['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[]=['paid','=',1]; - $where[]=['status','<>',-1]; - $where[]=['uid','=',$user_id]; - $count=Db::name('store_order') - ->where($where) - ->sum('pay_price'); - return app('json')->success(['trade_amount'=>$count]); + $where[] = ['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[] = ['paid', '=', 1]; + $where[] = ['status', '<>', -1]; + $where[] = ['uid', '=', $user_id]; + $count = Db::name('store_order') + ->where($where) + ->sum('pay_price'); + return app('json')->success(['trade_amount' => $count]); + } + + /** + * 查询镇农科公司负责片区内的种养殖商户和供应链商户交易额 + *暂无种养殖商户分类 + */ + public function SupplyChainVillageBreedingPriceCount() + { + $parmas = $this->request->param(); + + 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['village']) || $parmas['village'] == '') { + return app('json')->fail('village:格式错误'); + } + $village_id = Db::name('geo_village')->where('village_code', $parmas['village'])->value('village_id'); + $merchant_category_id = Db::name('merchant_category')->where('code', 'zhongyangzhi')->value('merchant_category_id'); + $area[] = ['village_id', '=', $village_id]; + $area[] = ['category_id', '=', $merchant_category_id]; + + $merchant = Db::name('merchant')->where($area)->column('mer_id'); + if (!$merchant) { + return app('json')->fail('查询商户为空'); + } + $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.is_refund', '=', 0]; + $count = Db::name('store_order_product')->alias('p') + ->where($where) + ->join('store_order o', 'o.mer_id in (' . implode(',', $merchant) . ') and o.paid=1 and o.is_del=0') + ->sum('p.total_price'); + return app('json')->success(['trade_amount' => $count]); + } } diff --git a/route/api.php b/route/api.php index e47ccf46..8856b174 100644 --- a/route/api.php +++ b/route/api.php @@ -704,6 +704,7 @@ Route::group('api/', function () { Route::get('supply_chain_product_price_count', '/SupplyChainProductPriceCount'); Route::get('supply_chain_street_product_price_count', '/SupplyChainStreetProductPriceCount'); Route::get('supply_chain_breeding_street_product_count', '/SupplyChainBreedingStreetProductCount'); + Route::get('supply_chain_village_breeding_price_count', '/SupplyChainVillageBreedingPriceCount'); Route::get('store_order_user_trade_amount', '/StoreOrderUserTradeAmount'); })->prefix('api.Statistics');