作者 刘锟

Merge remote-tracking branch 'origin/develop' into akun

<?php
/**
* @remark :
* @name :ImportChannel.php
* @author :lyh
* @method :post
* @time :2023/9/25 15:31
*/
namespace App\Console\Commands;
use App\Helper\OaGlobalsoApi;
use App\Models\Channel\Channel;
use App\Models\Project\Project;
use Illuminate\Console\Command;
class ImportChannel extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'import_channel';
/**
* The console command description.
*
* @var string
*/
protected $description = '更新渠道信息';
/**
* @remark :导入5.0管理员数据
* @name :handle
* @author :lyh
* @method :post
* @time :2023/8/7 17:49
*/
public function handle(){
$projectModel = new Project();
$map = [
'channel'=>['like','%"user_id": "0"%'],
];
$lists = $projectModel->list($map);
// var_dump($lists);
// die();
foreach ($lists as $k => $v){
$order_id = $v['notice_order_id'];
$api = new OaGlobalsoApi();
$data = $api->order_info($order_id);
$data = $data['data'];
$channel = Channel::getProjectChannel($data['company_id'], $data['username_sales']);
$projectModel->edit(['channel'=>$channel],['id'=>$v['id']]);
}
return 1;
}
}
... ...
... ... @@ -39,7 +39,7 @@ class BaseController extends Controller
$info = Cache::get(Common::MANAGE_TOKEN . $this->token);
if(!empty($this->token) && !empty($info)){
$this->manage = $info;
Cache::put($this->token, $info, 3600 * 6);//更新缓存时间
Cache::put(Common::MANAGE_TOKEN . $this->token, $info, 3600 * 6);//更新缓存时间
$this->uid = $info['id'];
}
}
... ...
... ... @@ -82,18 +82,18 @@ class LoginController extends BaseController
$mobile = $this->param['mobile'];
$manager = Manage::where(['mobile' => $mobile])->first();
if (empty($manager)) {
$this->response('请输入正确的手机号码!', Code::USER_LOGIN_ERROE);
$this->response('请输入正确的手机号码!', Code::SYSTEM_ERROR);
}
$last_sms = SmsLog::getLastLog($mobile, SmsLog::TYPE_MANAGER_LOGIN);
if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60) {
$this->response('请不要重复发送短信!', Code::USER_LOGIN_ERROE);
$this->response('请不要重复发送短信!', Code::SYSTEM_ERROR);
}
$template = config('aliyunsms.login_sms_temp');
$code['code'] = rand(100000,999999);
$ali_sms = new AliSms();
$send = $ali_sms->sendSms(strval($mobile), $template, $code);
if (empty($send->Code) && $send->Code != 'OK') {
$this->response('发送失败, 请稍后重试!', Code::USER_LOGIN_ERROE);
$this->response('发送失败, 请稍后重试!', Code::SYSTEM_ERROR);
}
SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN);
$this->response('success');
... ...
... ... @@ -112,18 +112,18 @@ class LoginController extends BaseController
$mobile = $this->param['mobile'];
$user = User::where(['mobile' => $mobile])->first();
if (empty($user)) {
$this->response('请输入正确的手机号码!', Code::USER_LOGIN_ERROE);
$this->response('请输入正确的手机号码!', Code::SYSTEM_ERROR);
}
$last_sms = SmsLog::getLastLog($mobile, SmsLog::TYPE_LOGIN);
if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60) {
$this->response('请不要重复发送短信!', Code::USER_LOGIN_ERROE);
$this->response('请不要重复发送短信!', Code::SYSTEM_ERROR);
}
$template = config('aliyunsms.login_sms_temp');
$code['code'] = rand(100000,999999);
$ali_sms = new AliSms();
$send = $ali_sms->sendSms(strval($mobile), $template, $code);
if (empty($send->Code) && $send->Code != 'OK') {
$this->response('发送失败, 请稍后重试!', Code::USER_LOGIN_ERROE);
$this->response('发送失败, 请稍后重试!', Code::SYSTEM_ERROR);
}
SmsLog::createLog($mobile, $code['code']);
$this->response('success');
... ...
... ... @@ -42,7 +42,7 @@ class UserLogic extends BaseLogic
if($info !== false){
$this->fail('当前手机号码已注册');
}
if(!isset($this->param['role']) || empty($this->param['role'])){
if(!isset($this->param['role_id']) || empty($this->param['role_id'])){
$this->fail('一个账号只允许一个超级管理员,请先添加角色');
}
$this->param['create_id'] = $this->user['id'];
... ...
... ... @@ -73,7 +73,7 @@ class LoginAuthMiddleware
$menu_id = $projectMenuModel->read(['action'=>$action],['id']);
if($menu_id !== false){
if(strpos($role_info['role_menu'], $menu_id['id']) === false){
return response(['code'=>Code::USER_PERMISSION_ERROE,'message'=>'当前用户没有权限']);
return response(['code'=>Code::USER_LOGIN_ERROE,'message'=>'当前用户没有权限']);
}
}
}
... ...