73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: HIAPAD
|
|
* Date: 2018/9/25
|
|
* Time: 10:48
|
|
*/
|
|
|
|
namespace app\common\service;
|
|
|
|
|
|
use think\Db;
|
|
|
|
class ActivityService
|
|
{
|
|
public function getActivityList($user_info,$parames = [])
|
|
{
|
|
$_where = [];
|
|
$_where['online_status'] = 1;
|
|
if(isset($parames['activity_belong']) && $parames['activity_belong']){
|
|
$_where['activity_belong'] = $parames['activity_belong'];
|
|
}
|
|
if(isset($parames['activity_type']) && $parames['activity_type']){
|
|
$_where['activity_type'] = $parames['activity_type'];
|
|
}
|
|
if(isset($parames['is_self'])){
|
|
$_where['is_self'] = $parames['is_self'];
|
|
}
|
|
$_field = '';
|
|
$_field.='id,activity_name,activity_belong,activity_type,is_self,cover_img';
|
|
$result = Db::name('activity')
|
|
->field($_field)
|
|
->where($_where)
|
|
->order('sort_num','desc')
|
|
->select();
|
|
foreach ($result as $key=>$value)
|
|
{
|
|
$result[$key]['goods_list'] = [];
|
|
if($value['is_self']){
|
|
$search_data['current_page'] = 1;
|
|
$search_data['per_page'] = 6;
|
|
$search_data['activity_id'] = $value['id'];
|
|
$res = model(GoodsService::class)->getGoodsSearch($user_info,$search_data);
|
|
unset($res['code']);
|
|
unset($res['msg']);
|
|
unset($res['to_select']);
|
|
$result[$key]['goods_list'] = $res['data'];
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
public function getActivityInfo($parames)
|
|
{
|
|
$_field = '';
|
|
$_field.='id,activity_name,activity_belong,activity_type';
|
|
$info = Db::name('activity')
|
|
->field($_field)
|
|
->find($parames['id']);
|
|
$ids = Db::name('activity_goods_relation')->where('activity_id',$info['id'])->column('price_id');
|
|
$search_data['page'] = 1;
|
|
$search_data['limit'] = 20;
|
|
if(isset($parames['page']) && $parames['page']){
|
|
$search_data['page'] = $parames['page'];
|
|
}
|
|
if(isset($parames['limit']) && $parames['limit']){
|
|
$search_data['limit'] = $parames['limit'];
|
|
}
|
|
$search_data['inIds'] = $ids;
|
|
$info['goods_list'] = model(GoodsService::class)->getList($search_data);
|
|
return $info;
|
|
}
|
|
} |