使用fdesk库

This commit is contained in:
2025-07-23 16:55:18 +08:00
parent fa4ade4b35
commit ef66ecbbef
13 changed files with 71 additions and 39 deletions
+6 -4
View File
@@ -58,13 +58,15 @@ class AreaController
// } // }
$list = Country::get()->toArray(); $list = Country::get()->toArray();
$language = 'en_addr'; $name = 'en_addr';
if($request->user['language'] == 'zh_CN'){ //$language = $request->user['language'];
$language = 'cn_addr'; $language = 'zh_CN';
if($language == 'zh_CN'){
$name = 'cn_addr';
} }
foreach ($list as &$row) { foreach ($list as &$row) {
$row['name'] = $row[$language]; $row['name'] = $row[$name];
} }
return Util::success($list); return Util::success($list);
} }
+4 -2
View File
@@ -17,11 +17,13 @@ class CarTypeController
{ {
$list = CarType::getAll(); $list = CarType::getAll();
if($request->user['language'] != 'zh_CN'){ //$language = $request->user['language'];
$language = 'zh_CN';
if($language == 'en'){
foreach ($list as &$value) { foreach ($list as &$value) {
$value['name'] = $value['name_en']; $value['name'] = $value['name_en'];
} }
}elseif ($request->user['language'] == 'ru'){ }elseif ($language == 'ru'){
foreach ($list as &$value) { foreach ($list as &$value) {
$value['name'] = $value['name_ru']; $value['name'] = $value['name_ru'];
} }
+14 -7
View File
@@ -31,9 +31,12 @@ class CustomerController
{ {
$grade = []; $grade = [];
$gradeConstants = Constants::GRADE_EN; $gradeConstants = Constants::GRADE_EN;
if($request->user['language'] == 'zh_CN'){
//$language = $request->user['language'];
$language = 'zh_CN';
if($language == 'zh_CN'){
$gradeConstants = Constants::GRADE; $gradeConstants = Constants::GRADE;
}elseif ($request->user['language'] == 'ru'){ }elseif ($language == 'ru'){
$gradeConstants = Constants::GRADE_RU; $gradeConstants = Constants::GRADE_RU;
} }
foreach ($gradeConstants as $key => $value) { foreach ($gradeConstants as $key => $value) {
@@ -54,9 +57,11 @@ class CustomerController
{ {
$grade = []; $grade = [];
$magnitudeConstants = Constants::MAGNITUDE_EN; $magnitudeConstants = Constants::MAGNITUDE_EN;
if($request->user['language'] == 'zh_CN'){ //$language = $request->user['language'];
$language = 'zh_CN';
if($language == 'zh_CN'){
$magnitudeConstants = Constants::MAGNITUDE; $magnitudeConstants = Constants::MAGNITUDE;
}elseif ($request->user['language'] == 'ru'){ }elseif ($language == 'ru'){
$magnitudeConstants = Constants::MAGNITUDE_RU; $magnitudeConstants = Constants::MAGNITUDE_RU;
} }
foreach ($magnitudeConstants as $key => $value) { foreach ($magnitudeConstants as $key => $value) {
@@ -77,11 +82,13 @@ class CustomerController
{ {
$list = Channel::getAll(); $list = Channel::getAll();
if($request->user['language'] != 'zh_CN'){ //$language = $request->user['language'];
$language = 'zh_CN';
if($language != '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 ($language == 'ru'){
foreach ($list as &$value) { foreach ($list as &$value) {
$value['name'] = $value['name_ru']; $value['name'] = $value['name_ru'];
} }
@@ -178,7 +185,7 @@ class CustomerController
// 执行分页查询 //关联标签tags //关联标签及分组tags.group // 执行分页查询 //关联标签tags //关联标签及分组tags.group
$query = Customer::with('tags')->where($where) $query = Customer::with('tags')->where($where)
->orderBy('customer.id', 'desc'); ->orderBy('crm_customer.id', 'desc');
if(!empty($tagId)){ if(!empty($tagId)){
// $query->with(['tags' => function($query) use ($tagId){ // $query->with(['tags' => function($query) use ($tagId){
// $query->where('tag.id', $tagId); // $query->where('tag.id', $tagId);
-2
View File
@@ -55,9 +55,7 @@ class FollowController
if(Util::isEmpty($userId)){ if(Util::isEmpty($userId)){
return Util::fail(['user_id'=>$userId],trans('user_none')); return Util::fail(['user_id'=>$userId],trans('user_none'));
} }
if($request->user['role']!=1){
$where['user_id'] = $userId; $where['user_id'] = $userId;
}
//跟进id //跟进id
$id = Util::getParam($request,'id'); $id = Util::getParam($request,'id');
+2 -1
View File
@@ -16,7 +16,8 @@ class TagGroupController
{ {
$list = TagGroup::with('tags')->get(); $list = TagGroup::with('tags')->get();
$languageArr = Constants::LANGUAGE; $languageArr = Constants::LANGUAGE;
$language = $request->user['language']; // $language = $request->user['language'];
$language = 'zh_CN';
foreach ($list as &$item) { foreach ($list as &$item) {
$item['names'] = unserialize($item['names']); $item['names'] = unserialize($item['names']);
if (in_array($language, $languageArr)) { if (in_array($language, $languageArr)) {
+29 -8
View File
@@ -6,12 +6,14 @@ use app\model\Country;
use app\model\FeishuUser; use app\model\FeishuUser;
use app\model\User; use app\model\User;
use app\model\UserSn; use app\model\UserSn;
use app\service\AuthService;
use app\service\MailService; use app\service\MailService;
use app\service\UserService; use app\service\UserService;
use app\util\HttpClient; use app\util\HttpClient;
use app\util\JwtUtil; use app\util\JwtUtil;
use app\util\Util; use app\util\Util;
use config\constants\Constants; use config\constants\Constants;
use support\exception\BusinessException;
use support\Log; use support\Log;
use support\Redis; use support\Redis;
use support\Request; use support\Request;
@@ -35,10 +37,14 @@ class UserController
return Util::fail([], trans('required_not_null')); return Util::fail([], trans('required_not_null'));
} }
$user = User::select(['id', 'name', 'sex', 'role', 'avatar', 'email', 'password']) $user = User::where('status', 0)
->where('status', 0) // ->where('email', $request->post('email'))
->where('email', $request->post('email')) ->OrWhere(['email' => $request->post('email'),'phone' => $request->post('email')])
->first(); ->first();
// $builder = User::where('status', 0)
// ->where('email', $request->post('email'));
// $sql = str_replace(['?'], ['\'%s\''], $builder->toSql());
// $fullSql = vsprintf($sql, $builder->getBindings());
if (!$user) { if (!$user) {
return Util::fail(['user' => $user], trans('user_none')); return Util::fail(['user' => $user], trans('user_none'));
} }
@@ -52,10 +58,15 @@ class UserController
//验证密码 //验证密码
// if (!password_verify($userPassword, $hashedPassword)) { // if (!password_verify($userPassword, $hashedPassword)) {
// if ($userPassword == $hashedPassword) { // if ($userPassword == $hashedPassword) {
if (!password_verify($password, $userPassword)) { if (!password_verify($password, $userPassword)) {
locale($language); locale($language);
return Util::fail([], trans('password_error')); return Util::fail([], trans('password_error'));
} }
if ($user['status'] != 1) {
return Util::fail([], '账号已禁用',403);
}
$userId = $user['id']; // 实际从数据库获取 $userId = $user['id']; // 实际从数据库获取
@@ -66,7 +77,7 @@ class UserController
$result = $user; $result = $user;
unset($result['password']); unset($result['password']);
$result['token'] = $token; $result['token'] = $token;
$result['feishu_openid'] = FeishuUser::where('user_id', $userId)->value('open_id'); // $result['feishu_openid'] = FeishuUser::where('user_id', $userId)->value('open_id');
if (!Util::isEmpty($language)) { if (!Util::isEmpty($language)) {
User::where('id', $userId) User::where('id', $userId)
@@ -77,6 +88,17 @@ class UserController
return Util::success($result, trans('login_success')); return Util::success($result, trans('login_success'));
} }
public function loginNew(Request $request)
{
try {
$authService = new AuthService();
$result = $authService->uPwdLogin($request->all());
return Util::success($result, '登录成功');
} catch (\Throwable $e) {
Util::fail([],$e->getMessage());
}
}
/** /**
* 发送邮箱验证码 * 发送邮箱验证码
* @param Request $request * @param Request $request
@@ -152,14 +174,13 @@ class UserController
$hashedPassword = password_hash($password, PASSWORD_DEFAULT); $hashedPassword = password_hash($password, PASSWORD_DEFAULT);
$data = [ $data = [
'mobile' => $mobile, 'phone' => $mobile,
'email' => $email, 'email' => $email,
'name' => '用户_'.rand(111111, 999999), 'name' => '用户_'.rand(111111, 999999),
'sex' => $sex, 'sex' => $sex,
'role' => 1,
'password' => $hashedPassword, 'password' => $hashedPassword,
'status' => 0, 'status' => 1,
'avatar' => 'lingke_crm/logo.png' 'avatar' => ''
]; ];
+4 -4
View File
@@ -77,17 +77,17 @@ class AuthMiddleware implements MiddlewareInterface
} }
$userId = $decoded->sub; $userId = $decoded->sub;
$user = User::select(['id','name','sex','role','avatar','email','password','language','created_at']) $user = User::find($userId);
->find($userId);
if(!$user){ if(!$user){
return Util::fail(['user'=>$user],trans('user_none')); return Util::fail(['user'=>$userId],trans('user_none'));
} }
$user = $user->toArray(); $user = $user->toArray();
// 将用户ID存入请求对象,供后续使用 // 将用户ID存入请求对象,供后续使用
// $request->user = ['id' => $userId]; // $request->user = ['id' => $userId];
$request->user = $user; $request->user = $user;
locale($user['language']); // locale($user['language']);
locale('zh_CN');
return $handler($request); return $handler($request);
} catch (BusinessException $e) { } catch (BusinessException $e) {
return json(['code' => 401, 'msg' => $e->getMessage()]); return json(['code' => 401, 'msg' => $e->getMessage()]);
+4 -3
View File
@@ -17,7 +17,7 @@ class Customer extends Model
* *
* @var string * @var string
*/ */
protected $table = 'customer'; protected $table = 'crm_customer';
/** /**
* The primary key associated with the table. * The primary key associated with the table.
@@ -67,7 +67,8 @@ class Customer extends Model
*/ */
public static function getCustomer($customer, $request, $tag = false) public static function getCustomer($customer, $request, $tag = false)
{ {
$language = $request->user['language'] ?: 'en'; //$language = $request->user['language'] ?: 'en';
$language = 'zh_CN';
$customer['grade_txt'] = Util::language($language, Constants::GRADE_EN[$customer['grade']], Constants::GRADE[$customer['grade']], Constants::GRADE_RU[$customer['grade']]); $customer['grade_txt'] = Util::language($language, Constants::GRADE_EN[$customer['grade']], Constants::GRADE[$customer['grade']], Constants::GRADE_RU[$customer['grade']]);
$customer['magnitude_txt'] = Util::language($language, Constants::MAGNITUDE_EN[$customer['magnitude']], Constants::MAGNITUDE[$customer['magnitude']], Constants::MAGNITUDE_RU[$customer['magnitude']]); $customer['magnitude_txt'] = Util::language($language, Constants::MAGNITUDE_EN[$customer['magnitude']], Constants::MAGNITUDE[$customer['magnitude']], Constants::MAGNITUDE_RU[$customer['magnitude']]);
$customer['sex_txt'] = Util::language($language, Constants::SEX_EN[$customer['sex']], Constants::SEX[$customer['sex']], Constants::SEX_RU[$customer['sex']]); $customer['sex_txt'] = Util::language($language, Constants::SEX_EN[$customer['sex']], Constants::SEX[$customer['sex']], Constants::SEX_RU[$customer['sex']]);
@@ -118,7 +119,7 @@ class Customer extends Model
*/ */
public function tags() public function tags()
{ {
return $this->belongsToMany(Tag::class, 'customer_tag', 'customer_id', 'tag_id') return $this->belongsToMany(Tag::class, 'crm_customer_tag', 'customer_id', 'tag_id')
->withTimestamps(); // 如果需要记录关联时间 ->withTimestamps(); // 如果需要记录关联时间
} }
+1 -1
View File
@@ -17,7 +17,7 @@ class CustomerHis extends Model
* *
* @var string * @var string
*/ */
protected $table = 'customer_his'; protected $table = 'crm_customer_his';
/** /**
* The primary key associated with the table. * The primary key associated with the table.
+1 -1
View File
@@ -14,7 +14,7 @@ class CustomerTag extends Model
* *
* @var string * @var string
*/ */
protected $table = 'customer_tag'; protected $table = 'crm_customer_tag';
/** /**
* The primary key associated with the table. * The primary key associated with the table.
+3 -3
View File
@@ -16,7 +16,7 @@ class Follow extends Model
* *
* @var string * @var string
*/ */
protected $table = 'follow'; protected $table = 'crm_follow';
/** /**
* The primary key associated with the table. * The primary key associated with the table.
@@ -57,8 +57,8 @@ class Follow extends Model
}else { }else {
$follow['oss_picture'] = ''; $follow['oss_picture'] = '';
} }
$follow['created_at'] = date('Y-m-d H:i:s',strtotime($follow['created_at'])+(3600*8)); $follow['created_at'] = (!empty($follow['created_at']))?date('Y-m-d H:i:s',strtotime($follow['created_at'])+(3600*8)):'';
$follow['updated_at'] = date('Y-m-d H:i:s',strtotime($follow['updated_at'])+(3600*8)); $follow['updated_at'] = (!empty($follow['updated_at']))?date('Y-m-d H:i:s',strtotime($follow['updated_at'])+(3600*8)):'';
// $follow = Util::formatDate($follow); // $follow = Util::formatDate($follow);
return $follow; return $follow;
} }
+1 -1
View File
@@ -17,7 +17,7 @@ class Tag extends Model
* *
* @var string * @var string
*/ */
protected $table = 'tag'; protected $table = 'crm_tag';
/** /**
* The primary key associated with the table. * The primary key associated with the table.
+1 -1
View File
@@ -17,7 +17,7 @@ class TagGroup extends Model
* *
* @var string * @var string
*/ */
protected $table = 'tag_group'; protected $table = 'crm_tag_group';
/** /**
* The primary key associated with the table. * The primary key associated with the table.