作者 刘锟

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

... ... @@ -55,7 +55,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>627]);
$list = $projectModel->list(['is_upgrade'=>0]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ... @@ -115,11 +115,11 @@ class UpdateRoute extends Command
foreach ($lists as $v){
if(!empty($v['route'])){
$tag = "-tag";
if (!(substr($v['route'], -strlen($tag)) === $tag)) {
if ((substr($v['route'], -strlen($tag)) === $tag)) {
echo date('Y-m-d H:i:s') . '拼接 :'.$v['id'] . PHP_EOL;
// $route = Translate::tran($v['route'], 'en').$tag;
// 如果不是以 '-tag' 结尾,则拼接上 '-tag'
$route = $v['route'].$tag;
$route = trim($v['route'],'-tag');
$route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
// }else{
... ... @@ -127,10 +127,10 @@ class UpdateRoute extends Command
// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
}
}else{
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
// }else{
// echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
// $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
}
echo date('Y-m-d H:i:s') . 'end :' . PHP_EOL;
}
... ...
... ... @@ -477,7 +477,9 @@ if (!function_exists('getImageUrl')) {
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
}else{
$url = url($path);
$s3 = config('filesystems.disks.s3');
$cdn = $s3['cdn'];
$url = $cdn.$path;
}
}
return $url;
... ... @@ -513,7 +515,9 @@ if (!function_exists('getFileUrl')) {
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
}else{
$url = url($path);
$s3 = config('filesystems.disks.s3');
$cdn = $s3['cdn'];
$url = $cdn.$path;
}
}
return $url;
... ...
... ... @@ -102,8 +102,9 @@ class LoginController extends BaseController
* @method :post
* @time :2023/8/19 9:13
*/
public function sendLoginSms($type = SmsLog::TYPE_LOGIN)
public function sendLoginSms()
{
$type = $this->request->post('type',SmsLog::TYPE_LOGIN);
$this->request->validate([
'mobile'=>['required', 'regex:/^1[3-9]\d{9}$/'],
],[
... ...
... ... @@ -78,25 +78,25 @@ class ProductController extends BaseController
public function getHandleFileImage($v){
//ToDo::处理图片及文件
if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
$v['thumb']['url'] = getImageUrl($v['thumb']['url'],$this->user['project_location'],$this->user['storage_type']);
$v['thumb']['url'] = getImageUrl($v['thumb']['url'],$this->user['project_location'] ?? 0,$this->user['storage_type'] ?? 0);
}
if(!empty($v['gallery'])){
foreach ($v['gallery'] as $gallery_k => $gallery_v){
$gallery_v['url'] = getImageUrl($gallery_v['url'],$this->user['project_location'],$this->user['storage_type']);
$gallery_v['url'] = getImageUrl($gallery_v['url'],$this->user['project_location'] ?? 0,$this->user['storage_type'] ?? 0);
$v['gallery'][$gallery_k] = $gallery_v;
}
}
if(!empty($v['icon'])){
foreach ($v['icon'] as $icon_k => $icon_v){
$icon_v = getImageUrl($icon_v,$this->user['project_location'],$this->user['storage_type']);
$icon_v = getImageUrl($icon_v,$this->user['project_location'] ?? 0,$this->user['storage_type'] ?? 0);
$v['icon'][$icon_k] = $icon_v;
}
}
if(!empty($v['video']) && !empty($v['video']['url'])){
$v['video']['url'] = getImageUrl($v['video']['url'],$this->user['project_location'],$this->user['storage_type']);
$v['video']['url'] = getImageUrl($v['video']['url'],$this->user['project_location'] ?? 0,$this->user['storage_type'] ?? 0);
}
if(!empty($v['files']) && !empty($v['files']['url'])){
$v['files']['url'] = getImageUrl($v['files']['url'],$this->user['project_location'],$this->user['storage_type']);
$v['files']['url'] = getImageUrl($v['files']['url'],$this->user['project_location'] ?? 0,$this->user['storage_type'] ?? 0);
}
return $this->success($v);
}
... ...
... ... @@ -16,6 +16,7 @@ use App\Models\Scoring\RatingQuestion;
use App\Models\Scoring\ScoringSystem;
use App\Models\Sms\SmsLog;
use App\Models\User\User;
use Illuminate\Support\Facades\Cache;
use Mrgoon\AliSms\AliSms;
/**
... ... @@ -27,22 +28,6 @@ use Mrgoon\AliSms\AliSms;
*/
class RatingController extends BaseController
{
/**
* @remark :获取问卷调查记录(阶段记录)
* @name :getHistory
* @author :lyh
* @method :post
* @time :2024/1/20 15:03
*/
public function getHistory(ScoringSystem $scoringSystem){
$this->request->validate([
'type' => 'required',
],[
'type.required' => '问题类型不能为空',
]);
$info = $scoringSystem->read($this->map);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :问卷调查详情
... ... @@ -72,9 +57,11 @@ class RatingController extends BaseController
$this->request->validate([
'data' => 'required',
'mobile' => 'required',
'type'=> 'required'
],[
'data.required' => '请填写完整',
'mobile.required' => '手机号码不能为空',
'type.required' => '阶段不能为空',
]);
$ratingLogic->ratingSave();
$this->response('success');
... ...
... ... @@ -111,7 +111,7 @@ class FileController
//查看文件是否存在
$fileModel = new File();
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$param['project_id'] = $this->cache['project_id'];
}
... ... @@ -223,7 +223,7 @@ class FileController
$fileModel = new File();
$name = $file->getClientOriginalName();
$hash = hash_file('md5', $file->getPathname());
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$param['project_id'] = $this->cache['project_id'];
}
... ...
... ... @@ -185,7 +185,7 @@ class ImageController extends Controller
//查看文件是否存在
$imageModel = new ImageModel();
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$param['project_id'] = $this->cache['project_id'];
}
... ... @@ -268,7 +268,7 @@ class ImageController extends Controller
$hash = hash_file('md5', $file->getPathname());
$name = $file->getClientOriginalName();
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$param['project_id'] = $this->cache['project_id'];
}
... ... @@ -277,7 +277,6 @@ class ImageController extends Controller
$data[] = $this->responseData($image_hash['path']);
continue;
}
$url = $this->config['root'].$this->path;
$image_type = $file->getClientOriginalExtension();
$fileName = uniqid().rand(10000,99999).'.'.$image_type;
//同步数据到cos
... ... @@ -287,7 +286,7 @@ class ImageController extends Controller
}else{
//TODO::上传亚马逊
$amazonS3Service = new AmazonS3Service();
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
$amazonS3Service->uploadFiles($file,$this->path,$fileName);
}
//批量存储
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
... ...
... ... @@ -66,7 +66,7 @@ class KeywordLogic extends BaseLogic
}else{
$info = $this->model->read(['title'=>$this->param['title']]);
if($info !== false){
$this->fail('当前title已存在');
return $this->success(['id'=>$info['id']]);
}
$this->param = $this->addHandleParam($this->param);
$id = $this->model->insertGetId($this->param);
... ...
... ... @@ -54,7 +54,29 @@ class RatingLogic extends BaseLogic
'data'=>json_encode($this->param['data']),
'mobile'=>$this->param['mobile'],
'project_id'=>$this->user['project_id'],
'type'=>$this->param['type']
];
return $this->scoringModel->add($param);
$this->scoringModel->add($param);
return $this->httpSore($this->param['data'],$this->project['post_id'],$this->param['type']);
}
/**
* @remark :同步数据
* @name :httpSore
* @author :lyh
* @method :post
* @time :2024/1/24 15:04
*/
public function httpSore($data,$postId,$fType){
$fType = (int)($fType + 1);
$token = md5('qqs'.$postId.$fType.date("Y-m-d"));
//$ftype 2,3,4
$str = '';
foreach ($data as $k => $v){
$str .= 'name_'.(int)($k+1).'='.($v['level'] ?? 5).'&';
}
$str = trim($str,'&');
$url = "http://www.quanqiusou.cn/extend_api/api/service_score.php?postid=$postId&token=$token&ftype=$fType&$str";
return http_get($url,['charset=utf-8']);
}
}
... ...
... ... @@ -8,6 +8,7 @@ use App\Exceptions\BsideGlobalException;
use App\Helper\Common;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Models\Scoring\ScoringSystem;
use App\Models\Sms\SmsLog;
use App\Models\User\ProjectRole as ProjectRoleModel;
use App\Models\User\User;
... ... @@ -170,6 +171,7 @@ class UserLoginLogic
$info['upload_config'] = $project['upload_config'];
$info['main_lang_id'] = $project['main_lang_id'];
$info['image_max'] = $project['image_max'];
$info['uptime_type'] = $this->getHistory($project);
$info['uptime'] = $project['uptime'];
$info['storage_type'] = $project['storage_type'];
$info['project_location'] = $project['project_location'];
... ... @@ -180,10 +182,57 @@ class UserLoginLogic
$info['is_visualization'] = json_decode($project['is_visualization']);
}
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,$minutes = null);
Cache::put('user-'.$info['project_id'],$project,12 * 3600);
return $this->success($info);
}
/**
* @remark :获取问卷调查记录(阶段记录)
* @name :getHistory
* @author :lyh
* @method :post
* @time :2024/1/20 15:03
*/
public function getHistory($projectInfo){
if(!$projectInfo){
return $this->success(0);
}
//建站中直接返回
if($projectInfo['type'] == 1){
return $this->success(0);
}
//上线项目判断当前属于第几阶段
if(empty($projectInfo['uptime'])){
return $this->success(0);
}
//获取上线时间30天后
$after30Days = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +30 days'));
$afterThreeMonths = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +3 months'));
$afterSixMonths = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +6 months'));
$afterOneYear = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +1 year'));
//获取当前时间
$date = date('Y-m-d H:i:s');
$scoringSystem = new ScoringSystem();
if($date <= $after30Days){
$info = $scoringSystem->read(['type'=>1]);//第一阶段是否有值
if($info === false){
return $this->success(1);
}
}
if($date >= $afterThreeMonths && $date <= $afterSixMonths){
$info = $scoringSystem->read(['type'=>2]);//第一阶段是否有值
if($info === false){
return $this->success(2);
}
}
if($date >= $afterOneYear){
$info = $scoringSystem->read(['type'=>3]);//第一阶段是否有值
if($info === false){
return $this->success(3);
}
}
return $this->success(0);
}
/**
* @remark :组装返回数据
... ... @@ -212,6 +261,7 @@ class UserLoginLogic
$info['upload_config'] = $project['upload_config'];
$info['main_lang_id'] = $project['main_lang_id'];
$info['image_max'] = $project['image_max'];
$info['uptime_type'] = $this->getHistory($project);
$info['uptime'] = $project['uptime'];
$info['is_update_language'] = $project['is_update_language'];
$info['configuration'] = $project['deploy_build']['configuration'];
... ... @@ -222,7 +272,7 @@ class UserLoginLogic
$info['is_visualization'] = json_decode($project['is_visualization']);
}
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,$minutes = null);
Cache::put('user-'.$info['project_id'],$project,12 * 3600);
return $this->success($info);
}
... ...
... ... @@ -61,9 +61,6 @@ class RouteMap extends Base
$info = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first();
$suffix = '';
if(empty($info)){
if($source == self::SOURCE_PRODUCT_KEYWORD){
$suffix = '-tag';
}
if($source == self::SOURCE_PRODUCT){
$suffix = '-product';
}
... ...
... ... @@ -17,8 +17,8 @@ class AmazonS3Service
protected $s3;
protected $accessKeyId = 'AKIAU6YKND7SAWIKBXCZ';//key
protected $secretAccessKey = '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';//密匙
protected $region = 's3://arn:aws:s3:us-west-2:340934860772:accesspoint/globalso-v6';//地址
protected $bucket = 'arn:aws:s3:::globalso-v6';//桶子
protected $region = 'us-west-2';//地址
protected $bucket = 'arn:aws:s3:us-west-2:340934860772:accesspoint/globalso-v6';//桶子
public function __construct()
{
... ... @@ -40,19 +40,21 @@ class AmazonS3Service
* @method :post
* @time :2024/1/23 9:20
*/
public function uploadFiles(&$files, $s3Key,$filename ,$binary = false)
public function uploadFiles(&$files, $s3Key,$filename)
{
$key = $s3Key.'/'.$filename;
$Body = $binary ? $files : fopen($files->getRealPath(), 'r');
$key = ltrim($s3Key.'/'.$filename,'/');
$body = $files->getRealPath();
try {
$result = $this->s3->putObject([
'Bucket' => $this->bucket,
'Key' => $key,
'SourceFile' => $Body,
'ACL' => 'public-read', // 设置图片为公共可读,可根据需求修改
'SourceFile' => $body,
// 'ACL' => 'public-read', // 设置图片为公共可读,可根据需求修改
]);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('ok:'.$result['ObjectURL'], true) . PHP_EOL, FILE_APPEND);
return $result['ObjectURL'];
} catch (S3Exception $e) {
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('失败'.$e->getMessage(), true) . PHP_EOL, FILE_APPEND);
return false;
}
}
... ...
... ... @@ -51,6 +51,7 @@ return [
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'cdn'=>'https://globalso-v6.s3.us-west-2.amazonaws.com'
],
'upload' => [
... ...
... ... @@ -484,7 +484,6 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('rating')->group(function () {
Route::any('/read', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'getProjectRead'])->name('rating_getProjectRead');
Route::any('/save', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'save'])->name('rating_save');
Route::any('/getHistory', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'getHistory'])->name('rating_getHistory');
Route::any('/code', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'verificationCode'])->name('rating_code');
});
});
... ...