feat:depot_purchase
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Constants\Admin\DepotCode;
|
||||
use App\Constants\Common\MaterialCode;
|
||||
use App\Constants\Common\RoleCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Extend\DateUtil;
|
||||
use App\Model\Depot;
|
||||
use App\Model\DepotPurchase;
|
||||
use App\Model\DepotRecycle;
|
||||
@@ -306,6 +307,56 @@ class DepotService extends BaseService{
|
||||
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
|
||||
{
|
||||
$depotId = (int)$this->request->input('depot_id');
|
||||
|
||||
Reference in New Issue
Block a user