Browse Source

Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix

master
Lemon 5 years ago
parent
commit
6968baeadf
  1. 2
      Envoy.blade.php
  2. 28
      app/Constants/v3/OssThumbnail.php
  3. 3
      app/Model/v3/Category.php
  4. 10
      app/Model/v3/Goods.php
  5. 8
      app/Model/v3/GoodsActivity.php
  6. 4
      app/Service/v3/Implementations/ActivityService.php
  7. 4
      app/Service/v3/Implementations/AttachmentService.php
  8. 2
      app/Service/v3/Implementations/BannerService.php
  9. 12
      app/Service/v3/Implementations/CategoryService.php
  10. 4
      app/Service/v3/Implementations/SearchService.php
  11. 2
      app/Service/v3/Implementations/UserCenterBlockService.php

2
Envoy.blade.php

@ -10,7 +10,7 @@
@task('git_dev')
cd /lanzu_api
git pull origin develop
git pull origin phoenix
@if($composer == true)
composer update --lock
@endif

28
app/Constants/v3/OssThumbnail.php

@ -10,8 +10,34 @@ use Hyperf\Constants\Annotation\Constants;
*/
class OssThumbnail extends AbstractConstants
{
/**
* @Message("thumbnail_q30")
*/
const THUMBNAIL_Q30 = '!thumbnail_q30';
/**
* @Message("thumbnail_q50")
*/
const THUMBNAIL_Q50 = '!thumbnail_q50';
/**
* @Message("thumbnail_q80")
*/
const THUMBNAIL_Q80 = '!thumbnail_q80';
/**
* @Message("thumbnail_100_q50")
*/
const THUMBNAIL_100_Q50 = '!thumbnail_100_q50';
const THUMBNAIL_100_Q90 = '!thumbnail_100_q50';
/**
* @Message("thumbnail_300_q80")
*/
const THUMBNAIL_300_Q80 = '!thumbnail_300_q80';
/**
* @Message("thumbnail_600")
*/
const THUMBNAIL_600_Q90 = '!thumbnail_600';
}

3
app/Model/v3/Category.php

@ -2,6 +2,7 @@
namespace App\Model\v3;
use App\Constants\v3\OssThumbnail;
use App\Model\Model;
use App\Service\v3\Interfaces\AttachmentServiceInterface;
use Hyperf\Database\Model\Builder;
@ -34,7 +35,7 @@ class Category extends Model
public function getCoverUrlAttribute()
{
return $this->attachmentService->switchImgToAliOss($this->attributes['cover_img']);
return $this->attachmentService->switchImgToAliOss($this->attributes['cover_img'], OssThumbnail::THUMBNAIL_100_Q90);
}
public function goodsTypes()

10
app/Model/v3/Goods.php

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace App\Model\v3;
use App\Constants\v3\OssThumbnail;
use App\Constants\v3\SsdbKeys;
use App\Model\Model;
use App\Service\v3\Interfaces\AttachmentServiceInterface;
@ -89,7 +90,7 @@ class Goods extends Model
public function getCoverImgAttribute($value)
{
return $this->attachmentService->switchImgToAliOss($value);
return $this->attachmentService->switchImgToAliOss($value, OssThumbnail::THUMBNAIL_600_Q90);
}
public function getMonthSalesAttribute()
@ -117,10 +118,9 @@ class Goods extends Model
public function getDetailsImgsUrlAttribute()
{
$details_imgs = $this->details_imgs;
$img_host = config('alioss.img_host').'/';
return collect($details_imgs)->map(function($item) use ($img_host){
return $img_host . $item;
return collect($details_imgs)->map(function($item) {
return $this->attachmentService->switchImgToAliOss($item);
});
}

8
app/Model/v3/GoodsActivity.php

@ -3,6 +3,7 @@
namespace App\Model\v3;
use App\Constants\v3\Goods as GoodsConstants;
use App\Constants\v3\OssThumbnail;
use App\Constants\v3\SsdbKeys;
use App\Model\Model;
use App\Service\v3\Interfaces\AttachmentServiceInterface;
@ -89,7 +90,7 @@ class GoodsActivity extends Model
public function getCoverImgAttribute($value)
{
return $this->attachmentService->switchImgToAliOss($value);
return $this->attachmentService->switchImgToAliOss($value, OssThumbnail::THUMBNAIL_600_Q90);
}
public function store()
@ -105,10 +106,9 @@ class GoodsActivity extends Model
public function getDetailsImgsUrlAttribute()
{
$details_imgs = $this->details_imgs;
$img_host = config('alioss.img_host').'/';
return collect($details_imgs)->map(function($item) use ($img_host){
return $img_host . $item;
return collect($details_imgs)->map(function($item) {
return $this->attachmentService->switchImgToAliOss($item);
});
}
}

4
app/Service/v3/Implementations/ActivityService.php

@ -34,6 +34,8 @@ class ActivityService implements ActivityServiceInterface
->orWhereJsonLength("market_ids", '=', 0);
});
return $builder->get()->toArray();
return $builder->orderBy('sort', 'DESC')
->orderBy('expire_time', 'ASC')
->get()->toArray();
}
}

