正在显示
20 个修改的文件
包含
14 行增加
和
300 行删除
| @@ -66,7 +66,7 @@ class ProjectLogic extends BaseLogic | @@ -66,7 +66,7 @@ class ProjectLogic extends BaseLogic | ||
| 66 | 'domain' => $item['deploy_optimize']['domain'] ?? 0, | 66 | 'domain' => $item['deploy_optimize']['domain'] ?? 0, |
| 67 | 'created_at' => date('Y年m月d日', strtotime($item['created_at'])), | 67 | 'created_at' => date('Y年m月d日', strtotime($item['created_at'])), |
| 68 | 'autologin_code' => $this->getAutoLoginCode($item['id']), | 68 | 'autologin_code' => $this->getAutoLoginCode($item['id']), |
| 69 | - 'product_num' => (new Product($item['id']))->getNumByProjectId($item['id']), | 69 | + 'product_num' => (new Product())->getNumByProjectId($item['id']), |
| 70 | 'keyword_num' => $item['deploy_build']['keyword_num'] ?? 0, | 70 | 'keyword_num' => $item['deploy_build']['keyword_num'] ?? 0, |
| 71 | 'article_num' => Blog::getNumByProjectId($item['id']) + News::getNumByProjectId($item['id']), | 71 | 'article_num' => Blog::getNumByProjectId($item['id']) + News::getNumByProjectId($item['id']), |
| 72 | 'task_finish_num' => Task::getNumByProjectId($item['id'], Task::STATUS_DOWN), | 72 | 'task_finish_num' => Task::getNumByProjectId($item['id'], Task::STATUS_DOWN), |
app/Models/ASide/Product/Attr.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Models\Product; | ||
| 4 | - | ||
| 5 | -use App\Helper\Arr; | ||
| 6 | -use App\Models\Base; | ||
| 7 | -use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 8 | - | ||
| 9 | -class Attr extends Base | ||
| 10 | -{ | ||
| 11 | - use SoftDeletes; | ||
| 12 | - | ||
| 13 | - protected $appends = ['attr_num']; | ||
| 14 | - | ||
| 15 | - //设置关联表名 | ||
| 16 | - protected $table = 'gl_product_attr'; | ||
| 17 | - //连接数据库 | ||
| 18 | - protected $connection = 'custom_mysql'; | ||
| 19 | - | ||
| 20 | - public function setAttrsAttribute($value) | ||
| 21 | - { | ||
| 22 | - $this->attributes['attrs'] = Arr::a2s($value); | ||
| 23 | - } | ||
| 24 | - | ||
| 25 | - public function getAttrsAttribute($value) | ||
| 26 | - { | ||
| 27 | - return Arr::s2a($value); | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | - public function getAttrNumAttribute() | ||
| 31 | - { | ||
| 32 | - return count($this->attrs); | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | -} |
app/Models/ASide/Product/Category.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Models\Product; | ||
| 4 | - | ||
| 5 | - | ||
| 6 | -use App\Models\Base; | ||
| 7 | -use App\Models\RouteMap; | ||
| 8 | -use App\Services\Facades\Upload; | ||
| 9 | -use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * @method static get() | ||
| 13 | - * @method static where(string $string, int $int) | ||
| 14 | - */ | ||
| 15 | -class Category extends Base | ||
| 16 | -{ | ||
| 17 | - use SoftDeletes; | ||
| 18 | - | ||
| 19 | - //设置关联表名 | ||
| 20 | - protected $table = 'gl_product_category'; | ||
| 21 | - //连接数据库 | ||
| 22 | - protected $connection = 'custom_mysql'; | ||
| 23 | - | ||
| 24 | - const STATUS_ACTIVE = 1; | ||
| 25 | - | ||
| 26 | - /** | ||
| 27 | - * 子分类 | ||
| 28 | - * @var array | ||
| 29 | - */ | ||
| 30 | - protected $child_ids_arr = []; | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - protected $appends = ['route']; | ||
| 34 | - | ||
| 35 | - public function getRouteAttribute(){ | ||
| 36 | - return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_CATE, $this->id, $this->project_id); | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - | ||
| 40 | - /** | ||
| 41 | - * 获取指定分类的所有子分类IDS(包括自己) | ||
| 42 | - * @param $id | ||
| 43 | - * @return array | ||
| 44 | - * @author zbj | ||
| 45 | - * @date 2023/4/28 | ||
| 46 | - */ | ||
| 47 | - public function getChildIdsArr($id) | ||
| 48 | - { | ||
| 49 | - $this->child_ids_arr = [$id]; | ||
| 50 | - return $this->getChildrenIdArr($id); | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - /** | ||
| 54 | - * 递归获取指定分类的所有子孙 | ||
| 55 | - * @param $id | ||
| 56 | - * @return array | ||
| 57 | - * @author zbj | ||
| 58 | - * @date 2023/4/28 | ||
| 59 | - */ | ||
| 60 | - protected function getChildrenIdArr($id) | ||
| 61 | - { | ||
| 62 | - $list = parent::where("pid", $id)->pluck('pid', 'id'); | ||
| 63 | - if ($list) { | ||
| 64 | - foreach ($list as $id => $pid) { | ||
| 65 | - $this->child_ids_arr[] = $id; | ||
| 66 | - $this->getChildrenIdArr($id); | ||
| 67 | - } | ||
| 68 | - } | ||
| 69 | - return $this->child_ids_arr; | ||
| 70 | - } | ||
| 71 | -} |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Models\Product; | ||
| 4 | - | ||
| 5 | - | ||
| 6 | -use App\Helper\Arr; | ||
| 7 | -use App\Models\Base; | ||
| 8 | - | ||
| 9 | -class CategoryRelated extends Base | ||
| 10 | -{ | ||
| 11 | - | ||
| 12 | - //设置关联表名 | ||
| 13 | - protected $table = 'gl_product_category_related'; | ||
| 14 | - //连接数据库 | ||
| 15 | - protected $connection = 'custom_mysql'; | ||
| 16 | - | ||
| 17 | - const CREATED_AT = null; | ||
| 18 | - const UPDATED_AT = null; | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - /** | ||
| 22 | - * 关联产品分类 | ||
| 23 | - * @param $product_id | ||
| 24 | - * @param $cate_ids | ||
| 25 | - * @author zbj | ||
| 26 | - * @date 2023/4/21 | ||
| 27 | - */ | ||
| 28 | - public static function saveRelated($product_id, $cate_ids) | ||
| 29 | - { | ||
| 30 | - if(!is_array($cate_ids)){ | ||
| 31 | - $cate_ids = array_filter(Arr::splitFilterToArray($cate_ids), 'intval'); | ||
| 32 | - } | ||
| 33 | - //先删除 | ||
| 34 | - self::where('product_id', $product_id)->delete(); | ||
| 35 | - | ||
| 36 | - //批量保存 | ||
| 37 | - $data = []; | ||
| 38 | - foreach ($cate_ids as $cate_id){ | ||
| 39 | - $data[] = [ | ||
| 40 | - 'product_id' => $product_id, | ||
| 41 | - 'cate_id' => $cate_id | ||
| 42 | - ]; | ||
| 43 | - } | ||
| 44 | - self::insert($data); | ||
| 45 | - } | ||
| 46 | -} |
app/Models/ASide/Product/Describe.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Models\Product; | ||
| 4 | - | ||
| 5 | -use App\Models\Base; | ||
| 6 | -use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 7 | - | ||
| 8 | -class Describe extends Base | ||
| 9 | -{ | ||
| 10 | - use SoftDeletes; | ||
| 11 | - | ||
| 12 | - //设置关联表名 | ||
| 13 | - protected $table = 'gl_product_describe'; | ||
| 14 | - //连接数据库 | ||
| 15 | - protected $connection = 'custom_mysql'; | ||
| 16 | - | ||
| 17 | -} |
app/Models/ASide/Product/Keyword.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Models\Product; | ||
| 4 | - | ||
| 5 | -use App\Models\Base; | ||
| 6 | -use App\Models\RouteMap; | ||
| 7 | -use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 8 | - | ||
| 9 | -class Keyword extends Base | ||
| 10 | -{ | ||
| 11 | - use SoftDeletes; | ||
| 12 | - | ||
| 13 | - //设置关联表名 | ||
| 14 | - protected $table = 'gl_product_keyword'; | ||
| 15 | - | ||
| 16 | - protected $appends = ['route']; | ||
| 17 | - | ||
| 18 | - //连接数据库 | ||
| 19 | - protected $connection = 'custom_mysql'; | ||
| 20 | - public function getRouteAttribute(){ | ||
| 21 | - return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $this->id, $this->project_id); | ||
| 22 | - } | ||
| 23 | -} |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Models\Product; | ||
| 4 | - | ||
| 5 | - | ||
| 6 | -use App\Helper\Arr; | ||
| 7 | -use App\Models\Base; | ||
| 8 | - | ||
| 9 | -class KeywordRelated extends Base | ||
| 10 | -{ | ||
| 11 | - | ||
| 12 | - //设置关联表名 | ||
| 13 | - protected $table = 'gl_product_keyword_related'; | ||
| 14 | - | ||
| 15 | - const CREATED_AT = null; | ||
| 16 | - const UPDATED_AT = null; | ||
| 17 | - | ||
| 18 | - //连接数据库 | ||
| 19 | - protected $connection = 'custom_mysql'; | ||
| 20 | - /** | ||
| 21 | - * 关联产品关键词 | ||
| 22 | - * @param $product_id | ||
| 23 | - * @param $keyword_ids | ||
| 24 | - * @author zbj | ||
| 25 | - * @date 2023/5/4 | ||
| 26 | - */ | ||
| 27 | - public static function saveRelated($product_id, $keyword_ids) | ||
| 28 | - { | ||
| 29 | - if(!is_array($keyword_ids)){ | ||
| 30 | - $keyword_ids = array_filter(Arr::splitFilterToArray($keyword_ids), 'intval'); | ||
| 31 | - } | ||
| 32 | - //先删除 | ||
| 33 | - self::where('product_id', $product_id)->delete(); | ||
| 34 | - | ||
| 35 | - //批量保存 | ||
| 36 | - $data = []; | ||
| 37 | - foreach ($keyword_ids as $keyword_id){ | ||
| 38 | - $data[] = [ | ||
| 39 | - 'product_id' => $product_id, | ||
| 40 | - 'keyword_id' => $keyword_id | ||
| 41 | - ]; | ||
| 42 | - } | ||
| 43 | - self::insert($data); | ||
| 44 | - } | ||
| 45 | -} |
app/Models/ASide/Product/Product.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Models\ASide\Product; | ||
| 4 | - | ||
| 5 | -use App\Enums\Common\Code; | ||
| 6 | -use App\Models\Base; | ||
| 7 | -use App\Services\ProjectServer; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * @method static get() | ||
| 11 | - */ | ||
| 12 | -class Product extends Base | ||
| 13 | -{ | ||
| 14 | - //设置关联表名 | ||
| 15 | - protected $table = 'gl_product'; | ||
| 16 | - const STATUS_DRAFT = 0; | ||
| 17 | - const STATUS_ON = 1; | ||
| 18 | - const STATUS_RECYCLE = 2; | ||
| 19 | - | ||
| 20 | - protected $connection; | ||
| 21 | - | ||
| 22 | - public function __construct($project_id) | ||
| 23 | - { | ||
| 24 | - $project = ProjectServer::useProject($project_id); | ||
| 25 | - if(empty($project)){ | ||
| 26 | - return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']); | ||
| 27 | - } | ||
| 28 | - $this->connection = 'custom_mysql'; | ||
| 29 | - } | ||
| 30 | - public static function statusMap(){ | ||
| 31 | - return [ | ||
| 32 | - self::STATUS_DRAFT => '草稿', | ||
| 33 | - self::STATUS_ON => '已发布', | ||
| 34 | - self::STATUS_RECYCLE => '回收站', | ||
| 35 | - ]; | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - /** | ||
| 39 | - * @var 获取产品类型 | ||
| 40 | - */ | ||
| 41 | - public $productType = [ | ||
| 42 | - 1=>'一般产品', | ||
| 43 | - 2=>'推荐产品', | ||
| 44 | - 3=>'热销产品' | ||
| 45 | - ]; | ||
| 46 | - | ||
| 47 | - public static function getNumByProjectId($project_id){ | ||
| 48 | - return self::where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | -} |
| @@ -9,7 +9,7 @@ class Blog extends Base | @@ -9,7 +9,7 @@ class Blog extends Base | ||
| 9 | { | 9 | { |
| 10 | protected $table = 'gl_blog'; | 10 | protected $table = 'gl_blog'; |
| 11 | //连接数据库 | 11 | //连接数据库 |
| 12 | - protected $connection = 'custom_mysql'; | 12 | +// protected $connection = 'custom_mysql'; |
| 13 | public function user(){ | 13 | public function user(){ |
| 14 | return $this->hasMany(User::class,'operator_id','id'); | 14 | return $this->hasMany(User::class,'operator_id','id'); |
| 15 | } | 15 | } |
| @@ -8,7 +8,7 @@ class News extends Base | @@ -8,7 +8,7 @@ class News extends Base | ||
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_news'; | 9 | protected $table = 'gl_news'; |
| 10 | //连接数据库 | 10 | //连接数据库 |
| 11 | - protected $connection = 'custom_mysql'; | 11 | +// protected $connection = 'custom_mysql'; |
| 12 | 12 | ||
| 13 | public static function getNumByProjectId($project_id){ | 13 | public static function getNumByProjectId($project_id){ |
| 14 | return self::where('project_id', $project_id)->where('status', 1)->count(); | 14 | return self::where('project_id', $project_id)->where('status', 1)->count(); |
| @@ -12,5 +12,5 @@ class NewsCategory extends Base | @@ -12,5 +12,5 @@ class NewsCategory extends Base | ||
| 12 | { | 12 | { |
| 13 | protected $table = 'gl_news_category'; | 13 | protected $table = 'gl_news_category'; |
| 14 | //连接数据库 | 14 | //连接数据库 |
| 15 | - protected $connection = 'custom_mysql'; | 15 | +// protected $connection = 'custom_mysql'; |
| 16 | } | 16 | } |
| @@ -15,7 +15,7 @@ class Attr extends Base | @@ -15,7 +15,7 @@ class Attr extends Base | ||
| 15 | //设置关联表名 | 15 | //设置关联表名 |
| 16 | protected $table = 'gl_product_attr'; | 16 | protected $table = 'gl_product_attr'; |
| 17 | //连接数据库 | 17 | //连接数据库 |
| 18 | - protected $connection = 'custom_mysql'; | 18 | +// protected $connection = 'custom_mysql'; |
| 19 | 19 | ||
| 20 | public function setAttrsAttribute($value) | 20 | public function setAttrsAttribute($value) |
| 21 | { | 21 | { |
| @@ -19,7 +19,7 @@ class Category extends Base | @@ -19,7 +19,7 @@ class Category extends Base | ||
| 19 | //设置关联表名 | 19 | //设置关联表名 |
| 20 | protected $table = 'gl_product_category'; | 20 | protected $table = 'gl_product_category'; |
| 21 | //连接数据库 | 21 | //连接数据库 |
| 22 | - protected $connection = 'custom_mysql'; | 22 | +// protected $connection = 'custom_mysql'; |
| 23 | 23 | ||
| 24 | const STATUS_ACTIVE = 1; | 24 | const STATUS_ACTIVE = 1; |
| 25 | 25 |
| @@ -12,7 +12,7 @@ class CategoryRelated extends Base | @@ -12,7 +12,7 @@ class CategoryRelated extends Base | ||
| 12 | //设置关联表名 | 12 | //设置关联表名 |
| 13 | protected $table = 'gl_product_category_related'; | 13 | protected $table = 'gl_product_category_related'; |
| 14 | //连接数据库 | 14 | //连接数据库 |
| 15 | - protected $connection = 'custom_mysql'; | 15 | +// protected $connection = 'custom_mysql'; |
| 16 | 16 | ||
| 17 | const CREATED_AT = null; | 17 | const CREATED_AT = null; |
| 18 | const UPDATED_AT = null; | 18 | const UPDATED_AT = null; |
| @@ -12,6 +12,6 @@ class Describe extends Base | @@ -12,6 +12,6 @@ class Describe extends Base | ||
| 12 | //设置关联表名 | 12 | //设置关联表名 |
| 13 | protected $table = 'gl_product_describe'; | 13 | protected $table = 'gl_product_describe'; |
| 14 | //连接数据库 | 14 | //连接数据库 |
| 15 | - protected $connection = 'custom_mysql'; | 15 | +// protected $connection = 'custom_mysql'; |
| 16 | 16 | ||
| 17 | } | 17 | } |
| @@ -16,7 +16,7 @@ class Keyword extends Base | @@ -16,7 +16,7 @@ class Keyword extends Base | ||
| 16 | protected $appends = ['route']; | 16 | protected $appends = ['route']; |
| 17 | 17 | ||
| 18 | //连接数据库 | 18 | //连接数据库 |
| 19 | - protected $connection = 'custom_mysql'; | 19 | +// protected $connection = 'custom_mysql'; |
| 20 | public function getRouteAttribute(){ | 20 | public function getRouteAttribute(){ |
| 21 | return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $this->id, $this->project_id); | 21 | return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $this->id, $this->project_id); |
| 22 | } | 22 | } |
| @@ -16,7 +16,7 @@ class KeywordRelated extends Base | @@ -16,7 +16,7 @@ class KeywordRelated extends Base | ||
| 16 | const UPDATED_AT = null; | 16 | const UPDATED_AT = null; |
| 17 | 17 | ||
| 18 | //连接数据库 | 18 | //连接数据库 |
| 19 | - protected $connection = 'custom_mysql'; | 19 | +// protected $connection = 'custom_mysql'; |
| 20 | /** | 20 | /** |
| 21 | * 关联产品关键词 | 21 | * 关联产品关键词 |
| 22 | * @param $product_id | 22 | * @param $product_id |
| @@ -18,7 +18,7 @@ class Product extends Base | @@ -18,7 +18,7 @@ class Product extends Base | ||
| 18 | //设置关联表名 | 18 | //设置关联表名 |
| 19 | protected $table = 'gl_product'; | 19 | protected $table = 'gl_product'; |
| 20 | //连接数据库 | 20 | //连接数据库 |
| 21 | - protected $connection = 'custom_mysql'; | 21 | +// protected $connection = 'custom_mysql'; |
| 22 | const STATUS_DRAFT = 0; | 22 | const STATUS_DRAFT = 0; |
| 23 | const STATUS_ON = 1; | 23 | const STATUS_ON = 1; |
| 24 | const STATUS_RECYCLE = 2; | 24 | const STATUS_RECYCLE = 2; |
-
请 注册 或 登录 后发表评论