更新种养殖户统计

This commit is contained in:
mkm 2023-11-20 10:35:27 +08:00
parent 637047894e
commit f363de8995
2 changed files with 50 additions and 14 deletions

View File

@ -275,4 +275,39 @@ class Statistics extends BaseController
->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]);
}
}

View File

@ -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');