|
|
|
@ -15,10 +15,14 @@ namespace app\api\service; |
|
|
|
|
use app\api\model\Goods as GoodsModel; |
|
|
|
|
use app\api\model\Setting as SettingModel; |
|
|
|
|
use app\api\model\GoodsSku as GoodsSkuModel; |
|
|
|
|
use app\api\model\Category as CategoryModel; |
|
|
|
|
use app\common\model\store\Shop as ShopModel; |
|
|
|
|
use app\api\service\sharp\Active as ActiveService; |
|
|
|
|
use app\common\enum\Setting as SettingEnum; |
|
|
|
|
use app\common\service\Goods as GoodsService; |
|
|
|
|
use app\api\model\sharp\Active as SharpActiveModel; |
|
|
|
|
use app\api\model\sharp\ActiveTime as ActiveTimeModel; |
|
|
|
|
use app\api\controller\sharp\Goods as miaosha; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 商品服务类 |
|
|
|
@ -53,6 +57,7 @@ class Goods extends GoodsService |
|
|
|
|
{ |
|
|
|
|
// 获取商品推荐数据 |
|
|
|
|
$setting = $this->getRecommendedSetting(); |
|
|
|
|
|
|
|
|
|
// 获取商品数据 |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if ($setting['params']['source'] === 'choice') { |
|
|
|
@ -74,65 +79,160 @@ class Goods extends GoodsService |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//大牌正品列表 |
|
|
|
|
public function brandList(): array |
|
|
|
|
public function brandList() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
$page = (int)$_GET['page']; |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
$list = $model->where([ |
|
|
|
|
'is_delete' => 0, |
|
|
|
|
|
|
|
|
|
$goodsList = $model->getList([ |
|
|
|
|
'status' => 10, |
|
|
|
|
'is_brand' => 1, |
|
|
|
|
'store_id' => $_GET['store_id'] |
|
|
|
|
])->select()->toArray(); |
|
|
|
|
'is_delete' => 0, |
|
|
|
|
'is_brand' => $_GET['is_brand'], |
|
|
|
|
'is_new' => $_GET['is_new'], |
|
|
|
|
'store_id' => $_GET['store_id'], |
|
|
|
|
'categoryId' => (int)$_GET['categoryId'], |
|
|
|
|
], 15); |
|
|
|
|
|
|
|
|
|
if (empty($goodsList) && $goodsList->isEmpty()) { |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
$list = $goodsList->toArray(); |
|
|
|
|
|
|
|
|
|
$list['data'] = $this->formatGoodsList($goodsList); |
|
|
|
|
return $list; |
|
|
|
|
// $list = $model->where([ |
|
|
|
|
// 'is_delete' => 0, |
|
|
|
|
// 'status' => 10, |
|
|
|
|
// 'is_brand' => 1, |
|
|
|
|
// 'store_id' => $_GET['store_id'] |
|
|
|
|
// ])->field('goods_name,sales_initial,sales_actual,goods_id,goods_price_min')->paginate($page)->toArray(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//新品首发 |
|
|
|
|
public function newList(): array |
|
|
|
|
|
|
|
|
|
//排行榜分类列表 一级 |
|
|
|
|
public function charts(): array |
|
|
|
|
{ |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
$model = new CategoryModel; |
|
|
|
|
|
|
|
|
|
$list = $model->where([ |
|
|
|
|
'is_delete' => 0, |
|
|
|
|
'status' => 10, |
|
|
|
|
'is_new' => 1, |
|
|
|
|
'parent_id' => 0, |
|
|
|
|
'status' => 1, |
|
|
|
|
'is_paihang' => 1, |
|
|
|
|
'store_id' => $_GET['store_id'] |
|
|
|
|
])->select()->toArray(); |
|
|
|
|
])->order('category_id desc')->select()->toArray(); |
|
|
|
|
|
|
|
|
|
return $list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//同城信息 |
|
|
|
|
public function cityInfo(): array |
|
|
|
|
|
|
|
|
|
public function chartsGoodsList() |
|
|
|
|
{ |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
$list = $model->where([ |
|
|
|
|
'is_delete' => 0, |
|
|
|
|
|
|
|
|
|
$goodsList = $model->getList([ |
|
|
|
|
'status' => 10, |
|
|
|
|
'is_brand' => 1, |
|
|
|
|
'store_id' => $_GET['store_id'] |
|
|
|
|
])->select()->toArray(); |
|
|
|
|
'is_delete' => 0, |
|
|
|
|
'paihang' => 1, |
|
|
|
|
'store_id' => $_GET['store_id'], |
|
|
|
|
'categoryId' => (int)$_GET['categoryId'], |
|
|
|
|
], 15); |
|
|
|
|
|
|
|
|
|
if (empty($goodsList) && $goodsList->isEmpty()) { |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
$list = $goodsList->toArray(); |
|
|
|
|
|
|
|
|
|
$list['data'] = $this->formatGoodsList($goodsList); |
|
|
|
|
return $list; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//抢购会场列表 |
|
|
|
|
public function panicList() |
|
|
|
|
public function chartsGoodsJing(): array |
|
|
|
|
{ |
|
|
|
|
$model = new SharpActiveModel; |
|
|
|
|
$list = $model->alias('a') |
|
|
|
|
->join('sharpActiveTime', 'a.active_id = sharpActiveTime.active_id', 'left')->where([ |
|
|
|
|
'a.is_delete' => 0, |
|
|
|
|
'a.status' => 1, |
|
|
|
|
'a.store_id' => $_GET['store_id'], |
|
|
|
|
'sharpActiveTime.status' => 1, |
|
|
|
|
])->select()->toArray(); |
|
|
|
|
$model = new CategoryModel; |
|
|
|
|
|
|
|
|
|
$list = $model->where([ |
|
|
|
|
'parent_id' => 0, |
|
|
|
|
'status' => 1, |
|
|
|
|
'is_paihang' => 1, |
|
|
|
|
'store_id' => $_GET['store_id'] |
|
|
|
|
])->order('category_id desc')->select()->toArray(); |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
foreach ($list as &$v) { |
|
|
|
|
$v['active_date'] = date('Y-m-d H:i:s', $v['active_date']); |
|
|
|
|
$goodsList = $model->getList([ |
|
|
|
|
'status' => 10, |
|
|
|
|
'is_delete' => 0, |
|
|
|
|
'paihang' => 1, |
|
|
|
|
'store_id' => $_GET['store_id'], |
|
|
|
|
'categoryId' => $v['category_id'], |
|
|
|
|
], 3); |
|
|
|
|
$list2 = $goodsList->toArray()['data']; |
|
|
|
|
|
|
|
|
|
$v['goods_list'] = $this->formatGoodsList($list2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//同城信息 |
|
|
|
|
public function cityInfo(): array |
|
|
|
|
{ |
|
|
|
|
$model = new ShopModel; |
|
|
|
|
$list = $model->where([ |
|
|
|
|
'is_delete' => 0, |
|
|
|
|
'status' => 1, |
|
|
|
|
'store_id' => $_GET['store_id'], |
|
|
|
|
'is_main' => 1, |
|
|
|
|
])->field('shop_name,star,shop_hours, |
|
|
|
|
province_id,city_id,region_id,shop_id,address,latitude,longitude')->find()->toArray(); |
|
|
|
|
|
|
|
|
|
return $list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// //抢购会场列表 |
|
|
|
|
// public function panicList() |
|
|
|
|
// { |
|
|
|
|
// //只拉第一个活动 |
|
|
|
|
// $model = new SharpActiveModel; |
|
|
|
|
// |
|
|
|
|
// $info = $model->alias('a') |
|
|
|
|
// ->where([ |
|
|
|
|
// 'a.is_delete' => 0, |
|
|
|
|
// 'a.status' => 1, |
|
|
|
|
// 'a.store_id' => $_GET['store_id'], |
|
|
|
|
//// 'sharpActiveTime.status' => 1, |
|
|
|
|
// ])->order(['a.active_id' => 'desc'])->find()->toArray(); |
|
|
|
|
// if (empty($info)) { |
|
|
|
|
// return []; |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// $info['create_date'] = date('Y-m-d H:i:s', $info['active_date']); |
|
|
|
|
// $aid = $info['active_id']; |
|
|
|
|
// $time = ActiveTimeModel::where([ |
|
|
|
|
// 'status' => 1, |
|
|
|
|
// 'active_id' => $aid, |
|
|
|
|
// ])->order('active_time asc')->select()->toArray(); |
|
|
|
|
// if (empty($time)) { |
|
|
|
|
// return []; |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// // 获取秒杀活动会场首页数据 |
|
|
|
|
// $service = new ActiveService; |
|
|
|
|
// |
|
|
|
|
//// $miaosha = $service->getGoodsListByActiveTimeId((int)$time[0]['active_time_id'])->toArray()['data'] ?? []; |
|
|
|
|
// |
|
|
|
|
// $info['create_time'] = date('Y-m-d', $info['active_date']) . ' ' . $time[0]['active_time'] . ':00'; |
|
|
|
|
// $info['lats_time'] = strtotime($info['create_time']) - time(); |
|
|
|
|
// $list['info'] = $info; |
|
|
|
|
// $list['detail'] = $time; |
|
|
|
|
// |
|
|
|
|
// return $list; |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 格式化商品列表 |
|
|
|
|
* @param $goodsList |
|
|
|
@ -152,11 +252,13 @@ class Goods extends GoodsService |
|
|
|
|
'line_price_min' => $goods['line_price_min'], |
|
|
|
|
'line_price_max' => $goods['line_price_max'], |
|
|
|
|
'goods_sales' => $goods['goods_sales'], |
|
|
|
|
'remaizhishu' => $goods['remaizhishu'], |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取商品推荐设置 |
|
|
|
|
* @return array |
|
|
|
@ -168,4 +270,4 @@ class Goods extends GoodsService |
|
|
|
|
{ |
|
|
|
|
return SettingModel::getItem(SettingEnum::RECOMMENDED); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|