crm
This commit is contained in:
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
namespace app\crm\controller;
|
namespace app\crm\controller;
|
||||||
|
|
||||||
|
use app\common\model\User;
|
||||||
use app\crm\model\Channel;
|
use app\crm\model\Channel;
|
||||||
|
use app\crm\model\Country;
|
||||||
use app\crm\model\Customer;
|
use app\crm\model\Customer;
|
||||||
use app\crm\model\CustomerHis;
|
use app\crm\model\CustomerHis;
|
||||||
use app\crm\model\Follow;
|
use app\crm\model\Follow;
|
||||||
use app\crm\model\User;
|
|
||||||
use app\crm\service\CustomerService;
|
use app\crm\service\CustomerService;
|
||||||
use app\crm\utils\Util;
|
use app\crm\utils\Util;
|
||||||
use config\constants\Constants;
|
use config\constants\Constants;
|
||||||
@@ -24,9 +25,9 @@ class CustomerController extends BaseController
|
|||||||
{
|
{
|
||||||
$grade = [];
|
$grade = [];
|
||||||
$gradeConstants = Constants::GRADE_EN;
|
$gradeConstants = Constants::GRADE_EN;
|
||||||
if($request->user['language'] == 'zh_CN'){
|
if('zh_CN' == 'zh_CN'){
|
||||||
$gradeConstants = Constants::GRADE;
|
$gradeConstants = Constants::GRADE_ZH;
|
||||||
}elseif ($request->user['language'] == 'ru'){
|
}elseif ('zh_CN' == 'ru'){
|
||||||
$gradeConstants = Constants::GRADE_RU;
|
$gradeConstants = Constants::GRADE_RU;
|
||||||
}
|
}
|
||||||
foreach ($gradeConstants as $key => $value) {
|
foreach ($gradeConstants as $key => $value) {
|
||||||
@@ -35,7 +36,7 @@ class CustomerController extends BaseController
|
|||||||
'name' => $value,
|
'name' => $value,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return Util::success($grade);
|
return $this->success($grade);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,9 +48,9 @@ class CustomerController extends BaseController
|
|||||||
{
|
{
|
||||||
$grade = [];
|
$grade = [];
|
||||||
$magnitudeConstants = Constants::MAGNITUDE_EN;
|
$magnitudeConstants = Constants::MAGNITUDE_EN;
|
||||||
if($request->user['language'] == 'zh_CN'){
|
if('zh_CN' == 'zh_CN'){
|
||||||
$magnitudeConstants = Constants::MAGNITUDE;
|
$magnitudeConstants = Constants::MAGNITUDE;
|
||||||
}elseif ($request->user['language'] == 'ru'){
|
}elseif ('zh_CN' == 'ru'){
|
||||||
$magnitudeConstants = Constants::MAGNITUDE_RU;
|
$magnitudeConstants = Constants::MAGNITUDE_RU;
|
||||||
}
|
}
|
||||||
foreach ($magnitudeConstants as $key => $value) {
|
foreach ($magnitudeConstants as $key => $value) {
|
||||||
@@ -58,7 +59,7 @@ class CustomerController extends BaseController
|
|||||||
'name' => $value,
|
'name' => $value,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return Util::success($grade);
|
return $this->success($grade);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,17 +71,40 @@ class CustomerController extends BaseController
|
|||||||
{
|
{
|
||||||
$list = Channel::getAll();
|
$list = Channel::getAll();
|
||||||
|
|
||||||
if($request->user['language'] != 'zh_CN'){
|
if('zh_CN' != 'zh_CN'){
|
||||||
foreach ($list as &$value) {
|
foreach ($list as &$value) {
|
||||||
$value['name'] = $value['name_en'];
|
$value['name'] = $value['name_en'];
|
||||||
}
|
}
|
||||||
}elseif ($request->user['language'] == 'ru'){
|
}elseif ('zh_CN' == 'ru'){
|
||||||
foreach ($list as &$value) {
|
foreach ($list as &$value) {
|
||||||
$value['name'] = $value['name_ru'];
|
$value['name'] = $value['name_ru'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Util::success($list);
|
return $this->success($list);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国家
|
||||||
|
* @param Request $request
|
||||||
|
* @return \support\Response
|
||||||
|
*/
|
||||||
|
public function getCountry(Request $request)
|
||||||
|
{
|
||||||
|
$list = Country::getAll();
|
||||||
|
|
||||||
|
if('zh_CN' != 'zh_CN'){
|
||||||
|
foreach ($list as &$value) {
|
||||||
|
$value['name'] = $value['name_en'];
|
||||||
|
}
|
||||||
|
}elseif ('zh_CN' == 'ru'){
|
||||||
|
foreach ($list as &$value) {
|
||||||
|
$value['name'] = $value['name_ru'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success($list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,12 +115,13 @@ class CustomerController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function waitFollow(Request $request)
|
public function waitFollow(Request $request)
|
||||||
{
|
{
|
||||||
$userId = $request->user['id'];
|
$userId = $request->user->uid;
|
||||||
$filter = Util::getParam($request, 'filter');
|
$filter = Util::getParam($request, 'filter');
|
||||||
$page = $request->input('page', 1);
|
$page = $request->input('page', 1);
|
||||||
$perPage = $request->input('per_page', 10);
|
$perPage = $request->input('per_page', 10);
|
||||||
$where = [
|
$where = [
|
||||||
['user_id', '=', $userId],
|
['user_id', '=', $userId],
|
||||||
|
['corp_abbr', '=', $request->basic_data['corp_abbr']],
|
||||||
['follow_next', '<>', 0],
|
['follow_next', '<>', 0],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -116,7 +141,7 @@ class CustomerController extends BaseController
|
|||||||
$item['follow_remaining'] = $item->follow_next-time();
|
$item['follow_remaining'] = $item->follow_next-time();
|
||||||
$item['follow_next'] = date('Y-m-d H:i:s',$item->follow_next);
|
$item['follow_next'] = date('Y-m-d H:i:s',$item->follow_next);
|
||||||
}
|
}
|
||||||
return Util::page($customer);
|
return $this->success($this->page($customer));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,6 +154,7 @@ class CustomerController extends BaseController
|
|||||||
try {
|
try {
|
||||||
$param = $request->all();
|
$param = $request->all();
|
||||||
$param['user_id'] = $request->user->uid;
|
$param['user_id'] = $request->user->uid;
|
||||||
|
$param['corp_abbr'] = $request->basic_data['corp_abbr'];
|
||||||
$result = (new CustomerService())->list($param);
|
$result = (new CustomerService())->list($param);
|
||||||
|
|
||||||
return $this->success($this->page($result));
|
return $this->success($this->page($result));
|
||||||
@@ -146,18 +172,18 @@ class CustomerController extends BaseController
|
|||||||
{
|
{
|
||||||
$id = Util::getParam($request,'id', '');
|
$id = Util::getParam($request,'id', '');
|
||||||
if (Util::isEmpty($id)) {
|
if (Util::isEmpty($id)) {
|
||||||
return Util::fail([], trans('id_empty'));
|
return $this->error(trans('id_empty'));
|
||||||
}
|
}
|
||||||
$userId = $request->user['id'];
|
$userId = $request->user->uid;
|
||||||
$where = [
|
$where = [
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'user_id' => $userId,
|
'user_id' => $userId,
|
||||||
];
|
];
|
||||||
$res = Customer::where($where)->restore();
|
$res = Customer::where($where)->restore();
|
||||||
if($res){
|
if($res){
|
||||||
return Util::success($res, trans('success'));
|
return $this->success($res, trans('success'));
|
||||||
}else{
|
}else{
|
||||||
return Util::fail([], trans('fail'));
|
return $this->error(trans('fail'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,21 +197,22 @@ class CustomerController extends BaseController
|
|||||||
{
|
{
|
||||||
$id = Util::getParam($request, 'id');
|
$id = Util::getParam($request, 'id');
|
||||||
if (Util::isEmpty($id)) {
|
if (Util::isEmpty($id)) {
|
||||||
return Util::fail([], 'id' . trans('not_null'));
|
return $this->error('id' . trans('not_null'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = Customer::with('tags')->select('id', 'user_id', 'grade', 'channel_id', 'car_type_id', 'country_id', 'magnitude', 'email', 'phone', 'WhatsApp', 'contacts', 'describe', 'address', 'lat', 'lng', 'follow_next', 'follow_remark', 'sex')
|
// $res = Customer::with('tags')->select('id', 'user_id', 'grade', 'channel_id', 'car_type_id', 'country_id', 'magnitude', 'email', 'phone', 'WhatsApp', 'contacts', 'describe', 'address', 'lat', 'lng', 'follow_next', 'follow_remark', 'sex')
|
||||||
->where('id', $id)
|
// ->where('id', $id)
|
||||||
->first();
|
// ->first();
|
||||||
|
$res = (new CustomerService)->detail($request->all());
|
||||||
if ($res) {
|
if ($res) {
|
||||||
$res->toArray();
|
$res->toArray();
|
||||||
} else {
|
} else {
|
||||||
return Util::fail([], '记录不存在');
|
return $this->error('记录不存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = Customer::getCustomer($res, $request, true);
|
$res = Customer::getCustomer($res, $request, true);
|
||||||
|
|
||||||
return Util::success($res);
|
return $this->success($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,25 +225,26 @@ class CustomerController extends BaseController
|
|||||||
$id = Util::getParam($request, 'id');
|
$id = Util::getParam($request, 'id');
|
||||||
$channel_id = Util::getParam($request, 'channel_id');
|
$channel_id = Util::getParam($request, 'channel_id');
|
||||||
if (Util::isEmpty($channel_id)) {
|
if (Util::isEmpty($channel_id)) {
|
||||||
return Util::fail([], trans('channel_not_null'));
|
return $this->error(trans('channel_not_null'));
|
||||||
}
|
}
|
||||||
$country_id = Util::getParam($request, 'country_id', 0);
|
$country_id = Util::getParam($request, 'country_id', 0);
|
||||||
if (Util::isEmpty($country_id)) {
|
if (Util::isEmpty($country_id)) {
|
||||||
// return Util::fail([],'country_id'.trans('not_null'));
|
// return $this->error('country_id'.trans('not_null'));
|
||||||
}
|
}
|
||||||
$car_type_id = Util::getParam($request, 'car_type_id');
|
$car_type_id = Util::getParam($request, 'car_type_id');
|
||||||
if (Util::isEmpty($car_type_id)) {
|
if (Util::isEmpty($car_type_id)) {
|
||||||
return Util::fail([], trans('car_type_not_null'));
|
return $this->error(trans('car_type_not_null'));
|
||||||
}
|
}
|
||||||
$contacts = Util::getParam($request, 'contacts');
|
$contacts = Util::getParam($request, 'contacts');
|
||||||
$email = Util::getParam($request, 'email');
|
$email = Util::getParam($request, 'email');
|
||||||
$phone = Util::getParam($request, 'phone');
|
$phone = Util::getParam($request, 'phone');
|
||||||
if (Util::isEmpty($contacts) && Util::isEmpty($email) && Util::isEmpty($phone)) {
|
if (Util::isEmpty($contacts) && Util::isEmpty($email) && Util::isEmpty($phone)) {
|
||||||
return Util::fail([], trans('contacts_not_null'));
|
return $this->error(trans('contacts_not_null'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'user_id' => $request->user['id'],
|
'user_id' => $request->user->uid,
|
||||||
|
'corp_abbr' => $request->basic_data['corp_abbr'],
|
||||||
'grade' => Util::getParam($request, 'grade', 0),
|
'grade' => Util::getParam($request, 'grade', 0),
|
||||||
'channel_id' => $channel_id,
|
'channel_id' => $channel_id,
|
||||||
'country_id' => $country_id,
|
'country_id' => $country_id,
|
||||||
@@ -244,9 +272,9 @@ class CustomerController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return Util::success($res, trans('save_success'));
|
return $this->success($res, trans('save_success'));
|
||||||
} else {
|
} else {
|
||||||
return Util::fail($res, trans('save_fail'));
|
return $this->error(trans('save_fail'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +289,7 @@ class CustomerController extends BaseController
|
|||||||
{
|
{
|
||||||
$id = Util::getParam($request, 'id');
|
$id = Util::getParam($request, 'id');
|
||||||
if (Util::isEmpty($id)) {
|
if (Util::isEmpty($id)) {
|
||||||
return Util::fail([], 'id' . trans('not_null'));
|
return $this->error('id' . trans('not_null'));
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [
|
||||||
'follow_next' => Util::getParam($request, 'follow_next', 0),
|
'follow_next' => Util::getParam($request, 'follow_next', 0),
|
||||||
@@ -273,9 +301,9 @@ class CustomerController extends BaseController
|
|||||||
->update($data);
|
->update($data);
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return Util::success($res, trans('save_success'));
|
return $this->success($res, trans('save_success'));
|
||||||
} else {
|
} else {
|
||||||
return Util::fail($res, trans('save_fail'));
|
return $this->error(trans('save_fail'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,14 +317,14 @@ class CustomerController extends BaseController
|
|||||||
$id = Util::getParam($request, 'id');
|
$id = Util::getParam($request, 'id');
|
||||||
$force = Util::getParam($request, 'force','');
|
$force = Util::getParam($request, 'force','');
|
||||||
|
|
||||||
$userId = $request->user['id'];
|
$userId = $request->user->uid;
|
||||||
$where = [
|
$where = [
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'user_id' => $userId,
|
'user_id' => $userId,
|
||||||
];
|
];
|
||||||
$customer = Customer::where($where)->withTrashed()->first();
|
$customer = Customer::where($where)->withTrashed()->first();
|
||||||
if(empty($customer)){
|
if(empty($customer)){
|
||||||
return Util::fail('', trans('fail'));
|
return $this->error( trans('fail'));
|
||||||
}
|
}
|
||||||
if($force == 'force'){
|
if($force == 'force'){
|
||||||
$res = $customer->forceDelete();
|
$res = $customer->forceDelete();
|
||||||
@@ -304,9 +332,9 @@ class CustomerController extends BaseController
|
|||||||
$res = $customer->delete();
|
$res = $customer->delete();
|
||||||
}
|
}
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return Util::success($res, trans('success'));
|
return $this->success($res, trans('success'));
|
||||||
} else {
|
} else {
|
||||||
return Util::fail($res, trans('fail'));
|
return $this->error(trans('fail'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,12 +347,14 @@ class CustomerController extends BaseController
|
|||||||
{
|
{
|
||||||
$created = Util::getParam($request, 'created');
|
$created = Util::getParam($request, 'created');
|
||||||
if (Util::isEmpty($created)) {
|
if (Util::isEmpty($created)) {
|
||||||
return Util::fail([], 'created' . trans('not_null'));
|
return $this->error('created' . trans('not_null'));
|
||||||
}
|
}
|
||||||
$userId = $request->user['id'];
|
$userId = $request->user->uid;
|
||||||
$created_at = $request->user['created_at'];
|
//$created_at = $request->user['created_at'];
|
||||||
|
$created_at = User::find($userId)->created_at;
|
||||||
$day = ceil((time() - $created_at + 1) / 60 / 60 / 24);
|
$day = ceil((time() - $created_at + 1) / 60 / 60 / 24);
|
||||||
$where[] = ['user_id', '=', $userId];
|
$where[] = ['user_id', '=', $userId];
|
||||||
|
$where[] = ['corp_abbr', '=', $request->basic_data['corp_abbr']];
|
||||||
$start = strtotime($created . '-01');
|
$start = strtotime($created . '-01');
|
||||||
$year = date('Y', $start);
|
$year = date('Y', $start);
|
||||||
$month = date('n', $start); //获取月份
|
$month = date('n', $start); //获取月份
|
||||||
@@ -366,9 +396,9 @@ class CustomerController extends BaseController
|
|||||||
'customer_deal' => $customerDeal, //已成交
|
'customer_deal' => $customerDeal, //已成交
|
||||||
];
|
];
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return Util::success($res, trans('success'));
|
return $this->success($res, trans('success'));
|
||||||
} else {
|
} else {
|
||||||
return Util::fail($res, trans('fail'));
|
return $this->error(trans('fail'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,17 +410,17 @@ class CustomerController extends BaseController
|
|||||||
public function claim(Request $request)
|
public function claim(Request $request)
|
||||||
{
|
{
|
||||||
$customerId = Util::getParam($request, 'customer_id');
|
$customerId = Util::getParam($request, 'customer_id');
|
||||||
$userId = $request->user['id'];
|
$userId = $request->user->uid;
|
||||||
if (Util::isEmpty($customerId)) {
|
if (Util::isEmpty($customerId)) {
|
||||||
return Util::fail([], trans('customer_id').trans('not_null'));
|
return $this->error(trans('customer_id').trans('not_null'));
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [
|
||||||
'user_id' => $request->user['id']
|
'user_id' => $request->user->uid
|
||||||
];
|
];
|
||||||
$customer= Customer::withTrashed()->find($customerId);
|
$customer= Customer::withTrashed()->find($customerId);
|
||||||
|
|
||||||
if(empty($customer) || $customer->user_id != 0){
|
if(empty($customer) || $customer->user_id != 0){
|
||||||
return Util::fail('', trans('claim_fail'));
|
return $this->error( trans('claim_fail'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$customer->restore();
|
$customer->restore();
|
||||||
@@ -404,9 +434,9 @@ class CustomerController extends BaseController
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return Util::success($res, trans('success'));
|
return $this->success($res, trans('success'));
|
||||||
} else {
|
} else {
|
||||||
return Util::fail($res, trans('fail'));
|
return $this->error(trans('fail'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,14 +451,14 @@ class CustomerController extends BaseController
|
|||||||
{
|
{
|
||||||
$customerId = Util::getParam($request, 'customer_id');
|
$customerId = Util::getParam($request, 'customer_id');
|
||||||
$user_sn = Util::getParam($request, 'user_sn');
|
$user_sn = Util::getParam($request, 'user_sn');
|
||||||
$userId = $request->user['id'];
|
$userId = $request->user->uid;
|
||||||
if (Util::isEmpty($user_sn)) {
|
if (Util::isEmpty($user_sn)) {
|
||||||
return Util::fail([], 'ID'.trans('not_null'));
|
return $this->error('ID'.trans('not_null'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::where(['sn' => $user_sn])->first();
|
$user = User::where(['sn' => $user_sn])->first();
|
||||||
if (Util::isEmpty($user)) {
|
if (Util::isEmpty($user)) {
|
||||||
return Util::fail(null, trans('user_none'));
|
return $this->error( trans('user_none'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Util::isEmpty($customerId)){
|
if(Util::isEmpty($customerId)){
|
||||||
@@ -453,9 +483,9 @@ class CustomerController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return Util::success($res, trans('success'));
|
return $this->success($res, trans('success'));
|
||||||
} else {
|
} else {
|
||||||
return Util::fail($res, trans('fail'));
|
return $this->error(trans('fail'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,10 +499,10 @@ class CustomerController extends BaseController
|
|||||||
$id = Util::getParam($request, 'id');
|
$id = Util::getParam($request, 'id');
|
||||||
$grade = Util::getParam($request, 'grade');
|
$grade = Util::getParam($request, 'grade');
|
||||||
if (Util::isEmpty($id)) {
|
if (Util::isEmpty($id)) {
|
||||||
return Util::fail('', 'id' . trans('not_null'));
|
return $this->error( 'id' . trans('not_null'));
|
||||||
}
|
}
|
||||||
if (Util::isEmpty($id)) {
|
if (Util::isEmpty($id)) {
|
||||||
return Util::fail('', 'grade' . trans('not_null'));
|
return $this->error( 'grade' . trans('not_null'));
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [
|
||||||
'grade' => $grade,
|
'grade' => $grade,
|
||||||
@@ -481,9 +511,9 @@ class CustomerController extends BaseController
|
|||||||
->update($data);
|
->update($data);
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return Util::success($res, trans('save_success'));
|
return $this->success($res, trans('save_success'));
|
||||||
} else {
|
} else {
|
||||||
return Util::fail($res, trans('save_fail'));
|
return $this->error(trans('save_fail'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,8 @@ class FollowController extends BaseController
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$data = $this->validate(new FollowValidate(), $request->get(), 'list');
|
$data = $this->validate(new FollowValidate(), $request->get(), 'list');
|
||||||
$result = (new FollowService())->list($request->all(),$request->user->uid);
|
$request->setGet('corp_abbr', $request->basic_data['corp_abbr']);
|
||||||
|
$result = (new FollowService())->list($request->all(), $request->user->uid);
|
||||||
return $this->success($result);
|
return $this->success($result);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return $this->error($e->getMessage());
|
return $this->error($e->getMessage());
|
||||||
@@ -55,17 +56,17 @@ class FollowController extends BaseController
|
|||||||
public function detail(Request $request)
|
public function detail(Request $request)
|
||||||
{
|
{
|
||||||
//跟进id
|
//跟进id
|
||||||
$id = Util::getParam($request,'id');
|
$id = Util::getParam($request, 'id');
|
||||||
if(Util::isEmpty($id)){
|
if (Util::isEmpty($id)) {
|
||||||
return $this->error('id'.trans('not_null'));
|
return $this->error('id' . trans('not_null'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = Follow::select('id','user_id','customer_id','type','picture','remark','audio','audio_text','lat','lng','address')
|
$res = Follow::select('id', 'user_id', 'customer_id', 'type', 'picture', 'remark', 'audio', 'audio_text', 'lat', 'lng', 'address')
|
||||||
->where('id',$id)
|
->where('id', $id)
|
||||||
->first();
|
->first();
|
||||||
if($res){
|
if ($res) {
|
||||||
$res->toArray();
|
$res->toArray();
|
||||||
}else{
|
} else {
|
||||||
return $this->error('记录不存在');
|
return $this->error('记录不存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,32 +82,33 @@ class FollowController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function save(Request $request)
|
public function save(Request $request)
|
||||||
{
|
{
|
||||||
$customer_id = Util::getParam($request,'customer_id');
|
$customer_id = Util::getParam($request, 'customer_id');
|
||||||
|
|
||||||
if(Util::isEmpty($customer_id)){
|
if (Util::isEmpty($customer_id)) {
|
||||||
return $this->error('customer_id'.trans('not_null'));
|
return $this->error('customer_id' . trans('not_null'));
|
||||||
}
|
}
|
||||||
$type = Util::getParam($request,'type');
|
$type = Util::getParam($request, 'type');
|
||||||
if(Util::isEmpty($type)){
|
if (Util::isEmpty($type)) {
|
||||||
return $this->error('type'.trans('not_null'));
|
return $this->error('type' . trans('not_null'));
|
||||||
}
|
}
|
||||||
$picture = Util::getParam($request,'picture');
|
$picture = Util::getParam($request, 'picture');
|
||||||
if(Util::isEmpty($picture)){
|
if (Util::isEmpty($picture)) {
|
||||||
return $this->error(trans('picture_not_null'));
|
return $this->error(trans('picture_not_null'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'user_id'=>$request->user->uid,
|
'user_id' => $request->user->uid,
|
||||||
'customer_id'=>$customer_id,
|
'corp_abbr' => $request->basic_data['corp_abbr'],
|
||||||
'type'=>$type,
|
'customer_id' => $customer_id,
|
||||||
'picture'=>$picture,
|
'type' => $type,
|
||||||
'remark'=>Util::getParam($request,'remark',''),
|
'picture' => $picture,
|
||||||
'audio'=>Util::getParam($request,'audio',''),
|
'remark' => Util::getParam($request, 'remark', ''),
|
||||||
'audio_text'=>Util::getParam($request,'audio_text',''),
|
'audio' => Util::getParam($request, 'audio', ''),
|
||||||
'lat'=>Util::getParam($request,'lat',0),
|
'audio_text' => Util::getParam($request, 'audio_text', ''),
|
||||||
'lng'=>Util::getParam($request,'lng',0),
|
'lat' => Util::getParam($request, 'lat', 0),
|
||||||
'address'=>Util::getParam($request,'address'),
|
'lng' => Util::getParam($request, 'lng', 0),
|
||||||
'follow_time'=>strtotime(Util::getParam($request,'firstFollowtime',0)),
|
'address' => Util::getParam($request, 'address'),
|
||||||
|
'follow_time' => strtotime(Util::getParam($request, 'firstFollowtime', 0)),
|
||||||
];
|
];
|
||||||
|
|
||||||
$res = Follow::create($data);
|
$res = Follow::create($data);
|
||||||
@@ -119,7 +121,7 @@ class FollowController extends BaseController
|
|||||||
|
|
||||||
$follow_next = Util::getParam($request, 'follow_next', 0);
|
$follow_next = Util::getParam($request, 'follow_next', 0);
|
||||||
$follow_remark = Util::getParam($request, 'follow_remark', 0);
|
$follow_remark = Util::getParam($request, 'follow_remark', 0);
|
||||||
if($res && (!empty($follow_next))){
|
if ($res && (!empty($follow_next))) {
|
||||||
$data = [
|
$data = [
|
||||||
'follow_next' => $follow_next,
|
'follow_next' => $follow_next,
|
||||||
'follow_remark' => $follow_remark,
|
'follow_remark' => $follow_remark,
|
||||||
@@ -130,7 +132,7 @@ class FollowController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return $this->success($res,trans('save_success'));
|
return $this->success($res, trans('save_success'));
|
||||||
} else {
|
} else {
|
||||||
return $this->error(trans('save_fail'));
|
return $this->error(trans('save_fail'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,14 @@
|
|||||||
|
|
||||||
namespace app\crm\logic;
|
namespace app\crm\logic;
|
||||||
|
|
||||||
|
use app\crm\model\Customer;
|
||||||
|
|
||||||
class CustomerLogic
|
class CustomerLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function find(int $id)
|
||||||
|
{
|
||||||
|
$customer = Customer::find($id);
|
||||||
|
return $customer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ class Channel extends Model
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $table = 'channel';
|
protected $table = 'inquiry_channel';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The primary key associated with the table.
|
* The primary key associated with the table.
|
||||||
@@ -42,7 +42,7 @@ class Channel extends Model
|
|||||||
|
|
||||||
public static function getAll()
|
public static function getAll()
|
||||||
{
|
{
|
||||||
$list = self::get()->select('id','name','name_en','status')->where('status',0)->toArray();
|
$list = self::get()->select('id','name','name_en','status')->where('status',1)->toArray();
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ class Country extends Model
|
|||||||
|
|
||||||
public static function getAll()
|
public static function getAll()
|
||||||
{
|
{
|
||||||
$list = self::get()->select('id','cn_addr','en_addr')->get()->toArray();
|
$list = self::select('id','cn_addr','en_addr')->get();
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,8 @@ class Customer extends Model
|
|||||||
// $customer['updated_at'] = Util::timeTotDate($customer['updated_at']);
|
// $customer['updated_at'] = Util::timeTotDate($customer['updated_at']);
|
||||||
|
|
||||||
$customer = Util::formatDate($customer,['follow_last']);
|
$customer = Util::formatDate($customer,['follow_last']);
|
||||||
$nameLang = $language=='en'?'name_en':($language=='ru'?'name_ru':'name');
|
// $nameLang = $language=='en'?'name_en':($language=='ru'?'name_ru':'name');
|
||||||
|
$nameLang = 'name';
|
||||||
$countryLang = $language=='en'?'en_addr':'cn_addr';
|
$countryLang = $language=='en'?'en_addr':'cn_addr';
|
||||||
$customer['car_type_name'] = empty($customer['car_type_id'])?'':CarType::where(['id'=>$customer['car_type_id']])->value($nameLang);
|
$customer['car_type_name'] = empty($customer['car_type_id'])?'':CarType::where(['id'=>$customer['car_type_id']])->value($nameLang);
|
||||||
$customer['country_name'] = empty($customer['country_id'])?'':Country::where(['id'=>$customer['country_id']])->value($countryLang);
|
$customer['country_name'] = empty($customer['country_id'])?'':Country::where(['id'=>$customer['country_id']])->value($countryLang);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace app\crm\service;
|
namespace app\crm\service;
|
||||||
|
|
||||||
|
use app\crm\logic\CustomerLogic;
|
||||||
use app\crm\model\Customer;
|
use app\crm\model\Customer;
|
||||||
|
|
||||||
class CustomerService
|
class CustomerService
|
||||||
@@ -25,4 +26,15 @@ class CustomerService
|
|||||||
// }
|
// }
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function detail($params)
|
||||||
|
{
|
||||||
|
$id =$params['id'];
|
||||||
|
$customer = Customer::with('tags')->select('id', 'user_id', 'grade', 'channel_id', 'car_type_id', 'country_id', 'magnitude', 'email', 'phone', 'WhatsApp', 'contacts', 'describe', 'address', 'lat', 'lng', 'follow_next', 'follow_remark', 'sex')
|
||||||
|
->where('id', $id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
return $customer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -18,16 +18,18 @@ class FollowService
|
|||||||
// $perPage = $request->input('per_page', 10);
|
// $perPage = $request->input('per_page', 10);
|
||||||
|
|
||||||
//客户id
|
//客户id
|
||||||
$customer_id =$param['customer_id'];
|
$customer_id = $param['customer_id'];
|
||||||
|
$corp_abbr = $param['corp_abbr'];
|
||||||
|
|
||||||
$where = [];
|
$where = [];
|
||||||
$where['customer_id'] = $customer_id;
|
$where['customer_id'] = $customer_id;
|
||||||
|
$where['corp_abbr'] = $corp_abbr;
|
||||||
|
|
||||||
//用户角色
|
//用户角色
|
||||||
|
|
||||||
//跟进id
|
//跟进id
|
||||||
$id = $param['id']??null;
|
$id = $param['id'] ?? null;
|
||||||
if(!Util::isEmpty($id)){
|
if (!Util::isEmpty($id)) {
|
||||||
$where['id'] = $id;
|
$where['id'] = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ class FollowService
|
|||||||
|
|
||||||
// $host = $request->host();
|
// $host = $request->host();
|
||||||
// $url = 'http:'.$request->url();
|
// $url = 'http:'.$request->url();
|
||||||
foreach ($data as &$value){
|
foreach ($data as &$value) {
|
||||||
$value = self::getFollow($value);
|
$value = self::getFollow($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,15 +49,14 @@ class FollowService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function getFollow($follow)
|
||||||
public static function getFollow($follow,$domain = 'https://vehicle-album.oss-cn-beijing.aliyuncs.com')
|
|
||||||
{
|
{
|
||||||
$follow['type_txt'] = Constants::FOLLOW[$follow['type']];
|
$follow['type_txt'] = Constants::FOLLOW[$follow['type']];
|
||||||
$follow['firstFollowtime'] = $follow['follow_time'];
|
$follow['firstFollowtime'] = $follow['follow_time'];
|
||||||
$oss_picture = '';
|
$oss_picture = '';
|
||||||
if(!empty($follow['picture'])){
|
if (!empty($follow['picture'])) {
|
||||||
$ossservice = new OssService();
|
$ossservice = new OssService();
|
||||||
$oss_picture = $ossservice->generatePrivateUrl($follow['picture'],86400);
|
$oss_picture = $ossservice->generatePrivateUrl($follow['picture'], 86400);
|
||||||
}
|
}
|
||||||
$follow['oss_picture'] = $oss_picture;
|
$follow['oss_picture'] = $oss_picture;
|
||||||
// $follow = Util::formatDate($follow);
|
// $follow = Util::formatDate($follow);
|
||||||
|
|||||||
@@ -91,5 +91,10 @@ Route::group('/crm', function () {
|
|||||||
Route::any('/customer/list', [app\crm\controller\CustomerController::class, 'list']);
|
Route::any('/customer/list', [app\crm\controller\CustomerController::class, 'list']);
|
||||||
Route::any('/customer/detail', [app\crm\controller\CustomerController::class, 'detail']);
|
Route::any('/customer/detail', [app\crm\controller\CustomerController::class, 'detail']);
|
||||||
Route::any('/customer/add', [app\crm\controller\CustomerController::class, 'save']);
|
Route::any('/customer/add', [app\crm\controller\CustomerController::class, 'save']);
|
||||||
|
Route::any('/customer/claim', [app\crm\controller\CustomerController::class, 'claim']);
|
||||||
|
Route::any('/customer/restore', [app\crm\controller\CustomerController::class, 'restore']);
|
||||||
|
Route::any('/customer/delete', [app\crm\controller\CustomerController::class, 'delete']);
|
||||||
|
Route::any('/customer/waitFollow', [app\crm\controller\CustomerController::class, 'waitFollow']);
|
||||||
|
Route::any('/customer/getChannel', [app\crm\controller\CustomerController::class, 'getChannel']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user