Commit 8eee6802 authored by ZhuChunYang's avatar ZhuChunYang

update

parent a4e4d594
......@@ -13,6 +13,7 @@ use common\models\psources\CoinApplication;
use common\models\psources\CoinApplicationCategory;
use common\models\psources\CoinBanner;
use common\models\psources\CoinImage;
use service\risk\constant\CoinCate;
use Yii;
class ApplicationBusiness
{
......@@ -202,7 +203,7 @@ class ApplicationBusiness
{
$app_cate_Model = CoinAppCate::find();
$query = $app_cate_Model->JoinWith(['application'], false)
->select('cate_id,app_id,name,h5_icon,show_width,show_height,introduce_image,official_url,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,redirect_type,open_type,'.CoinAppCate::tableName().'.sort')
->select('cate_id,app_id,name,h5_icon,show_width,show_height,introduce_image,official_url,advertise,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,redirect_type,open_type,'.CoinAppCate::tableName().'.sort')
->orderBy(CoinAppCate::tableName().'.sort asc');
foreach ($condition as $item) {
$query = $query->andWhere($item);
......@@ -263,4 +264,39 @@ class ApplicationBusiness
}
return $rank;
}
public static function h5AppInfo($id)
{
$app_item = CoinApplication::getH5ApplicateById($id);
if($app_item){
if($app_item['h5_icon']){
$icon_item = CoinImage::getItemById($app_item['h5_icon']);
$app_item['h5_icon'] = $icon_item['base_url'].$icon_item['file_url'];
}else{
$app_item['h5_icon'] = "";
}
if($app_item['h5_image_ids']){
$image_items = CoinImage::getItemsByImageIds($app_item['h5_image_ids']);
$app_item['images'] = array_column($image_items['data'],'image_url');
}else{
$app_item['images'] =[];
}
unset($app_item['h5_image_ids']);
$app_user_num = self::getAppUserNum($id);
$app_item['app_user_num'] = $app_user_num;
$category_ids = CoinAppCate::getCateItemsByAppId($id);
$category_infos = CoinApplicationCategory::getCateItemsByIds($category_ids);
$category_names = '';
foreach($category_infos as $item){
if($category_names){
$category_names .= ','.$item['name'];
}else{
$category_names = $item['name'];
}
}
$app_item['category'] = $category_names;
}
return $app_item;
}
}
\ No newline at end of file
......@@ -69,5 +69,10 @@ class CoinAppCate extends BaseActiveRecord
}
}
public static function getCateItemsByAppId($app_id)
{
return array_column(self::find()->where(['app_id' => $app_id])->asArray()->all(),'cate_id');
}
}
\ No newline at end of file
......@@ -155,6 +155,12 @@ class CoinApplication extends BaseActiveRecord
->where(['like','name',$name])->asArray()->all(),null,'app_id');
}
public static function getH5ApplicateById($id)
{
return self::find()->where(['id' => $id])
->select('id,h5_icon,name,advertise,official_url,h5_image_ids,description,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url')
->asArray()->one();
}
}
\ No newline at end of file
......@@ -102,6 +102,11 @@ class CoinApplicationCategory extends BaseActiveRecord
return self::find()->orderBy('sort asc')->asArray()->all();
}
public static function getCateItemsByIds($ids)
{
return array_column(self::find()->where(['in','id',$ids])->asArray()->all(),null,'id');
}
......
......@@ -37,26 +37,45 @@ class ApplicationController extends BaseController
/**
* 分类下的应用列表
*/
public function actionGetH5AppsByCate()
public function actionGetAppsByCate()
{
$response_ = new ResponseBuild();
$request = Yii::$app->request;
$cate_id = $request->get('cate_id','');
$cate_info_data = [];
if($cate_id){
$cate_info = CoinApplicationCategory::getCategoryById($cate_id);
$cate_info_data['id'] = $cate_info->id;
$cate_info_data['name'] = $cate_info->name;
$appItems = ApplicationBusiness::getCateAppInfo(0,[['cate_id' => $cate_id]]);
if($appItems){
$appItems = array_shift($appItems);
foreach($appItems as &$value){
$value['app_user_num'] = ApplicationBusiness::getAppUserNum($value['app_id']);
if($cate_info){
$cate_info_data['id'] = $cate_info->id;
$cate_info_data['name'] = $cate_info->name;
$appItems = ApplicationBusiness::getH5CateAppInfo(0,[['cate_id' => $cate_id]]);
if($appItems){
$appItems = array_shift($appItems);
foreach($appItems as &$value){
$value['app_user_num'] = ApplicationBusiness::getAppUserNum($value['app_id']);
}
$cate_info_data['apps'] = $appItems;
}
$cate_info_data['apps'] = $appItems;
return ['code' => 0,'data' => $cate_info_data];
}
}
return ['code' => 0,'data' => []];
$response_->build(ResponseBuild::STATUS_SUCCEED, '', $cate_info_data);
return $response_;
}
/**
* 获取应用详情
*/
public function actionAppInfo()
{
$response_ = new ResponseBuild();
$request = Yii::$app->request;
$id = $request->post('id',0);
$data = [];
if($id){
$data = ApplicationBusiness::h5AppInfo($id);
}
$response_->build(ResponseBuild::STATUS_SUCCEED, '', $data);
return $response_;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment