Files
spacestation/common/models/receiver/Receiver_enroll_model.php
2025-07-30 10:57:00 +08:00

40 lines
1.2 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Receiver_enroll_model extends HD_Model
{
private $table_name = 'lc_receiver_enroll';
public function __construct()
{
parent::__construct($this->table_name, 'default');
$this->load->model('auto/auto_brand_model');
$this->load->model('auto/auto_series_model');
}
/**
* 获取手机号关注品牌
* @param $mobile
* @return array
*/
public function getBrandsByMobile($mobile)
{
$where = [
'mobile' => $mobile
];
$rows = $this->select($where, 'id desc', '', '', 'DISTINCT brand_id,series_id');
$brandList = [];
if($rows){
$brands = $this->auto_brand_model->get_map_by_ids(array_column($rows, 'brand_id'));
$series = $this->auto_series_model->get_map_by_ids(array_column($rows, 'series_id'));
foreach ($rows as $v) {
$brandName = $brands[$v['brand_id']] ? $brands[$v['brand_id']][0]['name'] : '';
$seriesName = $series[$v['series_id']] ? $series[$v['series_id']][0]['name'] : '';
$brandList[] = "$brandName-$seriesName";
}
}
return $brandList;
}
}