feat:depot_purchase
This commit is contained in:
@@ -118,6 +118,18 @@ class DepotController
|
|||||||
return (new DepotService)->purchaseList();
|
return (new DepotService)->purchaseList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计采购额
|
||||||
|
* @param DepotRequest $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: "purchase_statistics", methods: "GET")]
|
||||||
|
#[Scene(scene: "purchase_statistics")]
|
||||||
|
public function purchaseStatistics(DepotRequest $request): array
|
||||||
|
{
|
||||||
|
return (new DepotService)->purchaseStatistics();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销售出库
|
* 销售出库
|
||||||
* @param DepotRequest $request
|
* @param DepotRequest $request
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class DepotRequest extends FormRequest
|
|||||||
return [
|
return [
|
||||||
'limit' => 'required|integer',
|
'limit' => 'required|integer',
|
||||||
'query_id' => 'sometimes|integer',
|
'query_id' => 'sometimes|integer',
|
||||||
'query_kitchen_id' => 'sometimes|integer',
|
'query_kitchen_id' => 'sometimes|integer|exists:kitchen,id',
|
||||||
'name' => 'required|string',
|
'name' => 'required|string',
|
||||||
'city_id' => 'required|integer|exists:system_city,id',
|
'city_id' => 'required|integer|exists:system_city,id',
|
||||||
'kitchen_id' => 'required|integer|exists:kitchen,id',
|
'kitchen_id' => 'required|integer|exists:kitchen,id',
|
||||||
@@ -49,6 +49,7 @@ class DepotRequest extends FormRequest
|
|||||||
'purchase_update' => ['id','number'],
|
'purchase_update' => ['id','number'],
|
||||||
'purchase_back' => ['id'],
|
'purchase_back' => ['id'],
|
||||||
'purchase_list' => ['limit','query_id','query_kitchen_id','type'],
|
'purchase_list' => ['limit','query_id','query_kitchen_id','type'],
|
||||||
|
'purchase_statistics' => ['city_id'],
|
||||||
'sale' => ['depot_id','material_id','supplier_id','number','application_id','city_id','kitchen_id'],
|
'sale' => ['depot_id','material_id','supplier_id','number','application_id','city_id','kitchen_id'],
|
||||||
'sale_update' => ['id','number'],
|
'sale_update' => ['id','number'],
|
||||||
'sale_delete' => ['id'],
|
'sale_delete' => ['id'],
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Constants\Admin\DepotCode;
|
|||||||
use App\Constants\Common\MaterialCode;
|
use App\Constants\Common\MaterialCode;
|
||||||
use App\Constants\Common\RoleCode;
|
use App\Constants\Common\RoleCode;
|
||||||
use App\Exception\ErrException;
|
use App\Exception\ErrException;
|
||||||
|
use App\Extend\DateUtil;
|
||||||
use App\Model\Depot;
|
use App\Model\Depot;
|
||||||
use App\Model\DepotPurchase;
|
use App\Model\DepotPurchase;
|
||||||
use App\Model\DepotRecycle;
|
use App\Model\DepotRecycle;
|
||||||
@@ -306,6 +307,56 @@ class DepotService extends BaseService{
|
|||||||
return $this->return->success('success',$list);
|
return $this->return->success('success',$list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function purchaseStatistics():array
|
||||||
|
{
|
||||||
|
$cityId = (int)$this->request->input('city_id');
|
||||||
|
|
||||||
|
//今日采购额
|
||||||
|
$todayStartDate = DateUtil::getTodayStartDate();
|
||||||
|
$todayEndDate = DateUtil::getTodayEndDate();
|
||||||
|
$todayPurchase = $this->DepotPurchaseModel
|
||||||
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
|
->where('type',1)
|
||||||
|
->where('status',1)
|
||||||
|
->where('city_id',$cityId)
|
||||||
|
->whereBetween('create_time',[$todayStartDate,$todayEndDate])
|
||||||
|
->sum('sum_price');
|
||||||
|
|
||||||
|
//昨天采购额
|
||||||
|
$yesterdayStartDate = DateUtil::getStartDate();
|
||||||
|
$yesterdayEndDate = DateUtil::getEndDate();
|
||||||
|
$yesterdayPurchase = $this->DepotPurchaseModel
|
||||||
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
|
->where('type',1)
|
||||||
|
->where('status',1)
|
||||||
|
->where('city_id',$cityId)
|
||||||
|
->whereBetween('create_time',[$yesterdayStartDate,$yesterdayEndDate])
|
||||||
|
->sum('sum_price');
|
||||||
|
|
||||||
|
//本月采购额
|
||||||
|
$currentMonthStartDate = date("Y-m-01 00:00:00");
|
||||||
|
$monthPurchase = $this->DepotPurchaseModel
|
||||||
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
|
->where('type',1)
|
||||||
|
->where('status',1)
|
||||||
|
->where('city_id',$cityId)
|
||||||
|
->whereBetween('create_time',[$currentMonthStartDate,$todayEndDate])
|
||||||
|
->sum('sum_price');
|
||||||
|
|
||||||
|
//今年采购额
|
||||||
|
$currentYearStartDate = date("Y-01-01 00:00:00");
|
||||||
|
$yearPurchase = $this->DepotPurchaseModel
|
||||||
|
->where('is_del',DepotCode::IS_NO_DEL)
|
||||||
|
->where('type',1)
|
||||||
|
->where('status',1)
|
||||||
|
->where('city_id',$cityId)
|
||||||
|
->whereBetween('create_time',[$currentYearStartDate,$todayEndDate])
|
||||||
|
->sum('sum_price');
|
||||||
|
|
||||||
|
return $this->return->success('success',["todayPurchase"=>$todayPurchase,"yesterdayPurchase"=>$yesterdayPurchase,
|
||||||
|
"monthPurchase"=>$monthPurchase,"yearPurchase"=>$yearPurchase]);
|
||||||
|
}
|
||||||
|
|
||||||
public function depotSale():array
|
public function depotSale():array
|
||||||
{
|
{
|
||||||
$depotId = (int)$this->request->input('depot_id');
|
$depotId = (int)$this->request->input('depot_id');
|
||||||
|
|||||||
@@ -394,6 +394,11 @@ POST {{host}}/admin/depot/depot_purchase_back?id=1
|
|||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
Authorization: Bearer {{admin_token}}
|
Authorization: Bearer {{admin_token}}
|
||||||
|
|
||||||
|
### 采购统计
|
||||||
|
GET {{host}}/admin/depot/purchase_statistics?city_id=1
|
||||||
|
content-type: application/json
|
||||||
|
Authorization: Bearer {{admin_token}}
|
||||||
|
|
||||||
### 排菜列表
|
### 排菜列表
|
||||||
GET {{host}}/admin/dish/list?limit=10
|
GET {{host}}/admin/dish/list?limit=10
|
||||||
content-type: application/json
|
content-type: application/json
|
||||||
|
|||||||
Reference in New Issue
Block a user