Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
4 个修改的文件
包含
43 行增加
和
7 行删除
| @@ -8,6 +8,7 @@ use App\Helper\Arr; | @@ -8,6 +8,7 @@ use App\Helper\Arr; | ||
| 8 | use App\Http\Controllers\Bside\BaseController; | 8 | use App\Http\Controllers\Bside\BaseController; |
| 9 | use App\Http\Logic\Bside\Product\ProductLogic; | 9 | use App\Http\Logic\Bside\Product\ProductLogic; |
| 10 | use App\Http\Requests\Bside\Product\ProductRequest; | 10 | use App\Http\Requests\Bside\Product\ProductRequest; |
| 11 | +use App\Models\Product\CategoryRelated; | ||
| 11 | use App\Rules\Ids; | 12 | use App\Rules\Ids; |
| 12 | use Illuminate\Http\Request; | 13 | use Illuminate\Http\Request; |
| 13 | 14 | ||
| @@ -26,11 +27,18 @@ class ProductController extends BaseController | @@ -26,11 +27,18 @@ class ProductController extends BaseController | ||
| 26 | if(!empty($this->param['search'])){ | 27 | if(!empty($this->param['search'])){ |
| 27 | $map[] = ['title', 'like', "%{$this->param['search']}%"]; | 28 | $map[] = ['title', 'like', "%{$this->param['search']}%"]; |
| 28 | } | 29 | } |
| 29 | - if(!empty($this->param['created_at'])){ | 30 | + if(!empty($this->param['created_at'][0]) && !empty($this->param['created_at'][1])){ |
| 30 | $map[] = ['created_at', 'between', $this->param['created_at']]; | 31 | $map[] = ['created_at', 'between', $this->param['created_at']]; |
| 31 | } | 32 | } |
| 33 | + if(!empty($this->param['category_id'])){ | ||
| 34 | + $ids = CategoryRelated::where('cate_id', $this->param['category_id'])->pluck('product_id')->toArray(); | ||
| 35 | + $map[] = ['id', 'in', $ids]; | ||
| 36 | + } | ||
| 37 | + if(!empty($this->param['status'])){ | ||
| 38 | + $map[] = ['status', $this->param['status']]; | ||
| 39 | + } | ||
| 32 | $sort = ['id' => 'desc']; | 40 | $sort = ['id' => 'desc']; |
| 33 | - $data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keywords', 'status', 'created_at', 'updated_at']); | 41 | + $data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keywords', 'status', 'created_uid', 'created_at', 'updated_at']); |
| 34 | return $this->success($data); | 42 | return $this->success($data); |
| 35 | } | 43 | } |
| 36 | 44 | ||
| @@ -42,7 +50,7 @@ class ProductController extends BaseController | @@ -42,7 +50,7 @@ class ProductController extends BaseController | ||
| 42 | ]); | 50 | ]); |
| 43 | $data = $logic->getInfo($this->param['id']); | 51 | $data = $logic->getInfo($this->param['id']); |
| 44 | return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keywords', 'intro', 'content', | 52 | return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keywords', 'intro', 'content', |
| 45 | - 'describe', 'seo_mate', 'related_product_id', 'status'])); | 53 | + 'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text', 'status_text', 'created_uid', 'created_uid_text'])); |
| 46 | } | 54 | } |
| 47 | 55 | ||
| 48 | public function save(ProductRequest $request, ProductLogic $logic) | 56 | public function save(ProductRequest $request, ProductLogic $logic) |
| @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\Product; | @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\Product; | ||
| 4 | 4 | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | +use App\Http\Logic\Bside\User\UserLogic; | ||
| 7 | use App\Models\Product\CategoryRelated; | 8 | use App\Models\Product\CategoryRelated; |
| 8 | use App\Models\Product\Product; | 9 | use App\Models\Product\Product; |
| 9 | use App\Models\RouteMap; | 10 | use App\Models\RouteMap; |
| @@ -24,6 +25,32 @@ class ProductLogic extends BaseLogic | @@ -24,6 +25,32 @@ class ProductLogic extends BaseLogic | ||
| 24 | $this->model = new Product(); | 25 | $this->model = new Product(); |
| 25 | } | 26 | } |
| 26 | 27 | ||
| 28 | + public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20) | ||
| 29 | + { | ||
| 30 | + $data = parent::getList($map, $sort, $columns, $limit); | ||
| 31 | + foreach ($data['list'] as &$v){ | ||
| 32 | + foreach ($v['category_id'] as $category_id){ | ||
| 33 | + $v['category_id_text'][] =(new CategoryLogic())->getCacheInfo($category_id)['title']??''; | ||
| 34 | + } | ||
| 35 | + $v['category_id_text'] = Arr::arrToSet($v['category_id_text'], 'trim'); | ||
| 36 | + $v['status_text'] = Product::statusMap()[$v['status']] ?? ''; | ||
| 37 | + $v['created_uid_text'] = (new UserLogic())->getCacheInfo($v['created_uid'])['name'] ?? ''; | ||
| 38 | + } | ||
| 39 | + return $this->success($data); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public function getInfo($id) | ||
| 43 | + { | ||
| 44 | + $info = parent::getInfo($id); | ||
| 45 | + foreach ($info['category_id'] as $category_id) { | ||
| 46 | + $info['category_id_text'][] = (new CategoryLogic())->getCacheInfo($category_id)['title'] ?? ''; | ||
| 47 | + } | ||
| 48 | + $info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim'); | ||
| 49 | + $info['status_text'] = Product::statusMap()[$info['status']] ?? ''; | ||
| 50 | + $info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? ''; | ||
| 51 | + return $this->success($info); | ||
| 52 | + } | ||
| 53 | + | ||
| 27 | public function save($param){ | 54 | public function save($param){ |
| 28 | //封面取第一个图片 | 55 | //封面取第一个图片 |
| 29 | $param['thumb'] = $param['gallery'][0] ?? ''; | 56 | $param['thumb'] = $param['gallery'][0] ?? ''; |
| @@ -31,6 +58,7 @@ class ProductLogic extends BaseLogic | @@ -31,6 +58,7 @@ class ProductLogic extends BaseLogic | ||
| 31 | try { | 58 | try { |
| 32 | $data = $param; | 59 | $data = $param; |
| 33 | unset($data['route']); | 60 | unset($data['route']); |
| 61 | + $data['created_uid'] = $this->user['id']; | ||
| 34 | $res = parent::save($data); | 62 | $res = parent::save($data); |
| 35 | //关联分类 | 63 | //关联分类 |
| 36 | CategoryRelated::saveRelated($res['id'], $data['category_id']); | 64 | CategoryRelated::saveRelated($res['id'], $data['category_id']); |
| @@ -43,7 +43,7 @@ class ProductRequest extends FormRequest | @@ -43,7 +43,7 @@ class ProductRequest extends FormRequest | ||
| 43 | if (empty($v['url'])) { | 43 | if (empty($v['url'])) { |
| 44 | $fail('图片链接不能为空'); | 44 | $fail('图片链接不能为空'); |
| 45 | } | 45 | } |
| 46 | - if (Str::contains($v['url'], env('APP_URL'))) { | 46 | + if (!Str::contains($v['url'], env('UPLOAD_LOCAL_URL') ?: env('APP_URL'))) { |
| 47 | $fail('图片链接不正确'); | 47 | $fail('图片链接不正确'); |
| 48 | } | 48 | } |
| 49 | } | 49 | } |
| @@ -16,14 +16,14 @@ class Product extends Base | @@ -16,14 +16,14 @@ class Product extends Base | ||
| 16 | 16 | ||
| 17 | const STATUS_DRAFT = 0; | 17 | const STATUS_DRAFT = 0; |
| 18 | const STATUS_ON = 1; | 18 | const STATUS_ON = 1; |
| 19 | - const STATUS_OFF = 2; | 19 | + const STATUS_RECYCLE = 2; |
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | public static function statusMap(){ | 22 | public static function statusMap(){ |
| 23 | return [ | 23 | return [ |
| 24 | self::STATUS_DRAFT => '草稿', | 24 | self::STATUS_DRAFT => '草稿', |
| 25 | - self::STATUS_ON => '已上架', | ||
| 26 | - self::STATUS_OFF => '未上架', | 25 | + self::STATUS_ON => '已发布', |
| 26 | + self::STATUS_RECYCLE => '回收站', | ||
| 27 | ]; | 27 | ]; |
| 28 | } | 28 | } |
| 29 | 29 |
-
请 注册 或 登录 后发表评论