Merge branch 'develop'

This commit is contained in:
mzl
2025-08-14 20:08:57 +08:00
parent f4a2966b1e
commit 39e840bba8
49 changed files with 2240 additions and 522 deletions
+62 -4
View File
@@ -4,6 +4,7 @@ namespace app\crmAdmin\service;
use app\common\model\InquiryLog;
use app\common\model\User;
use app\common\service\OssService;
use app\crm\model\CustomerHis;
use app\crmAdmin\logic\CustomerLogic;
use app\crm\model\CarType;
@@ -104,16 +105,22 @@ class CustomerService
if (!Util::isEmpty($keyword)) {
$query->where(function ($query) use ($keyword) {
$query->where('contacts', 'like', "%{$keyword}%")
->orWhere('phone', 'like', "%{$keyword}%");
->orWhere('phone', 'like', "%{$keyword}%")
->orWhere('email', 'like', "%{$keyword}%")
->orWhere('WhatsApp', 'like', "%{$keyword}%")
->orWhere('code', 'like', "%{$keyword}%");
});
}
if (!Util::isEmpty($grade)) {
$query->whereIn('grade', $grade);
}
if ($recycle == 'recycle' || $scene == 'recycle' || $seas == 'seas' || $scene == 'seas' || $scene == 'audit') {
if ($recycle == 'recycle' || $scene == 'recycle' || $scene == 'audit') {
$query->onlyTrashed();
}
if ($seas == 'seas' || $scene == 'seas') {
$query->withTrashed();
}
if (!$export) {
$customer = $query->orderBy('id', 'desc')->paginate($perPage, ['*'], 'page', $page);
@@ -124,9 +131,10 @@ class CustomerService
if (!$export) {
foreach ($customer as &$item) {
$item = $this->getCustomer($item);
$item['desc_collect'] = $item['desc_collect'] ?? '';
$item['follow_next'] = empty($item['follow_next'])?'':date('Y-m-d H:i:s', $item['follow_next']);
if ($seas == 'seas' || $scene == 'seas') {
$item['seas_time'] = time() - strtotime($item['deleted_at']);
$item['seas_time'] = time() - (empty($item['deleted_at'])?strtotime($item['updated_at']):strtotime($item['deleted_at']));
}
if ($scene == 'audit') { //审核时查询举报人姓名
$customerHis = CustomerHis::where('customer_id', $item->id)->orderBy('id', 'desc')->first(['user_his']);
@@ -315,7 +323,42 @@ class CustomerService
}
}
}
$res = $query->update(['user_id' => $userId]);
$data = [
'user_id' => $userId,
'obtain' => time(),
];
$res = $query->update($data);
Db::commit();
return $res;
} catch (\Throwable $e) {
Db::rollback();
throw $e;
}
}
/**
* @param $params
* @return bool
*/
public function delete($params)
{
try {
Db::beginTransaction();
$customerId = $params['customer_id'];
$query= Customer::whereIn('id',explode(',',$customerId));
$customer = $query->get();
foreach ($customer as $item) {
//记录客户关系变化
$his = CustomerHis::create([
'customer_id' => $item->id,
'user_his' => $item->user_id,
'user_id' => 0,
]);
}
$res = $query->update(['user_id' => 0]);
Db::commit();
return $res;
@@ -394,4 +437,19 @@ class CustomerService
return $customer;
}
public function follow($params)
{
$id = $params['id'];
$follow = Follow::
where('customer_id', $id)
->get();
$ossservice = new OssService();
foreach ($follow as $item) {
$item['picture_full'] = empty($item->picture)?'':$ossservice->generatePrivateUrl($item->picture);
}
return $follow;
}
}