Files
spacestation/common/libraries/entity/AutoProductEntity.php
T
2025-10-11 14:45:44 +08:00

268 lines
12 KiB
PHP

<?php
class AutoProductEntity
{
public $id;
public $title;
public $imgs;
public $brandId;
public $seriesId;
public $provinceId;
public $cityId;
public $countyId;
public $timeStart;
public $timeEnd;
public $timeLaunch;
public $crowdProfiling;
public $status;
public $cluesCommission;
public $orderCommission;
public $updateTime;
public $createTime;
public $cpsMoney;
//扩展信息
public $guide_price; //指导价
public $discounts; //优惠信息
public $discounts2; //优惠信息
public $discounts3; //优惠信息
public $promotion_text; //推广文案
public $posterBg; //海报背景图
public $banner; //banner图
public function __construct()
{
$ci = &get_instance();
$ci->load->model('area_model');
$ci->load->model('agent/auto_product_city_model', 'autoProductCity');
$ci->load->model('agent/auto_product_model', 'autoProduct');
$ci->load->model('agent/auto_product_setting_model', 'autoProductSetting');
$ci->load->model('auto/auto_brand_model', 'mdAutoBrand');
$ci->mdAutoBrand->set_db('ssdb');
$ci->load->model('auto/auto_series_model', 'mdAutoSeries');
$ci->mdAutoSeries->set_db('ssdb');
$autoProduct = new Auto_product_model();
foreach ($autoProduct::EXTEND_FIELDS as $key => $val) {
$value = $ci->autoProductSetting->getValue($this->id, $key);
$this->$key = $value ?: $val;
}
}
/**
* @return string
*/
public function getBrandName()
{
$ci = &get_instance();
$brand = $ci->mdAutoBrand->get(['id' => $this->brandId]);
return $brand ? $brand['name'] : '';
}
/**
* @return string
*/
public function getSeriesName()
{
$ci = &get_instance();
$series = $ci->mdAutoSeries->get(['id' => $this->seriesId]);
return $series ? $series['name'] : '';
}
/**
* 获取标签
* @return array
*/
public function getLabel()
{
$ci = &get_instance();
$ci->load->model('agent/auto_product_label_model', 'autoProductLabel');
$rows = $ci->autoProductLabel->select(['product_id' => $this->id], '', '', '', 'label_id');
$result = [];
if (!empty($rows)) {
foreach ($rows as $row) {
$result[] = intval($row['label_id']);
}
}
return $result;
}
/**
* 获取标签中文名称
* @return array
*/
public function getLabelName()
{
$ci = &get_instance();
$ci->load->model('agent/auto_product_label_model', 'autoProductLabel');
$rows = $ci->autoProductLabel->select(['product_id' => $this->id], '', '', '', 'label_id');
$result = [];
if (!empty($rows)) {
foreach ($rows as $row) {
$ids[] = intval($row['label_id']);
}
$idsString = implode(',', $ids);
if ($idsString) {
$ci->load->model('agent/admin/Market_sys_dictionary_data_model', 'mdSysDictionaryData');
$where = [
"dictDataId in ({$idsString})" => null,
"dictId in (select dictId from lc_market_sys_dictionary where dictCode in ('carProductLabel','productLevel'))" => null
];
$rows = $ci->mdSysDictionaryData->select($where, '', '', '', 'dictDataId,dictDataName');
foreach ($rows as $item) {
$result[] = $item['dictDataName'];
}
}
}
return $result;
}
/**
* 获取第一张banner图
* @return string
*/
public function getFirstBanner()
{
$banner = $this->banner ? explode(',', $this->banner) : [];
return $banner ? build_qiniu_image_url($banner[0]) : '';
}
/**
* 获取图片列表
* @return array
*/
public function getImagesList()
{
$imgs = $this->imgs ? explode(',', $this->imgs) : [];
$result = [];
if (!empty($imgs)) {
foreach ($imgs as $item) {
$result[] = build_qiniu_image_url($item);
}
}
return $result;
}
/**
* 获取一个优惠券信息
* @return array
*/
public function getOneCoupons($userId = '')
{
$ci = &get_instance();
$ci->load->model('agent/auto_product_coupon_model', 'autoProductCoupon');
$ci->load->model('agent/auto_user_coupon_model', 'autoUserCoupon');
$where = [
'product_id' => $this->id,
'status' => 1
];
/** @var AutoProductCouponEntity[] $rows */
$rows = $ci->autoProductCoupon->select($where, 'id desc', 1, 1, '', 'AutoProductCouponEntity');
$result = ['show' => 0];
if (!empty($rows)) {
$row = $rows[0];
$text = '立即领取';
$status = 1;
$count_down = 0;
if (strtotime($row->timeStart) < time() && strtotime($row->timeEnd) > time()) {
$count_down = strtotime($row->timeEnd) - time();
} else {
if (strtotime($row->timeStart) > time()) {
$text = '未开始';
$status = 2;
} else {
$text = '已结束';
$status = 3;
}
};
if ($userId && $ci->autoUserCoupon->count(['couponId' => $row->id, 'userId' => $userId])) {
$text = '领取成功';
$status = 4;
}
$result = [
'show' => 1,
'coupon_id' => $row->id,
'title' => $row->title,
'price' => intval($row->price),
'rule' => $row->rule ?: '<p>1. 购车补贴券只适用于平台指定的经销商门店</p>
<p>2. 购车补贴券只适用于标注的品牌和车型,不同品牌或车型补贴券不通用</p>
<p>3. 购车补贴券有效期90天,用户需在90天内完成购车方可享受补贴</p>
<p>4. 完成购车后,需在30天内完成资料上传方可享受补贴</p>',
'typeCn' => '超级车补专项补贴',
'timeStart' => date('Y-m-d', strtotime($row->timeStart)),
'timeEnd' => date('Y-m-d', strtotime($row->timeEnd)),
'activityProcess' => '<p><img src="https://img.liche.cn/space/agentadmin/202509/p_2678446e044d460f8ace75b52e1f5b51.png" alt=""/></p>
<h4><strong>在线领券</strong></h4><p>用户在超级车补平台查找选择意向品牌及车型,在车型详情页面领取对应的购车补贴券</p><br>
<h4><strong>到店购车</strong></h4><p>前往补贴券适用的门店进行选车、购车,并取得相应的购车资料</p>
<p>* 特别注意:购车补贴券为超级车补平台独立发放的购车补贴,与车辆的实际销售价无关,平台不为经销商门店的销售行为负责</p><br>
<h4><strong>上传资料</strong></h4><p>* 购车合同(若购车时为线上下单,无法提供购车合同,可提供线上订单截图)</p><p>* 机动车销售统一发票</p><br>
<h4><strong>获取补贴</strong></h4><p>资料审核通过后,按照要求绑定银行卡信息,平台将在一个工作日内完成补贴发放</p>',
'checkStandard' => '<h><strong>购车合同/线上订单截图</strong></h><p>1.须真实有效、字迹清晰、内容完整、加盖有效印鉴、不得人为故意遮挡或涂改</p>
<p>2.合同/订单截图的签约时间须符合活动规定的有效时间,签约手机号须与领券手机号一致</p>
<p>3.合同/订单截图中购买的品牌车型须与购车券对应的品牌车型一致</p>
<p>4.合同/订单截图中经销商门店信须在对应购车券指定适用门店范围内</p><br>
<h4><strong>机动车销售统一发票</strong></h4><p>1.发票为发票联原件照片或扫描,不能是复印件或其他联的照片或扫描件</p>
<p>2.开票时间须符合活动规定的有效时间</p>
<p>3.发票上购买用户姓名、证件号须与合同/订单截图信息一致,厂牌型号须与购车券适用品 牌车型一致</p>
<p>4.发票上销货单位须与下单时选择经销商、购车合同中的售卖方一致</p>',
'FAQ' => '<p>问:购车人与实名认证账户人不一致可以领取补贴吗?</p>
<p>答:仅限购车人本人领取补贴。</p>
<p>&nbsp;</p>
<p>问:如何领权益?先买车还是先领券?</p>
<p>答:领取补贴流程为:在线上领取补贴券,线下4S店交付定金、到店提车&mdash;上传凭证&mdash;审 核通过,领取补贴返现。如您已在4S店内交付定金,或已提车,再领补贴券是无法享 受补贴的。</p>
<p>&nbsp;</p>
<p>问:我申请的购车补贴什么时候审核?</p>
<p>答:补贴审核时效一般为自上传凭证起15个工作日内完成审核,因公平起见参与活动的订单依据上传凭证时间顺序进行审核,无法做加急处理,请您耐心等待,如遇特殊情况将会顺延审核时效。具体届时请参考实际页面的审核结果为准。</p>
<p>&nbsp;</p>
<p>问:同一天下单同一天购车可以吗?</p>
<p>答:下单日期必须早于在4S店缴纳定金或者购车日期,(部分品牌有特殊规则要求,明细 规则以商品详情页说明为准)。</p>
<p>&nbsp;</p>
<p>问:我到店了,4S店说不知道有这个活动怎么办?</p>
<p>答:本次活动为平安车主专项补贴权益(活动权益与4S店无关,无须询问4S店)。不影响 您正常到店自由议价和享受其他优惠。</p>
<p>&nbsp;</p>
<p>问:下单后在哪里查看订单?如何上传凭证?</p>
<p>答:通过活动页面进入【我的】-【我的订单】,可查看订单进度。【我的】-【我的补贴】, 可根据提示上传相关凭证进行审核。</p>',
'getNun' => $ci->autoUserCoupon->count(['couponId' => $row->id]),
'bizTip' => $row->getBizTip(),
'count_down' => $count_down * 1000,
'btn_info' => [
'text' => $text,
'status' => $status,
],
'bizList' => $row->getBizList(1, 1),
'hasMoreBiz' => $row
];
}
return $result;
}
/**
* 获取推广城市
* @return array
*/
public function getProvinceCity()
{
$ci = &get_instance();
$cityList = $ci->autoProductCity->select(['productId' => $this->id]);
$provinceCityIds = [];
$cityNames = [];
if ($cityList) {
$cityIds = implode(',', array_column($cityList, 'cityId'));
if ($cityIds) {
$where = [
"city_id in ($cityIds)" => null
];
$citys = $ci->area_model->map('city_id', '', $where, '', '', '', 'DISTINCT city_id,city_name');
}
foreach ($cityList as $item) {
$provinceCityIds[] = [$item['provinceId'], $item['cityId']];
$city = $citys[$item['cityId']] ? $citys[$item['cityId']][0] : [];
if ($city) {
$cityNames[] = $city['city_name'];
}
}
}
$result = ['provinceCityIds' => $provinceCityIds, 'cityNames' => $cityNames];
return $result;
}
}