Browse Source
Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix
Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix
# Conflicts: # app/Controller/v3/HomeController.php # config/autoload/dependencies.phpmaster
15 changed files with 313 additions and 131 deletions
-
17app/Constants/v3/Banner.php
-
6app/Constants/v3/SsdbKeys.php
-
10app/Constants/v3/Tabs.php
-
25app/Controller/v3/GoodsRecommendController.php
-
151app/Controller/v3/HomeController.php
-
21app/Model/v3/Banner.php
-
49app/Model/v3/GoodsActivity.php
-
110app/Service/v3/Implementations/ActivityService.php
-
14app/Service/v3/Implementations/BannerService.php
-
18app/Service/v3/Implementations/CategoryService.php
-
11app/Service/v3/Interfaces/ActivityServiceInterface.php
-
8app/Service/v3/Interfaces/BannerServiceInterface.php
-
1app/Service/v3/Interfaces/CategoryServiceInterface.php
-
1config/autoload/dependencies.php
-
2config/routes.php
@ -0,0 +1,17 @@ |
|||
<?php |
|||
|
|||
namespace App\Constants\v3; |
|||
|
|||
use Hyperf\Constants\AbstractConstants; |
|||
use Hyperf\Constants\Annotation\Constants; |
|||
|
|||
/** |
|||
* @Constants |
|||
*/ |
|||
class Banner extends AbstractConstants |
|||
{ |
|||
/** |
|||
* @Message("首页Banner") |
|||
*/ |
|||
const TYPE_APPLET_INDEX = 1; |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<?php |
|||
|
|||
namespace App\Model\v3; |
|||
|
|||
use App\Model\Model; |
|||
use Hyperf\Database\Model\Builder; |
|||
use Hyperf\Database\Model\SoftDeletes; |
|||
|
|||
class Banner extends Model |
|||
{ |
|||
use SoftDeletes; |
|||
protected $table = 'lanzu_banners'; |
|||
|
|||
protected function boot(): void |
|||
{ |
|||
parent::boot(); |
|||
self::addGlobalScope('normal', function (Builder $builder) { |
|||
return $builder->where(['status' => 1]); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
<?php |
|||
|
|||
namespace App\Model\v3; |
|||
|
|||
use App\Constants\v3\Goods as GoodsConstants; |
|||
use App\Constants\v3\SsdbKeys; |
|||
use App\Model\Model; |
|||
use Hyperf\Database\Model\Builder; |
|||
use Hyperf\Utils\ApplicationContext; |
|||
|
|||
class GoodsActivity extends Model |
|||
{ |
|||
protected $table = 'lanzu_goods_activity'; |
|||
|
|||
protected $casts = [ |
|||
'details_imgs' => 'array', |
|||
'spec' => 'array', |
|||
'tags' => 'array', |
|||
]; |
|||
|
|||
protected $appends = [ |
|||
'month_sales', |
|||
'cart_num', |
|||
]; |
|||
|
|||
protected function boot(): void |
|||
{ |
|||
parent::boot(); |
|||
self::addGlobalScope('normal', function (Builder $builder) { |
|||
$builder->where(['on_sale' => GoodsConstants::ON_SALE_YES]); |
|||
}); |
|||
} |
|||
|
|||
public function getMonthSalesAttribute() |
|||
{ |
|||
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); |
|||
return (integer)$ssdb->exec('get', SsdbKeys::GOODS_MONTH_SALES.date('YM').'_'.$this->id); |
|||
} |
|||
|
|||
public function getCartNumAttribute() |
|||
{ |
|||
return (integer)$this->shopCartService->check($this->id); |
|||
} |
|||
|
|||
public function store() |
|||
{ |
|||
return $this->belongsTo(Store::class, 'store_id', 'goods_id'); |
|||
} |
|||
} |
|||
@ -0,0 +1,110 @@ |
|||
<?php |
|||
|
|||
namespace App\Service\v3\Implementations; |
|||
|
|||
use App\Constants\v3\ActivityType; |
|||
use App\Model\v3\GoodsActivity; |
|||
use App\Service\v3\Interfaces\ActivityServiceInterface; |
|||
|
|||
class ActivityService implements ActivityServiceInterface |
|||
{ |
|||
|
|||
public function do() |
|||
{ |
|||
// TODO: Implement do() method.
|
|||
} |
|||
|
|||
public function check() |
|||
{ |
|||
// TODO: Implement check() method.
|
|||
} |
|||
|
|||
public function undo() |
|||
{ |
|||
// TODO: Implement undo() method.
|
|||
} |
|||
|
|||
public function allForAppletIndex($type, $marketId) |
|||
{ |
|||
|
|||
return GoodsActivity::query() |
|||
->where(['type' => $type, 'market_id' => $marketId]) |
|||
->addSelect('sales as total_sales') |
|||
->get()->toArray(); |
|||
|
|||
return [ |
|||
'type' => ActivityType::FLASH_SALE, |
|||
'goods' => [ |
|||
[ |
|||
'id' => 1, |
|||
'store_id' => 111, |
|||
'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', |
|||
'name' => '【优质】大白菜', |
|||
'spec' => [ |
|||
['key' => '净含量', 'value' => '500g'] |
|||
], |
|||
'original_price' => 50.5, |
|||
'price' => 25.25, |
|||
'inventory' => 0, |
|||
'month_sales' => 20, |
|||
'total_sales' => 20, |
|||
'cart_num' => 0, |
|||
'is_effective' => 1, |
|||
'noneffective_note' => '已抢光', |
|||
'total_seconds' => $seconds, |
|||
],[ |
|||
'id' => 1, |
|||
'store_id' => 111, |
|||
'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', |
|||
'name' => '【优质】大白菜', |
|||
'spec' => [ |
|||
['key' => '净含量', 'value' => '500g'] |
|||
], |
|||
'original_price' => 50.5, |
|||
'price' => 25.25, |
|||
'inventory' => 0, |
|||
'month_sales' => 20, |
|||
'total_sales' => 20, |
|||
'cart_num' => 0, |
|||
'is_effective' => 1, |
|||
'noneffective_note' => '已抢光', |
|||
'total_seconds' => $seconds, |
|||
],[ |
|||
'id' => 1, |
|||
'store_id' => 111, |
|||
'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', |
|||
'name' => '【优质】大白菜', |
|||
'spec' => [ |
|||
['key' => '净含量', 'value' => '500g'] |
|||
], |
|||
'original_price' => 50.5, |
|||
'price' => 25.25, |
|||
'inventory' => 0, |
|||
'month_sales' => 20, |
|||
'total_sales' => 20, |
|||
'cart_num' => 0, |
|||
'is_effective' => 1, |
|||
'noneffective_note' => '已抢光', |
|||
'total_seconds' => $seconds, |
|||
],[ |
|||
'id' => 1, |
|||
'store_id' => 111, |
|||
'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', |
|||
'name' => '【优质】大白菜', |
|||
'spec' => [ |
|||
['key' => '净含量', 'value' => '500g'] |
|||
], |
|||
'original_price' => 50.5, |
|||
'price' => 25.25, |
|||
'inventory' => 0, |
|||
'month_sales' => 20, |
|||
'total_sales' => 20, |
|||
'cart_num' => 0, |
|||
'is_effective' => 1, |
|||
'noneffective_note' => '已抢光', |
|||
'total_seconds' => $seconds, |
|||
], |
|||
] |
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
<?php |
|||
|
|||
namespace App\Service\v3\Implementations; |
|||
|
|||
use App\Model\v3\Banner; |
|||
use App\Service\v3\Interfaces\BannerServiceInterface; |
|||
|
|||
class BannerService implements BannerServiceInterface |
|||
{ |
|||
public function all($type, $marketId) |
|||
{ |
|||
return Banner::query()->where(['type' => $type, 'market_id' => $marketId])->get()->toArray(); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
<?php |
|||
|
|||
namespace App\Service\v3\Interfaces; |
|||
|
|||
interface ActivityServiceInterface |
|||
{ |
|||
public function do(); |
|||
public function check(); |
|||
public function undo(); |
|||
public function allForAppletIndex($type, $marketId); |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
<?php |
|||
|
|||
namespace App\Service\v3\Interfaces; |
|||
|
|||
interface BannerServiceInterface |
|||
{ |
|||
public function all($type, $marketId); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue