feat:depot_sale
This commit is contained in:
@@ -181,6 +181,18 @@ class DepotController
|
|||||||
return (new DepotService)->saleList();
|
return (new DepotService)->saleList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计销售额
|
||||||
|
* @param DepotRequest $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: "sale_statistics", methods: "GET")]
|
||||||
|
#[Scene(scene: "sale_statistics")]
|
||||||
|
public function saleStatistics(DepotRequest $request): array
|
||||||
|
{
|
||||||
|
return (new DepotService)->saleStatistics();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 回收
|
* 回收
|
||||||
* @param DepotRequest $request
|
* @param DepotRequest $request
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class DepotRequest extends FormRequest
|
|||||||
'sale_update' => ['id','number'],
|
'sale_update' => ['id','number'],
|
||||||
'sale_delete' => ['id'],
|
'sale_delete' => ['id'],
|
||||||
'sale_list' => ['limit','query_id','query_kitchen_id'],
|
'sale_list' => ['limit','query_id','query_kitchen_id'],
|
||||||
|
'sale_statistics' => ['city_id'],
|
||||||
'recycle' =>['material_id','supplier_id','number','sale_id','city_id','kitchen_id'],
|
'recycle' =>['material_id','supplier_id','number','sale_id','city_id','kitchen_id'],
|
||||||
'recycle_update' => ['id','number'],
|
'recycle_update' => ['id','number'],
|
||||||
'recycle_delete' => ['id'],
|
'recycle_delete' => ['id'],
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class DepotService extends BaseService{
|
|||||||
$todayPurchase = $this->DepotPurchaseModel
|
$todayPurchase = $this->DepotPurchaseModel
|
||||||
->where('is_del',DepotCode::IS_NO_DEL)
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
->where('type',1)
|
->where('type',1)
|
||||||
->where('status',1)
|
->where('status',DepotCode::INPUT)
|
||||||
->where('city_id',$cityId)
|
->where('city_id',$cityId)
|
||||||
->whereBetween('create_time',[$todayStartDate,$todayEndDate])
|
->whereBetween('create_time',[$todayStartDate,$todayEndDate])
|
||||||
->sum('sum_price');
|
->sum('sum_price');
|
||||||
@@ -318,7 +318,7 @@ class DepotService extends BaseService{
|
|||||||
$yesterdayPurchase = $this->DepotPurchaseModel
|
$yesterdayPurchase = $this->DepotPurchaseModel
|
||||||
->where('is_del',DepotCode::IS_NO_DEL)
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
->where('type',1)
|
->where('type',1)
|
||||||
->where('status',1)
|
->where('status',DepotCode::INPUT)
|
||||||
->where('city_id',$cityId)
|
->where('city_id',$cityId)
|
||||||
->whereBetween('create_time',[$yesterdayStartDate,$yesterdayEndDate])
|
->whereBetween('create_time',[$yesterdayStartDate,$yesterdayEndDate])
|
||||||
->sum('sum_price');
|
->sum('sum_price');
|
||||||
@@ -328,7 +328,7 @@ class DepotService extends BaseService{
|
|||||||
$monthPurchase = $this->DepotPurchaseModel
|
$monthPurchase = $this->DepotPurchaseModel
|
||||||
->where('is_del',DepotCode::IS_NO_DEL)
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
->where('type',1)
|
->where('type',1)
|
||||||
->where('status',1)
|
->where('status',DepotCode::INPUT)
|
||||||
->where('city_id',$cityId)
|
->where('city_id',$cityId)
|
||||||
->whereBetween('create_time',[$currentMonthStartDate,$todayEndDate])
|
->whereBetween('create_time',[$currentMonthStartDate,$todayEndDate])
|
||||||
->sum('sum_price');
|
->sum('sum_price');
|
||||||
@@ -338,7 +338,7 @@ class DepotService extends BaseService{
|
|||||||
$yearPurchase = $this->DepotPurchaseModel
|
$yearPurchase = $this->DepotPurchaseModel
|
||||||
->where('is_del',DepotCode::IS_NO_DEL)
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
->where('type',1)
|
->where('type',1)
|
||||||
->where('status',1)
|
->where('status',DepotCode::INPUT)
|
||||||
->where('city_id',$cityId)
|
->where('city_id',$cityId)
|
||||||
->whereBetween('create_time',[$currentYearStartDate,$todayEndDate])
|
->whereBetween('create_time',[$currentYearStartDate,$todayEndDate])
|
||||||
->sum('sum_price');
|
->sum('sum_price');
|
||||||
@@ -501,6 +501,48 @@ class DepotService extends BaseService{
|
|||||||
return $this->return->success('success',$list);
|
return $this->return->success('success',$list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function saleStatistics():array
|
||||||
|
{
|
||||||
|
$cityId = (int)$this->request->input('city_id');
|
||||||
|
|
||||||
|
//今日销售额
|
||||||
|
$todayStartDate = DateUtil::getTodayStartDate();
|
||||||
|
$todayEndDate = DateUtil::getTodayEndDate();
|
||||||
|
$todaySale = $this->DepotSaleModel
|
||||||
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
|
->where('city_id',$cityId)
|
||||||
|
->whereBetween('create_time',[$todayStartDate,$todayEndDate])
|
||||||
|
->sum('sum_price');
|
||||||
|
|
||||||
|
//昨天销售额
|
||||||
|
$yesterdayStartDate = DateUtil::getStartDate();
|
||||||
|
$yesterdayEndDate = DateUtil::getEndDate();
|
||||||
|
$yesterdaySale = $this->DepotPurchaseModel
|
||||||
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
|
->where('city_id',$cityId)
|
||||||
|
->whereBetween('create_time',[$yesterdayStartDate,$yesterdayEndDate])
|
||||||
|
->sum('sum_price');
|
||||||
|
|
||||||
|
//本月销售额
|
||||||
|
$currentMonthStartDate = date("Y-m-01 00:00:00");
|
||||||
|
$monthSale = $this->DepotSaleModel
|
||||||
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
|
->where('city_id',$cityId)
|
||||||
|
->whereBetween('create_time',[$currentMonthStartDate,$todayEndDate])
|
||||||
|
->sum('sum_price');
|
||||||
|
|
||||||
|
//今年销售额
|
||||||
|
$currentYearStartDate = date("Y-01-01 00:00:00");
|
||||||
|
$yearSale = $this->DepotSaleModel
|
||||||
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
|
->where('city_id',$cityId)
|
||||||
|
->whereBetween('create_time',[$currentYearStartDate,$todayEndDate])
|
||||||
|
->sum('sum_price');
|
||||||
|
|
||||||
|
return $this->return->success('success',["todaySale"=>$todaySale,"yesterdaySale"=>$yesterdaySale,
|
||||||
|
"monthSale"=>$monthSale,"yearSale"=>$yearSale]);
|
||||||
|
}
|
||||||
|
|
||||||
public function recycle():array
|
public function recycle():array
|
||||||
{
|
{
|
||||||
$materialId = (int)$this->request->input('material_id');
|
$materialId = (int)$this->request->input('material_id');
|
||||||
|
|||||||
Reference in New Issue
Block a user