4
app/Service/v3/Implementations/AttachmentService.php

@ -72,7 +72,7 @@ class AttachmentService implements AttachmentServiceInterface
return $baseDir.$path;
}
public function switchImgToAliOss($path, $bucket = 'thumbnail_q50')
public function switchImgToAliOss($path, $bucket = '')
{
if (strpos($path, 'http') === false || strpos($path, 'https') === false) {
$path = config('alioss.img_host') . '/' . $path;
@ -82,6 +82,6 @@ class AttachmentService implements AttachmentServiceInterface
unset($temp[0]);
$path = config('alioss.img_host') . '/' . implode('/', $temp);
}
return $path . '!' . $bucket;
return $path . $bucket;
}
}

2
app/Service/v3/Implementations/BannerService.php

@ -16,6 +16,6 @@ class BannerService implements BannerServiceInterface
->orWhereJsonLength('market_ids', '=', 0);
});
return $builder->get()->toArray();
return $builder->orderBy('sort', 'DESC')->get()->toArray();
}
}

12
app/Service/v3/Implementations/CategoryService.php

@ -6,15 +6,21 @@ use App\Constants\v3\OssThumbnail;
use App\Constants\v3\SsdbKeys;
use App\Model\v3\Category;
use App\Model\v3\Goods;
use App\Model\v3\GoodsType;
use App\Model\v3\StoreType;
use App\Service\v3\Interfaces\AttachmentServiceInterface;
use App\Service\v3\Interfaces\CategoryServiceInterface;
use App\TaskWorker\SSDBTask;
use Hyperf\Utils\ApplicationContext;
use Hyperf\Di\Annotation\Inject;
class CategoryService implements CategoryServiceInterface
{
/**
* @Inject
* @var AttachmentServiceInterface
*/
protected $attachmentService;
public function do()
{
// TODO: Implement do() method.
@ -85,7 +91,7 @@ class CategoryService implements CategoryServiceInterface
if(strripos($iconUrl,"http") === false){
$iconUrl = config('alioss.img_host').'/'.$value['icon'];
}
$iconUrl = $iconUrl . OssThumbnail::THUMBNAIL_100_Q50;
$iconUrl = $this->attachmentService->switchImgToAliOss($iconUrl, OssThumbnail::THUMBNAIL_100_Q90);
$returnData[] = ['id' => $key, 'icon' => $iconUrl , 'name' => $value['name']];
}

4
app/Service/v3/Implementations/SearchService.php

@ -18,9 +18,7 @@ class SearchService implements SearchServiceInterface
{
$builder = Goods::query()
->with(['store' => function($query) {
return $query->select(['id', 'logo', 'name']);
}])
->with(['store'])
->where(['market_id' => $params['market_id']])
->where(function ($query) {
$query->where('inventory', '>', 0)->orWhere('is_infinite', '=', 1);

2
app/Service/v3/Implementations/UserCenterBlockService.php

@ -45,7 +45,7 @@ class UserCenterBlockService implements UserCenterBlockServiceInterface
$blocks[] = [
'type' => 'store_user',
'title' => '商相关',
'title' => '商相关',
'items' => [
['name' => '商家入口', 'icon' => $img_host . 'user_icons/shop_enter.png', 'type' => 'page', 'path' => '/pages/shopLogin/shopLogin','command'=>'store_login']
]

Loading…
Cancel
Save