This commit is contained in:
mkm 2023-11-08 10:27:50 +08:00
parent 44aef5f3fa
commit f099acb853
2 changed files with 125 additions and 57 deletions

View File

@ -95,7 +95,8 @@ class Statistics extends BaseController
/**
* 商品列表
*/
public function ProductList(){
public function ProductList()
{
$parmas = $this->request->param();
if (!isset($parmas['page']) || $parmas['page'] == '') {
@ -112,7 +113,6 @@ class Statistics extends BaseController
->field('product_id,store_name,image,price')
->limit(10)->select();
return app('json')->success(['page' => $parmas['page'], 'data' => $list]);
}
/**
@ -208,4 +208,70 @@ class Statistics extends BaseController
return app('json')->success(['procure_amount' => $count]);
}
/**
* 查询镇农科公司负责片区内的种养殖商户和供应链商户交易额
*暂无种养殖商户分类
*/
public function SupplyChainBreedingStreetProductCount()
{
$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['responsible_area']) || $parmas['responsible_area'] == '') {
return app('json')->fail('responsible_area:格式错误');
}
// if (!isset($parmas['type']) || $parmas['type'] == '') {
// return app('json')->fail('type:格式错误');
// }
$area[] = ['street_id', 'in', explode(',', $parmas['responsible_area'])];
$area[] = ['type_id', '=',17];
$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]);
}
/**
* 查询手机号用户的交易金额
*/
public function StoreOrderUserTradeAmount()
{
$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['phone']) || $parmas['phone'] == '') {
return app('json')->fail('phone:格式错误');
}
$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]);
}
}

View File

@ -701,6 +701,8 @@ Route::group('api/', function () {
Route::get('product_list', '/ProductList');
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('store_order_user_trade_amount', '/StoreOrderUserTradeAmount');
})->prefix('api.Statistics');
//滑块验证码