Commit ac83deaf by 杨树贤

根据用户id获取询价数量

parent 522599f3
...@@ -7,6 +7,7 @@ use App\Admin\Renderable\BarChart; ...@@ -7,6 +7,7 @@ use App\Admin\Renderable\BarChart;
use App\Admin\Renderable\InquiryDetail; use App\Admin\Renderable\InquiryDetail;
use App\Admin\Renderable\PostTable; use App\Admin\Renderable\PostTable;
use App\Admin\Repositories\Inquiry; use App\Admin\Repositories\Inquiry;
use App\Admin\Service\InquiryService;
use App\Models\Cms\CmsUser; use App\Models\Cms\CmsUser;
use Dcat\Admin\Admin; use Dcat\Admin\Admin;
use Dcat\Admin\Form; use Dcat\Admin\Form;
......
...@@ -15,4 +15,19 @@ class InquiryService ...@@ -15,4 +15,19 @@ class InquiryService
{ {
return Inquiry::batchUpdateSalesId($salesId, $userIds); return Inquiry::batchUpdateSalesId($salesId, $userIds);
} }
//根据用户id列表获取待处理和所有询价单的数量
public static function getInquiryCountByUserIds($userIds = [])
{
$result = [];
foreach ($userIds as $userId) {
$pendingCount = Inquiry::getInquiryCountByStatus($userId,Inquiry::STATUS_PENDING);
$allCount = Inquiry::where('user_id',$userId)->count();
$result[$userId] = [
'pending' => $pendingCount,
'all' => $allCount,
];
}
return $result;
}
} }
...@@ -32,6 +32,11 @@ class Inquiry extends Model ...@@ -32,6 +32,11 @@ class Inquiry extends Model
return $this->hasOne(CmsUser::class, 'userId', 'sales_id'); return $this->hasOne(CmsUser::class, 'userId', 'sales_id');
} }
public static function getInquiryCountByStatus($userId,$status)
{
return self::where('user_id',$userId)->where('status', $status)->count();
}
public static function batchUpdateSalesId($salesId, $userIds = []) public static function batchUpdateSalesId($salesId, $userIds = [])
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment