You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.4 KiB
64 lines
2.4 KiB
<?php
|
|
|
|
namespace App\Service\v3\Implementations;
|
|
|
|
use App\Constants\v3\Goods as GoodsConstants;
|
|
use App\Model\v3\GoodsActivity;
|
|
use App\Model\v3\Store;
|
|
use App\Service\v3\Interfaces\ActivityServiceInterface;
|
|
use Hyperf\Utils\ApplicationContext;
|
|
|
|
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)
|
|
{
|
|
|
|
$storeTable = ApplicationContext::getContainer()->get(Store::class)->getTable();
|
|
$goodsTable = ApplicationContext::getContainer()->get(GoodsActivity::class)->getTable();
|
|
|
|
$builder = GoodsActivity::query()
|
|
->join($storeTable, ''.$storeTable.'.id', '=', ''.$goodsTable.'.store_id')
|
|
->with(['store'])
|
|
->where([''.$goodsTable.'.type' => $type])
|
|
->where(function ($query) use ($marketId, $goodsTable) {
|
|
$query->whereJsonContains(''.$goodsTable.'.market_ids', [(string)$marketId])
|
|
->orWhereJsonLength(''.$goodsTable.'.market_ids', '=', 0);
|
|
})
|
|
->where([''.$goodsTable.'.on_sale' => GoodsConstants::ON_SALE_YES])
|
|
// ->where(function ($query) use ($goodsTable) {
|
|
// $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1);
|
|
// })
|
|
->whereRaw(''.$goodsTable.'.deleted_at IS NULL')
|
|
->where([''.$storeTable.'.market_id' => $marketId])
|
|
->where([''.$storeTable.'.is_open' => \App\Constants\v3\Store::IS_OPEN_YES])
|
|
->where([''.$storeTable.'.is_rest' => \App\Constants\v3\Store::IS_REST_NO])
|
|
->where('time1', '<=', date('H:i'))
|
|
->where(function ($query) {
|
|
$query->where('time2', '>=', date('H:i'))
|
|
->orWhere('time4', '>=', date('H:i'));
|
|
})
|
|
->where(''.$goodsTable.'.expire_time', '>', time());
|
|
|
|
return $builder->select(''.$goodsTable.'.*')->addSelect(''.$goodsTable.'.sales as total_sales')
|
|
->orderBy(''.$goodsTable.'.sort', 'DESC')
|
|
->orderBy(''.$goodsTable.'.expire_time', 'ASC')
|
|
->orderBy(''.$goodsTable.'.created_at', 'DESC')
|
|
->get()->toArray();
|
|
}
|
|
}
|